@seshuk/payload-plugin-openapi 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +595 -0
- package/dist/bin/generateSpec.d.ts +25 -0
- package/dist/bin/generateSpec.js +61 -0
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +2 -0
- package/dist/endpoints/interactiveAuth.d.ts +4 -0
- package/dist/endpoints/interactiveAuth.js +27 -0
- package/dist/endpoints/spec.d.ts +5 -0
- package/dist/endpoints/spec.js +39 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +67 -0
- package/dist/options.d.ts +2 -0
- package/dist/options.js +44 -0
- package/dist/spec/build.d.ts +14 -0
- package/dist/spec/build.js +36 -0
- package/dist/spec/buildDocument.d.ts +15 -0
- package/dist/spec/buildDocument.js +234 -0
- package/dist/spec/components.d.ts +46 -0
- package/dist/spec/components.js +280 -0
- package/dist/spec/downconvert.d.ts +3 -0
- package/dist/spec/downconvert.js +55 -0
- package/dist/spec/entitySchemas.d.ts +15 -0
- package/dist/spec/entitySchemas.js +246 -0
- package/dist/spec/fields.d.ts +5 -0
- package/dist/spec/fields.js +44 -0
- package/dist/spec/filters.d.ts +11 -0
- package/dist/spec/filters.js +74 -0
- package/dist/spec/names.d.ts +14 -0
- package/dist/spec/names.js +37 -0
- package/dist/spec/params.d.ts +47 -0
- package/dist/spec/params.js +344 -0
- package/dist/spec/paths/auth.d.ts +9 -0
- package/dist/spec/paths/auth.js +285 -0
- package/dist/spec/paths/collections.d.ts +7 -0
- package/dist/spec/paths/collections.js +261 -0
- package/dist/spec/paths/custom.d.ts +9 -0
- package/dist/spec/paths/custom.js +41 -0
- package/dist/spec/paths/globals.d.ts +7 -0
- package/dist/spec/paths/globals.js +68 -0
- package/dist/spec/paths/jobs.d.ts +7 -0
- package/dist/spec/paths/jobs.js +130 -0
- package/dist/spec/paths/versions.d.ts +18 -0
- package/dist/spec/paths/versions.js +243 -0
- package/dist/spec/tags.d.ts +27 -0
- package/dist/spec/tags.js +79 -0
- package/dist/translations/index.d.ts +6 -0
- package/dist/translations/index.js +96 -0
- package/dist/translations/locales/ar.d.ts +2 -0
- package/dist/translations/locales/ar.js +76 -0
- package/dist/translations/locales/az.d.ts +2 -0
- package/dist/translations/locales/az.js +76 -0
- package/dist/translations/locales/bg.d.ts +2 -0
- package/dist/translations/locales/bg.js +76 -0
- package/dist/translations/locales/bnBd.d.ts +2 -0
- package/dist/translations/locales/bnBd.js +76 -0
- package/dist/translations/locales/bnIn.d.ts +2 -0
- package/dist/translations/locales/bnIn.js +76 -0
- package/dist/translations/locales/ca.d.ts +2 -0
- package/dist/translations/locales/ca.js +76 -0
- package/dist/translations/locales/cs.d.ts +2 -0
- package/dist/translations/locales/cs.js +76 -0
- package/dist/translations/locales/da.d.ts +2 -0
- package/dist/translations/locales/da.js +76 -0
- package/dist/translations/locales/de.d.ts +2 -0
- package/dist/translations/locales/de.js +76 -0
- package/dist/translations/locales/en.d.ts +2 -0
- package/dist/translations/locales/en.js +76 -0
- package/dist/translations/locales/es.d.ts +2 -0
- package/dist/translations/locales/es.js +76 -0
- package/dist/translations/locales/et.d.ts +2 -0
- package/dist/translations/locales/et.js +76 -0
- package/dist/translations/locales/fa.d.ts +2 -0
- package/dist/translations/locales/fa.js +76 -0
- package/dist/translations/locales/fr.d.ts +2 -0
- package/dist/translations/locales/fr.js +76 -0
- package/dist/translations/locales/he.d.ts +2 -0
- package/dist/translations/locales/he.js +76 -0
- package/dist/translations/locales/hr.d.ts +2 -0
- package/dist/translations/locales/hr.js +76 -0
- package/dist/translations/locales/hu.d.ts +2 -0
- package/dist/translations/locales/hu.js +76 -0
- package/dist/translations/locales/hy.d.ts +2 -0
- package/dist/translations/locales/hy.js +76 -0
- package/dist/translations/locales/id.d.ts +2 -0
- package/dist/translations/locales/id.js +76 -0
- package/dist/translations/locales/is.d.ts +2 -0
- package/dist/translations/locales/is.js +76 -0
- package/dist/translations/locales/it.d.ts +2 -0
- package/dist/translations/locales/it.js +76 -0
- package/dist/translations/locales/ja.d.ts +2 -0
- package/dist/translations/locales/ja.js +76 -0
- package/dist/translations/locales/ko.d.ts +2 -0
- package/dist/translations/locales/ko.js +76 -0
- package/dist/translations/locales/lt.d.ts +2 -0
- package/dist/translations/locales/lt.js +76 -0
- package/dist/translations/locales/lv.d.ts +2 -0
- package/dist/translations/locales/lv.js +76 -0
- package/dist/translations/locales/my.d.ts +2 -0
- package/dist/translations/locales/my.js +76 -0
- package/dist/translations/locales/nb.d.ts +2 -0
- package/dist/translations/locales/nb.js +76 -0
- package/dist/translations/locales/nl.d.ts +2 -0
- package/dist/translations/locales/nl.js +76 -0
- package/dist/translations/locales/pl.d.ts +2 -0
- package/dist/translations/locales/pl.js +76 -0
- package/dist/translations/locales/pt.d.ts +2 -0
- package/dist/translations/locales/pt.js +76 -0
- package/dist/translations/locales/ro.d.ts +2 -0
- package/dist/translations/locales/ro.js +76 -0
- package/dist/translations/locales/rs.d.ts +2 -0
- package/dist/translations/locales/rs.js +76 -0
- package/dist/translations/locales/rsLatin.d.ts +2 -0
- package/dist/translations/locales/rsLatin.js +76 -0
- package/dist/translations/locales/ru.d.ts +2 -0
- package/dist/translations/locales/ru.js +76 -0
- package/dist/translations/locales/sk.d.ts +2 -0
- package/dist/translations/locales/sk.js +76 -0
- package/dist/translations/locales/sl.d.ts +2 -0
- package/dist/translations/locales/sl.js +76 -0
- package/dist/translations/locales/sv.d.ts +2 -0
- package/dist/translations/locales/sv.js +76 -0
- package/dist/translations/locales/ta.d.ts +2 -0
- package/dist/translations/locales/ta.js +76 -0
- package/dist/translations/locales/th.d.ts +2 -0
- package/dist/translations/locales/th.js +76 -0
- package/dist/translations/locales/tr.d.ts +2 -0
- package/dist/translations/locales/tr.js +76 -0
- package/dist/translations/locales/uk.d.ts +2 -0
- package/dist/translations/locales/uk.js +76 -0
- package/dist/translations/locales/vi.d.ts +2 -0
- package/dist/translations/locales/vi.js +76 -0
- package/dist/translations/locales/zh.d.ts +2 -0
- package/dist/translations/locales/zh.js +76 -0
- package/dist/translations/locales/zhTw.d.ts +2 -0
- package/dist/translations/locales/zhTw.js +76 -0
- package/dist/translations/types.d.ts +82 -0
- package/dist/translations/types.js +1 -0
- package/dist/types.d.ts +183 -0
- package/dist/types.js +1 -0
- package/dist/ui/createUiPlugin.d.ts +14 -0
- package/dist/ui/createUiPlugin.js +28 -0
- package/dist/ui/html.d.ts +8 -0
- package/dist/ui/html.js +8 -0
- package/dist/ui/scalar.d.ts +1 -0
- package/dist/ui/scalar.js +12 -0
- package/dist/ui/swagger.d.ts +1 -0
- package/dist/ui/swagger.js +12 -0
- package/dist/utils.d.ts +3 -0
- package/dist/utils.js +13 -0
- package/package.json +84 -0
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { makeT } from "../../translations/index.js";
|
|
2
|
+
import { errorResponses, jsonResponse } from "../components.js";
|
|
3
|
+
const boolParam = (name, description)=>({
|
|
4
|
+
name,
|
|
5
|
+
in: 'query',
|
|
6
|
+
description,
|
|
7
|
+
schema: {
|
|
8
|
+
type: 'boolean'
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const collectQueues = (jobs)=>{
|
|
12
|
+
const queues = new Set([
|
|
13
|
+
'default'
|
|
14
|
+
]);
|
|
15
|
+
const add = (q)=>{
|
|
16
|
+
if ('string' == typeof q && q) queues.add(q);
|
|
17
|
+
};
|
|
18
|
+
const fromSchedules = (items)=>{
|
|
19
|
+
if (!Array.isArray(items)) return;
|
|
20
|
+
for (const item of items)for (const s of item.schedule ?? [])add(s.queue);
|
|
21
|
+
};
|
|
22
|
+
fromSchedules(jobs?.tasks);
|
|
23
|
+
fromSchedules(jobs?.workflows);
|
|
24
|
+
const autoRun = jobs?.autoRun;
|
|
25
|
+
if (Array.isArray(autoRun)) for (const cron of autoRun)add(cron.queue);
|
|
26
|
+
const processingOrder = jobs?.processingOrder;
|
|
27
|
+
if (processingOrder?.queues) for (const name of Object.keys(processingOrder.queues))add(name);
|
|
28
|
+
return [
|
|
29
|
+
...queues
|
|
30
|
+
].toSorted();
|
|
31
|
+
};
|
|
32
|
+
const queueParam = (queues, ctx)=>({
|
|
33
|
+
name: 'queue',
|
|
34
|
+
in: 'query',
|
|
35
|
+
description: makeT(ctx.i18n)('jobsQueue', {
|
|
36
|
+
queues: queues.map((q)=>`\`${q}\``).join(', ')
|
|
37
|
+
}),
|
|
38
|
+
schema: {
|
|
39
|
+
type: 'string',
|
|
40
|
+
enum: queues
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
const buildJobsPaths = ({ config, ctx })=>{
|
|
44
|
+
const jobs = config.jobs;
|
|
45
|
+
const hasJobs = Boolean(jobs?.tasks?.length || jobs?.workflows?.length);
|
|
46
|
+
if (!hasJobs) return {};
|
|
47
|
+
const t = makeT(ctx.i18n);
|
|
48
|
+
const queue = queueParam(collectQueues(jobs), ctx);
|
|
49
|
+
const errors = errorResponses([
|
|
50
|
+
'401',
|
|
51
|
+
'403',
|
|
52
|
+
'500'
|
|
53
|
+
], t);
|
|
54
|
+
return {
|
|
55
|
+
[`${ctx.apiRoute}/payload-jobs/run`]: {
|
|
56
|
+
get: {
|
|
57
|
+
tags: [
|
|
58
|
+
'Jobs'
|
|
59
|
+
],
|
|
60
|
+
operationId: 'runJobs',
|
|
61
|
+
summary: t('jobsRunSummary'),
|
|
62
|
+
parameters: [
|
|
63
|
+
queue,
|
|
64
|
+
boolParam('allQueues', t('jobsRunAllQueues')),
|
|
65
|
+
{
|
|
66
|
+
name: 'limit',
|
|
67
|
+
in: 'query',
|
|
68
|
+
description: t('jobsLimit'),
|
|
69
|
+
schema: {
|
|
70
|
+
type: 'integer'
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
boolParam('disableScheduling', t('jobsDisableScheduling')),
|
|
74
|
+
boolParam('silent', t('jobsSilent'))
|
|
75
|
+
],
|
|
76
|
+
responses: {
|
|
77
|
+
200: jsonResponse(t('jobsRunResult'), {
|
|
78
|
+
type: 'object',
|
|
79
|
+
properties: {
|
|
80
|
+
message: {
|
|
81
|
+
type: 'string'
|
|
82
|
+
},
|
|
83
|
+
noJobsRemaining: {
|
|
84
|
+
type: 'boolean'
|
|
85
|
+
},
|
|
86
|
+
remainingJobsFromQueried: {
|
|
87
|
+
type: 'integer'
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}),
|
|
91
|
+
...errors
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
[`${ctx.apiRoute}/payload-jobs/handle-schedules`]: {
|
|
96
|
+
get: {
|
|
97
|
+
tags: [
|
|
98
|
+
'Jobs'
|
|
99
|
+
],
|
|
100
|
+
operationId: 'handleJobSchedules',
|
|
101
|
+
summary: t('jobsSchedulesSummary'),
|
|
102
|
+
parameters: [
|
|
103
|
+
queue,
|
|
104
|
+
boolParam('allQueues', t('jobsSchedulesAllQueues'))
|
|
105
|
+
],
|
|
106
|
+
responses: {
|
|
107
|
+
200: jsonResponse(t('jobsSchedulesResult'), {
|
|
108
|
+
type: 'object',
|
|
109
|
+
properties: {
|
|
110
|
+
message: {
|
|
111
|
+
type: 'string'
|
|
112
|
+
},
|
|
113
|
+
queued: {
|
|
114
|
+
type: 'integer'
|
|
115
|
+
},
|
|
116
|
+
errored: {
|
|
117
|
+
type: 'integer'
|
|
118
|
+
},
|
|
119
|
+
skipped: {
|
|
120
|
+
type: 'integer'
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}),
|
|
124
|
+
...errors
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
export { buildJobsPaths };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { PathsObject, SchemaObject } from '@scalar/openapi-types/3.2';
|
|
2
|
+
import type { BuildContext, Entity, IDType } from '../../types.js';
|
|
3
|
+
export interface VersionSchemas {
|
|
4
|
+
version: SchemaObject;
|
|
5
|
+
versionList: SchemaObject;
|
|
6
|
+
}
|
|
7
|
+
export declare const versionComponentSchemas: ({ docBase, base, idType, }: {
|
|
8
|
+
docBase: string;
|
|
9
|
+
base: string;
|
|
10
|
+
idType: IDType;
|
|
11
|
+
}) => VersionSchemas;
|
|
12
|
+
export declare const buildVersionPaths: ({ entity, pathBase, ctx, schemaBase, nestedTags, }: {
|
|
13
|
+
entity: Entity;
|
|
14
|
+
pathBase: string;
|
|
15
|
+
ctx: BuildContext;
|
|
16
|
+
schemaBase?: string;
|
|
17
|
+
nestedTags: boolean;
|
|
18
|
+
}) => PathsObject;
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import { makeT } from "../../translations/index.js";
|
|
2
|
+
import { ERRORS, errorResponses, jsonResponse, nullableType } from "../components.js";
|
|
3
|
+
import { refTo, schemaName } from "../names.js";
|
|
4
|
+
import { buildParamSchemas, commonReadParams } from "../params.js";
|
|
5
|
+
import { versionsTagName } from "../tags.js";
|
|
6
|
+
const buildVersionSchema = (base, idType)=>{
|
|
7
|
+
const id = {
|
|
8
|
+
type: 'number' === idType ? 'integer' : 'string'
|
|
9
|
+
};
|
|
10
|
+
return {
|
|
11
|
+
type: 'object',
|
|
12
|
+
properties: {
|
|
13
|
+
id,
|
|
14
|
+
parent: id,
|
|
15
|
+
version: {
|
|
16
|
+
$ref: refTo(base)
|
|
17
|
+
},
|
|
18
|
+
createdAt: {
|
|
19
|
+
type: 'string',
|
|
20
|
+
format: 'date-time'
|
|
21
|
+
},
|
|
22
|
+
updatedAt: {
|
|
23
|
+
type: 'string',
|
|
24
|
+
format: 'date-time'
|
|
25
|
+
},
|
|
26
|
+
latest: {
|
|
27
|
+
type: 'boolean'
|
|
28
|
+
},
|
|
29
|
+
autosave: {
|
|
30
|
+
type: 'boolean'
|
|
31
|
+
},
|
|
32
|
+
snapshot: {
|
|
33
|
+
type: 'boolean'
|
|
34
|
+
},
|
|
35
|
+
publishedLocale: {
|
|
36
|
+
type: 'string'
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
required: [
|
|
40
|
+
'id',
|
|
41
|
+
'parent',
|
|
42
|
+
'version',
|
|
43
|
+
'createdAt',
|
|
44
|
+
'updatedAt'
|
|
45
|
+
]
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
const buildVersionListSchema = (base)=>({
|
|
49
|
+
type: 'object',
|
|
50
|
+
properties: {
|
|
51
|
+
docs: {
|
|
52
|
+
type: 'array',
|
|
53
|
+
items: {
|
|
54
|
+
$ref: refTo(`${base}Version`)
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
totalDocs: {
|
|
58
|
+
type: 'integer'
|
|
59
|
+
},
|
|
60
|
+
limit: {
|
|
61
|
+
type: 'integer'
|
|
62
|
+
},
|
|
63
|
+
totalPages: {
|
|
64
|
+
type: 'integer'
|
|
65
|
+
},
|
|
66
|
+
page: {
|
|
67
|
+
type: 'integer'
|
|
68
|
+
},
|
|
69
|
+
pagingCounter: {
|
|
70
|
+
type: 'integer'
|
|
71
|
+
},
|
|
72
|
+
hasPrevPage: {
|
|
73
|
+
type: 'boolean'
|
|
74
|
+
},
|
|
75
|
+
hasNextPage: {
|
|
76
|
+
type: 'boolean'
|
|
77
|
+
},
|
|
78
|
+
prevPage: nullableType('integer'),
|
|
79
|
+
nextPage: nullableType('integer')
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
const versionComponentSchemas = ({ docBase, base, idType })=>({
|
|
83
|
+
version: buildVersionSchema(docBase, idType),
|
|
84
|
+
versionList: buildVersionListSchema(base)
|
|
85
|
+
});
|
|
86
|
+
const versionRef = (base)=>({
|
|
87
|
+
$ref: refTo(`${base}Version`)
|
|
88
|
+
});
|
|
89
|
+
const versionListRef = (base)=>({
|
|
90
|
+
$ref: refTo(`${base}VersionList`)
|
|
91
|
+
});
|
|
92
|
+
const listVersionParams = ({ base, ctx, refs })=>{
|
|
93
|
+
const t = makeT(ctx.i18n);
|
|
94
|
+
return [
|
|
95
|
+
{
|
|
96
|
+
name: 'page',
|
|
97
|
+
in: 'query',
|
|
98
|
+
schema: {
|
|
99
|
+
type: 'integer'
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
name: 'limit',
|
|
104
|
+
in: 'query',
|
|
105
|
+
schema: {
|
|
106
|
+
type: 'integer'
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
name: 'pagination',
|
|
111
|
+
in: 'query',
|
|
112
|
+
schema: {
|
|
113
|
+
type: 'boolean'
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
name: 'sort',
|
|
118
|
+
in: 'query',
|
|
119
|
+
description: t('paramSortShort'),
|
|
120
|
+
schema: {
|
|
121
|
+
type: 'string'
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
...commonReadParams({
|
|
125
|
+
base,
|
|
126
|
+
ctx,
|
|
127
|
+
refs
|
|
128
|
+
}),
|
|
129
|
+
{
|
|
130
|
+
name: 'where',
|
|
131
|
+
in: 'query',
|
|
132
|
+
description: t('versionWhere'),
|
|
133
|
+
content: {
|
|
134
|
+
'application/json': {
|
|
135
|
+
schema: {
|
|
136
|
+
type: 'object',
|
|
137
|
+
additionalProperties: true
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
];
|
|
143
|
+
};
|
|
144
|
+
const buildVersionPaths = ({ entity, pathBase, ctx, schemaBase, nestedTags })=>{
|
|
145
|
+
if (!entity.versions) return {};
|
|
146
|
+
const t = makeT(ctx.i18n);
|
|
147
|
+
const name = schemaBase ?? schemaName(entity.slug);
|
|
148
|
+
const versionsTag = [
|
|
149
|
+
nestedTags ? versionsTagName(name) : name
|
|
150
|
+
];
|
|
151
|
+
const paramSchemas = buildParamSchemas({
|
|
152
|
+
fields: entity.fields,
|
|
153
|
+
ctx
|
|
154
|
+
});
|
|
155
|
+
const refs = {
|
|
156
|
+
select: true,
|
|
157
|
+
populate: Boolean(paramSchemas.populate),
|
|
158
|
+
joins: Boolean(paramSchemas.joins)
|
|
159
|
+
};
|
|
160
|
+
const idParam = {
|
|
161
|
+
name: 'id',
|
|
162
|
+
in: 'path',
|
|
163
|
+
required: true,
|
|
164
|
+
schema: {
|
|
165
|
+
type: 'number' === ctx.defaultIDType ? 'integer' : 'string'
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
const restoreResponse = {
|
|
169
|
+
allOf: [
|
|
170
|
+
{
|
|
171
|
+
$ref: refTo(name)
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
type: 'object',
|
|
175
|
+
properties: {
|
|
176
|
+
message: {
|
|
177
|
+
type: 'string'
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
]
|
|
182
|
+
};
|
|
183
|
+
return {
|
|
184
|
+
[`${pathBase}/versions`]: {
|
|
185
|
+
get: {
|
|
186
|
+
tags: versionsTag,
|
|
187
|
+
operationId: `find${name}Versions`,
|
|
188
|
+
parameters: listVersionParams({
|
|
189
|
+
base: name,
|
|
190
|
+
ctx,
|
|
191
|
+
refs
|
|
192
|
+
}),
|
|
193
|
+
responses: {
|
|
194
|
+
200: jsonResponse(t('versionList'), versionListRef(name)),
|
|
195
|
+
...errorResponses(ERRORS.versionList, t)
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
[`${pathBase}/versions/{id}`]: {
|
|
200
|
+
parameters: [
|
|
201
|
+
idParam
|
|
202
|
+
],
|
|
203
|
+
get: {
|
|
204
|
+
tags: versionsTag,
|
|
205
|
+
operationId: `find${name}VersionById`,
|
|
206
|
+
parameters: commonReadParams({
|
|
207
|
+
base: name,
|
|
208
|
+
ctx,
|
|
209
|
+
refs
|
|
210
|
+
}),
|
|
211
|
+
responses: {
|
|
212
|
+
200: jsonResponse(t('versionSingle'), versionRef(name)),
|
|
213
|
+
...errorResponses(ERRORS.versionRead, t)
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
post: {
|
|
217
|
+
tags: versionsTag,
|
|
218
|
+
operationId: `restore${name}Version`,
|
|
219
|
+
parameters: [
|
|
220
|
+
{
|
|
221
|
+
name: 'depth',
|
|
222
|
+
in: 'query',
|
|
223
|
+
schema: {
|
|
224
|
+
type: 'integer'
|
|
225
|
+
}
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
name: 'draft',
|
|
229
|
+
in: 'query',
|
|
230
|
+
schema: {
|
|
231
|
+
type: 'boolean'
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
],
|
|
235
|
+
responses: {
|
|
236
|
+
200: jsonResponse(t('versionRestored'), restoreResponse),
|
|
237
|
+
...errorResponses(ERRORS.versionRestore, t)
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
};
|
|
243
|
+
export { buildVersionPaths, versionComponentSchemas };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { TagObject } from '@scalar/openapi-types/3.2';
|
|
2
|
+
import type { Translate } from '../translations/types.js';
|
|
3
|
+
export declare const NAV_COLLECTIONS = "Collections";
|
|
4
|
+
export declare const NAV_GLOBALS = "Globals";
|
|
5
|
+
export declare const NAV_SYSTEM = "System";
|
|
6
|
+
export declare const entityTagName: (base: string) => string;
|
|
7
|
+
export declare const authTagName: (base: string) => string;
|
|
8
|
+
export declare const versionsTagName: (base: string) => string;
|
|
9
|
+
export interface CollectionTagInfo {
|
|
10
|
+
base: string;
|
|
11
|
+
hasAuth: boolean;
|
|
12
|
+
hasVersions: boolean;
|
|
13
|
+
description?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface GlobalTagInfo {
|
|
16
|
+
base: string;
|
|
17
|
+
hasVersions: boolean;
|
|
18
|
+
description?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface TagHierarchyInput {
|
|
21
|
+
collections: CollectionTagInfo[];
|
|
22
|
+
globals: GlobalTagInfo[];
|
|
23
|
+
hasJobs: boolean;
|
|
24
|
+
t: Translate;
|
|
25
|
+
nested: boolean;
|
|
26
|
+
}
|
|
27
|
+
export declare const buildTagHierarchy: ({ collections, globals, hasJobs, t, nested }: TagHierarchyInput) => TagObject[];
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
const NAV_COLLECTIONS = 'Collections';
|
|
2
|
+
const NAV_GLOBALS = 'Globals';
|
|
3
|
+
const NAV_SYSTEM = 'System';
|
|
4
|
+
const entityTagName = (base)=>base;
|
|
5
|
+
const authTagName = (base)=>`${base} Auth`;
|
|
6
|
+
const versionsTagName = (base)=>`${base} Versions`;
|
|
7
|
+
const buildTagHierarchy = ({ collections, globals, hasJobs, t, nested })=>{
|
|
8
|
+
if (!nested) return [
|
|
9
|
+
...collections.map((c)=>({
|
|
10
|
+
name: entityTagName(c.base),
|
|
11
|
+
description: c.description
|
|
12
|
+
})),
|
|
13
|
+
...globals.map((g)=>({
|
|
14
|
+
name: entityTagName(g.base),
|
|
15
|
+
description: g.description
|
|
16
|
+
}))
|
|
17
|
+
];
|
|
18
|
+
const tags = [];
|
|
19
|
+
if (collections.length > 0) {
|
|
20
|
+
tags.push({
|
|
21
|
+
name: NAV_COLLECTIONS,
|
|
22
|
+
summary: t('tagCollections'),
|
|
23
|
+
description: t('tagCollectionsDesc'),
|
|
24
|
+
kind: 'nav'
|
|
25
|
+
});
|
|
26
|
+
for (const c of collections){
|
|
27
|
+
tags.push({
|
|
28
|
+
name: entityTagName(c.base),
|
|
29
|
+
parent: NAV_COLLECTIONS,
|
|
30
|
+
description: c.description
|
|
31
|
+
});
|
|
32
|
+
if (c.hasAuth) tags.push({
|
|
33
|
+
name: authTagName(c.base),
|
|
34
|
+
parent: c.base,
|
|
35
|
+
summary: t('tagAuth')
|
|
36
|
+
});
|
|
37
|
+
if (c.hasVersions) tags.push({
|
|
38
|
+
name: versionsTagName(c.base),
|
|
39
|
+
parent: c.base,
|
|
40
|
+
summary: t('tagVersions')
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (globals.length > 0) {
|
|
45
|
+
tags.push({
|
|
46
|
+
name: NAV_GLOBALS,
|
|
47
|
+
summary: t('tagGlobals'),
|
|
48
|
+
description: t('tagGlobalsDesc'),
|
|
49
|
+
kind: 'nav'
|
|
50
|
+
});
|
|
51
|
+
for (const g of globals){
|
|
52
|
+
tags.push({
|
|
53
|
+
name: entityTagName(g.base),
|
|
54
|
+
parent: NAV_GLOBALS,
|
|
55
|
+
description: g.description
|
|
56
|
+
});
|
|
57
|
+
if (g.hasVersions) tags.push({
|
|
58
|
+
name: versionsTagName(g.base),
|
|
59
|
+
parent: g.base,
|
|
60
|
+
summary: t('tagVersions')
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (hasJobs) {
|
|
65
|
+
tags.push({
|
|
66
|
+
name: NAV_SYSTEM,
|
|
67
|
+
summary: t('tagSystem'),
|
|
68
|
+
description: t('tagSystemDesc'),
|
|
69
|
+
kind: 'nav'
|
|
70
|
+
});
|
|
71
|
+
tags.push({
|
|
72
|
+
name: 'Jobs',
|
|
73
|
+
parent: NAV_SYSTEM,
|
|
74
|
+
summary: t('tagJobs')
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
return tags;
|
|
78
|
+
};
|
|
79
|
+
export { NAV_COLLECTIONS, NAV_GLOBALS, NAV_SYSTEM, authTagName, buildTagHierarchy, entityTagName, versionsTagName };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AcceptedLanguages, I18n } from '@payloadcms/translations';
|
|
2
|
+
import type { PluginDefaultTranslationsObject, Translate } from './types.js';
|
|
3
|
+
export declare const makeT: (i18n: Pick<I18n, "t">) => Translate;
|
|
4
|
+
export declare const translations: {
|
|
5
|
+
[key in AcceptedLanguages]?: PluginDefaultTranslationsObject;
|
|
6
|
+
};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { PLUGIN_NAME } from "../constants.js";
|
|
2
|
+
import { ar } from "./locales/ar.js";
|
|
3
|
+
import { az } from "./locales/az.js";
|
|
4
|
+
import { bg } from "./locales/bg.js";
|
|
5
|
+
import { bnBd } from "./locales/bnBd.js";
|
|
6
|
+
import { bnIn } from "./locales/bnIn.js";
|
|
7
|
+
import { ca } from "./locales/ca.js";
|
|
8
|
+
import { cs } from "./locales/cs.js";
|
|
9
|
+
import { da } from "./locales/da.js";
|
|
10
|
+
import { de } from "./locales/de.js";
|
|
11
|
+
import { en } from "./locales/en.js";
|
|
12
|
+
import { es } from "./locales/es.js";
|
|
13
|
+
import { et } from "./locales/et.js";
|
|
14
|
+
import { fa } from "./locales/fa.js";
|
|
15
|
+
import { fr } from "./locales/fr.js";
|
|
16
|
+
import { he } from "./locales/he.js";
|
|
17
|
+
import { hr } from "./locales/hr.js";
|
|
18
|
+
import { hu } from "./locales/hu.js";
|
|
19
|
+
import { hy } from "./locales/hy.js";
|
|
20
|
+
import { id } from "./locales/id.js";
|
|
21
|
+
import { is } from "./locales/is.js";
|
|
22
|
+
import { it } from "./locales/it.js";
|
|
23
|
+
import { ja } from "./locales/ja.js";
|
|
24
|
+
import { ko } from "./locales/ko.js";
|
|
25
|
+
import { lt } from "./locales/lt.js";
|
|
26
|
+
import { lv } from "./locales/lv.js";
|
|
27
|
+
import { my } from "./locales/my.js";
|
|
28
|
+
import { nb } from "./locales/nb.js";
|
|
29
|
+
import { nl } from "./locales/nl.js";
|
|
30
|
+
import { pl } from "./locales/pl.js";
|
|
31
|
+
import { pt } from "./locales/pt.js";
|
|
32
|
+
import { ro } from "./locales/ro.js";
|
|
33
|
+
import { rs } from "./locales/rs.js";
|
|
34
|
+
import { rsLatin } from "./locales/rsLatin.js";
|
|
35
|
+
import { ru } from "./locales/ru.js";
|
|
36
|
+
import { sk } from "./locales/sk.js";
|
|
37
|
+
import { sl } from "./locales/sl.js";
|
|
38
|
+
import { sv } from "./locales/sv.js";
|
|
39
|
+
import { ta } from "./locales/ta.js";
|
|
40
|
+
import { th } from "./locales/th.js";
|
|
41
|
+
import { tr } from "./locales/tr.js";
|
|
42
|
+
import { uk } from "./locales/uk.js";
|
|
43
|
+
import { vi } from "./locales/vi.js";
|
|
44
|
+
import { zh } from "./locales/zh.js";
|
|
45
|
+
import { zhTw } from "./locales/zhTw.js";
|
|
46
|
+
const makeT = (i18n)=>{
|
|
47
|
+
const t = i18n.t;
|
|
48
|
+
return (key, vars)=>t ? t(`${PLUGIN_NAME}:${key}`, vars) : key;
|
|
49
|
+
};
|
|
50
|
+
const translations = {
|
|
51
|
+
ar: ar,
|
|
52
|
+
az: az,
|
|
53
|
+
bg: bg,
|
|
54
|
+
'bn-BD': bnBd,
|
|
55
|
+
'bn-IN': bnIn,
|
|
56
|
+
ca: ca,
|
|
57
|
+
cs: cs,
|
|
58
|
+
da: da,
|
|
59
|
+
de: de,
|
|
60
|
+
en: en,
|
|
61
|
+
es: es,
|
|
62
|
+
et: et,
|
|
63
|
+
fa: fa,
|
|
64
|
+
fr: fr,
|
|
65
|
+
he: he,
|
|
66
|
+
hr: hr,
|
|
67
|
+
hu: hu,
|
|
68
|
+
hy: hy,
|
|
69
|
+
id: id,
|
|
70
|
+
is: is,
|
|
71
|
+
it: it,
|
|
72
|
+
ja: ja,
|
|
73
|
+
ko: ko,
|
|
74
|
+
lt: lt,
|
|
75
|
+
lv: lv,
|
|
76
|
+
my: my,
|
|
77
|
+
nb: nb,
|
|
78
|
+
nl: nl,
|
|
79
|
+
pl: pl,
|
|
80
|
+
pt: pt,
|
|
81
|
+
ro: ro,
|
|
82
|
+
rs: rs,
|
|
83
|
+
'rs-latin': rsLatin,
|
|
84
|
+
ru: ru,
|
|
85
|
+
sk: sk,
|
|
86
|
+
sl: sl,
|
|
87
|
+
sv: sv,
|
|
88
|
+
ta: ta,
|
|
89
|
+
th: th,
|
|
90
|
+
tr: tr,
|
|
91
|
+
uk: uk,
|
|
92
|
+
vi: vi,
|
|
93
|
+
zh: zh,
|
|
94
|
+
'zh-TW': zhTw
|
|
95
|
+
};
|
|
96
|
+
export { makeT, translations };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
const ar = {
|
|
2
|
+
'@seshuk/payload-plugin-openapi': {
|
|
3
|
+
paramDepth: 'عدد مستويات المستندات المرتبطة المراد جلبها.',
|
|
4
|
+
paramSort: 'الحقل المراد الترتيب حسبه؛ ضع البادئة `-` للترتيب التنازلي، مثل `-createdAt`.',
|
|
5
|
+
paramSortShort: 'الحقل المراد الترتيب حسبه؛ ضع البادئة `-` للترتيب التنازلي.',
|
|
6
|
+
paramDraft: 'إرجاع نسخ المسودة.',
|
|
7
|
+
paramTrash: 'تضمين المستندات المحذوفة.',
|
|
8
|
+
paramFlattenLocales: 'مع `locale=all`، اضبط على false للإبقاء على الحقول المترجمة ككائنات لكل لغة. القيمة الافتراضية true.',
|
|
9
|
+
paramLocale: 'اللغة المراد إرجاعها، أو `all` لكل اللغات. راجع قسم الترجمة في وصف الـ API.',
|
|
10
|
+
paramFallbackLocale: 'اللغة الاحتياطية للقيم المترجمة المفقودة، أو `none` للتعطيل.',
|
|
11
|
+
schemaSelect: 'اختر الحقول المراد إرجاعها، مثل `select[title]=true`. اتركه فارغًا لإرجاع الكل.',
|
|
12
|
+
schemaPopulate: 'جلب المستندات المرتبطة لكل مجموعة، مثل `populate[posts][title]=true`.',
|
|
13
|
+
schemaJoins: 'عناصر تحكم لكل ربط (limit/page/sort/where/count)، مثل `joins[posts][limit]=10`.',
|
|
14
|
+
schemaWhere: 'مرشح `where` الخاص بـ Payload. ضمّن حقلاً ثم عاملاً: `where[field][equals]=value`. ادمج الجمل باستخدام المصفوفتين `and` / `or`، مثل `where[or][0][field][equals]=value`. يسرد كل حقل فقط العوامل الصالحة لنوعه.',
|
|
15
|
+
schemaSupportedTimezones: 'المناطق الزمنية المدعومة بتنسيق IANA.',
|
|
16
|
+
schemaPerLocale: 'القيم لكل لغة، تُرجَع عند استخدام `locale=all`.',
|
|
17
|
+
collectionList: 'قائمة مستندات مقسّمة إلى صفحات',
|
|
18
|
+
collectionDoc: 'مستند واحد',
|
|
19
|
+
collectionCreated: 'المستند المُنشأ',
|
|
20
|
+
collectionUpdated: 'المستند المُحدَّث',
|
|
21
|
+
collectionDeleted: 'المستند المحذوف',
|
|
22
|
+
collectionBulkUpdate: 'نتيجة التحديث المجمّع',
|
|
23
|
+
collectionBulkDelete: 'نتيجة الحذف المجمّع',
|
|
24
|
+
collectionCount: 'عدد المستندات',
|
|
25
|
+
collectionDuplicated: 'المستند المُكرَّر',
|
|
26
|
+
globalDoc: 'المستند العام',
|
|
27
|
+
authLogin: 'نتيجة تسجيل الدخول',
|
|
28
|
+
authLogout: 'نتيجة تسجيل الخروج',
|
|
29
|
+
authMe: 'المستخدم المُصادَق عليه حاليًا',
|
|
30
|
+
authRefreshToken: 'رمز مُحدَّث',
|
|
31
|
+
authForgotPassword: 'تم إرسال بريد إعادة تعيين كلمة المرور',
|
|
32
|
+
authResetPassword: 'نتيجة إعادة تعيين كلمة المرور',
|
|
33
|
+
authFirstRegister: 'المستخدم الأول، تم إنشاؤه برمز مصادقة',
|
|
34
|
+
authInit: 'ما إذا كان لدى مجموعة المصادقة هذه أي مستخدمين بعد',
|
|
35
|
+
authAccess: 'صلاحيات (أذونات) المستخدم الحالي لهذه المجموعة',
|
|
36
|
+
authUnlock: 'نتيجة إلغاء القفل',
|
|
37
|
+
authVerify: 'نتيجة التحقق',
|
|
38
|
+
versionList: 'قائمة إصدارات مقسّمة إلى صفحات',
|
|
39
|
+
versionSingle: 'إصدار واحد',
|
|
40
|
+
versionRestored: 'المستند المُستعاد',
|
|
41
|
+
versionWhere: 'تصفية حقول الإصدار، مثل `where[parent][equals]=<docId>`.',
|
|
42
|
+
jobsRunSummary: 'تشغيل المهام المُدرَجة في قائمة الانتظار (ومعالجة الجداول الزمنية افتراضيًا)',
|
|
43
|
+
jobsSchedulesSummary: 'إدراج المهام المستحقة وفقًا لجدولها الزمني في قائمة الانتظار',
|
|
44
|
+
jobsRunResult: 'نتيجة التشغيل',
|
|
45
|
+
jobsSchedulesResult: 'نتيجة الجدولة',
|
|
46
|
+
jobsRunAllQueues: 'تشغيل المهام عبر جميع قوائم الانتظار.',
|
|
47
|
+
jobsLimit: 'الحد الأقصى للمهام المراد تشغيلها.',
|
|
48
|
+
jobsDisableScheduling: 'تخطّي معالجة الجداول الزمنية التي يقوم بها `run` افتراضيًا.',
|
|
49
|
+
jobsSilent: 'إخفاء سجلات التشغيل.',
|
|
50
|
+
jobsSchedulesAllQueues: 'معالجة الجداول الزمنية عبر جميع قوائم الانتظار.',
|
|
51
|
+
jobsQueue: 'تقييد العملية بقائمة انتظار واحدة. قوائم الانتظار المعروفة: {{queues}}.',
|
|
52
|
+
uploadFile: 'الملف الثنائي المراد رفعه.',
|
|
53
|
+
uploadBody: 'أرسِل `multipart/form-data` لرفع ملف (جزء ثنائي `file` بالإضافة إلى جزء `_payload` يحتوي على الحقول بصيغة JSON)، أو `application/json` بالحقول فقط في حال عدم وجود ملف.',
|
|
54
|
+
uploadPayloadField: 'حقول {{schema}} بصيغة JSON. مثال: `{"alt":"A caption"}`.',
|
|
55
|
+
error400: 'خطأ في التحقق أو الاستعلام (ValidationError، QueryError)',
|
|
56
|
+
error401: 'غير مُصادَق عليه (AuthenticationError)',
|
|
57
|
+
error403: 'محظور بواسطة التحكم في الوصول (Forbidden، UnverifiedEmail)',
|
|
58
|
+
error404: 'المستند غير موجود (NotFound)',
|
|
59
|
+
error500: 'خطأ داخلي في الخادم (APIError)',
|
|
60
|
+
securityBearer: 'الصق الرمز `token` الذي يُرجعه نقطة نهاية تسجيل الدخول. يُرسَل بصيغة `Authorization: Bearer <token>`. يقبل Payload أيضًا مخطط `JWT <token>` وملف تعريف ارتباط `{{cookiePrefix}}-token`.',
|
|
61
|
+
securityInteractive: 'تسجيل دخول تفاعلي: أدخِل اسم المستخدم (أو البريد الإلكتروني) وكلمة المرور؛ اترك Client ID/Secret فارغين.',
|
|
62
|
+
tagCollections: 'المجموعات',
|
|
63
|
+
tagCollectionsDesc: 'نقاط نهاية مجموعات المستندات (CRUD، العدّ، التكرار).',
|
|
64
|
+
tagGlobals: 'العناصر العامة',
|
|
65
|
+
tagGlobalsDesc: 'نقاط نهاية المستندات العامة.',
|
|
66
|
+
tagSystem: 'النظام',
|
|
67
|
+
tagSystemDesc: 'نقاط نهاية نظام Payload.',
|
|
68
|
+
tagAuth: 'المصادقة',
|
|
69
|
+
tagVersions: 'الإصدارات',
|
|
70
|
+
tagJobs: 'المهام',
|
|
71
|
+
localizationHeading: 'الترجمة',
|
|
72
|
+
localizationNote: 'اللغات المتاحة: {{locales}}. مرّر `?locale=<code>` إلى نقطة نهاية قراءة لاختيار لغة واحدة. مرّر `?locale=all` لتلقّي كل اللغات دفعة واحدة — عندئذٍ يُرجَع كل حقل مترجم ككائن مفهرس بحسب رمز اللغة (مثل `{ "en": "Hello", "de": "Hallo" }`) بدلاً من قيمة واحدة. اضبط `?flattenLocales=false` مع `locale=all` للإبقاء على شكل الكائن لكل لغة. تعرض مخططات الحقول شكل اللغة الواحدة.',
|
|
73
|
+
docLanguagesNote: 'يتوفر هذا التوثيق باللغات التالية: {{languages}}. أضِف `?lang=<code>` إلى عنوان URL لهذه المواصفة للتبديل.'
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
export { ar };
|