@webiny/api-headless-cms 0.0.0-unstable.7f63ea0744 → 0.0.0-unstable.8acc9e8892

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.
Files changed (184) hide show
  1. package/context.js +47 -43
  2. package/context.js.map +1 -1
  3. package/crud/contentEntry/markLockedFields.d.ts +1 -1
  4. package/crud/contentEntry/markLockedFields.js +13 -2
  5. package/crud/contentEntry/markLockedFields.js.map +1 -1
  6. package/crud/contentEntry/referenceFieldsMapping.js +34 -5
  7. package/crud/contentEntry/referenceFieldsMapping.js.map +1 -1
  8. package/crud/contentEntry.crud.d.ts +5 -2
  9. package/crud/contentEntry.crud.js +848 -830
  10. package/crud/contentEntry.crud.js.map +1 -1
  11. package/crud/contentModel/beforeCreate.js +39 -76
  12. package/crud/contentModel/beforeCreate.js.map +1 -1
  13. package/crud/contentModel/beforeDelete.d.ts +1 -1
  14. package/crud/contentModel/beforeDelete.js +1 -5
  15. package/crud/contentModel/beforeDelete.js.map +1 -1
  16. package/crud/contentModel/beforeUpdate.js +31 -3
  17. package/crud/contentModel/beforeUpdate.js.map +1 -1
  18. package/crud/contentModel/compatibility/modelApiName.d.ts +3 -0
  19. package/crud/contentModel/compatibility/modelApiName.js +24 -0
  20. package/crud/contentModel/compatibility/modelApiName.js.map +1 -0
  21. package/crud/contentModel/createFieldModels.d.ts +2 -0
  22. package/crud/contentModel/createFieldModels.js +26 -0
  23. package/crud/contentModel/createFieldModels.js.map +1 -0
  24. package/crud/contentModel/defaultFields.d.ts +5 -0
  25. package/crud/contentModel/defaultFields.js +58 -0
  26. package/crud/contentModel/defaultFields.js.map +1 -0
  27. package/crud/contentModel/fieldIdValidation.d.ts +1 -0
  28. package/crud/contentModel/fieldIdValidation.js +25 -0
  29. package/crud/contentModel/fieldIdValidation.js.map +1 -0
  30. package/crud/contentModel/fields/descriptionField.d.ts +2 -0
  31. package/crud/contentModel/fields/descriptionField.js +42 -0
  32. package/crud/contentModel/fields/descriptionField.js.map +1 -0
  33. package/crud/contentModel/fields/imageField.d.ts +2 -0
  34. package/crud/contentModel/fields/imageField.js +46 -0
  35. package/crud/contentModel/fields/imageField.js.map +1 -0
  36. package/crud/contentModel/fields/titleField.d.ts +2 -0
  37. package/crud/contentModel/fields/titleField.js +58 -0
  38. package/crud/contentModel/fields/titleField.js.map +1 -0
  39. package/crud/contentModel/idValidation.d.ts +1 -0
  40. package/crud/contentModel/idValidation.js +22 -0
  41. package/crud/contentModel/idValidation.js.map +1 -0
  42. package/crud/contentModel/models.d.ts +4 -0
  43. package/crud/contentModel/models.js +192 -0
  44. package/crud/contentModel/models.js.map +1 -0
  45. package/crud/contentModel/systemFields.js.map +1 -1
  46. package/crud/contentModel/validate/endingAllowed.d.ts +6 -0
  47. package/crud/contentModel/validate/endingAllowed.js +26 -0
  48. package/crud/contentModel/validate/endingAllowed.js.map +1 -0
  49. package/crud/contentModel/validate/isModelEndingAllowed.d.ts +6 -0
  50. package/crud/contentModel/validate/isModelEndingAllowed.js +24 -0
  51. package/crud/contentModel/validate/isModelEndingAllowed.js.map +1 -0
  52. package/crud/contentModel/validate/modelId.d.ts +11 -0
  53. package/crud/contentModel/validate/modelId.js +36 -0
  54. package/crud/contentModel/validate/modelId.js.map +1 -0
  55. package/crud/contentModel/validate/pluralApiName.d.ts +7 -0
  56. package/crud/contentModel/validate/pluralApiName.js +24 -0
  57. package/crud/contentModel/validate/pluralApiName.js.map +1 -0
  58. package/crud/contentModel/validate/singularApiName.d.ts +7 -0
  59. package/crud/contentModel/validate/singularApiName.js +24 -0
  60. package/crud/contentModel/validate/singularApiName.js.map +1 -0
  61. package/crud/contentModel/validateModel.d.ts +1 -0
  62. package/crud/contentModel/validateModel.js.map +1 -1
  63. package/crud/contentModel/validateModelFields.d.ts +2 -1
  64. package/crud/contentModel/validateModelFields.js +29 -56
  65. package/crud/contentModel/validateModelFields.js.map +1 -1
  66. package/crud/contentModel/validation.d.ts +195 -121
  67. package/crud/contentModel/validation.js +61 -13
  68. package/crud/contentModel/validation.js.map +1 -1
  69. package/crud/contentModel.crud.js +346 -285
  70. package/crud/contentModel.crud.js.map +1 -1
  71. package/crud/contentModelGroup/validation.d.ts +4 -4
  72. package/crud/contentModelGroup.crud.js +170 -142
  73. package/crud/contentModelGroup.crud.js.map +1 -1
  74. package/crud/settings.crud.d.ts +1 -1
  75. package/crud/settings.crud.js +5 -10
  76. package/crud/settings.crud.js.map +1 -1
  77. package/crud/system.crud.js +0 -60
  78. package/crud/system.crud.js.map +1 -1
  79. package/graphql/checkEndpointAccess.d.ts +2 -0
  80. package/graphql/checkEndpointAccess.js +18 -0
  81. package/graphql/checkEndpointAccess.js.map +1 -0
  82. package/graphql/createExecutableSchema.d.ts +2 -3
  83. package/graphql/createExecutableSchema.js.map +1 -1
  84. package/graphql/createRequestBody.d.ts +2 -0
  85. package/graphql/createRequestBody.js +14 -0
  86. package/graphql/createRequestBody.js.map +1 -0
  87. package/graphql/formatErrorPayload.d.ts +1 -0
  88. package/graphql/formatErrorPayload.js +25 -0
  89. package/graphql/formatErrorPayload.js.map +1 -0
  90. package/graphql/generateSchema.js.map +1 -1
  91. package/graphql/getSchema.d.ts +17 -0
  92. package/graphql/getSchema.js +102 -0
  93. package/graphql/getSchema.js.map +1 -0
  94. package/graphql/graphQLHandlerFactory.js +6 -145
  95. package/graphql/graphQLHandlerFactory.js.map +1 -1
  96. package/graphql/handleRequest.d.ts +11 -0
  97. package/graphql/handleRequest.js +81 -0
  98. package/graphql/handleRequest.js.map +1 -0
  99. package/graphql/index.d.ts +1 -1
  100. package/graphql/schema/baseContentSchema.js +4 -8
  101. package/graphql/schema/baseContentSchema.js.map +1 -1
  102. package/graphql/schema/contentEntries.js +90 -53
  103. package/graphql/schema/contentEntries.js.map +1 -1
  104. package/graphql/schema/contentModelGroups.js +7 -7
  105. package/graphql/schema/contentModelGroups.js.map +1 -1
  106. package/graphql/schema/contentModels.js +23 -4
  107. package/graphql/schema/contentModels.js.map +1 -1
  108. package/graphql/schema/createFieldResolvers.js +2 -1
  109. package/graphql/schema/createFieldResolvers.js.map +1 -1
  110. package/graphql/schema/createManageResolvers.d.ts +1 -1
  111. package/graphql/schema/createManageResolvers.js +33 -17
  112. package/graphql/schema/createManageResolvers.js.map +1 -1
  113. package/graphql/schema/createManageSDL.d.ts +1 -0
  114. package/graphql/schema/createManageSDL.js +55 -49
  115. package/graphql/schema/createManageSDL.js.map +1 -1
  116. package/graphql/schema/createPreviewResolvers.js +3 -7
  117. package/graphql/schema/createPreviewResolvers.js.map +1 -1
  118. package/graphql/schema/createReadResolvers.js +4 -8
  119. package/graphql/schema/createReadResolvers.js.map +1 -1
  120. package/graphql/schema/createReadSDL.d.ts +1 -0
  121. package/graphql/schema/createReadSDL.js +24 -22
  122. package/graphql/schema/createReadSDL.js.map +1 -1
  123. package/graphql/schema/resolvers/commonFieldResolvers.d.ts +3 -2
  124. package/graphql/schema/resolvers/commonFieldResolvers.js +2 -1
  125. package/graphql/schema/resolvers/commonFieldResolvers.js.map +1 -1
  126. package/graphql/schema/schemaPlugins.js +12 -12
  127. package/graphql/schema/schemaPlugins.js.map +1 -1
  128. package/graphql/system.js +0 -16
  129. package/graphql/system.js.map +1 -1
  130. package/graphqlFields/dynamicZone/dynamicZoneField.d.ts +1 -1
  131. package/graphqlFields/dynamicZone/dynamicZoneField.js +54 -19
  132. package/graphqlFields/dynamicZone/dynamicZoneField.js.map +1 -1
  133. package/graphqlFields/object.js +21 -2
  134. package/graphqlFields/object.js.map +1 -1
  135. package/graphqlFields/ref.js +42 -14
  136. package/graphqlFields/ref.js.map +1 -1
  137. package/index.d.ts +4 -2
  138. package/index.js +25 -2
  139. package/index.js.map +1 -1
  140. package/package.json +22 -23
  141. package/plugins/CmsModelPlugin.d.ts +21 -3
  142. package/plugins/CmsModelPlugin.js +28 -2
  143. package/plugins/CmsModelPlugin.js.map +1 -1
  144. package/plugins/StorageOperationsCmsModelPlugin.d.ts +23 -0
  145. package/plugins/StorageOperationsCmsModelPlugin.js +42 -0
  146. package/plugins/StorageOperationsCmsModelPlugin.js.map +1 -0
  147. package/plugins/index.d.ts +1 -0
  148. package/plugins/index.js +11 -0
  149. package/plugins/index.js.map +1 -1
  150. package/types.d.ts +121 -67
  151. package/types.js +1 -1
  152. package/types.js.map +1 -1
  153. package/upgrades/5.33.0/index.js +26 -3
  154. package/upgrades/5.33.0/index.js.map +1 -1
  155. package/upgrades/index.js +3 -0
  156. package/upgrades/index.js.map +1 -1
  157. package/utils/converters/valueKeyStorageConverter.d.ts +1 -5
  158. package/utils/converters/valueKeyStorageConverter.js +21 -18
  159. package/utils/converters/valueKeyStorageConverter.js.map +1 -1
  160. package/utils/createTypeFromFields.d.ts +1 -0
  161. package/utils/createTypeFromFields.js +7 -5
  162. package/utils/createTypeFromFields.js.map +1 -1
  163. package/utils/createTypeName.d.ts +0 -2
  164. package/utils/createTypeName.js +2 -10
  165. package/utils/createTypeName.js.map +1 -1
  166. package/utils/getEntryDescription.d.ts +2 -0
  167. package/utils/getEntryDescription.js +17 -0
  168. package/utils/getEntryDescription.js.map +1 -0
  169. package/utils/getEntryImage.d.ts +2 -0
  170. package/utils/getEntryImage.js +17 -0
  171. package/utils/getEntryImage.js.map +1 -0
  172. package/utils/incrementEntryIdVersion.d.ts +5 -0
  173. package/utils/incrementEntryIdVersion.js +29 -0
  174. package/utils/incrementEntryIdVersion.js.map +1 -0
  175. package/utils/ownership.d.ts +3 -3
  176. package/utils/ownership.js.map +1 -1
  177. package/utils/pluralizedTypeName.js +6 -0
  178. package/utils/pluralizedTypeName.js.map +1 -1
  179. package/utils/renderFields.d.ts +2 -1
  180. package/utils/renderFields.js +8 -1
  181. package/utils/renderFields.js.map +1 -1
  182. package/utils/renderInputFields.d.ts +2 -1
  183. package/utils/renderInputFields.js +4 -0
  184. package/utils/renderInputFields.js.map +1 -1
@@ -0,0 +1,192 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.UpdateContentModelModel = exports.CreateContentModelModelFrom = exports.CreateContentModelModel = exports.ContentModelFieldModel = void 0;
7
+
8
+ var _validation = require("@webiny/validation");
9
+
10
+ var _commodoFieldsObject = require("commodo-fields-object");
11
+
12
+ var _fields = require("@commodo/fields");
13
+
14
+ var _fieldIdValidation = require("./fieldIdValidation");
15
+
16
+ /**
17
+ * Package commodo-fields-object does not have types
18
+ */
19
+ // @ts-ignore
20
+
21
+ /**
22
+ * Package commodo-fields does not have object.
23
+ */
24
+ // @ts-ignore
25
+ const requiredShortString = _validation.validation.create("required,maxLength:255");
26
+
27
+ const shortString = _validation.validation.create("maxLength:255");
28
+
29
+ const RendererModel = (0, _fields.withFields)({
30
+ name: (0, _fields.string)({
31
+ validation: requiredShortString
32
+ })
33
+ })();
34
+ const ContentModelFieldModel = (0, _fields.withFields)({
35
+ id: (0, _fields.string)({
36
+ validation: requiredShortString
37
+ }),
38
+ fieldId: (0, _fields.string)({
39
+ validation: _fieldIdValidation.validateFieldId
40
+ }),
41
+ label: (0, _fields.string)({
42
+ validation: requiredShortString
43
+ }),
44
+ helpText: (0, _fields.string)({
45
+ validation: shortString
46
+ }),
47
+ placeholderText: (0, _fields.string)({
48
+ validation: shortString
49
+ }),
50
+ type: (0, _fields.setOnce)()((0, _fields.string)({
51
+ validation: requiredShortString
52
+ })),
53
+ tags: (0, _commodoFieldsObject.object)({
54
+ value: [],
55
+ required: false
56
+ }),
57
+ multipleValues: (0, _fields.boolean)({
58
+ value: false
59
+ }),
60
+ predefinedValues: (0, _fields.fields)({
61
+ value: {},
62
+ instanceOf: (0, _fields.withFields)({
63
+ enabled: (0, _fields.boolean)(),
64
+ values: (0, _fields.fields)({
65
+ value: [],
66
+ list: true,
67
+ instanceOf: (0, _fields.withFields)({
68
+ label: (0, _fields.string)(),
69
+ value: (0, _fields.string)(),
70
+ selected: (0, _fields.boolean)()
71
+ })()
72
+ })
73
+ })()
74
+ }),
75
+ renderer: (0, _fields.fields)({
76
+ instanceOf: RendererModel,
77
+ validation: shortString
78
+ }),
79
+ validation: (0, _fields.fields)({
80
+ list: true,
81
+ value: [],
82
+ instanceOf: (0, _fields.withFields)({
83
+ name: (0, _fields.string)({
84
+ validation: requiredShortString
85
+ }),
86
+ message: (0, _fields.string)({
87
+ validation: shortString
88
+ }),
89
+ settings: (0, _commodoFieldsObject.object)({
90
+ value: {}
91
+ })
92
+ })()
93
+ }),
94
+ listValidation: (0, _fields.fields)({
95
+ list: true,
96
+ value: [],
97
+ instanceOf: (0, _fields.withFields)({
98
+ name: (0, _fields.string)({
99
+ validation: requiredShortString
100
+ }),
101
+ message: (0, _fields.string)({
102
+ validation: shortString
103
+ }),
104
+ settings: (0, _commodoFieldsObject.object)({
105
+ value: {}
106
+ })
107
+ })()
108
+ }),
109
+ settings: (0, _commodoFieldsObject.object)({
110
+ value: {}
111
+ })
112
+ /**
113
+ * By the default, field is not deleted.
114
+ */
115
+ // isDeleted: boolean({ value: false })
116
+
117
+ })();
118
+ exports.ContentModelFieldModel = ContentModelFieldModel;
119
+ const CreateContentModelModel = (0, _fields.withFields)({
120
+ name: (0, _fields.string)({
121
+ validation: requiredShortString
122
+ }),
123
+ modelId: (0, _fields.string)({
124
+ validation: shortString
125
+ }),
126
+ description: (0, _fields.string)({
127
+ validation: shortString
128
+ }),
129
+ group: (0, _fields.string)({
130
+ validation: requiredShortString
131
+ }),
132
+ fields: (0, _fields.fields)({
133
+ instanceOf: ContentModelFieldModel,
134
+ value: [],
135
+ list: true,
136
+ required: true
137
+ }),
138
+ layout: (0, _commodoFieldsObject.object)({
139
+ value: [],
140
+ required: true
141
+ }),
142
+ tags: (0, _commodoFieldsObject.object)({
143
+ value: [],
144
+ required: false
145
+ })
146
+ })();
147
+ exports.CreateContentModelModel = CreateContentModelModel;
148
+ const CreateContentModelModelFrom = (0, _fields.withFields)({
149
+ name: (0, _fields.string)({
150
+ validation: requiredShortString
151
+ }),
152
+ modelId: (0, _fields.string)({
153
+ validation: shortString
154
+ }),
155
+ description: (0, _fields.string)({
156
+ validation: shortString
157
+ }),
158
+ group: (0, _fields.string)({
159
+ validation: requiredShortString
160
+ }),
161
+ locale: (0, _fields.string)({
162
+ validation: shortString
163
+ })
164
+ })();
165
+ exports.CreateContentModelModelFrom = CreateContentModelModelFrom;
166
+ const UpdateContentModelModel = (0, _fields.withFields)({
167
+ name: (0, _fields.string)({
168
+ validation: shortString
169
+ }),
170
+ description: (0, _fields.string)({
171
+ validation: shortString
172
+ }),
173
+ group: (0, _fields.string)({
174
+ validation: shortString
175
+ }),
176
+ titleFieldId: (0, _fields.string)(),
177
+ fields: (0, _fields.fields)({
178
+ instanceOf: ContentModelFieldModel,
179
+ value: [],
180
+ list: true,
181
+ required: true
182
+ }),
183
+ layout: (0, _commodoFieldsObject.object)({
184
+ value: [],
185
+ required: true
186
+ }),
187
+ tags: (0, _commodoFieldsObject.object)({
188
+ value: [],
189
+ required: false
190
+ })
191
+ })();
192
+ exports.UpdateContentModelModel = UpdateContentModelModel;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["requiredShortString","validation","create","shortString","RendererModel","withFields","name","string","ContentModelFieldModel","id","fieldId","validateFieldId","label","helpText","placeholderText","type","setOnce","tags","object","value","required","multipleValues","boolean","predefinedValues","fields","instanceOf","enabled","values","list","selected","renderer","message","settings","listValidation","CreateContentModelModel","modelId","description","group","layout","CreateContentModelModelFrom","locale","UpdateContentModelModel","titleFieldId"],"sources":["models.ts"],"sourcesContent":["import { validation } from \"@webiny/validation\";\n/**\n * Package commodo-fields-object does not have types\n */\n// @ts-ignore\nimport { object } from \"commodo-fields-object\";\n/**\n * Package commodo-fields does not have object.\n */\n// @ts-ignore\nimport { withFields, string, setOnce, boolean, fields } from \"@commodo/fields\";\nimport { validateFieldId } from \"./fieldIdValidation\";\n\nconst requiredShortString = validation.create(\"required,maxLength:255\");\nconst shortString = validation.create(\"maxLength:255\");\n\nconst RendererModel = withFields({\n name: string({ validation: requiredShortString })\n})();\n\nexport const ContentModelFieldModel = withFields({\n id: string({ validation: requiredShortString }),\n fieldId: string({\n validation: validateFieldId\n }),\n label: string({ validation: requiredShortString }),\n helpText: string({ validation: shortString }),\n placeholderText: string({ validation: shortString }),\n type: setOnce()(string({ validation: requiredShortString })),\n tags: object({ value: [], required: false }),\n multipleValues: boolean({ value: false }),\n predefinedValues: fields({\n value: {},\n instanceOf: withFields({\n enabled: boolean(),\n values: fields({\n value: [],\n list: true,\n instanceOf: withFields({\n label: string(),\n value: string(),\n selected: boolean()\n })()\n })\n })()\n }),\n renderer: fields({ instanceOf: RendererModel, validation: shortString }),\n validation: fields({\n list: true,\n value: [],\n instanceOf: withFields({\n name: string({ validation: requiredShortString }),\n message: string({ validation: shortString }),\n settings: object({ value: {} })\n })()\n }),\n listValidation: fields({\n list: true,\n value: [],\n instanceOf: withFields({\n name: string({ validation: requiredShortString }),\n message: string({ validation: shortString }),\n settings: object({ value: {} })\n })()\n }),\n settings: object({ value: {} })\n /**\n * By the default, field is not deleted.\n */\n // isDeleted: boolean({ value: false })\n})();\n\nexport const CreateContentModelModel = withFields({\n name: string({ validation: requiredShortString }),\n modelId: string({ validation: shortString }),\n description: string({ validation: shortString }),\n group: string({ validation: requiredShortString }),\n fields: fields({ instanceOf: ContentModelFieldModel, value: [], list: true, required: true }),\n layout: object({ value: [], required: true }),\n tags: object({ value: [], required: false })\n})();\n\nexport const CreateContentModelModelFrom = withFields({\n name: string({ validation: requiredShortString }),\n modelId: string({ validation: shortString }),\n description: string({ validation: shortString }),\n group: string({ validation: requiredShortString }),\n locale: string({ validation: shortString })\n})();\n\nexport const UpdateContentModelModel = withFields({\n name: string({ validation: shortString }),\n description: string({ validation: shortString }),\n group: string({ validation: shortString }),\n titleFieldId: string(),\n fields: fields({ instanceOf: ContentModelFieldModel, value: [], list: true, required: true }),\n layout: object({ value: [], required: true }),\n tags: object({ value: [], required: false })\n})();\n"],"mappings":";;;;;;;AAAA;;AAKA;;AAKA;;AACA;;AAVA;AACA;AACA;AACA;;AAEA;AACA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L0C,CAAX,GAApC;;AAQA,MAAMsC,uBAAuB,GAAG,IAAApC,kBAAA,EAAW;EAC9CC,IAAI,EAAE,IAAAC,cAAA,EAAO;IAAEN,UAAU,EAAEE;EAAd,CAAP,CADwC;EAE9CiC,WAAW,EAAE,IAAA7B,cAAA,EAAO;IAAEN,UAAU,EAAEE;EAAd,CAAP,CAFiC;EAG9CkC,KAAK,EAAE,IAAA9B,cAAA,EAAO;IAAEN,UAAU,EAAEE;EAAd,CAAP,CAHuC;EAI9CuC,YAAY,EAAE,IAAAnC,cAAA,GAJgC;EAK9CiB,MAAM,EAAE,IAAAA,cAAA,EAAO;IAAEC,UAAU,EAAEjB,sBAAd;IAAsCW,KAAK,EAAE,EAA7C;IAAiDS,IAAI,EAAE,IAAvD;IAA6DR,QAAQ,EAAE;EAAvE,CAAP,CALsC;EAM9CkB,MAAM,EAAE,IAAApB,2BAAA,EAAO;IAAEC,KAAK,EAAE,EAAT;IAAaC,QAAQ,EAAE;EAAvB,CAAP,CANsC;EAO9CH,IAAI,EAAE,IAAAC,2BAAA,EAAO;IAAEC,KAAK,EAAE,EAAT;IAAaC,QAAQ,EAAE;EAAvB,CAAP;AAPwC,CAAX,GAAhC"}
@@ -1 +1 @@
1
- {"version":3,"names":["fieldSystemFields"],"sources":["systemFields.ts"],"sourcesContent":["export const fieldSystemFields: string[] = [\n \"id\",\n \"fieldId\",\n \"storageId\",\n \"label\",\n \"helpText\",\n \"placeholderText\",\n \"type\",\n \"multipleValues\",\n \"predefinedValues\",\n \"renderer\",\n \"validation\",\n \"listValidation\",\n \"settings\"\n];\n"],"mappings":";;;;;;AAAO,MAAMA,iBAA2B,GAAG,CACvC,IAAI,EACJ,SAAS,EACT,WAAW,EACX,OAAO,EACP,UAAU,EACV,iBAAiB,EACjB,MAAM,EACN,gBAAgB,EAChB,kBAAkB,EAClB,UAAU,EACV,YAAY,EACZ,gBAAgB,EAChB,UAAU,CACb;AAAC"}
1
+ {"version":3,"names":["fieldSystemFields"],"sources":["systemFields.ts"],"sourcesContent":["export const fieldSystemFields: string[] = [\n \"id\",\n \"fieldId\",\n \"storageId\",\n \"label\",\n \"helpText\",\n \"placeholderText\",\n \"type\",\n \"multipleValues\",\n \"predefinedValues\",\n \"renderer\",\n \"validation\",\n \"listValidation\",\n \"settings\"\n];\n"],"mappings":";;;;;;AAAO,MAAMA,iBAA2B,GAAG,CACvC,IADuC,EAEvC,SAFuC,EAGvC,WAHuC,EAIvC,OAJuC,EAKvC,UALuC,EAMvC,iBANuC,EAOvC,MAPuC,EAQvC,gBARuC,EASvC,kBATuC,EAUvC,UAVuC,EAWvC,YAXuC,EAYvC,gBAZuC,EAavC,UAbuC,CAApC"}
@@ -0,0 +1,6 @@
1
+ import { CmsModel } from "../../../types";
2
+ interface Params {
3
+ model: Pick<CmsModel, "singularApiName" | "pluralApiName">;
4
+ }
5
+ export declare const validateEndingAllowed: (params: Params) => void;
6
+ export {};
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.validateEndingAllowed = void 0;
8
+ var _error = _interopRequireDefault(require("@webiny/error"));
9
+ var _isModelEndingAllowed = require("./isModelEndingAllowed");
10
+ const validateEndingAllowed = params => {
11
+ const {
12
+ model
13
+ } = params;
14
+ if ((0, _isModelEndingAllowed.isModelEndingAllowed)(model.singularApiName) === false) {
15
+ throw new _error.default(`Content model with singularApiName "${model.singularApiName}" is not allowed, as it ends in disallowed value.`, "MODEL_SINGULAR_API_NAME_ENDING_NOT_ALLOWED", {
16
+ input: model.singularApiName,
17
+ disallowedEnding: _isModelEndingAllowed.disallowedEnding
18
+ });
19
+ } else if ((0, _isModelEndingAllowed.isModelEndingAllowed)(model.pluralApiName) === false) {
20
+ throw new _error.default(`Content model with pluralApiName "${model.pluralApiName}" is not allowed, as it ends in disallowed value.`, "MODEL_PLURAL_API_NAME_NOT_ENDING_ALLOWED", {
21
+ input: model.pluralApiName,
22
+ disallowedEnding: _isModelEndingAllowed.disallowedEnding
23
+ });
24
+ }
25
+ };
26
+ exports.validateEndingAllowed = validateEndingAllowed;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["validateEndingAllowed","params","model","isModelEndingAllowed","singularApiName","WebinyError","input","disallowedEnding","pluralApiName"],"sources":["endingAllowed.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { disallowedEnding, isModelEndingAllowed } from \"./isModelEndingAllowed\";\nimport { CmsModel } from \"~/types\";\n\ninterface Params {\n model: Pick<CmsModel, \"singularApiName\" | \"pluralApiName\">;\n}\n\nexport const validateEndingAllowed = (params: Params): void => {\n const { model } = params;\n if (isModelEndingAllowed(model.singularApiName) === false) {\n throw new WebinyError(\n `Content model with singularApiName \"${model.singularApiName}\" is not allowed, as it ends in disallowed value.`,\n \"MODEL_SINGULAR_API_NAME_ENDING_NOT_ALLOWED\",\n {\n input: model.singularApiName,\n disallowedEnding\n }\n );\n } else if (isModelEndingAllowed(model.pluralApiName) === false) {\n throw new WebinyError(\n `Content model with pluralApiName \"${model.pluralApiName}\" is not allowed, as it ends in disallowed value.`,\n \"MODEL_PLURAL_API_NAME_NOT_ENDING_ALLOWED\",\n {\n input: model.pluralApiName,\n disallowedEnding: disallowedEnding\n }\n );\n }\n};\n"],"mappings":";;;;;;;AAAA;AACA;AAOO,MAAMA,qBAAqB,GAAIC,MAAc,IAAW;EAC3D,MAAM;IAAEC;EAAM,CAAC,GAAGD,MAAM;EACxB,IAAI,IAAAE,0CAAoB,EAACD,KAAK,CAACE,eAAe,CAAC,KAAK,KAAK,EAAE;IACvD,MAAM,IAAIC,cAAW,CAChB,uCAAsCH,KAAK,CAACE,eAAgB,mDAAkD,EAC/G,4CAA4C,EAC5C;MACIE,KAAK,EAAEJ,KAAK,CAACE,eAAe;MAC5BG,gBAAgB,EAAhBA;IACJ,CAAC,CACJ;EACL,CAAC,MAAM,IAAI,IAAAJ,0CAAoB,EAACD,KAAK,CAACM,aAAa,CAAC,KAAK,KAAK,EAAE;IAC5D,MAAM,IAAIH,cAAW,CAChB,qCAAoCH,KAAK,CAACM,aAAc,mDAAkD,EAC3G,0CAA0C,EAC1C;MACIF,KAAK,EAAEJ,KAAK,CAACM,aAAa;MAC1BD,gBAAgB,EAAEA;IACtB,CAAC,CACJ;EACL;AACJ,CAAC;AAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * This list is to disallow creating models that might interfere with GraphQL schema creation.
3
+ * Add more if required.
4
+ */
5
+ export declare const disallowedEnding: string[];
6
+ export declare const isModelEndingAllowed: (apiName: string) => boolean;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isModelEndingAllowed = exports.disallowedEnding = void 0;
7
+ /**
8
+ * This list is to disallow creating models that might interfere with GraphQL schema creation.
9
+ * Add more if required.
10
+ */
11
+ const disallowedEnding = ["Response", "List", "Meta", "Input", "Sorter", "RefType"];
12
+ exports.disallowedEnding = disallowedEnding;
13
+ const isModelEndingAllowed = apiName => {
14
+ for (const ending of disallowedEnding) {
15
+ const re = new RegExp(`${ending}$`, "i");
16
+ const matched = apiName.match(re);
17
+ if (matched === null) {
18
+ continue;
19
+ }
20
+ return false;
21
+ }
22
+ return true;
23
+ };
24
+ exports.isModelEndingAllowed = isModelEndingAllowed;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["disallowedEnding","isModelEndingAllowed","apiName","ending","re","RegExp","matched","match"],"sources":["isModelEndingAllowed.ts"],"sourcesContent":["/**\n * This list is to disallow creating models that might interfere with GraphQL schema creation.\n * Add more if required.\n */\nexport const disallowedEnding: string[] = [\n \"Response\",\n \"List\",\n \"Meta\",\n \"Input\",\n \"Sorter\",\n \"RefType\"\n];\n\nexport const isModelEndingAllowed = (apiName: string): boolean => {\n for (const ending of disallowedEnding) {\n const re = new RegExp(`${ending}$`, \"i\");\n const matched = apiName.match(re);\n if (matched === null) {\n continue;\n }\n return false;\n }\n return true;\n};\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACO,MAAMA,gBAA0B,GAAG,CACtC,UAAU,EACV,MAAM,EACN,MAAM,EACN,OAAO,EACP,QAAQ,EACR,SAAS,CACZ;AAAC;AAEK,MAAMC,oBAAoB,GAAIC,OAAe,IAAc;EAC9D,KAAK,MAAMC,MAAM,IAAIH,gBAAgB,EAAE;IACnC,MAAMI,EAAE,GAAG,IAAIC,MAAM,CAAE,GAAEF,MAAO,GAAE,EAAE,GAAG,CAAC;IACxC,MAAMG,OAAO,GAAGJ,OAAO,CAACK,KAAK,CAACH,EAAE,CAAC;IACjC,IAAIE,OAAO,KAAK,IAAI,EAAE;MAClB;IACJ;IACA,OAAO,KAAK;EAChB;EACA,OAAO,IAAI;AACf,CAAC;AAAC"}
@@ -0,0 +1,11 @@
1
+ import { CmsModel } from "../../../types";
2
+ interface ModelIdAllowedParams {
3
+ model: Pick<CmsModel, "modelId">;
4
+ }
5
+ export declare const validateModelIdAllowed: (params: ModelIdAllowedParams) => void;
6
+ interface Params {
7
+ existingModel: Pick<CmsModel, "modelId">;
8
+ model: Pick<CmsModel, "modelId">;
9
+ }
10
+ export declare const validateExistingModelId: (params: Params) => void;
11
+ export {};
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.validateModelIdAllowed = exports.validateExistingModelId = void 0;
8
+ var _error = _interopRequireDefault(require("@webiny/error"));
9
+ const disallowedModelIdList = ["contentModel", "contentModels", "contentModelGroup", "contentModelGroups"];
10
+ const isModelIdAllowed = modelId => {
11
+ return disallowedModelIdList.includes(modelId) === false;
12
+ };
13
+ const validateModelIdAllowed = params => {
14
+ const {
15
+ model
16
+ } = params;
17
+ if (isModelIdAllowed(model.modelId)) {
18
+ return;
19
+ }
20
+ throw new _error.default(`Provided model ID "${model.modelId}" is not allowed.`, "MODEL_ID_NOT_ALLOWED", {
21
+ input: model.modelId
22
+ });
23
+ };
24
+ exports.validateModelIdAllowed = validateModelIdAllowed;
25
+ const validateExistingModelId = params => {
26
+ const {
27
+ existingModel,
28
+ model
29
+ } = params;
30
+ if (existingModel.modelId === model.modelId) {
31
+ throw new _error.default(`Content model with modelId "${model.modelId}" already exists.`, "MODEL_ID_EXISTS", {
32
+ input: existingModel.modelId
33
+ });
34
+ }
35
+ };
36
+ exports.validateExistingModelId = validateExistingModelId;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["disallowedModelIdList","isModelIdAllowed","modelId","includes","validateModelIdAllowed","params","model","WebinyError","input","validateExistingModelId","existingModel"],"sources":["modelId.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsModel } from \"~/types\";\n\nconst disallowedModelIdList: string[] = [\n \"contentModel\",\n \"contentModels\",\n \"contentModelGroup\",\n \"contentModelGroups\"\n];\nconst isModelIdAllowed = (modelId: string): boolean => {\n return disallowedModelIdList.includes(modelId) === false;\n};\n\ninterface ModelIdAllowedParams {\n model: Pick<CmsModel, \"modelId\">;\n}\n\nexport const validateModelIdAllowed = (params: ModelIdAllowedParams) => {\n const { model } = params;\n if (isModelIdAllowed(model.modelId)) {\n return;\n }\n throw new WebinyError(\n `Provided model ID \"${model.modelId}\" is not allowed.`,\n \"MODEL_ID_NOT_ALLOWED\",\n {\n input: model.modelId\n }\n );\n};\n\ninterface Params {\n existingModel: Pick<CmsModel, \"modelId\">;\n model: Pick<CmsModel, \"modelId\">;\n}\n\nexport const validateExistingModelId = (params: Params): void => {\n const { existingModel, model } = params;\n\n if (existingModel.modelId === model.modelId) {\n throw new WebinyError(\n `Content model with modelId \"${model.modelId}\" already exists.`,\n \"MODEL_ID_EXISTS\",\n {\n input: existingModel.modelId\n }\n );\n }\n};\n"],"mappings":";;;;;;;AAAA;AAGA,MAAMA,qBAA+B,GAAG,CACpC,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,oBAAoB,CACvB;AACD,MAAMC,gBAAgB,GAAIC,OAAe,IAAc;EACnD,OAAOF,qBAAqB,CAACG,QAAQ,CAACD,OAAO,CAAC,KAAK,KAAK;AAC5D,CAAC;AAMM,MAAME,sBAAsB,GAAIC,MAA4B,IAAK;EACpE,MAAM;IAAEC;EAAM,CAAC,GAAGD,MAAM;EACxB,IAAIJ,gBAAgB,CAACK,KAAK,CAACJ,OAAO,CAAC,EAAE;IACjC;EACJ;EACA,MAAM,IAAIK,cAAW,CAChB,sBAAqBD,KAAK,CAACJ,OAAQ,mBAAkB,EACtD,sBAAsB,EACtB;IACIM,KAAK,EAAEF,KAAK,CAACJ;EACjB,CAAC,CACJ;AACL,CAAC;AAAC;AAOK,MAAMO,uBAAuB,GAAIJ,MAAc,IAAW;EAC7D,MAAM;IAAEK,aAAa;IAAEJ;EAAM,CAAC,GAAGD,MAAM;EAEvC,IAAIK,aAAa,CAACR,OAAO,KAAKI,KAAK,CAACJ,OAAO,EAAE;IACzC,MAAM,IAAIK,cAAW,CAChB,+BAA8BD,KAAK,CAACJ,OAAQ,mBAAkB,EAC/D,iBAAiB,EACjB;MACIM,KAAK,EAAEE,aAAa,CAACR;IACzB,CAAC,CACJ;EACL;AACJ,CAAC;AAAC"}
@@ -0,0 +1,7 @@
1
+ import { CmsModel } from "../../../types";
2
+ interface Params {
3
+ existingModel: Pick<CmsModel, "singularApiName" | "pluralApiName">;
4
+ model: Pick<CmsModel, "singularApiName" | "pluralApiName">;
5
+ }
6
+ export declare const validatePluralApiName: (params: Params) => void;
7
+ export {};
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.validatePluralApiName = void 0;
8
+ var _error = _interopRequireDefault(require("@webiny/error"));
9
+ const validatePluralApiName = params => {
10
+ const {
11
+ existingModel,
12
+ model
13
+ } = params;
14
+ if (existingModel.singularApiName === model.pluralApiName) {
15
+ throw new _error.default(`Content model with singularApiName "${model.pluralApiName}" already exists.`, "MODEL_SINGULAR_API_NAME_EXISTS", {
16
+ input: model.pluralApiName
17
+ });
18
+ } else if (existingModel.pluralApiName === model.pluralApiName) {
19
+ throw new _error.default(`Content model with pluralApiName "${model.pluralApiName}" already exists.`, "MODEL_PLURAL_API_NAME_EXISTS", {
20
+ input: model.pluralApiName
21
+ });
22
+ }
23
+ };
24
+ exports.validatePluralApiName = validatePluralApiName;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["validatePluralApiName","params","existingModel","model","singularApiName","pluralApiName","WebinyError","input"],"sources":["pluralApiName.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsModel } from \"~/types\";\n\ninterface Params {\n existingModel: Pick<CmsModel, \"singularApiName\" | \"pluralApiName\">;\n model: Pick<CmsModel, \"singularApiName\" | \"pluralApiName\">;\n}\n\nexport const validatePluralApiName = (params: Params): void => {\n const { existingModel, model } = params;\n\n if (existingModel.singularApiName === model.pluralApiName) {\n throw new WebinyError(\n `Content model with singularApiName \"${model.pluralApiName}\" already exists.`,\n \"MODEL_SINGULAR_API_NAME_EXISTS\",\n {\n input: model.pluralApiName\n }\n );\n } else if (existingModel.pluralApiName === model.pluralApiName) {\n throw new WebinyError(\n `Content model with pluralApiName \"${model.pluralApiName}\" already exists.`,\n \"MODEL_PLURAL_API_NAME_EXISTS\",\n {\n input: model.pluralApiName\n }\n );\n }\n};\n"],"mappings":";;;;;;;AAAA;AAQO,MAAMA,qBAAqB,GAAIC,MAAc,IAAW;EAC3D,MAAM;IAAEC,aAAa;IAAEC;EAAM,CAAC,GAAGF,MAAM;EAEvC,IAAIC,aAAa,CAACE,eAAe,KAAKD,KAAK,CAACE,aAAa,EAAE;IACvD,MAAM,IAAIC,cAAW,CAChB,uCAAsCH,KAAK,CAACE,aAAc,mBAAkB,EAC7E,gCAAgC,EAChC;MACIE,KAAK,EAAEJ,KAAK,CAACE;IACjB,CAAC,CACJ;EACL,CAAC,MAAM,IAAIH,aAAa,CAACG,aAAa,KAAKF,KAAK,CAACE,aAAa,EAAE;IAC5D,MAAM,IAAIC,cAAW,CAChB,qCAAoCH,KAAK,CAACE,aAAc,mBAAkB,EAC3E,8BAA8B,EAC9B;MACIE,KAAK,EAAEJ,KAAK,CAACE;IACjB,CAAC,CACJ;EACL;AACJ,CAAC;AAAC"}
@@ -0,0 +1,7 @@
1
+ import { CmsModel } from "../../../types";
2
+ interface Params {
3
+ existingModel: Pick<CmsModel, "singularApiName" | "pluralApiName">;
4
+ model: Pick<CmsModel, "singularApiName" | "pluralApiName">;
5
+ }
6
+ export declare const validateSingularApiName: (params: Params) => void;
7
+ export {};
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.validateSingularApiName = void 0;
8
+ var _error = _interopRequireDefault(require("@webiny/error"));
9
+ const validateSingularApiName = params => {
10
+ const {
11
+ existingModel,
12
+ model
13
+ } = params;
14
+ if (existingModel.singularApiName === model.singularApiName) {
15
+ throw new _error.default(`Content model with singularApiName "${model.singularApiName}" already exists.`, "MODEL_SINGULAR_API_NAME_EXISTS", {
16
+ input: model.singularApiName
17
+ });
18
+ } else if (existingModel.pluralApiName === model.singularApiName) {
19
+ throw new _error.default(`Content model with pluralApiName "${model.singularApiName}" already exists.`, "MODEL_PLURAL_API_NAME_EXISTS", {
20
+ input: model.singularApiName
21
+ });
22
+ }
23
+ };
24
+ exports.validateSingularApiName = validateSingularApiName;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["validateSingularApiName","params","existingModel","model","singularApiName","WebinyError","input","pluralApiName"],"sources":["singularApiName.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsModel } from \"~/types\";\n\ninterface Params {\n existingModel: Pick<CmsModel, \"singularApiName\" | \"pluralApiName\">;\n model: Pick<CmsModel, \"singularApiName\" | \"pluralApiName\">;\n}\n\nexport const validateSingularApiName = (params: Params): void => {\n const { existingModel, model } = params;\n\n if (existingModel.singularApiName === model.singularApiName) {\n throw new WebinyError(\n `Content model with singularApiName \"${model.singularApiName}\" already exists.`,\n \"MODEL_SINGULAR_API_NAME_EXISTS\",\n {\n input: model.singularApiName\n }\n );\n } else if (existingModel.pluralApiName === model.singularApiName) {\n throw new WebinyError(\n `Content model with pluralApiName \"${model.singularApiName}\" already exists.`,\n \"MODEL_PLURAL_API_NAME_EXISTS\",\n {\n input: model.singularApiName\n }\n );\n }\n};\n"],"mappings":";;;;;;;AAAA;AAQO,MAAMA,uBAAuB,GAAIC,MAAc,IAAW;EAC7D,MAAM;IAAEC,aAAa;IAAEC;EAAM,CAAC,GAAGF,MAAM;EAEvC,IAAIC,aAAa,CAACE,eAAe,KAAKD,KAAK,CAACC,eAAe,EAAE;IACzD,MAAM,IAAIC,cAAW,CAChB,uCAAsCF,KAAK,CAACC,eAAgB,mBAAkB,EAC/E,gCAAgC,EAChC;MACIE,KAAK,EAAEH,KAAK,CAACC;IACjB,CAAC,CACJ;EACL,CAAC,MAAM,IAAIF,aAAa,CAACK,aAAa,KAAKJ,KAAK,CAACC,eAAe,EAAE;IAC9D,MAAM,IAAIC,cAAW,CAChB,qCAAoCF,KAAK,CAACC,eAAgB,mBAAkB,EAC7E,8BAA8B,EAC9B;MACIE,KAAK,EAAEH,KAAK,CAACC;IACjB,CAAC,CACJ;EACL;AACJ,CAAC;AAAC"}
@@ -1,5 +1,6 @@
1
1
  import { CmsContext, CmsModel } from "../../types";
2
2
  interface ValidateModelParams {
3
+ models: CmsModel[];
3
4
  model: CmsModel;
4
5
  original?: CmsModel;
5
6
  context: CmsContext;
@@ -1 +1 @@
1
- {"version":3,"names":["validateModel","params","model","context","plugins","modelPlugin","byType","CmsModelPlugin","type","find","item","contentModel","modelId","WebinyError","validateModelFields"],"sources":["validateModel.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsModelPlugin } from \"~/plugins/CmsModelPlugin\";\nimport { CmsContext, CmsModel } from \"~/types\";\nimport { validateModelFields } from \"~/crud/contentModel/validateModelFields\";\n\ninterface ValidateModelParams {\n model: CmsModel;\n original?: CmsModel;\n context: CmsContext;\n}\n\nexport const validateModel = async (params: ValidateModelParams): Promise<void> => {\n const { model, context } = params;\n\n const { plugins } = context;\n\n const modelPlugin = plugins\n .byType<CmsModelPlugin>(CmsModelPlugin.type)\n .find(item => item.contentModel.modelId === model.modelId);\n\n if (modelPlugin) {\n throw new WebinyError(\n \"Content models defined via plugins cannot be updated.\",\n \"CONTENT_MODEL_UPDATE_ERROR\",\n {\n modelId: model.modelId\n }\n );\n }\n\n await validateModelFields(params);\n};\n"],"mappings":";;;;;;;AAAA;AACA;AAEA;AAQO,MAAMA,aAAa,GAAG,MAAOC,MAA2B,IAAoB;EAC/E,MAAM;IAAEC,KAAK;IAAEC;EAAQ,CAAC,GAAGF,MAAM;EAEjC,MAAM;IAAEG;EAAQ,CAAC,GAAGD,OAAO;EAE3B,MAAME,WAAW,GAAGD,OAAO,CACtBE,MAAM,CAAiBC,8BAAc,CAACC,IAAI,CAAC,CAC3CC,IAAI,CAACC,IAAI,IAAIA,IAAI,CAACC,YAAY,CAACC,OAAO,KAAKV,KAAK,CAACU,OAAO,CAAC;EAE9D,IAAIP,WAAW,EAAE;IACb,MAAM,IAAIQ,cAAW,CACjB,uDAAuD,EACvD,4BAA4B,EAC5B;MACID,OAAO,EAAEV,KAAK,CAACU;IACnB,CAAC,CACJ;EACL;EAEA,MAAM,IAAAE,wCAAmB,EAACb,MAAM,CAAC;AACrC,CAAC;AAAC"}
1
+ {"version":3,"names":["validateModel","params","model","context","plugins","modelPlugin","byType","CmsModelPlugin","type","find","item","contentModel","modelId","WebinyError","validateModelFields"],"sources":["validateModel.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsModelPlugin } from \"~/plugins/CmsModelPlugin\";\nimport { CmsContext, CmsModel } from \"~/types\";\nimport { validateModelFields } from \"~/crud/contentModel/validateModelFields\";\n\ninterface ValidateModelParams {\n models: CmsModel[];\n model: CmsModel;\n original?: CmsModel;\n context: CmsContext;\n}\n\nexport const validateModel = async (params: ValidateModelParams): Promise<void> => {\n const { model, context } = params;\n\n const { plugins } = context;\n\n const modelPlugin = plugins\n .byType<CmsModelPlugin>(CmsModelPlugin.type)\n .find(item => item.contentModel.modelId === model.modelId);\n\n if (modelPlugin) {\n throw new WebinyError(\n \"Content models defined via plugins cannot be updated.\",\n \"CONTENT_MODEL_UPDATE_ERROR\",\n {\n modelId: model.modelId\n }\n );\n }\n\n await validateModelFields(params);\n};\n"],"mappings":";;;;;;;AAAA;AACA;AAEA;AASO,MAAMA,aAAa,GAAG,MAAOC,MAA2B,IAAoB;EAC/E,MAAM;IAAEC,KAAK;IAAEC;EAAQ,CAAC,GAAGF,MAAM;EAEjC,MAAM;IAAEG;EAAQ,CAAC,GAAGD,OAAO;EAE3B,MAAME,WAAW,GAAGD,OAAO,CACtBE,MAAM,CAAiBC,8BAAc,CAACC,IAAI,CAAC,CAC3CC,IAAI,CAACC,IAAI,IAAIA,IAAI,CAACC,YAAY,CAACC,OAAO,KAAKV,KAAK,CAACU,OAAO,CAAC;EAE9D,IAAIP,WAAW,EAAE;IACb,MAAM,IAAIQ,cAAW,CACjB,uDAAuD,EACvD,4BAA4B,EAC5B;MACID,OAAO,EAAEV,KAAK,CAACU;IACnB,CAAC,CACJ;EACL;EAEA,MAAM,IAAAE,wCAAmB,EAACb,MAAM,CAAC;AACrC,CAAC;AAAC"}
@@ -1,5 +1,6 @@
1
- import { CmsContext, CmsModel } from "../../types";
1
+ import { CmsModel, CmsContext } from "../../types";
2
2
  interface ValidateModelFieldsParams {
3
+ models: CmsModel[];
3
4
  model: CmsModel;
4
5
  original?: CmsModel;
5
6
  context: CmsContext;
@@ -6,63 +6,18 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.validateModelFields = void 0;
8
8
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
9
+ var _graphqlTag = _interopRequireDefault(require("graphql-tag"));
9
10
  var _error = _interopRequireDefault(require("@webiny/error"));
10
11
  var _createManageSDL = require("../../graphql/schema/createManageSDL");
11
- var _graphqlTag = _interopRequireDefault(require("graphql-tag"));
12
12
  var _createFieldStorageId = require("./createFieldStorageId");
13
13
  var _getBaseFieldType = require("../../utils/getBaseFieldType");
14
+ var _titleField = require("./fields/titleField");
15
+ var _descriptionField = require("./fields/descriptionField");
16
+ var _imageField = require("./fields/imageField");
14
17
  var _plugins = require("../../plugins");
15
18
  var _buildSchemaPlugins = require("../../graphql/buildSchemaPlugins");
16
19
  var _createExecutableSchema = require("../../graphql/createExecutableSchema");
17
- var _handlerGraphql = require("@webiny/handler-graphql");
18
- const defaultTitleFieldId = "id";
19
- const allowedTitleFieldTypes = ["text", "number"];
20
- const getContentModelTitleFieldId = (fields, titleFieldId) => {
21
- /**
22
- * If there are no fields defined, we will return the default field
23
- */
24
- if (fields.length === 0) {
25
- return defaultTitleFieldId;
26
- }
27
- /**
28
- * if there is no title field defined either in input data or existing content model data
29
- * we will take first text field that has no multiple values enabled
30
- * or if initial titleFieldId is the default one also try to find first available text field
31
- */
32
- if (!titleFieldId || titleFieldId === defaultTitleFieldId) {
33
- const titleField = fields.find(field => {
34
- return (0, _getBaseFieldType.getBaseFieldType)(field) === "text" && !field.multipleValues;
35
- });
36
- return (titleField === null || titleField === void 0 ? void 0 : titleField.fieldId) || defaultTitleFieldId;
37
- }
38
- /**
39
- * check existing titleFieldId for existence in the model
40
- * for correct type
41
- * and that it is not multiple values field
42
- */
43
- const target = fields.find(f => f.fieldId === titleFieldId);
44
- if (!target) {
45
- throw new _error.default(`Field selected for the title field does not exist in the model.`, "VALIDATION_ERROR", {
46
- fieldId: titleFieldId,
47
- fields
48
- });
49
- }
50
- if (allowedTitleFieldTypes.includes(target.type) === false) {
51
- throw new _error.default(`Only ${allowedTitleFieldTypes.join(", ")} and id fields can be used as an entry title.`, "ENTRY_TITLE_FIELD_TYPE", {
52
- storageId: target.storageId,
53
- fieldId: target.fieldId,
54
- type: target.type
55
- });
56
- }
57
- if (target.multipleValues) {
58
- throw new _error.default(`Fields that accept multiple values cannot be used as the entry title.`, "ENTRY_TITLE_FIELD_TYPE", {
59
- storageId: target.storageId,
60
- fieldId: target.fieldId,
61
- type: target.type
62
- });
63
- }
64
- return target.fieldId;
65
- };
20
+ var _utils = require("@webiny/utils");
66
21
  const extractInvalidField = (model, err) => {
67
22
  var _err$source;
68
23
  const sdl = ((_err$source = err.source) === null || _err$source === void 0 ? void 0 : _err$source.body) || "";
@@ -232,14 +187,26 @@ const createGraphQLSchema = async params => {
232
187
  context,
233
188
  model
234
189
  } = params;
190
+ const models = await context.security.withoutAuthorization(async () => {
191
+ return (await context.cms.listModels()).filter(model => {
192
+ return model.isPrivate !== true;
193
+ });
194
+ });
235
195
  const modelPlugins = await (0, _buildSchemaPlugins.buildSchemaPlugins)({
236
196
  context,
237
- models: [model]
197
+ models: models.concat([model])
238
198
  });
239
- const plugins = context.plugins.byType(_handlerGraphql.GraphQLSchemaPlugin.type);
240
- plugins.push(...modelPlugins);
199
+ const plugins = context.plugins.byType(_plugins.CmsGraphQLSchemaPlugin.type).reduce((collection, plugin) => {
200
+ const name = plugin.name || `${_plugins.CmsGraphQLSchemaPlugin.type}-${(0, _utils.generateAlphaNumericId)(16)}`;
201
+ collection[name] = plugin;
202
+ return collection;
203
+ }, {});
204
+ for (const plugin of modelPlugins) {
205
+ const name = plugin.name || `${plugin.type}-${(0, _utils.generateAlphaNumericId)(16)}`;
206
+ plugins[name] = plugin;
207
+ }
241
208
  return (0, _createExecutableSchema.createExecutableSchema)({
242
- plugins
209
+ plugins: Object.values(plugins)
243
210
  });
244
211
  };
245
212
  const extractErrorObject = error => {
@@ -253,12 +220,15 @@ const extractErrorObject = error => {
253
220
  };
254
221
  const validateModelFields = async params => {
255
222
  const {
223
+ models,
256
224
  model,
257
225
  original,
258
226
  context
259
227
  } = params;
260
228
  const {
261
- titleFieldId
229
+ titleFieldId,
230
+ descriptionFieldId,
231
+ imageFieldId
262
232
  } = model;
263
233
  const {
264
234
  plugins
@@ -289,6 +259,7 @@ const validateModelFields = async params => {
289
259
  * Make sure that this model can be safely converted to a GraphQL SDL
290
260
  */
291
261
  const schema = (0, _createManageSDL.createManageSDL)({
262
+ models,
292
263
  model,
293
264
  fieldTypePlugins: fieldTypePlugins.reduce((acc, pl) => (0, _objectSpread2.default)((0, _objectSpread2.default)({}, acc), {}, {
294
265
  [pl.fieldType]: pl
@@ -319,7 +290,9 @@ const validateModelFields = async params => {
319
290
  });
320
291
  }
321
292
  }
322
- model.titleFieldId = getContentModelTitleFieldId(fields, titleFieldId);
293
+ model.titleFieldId = (0, _titleField.getContentModelTitleFieldId)(fields, titleFieldId);
294
+ model.descriptionFieldId = (0, _descriptionField.getContentModelDescriptionFieldId)(fields, descriptionFieldId);
295
+ model.imageFieldId = (0, _imageField.getContentModelImageFieldId)(fields, imageFieldId);
323
296
  const cmsLockedFieldPlugins = plugins.byType("cms-model-locked-field");
324
297
 
325
298
  /**