@strapi/content-type-builder 5.19.0 → 5.21.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/dist/admin/components/DataManager/DataManagerProvider.js +3 -6
- package/dist/admin/components/DataManager/DataManagerProvider.js.map +1 -1
- package/dist/admin/components/DataManager/DataManagerProvider.mjs +4 -7
- package/dist/admin/components/DataManager/DataManagerProvider.mjs.map +1 -1
- package/dist/admin/components/FormModal/attributes/ConditionForm.js +8 -6
- package/dist/admin/components/FormModal/attributes/ConditionForm.js.map +1 -1
- package/dist/admin/components/FormModal/attributes/ConditionForm.mjs +8 -6
- package/dist/admin/components/FormModal/attributes/ConditionForm.mjs.map +1 -1
- package/dist/admin/components/PluralName.js +20 -17
- package/dist/admin/components/PluralName.js.map +1 -1
- package/dist/admin/components/PluralName.mjs +20 -17
- package/dist/admin/components/PluralName.mjs.map +1 -1
- package/dist/admin/components/SingularName.js +12 -4
- package/dist/admin/components/SingularName.js.map +1 -1
- package/dist/admin/components/SingularName.mjs +12 -4
- package/dist/admin/components/SingularName.mjs.map +1 -1
- package/dist/admin/pages/App/index.js +0 -7
- package/dist/admin/pages/App/index.js.map +1 -1
- package/dist/admin/pages/App/index.mjs +2 -9
- package/dist/admin/pages/App/index.mjs.map +1 -1
- package/dist/admin/pages/ListView/EmptyState.js +1 -1
- package/dist/admin/pages/ListView/EmptyState.js.map +1 -1
- package/dist/admin/pages/ListView/EmptyState.mjs +2 -2
- package/dist/admin/pages/ListView/EmptyState.mjs.map +1 -1
- package/dist/admin/pages/ListView/ListView.js +1 -1
- package/dist/admin/pages/ListView/ListView.js.map +1 -1
- package/dist/admin/pages/ListView/ListView.mjs +2 -2
- package/dist/admin/pages/ListView/ListView.mjs.map +1 -1
- package/dist/server/controllers/validation/schema.js +4 -2
- package/dist/server/controllers/validation/schema.js.map +1 -1
- package/dist/server/controllers/validation/schema.mjs +3 -3
- package/dist/server/controllers/validation/schema.mjs.map +1 -1
- package/dist/server/routes/content-api.js +191 -25
- package/dist/server/routes/content-api.js.map +1 -1
- package/dist/server/routes/content-api.mjs +172 -25
- package/dist/server/routes/content-api.mjs.map +1 -1
- package/dist/server/services/builder.js +1 -0
- package/dist/server/services/builder.js.map +1 -1
- package/dist/server/services/builder.mjs +1 -0
- package/dist/server/services/builder.mjs.map +1 -1
- package/dist/server/src/controllers/validation/schema.d.ts +2774 -3828
- package/dist/server/src/controllers/validation/schema.d.ts.map +1 -1
- package/dist/server/src/index.d.ts +1 -8
- package/dist/server/src/index.d.ts.map +1 -1
- package/dist/server/src/routes/content-api.d.ts +2 -8
- package/dist/server/src/routes/content-api.d.ts.map +1 -1
- package/dist/server/src/routes/index.d.ts +1 -8
- package/dist/server/src/routes/index.d.ts.map +1 -1
- package/dist/server/src/services/builder.d.ts.map +1 -1
- package/package.json +6 -6
|
@@ -1,28 +1,175 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
};
|
|
1
|
+
import * as z from 'zod/v4';
|
|
2
|
+
|
|
3
|
+
const ctUIDRegexp = /^((strapi|admin)::[\w-]+|(api|plugin)::[\w-]+\.[\w-]+)$/;
|
|
4
|
+
const componentUIDRegexp = /^[\w-]+\.[\w-]+$/;
|
|
5
|
+
const baseAttributeSchema = z.object({
|
|
6
|
+
type: z.string(),
|
|
7
|
+
configurable: z.literal(false).optional(),
|
|
8
|
+
private: z.boolean().optional(),
|
|
9
|
+
pluginOptions: z.record(z.string(), z.unknown()).optional()
|
|
10
|
+
});
|
|
11
|
+
const mediaAttributeSchema = baseAttributeSchema.extend({
|
|
12
|
+
type: z.literal('media'),
|
|
13
|
+
multiple: z.boolean(),
|
|
14
|
+
required: z.boolean().optional(),
|
|
15
|
+
allowedTypes: z.array(z.string()).optional()
|
|
16
|
+
});
|
|
17
|
+
const relationAttributeSchema = baseAttributeSchema.extend({
|
|
18
|
+
type: z.literal('relation'),
|
|
19
|
+
relation: z.string(),
|
|
20
|
+
target: z.string().regex(ctUIDRegexp),
|
|
21
|
+
targetAttribute: z.string().nullable(),
|
|
22
|
+
autoPopulate: z.boolean().optional(),
|
|
23
|
+
mappedBy: z.string().optional(),
|
|
24
|
+
inversedBy: z.string().optional()
|
|
25
|
+
});
|
|
26
|
+
const componentAttributeSchema = baseAttributeSchema.extend({
|
|
27
|
+
type: z.literal('component'),
|
|
28
|
+
component: z.string(),
|
|
29
|
+
repeatable: z.boolean(),
|
|
30
|
+
required: z.boolean().optional(),
|
|
31
|
+
min: z.number().optional(),
|
|
32
|
+
max: z.number().optional()
|
|
33
|
+
});
|
|
34
|
+
const dynamicZoneAttributeSchema = baseAttributeSchema.extend({
|
|
35
|
+
type: z.literal('dynamiczone'),
|
|
36
|
+
components: z.array(z.string().regex(componentUIDRegexp)),
|
|
37
|
+
required: z.boolean().optional(),
|
|
38
|
+
min: z.number().optional(),
|
|
39
|
+
max: z.number().optional()
|
|
40
|
+
});
|
|
41
|
+
const uidAttributeSchema = baseAttributeSchema.extend({
|
|
42
|
+
type: z.literal('uid'),
|
|
43
|
+
targetField: z.string().optional()
|
|
44
|
+
});
|
|
45
|
+
const genericAttributeSchema = z.object({
|
|
46
|
+
type: z.string(),
|
|
47
|
+
required: z.boolean().optional(),
|
|
48
|
+
unique: z.boolean().optional(),
|
|
49
|
+
default: z.unknown().optional(),
|
|
50
|
+
min: z.union([
|
|
51
|
+
z.number(),
|
|
52
|
+
z.string()
|
|
53
|
+
]).optional(),
|
|
54
|
+
max: z.union([
|
|
55
|
+
z.number(),
|
|
56
|
+
z.string()
|
|
57
|
+
]).optional(),
|
|
58
|
+
minLength: z.number().optional(),
|
|
59
|
+
maxLength: z.number().optional(),
|
|
60
|
+
enum: z.array(z.string()).optional(),
|
|
61
|
+
regex: z.string().optional(),
|
|
62
|
+
private: z.boolean().optional(),
|
|
63
|
+
configurable: z.boolean().optional(),
|
|
64
|
+
pluginOptions: z.record(z.string(), z.unknown()).optional()
|
|
65
|
+
});
|
|
66
|
+
const attributeSchema = z.union([
|
|
67
|
+
mediaAttributeSchema,
|
|
68
|
+
relationAttributeSchema,
|
|
69
|
+
componentAttributeSchema,
|
|
70
|
+
dynamicZoneAttributeSchema,
|
|
71
|
+
uidAttributeSchema,
|
|
72
|
+
genericAttributeSchema
|
|
73
|
+
]);
|
|
74
|
+
const contentTypeSchemaBase = z.object({
|
|
75
|
+
displayName: z.string(),
|
|
76
|
+
singularName: z.string(),
|
|
77
|
+
pluralName: z.string(),
|
|
78
|
+
description: z.string(),
|
|
79
|
+
draftAndPublish: z.boolean(),
|
|
80
|
+
kind: z.enum([
|
|
81
|
+
'collectionType',
|
|
82
|
+
'singleType'
|
|
83
|
+
]),
|
|
84
|
+
collectionName: z.string().optional(),
|
|
85
|
+
attributes: z.record(z.string(), attributeSchema),
|
|
86
|
+
visible: z.boolean(),
|
|
87
|
+
restrictRelationsTo: z.array(z.string()).nullable(),
|
|
88
|
+
pluginOptions: z.record(z.string(), z.unknown()).optional(),
|
|
89
|
+
options: z.record(z.string(), z.unknown()).optional(),
|
|
90
|
+
reviewWorkflows: z.boolean().optional(),
|
|
91
|
+
populateCreatorFields: z.boolean().optional(),
|
|
92
|
+
comment: z.string().optional(),
|
|
93
|
+
version: z.string().optional()
|
|
94
|
+
});
|
|
95
|
+
const formattedContentTypeSchema = z.object({
|
|
96
|
+
uid: z.string().regex(ctUIDRegexp),
|
|
97
|
+
plugin: z.string().optional(),
|
|
98
|
+
apiID: z.string(),
|
|
99
|
+
schema: contentTypeSchemaBase
|
|
100
|
+
});
|
|
101
|
+
const componentSchemaBase = z.object({
|
|
102
|
+
displayName: z.string(),
|
|
103
|
+
description: z.string(),
|
|
104
|
+
icon: z.string().optional(),
|
|
105
|
+
connection: z.string().optional(),
|
|
106
|
+
collectionName: z.string().optional(),
|
|
107
|
+
attributes: z.record(z.string(), attributeSchema),
|
|
108
|
+
pluginOptions: z.record(z.string(), z.unknown()).optional()
|
|
109
|
+
});
|
|
110
|
+
const formattedComponentSchema = z.object({
|
|
111
|
+
uid: z.string().regex(componentUIDRegexp),
|
|
112
|
+
category: z.string(),
|
|
113
|
+
apiId: z.string(),
|
|
114
|
+
schema: componentSchemaBase
|
|
115
|
+
});
|
|
116
|
+
var contentApi = (()=>{
|
|
117
|
+
return {
|
|
118
|
+
type: 'content-api',
|
|
119
|
+
routes: [
|
|
120
|
+
{
|
|
121
|
+
method: 'GET',
|
|
122
|
+
path: '/content-types',
|
|
123
|
+
handler: 'content-types.getContentTypes',
|
|
124
|
+
request: {
|
|
125
|
+
query: {
|
|
126
|
+
kind: z.enum([
|
|
127
|
+
'collectionType',
|
|
128
|
+
'singleType'
|
|
129
|
+
])
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
response: z.object({
|
|
133
|
+
data: z.array(formattedContentTypeSchema)
|
|
134
|
+
})
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
method: 'GET',
|
|
138
|
+
path: '/content-types/:uid',
|
|
139
|
+
handler: 'content-types.getContentType',
|
|
140
|
+
request: {
|
|
141
|
+
params: {
|
|
142
|
+
uid: z.string().regex(ctUIDRegexp)
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
response: z.object({
|
|
146
|
+
data: formattedContentTypeSchema
|
|
147
|
+
})
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
method: 'GET',
|
|
151
|
+
path: '/components',
|
|
152
|
+
handler: 'components.getComponents',
|
|
153
|
+
response: z.object({
|
|
154
|
+
data: z.array(formattedComponentSchema)
|
|
155
|
+
})
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
method: 'GET',
|
|
159
|
+
path: '/components/:uid',
|
|
160
|
+
handler: 'components.getComponent',
|
|
161
|
+
request: {
|
|
162
|
+
params: {
|
|
163
|
+
uid: z.string().regex(componentUIDRegexp)
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
response: z.object({
|
|
167
|
+
data: formattedComponentSchema
|
|
168
|
+
})
|
|
169
|
+
}
|
|
170
|
+
]
|
|
171
|
+
};
|
|
172
|
+
});
|
|
26
173
|
|
|
27
174
|
export { contentApi as default };
|
|
28
175
|
//# sourceMappingURL=content-api.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content-api.mjs","sources":["../../../server/src/routes/content-api.ts"],"sourcesContent":["export default {\n type: 'content-api',\n routes: [\n {\n method: 'GET',\n path: '/content-types',\n handler: 'content-types.getContentTypes',\n },\n {\n method: 'GET',\n path: '/content-types/:uid',\n handler: 'content-types.getContentType',\n },\n {\n method: 'GET',\n path: '/components',\n handler: 'components.getComponents',\n },\n {\n method: 'GET',\n path: '/components/:uid',\n handler: 'components.getComponent',\n },\n ],\n};\n"],"names":["type","routes","method","path","handler"],"mappings":"AAAA,iBAAe;IACbA,IAAM,EAAA,aAAA;IACNC,MAAQ,EAAA;AACN,QAAA;YACEC,MAAQ,EAAA,KAAA;YACRC,IAAM,EAAA,gBAAA;YACNC,OAAS,EAAA;AACX,SAAA;AACA,QAAA;YACEF,MAAQ,EAAA,KAAA;YACRC,IAAM,EAAA,qBAAA;YACNC,OAAS,EAAA;AACX,SAAA;AACA,QAAA;YACEF,MAAQ,EAAA,KAAA;YACRC,IAAM,EAAA,aAAA;YACNC,OAAS,EAAA;AACX,SAAA;AACA,QAAA;YACEF,MAAQ,EAAA,KAAA;YACRC,IAAM,EAAA,kBAAA;YACNC,OAAS,EAAA;AACX;AACD;AACH,CAAE;;;;"}
|
|
1
|
+
{"version":3,"file":"content-api.mjs","sources":["../../../server/src/routes/content-api.ts"],"sourcesContent":["import type { Core } from '@strapi/types';\nimport * as z from 'zod/v4';\n\nconst ctUIDRegexp = /^((strapi|admin)::[\\w-]+|(api|plugin)::[\\w-]+\\.[\\w-]+)$/;\nconst componentUIDRegexp = /^[\\w-]+\\.[\\w-]+$/;\n\nconst baseAttributeSchema = z.object({\n type: z.string(),\n configurable: z.literal(false).optional(),\n private: z.boolean().optional(),\n pluginOptions: z.record(z.string(), z.unknown()).optional(),\n});\n\nconst mediaAttributeSchema = baseAttributeSchema.extend({\n type: z.literal('media'),\n multiple: z.boolean(),\n required: z.boolean().optional(),\n allowedTypes: z.array(z.string()).optional(),\n});\n\nconst relationAttributeSchema = baseAttributeSchema.extend({\n type: z.literal('relation'),\n relation: z.string(),\n target: z.string().regex(ctUIDRegexp),\n targetAttribute: z.string().nullable(),\n autoPopulate: z.boolean().optional(),\n mappedBy: z.string().optional(),\n inversedBy: z.string().optional(),\n});\n\nconst componentAttributeSchema = baseAttributeSchema.extend({\n type: z.literal('component'),\n component: z.string(),\n repeatable: z.boolean(),\n required: z.boolean().optional(),\n min: z.number().optional(),\n max: z.number().optional(),\n});\n\nconst dynamicZoneAttributeSchema = baseAttributeSchema.extend({\n type: z.literal('dynamiczone'),\n components: z.array(z.string().regex(componentUIDRegexp)),\n required: z.boolean().optional(),\n min: z.number().optional(),\n max: z.number().optional(),\n});\n\nconst uidAttributeSchema = baseAttributeSchema.extend({\n type: z.literal('uid'),\n targetField: z.string().optional(),\n});\n\nconst genericAttributeSchema = z.object({\n type: z.string(),\n required: z.boolean().optional(),\n unique: z.boolean().optional(),\n default: z.unknown().optional(),\n min: z.union([z.number(), z.string()]).optional(),\n max: z.union([z.number(), z.string()]).optional(),\n minLength: z.number().optional(),\n maxLength: z.number().optional(),\n enum: z.array(z.string()).optional(),\n regex: z.string().optional(),\n private: z.boolean().optional(),\n configurable: z.boolean().optional(),\n pluginOptions: z.record(z.string(), z.unknown()).optional(),\n});\n\nconst attributeSchema = z.union([\n mediaAttributeSchema,\n relationAttributeSchema,\n componentAttributeSchema,\n dynamicZoneAttributeSchema,\n uidAttributeSchema,\n genericAttributeSchema,\n]);\n\nconst contentTypeSchemaBase = z.object({\n displayName: z.string(),\n singularName: z.string(),\n pluralName: z.string(),\n description: z.string(),\n draftAndPublish: z.boolean(),\n kind: z.enum(['collectionType', 'singleType']),\n collectionName: z.string().optional(),\n attributes: z.record(z.string(), attributeSchema),\n visible: z.boolean(),\n restrictRelationsTo: z.array(z.string()).nullable(),\n pluginOptions: z.record(z.string(), z.unknown()).optional(),\n options: z.record(z.string(), z.unknown()).optional(),\n reviewWorkflows: z.boolean().optional(),\n populateCreatorFields: z.boolean().optional(),\n comment: z.string().optional(),\n version: z.string().optional(),\n});\n\nconst formattedContentTypeSchema = z.object({\n uid: z.string().regex(ctUIDRegexp),\n plugin: z.string().optional(),\n apiID: z.string(),\n schema: contentTypeSchemaBase,\n});\n\nconst componentSchemaBase = z.object({\n displayName: z.string(),\n description: z.string(),\n icon: z.string().optional(),\n connection: z.string().optional(),\n collectionName: z.string().optional(),\n attributes: z.record(z.string(), attributeSchema),\n pluginOptions: z.record(z.string(), z.unknown()).optional(),\n});\n\nconst formattedComponentSchema = z.object({\n uid: z.string().regex(componentUIDRegexp),\n category: z.string(),\n apiId: z.string(),\n schema: componentSchemaBase,\n});\n\nexport default (): Core.RouterInput => {\n return {\n type: 'content-api',\n routes: [\n {\n method: 'GET',\n path: '/content-types',\n handler: 'content-types.getContentTypes',\n request: {\n query: { kind: z.enum(['collectionType', 'singleType']) },\n },\n response: z.object({ data: z.array(formattedContentTypeSchema) }),\n },\n {\n method: 'GET',\n path: '/content-types/:uid',\n handler: 'content-types.getContentType',\n request: {\n params: {\n uid: z.string().regex(ctUIDRegexp),\n },\n },\n response: z.object({ data: formattedContentTypeSchema }),\n },\n {\n method: 'GET',\n path: '/components',\n handler: 'components.getComponents',\n response: z.object({ data: z.array(formattedComponentSchema) }),\n },\n {\n method: 'GET',\n path: '/components/:uid',\n handler: 'components.getComponent',\n request: {\n params: {\n uid: z.string().regex(componentUIDRegexp),\n },\n },\n response: z.object({ data: formattedComponentSchema }),\n },\n ],\n };\n};\n"],"names":["ctUIDRegexp","componentUIDRegexp","baseAttributeSchema","z","object","type","string","configurable","literal","optional","private","boolean","pluginOptions","record","unknown","mediaAttributeSchema","extend","multiple","required","allowedTypes","array","relationAttributeSchema","relation","target","regex","targetAttribute","nullable","autoPopulate","mappedBy","inversedBy","componentAttributeSchema","component","repeatable","min","number","max","dynamicZoneAttributeSchema","components","uidAttributeSchema","targetField","genericAttributeSchema","unique","default","union","minLength","maxLength","enum","attributeSchema","contentTypeSchemaBase","displayName","singularName","pluralName","description","draftAndPublish","kind","collectionName","attributes","visible","restrictRelationsTo","options","reviewWorkflows","populateCreatorFields","comment","version","formattedContentTypeSchema","uid","plugin","apiID","schema","componentSchemaBase","icon","connection","formattedComponentSchema","category","apiId","routes","method","path","handler","request","query","response","data","params"],"mappings":";;AAGA,MAAMA,WAAc,GAAA,yDAAA;AACpB,MAAMC,kBAAqB,GAAA,kBAAA;AAE3B,MAAMC,mBAAAA,GAAsBC,CAAEC,CAAAA,MAAM,CAAC;AACnCC,IAAAA,IAAAA,EAAMF,EAAEG,MAAM,EAAA;AACdC,IAAAA,YAAAA,EAAcJ,CAAEK,CAAAA,OAAO,CAAC,KAAA,CAAA,CAAOC,QAAQ,EAAA;IACvCC,OAASP,EAAAA,CAAAA,CAAEQ,OAAO,EAAA,CAAGF,QAAQ,EAAA;IAC7BG,aAAeT,EAAAA,CAAAA,CAAEU,MAAM,CAACV,CAAAA,CAAEG,MAAM,EAAIH,EAAAA,CAAAA,CAAEW,OAAO,EAAA,CAAA,CAAIL,QAAQ;AAC3D,CAAA,CAAA;AAEA,MAAMM,oBAAAA,GAAuBb,mBAAoBc,CAAAA,MAAM,CAAC;IACtDX,IAAMF,EAAAA,CAAAA,CAAEK,OAAO,CAAC,OAAA,CAAA;AAChBS,IAAAA,QAAAA,EAAUd,EAAEQ,OAAO,EAAA;IACnBO,QAAUf,EAAAA,C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
+
// V6: we will need to add first_published_at when it becomes the default behaviour
|
|
15
16
|
'created_by_id',
|
|
16
17
|
'updated_by_id',
|
|
17
18
|
// does not actually conflict because the fields are called *_by_id but we'll leave it to avoid confusion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builder.js","sources":["../../../server/src/services/builder.ts"],"sourcesContent":["import { snakeCase } from 'lodash/fp';\n\n// use snake_case\nexport const reservedAttributes = [\n // TODO: these need to come from a centralized place so we don't break things accidentally in the future and can share them outside the CTB, for example on Strapi bootstrap prior to schema db sync\n\n // ID fields\n 'id',\n 'document_id',\n\n // Creator fields\n 'created_at',\n 'updated_at',\n 'published_at',\n 'created_by_id',\n 'updated_by_id',\n // does not actually conflict because the fields are called *_by_id but we'll leave it to avoid confusion\n 'created_by',\n 'updated_by',\n\n // Used for Strapi functionality\n 'entry_id',\n 'status',\n 'localizations',\n 'meta',\n 'locale',\n '__component',\n '__contentType',\n\n // We support ending with * to denote prefixes\n 'strapi*',\n '_strapi*',\n '__strapi*',\n];\n\n// use snake_case\nexport const reservedModels = [\n 'boolean',\n 'date',\n 'date_time',\n 'time',\n 'upload',\n 'document',\n 'then', // no longer an issue but still restricting for being a javascript keyword\n\n // We support ending with * to denote prefixes\n 'strapi*',\n '_strapi*',\n '__strapi*',\n];\n\nexport const getReservedNames = () => {\n return {\n models: reservedModels,\n attributes: reservedAttributes,\n };\n};\n\n// compare snake case to check the actual column names that will be used in the database\nexport const isReservedModelName = (name: string) => {\n const snakeCaseName = snakeCase(name);\n if (reservedModels.includes(snakeCaseName)) {\n return true;\n }\n\n if (\n reservedModels\n .filter((key) => key.endsWith('*'))\n .map((key) => key.slice(0, -1))\n .some((prefix) => snakeCaseName.startsWith(prefix))\n ) {\n return true;\n }\n\n return false;\n};\n\n// compare snake case to check the actual column names that will be used in the database\nexport const isReservedAttributeName = (name: string) => {\n const snakeCaseName = snakeCase(name);\n if (reservedAttributes.includes(snakeCaseName)) {\n return true;\n }\n\n if (\n reservedAttributes\n .filter((key) => key.endsWith('*'))\n .map((key) => key.slice(0, -1))\n .some((prefix) => snakeCaseName.startsWith(prefix))\n ) {\n return true;\n }\n\n return false;\n};\n"],"names":["reservedAttributes","reservedModels","getReservedNames","models","attributes","isReservedModelName","name","snakeCaseName","snakeCase","includes","filter","key","endsWith","map","slice","some","prefix","startsWith","isReservedAttributeName"],"mappings":";;;;AAEA;MACaA,kBAAqB,GAAA;;;AAIhC,IAAA,IAAA;AACA,IAAA,aAAA;;AAGA,IAAA,YAAA;AACA,IAAA,YAAA;AACA,IAAA,cAAA
|
|
1
|
+
{"version":3,"file":"builder.js","sources":["../../../server/src/services/builder.ts"],"sourcesContent":["import { snakeCase } from 'lodash/fp';\n\n// use snake_case\nexport const reservedAttributes = [\n // TODO: these need to come from a centralized place so we don't break things accidentally in the future and can share them outside the CTB, for example on Strapi bootstrap prior to schema db sync\n\n // ID fields\n 'id',\n 'document_id',\n\n // Creator fields\n 'created_at',\n 'updated_at',\n 'published_at',\n // V6: we will need to add first_published_at when it becomes the default behaviour\n 'created_by_id',\n 'updated_by_id',\n // does not actually conflict because the fields are called *_by_id but we'll leave it to avoid confusion\n 'created_by',\n 'updated_by',\n\n // Used for Strapi functionality\n 'entry_id',\n 'status',\n 'localizations',\n 'meta',\n 'locale',\n '__component',\n '__contentType',\n\n // We support ending with * to denote prefixes\n 'strapi*',\n '_strapi*',\n '__strapi*',\n];\n\n// use snake_case\nexport const reservedModels = [\n 'boolean',\n 'date',\n 'date_time',\n 'time',\n 'upload',\n 'document',\n 'then', // no longer an issue but still restricting for being a javascript keyword\n\n // We support ending with * to denote prefixes\n 'strapi*',\n '_strapi*',\n '__strapi*',\n];\n\nexport const getReservedNames = () => {\n return {\n models: reservedModels,\n attributes: reservedAttributes,\n };\n};\n\n// compare snake case to check the actual column names that will be used in the database\nexport const isReservedModelName = (name: string) => {\n const snakeCaseName = snakeCase(name);\n if (reservedModels.includes(snakeCaseName)) {\n return true;\n }\n\n if (\n reservedModels\n .filter((key) => key.endsWith('*'))\n .map((key) => key.slice(0, -1))\n .some((prefix) => snakeCaseName.startsWith(prefix))\n ) {\n return true;\n }\n\n return false;\n};\n\n// compare snake case to check the actual column names that will be used in the database\nexport const isReservedAttributeName = (name: string) => {\n const snakeCaseName = snakeCase(name);\n if (reservedAttributes.includes(snakeCaseName)) {\n return true;\n }\n\n if (\n reservedAttributes\n .filter((key) => key.endsWith('*'))\n .map((key) => key.slice(0, -1))\n .some((prefix) => snakeCaseName.startsWith(prefix))\n ) {\n return true;\n }\n\n return false;\n};\n"],"names":["reservedAttributes","reservedModels","getReservedNames","models","attributes","isReservedModelName","name","snakeCaseName","snakeCase","includes","filter","key","endsWith","map","slice","some","prefix","startsWith","isReservedAttributeName"],"mappings":";;;;AAEA;MACaA,kBAAqB,GAAA;;;AAIhC,IAAA,IAAA;AACA,IAAA,aAAA;;AAGA,IAAA,YAAA;AACA,IAAA,YAAA;AACA,IAAA,cAAA;;AAEA,IAAA,eAAA;AACA,IAAA,eAAA;;AAEA,IAAA,YAAA;AACA,IAAA,YAAA;;AAGA,IAAA,UAAA;AACA,IAAA,QAAA;AACA,IAAA,eAAA;AACA,IAAA,MAAA;AACA,IAAA,QAAA;AACA,IAAA,aAAA;AACA,IAAA,eAAA;;AAGA,IAAA,SAAA;AACA,IAAA,UAAA;AACA,IAAA;;AAGF;MACaC,cAAiB,GAAA;AAC5B,IAAA,SAAA;AACA,IAAA,MAAA;AACA,IAAA,WAAA;AACA,IAAA,MAAA;AACA,IAAA,QAAA;AACA,IAAA,UAAA;AACA,IAAA,MAAA;;AAGA,IAAA,SAAA;AACA,IAAA,UAAA;AACA,IAAA;;MAGWC,gBAAmB,GAAA,IAAA;IAC9B,OAAO;QACLC,MAAQF,EAAAA,cAAAA;QACRG,UAAYJ,EAAAA;AACd,KAAA;AACF;AAEA;AACO,MAAMK,sBAAsB,CAACC,IAAAA,GAAAA;AAClC,IAAA,MAAMC,gBAAgBC,YAAUF,CAAAA,IAAAA,CAAAA;IAChC,IAAIL,cAAAA,CAAeQ,QAAQ,CAACF,aAAgB,CAAA,EAAA;QAC1C,OAAO,IAAA;AACT;IAEA,IACEN,cAAAA,CACGS,MAAM,CAAC,CAACC,GAAAA,GAAQA,GAAIC,CAAAA,QAAQ,CAAC,GAAA,CAAA,CAAA,CAC7BC,GAAG,CAAC,CAACF,GAAAA,GAAQA,IAAIG,KAAK,CAAC,CAAG,EAAA,CAAC,CAC3BC,CAAAA,CAAAA,CAAAA,IAAI,CAAC,CAACC,MAAWT,GAAAA,aAAAA,CAAcU,UAAU,CAACD,MAC7C,CAAA,CAAA,EAAA;QACA,OAAO,IAAA;AACT;IAEA,OAAO,KAAA;AACT;AAEA;AACO,MAAME,0BAA0B,CAACZ,IAAAA,GAAAA;AACtC,IAAA,MAAMC,gBAAgBC,YAAUF,CAAAA,IAAAA,CAAAA;IAChC,IAAIN,kBAAAA,CAAmBS,QAAQ,CAACF,aAAgB,CAAA,EAAA;QAC9C,OAAO,IAAA;AACT;IAEA,IACEP,kBAAAA,CACGU,MAAM,CAAC,CAACC,GAAAA,GAAQA,GAAIC,CAAAA,QAAQ,CAAC,GAAA,CAAA,CAAA,CAC7BC,GAAG,CAAC,CAACF,GAAAA,GAAQA,IAAIG,KAAK,CAAC,CAAG,EAAA,CAAC,CAC3BC,CAAAA,CAAAA,CAAAA,IAAI,CAAC,CAACC,MAAWT,GAAAA,aAAAA,CAAcU,UAAU,CAACD,MAC7C,CAAA,CAAA,EAAA;QACA,OAAO,IAAA;AACT;IAEA,OAAO,KAAA;AACT;;;;;;;;"}
|
|
@@ -10,6 +10,7 @@ const reservedAttributes = [
|
|
|
10
10
|
'created_at',
|
|
11
11
|
'updated_at',
|
|
12
12
|
'published_at',
|
|
13
|
+
// V6: we will need to add first_published_at when it becomes the default behaviour
|
|
13
14
|
'created_by_id',
|
|
14
15
|
'updated_by_id',
|
|
15
16
|
// does not actually conflict because the fields are called *_by_id but we'll leave it to avoid confusion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builder.mjs","sources":["../../../server/src/services/builder.ts"],"sourcesContent":["import { snakeCase } from 'lodash/fp';\n\n// use snake_case\nexport const reservedAttributes = [\n // TODO: these need to come from a centralized place so we don't break things accidentally in the future and can share them outside the CTB, for example on Strapi bootstrap prior to schema db sync\n\n // ID fields\n 'id',\n 'document_id',\n\n // Creator fields\n 'created_at',\n 'updated_at',\n 'published_at',\n 'created_by_id',\n 'updated_by_id',\n // does not actually conflict because the fields are called *_by_id but we'll leave it to avoid confusion\n 'created_by',\n 'updated_by',\n\n // Used for Strapi functionality\n 'entry_id',\n 'status',\n 'localizations',\n 'meta',\n 'locale',\n '__component',\n '__contentType',\n\n // We support ending with * to denote prefixes\n 'strapi*',\n '_strapi*',\n '__strapi*',\n];\n\n// use snake_case\nexport const reservedModels = [\n 'boolean',\n 'date',\n 'date_time',\n 'time',\n 'upload',\n 'document',\n 'then', // no longer an issue but still restricting for being a javascript keyword\n\n // We support ending with * to denote prefixes\n 'strapi*',\n '_strapi*',\n '__strapi*',\n];\n\nexport const getReservedNames = () => {\n return {\n models: reservedModels,\n attributes: reservedAttributes,\n };\n};\n\n// compare snake case to check the actual column names that will be used in the database\nexport const isReservedModelName = (name: string) => {\n const snakeCaseName = snakeCase(name);\n if (reservedModels.includes(snakeCaseName)) {\n return true;\n }\n\n if (\n reservedModels\n .filter((key) => key.endsWith('*'))\n .map((key) => key.slice(0, -1))\n .some((prefix) => snakeCaseName.startsWith(prefix))\n ) {\n return true;\n }\n\n return false;\n};\n\n// compare snake case to check the actual column names that will be used in the database\nexport const isReservedAttributeName = (name: string) => {\n const snakeCaseName = snakeCase(name);\n if (reservedAttributes.includes(snakeCaseName)) {\n return true;\n }\n\n if (\n reservedAttributes\n .filter((key) => key.endsWith('*'))\n .map((key) => key.slice(0, -1))\n .some((prefix) => snakeCaseName.startsWith(prefix))\n ) {\n return true;\n }\n\n return false;\n};\n"],"names":["reservedAttributes","reservedModels","getReservedNames","models","attributes","isReservedModelName","name","snakeCaseName","snakeCase","includes","filter","key","endsWith","map","slice","some","prefix","startsWith","isReservedAttributeName"],"mappings":";;AAEA;MACaA,kBAAqB,GAAA;;;AAIhC,IAAA,IAAA;AACA,IAAA,aAAA;;AAGA,IAAA,YAAA;AACA,IAAA,YAAA;AACA,IAAA,cAAA
|
|
1
|
+
{"version":3,"file":"builder.mjs","sources":["../../../server/src/services/builder.ts"],"sourcesContent":["import { snakeCase } from 'lodash/fp';\n\n// use snake_case\nexport const reservedAttributes = [\n // TODO: these need to come from a centralized place so we don't break things accidentally in the future and can share them outside the CTB, for example on Strapi bootstrap prior to schema db sync\n\n // ID fields\n 'id',\n 'document_id',\n\n // Creator fields\n 'created_at',\n 'updated_at',\n 'published_at',\n // V6: we will need to add first_published_at when it becomes the default behaviour\n 'created_by_id',\n 'updated_by_id',\n // does not actually conflict because the fields are called *_by_id but we'll leave it to avoid confusion\n 'created_by',\n 'updated_by',\n\n // Used for Strapi functionality\n 'entry_id',\n 'status',\n 'localizations',\n 'meta',\n 'locale',\n '__component',\n '__contentType',\n\n // We support ending with * to denote prefixes\n 'strapi*',\n '_strapi*',\n '__strapi*',\n];\n\n// use snake_case\nexport const reservedModels = [\n 'boolean',\n 'date',\n 'date_time',\n 'time',\n 'upload',\n 'document',\n 'then', // no longer an issue but still restricting for being a javascript keyword\n\n // We support ending with * to denote prefixes\n 'strapi*',\n '_strapi*',\n '__strapi*',\n];\n\nexport const getReservedNames = () => {\n return {\n models: reservedModels,\n attributes: reservedAttributes,\n };\n};\n\n// compare snake case to check the actual column names that will be used in the database\nexport const isReservedModelName = (name: string) => {\n const snakeCaseName = snakeCase(name);\n if (reservedModels.includes(snakeCaseName)) {\n return true;\n }\n\n if (\n reservedModels\n .filter((key) => key.endsWith('*'))\n .map((key) => key.slice(0, -1))\n .some((prefix) => snakeCaseName.startsWith(prefix))\n ) {\n return true;\n }\n\n return false;\n};\n\n// compare snake case to check the actual column names that will be used in the database\nexport const isReservedAttributeName = (name: string) => {\n const snakeCaseName = snakeCase(name);\n if (reservedAttributes.includes(snakeCaseName)) {\n return true;\n }\n\n if (\n reservedAttributes\n .filter((key) => key.endsWith('*'))\n .map((key) => key.slice(0, -1))\n .some((prefix) => snakeCaseName.startsWith(prefix))\n ) {\n return true;\n }\n\n return false;\n};\n"],"names":["reservedAttributes","reservedModels","getReservedNames","models","attributes","isReservedModelName","name","snakeCaseName","snakeCase","includes","filter","key","endsWith","map","slice","some","prefix","startsWith","isReservedAttributeName"],"mappings":";;AAEA;MACaA,kBAAqB,GAAA;;;AAIhC,IAAA,IAAA;AACA,IAAA,aAAA;;AAGA,IAAA,YAAA;AACA,IAAA,YAAA;AACA,IAAA,cAAA;;AAEA,IAAA,eAAA;AACA,IAAA,eAAA;;AAEA,IAAA,YAAA;AACA,IAAA,YAAA;;AAGA,IAAA,UAAA;AACA,IAAA,QAAA;AACA,IAAA,eAAA;AACA,IAAA,MAAA;AACA,IAAA,QAAA;AACA,IAAA,aAAA;AACA,IAAA,eAAA;;AAGA,IAAA,SAAA;AACA,IAAA,UAAA;AACA,IAAA;;AAGF;MACaC,cAAiB,GAAA;AAC5B,IAAA,SAAA;AACA,IAAA,MAAA;AACA,IAAA,WAAA;AACA,IAAA,MAAA;AACA,IAAA,QAAA;AACA,IAAA,UAAA;AACA,IAAA,MAAA;;AAGA,IAAA,SAAA;AACA,IAAA,UAAA;AACA,IAAA;;MAGWC,gBAAmB,GAAA,IAAA;IAC9B,OAAO;QACLC,MAAQF,EAAAA,cAAAA;QACRG,UAAYJ,EAAAA;AACd,KAAA;AACF;AAEA;AACO,MAAMK,sBAAsB,CAACC,IAAAA,GAAAA;AAClC,IAAA,MAAMC,gBAAgBC,SAAUF,CAAAA,IAAAA,CAAAA;IAChC,IAAIL,cAAAA,CAAeQ,QAAQ,CAACF,aAAgB,CAAA,EAAA;QAC1C,OAAO,IAAA;AACT;IAEA,IACEN,cAAAA,CACGS,MAAM,CAAC,CAACC,GAAAA,GAAQA,GAAIC,C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