Skip to content
This repository was archived by the owner on Sep 9, 2024. It is now read-only.

Commit c59a125

Browse files
committed
fix: local git validation
1 parent 4bbc0c5 commit c59a125

File tree

1 file changed

+77
-0
lines changed

1 file changed

+77
-0
lines changed

src/middlewares/joi/index.ts

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@ const allowedActions = [
77
'entriesByFolder',
88
'entriesByFiles',
99
'getEntry',
10+
'unpublishedEntries',
11+
'unpublishedEntry',
12+
'unpublishedEntryDataFile',
13+
'unpublishedEntryMediaFile',
14+
'deleteUnpublishedEntry',
1015
'persistEntry',
16+
'updateUnpublishedEntryStatus',
17+
'publishUnpublishedEntry',
1118
'getMedia',
1219
'getMediaFile',
1320
'persistMedia',
@@ -18,6 +25,7 @@ const allowedActions = [
1825

1926
const requiredString = Joi.string().required();
2027
const requiredNumber = Joi.number().required();
28+
const requiredBool = Joi.bool().required();
2129

2230
const collection = requiredString;
2331
const slug = requiredString;
@@ -72,21 +80,90 @@ export function defaultSchema({ path = requiredString } = {}) {
7280
})
7381
.required(),
7482
},
83+
{
84+
is: 'unpublishedEntries',
85+
then: defaultParams.keys({ branch: requiredString }).required(),
86+
},
87+
{
88+
is: 'unpublishedEntry',
89+
then: defaultParams
90+
.keys({
91+
id: Joi.string().optional(),
92+
collection: Joi.string().optional(),
93+
slug: Joi.string().optional(),
94+
cmsLabelPrefix: Joi.string().optional(),
95+
})
96+
.required(),
97+
},
98+
{
99+
is: 'unpublishedEntryDataFile',
100+
then: defaultParams
101+
.keys({
102+
collection,
103+
slug,
104+
id: requiredString,
105+
path: requiredString,
106+
})
107+
.required(),
108+
},
109+
{
110+
is: 'unpublishedEntryMediaFile',
111+
then: defaultParams
112+
.keys({
113+
collection,
114+
slug,
115+
id: requiredString,
116+
path: requiredString,
117+
})
118+
.required(),
119+
},
120+
{
121+
is: 'deleteUnpublishedEntry',
122+
then: defaultParams
123+
.keys({
124+
collection,
125+
slug,
126+
})
127+
.required(),
128+
},
75129
{
76130
is: 'persistEntry',
77131
then: defaultParams
78132
.keys({
133+
cmsLabelPrefix: Joi.string().optional(),
79134
entry: dataFile, // entry is kept for backwards compatibility
80135
dataFiles: Joi.array().items(dataFile),
81136
assets: Joi.array().items(asset).required(),
82137
options: Joi.object({
83138
collectionName: Joi.string(),
84139
commitMessage: requiredString,
140+
useWorkflow: requiredBool,
141+
status: requiredString,
85142
}).required(),
86143
})
87144
.xor('entry', 'dataFiles')
88145
.required(),
89146
},
147+
{
148+
is: 'updateUnpublishedEntryStatus',
149+
then: defaultParams
150+
.keys({
151+
collection,
152+
slug,
153+
newStatus: requiredString,
154+
cmsLabelPrefix: Joi.string().optional(),
155+
})
156+
.required(),
157+
},
158+
{
159+
is: 'publishUnpublishedEntry',
160+
then: defaultParams
161+
.keys({
162+
collection,
163+
slug,
164+
})
165+
.required(),
166+
},
90167
{
91168
is: 'getMedia',
92169
then: defaultParams

0 commit comments

Comments
 (0)