@webiny/api-headless-cms 0.0.0-unstable.9e825fd5fb → 0.0.0-unstable.aa00eecd97

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 (135) hide show
  1. package/context.js +4 -3
  2. package/context.js.map +1 -1
  3. package/crud/contentEntry/referenceFieldsMapping.js +34 -5
  4. package/crud/contentEntry/referenceFieldsMapping.js.map +1 -1
  5. package/crud/contentEntry.crud.d.ts +4 -4
  6. package/crud/contentEntry.crud.js +207 -106
  7. package/crud/contentEntry.crud.js.map +1 -1
  8. package/crud/contentModel/beforeDelete.d.ts +1 -1
  9. package/crud/contentModel/beforeDelete.js +1 -5
  10. package/crud/contentModel/beforeDelete.js.map +1 -1
  11. package/crud/contentModel/validation.d.ts +48 -16
  12. package/crud/contentModel/validation.js +2 -2
  13. package/crud/contentModel/validation.js.map +1 -1
  14. package/crud/contentModelGroup.crud.js +1 -7
  15. package/crud/contentModelGroup.crud.js.map +1 -1
  16. package/graphql/checkEndpointAccess.d.ts +2 -0
  17. package/graphql/checkEndpointAccess.js +18 -0
  18. package/graphql/checkEndpointAccess.js.map +1 -0
  19. package/graphql/createRequestBody.d.ts +2 -0
  20. package/graphql/createRequestBody.js +14 -0
  21. package/graphql/createRequestBody.js.map +1 -0
  22. package/graphql/formatErrorPayload.d.ts +1 -0
  23. package/graphql/formatErrorPayload.js +25 -0
  24. package/graphql/formatErrorPayload.js.map +1 -0
  25. package/graphql/generateSchema.js.map +1 -1
  26. package/graphql/getSchema.d.ts +17 -0
  27. package/graphql/getSchema.js +102 -0
  28. package/graphql/getSchema.js.map +1 -0
  29. package/graphql/graphQLHandlerFactory.js +5 -190
  30. package/graphql/graphQLHandlerFactory.js.map +1 -1
  31. package/graphql/handleRequest.d.ts +11 -0
  32. package/graphql/handleRequest.js +81 -0
  33. package/graphql/handleRequest.js.map +1 -0
  34. package/graphql/schema/baseSchema.js +15 -0
  35. package/graphql/schema/baseSchema.js.map +1 -1
  36. package/graphql/schema/createFieldResolvers.d.ts +1 -1
  37. package/graphql/schema/createFieldResolvers.js +6 -12
  38. package/graphql/schema/createFieldResolvers.js.map +1 -1
  39. package/graphql/schema/createFieldTypePluginRecords.d.ts +3 -0
  40. package/graphql/schema/createFieldTypePluginRecords.js +13 -0
  41. package/graphql/schema/createFieldTypePluginRecords.js.map +1 -0
  42. package/graphql/schema/createManageResolvers.js +4 -0
  43. package/graphql/schema/createManageResolvers.js.map +1 -1
  44. package/graphql/schema/createManageSDL.js +34 -26
  45. package/graphql/schema/createManageSDL.js.map +1 -1
  46. package/graphql/schema/createReadSDL.js +22 -19
  47. package/graphql/schema/createReadSDL.js.map +1 -1
  48. package/graphql/schema/resolvers/manage/resolveDelete.d.ts +2 -1
  49. package/graphql/schema/resolvers/manage/resolveDelete.js +13 -3
  50. package/graphql/schema/resolvers/manage/resolveDelete.js.map +1 -1
  51. package/graphql/schema/resolvers/manage/resolveDeleteMultiple.d.ts +7 -0
  52. package/graphql/schema/resolvers/manage/resolveDeleteMultiple.js +20 -0
  53. package/graphql/schema/resolvers/manage/resolveDeleteMultiple.js.map +1 -0
  54. package/graphql/schema/resolvers/manage/resolveGetUniqueFieldValues.d.ts +4 -0
  55. package/graphql/schema/resolvers/manage/resolveGetUniqueFieldValues.js +18 -0
  56. package/graphql/schema/resolvers/manage/resolveGetUniqueFieldValues.js.map +1 -0
  57. package/graphql/schema/schemaPlugins.js +2 -11
  58. package/graphql/schema/schemaPlugins.js.map +1 -1
  59. package/graphqlFields/dynamicZone/dynamicZoneField.d.ts +1 -1
  60. package/graphqlFields/dynamicZone/dynamicZoneField.js +44 -17
  61. package/graphqlFields/dynamicZone/dynamicZoneField.js.map +1 -1
  62. package/graphqlFields/object.js.map +1 -1
  63. package/graphqlFields/ref.js +7 -7
  64. package/graphqlFields/ref.js.map +1 -1
  65. package/index.d.ts +1 -1
  66. package/index.js +13 -9
  67. package/index.js.map +1 -1
  68. package/package.json +35 -35
  69. package/plugins/CmsModelPlugin.d.ts +3 -1
  70. package/plugins/CmsModelPlugin.js +5 -5
  71. package/plugins/CmsModelPlugin.js.map +1 -1
  72. package/plugins/StorageOperationsCmsModelPlugin.d.ts +23 -0
  73. package/plugins/StorageOperationsCmsModelPlugin.js +42 -0
  74. package/plugins/StorageOperationsCmsModelPlugin.js.map +1 -0
  75. package/plugins/index.d.ts +1 -0
  76. package/plugins/index.js +11 -0
  77. package/plugins/index.js.map +1 -1
  78. package/types.d.ts +122 -71
  79. package/types.js +11 -0
  80. package/types.js.map +1 -1
  81. package/utils/converters/valueKeyStorageConverter.d.ts +1 -5
  82. package/utils/converters/valueKeyStorageConverter.js +24 -25
  83. package/utils/converters/valueKeyStorageConverter.js.map +1 -1
  84. package/utils/createTypeFromFields.js +1 -2
  85. package/utils/createTypeFromFields.js.map +1 -1
  86. package/utils/createTypeName.d.ts +0 -2
  87. package/utils/createTypeName.js +2 -10
  88. package/utils/createTypeName.js.map +1 -1
  89. package/utils/getBaseFieldType.d.ts +1 -3
  90. package/utils/getBaseFieldType.js.map +1 -1
  91. package/utils/getEntryDescription.d.ts +1 -1
  92. package/utils/getEntryDescription.js.map +1 -1
  93. package/utils/getEntryImage.d.ts +1 -1
  94. package/utils/getEntryImage.js.map +1 -1
  95. package/utils/getEntryTitle.d.ts +1 -1
  96. package/utils/getEntryTitle.js.map +1 -1
  97. package/utils/renderFields.d.ts +2 -1
  98. package/utils/renderFields.js +2 -1
  99. package/utils/renderFields.js.map +1 -1
  100. package/utils/renderGetFilterFields.d.ts +2 -2
  101. package/utils/renderGetFilterFields.js +7 -20
  102. package/utils/renderGetFilterFields.js.map +1 -1
  103. package/utils/renderInputFields.d.ts +2 -1
  104. package/utils/renderInputFields.js +14 -6
  105. package/utils/renderInputFields.js.map +1 -1
  106. package/utils/renderListFilterFields.d.ts +2 -1
  107. package/utils/renderListFilterFields.js +9 -20
  108. package/utils/renderListFilterFields.js.map +1 -1
  109. package/utils/renderSortEnum.d.ts +2 -1
  110. package/utils/renderSortEnum.js +2 -1
  111. package/utils/renderSortEnum.js.map +1 -1
  112. package/crud/contentModel/createFieldModels.d.ts +0 -2
  113. package/crud/contentModel/createFieldModels.js +0 -26
  114. package/crud/contentModel/createFieldModels.js.map +0 -1
  115. package/crud/contentModel/fieldIdValidation.d.ts +0 -1
  116. package/crud/contentModel/fieldIdValidation.js +0 -25
  117. package/crud/contentModel/fieldIdValidation.js.map +0 -1
  118. package/crud/contentModel/idValidation.d.ts +0 -1
  119. package/crud/contentModel/idValidation.js +0 -22
  120. package/crud/contentModel/idValidation.js.map +0 -1
  121. package/crud/contentModel/models.d.ts +0 -4
  122. package/crud/contentModel/models.js +0 -192
  123. package/crud/contentModel/models.js.map +0 -1
  124. package/crud/contentModel/systemFields.d.ts +0 -1
  125. package/crud/contentModel/systemFields.js +0 -8
  126. package/crud/contentModel/systemFields.js.map +0 -1
  127. package/upgrades/5.33.0/index.d.ts +0 -3
  128. package/upgrades/5.33.0/index.js +0 -182
  129. package/upgrades/5.33.0/index.js.map +0 -1
  130. package/upgrades/index.d.ts +0 -1
  131. package/upgrades/index.js +0 -12
  132. package/upgrades/index.js.map +0 -1
  133. package/utils/pluralizedTypeName.d.ts +0 -1
  134. package/utils/pluralizedTypeName.js +0 -26
  135. package/utils/pluralizedTypeName.js.map +0 -1
@@ -5,205 +5,20 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.graphQLHandlerFactory = void 0;
8
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
9
- var _error = _interopRequireDefault(require("@webiny/error"));
10
- var _codeFrame = _interopRequireDefault(require("code-frame"));
11
8
  var _debugPlugins = _interopRequireDefault(require("@webiny/handler-graphql/debugPlugins"));
12
- var _processRequestBody = _interopRequireDefault(require("@webiny/handler-graphql/processRequestBody"));
13
- var _apiSecurity = require("@webiny/api-security");
14
9
  var _handler = require("@webiny/handler");
15
- var _generateSchema = require("./generateSchema");
16
- // @ts-ignore `code-frame` has no types
17
-
18
- const createRequestBody = body => {
19
- /**
20
- * We are trusting that the body payload is correct.
21
- * The `processRequestBody` will fail if it is not.
22
- */
23
- return typeof body === "string" ? JSON.parse(body) : body;
24
- };
25
- const schemaList = new Map();
26
-
27
- /**
28
- * Method generates cache ID based on:
29
- * - tenant
30
- * - endpoint type
31
- * - locale
32
- */
33
-
34
- const generateCacheId = params => {
35
- const {
36
- getTenant,
37
- type,
38
- getLocale
39
- } = params;
40
- return [`tenant:${getTenant().id}`, `endpoint:${type}`, `locale:${getLocale().code}`].join("#");
41
- };
42
- /**
43
- * Method generates cache key based on last model change time.
44
- * Or sets "unknown" - possible when no models in database.
45
- */
46
-
47
- const generateCacheKey = async params => {
48
- const {
49
- getLastModifiedTime
50
- } = params;
51
- const lastModelChange = await getLastModifiedTime();
52
- if (!lastModelChange) {
53
- return "unknown";
54
- }
55
- return lastModelChange.toISOString();
56
- };
57
-
58
- /**
59
- * Gets an existing schema or rewrites existing one or creates a completely new one
60
- * depending on the schemaId created from type and locale parameters
61
- */
62
- const getSchema = async params => {
63
- const {
64
- context
65
- } = params;
66
- const cacheId = generateCacheId(params);
67
- const cacheKey = await generateCacheKey(params);
68
- const cachedSchema = schemaList.get(cacheId);
69
- if ((cachedSchema === null || cachedSchema === void 0 ? void 0 : cachedSchema.key) === cacheKey) {
70
- return cachedSchema.schema;
71
- }
72
-
73
- /**
74
- * We need all the API models.
75
- * Private models are hidden in the GraphQL, so filter them out.
76
- */
77
- const models = await context.security.withoutAuthorization(async () => {
78
- return (await context.cms.listModels()).filter(model => {
79
- return model.isPrivate !== true;
80
- });
81
- });
82
- try {
83
- const schema = await (0, _generateSchema.generateSchema)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
84
- models
85
- }));
86
- schemaList.set(cacheId, {
87
- key: cacheKey,
88
- schema
89
- });
90
- return schema;
91
- } catch (err) {
92
- if (!Array.isArray(err.locations)) {
93
- throw new _error.default({
94
- message: err.message,
95
- code: err.code || "INVALID_GRAPHQL_SCHEMA_LOCATIONS",
96
- data: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, err.data || {}), {}, {
97
- locations: err.locations
98
- })
99
- });
100
- }
101
- const [location] = err.locations;
102
- throw new _error.default({
103
- code: "INVALID_GRAPHQL_SCHEMA",
104
- message: err.message,
105
- data: {
106
- invalidSegment: (0, _codeFrame.default)(err.source.body, location.line, location.column, {
107
- frameSize: 15
108
- })
109
- }
110
- });
111
- }
112
- };
113
- const checkEndpointAccess = async context => {
114
- const permission = await context.security.getPermission(`cms.endpoint.${context.cms.type}`);
115
- if (!permission) {
116
- throw new _apiSecurity.NotAuthorizedError({
117
- data: {
118
- reason: `Not allowed to access "${context.cms.type}" endpoint.`
119
- }
120
- });
121
- }
122
- };
123
- const formatErrorPayload = error => {
124
- if (error instanceof _error.default) {
125
- return JSON.stringify({
126
- type: "CmsGraphQLWebinyError",
127
- message: error.message,
128
- code: error.code,
129
- data: error.data
130
- });
131
- }
132
- return JSON.stringify({
133
- type: "Error",
134
- name: error.name,
135
- message: error.message,
136
- stack: error.stack
137
- });
138
- };
10
+ var _handleRequest = require("./handleRequest");
139
11
  const cmsRoutes = new _handler.RoutePlugin(({
140
12
  onPost,
141
13
  onOptions,
142
14
  context
143
15
  }) => {
144
16
  onPost("/cms/:type(^manage|preview|read$)/:locale", async (request, reply) => {
145
- try {
146
- await checkEndpointAccess(context);
147
- } catch (ex) {
148
- return reply.code(401).send({
149
- data: null,
150
- error: {
151
- message: ex.message || "Not authorized!",
152
- code: ex.code || "SECURITY_NOT_AUTHORIZED",
153
- data: ex.data || null,
154
- stack: null
155
- }
156
- });
157
- }
158
- const getTenant = () => {
159
- return context.tenancy.getCurrentTenant();
160
- };
161
- const getLocale = () => {
162
- return context.cms.getLocale();
163
- };
164
- const getLastModifiedTime = async () => {
165
- return context.cms.getModelLastChange();
166
- };
167
- const schema = await context.benchmark.measure("headlessCms.graphql.getSchema", async () => {
168
- try {
169
- return await getSchema({
170
- context,
171
- getTenant,
172
- getLastModifiedTime,
173
- getLocale,
174
- type: context.cms.type
175
- });
176
- } catch (ex) {
177
- console.error(`Error while generating the schema.`);
178
- console.error(formatErrorPayload(ex));
179
- throw ex;
180
- }
181
- });
182
- const body = await context.benchmark.measure("headlessCms.graphql.createRequestBody", async () => {
183
- try {
184
- return createRequestBody(request.body);
185
- } catch (ex) {
186
- console.error(`Error while creating the body request.`);
187
- console.error(formatErrorPayload(ex));
188
- throw ex;
189
- }
190
- });
191
-
192
- /**
193
- * We need to store the processRequestBody result in a variable and output it after the measurement.
194
- * Otherwise, the measurement will not be shown in the output.
195
- */
196
- let result = null;
197
- await context.benchmark.measure("headlessCms.graphql.processRequestBody", async () => {
198
- try {
199
- result = await (0, _processRequestBody.default)(body, schema, context);
200
- } catch (ex) {
201
- console.error(`Error while processing the body request.`);
202
- console.error(formatErrorPayload(ex));
203
- throw ex;
204
- }
17
+ return (0, _handleRequest.handleRequest)({
18
+ context,
19
+ request,
20
+ reply
205
21
  });
206
- return reply.code(200).send(result);
207
22
  });
208
23
  onOptions("/cms/:type(^manage|preview|read$)/:locale", async (_, reply) => {
209
24
  return reply.status(204).send({}).hijack();
@@ -1 +1 @@
1
- {"version":3,"names":["createRequestBody","body","JSON","parse","schemaList","Map","generateCacheId","params","getTenant","type","getLocale","id","code","join","generateCacheKey","getLastModifiedTime","lastModelChange","toISOString","getSchema","context","cacheId","cacheKey","cachedSchema","get","key","schema","models","security","withoutAuthorization","cms","listModels","filter","model","isPrivate","generateSchema","set","err","Array","isArray","locations","WebinyError","message","data","location","invalidSegment","codeFrame","source","line","column","frameSize","checkEndpointAccess","permission","getPermission","NotAuthorizedError","reason","formatErrorPayload","error","stringify","name","stack","cmsRoutes","RoutePlugin","onPost","onOptions","request","reply","ex","send","tenancy","getCurrentTenant","getModelLastChange","benchmark","measure","console","result","processRequestBody","_","status","hijack","graphQLHandlerFactory","debug","debugPlugins"],"sources":["graphQLHandlerFactory.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\n// @ts-ignore `code-frame` has no types\nimport codeFrame from \"code-frame\";\nimport debugPlugins from \"@webiny/handler-graphql/debugPlugins\";\nimport processRequestBody from \"@webiny/handler-graphql/processRequestBody\";\nimport { ExecutionResult, GraphQLSchema } from \"graphql\";\nimport { ApiEndpoint, CmsContext } from \"~/types\";\nimport { I18NLocale } from \"@webiny/api-i18n/types\";\nimport { NotAuthorizedError } from \"@webiny/api-security\";\nimport { PluginCollection } from \"@webiny/plugins/types\";\nimport { GraphQLRequestBody } from \"@webiny/handler-graphql/types\";\nimport { RoutePlugin } from \"@webiny/handler\";\nimport { generateSchema } from \"~/graphql/generateSchema\";\nimport { Tenant } from \"@webiny/api-tenancy/types\";\n\ninterface SchemaCache {\n key: string;\n schema: GraphQLSchema;\n}\n\ninterface GetSchemaParams {\n context: CmsContext;\n type: ApiEndpoint;\n getLastModifiedTime: () => Promise<Date | null>;\n getTenant: () => Tenant;\n getLocale: () => I18NLocale;\n}\n\nconst createRequestBody = (body: unknown): GraphQLRequestBody | GraphQLRequestBody[] => {\n /**\n * We are trusting that the body payload is correct.\n * The `processRequestBody` will fail if it is not.\n */\n return typeof body === \"string\" ? JSON.parse(body) : body;\n};\n\nconst schemaList = new Map<string, SchemaCache>();\n\n/**\n * Method generates cache ID based on:\n * - tenant\n * - endpoint type\n * - locale\n */\ntype GenerateCacheIdParams = Pick<GetSchemaParams, \"getTenant\" | \"getLocale\" | \"type\">;\nconst generateCacheId = (params: GenerateCacheIdParams): string => {\n const { getTenant, type, getLocale } = params;\n return [`tenant:${getTenant().id}`, `endpoint:${type}`, `locale:${getLocale().code}`].join(\"#\");\n};\n/**\n * Method generates cache key based on last model change time.\n * Or sets \"unknown\" - possible when no models in database.\n */\ntype GenerateCacheKeyParams = Pick<GetSchemaParams, \"getLastModifiedTime\">;\nconst generateCacheKey = async (params: GenerateCacheKeyParams): Promise<string> => {\n const { getLastModifiedTime } = params;\n const lastModelChange = await getLastModifiedTime();\n if (!lastModelChange) {\n return \"unknown\";\n }\n return lastModelChange.toISOString();\n};\n\n/**\n * Gets an existing schema or rewrites existing one or creates a completely new one\n * depending on the schemaId created from type and locale parameters\n */\nconst getSchema = async (params: GetSchemaParams): Promise<GraphQLSchema> => {\n const { context } = params;\n\n const cacheId = generateCacheId(params);\n\n const cacheKey = await generateCacheKey(params);\n const cachedSchema = schemaList.get(cacheId);\n if (cachedSchema?.key === cacheKey) {\n return cachedSchema.schema;\n }\n\n /**\n * We need all the API models.\n * Private models are hidden in the GraphQL, so filter them out.\n */\n const models = await context.security.withoutAuthorization(async () => {\n return (await context.cms.listModels()).filter(model => {\n return model.isPrivate !== true;\n });\n });\n try {\n const schema = await generateSchema({\n ...params,\n models\n });\n schemaList.set(cacheId, {\n key: cacheKey,\n schema\n });\n return schema;\n } catch (err) {\n if (!Array.isArray(err.locations)) {\n throw new WebinyError({\n message: err.message,\n code: err.code || \"INVALID_GRAPHQL_SCHEMA_LOCATIONS\",\n data: {\n ...(err.data || {}),\n locations: err.locations\n }\n });\n }\n const [location] = err.locations;\n\n throw new WebinyError({\n code: \"INVALID_GRAPHQL_SCHEMA\",\n message: err.message,\n data: {\n invalidSegment: codeFrame(err.source.body, location.line, location.column, {\n frameSize: 15\n })\n }\n });\n }\n};\n\nconst checkEndpointAccess = async (context: CmsContext): Promise<void> => {\n const permission = await context.security.getPermission(`cms.endpoint.${context.cms.type}`);\n if (!permission) {\n throw new NotAuthorizedError({\n data: {\n reason: `Not allowed to access \"${context.cms.type}\" endpoint.`\n }\n });\n }\n};\n\nconst formatErrorPayload = (error: Error): string => {\n if (error instanceof WebinyError) {\n return JSON.stringify({\n type: \"CmsGraphQLWebinyError\",\n message: error.message,\n code: error.code,\n data: error.data\n });\n }\n\n return JSON.stringify({\n type: \"Error\",\n name: error.name,\n message: error.message,\n stack: error.stack\n });\n};\n\nexport interface GraphQLHandlerFactoryParams {\n debug?: boolean;\n}\n\nconst cmsRoutes = new RoutePlugin<CmsContext>(({ onPost, onOptions, context }) => {\n onPost(\"/cms/:type(^manage|preview|read$)/:locale\", async (request, reply) => {\n try {\n await checkEndpointAccess(context);\n } catch (ex) {\n return reply.code(401).send({\n data: null,\n error: {\n message: ex.message || \"Not authorized!\",\n code: ex.code || \"SECURITY_NOT_AUTHORIZED\",\n data: ex.data || null,\n stack: null\n }\n });\n }\n\n const getTenant = () => {\n return context.tenancy.getCurrentTenant();\n };\n\n const getLocale = () => {\n return context.cms.getLocale();\n };\n\n const getLastModifiedTime = async () => {\n return context.cms.getModelLastChange();\n };\n\n const schema = await context.benchmark.measure(\n \"headlessCms.graphql.getSchema\",\n async () => {\n try {\n return await getSchema({\n context,\n getTenant,\n getLastModifiedTime,\n getLocale,\n type: context.cms.type as ApiEndpoint\n });\n } catch (ex) {\n console.error(`Error while generating the schema.`);\n console.error(formatErrorPayload(ex));\n throw ex;\n }\n }\n );\n\n const body = await context.benchmark.measure(\n \"headlessCms.graphql.createRequestBody\",\n async () => {\n try {\n return createRequestBody(request.body);\n } catch (ex) {\n console.error(`Error while creating the body request.`);\n console.error(formatErrorPayload(ex));\n throw ex;\n }\n }\n );\n\n /**\n * We need to store the processRequestBody result in a variable and output it after the measurement.\n * Otherwise, the measurement will not be shown in the output.\n */\n let result: ExecutionResult[] | ExecutionResult | null = null;\n\n await context.benchmark.measure(\"headlessCms.graphql.processRequestBody\", async () => {\n try {\n result = await processRequestBody(body, schema, context);\n } catch (ex) {\n console.error(`Error while processing the body request.`);\n console.error(formatErrorPayload(ex));\n throw ex;\n }\n });\n\n return reply.code(200).send(result);\n });\n\n onOptions(\"/cms/:type(^manage|preview|read$)/:locale\", async (_, reply) => {\n return reply.status(204).send({}).hijack();\n });\n});\n\ncmsRoutes.name = \"headless-cms.graphql.route.default\";\n\nexport const graphQLHandlerFactory = ({ debug }: GraphQLHandlerFactoryParams): PluginCollection => {\n return [\n ...(debug ? debugPlugins() : []),\n cmsRoutes,\n {\n type: \"wcp-telemetry-tracker\"\n }\n ];\n};\n"],"mappings":";;;;;;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jB,KAAK,CAACD,kBAAkB,CAACW,EAAE,CAAC,CAAC;QACrC,MAAMA,EAAE;MACZ;IACJ,CAAC,CACJ;;IAED;AACR;AACA;AACA;IACQ,IAAIQ,MAAkD,GAAG,IAAI;IAE7D,MAAMvD,OAAO,CAACoD,SAAS,CAACC,OAAO,CAAC,wCAAwC,EAAE,YAAY;MAClF,IAAI;QACAE,MAAM,GAAG,MAAM,IAAAC,2BAAkB,EAAC1E,IAAI,EAAEwB,MAAM,EAAEN,OAAO,CAAC;MAC5D,CAAC,CAAC,OAAO+C,EAAE,EAAE;QACTO,OAAO,CAACjB,KAAK,CAAE,0CAAyC,CAAC;QACzDiB,OAAO,CAACjB,KAAK,CAACD,kBAAkB,CAACW,EAAE,CAAC,CAAC;QACrC,MAAMA,EAAE;MACZ;IACJ,CAAC,CAAC;IAEF,OAAOD,KAAK,CAACrD,IAAI,CAAC,GAAG,CAAC,CAACuD,IAAI,CAACO,MAAM,CAAC;EACvC,CAAC,CAAC;EAEFX,SAAS,CAAC,2CAA2C,EAAE,OAAOa,CAAC,EAAEX,KAAK,KAAK;IACvE,OAAOA,KAAK,CAACY,MAAM,CAAC,GAAG,CAAC,CAACV,IAAI,CAAC,CAAC,CAAC,CAAC,CAACW,MAAM,EAAE;EAC9C,CAAC,CAAC;AACN,CAAC,CAAC;AAEFlB,SAAS,CAACF,IAAI,GAAG,oCAAoC;AAE9C,MAAMqB,qBAAqB,GAAG,CAAC;EAAEC;AAAmC,CAAC,KAAuB;EAC/F,OAAO,CACH,IAAIA,KAAK,GAAG,IAAAC,qBAAY,GAAE,GAAG,EAAE,CAAC,EAChCrB,SAAS,EACT;IACInD,IAAI,EAAE;EACV,CAAC,CACJ;AACL,CAAC;AAAC"}
1
+ {"version":3,"names":["cmsRoutes","RoutePlugin","onPost","onOptions","context","request","reply","handleRequest","_","status","send","hijack","name","graphQLHandlerFactory","debug","debugPlugins","type"],"sources":["graphQLHandlerFactory.ts"],"sourcesContent":["import debugPlugins from \"@webiny/handler-graphql/debugPlugins\";\nimport { CmsContext } from \"~/types\";\nimport { PluginCollection } from \"@webiny/plugins/types\";\nimport { RoutePlugin } from \"@webiny/handler\";\nimport { handleRequest } from \"./handleRequest\";\n\nexport interface GraphQLHandlerFactoryParams {\n debug?: boolean;\n}\n\nconst cmsRoutes = new RoutePlugin<CmsContext>(({ onPost, onOptions, context }) => {\n onPost(\"/cms/:type(^manage|preview|read$)/:locale\", async (request, reply) => {\n return handleRequest({ context, request, reply });\n });\n\n onOptions(\"/cms/:type(^manage|preview|read$)/:locale\", async (_, reply) => {\n return reply.status(204).send({}).hijack();\n });\n});\n\ncmsRoutes.name = \"headless-cms.graphql.route.default\";\n\nexport const graphQLHandlerFactory = ({ debug }: GraphQLHandlerFactoryParams): PluginCollection => {\n return [\n ...(debug ? debugPlugins() : []),\n cmsRoutes,\n {\n type: \"wcp-telemetry-tracker\"\n }\n ];\n};\n"],"mappings":";;;;;;;AAAA;AAGA;AACA;AAMA,MAAMA,SAAS,GAAG,IAAIC,oBAAW,CAAa,CAAC;EAAEC,MAAM;EAAEC,SAAS;EAAEC;AAAQ,CAAC,KAAK;EAC9EF,MAAM,CAAC,2CAA2C,EAAE,OAAOG,OAAO,EAAEC,KAAK,KAAK;IAC1E,OAAO,IAAAC,4BAAa,EAAC;MAAEH,OAAO;MAAEC,OAAO;MAAEC;IAAM,CAAC,CAAC;EACrD,CAAC,CAAC;EAEFH,SAAS,CAAC,2CAA2C,EAAE,OAAOK,CAAC,EAAEF,KAAK,KAAK;IACvE,OAAOA,KAAK,CAACG,MAAM,CAAC,GAAG,CAAC,CAACC,IAAI,CAAC,CAAC,CAAC,CAAC,CAACC,MAAM,EAAE;EAC9C,CAAC,CAAC;AACN,CAAC,CAAC;AAEFX,SAAS,CAACY,IAAI,GAAG,oCAAoC;AAE9C,MAAMC,qBAAqB,GAAG,CAAC;EAAEC;AAAmC,CAAC,KAAuB;EAC/F,OAAO,CACH,IAAIA,KAAK,GAAG,IAAAC,qBAAY,GAAE,GAAG,EAAE,CAAC,EAChCf,SAAS,EACT;IACIgB,IAAI,EAAE;EACV,CAAC,CACJ;AACL,CAAC;AAAC"}
@@ -0,0 +1,11 @@
1
+ import { CmsContext } from "../types";
2
+ import { Reply, Request } from "@webiny/handler/types";
3
+ export interface HandleRequestParams {
4
+ context: CmsContext;
5
+ request: Request;
6
+ reply: Reply;
7
+ }
8
+ export interface HandleRequest {
9
+ (params: HandleRequestParams): Promise<Reply>;
10
+ }
11
+ export declare const handleRequest: HandleRequest;
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.handleRequest = void 0;
7
+ var _checkEndpointAccess = require("./checkEndpointAccess");
8
+ var _createRequestBody = require("./createRequestBody");
9
+ var _formatErrorPayload = require("./formatErrorPayload");
10
+ var _getSchema = require("./getSchema");
11
+ var _handlerGraphql = require("@webiny/handler-graphql");
12
+ const handleRequest = async params => {
13
+ const {
14
+ context,
15
+ request,
16
+ reply
17
+ } = params;
18
+ try {
19
+ await (0, _checkEndpointAccess.checkEndpointAccess)(context);
20
+ } catch (ex) {
21
+ return reply.code(401).send({
22
+ data: null,
23
+ error: {
24
+ message: ex.message || "Not authorized!",
25
+ code: ex.code || "SECURITY_NOT_AUTHORIZED",
26
+ data: ex.data || null,
27
+ stack: null
28
+ }
29
+ });
30
+ }
31
+ const getTenant = () => {
32
+ return context.tenancy.getCurrentTenant();
33
+ };
34
+ const getLocale = () => {
35
+ return context.cms.getLocale();
36
+ };
37
+ const getLastModifiedTime = async () => {
38
+ return context.cms.getModelLastChange();
39
+ };
40
+ const schema = await context.benchmark.measure("headlessCms.graphql.getSchema", async () => {
41
+ try {
42
+ return await (0, _getSchema.getSchema)({
43
+ context,
44
+ getTenant,
45
+ getLastModifiedTime,
46
+ getLocale,
47
+ type: context.cms.type
48
+ });
49
+ } catch (ex) {
50
+ console.error(`Error while generating the schema.`);
51
+ console.error((0, _formatErrorPayload.formatErrorPayload)(ex));
52
+ throw ex;
53
+ }
54
+ });
55
+ const body = await context.benchmark.measure("headlessCms.graphql.createRequestBody", async () => {
56
+ try {
57
+ return (0, _createRequestBody.createRequestBody)(request.body);
58
+ } catch (ex) {
59
+ console.error(`Error while creating the body request.`);
60
+ console.error((0, _formatErrorPayload.formatErrorPayload)(ex));
61
+ throw ex;
62
+ }
63
+ });
64
+
65
+ /**
66
+ * We need to store the processRequestBody result in a variable and output it after the measurement.
67
+ * Otherwise, the measurement will not be shown in the output.
68
+ */
69
+ let result = null;
70
+ await context.benchmark.measure("headlessCms.graphql.processRequestBody", async () => {
71
+ try {
72
+ result = await (0, _handlerGraphql.processRequestBody)(body, schema, context);
73
+ } catch (ex) {
74
+ console.error(`Error while processing the body request.`);
75
+ console.error((0, _formatErrorPayload.formatErrorPayload)(ex));
76
+ throw ex;
77
+ }
78
+ });
79
+ return reply.code(200).send(result);
80
+ };
81
+ exports.handleRequest = handleRequest;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["handleRequest","params","context","request","reply","checkEndpointAccess","ex","code","send","data","error","message","stack","getTenant","tenancy","getCurrentTenant","getLocale","cms","getLastModifiedTime","getModelLastChange","schema","benchmark","measure","getSchema","type","console","formatErrorPayload","body","createRequestBody","result","processRequestBody"],"sources":["handleRequest.ts"],"sourcesContent":["import { ApiEndpoint, CmsContext } from \"~/types\";\nimport { checkEndpointAccess } from \"./checkEndpointAccess\";\nimport { createRequestBody } from \"./createRequestBody\";\nimport { formatErrorPayload } from \"./formatErrorPayload\";\nimport { getSchema } from \"./getSchema\";\nimport { Reply, Request } from \"@webiny/handler/types\";\nimport { processRequestBody } from \"@webiny/handler-graphql\";\nimport { ExecutionResult } from \"graphql\";\n\nexport interface HandleRequestParams {\n context: CmsContext;\n request: Request;\n reply: Reply;\n}\n\nexport interface HandleRequest {\n (params: HandleRequestParams): Promise<Reply>;\n}\n\nexport const handleRequest: HandleRequest = async params => {\n const { context, request, reply } = params;\n try {\n await checkEndpointAccess(context);\n } catch (ex) {\n return reply.code(401).send({\n data: null,\n error: {\n message: ex.message || \"Not authorized!\",\n code: ex.code || \"SECURITY_NOT_AUTHORIZED\",\n data: ex.data || null,\n stack: null\n }\n });\n }\n\n const getTenant = () => {\n return context.tenancy.getCurrentTenant();\n };\n\n const getLocale = () => {\n return context.cms.getLocale();\n };\n\n const getLastModifiedTime = async () => {\n return context.cms.getModelLastChange();\n };\n\n const schema = await context.benchmark.measure(\"headlessCms.graphql.getSchema\", async () => {\n try {\n return await getSchema({\n context,\n getTenant,\n getLastModifiedTime,\n getLocale,\n type: context.cms.type as ApiEndpoint\n });\n } catch (ex) {\n console.error(`Error while generating the schema.`);\n console.error(formatErrorPayload(ex));\n throw ex;\n }\n });\n\n const body = await context.benchmark.measure(\n \"headlessCms.graphql.createRequestBody\",\n async () => {\n try {\n return createRequestBody(request.body);\n } catch (ex) {\n console.error(`Error while creating the body request.`);\n console.error(formatErrorPayload(ex));\n throw ex;\n }\n }\n );\n\n /**\n * We need to store the processRequestBody result in a variable and output it after the measurement.\n * Otherwise, the measurement will not be shown in the output.\n */\n let result: ExecutionResult[] | ExecutionResult | null = null;\n\n await context.benchmark.measure(\"headlessCms.graphql.processRequestBody\", async () => {\n try {\n result = await processRequestBody(body, schema, context);\n } catch (ex) {\n console.error(`Error while processing the body request.`);\n console.error(formatErrorPayload(ex));\n throw ex;\n }\n });\n\n return reply.code(200).send(result);\n};\n"],"mappings":";;;;;;AACA;AACA;AACA;AACA;AAEA;AAaO,MAAMA,aAA4B,GAAG,MAAMC,MAAM,IAAI;EACxD,MAAM;IAAEC,OAAO;IAAEC,OAAO;IAAEC;EAAM,CAAC,GAAGH,MAAM;EAC1C,IAAI;IACA,MAAM,IAAAI,wCAAmB,EAACH,OAAO,CAAC;EACtC,CAAC,CAAC,OAAOI,EAAE,EAAE;IACT,OAAOF,KAAK,CAACG,IAAI,CAAC,GAAG,CAAC,CAACC,IAAI,CAAC;MACxBC,IAAI,EAAE,IAAI;MACVC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CAAC,IAAAgB,sCAAkB,EAACpB,EAAE,CAAC,CAAC;MACrC,MAAMA,EAAE;IACZ;EACJ,CAAC,CACJ;;EAED;AACJ;AACA;AACA;EACI,IAAIuB,MAAkD,GAAG,IAAI;EAE7D,MAAM3B,OAAO,CAACmB,SAAS,CAACC,OAAO,CAAC,wCAAwC,EAAE,YAAY;IAClF,IAAI;MACAO,MAAM,GAAG,MAAM,IAAAC,kCAAkB,EAACH,IAAI,EAAEP,MAAM,EAAElB,OAAO,CAAC;IAC5D,CAAC,CAAC,OAAOI,EAAE,EAAE;MACTmB,OAAO,CAACf,KAAK,CAAE,0CAAyC,CAAC;MACzDe,OAAO,CAACf,KAAK,CAAC,IAAAgB,sCAAkB,EAACpB,EAAE,CAAC,CAAC;MACrC,MAAMA,EAAE;IACZ;EACJ,CAAC,CAAC;EAEF,OAAOF,KAAK,CAACG,IAAI,CAAC,GAAG,CAAC,CAACC,IAAI,CAACqB,MAAM,CAAC;AACvC,CAAC;AAAC"}
@@ -27,11 +27,26 @@ const createBaseSchema = () => {
27
27
  totalCount: Int
28
28
  }
29
29
 
30
+ input CmsDeleteEntryOptions {
31
+ # force delete an entry that might have some records left behind in the database
32
+ # see CmsDeleteEntryOptions in types.ts
33
+ force: Boolean
34
+ }
35
+
30
36
  type CmsDeleteResponse {
31
37
  data: Boolean
32
38
  error: CmsError
33
39
  }
34
40
 
41
+ type CmsDeleteMultipleDataResponse {
42
+ id: ID!
43
+ }
44
+
45
+ type CmsDeleteMultipleResponse {
46
+ data: [CmsDeleteMultipleDataResponse!]
47
+ error: CmsError
48
+ }
49
+
35
50
  type CmsBooleanResponse {
36
51
  data: Boolean
37
52
  error: CmsError
@@ -1 +1 @@
1
- {"version":3,"names":["createBaseSchema","cmsPlugin","CmsGraphQLSchemaPlugin","typeDefs","resolvers","name","corePlugin","GraphQLSchemaPlugin","schema"],"sources":["baseSchema.ts"],"sourcesContent":["import { CmsContext } from \"~/types\";\nimport { CmsGraphQLSchemaPlugin } from \"~/plugins\";\nimport { GraphQLSchemaPlugin } from \"@webiny/handler-graphql\";\n\nexport const createBaseSchema = (): GraphQLSchemaPlugin<CmsContext>[] => {\n const cmsPlugin = new CmsGraphQLSchemaPlugin({\n typeDefs: /* GraphQL */ `\n type CmsError {\n code: String\n message: String\n data: JSON\n stack: String\n }\n\n type CmsCursors {\n next: String\n previous: String\n }\n\n type CmsListMeta {\n cursor: String\n hasMoreItems: Boolean\n totalCount: Int\n }\n\n type CmsDeleteResponse {\n data: Boolean\n error: CmsError\n }\n\n type CmsBooleanResponse {\n data: Boolean\n error: CmsError\n }\n `,\n resolvers: {}\n });\n cmsPlugin.name = \"headless-cms.graphql.schema.base\";\n const corePlugin = new GraphQLSchemaPlugin<CmsContext>({\n typeDefs: cmsPlugin.schema.typeDefs,\n resolvers: cmsPlugin.schema.resolvers\n });\n corePlugin.name = \"headless-cms.graphql.core.schema.base\";\n /**\n * Due to splitting of CMS and Core schema plugins, we must have both defined for CMS to work.\n */\n return [cmsPlugin, corePlugin];\n};\n"],"mappings":";;;;;;AACA;AACA;AAEO,MAAMA,gBAAgB,GAAG,MAAyC;EACrE,MAAMC,SAAS,GAAG,IAAIC,+BAAsB,CAAC;IACzCC,QAAQ,EAAE,aAAe;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;IACDC,SAAS,EAAE,CAAC;EAChB,CAAC,CAAC;EACFH,SAAS,CAACI,IAAI,GAAG,kCAAkC;EACnD,MAAMC,UAAU,GAAG,IAAIC,mCAAmB,CAAa;IACnDJ,QAAQ,EAAEF,SAAS,CAACO,MAAM,CAACL,QAAQ;IACnCC,SAAS,EAAEH,SAAS,CAACO,MAAM,CAACJ;EAChC,CAAC,CAAC;EACFE,UAAU,CAACD,IAAI,GAAG,uCAAuC;EACzD;AACJ;AACA;EACI,OAAO,CAACJ,SAAS,EAAEK,UAAU,CAAC;AAClC,CAAC;AAAC"}
1
+ {"version":3,"names":["createBaseSchema","cmsPlugin","CmsGraphQLSchemaPlugin","typeDefs","resolvers","name","corePlugin","GraphQLSchemaPlugin","schema"],"sources":["baseSchema.ts"],"sourcesContent":["import { CmsContext } from \"~/types\";\nimport { CmsGraphQLSchemaPlugin } from \"~/plugins\";\nimport { GraphQLSchemaPlugin } from \"@webiny/handler-graphql\";\n\nexport const createBaseSchema = (): GraphQLSchemaPlugin<CmsContext>[] => {\n const cmsPlugin = new CmsGraphQLSchemaPlugin({\n typeDefs: /* GraphQL */ `\n type CmsError {\n code: String\n message: String\n data: JSON\n stack: String\n }\n\n type CmsCursors {\n next: String\n previous: String\n }\n\n type CmsListMeta {\n cursor: String\n hasMoreItems: Boolean\n totalCount: Int\n }\n\n input CmsDeleteEntryOptions {\n # force delete an entry that might have some records left behind in the database\n # see CmsDeleteEntryOptions in types.ts\n force: Boolean\n }\n\n type CmsDeleteResponse {\n data: Boolean\n error: CmsError\n }\n\n type CmsDeleteMultipleDataResponse {\n id: ID!\n }\n\n type CmsDeleteMultipleResponse {\n data: [CmsDeleteMultipleDataResponse!]\n error: CmsError\n }\n\n type CmsBooleanResponse {\n data: Boolean\n error: CmsError\n }\n `,\n resolvers: {}\n });\n cmsPlugin.name = \"headless-cms.graphql.schema.base\";\n const corePlugin = new GraphQLSchemaPlugin<CmsContext>({\n typeDefs: cmsPlugin.schema.typeDefs,\n resolvers: cmsPlugin.schema.resolvers\n });\n corePlugin.name = \"headless-cms.graphql.core.schema.base\";\n /**\n * Due to splitting of CMS and Core schema plugins, we must have both defined for CMS to work.\n */\n return [cmsPlugin, corePlugin];\n};\n"],"mappings":";;;;;;AACA;AACA;AAEO,MAAMA,gBAAgB,GAAG,MAAyC;EACrE,MAAMC,SAAS,GAAG,IAAIC,+BAAsB,CAAC;IACzCC,QAAQ,EAAE,aAAe;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;IACDC,SAAS,EAAE,CAAC;EAChB,CAAC,CAAC;EACFH,SAAS,CAACI,IAAI,GAAG,kCAAkC;EACnD,MAAMC,UAAU,GAAG,IAAIC,mCAAmB,CAAa;IACnDJ,QAAQ,EAAEF,SAAS,CAACO,MAAM,CAACL,QAAQ;IACnCC,SAAS,EAAEH,SAAS,CAACO,MAAM,CAACJ;EAChC,CAAC,CAAC;EACFE,UAAU,CAACD,IAAI,GAAG,uCAAuC;EACzD;AACJ;AACA;EACI,OAAO,CAACJ,SAAS,EAAEK,UAAU,CAAC;AAClC,CAAC;AAAC"}
@@ -1,4 +1,4 @@
1
- import { CmsModelField, ApiEndpoint, CmsModel, CmsFieldTypePlugins } from "../../types";
1
+ import { ApiEndpoint, CmsFieldTypePlugins, CmsModel, CmsModelField } from "../../types";
2
2
  import { Resolvers } from "@webiny/handler-graphql/types";
3
3
  interface CreateFieldResolvers {
4
4
  graphQLType: string;
@@ -10,15 +10,6 @@ var _set = _interopRequireDefault(require("lodash/set"));
10
10
  var _entryStorage = require("../../utils/entryStorage");
11
11
  var _error = _interopRequireDefault(require("@webiny/error"));
12
12
  var _getBaseFieldType = require("../../utils/getBaseFieldType");
13
- const getCreateResolver = (plugins, field, endpointType) => {
14
- const baseType = (0, _getBaseFieldType.getBaseFieldType)(field);
15
- if (!plugins[baseType]) {
16
- return null;
17
- } else if (!plugins[baseType][endpointType]) {
18
- return null;
19
- }
20
- return plugins[baseType][endpointType].createResolver;
21
- };
22
13
  /**
23
14
  * We use a factory to avoid passing the parameters for recursive invocations.
24
15
  * This way they will always be in the function scope, and we can only pass "fields".
@@ -40,7 +31,9 @@ const createFieldResolversFactory = factoryParams => {
40
31
  const fieldResolvers = (0, _objectSpread2.default)({}, extraResolvers);
41
32
  const typeResolvers = {};
42
33
  for (const field of fields) {
43
- if (!fieldTypePlugins[(0, _getBaseFieldType.getBaseFieldType)(field)]) {
34
+ var _plugin$endpointType;
35
+ const plugin = fieldTypePlugins[(0, _getBaseFieldType.getBaseFieldType)(field)];
36
+ if (!plugin) {
44
37
  continue;
45
38
  }
46
39
  /**
@@ -51,14 +44,15 @@ const createFieldResolversFactory = factoryParams => {
51
44
  field
52
45
  });
53
46
  }
54
- const createResolver = getCreateResolver(fieldTypePlugins, field, endpointType);
47
+ const createResolver = ((_plugin$endpointType = plugin[endpointType]) === null || _plugin$endpointType === void 0 ? void 0 : _plugin$endpointType.createResolver) || null;
55
48
  let resolver;
56
49
  const fieldResolver = createResolver ? createResolver({
57
50
  graphQLType,
58
51
  models,
59
52
  model,
60
53
  field,
61
- createFieldResolvers
54
+ createFieldResolvers,
55
+ fieldTypePlugins
62
56
  }) : null;
63
57
 
64
58
  /**
@@ -1 +1 @@
1
- {"version":3,"names":["getCreateResolver","plugins","field","endpointType","baseType","getBaseFieldType","createResolver","createFieldResolversFactory","factoryParams","models","model","fieldTypePlugins","createFieldResolvers","params","graphQLType","fields","isRoot","extraResolvers","fieldResolvers","typeResolvers","fieldId","WebinyError","resolver","fieldResolver","Object","assign","parent","args","context","info","value","values","undefined","transformedValue","entryFieldFromStorageTransform","set"],"sources":["createFieldResolvers.ts"],"sourcesContent":["import set from \"lodash/set\";\nimport {\n CmsModelField,\n CmsContext,\n CmsModelFieldToGraphQLCreateResolver,\n ApiEndpoint,\n CmsModel,\n CmsFieldTypePlugins\n} from \"~/types\";\nimport { entryFieldFromStorageTransform } from \"~/utils/entryStorage\";\nimport { Resolvers } from \"@webiny/handler-graphql/types\";\nimport WebinyError from \"@webiny/error\";\nimport { getBaseFieldType } from \"~/utils/getBaseFieldType\";\n\ninterface CreateFieldResolvers {\n graphQLType: string;\n fields: CmsModelField[];\n isRoot: boolean;\n extraResolvers?: Resolvers<any>;\n}\n\ninterface CreateFieldResolversFactoryParams {\n endpointType: ApiEndpoint;\n models: CmsModel[];\n model: CmsModel;\n fieldTypePlugins: CmsFieldTypePlugins;\n}\n\nconst getCreateResolver = (\n plugins: CmsFieldTypePlugins,\n field: CmsModelField,\n endpointType: ApiEndpoint\n): CmsModelFieldToGraphQLCreateResolver | null => {\n const baseType = getBaseFieldType(field);\n if (!plugins[baseType]) {\n return null;\n } else if (!plugins[baseType][endpointType]) {\n return null;\n }\n return plugins[baseType][endpointType].createResolver;\n};\n/**\n * We use a factory to avoid passing the parameters for recursive invocations.\n * This way they will always be in the function scope, and we can only pass \"fields\".\n */\nexport const createFieldResolversFactory = (factoryParams: CreateFieldResolversFactoryParams) => {\n const { endpointType, models, model, fieldTypePlugins } = factoryParams;\n return function createFieldResolvers(params: CreateFieldResolvers) {\n const { graphQLType, fields, isRoot = false, extraResolvers = {} } = params;\n\n const fieldResolvers = { ...extraResolvers };\n const typeResolvers = {};\n\n for (const field of fields) {\n if (!fieldTypePlugins[getBaseFieldType(field)]) {\n continue;\n }\n /**\n * Field that is passed into this factory MUST have fieldId, so filter it before the method call.\n */\n if (!field.fieldId) {\n throw new WebinyError(\n \"Field is missing an `fieldId`. Cannot process field without the `fieldId` in the resolvers.\",\n \"FIELD_ID_ERROR\",\n {\n field\n }\n );\n }\n\n const createResolver = getCreateResolver(fieldTypePlugins, field, endpointType);\n\n let resolver: any;\n const fieldResolver = createResolver\n ? createResolver({ graphQLType, models, model, field, createFieldResolvers })\n : null;\n\n /**\n * When fieldResolver is false it will completely skip adding field fieldId into the resolvers.\n * This is to fix the breaking of GraphQL schema.\n */\n if (fieldResolver === false) {\n continue;\n } else if (typeof fieldResolver === \"function\") {\n resolver = fieldResolver;\n } else if (fieldResolver) {\n resolver = fieldResolver.resolver;\n Object.assign(typeResolvers, fieldResolver.typeResolvers);\n }\n\n const { fieldId } = field;\n // TODO @ts-refactor figure out types for parameters\n // @ts-ignore\n fieldResolvers[fieldId] = async (parent, args, context: CmsContext, info) => {\n /**\n * This is required because due to ref field can be requested without the populated data.\n * At that point there is no .values no fieldId property on the parent\n */\n const value =\n parent?.values?.[fieldId] === undefined\n ? parent?.[fieldId]\n : parent?.values?.[fieldId];\n if (value === undefined) {\n return undefined;\n }\n // Get transformed value (eg. data decompression)\n const transformedValue = await entryFieldFromStorageTransform({\n context,\n model,\n field,\n value: isRoot ? parent.values?.[fieldId] : parent[fieldId]\n });\n\n set(isRoot ? parent.values : parent, fieldId, transformedValue);\n\n if (!resolver) {\n return isRoot ? parent.values[fieldId] : parent[fieldId];\n }\n\n return await resolver(isRoot ? parent.values : parent, args, context, info);\n };\n }\n\n return { [graphQLType]: fieldResolvers, ...typeResolvers };\n };\n};\n"],"mappings":";;;;;;;;AAAA;AASA;AAEA;AACA;AAgBA,MAAMA,iBAAiB,GAAG,CACtBC,OAA4B,EAC5BC,KAAoB,EACpBC,YAAyB,KACqB;EAC9C,MAAMC,QAAQ,GAAG,IAAAC,kCAAgB,EAACH,KAAK,CAAC;EACxC,IAAI,CAACD,OAAO,CAACG,QAAQ,CAAC,EAAE;IACpB,OAAO,IAAI;EACf,CAAC,MAAM,IAAI,CAACH,OAAO,CAACG,QAAQ,CAAC,CAACD,YAAY,CAAC,EAAE;IACzC,OAAO,IAAI;EACf;EACA,OAAOF,OAAO,CAACG,QAAQ,CAAC,CAACD,YAAY,CAAC,CAACG,cAAc;AACzD,CAAC;AACD;AACA;AACA;AACA;AACO,MAAMC,2BAA2B,GAAIC,aAAgD,IAAK;EAC7F,MAAM;IAAEL,YAAY;IAAEM,MAAM;IAAEC,KAAK;IAAEC;EAAiB,CAAC,GAAGH,aAAa;EACvE,OAAO,SAASI,oBAAoB,CAACC,MAA4B,EAAE;IAC/D,MAAM;MAAEC,WAAW;MAAEC,MAAM;MAAEC,MAAM,GAAG,KAAK;MAAEC,cAAc,GAAG,CAAC;IAAE,CAAC,GAAGJ,MAAM;IAE3E,MAAMK,cAAc,mCAAQD,cAAc,CAAE;IAC5C,MAAME,aAAa,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ANA,MAAM,0CAANA,MAAM,CAAEK,MAAM,oDAAd,gBAAiBX,OAAO,CAAC;QACnC,IAAIU,KAAK,KAAKE,SAAS,EAAE;UACrB,OAAOA,SAAS;QACpB;QACA;QACA,MAAMC,gBAAgB,GAAG,MAAM,IAAAC,4CAA8B,EAAC;UAC1DN,OAAO;UACPlB,KAAK;UACLR,KAAK;UACL4B,KAAK,EAAEd,MAAM,sBAAGU,MAAM,CAACK,MAAM,oDAAb,gBAAgBX,OAAO,CAAC,GAAGM,MAAM,CAACN,OAAO;QAC7D,CAAC,CAAC;QAEF,IAAAe,YAAG,EAACnB,MAAM,GAAGU,MAAM,CAACK,MAAM,GAAGL,MAAM,EAAEN,OAAO,EAAEa,gBAAgB,CAAC;QAE/D,IAAI,CAACX,QAAQ,EAAE;UACX,OAAON,MAAM,GAAGU,MAAM,CAACK,MAAM,CAACX,OAAO,CAAC,GAAGM,MAAM,CAACN,OAAO,CAAC;QAC5D;QAEA,OAAO,MAAME,QAAQ,CAACN,MAAM,GAAGU,MAAM,CAACK,MAAM,GAAGL,MAAM,EAAEC,IAAI,EAAEC,OAAO,EAAEC,IAAI,CAAC;MAC/E,CAAC;IACL;IAEA;MAAS,CAACf,WAAW,GAAGI;IAAc,GAAKC,aAAa;EAC5D,CAAC;AACL,CAAC;AAAC"}
1
+ {"version":3,"names":["createFieldResolversFactory","factoryParams","endpointType","models","model","fieldTypePlugins","createFieldResolvers","params","graphQLType","fields","isRoot","extraResolvers","fieldResolvers","typeResolvers","field","plugin","getBaseFieldType","fieldId","WebinyError","createResolver","resolver","fieldResolver","Object","assign","parent","args","context","info","value","values","undefined","transformedValue","entryFieldFromStorageTransform","set"],"sources":["createFieldResolvers.ts"],"sourcesContent":["import set from \"lodash/set\";\nimport { ApiEndpoint, CmsContext, CmsFieldTypePlugins, CmsModel, CmsModelField } from \"~/types\";\nimport { entryFieldFromStorageTransform } from \"~/utils/entryStorage\";\nimport { Resolvers } from \"@webiny/handler-graphql/types\";\nimport WebinyError from \"@webiny/error\";\nimport { getBaseFieldType } from \"~/utils/getBaseFieldType\";\n\ninterface CreateFieldResolvers {\n graphQLType: string;\n fields: CmsModelField[];\n isRoot: boolean;\n extraResolvers?: Resolvers<any>;\n}\n\ninterface CreateFieldResolversFactoryParams {\n endpointType: ApiEndpoint;\n models: CmsModel[];\n model: CmsModel;\n fieldTypePlugins: CmsFieldTypePlugins;\n}\n\n/**\n * We use a factory to avoid passing the parameters for recursive invocations.\n * This way they will always be in the function scope, and we can only pass \"fields\".\n */\nexport const createFieldResolversFactory = (factoryParams: CreateFieldResolversFactoryParams) => {\n const { endpointType, models, model, fieldTypePlugins } = factoryParams;\n return function createFieldResolvers(params: CreateFieldResolvers) {\n const { graphQLType, fields, isRoot = false, extraResolvers = {} } = params;\n\n const fieldResolvers = { ...extraResolvers };\n const typeResolvers = {};\n\n for (const field of fields) {\n const plugin = fieldTypePlugins[getBaseFieldType(field)];\n if (!plugin) {\n continue;\n }\n /**\n * Field that is passed into this factory MUST have fieldId, so filter it before the method call.\n */\n if (!field.fieldId) {\n throw new WebinyError(\n \"Field is missing an `fieldId`. Cannot process field without the `fieldId` in the resolvers.\",\n \"FIELD_ID_ERROR\",\n {\n field\n }\n );\n }\n\n const createResolver = plugin[endpointType]?.createResolver || null;\n\n let resolver: any;\n const fieldResolver = createResolver\n ? createResolver({\n graphQLType,\n models,\n model,\n field,\n createFieldResolvers,\n fieldTypePlugins\n })\n : null;\n\n /**\n * When fieldResolver is false it will completely skip adding field fieldId into the resolvers.\n * This is to fix the breaking of GraphQL schema.\n */\n if (fieldResolver === false) {\n continue;\n } else if (typeof fieldResolver === \"function\") {\n resolver = fieldResolver;\n } else if (fieldResolver) {\n resolver = fieldResolver.resolver;\n Object.assign(typeResolvers, fieldResolver.typeResolvers);\n }\n\n const { fieldId } = field;\n // TODO @ts-refactor figure out types for parameters\n // @ts-ignore\n fieldResolvers[fieldId] = async (parent, args, context: CmsContext, info) => {\n /**\n * This is required because due to ref field can be requested without the populated data.\n * At that point there is no .values no fieldId property on the parent\n */\n const value =\n parent?.values?.[fieldId] === undefined\n ? parent?.[fieldId]\n : parent?.values?.[fieldId];\n if (value === undefined) {\n return undefined;\n }\n // Get transformed value (eg. data decompression)\n const transformedValue = await entryFieldFromStorageTransform({\n context,\n model,\n field,\n value: isRoot ? parent.values?.[fieldId] : parent[fieldId]\n });\n\n set(isRoot ? parent.values : parent, fieldId, transformedValue);\n\n if (!resolver) {\n return isRoot ? parent.values[fieldId] : parent[fieldId];\n }\n\n return await resolver(isRoot ? parent.values : parent, args, context, info);\n };\n }\n\n return { [graphQLType]: fieldResolvers, ...typeResolvers };\n };\n};\n"],"mappings":";;;;;;;;AAAA;AAEA;AAEA;AACA;AAgBA;AACA;AACA;AACA;AACO,MAAMA,2BAA2B,GAAIC,aAAgD,IAAK;EAC7F,MAAM;IAAEC,YAAY;IAAEC,MAAM;IAAEC,KAAK;IAAEC;EAAiB,CAAC,GAAGJ,aAAa;EACvE,OAAO,SAASK,oBAAoB,CAACC,MAA4B,EAAE;IAC/D,MAAM;MAAEC,WAAW;MAAEC,MAAM;MAAEC,MAAM,GAAG,KAAK;MAAEC,cAAc,GAAG,CAAC;IAAE,CAAC,GAAGJ,MAAM;IAE3E,MAAMK,cAAc,mCAAQD,cAAc,CAAE;IAC5C,MAAME,aAAa,GAAG,CAAC,CAAC;IAExB,KAAK,MAAMC,KAAK,IAAIL,MAAM,EAAE;MAAA;MACxB,MAAMM,MAAM,GAAGV,gBAAgB,CAAC,IAAAW,kCAAgB,EAACF,KAAK,CAAC,CAAC;MACxD,IAAI,CAACC,MAAM,EAAE;QACT;MACJ;MACA;AACZ;AACA;MACY,IAAI,CAACD,KAAK,CAACG,OAAO,EAAE;QAChB,MAAM,IAAIC,cAAW,CACjB,6FAA6F,EAC7F,gBAAgB,EAChB;UACIJ;QACJ,CAAC,CACJ;MACL;MAEA,MAAMK,cAAc,GAAG,yBAAAJ,MAAM,CAACb,YAAY,CAAC,yDAApB,qBAAs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EF,IAAAgB,YAAG,EAACvB,MAAM,GAAGc,MAAM,CAACK,MAAM,GAAGL,MAAM,EAAEP,OAAO,EAAEc,gBAAgB,CAAC;QAE/D,IAAI,CAACX,QAAQ,EAAE;UACX,OAAOV,MAAM,GAAGc,MAAM,CAACK,MAAM,CAACZ,OAAO,CAAC,GAAGO,MAAM,CAACP,OAAO,CAAC;QAC5D;QAEA,OAAO,MAAMG,QAAQ,CAACV,MAAM,GAAGc,MAAM,CAACK,MAAM,GAAGL,MAAM,EAAEC,IAAI,EAAEC,OAAO,EAAEC,IAAI,CAAC;MAC/E,CAAC;IACL;IAEA;MAAS,CAACnB,WAAW,GAAGI;IAAc,GAAKC,aAAa;EAC5D,CAAC;AACL,CAAC;AAAC"}
@@ -0,0 +1,3 @@
1
+ import { CmsFieldTypePlugins } from "../../types";
2
+ import { PluginsContainer } from "@webiny/plugins";
3
+ export declare const createFieldTypePluginRecords: (plugins: PluginsContainer) => CmsFieldTypePlugins;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createFieldTypePluginRecords = void 0;
7
+ const createFieldTypePluginRecords = plugins => {
8
+ return plugins.byType("cms-model-field-to-graphql").reduce((acc, pl) => {
9
+ acc[pl.fieldType] = pl;
10
+ return acc;
11
+ }, {});
12
+ };
13
+ exports.createFieldTypePluginRecords = createFieldTypePluginRecords;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createFieldTypePluginRecords","plugins","byType","reduce","acc","pl","fieldType"],"sources":["createFieldTypePluginRecords.ts"],"sourcesContent":["import { CmsFieldTypePlugins, CmsModelFieldToGraphQLPlugin } from \"~/types\";\nimport { PluginsContainer } from \"@webiny/plugins\";\n\nexport const createFieldTypePluginRecords = (plugins: PluginsContainer) => {\n return plugins\n .byType<CmsModelFieldToGraphQLPlugin>(\"cms-model-field-to-graphql\")\n .reduce<CmsFieldTypePlugins>((acc, pl) => {\n acc[pl.fieldType] = pl;\n return acc;\n }, {});\n};\n"],"mappings":";;;;;;AAGO,MAAMA,4BAA4B,GAAIC,OAAyB,IAAK;EACvE,OAAOA,OAAO,CACTC,MAAM,CAA+B,4BAA4B,CAAC,CAClEC,MAAM,CAAsB,CAACC,GAAG,EAAEC,EAAE,KAAK;IACtCD,GAAG,CAACC,EAAE,CAACC,SAAS,CAAC,GAAGD,EAAE;IACtB,OAAOD,GAAG;EACd,CAAC,EAAE,CAAC,CAAC,CAAC;AACd,CAAC;AAAC"}
@@ -14,6 +14,7 @@ var _resolveGetByIds = require("./resolvers/manage/resolveGetByIds");
14
14
  var _resolveCreate = require("./resolvers/manage/resolveCreate");
15
15
  var _resolveUpdate = require("./resolvers/manage/resolveUpdate");
16
16
  var _resolveDelete = require("./resolvers/manage/resolveDelete");
17
+ var _resolveDeleteMultiple = require("./resolvers/manage/resolveDeleteMultiple");
17
18
  var _resolvePublish = require("./resolvers/manage/resolvePublish");
18
19
  var _resolveRepublish = require("./resolvers/manage/resolveRepublish");
19
20
  var _resolveUnpublish = require("./resolvers/manage/resolveUnpublish");
@@ -75,6 +76,9 @@ const createManageResolvers = ({
75
76
  [`delete${model.singularApiName}`]: (0, _resolveDelete.resolveDelete)({
76
77
  model
77
78
  }),
79
+ [`deleteMultiple${model.pluralApiName}`]: (0, _resolveDeleteMultiple.resolveDeleteMultiple)({
80
+ model
81
+ }),
78
82
  [`publish${model.singularApiName}`]: (0, _resolvePublish.resolvePublish)({
79
83
  model
80
84
  }),
@@ -1 +1 @@
1
- {"version":3,"names":["createManageResolvers","models","model","fieldTypePlugins","fields","length","Query","Mutation","createFieldResolvers","createFieldResolversFactory","endpointType","fieldResolvers","graphQLType","singularApiName","isRoot","extraResolvers","commonFieldResolvers","meta","entry","resolveGet","resolveGetRevisions","pluralApiName","resolveGetByIds","resolveList","resolveCreate","resolveUpdate","resolveDelete","resolvePublish","resolveRepublish","resolveUnpublish","resolveCreateFrom","title","getEntryTitle","description","_","context","descriptionFieldId","field","find","f","fieldId","entryFieldFromStorageTransform","value","values","image","getEntryImage","status","data","revisions","cms","getEntryRevisions","entryId","sort","a","b","version"],"sources":["createManageResolvers.ts"],"sourcesContent":["import { CmsFieldTypePlugins, CmsContext, CmsEntry, CmsModel } from \"~/types\";\nimport { commonFieldResolvers } from \"./resolvers/commonFieldResolvers\";\nimport { resolveGet } from \"./resolvers/manage/resolveGet\";\nimport { resolveList } from \"./resolvers/manage/resolveList\";\nimport { resolveGetRevisions } from \"./resolvers/manage/resolveGetRevisions\";\nimport { resolveGetByIds } from \"./resolvers/manage/resolveGetByIds\";\nimport { resolveCreate } from \"./resolvers/manage/resolveCreate\";\nimport { resolveUpdate } from \"./resolvers/manage/resolveUpdate\";\nimport { resolveDelete } from \"./resolvers/manage/resolveDelete\";\nimport { resolvePublish } from \"./resolvers/manage/resolvePublish\";\nimport { resolveRepublish } from \"./resolvers/manage/resolveRepublish\";\nimport { resolveUnpublish } from \"./resolvers/manage/resolveUnpublish\";\nimport { resolveCreateFrom } from \"./resolvers/manage/resolveCreateFrom\";\nimport { createFieldResolversFactory } from \"./createFieldResolvers\";\nimport { getEntryTitle } from \"~/utils/getEntryTitle\";\nimport { getEntryImage } from \"~/utils/getEntryImage\";\nimport { entryFieldFromStorageTransform } from \"~/utils/entryStorage\";\n\ninterface CreateManageResolversParams {\n models: CmsModel[];\n model: CmsModel;\n context: CmsContext;\n fieldTypePlugins: CmsFieldTypePlugins;\n}\n\ninterface CreateManageResolvers {\n // TODO @ts-refactor determine correct type.\n (params: CreateManageResolversParams): any;\n}\n\nexport const createManageResolvers: CreateManageResolvers = ({\n models,\n model,\n fieldTypePlugins\n}) => {\n if (model.fields.length === 0) {\n return {\n Query: {},\n Mutation: {}\n };\n }\n\n const createFieldResolvers = createFieldResolversFactory({\n endpointType: \"manage\",\n models,\n model,\n fieldTypePlugins\n });\n\n const fieldResolvers = createFieldResolvers({\n graphQLType: model.singularApiName,\n fields: model.fields,\n isRoot: true,\n // These are extra fields we want to apply to field resolvers of \"gqlType\"\n extraResolvers: {\n ...commonFieldResolvers(),\n meta(entry) {\n return entry;\n }\n }\n });\n\n return {\n Query: {\n [`get${model.singularApiName}`]: resolveGet({ model }),\n [`get${model.singularApiName}Revisions`]: resolveGetRevisions({ model }),\n [`get${model.pluralApiName}ByIds`]: resolveGetByIds({ model }),\n [`list${model.pluralApiName}`]: resolveList({ model })\n },\n Mutation: {\n [`create${model.singularApiName}`]: resolveCreate({ model }),\n [`update${model.singularApiName}`]: resolveUpdate({ model }),\n [`delete${model.singularApiName}`]: resolveDelete({ model }),\n [`publish${model.singularApiName}`]: resolvePublish({ model }),\n [`republish${model.singularApiName}`]: resolveRepublish({ model }),\n [`unpublish${model.singularApiName}`]: resolveUnpublish({ model }),\n [`create${model.singularApiName}From`]: resolveCreateFrom({ model })\n },\n ...fieldResolvers,\n [`${model.singularApiName}Meta`]: {\n title(entry: CmsEntry) {\n return getEntryTitle(model, entry);\n },\n description: (entry: CmsEntry, _: any, context: CmsContext) => {\n if (!model.descriptionFieldId) {\n return \"\";\n }\n const field = model.fields.find(f => f.fieldId === model.descriptionFieldId);\n if (!field) {\n return \"\";\n }\n\n return entryFieldFromStorageTransform({\n context,\n model,\n field,\n value: entry.values[field.fieldId]\n });\n },\n image: (entry: CmsEntry) => {\n return getEntryImage(model, entry);\n },\n status(entry: CmsEntry) {\n return entry.status;\n },\n data: (entry: CmsEntry) => {\n return entry.meta || {};\n },\n async revisions(entry: CmsEntry, _: any, context: CmsContext) {\n const revisions = await context.cms.getEntryRevisions(model, entry.entryId);\n return revisions.sort((a, b) => b.version - a.version);\n }\n }\n };\n};\n"],"mappings":";;;;;;;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAcO,MAAMA,qBAA4C,GAAG,CAAC;EACzDC,MAAM;EACNC,KAAK;EACLC;AACJ,CAAC,KAAK;EACF,IAAID,KAAK,CAACE,MAAM,CAACC,MAAM,KAAK,CAAC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C,IAAI,EAAG7B,KAAe,IAAK;QACvB,OAAOA,KAAK,CAACD,IAAI,IAAI,CAAC,CAAC;MAC3B,CAAC;MACD,MAAM+B,SAAS,CAAC9B,KAAe,EAAEgB,CAAM,EAAEC,OAAmB,EAAE;QAC1D,MAAMa,SAAS,GAAG,MAAMb,OAAO,CAACc,GAAG,CAACC,iBAAiB,CAAChD,KAAK,EAAEgB,KAAK,CAACiC,OAAO,CAAC;QAC3E,OAAOH,SAAS,CAACI,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAKA,CAAC,CAACC,OAAO,GAAGF,CAAC,CAACE,OAAO,CAAC;MAC1D;IACJ;EAAC;AAET,CAAC;AAAC"}
1
+ {"version":3,"names":["createManageResolvers","models","model","fieldTypePlugins","fields","length","Query","Mutation","createFieldResolvers","createFieldResolversFactory","endpointType","fieldResolvers","graphQLType","singularApiName","isRoot","extraResolvers","commonFieldResolvers","meta","entry","resolveGet","resolveGetRevisions","pluralApiName","resolveGetByIds","resolveList","resolveCreate","resolveUpdate","resolveDelete","resolveDeleteMultiple","resolvePublish","resolveRepublish","resolveUnpublish","resolveCreateFrom","title","getEntryTitle","description","_","context","descriptionFieldId","field","find","f","fieldId","entryFieldFromStorageTransform","value","values","image","getEntryImage","status","data","revisions","cms","getEntryRevisions","entryId","sort","a","b","version"],"sources":["createManageResolvers.ts"],"sourcesContent":["import { CmsFieldTypePlugins, CmsContext, CmsEntry, CmsModel } from \"~/types\";\nimport { commonFieldResolvers } from \"./resolvers/commonFieldResolvers\";\nimport { resolveGet } from \"./resolvers/manage/resolveGet\";\nimport { resolveList } from \"./resolvers/manage/resolveList\";\nimport { resolveGetRevisions } from \"./resolvers/manage/resolveGetRevisions\";\nimport { resolveGetByIds } from \"./resolvers/manage/resolveGetByIds\";\nimport { resolveCreate } from \"./resolvers/manage/resolveCreate\";\nimport { resolveUpdate } from \"./resolvers/manage/resolveUpdate\";\nimport { resolveDelete } from \"./resolvers/manage/resolveDelete\";\nimport { resolveDeleteMultiple } from \"./resolvers/manage/resolveDeleteMultiple\";\nimport { resolvePublish } from \"./resolvers/manage/resolvePublish\";\nimport { resolveRepublish } from \"./resolvers/manage/resolveRepublish\";\nimport { resolveUnpublish } from \"./resolvers/manage/resolveUnpublish\";\nimport { resolveCreateFrom } from \"./resolvers/manage/resolveCreateFrom\";\nimport { createFieldResolversFactory } from \"./createFieldResolvers\";\nimport { getEntryTitle } from \"~/utils/getEntryTitle\";\nimport { getEntryImage } from \"~/utils/getEntryImage\";\nimport { entryFieldFromStorageTransform } from \"~/utils/entryStorage\";\n\ninterface CreateManageResolversParams {\n models: CmsModel[];\n model: CmsModel;\n context: CmsContext;\n fieldTypePlugins: CmsFieldTypePlugins;\n}\n\ninterface CreateManageResolvers {\n // TODO @ts-refactor determine correct type.\n (params: CreateManageResolversParams): any;\n}\n\nexport const createManageResolvers: CreateManageResolvers = ({\n models,\n model,\n fieldTypePlugins\n}) => {\n if (model.fields.length === 0) {\n return {\n Query: {},\n Mutation: {}\n };\n }\n\n const createFieldResolvers = createFieldResolversFactory({\n endpointType: \"manage\",\n models,\n model,\n fieldTypePlugins\n });\n\n const fieldResolvers = createFieldResolvers({\n graphQLType: model.singularApiName,\n fields: model.fields,\n isRoot: true,\n // These are extra fields we want to apply to field resolvers of \"gqlType\"\n extraResolvers: {\n ...commonFieldResolvers(),\n meta(entry) {\n return entry;\n }\n }\n });\n\n return {\n Query: {\n [`get${model.singularApiName}`]: resolveGet({ model }),\n [`get${model.singularApiName}Revisions`]: resolveGetRevisions({ model }),\n [`get${model.pluralApiName}ByIds`]: resolveGetByIds({ model }),\n [`list${model.pluralApiName}`]: resolveList({ model })\n },\n Mutation: {\n [`create${model.singularApiName}`]: resolveCreate({ model }),\n [`update${model.singularApiName}`]: resolveUpdate({ model }),\n [`delete${model.singularApiName}`]: resolveDelete({ model }),\n [`deleteMultiple${model.pluralApiName}`]: resolveDeleteMultiple({ model }),\n [`publish${model.singularApiName}`]: resolvePublish({ model }),\n [`republish${model.singularApiName}`]: resolveRepublish({ model }),\n [`unpublish${model.singularApiName}`]: resolveUnpublish({ model }),\n [`create${model.singularApiName}From`]: resolveCreateFrom({ model })\n },\n ...fieldResolvers,\n [`${model.singularApiName}Meta`]: {\n title(entry: CmsEntry) {\n return getEntryTitle(model, entry);\n },\n description: (entry: CmsEntry, _: any, context: CmsContext) => {\n if (!model.descriptionFieldId) {\n return \"\";\n }\n const field = model.fields.find(f => f.fieldId === model.descriptionFieldId);\n if (!field) {\n return \"\";\n }\n\n return entryFieldFromStorageTransform({\n context,\n model,\n field,\n value: entry.values[field.fieldId]\n });\n },\n image: (entry: CmsEntry) => {\n return getEntryImage(model, entry);\n },\n status(entry: CmsEntry) {\n return entry.status;\n },\n data: (entry: CmsEntry) => {\n return entry.meta || {};\n },\n async revisions(entry: CmsEntry, _: any, context: CmsContext) {\n const revisions = await context.cms.getEntryRevisions(model, entry.entryId);\n return revisions.sort((a, b) => b.version - a.version);\n }\n }\n };\n};\n"],"mappings":";;;;;;;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAcO,MAAMA,qBAA4C,GAAG,CAAC;EACzDC,MAAM;EACNC,KAAK;EACLC;AACJ,CAAC,KAAK;EACF,IAAID,KAAK,CAACE,MAAM,CAACC,MAAM,KAAK,CAAC,EAAE;IAC3B,OAAO;MACHC,KAAK,EAAE,CAAC,CAAC;MACTC,QAAQ,EAAE,CAAC;IACf,CAAC;EACL;EAEA,MAAMC,oBAAoB,GAAG,IAAAC,iDAA2B,EAAC;IACrDC,YAAY,EAAE,QAAQ;IACtBT,MAAM;IACNC,KAAK;IACLC;EACJ,CAAC,CAAC;EAEF,MAAMQ,cAAc,GAAGH,oBAAoB,CAAC;IACxCI,WAAW,EAAEV,KAAK,CAACW,eAAe;IAClCT,MAAM,EAAEF,KAAK,CAACE,MAAM;IACpBU,MAAM,EAAE,IAAI;IACZ;IACAC,cAAc,8DACP,IA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