@webiny/api-headless-cms 5.41.4-beta.6 → 5.42.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/constants.js +1 -1
- package/constants.js.map +1 -1
- package/crud/AccessControl/AccessControl.js.map +1 -1
- package/crud/contentEntry/afterDelete.d.ts +5 -1
- package/crud/contentEntry/afterDelete.js +9 -1
- package/crud/contentEntry/afterDelete.js.map +1 -1
- package/crud/contentEntry/entryDataValidation.js.map +1 -1
- package/crud/contentEntry/markLockedFields.d.ts +1 -1
- package/crud/contentEntry/markLockedFields.js.map +1 -1
- package/crud/contentEntry/referenceFieldsMapping.js.map +1 -1
- package/crud/contentEntry/useCases/DeleteEntry/DeleteEntry.js.map +1 -1
- package/crud/contentEntry/useCases/DeleteEntry/MoveEntryToBin.js.map +1 -1
- package/crud/contentEntry/useCases/ListEntries/GetEntry.js.map +1 -1
- package/crud/contentEntry/useCases/RestoreEntryFromBin/RestoreEntryFromBin.js.map +1 -1
- package/crud/contentEntry.crud.js.map +1 -1
- package/crud/contentModel/beforeCreate.js.map +1 -1
- package/crud/contentModel/beforeDelete.js.map +1 -1
- package/crud/contentModel/createFieldStorageId.js.map +1 -1
- package/crud/contentModel/validate/endingAllowed.js.map +1 -1
- package/crud/contentModel/validate/isModelEndingAllowed.js.map +1 -1
- package/crud/contentModel/validate/modelId.js.map +1 -1
- package/crud/contentModel/validate/pluralApiName.js.map +1 -1
- package/crud/contentModel/validate/singularApiName.js.map +1 -1
- package/crud/contentModel/validateModelFields.js.map +1 -1
- package/crud/contentModel/validateStorageId.js.map +1 -1
- package/crud/contentModel/validation.js.map +1 -1
- package/crud/contentModel.crud.js +17 -4
- package/crud/contentModel.crud.js.map +1 -1
- package/crud/contentModelGroup/beforeCreate.js.map +1 -1
- package/crud/contentModelGroup/beforeDelete.js.map +1 -1
- package/crud/contentModelGroup/beforeUpdate.js.map +1 -1
- package/crud/contentModelGroup.crud.js.map +1 -1
- package/export/crud/imports/importModels.js.map +1 -1
- package/export/crud/imports/validateGroups.js.map +1 -1
- package/export/crud/imports/validateModels.js.map +1 -1
- package/export/graphql/index.js.map +1 -1
- package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.js.map +1 -1
- package/graphql/checkEndpointAccess.js.map +1 -1
- package/graphql/generateSchema.js +6 -1
- package/graphql/generateSchema.js.map +1 -1
- package/graphql/getSchema/generateCacheId.js.map +1 -1
- package/graphql/getSchema.js +3 -2
- package/graphql/getSchema.js.map +1 -1
- package/graphql/handleRequest.js.map +1 -1
- package/graphql/scalars/RevisionId.js.map +1 -1
- package/graphql/schema/baseContentSchema.js.map +1 -1
- package/graphql/schema/baseSchema.js.map +1 -1
- package/graphql/schema/contentEntries.js.map +1 -1
- package/graphql/schema/contentModelGroups.js.map +1 -1
- package/graphql/schema/contentModels.d.ts +2 -3
- package/graphql/schema/contentModels.js +7 -4
- package/graphql/schema/contentModels.js.map +1 -1
- package/graphql/schema/createManageResolvers.d.ts +1 -2
- package/graphql/schema/createManageResolvers.js.map +1 -1
- package/graphql/schema/createManageSDL.js.map +1 -1
- package/graphql/schema/createPreviewResolvers.d.ts +1 -2
- package/graphql/schema/createPreviewResolvers.js.map +1 -1
- package/graphql/schema/createReadResolvers.d.ts +1 -2
- package/graphql/schema/createReadResolvers.js.map +1 -1
- package/graphql/schema/createReadSDL.js.map +1 -1
- package/graphql/schema/createSingularResolvers.d.ts +1 -2
- package/graphql/schema/createSingularResolvers.js.map +1 -1
- package/graphql/schema/createSingularSDL.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveGet.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveMove.js.map +1 -1
- package/graphql/schema/resolvers/preview/resolveGet.js.map +1 -1
- package/graphql/schema/resolvers/read/resolveGet.js.map +1 -1
- package/graphql/schema/schemaPlugins.d.ts +1 -1
- package/graphql/schema/schemaPlugins.js +9 -9
- package/graphql/schema/schemaPlugins.js.map +1 -1
- package/graphql/system.js.map +1 -1
- package/graphqlFields/boolean.js.map +1 -1
- package/graphqlFields/datetime.js.map +1 -1
- package/graphqlFields/dynamicZone/dynamicZoneField.js.map +1 -1
- package/graphqlFields/file.js.map +1 -1
- package/graphqlFields/helpers.js.map +1 -1
- package/graphqlFields/json.js.map +1 -1
- package/graphqlFields/longText.js.map +1 -1
- package/graphqlFields/number.js.map +1 -1
- package/graphqlFields/object.js.map +1 -1
- package/graphqlFields/ref.js.map +1 -1
- package/graphqlFields/richText.js.map +1 -1
- package/graphqlFields/text.js.map +1 -1
- package/htmlRenderer/createLexicalHTMLRenderer.js +1 -1
- package/htmlRenderer/createLexicalHTMLRenderer.js.map +1 -1
- package/modelManager/SingletonModelManager.js.map +1 -1
- package/package.json +29 -34
- package/parameters/header.js.map +1 -1
- package/parameters/manual.js.map +1 -1
- package/parameters/path.js.map +1 -1
- package/plugins/CmsModelPlugin.js.map +1 -1
- package/storage/date.js.map +1 -1
- package/storage/dynamicZone.js.map +1 -1
- package/storage/object.js.map +1 -1
- package/types/modelField.d.ts +4 -0
- package/types/modelField.js.map +1 -1
- package/types/types.d.ts +8 -1
- package/types/types.js.map +1 -1
- package/utils/caching/Cache.d.ts +4 -1
- package/utils/caching/Cache.js +4 -7
- package/utils/caching/Cache.js.map +1 -1
- package/utils/caching/types.d.ts +1 -0
- package/utils/caching/types.js.map +1 -1
- package/utils/converters/Converter.js.map +1 -1
- package/utils/converters/ConverterCollection.js.map +1 -1
- package/utils/converters/valueKeyStorageConverter.js.map +1 -1
- package/utils/createModelField.js.map +1 -1
- package/utils/createTypeFromFields.js.map +1 -1
- package/utils/entryStorage.js.map +1 -1
- package/utils/getSchemaFromFieldPlugins.js.map +1 -1
- package/utils/renderFields.js +2 -0
- package/utils/renderFields.js.map +1 -1
- package/utils/renderListFilterFields.js.map +1 -1
- package/utils/renderSortEnum.js.map +1 -1
- package/validators/dateGte.js.map +1 -1
- package/validators/dateLte.js.map +1 -1
- package/validators/gte.js.map +1 -1
- package/validators/in.js.map +1 -1
- package/validators/lte.js.map +1 -1
- package/validators/maxLength.js.map +1 -1
- package/validators/minLength.js.map +1 -1
- package/validators/patternPlugins/email.js.map +1 -1
- package/validators/patternPlugins/lowerCase.js.map +1 -1
- package/validators/patternPlugins/lowerCaseSpace.js.map +1 -1
- package/validators/patternPlugins/upperCase.js.map +1 -1
- package/validators/patternPlugins/upperCaseSpace.js.map +1 -1
- package/validators/timeGte.js.map +1 -1
- package/validators/timeLte.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_error","_interopRequireDefault","require","_handlerGraphql","_CmsGroupPlugin","_pubsub","_beforeUpdate","_beforeCreate","_beforeDelete","_validation","_utils","_filterAsync","_utils2","_listGroupsFromDatabase","createModelGroupsCrud","params","getTenant","getIdentity","getLocale","storageOperations","accessControl","context","filterGroup","group","canAccessGroup","listDatabaseGroupsCache","createMemoryCache","listFilteredDatabaseGroupsCache","listPluginGroupsCache","clearGroupsCache","clear","fetchPluginGroups","tenant","locale","pluginGroups","plugins","byType","CmsGroupPlugin","type","cacheKey","createCacheKey","identity","security","isAuthorizationEnabled","id","undefined","groups","map","contentModelGroup","slug","savedOn","join","getOrSet","filter","plugin","t","l","webinyVersion","WEBINY_VERSION","filterAsync","fetchGroups","databaseGroups","listGroupsFromDatabase","filteredCacheKey","dbCacheKey","get","concat","onGroupBeforeCreate","createTopic","onGroupAfterCreate","onGroupCreateError","onGroupBeforeUpdate","onGroupAfterUpdate","onGroupUpdateError","onGroupBeforeDelete","onGroupAfterDelete","onGroupDeleteError","assignBeforeGroupCreate","assignBeforeGroupUpdate","assignBeforeGroupDelete","getGroup","ensureCanAccessGroup","withoutAuthorization","code","find","NotFoundError","listGroups","where","createGroup","input","rwd","result","createGroupCreateValidation","safeParseAsync","success","createZodError","error","data","mdbid","createdOn","Date","toISOString","createdBy","displayName","publish","create","ex","WebinyError","message","updateGroup","original","createGroupUpdateValidation","Object","keys","length","updatedGroup","update","deleteGroup","delete","benchmark","measure","exports"],"sources":["contentModelGroup.crud.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { NotFoundError } from \"@webiny/handler-graphql\";\nimport {\n CmsContext,\n CmsGroup,\n CmsGroupContext,\n HeadlessCmsStorageOperations,\n OnGroupAfterCreateTopicParams,\n OnGroupAfterDeleteTopicParams,\n OnGroupAfterUpdateTopicParams,\n OnGroupBeforeCreateTopicParams,\n OnGroupBeforeDeleteTopicParams,\n OnGroupBeforeUpdateTopicParams,\n OnGroupCreateErrorTopicParams,\n OnGroupDeleteErrorTopicParams,\n OnGroupUpdateErrorTopicParams\n} from \"~/types\";\nimport { CmsGroupPlugin } from \"~/plugins/CmsGroupPlugin\";\nimport { Tenant } from \"@webiny/api-tenancy/types\";\nimport { I18NLocale } from \"@webiny/api-i18n/types\";\nimport { SecurityIdentity } from \"@webiny/api-security/types\";\nimport { createTopic } from \"@webiny/pubsub\";\nimport { assignBeforeGroupUpdate } from \"./contentModelGroup/beforeUpdate\";\nimport { assignBeforeGroupCreate } from \"./contentModelGroup/beforeCreate\";\nimport { assignBeforeGroupDelete } from \"./contentModelGroup/beforeDelete\";\nimport {\n createGroupCreateValidation,\n createGroupUpdateValidation\n} from \"~/crud/contentModelGroup/validation\";\nimport { createZodError, mdbid } from \"@webiny/utils\";\nimport { filterAsync } from \"~/utils/filterAsync\";\nimport { createCacheKey, createMemoryCache } from \"~/utils\";\nimport { listGroupsFromDatabase } from \"~/crud/contentModelGroup/listGroupsFromDatabase\";\nimport { AccessControl } from \"./AccessControl/AccessControl\";\n\nexport interface CreateModelGroupsCrudParams {\n getTenant: () => Tenant;\n getLocale: () => I18NLocale;\n storageOperations: HeadlessCmsStorageOperations;\n accessControl: AccessControl;\n context: CmsContext;\n getIdentity: () => SecurityIdentity;\n}\n\nexport const createModelGroupsCrud = (params: CreateModelGroupsCrudParams): CmsGroupContext => {\n const { getTenant, getIdentity, getLocale, storageOperations, accessControl, context } = params;\n\n const filterGroup = async (group?: CmsGroup) => {\n if (!group) {\n return false;\n }\n\n return accessControl.canAccessGroup({ group });\n };\n\n const listDatabaseGroupsCache = createMemoryCache<Promise<CmsGroup[]>>();\n const listFilteredDatabaseGroupsCache = createMemoryCache<Promise<CmsGroup[]>>();\n const listPluginGroupsCache = createMemoryCache<Promise<CmsGroup[]>>();\n const clearGroupsCache = (): void => {\n listPluginGroupsCache.clear();\n listDatabaseGroupsCache.clear();\n listFilteredDatabaseGroupsCache.clear();\n };\n\n const fetchPluginGroups = (tenant: string, locale: string): Promise<CmsGroup[]> => {\n const pluginGroups = context.plugins.byType<CmsGroupPlugin>(CmsGroupPlugin.type);\n\n const cacheKey = createCacheKey({\n tenant,\n locale,\n identity: context.security.isAuthorizationEnabled() ? getIdentity()?.id : undefined,\n groups: pluginGroups\n .map(({ contentModelGroup: group }) => {\n return `${group.id}#${group.slug}#${group.savedOn || \"unknown\"}`;\n })\n .join(\"/\")\n });\n\n return listPluginGroupsCache.getOrSet(cacheKey, async (): Promise<CmsGroup[]> => {\n const groups = pluginGroups\n /**\n * We need to filter out groups that are not for this tenant or locale.\n * If it does not have tenant or locale define, it is for every locale and tenant\n */\n .filter(plugin => {\n const { tenant: t, locale: l } = plugin.contentModelGroup;\n if (t && t !== tenant) {\n return false;\n } else if (l && l !== locale) {\n return false;\n }\n return true;\n })\n .map(plugin => {\n return {\n ...plugin.contentModelGroup,\n tenant,\n locale,\n webinyVersion: context.WEBINY_VERSION\n };\n });\n return filterAsync(groups, filterGroup);\n });\n };\n\n const fetchGroups = async (tenant: string, locale: string) => {\n const pluginGroups = await fetchPluginGroups(tenant, locale);\n /**\n * Maybe we can cache based on permissions, not the identity id?\n *\n * TODO: @adrian please check if possible.\n */\n const cacheKey = createCacheKey({\n tenant,\n locale\n });\n const databaseGroups = await listDatabaseGroupsCache.getOrSet(cacheKey, async () => {\n return await listGroupsFromDatabase({\n storageOperations,\n tenant,\n locale\n });\n });\n const filteredCacheKey = createCacheKey({\n dbCacheKey: cacheKey.get(),\n identity: context.security.isAuthorizationEnabled() ? getIdentity()?.id : undefined\n });\n\n const groups = await listFilteredDatabaseGroupsCache.getOrSet(\n filteredCacheKey,\n async () => {\n return filterAsync(databaseGroups, filterGroup);\n }\n );\n\n return groups.concat(pluginGroups);\n };\n\n /**\n * Create\n */\n const onGroupBeforeCreate =\n createTopic<OnGroupBeforeCreateTopicParams>(\"cms.onGroupBeforeCreate\");\n const onGroupAfterCreate = createTopic<OnGroupAfterCreateTopicParams>(\"cms.onGroupAfterCreate\");\n const onGroupCreateError = createTopic<OnGroupCreateErrorTopicParams>(\"cms.onGroupCreateError\");\n /**\n * Update\n */\n const onGroupBeforeUpdate =\n createTopic<OnGroupBeforeUpdateTopicParams>(\"cms.onGroupBeforeUpdate\");\n const onGroupAfterUpdate = createTopic<OnGroupAfterUpdateTopicParams>(\"cms.onGroupAfterUpdate\");\n const onGroupUpdateError = createTopic<OnGroupUpdateErrorTopicParams>(\"cms.onGroupUpdateError\");\n /**\n * Delete\n */\n const onGroupBeforeDelete =\n createTopic<OnGroupBeforeDeleteTopicParams>(\"cms.onGroupBeforeDelete\");\n const onGroupAfterDelete = createTopic<OnGroupAfterDeleteTopicParams>(\"cms.onGroupAfterDelete\");\n const onGroupDeleteError = createTopic<OnGroupDeleteErrorTopicParams>(\"cms.onGroupDeleteError\");\n\n /**\n * We need to assign some default behaviors.\n */\n assignBeforeGroupCreate({\n onGroupBeforeCreate,\n plugins: context.plugins,\n storageOperations\n });\n assignBeforeGroupUpdate({\n onGroupBeforeUpdate,\n plugins: context.plugins\n });\n assignBeforeGroupDelete({\n onGroupBeforeDelete,\n plugins: context.plugins,\n storageOperations\n });\n /**\n * CRUD Methods\n */\n const getGroup: CmsGroupContext[\"getGroup\"] = async id => {\n await accessControl.ensureCanAccessGroup();\n\n const groups = await context.security.withoutAuthorization(async () => {\n return fetchGroups(getTenant().id, getLocale().code);\n });\n const group = groups.find(group => group.id === id);\n if (!group) {\n throw new NotFoundError(`Cms Group \"${id}\" was not found!`);\n }\n\n await accessControl.ensureCanAccessGroup({ group });\n\n return group;\n };\n\n const listGroups: CmsGroupContext[\"listGroups\"] = async params => {\n const { where } = params || {};\n\n const { tenant, locale } = where || {};\n\n await accessControl.ensureCanAccessGroup();\n\n return fetchGroups(tenant || getTenant().id, locale || getLocale().code);\n };\n\n const createGroup: CmsGroupContext[\"createGroup\"] = async input => {\n await accessControl.ensureCanAccessGroup({ rwd: \"w\" });\n\n const result = await createGroupCreateValidation().safeParseAsync(input);\n\n if (!result.success) {\n throw createZodError(result.error);\n }\n const data = result.data;\n\n const identity = getIdentity();\n\n const id = data.id || mdbid();\n const group: CmsGroup = {\n ...data,\n id,\n tenant: getTenant().id,\n locale: getLocale().code,\n createdOn: new Date().toISOString(),\n savedOn: new Date().toISOString(),\n createdBy: {\n id: identity.id,\n displayName: identity.displayName,\n type: identity.type\n },\n webinyVersion: context.WEBINY_VERSION\n };\n\n await accessControl.ensureCanAccessGroup({ group, rwd: \"w\" });\n\n try {\n await onGroupBeforeCreate.publish({\n group\n });\n\n const result = await storageOperations.groups.create({\n group\n });\n\n clearGroupsCache();\n\n await onGroupAfterCreate.publish({\n group: result\n });\n\n return group;\n } catch (ex) {\n await onGroupCreateError.publish({\n input,\n group,\n error: ex\n });\n throw new WebinyError(\n ex.message || \"Could not save data model group.\",\n ex.code || \"ERROR_ON_CREATE\",\n {\n ...(ex.data || {}),\n group,\n input\n }\n );\n }\n };\n const updateGroup: CmsGroupContext[\"updateGroup\"] = async (id, input) => {\n await accessControl.ensureCanAccessGroup({ rwd: \"w\" });\n\n const original = await getGroup(id);\n\n await accessControl.ensureCanAccessGroup({ group: original });\n\n const result = await createGroupUpdateValidation().safeParseAsync(input);\n\n if (!result.success) {\n throw createZodError(result.error);\n }\n const data = result.data;\n\n /**\n * No need to continue if no values were changed\n */\n if (Object.keys(data).length === 0) {\n return original;\n }\n\n const group: CmsGroup = {\n ...original,\n ...data,\n locale: getLocale().code,\n tenant: getTenant().id,\n savedOn: new Date().toISOString()\n };\n\n try {\n await onGroupBeforeUpdate.publish({\n original,\n group\n });\n\n const updatedGroup = await storageOperations.groups.update({\n group\n });\n clearGroupsCache();\n\n await onGroupAfterUpdate.publish({\n original,\n group: updatedGroup\n });\n\n return updatedGroup;\n } catch (ex) {\n await onGroupUpdateError.publish({\n input,\n original,\n group,\n error: ex\n });\n throw new WebinyError(ex.message, ex.code || \"UPDATE_ERROR\", {\n error: ex,\n original,\n group,\n input\n });\n }\n };\n const deleteGroup: CmsGroupContext[\"deleteGroup\"] = async id => {\n await accessControl.ensureCanAccessGroup({ rwd: \"d\" });\n\n const group = await getGroup(id);\n\n await accessControl.ensureCanAccessGroup({ group });\n\n try {\n await onGroupBeforeDelete.publish({\n group\n });\n\n await storageOperations.groups.delete({ group });\n clearGroupsCache();\n\n await onGroupAfterDelete.publish({\n group\n });\n } catch (ex) {\n await onGroupDeleteError.publish({\n group,\n error: ex\n });\n throw new WebinyError(ex.message, ex.code || \"DELETE_ERROR\", {\n ...(ex.data || {}),\n id\n });\n }\n\n return true;\n };\n\n return {\n onGroupBeforeCreate,\n onGroupAfterCreate,\n onGroupCreateError,\n onGroupBeforeUpdate,\n onGroupAfterUpdate,\n onGroupUpdateError,\n onGroupBeforeDelete,\n onGroupAfterDelete,\n onGroupDeleteError,\n clearGroupsCache,\n getGroup: async id => {\n return context.benchmark.measure(\"headlessCms.crud.groups.getGroup\", async () => {\n return getGroup(id);\n });\n },\n listGroups: async params => {\n return context.benchmark.measure(\"headlessCms.crud.groups.listGroups\", async () => {\n return listGroups(params);\n });\n },\n createGroup: async input => {\n return context.benchmark.measure(\"headlessCms.crud.groups.createGroup\", async () => {\n return createGroup(input);\n });\n },\n updateGroup: async (id, input) => {\n return context.benchmark.measure(\"headlessCms.crud.groups.updateGroup\", async () => {\n return updateGroup(id, input);\n });\n },\n deleteGroup: async id => {\n return context.benchmark.measure(\"headlessCms.crud.groups.deleteGroup\", async () => {\n return deleteGroup(id);\n });\n }\n };\n};\n"],"mappings":";;;;;;;AA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AACpC,EAAE,CAAC;MACvB,CAAC,CAAC;IACN,CAAC;IACD0C,UAAU,EAAE,MAAMvE,MAAM,IAAI;MACxB,OAAOM,OAAO,CAACkG,SAAS,CAACC,OAAO,CAAC,oCAAoC,EAAE,YAAY;QAC/E,OAAOlC,UAAU,CAACvE,MAAM,CAAC;MAC7B,CAAC,CAAC;IACN,CAAC;IACDyE,WAAW,EAAE,MAAMC,KAAK,IAAI;MACxB,OAAOpE,OAAO,CAACkG,SAAS,CAACC,OAAO,CAAC,qCAAqC,EAAE,YAAY;QAChF,OAAOhC,WAAW,CAACC,KAAK,CAAC;MAC7B,CAAC,CAAC;IACN,CAAC;IACDoB,WAAW,EAAE,MAAAA,CAAOjE,EAAE,EAAE6C,KAAK,KAAK;MAC9B,OAAOpE,OAAO,CAACkG,SAAS,CAACC,OAAO,CAAC,qCAAqC,EAAE,YAAY;QAChF,OAAOX,WAAW,CAACjE,EAAE,EAAE6C,KAAK,CAAC;MACjC,CAAC,CAAC;IACN,CAAC;IACD4B,WAAW,EAAE,MAAMzE,EAAE,IAAI;MACrB,OAAOvB,OAAO,CAACkG,SAAS,CAACC,OAAO,CAAC,qCAAqC,EAAE,YAAY;QAChF,OAAOH,WAAW,CAACzE,EAAE,CAAC;MAC1B,CAAC,CAAC;IACN;EACJ,CAAC;AACL,CAAC;AAAC6E,OAAA,CAAA3G,qBAAA,GAAAA,qBAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_handlerGraphql","_CmsGroupPlugin","_pubsub","_beforeUpdate","_beforeCreate","_beforeDelete","_validation","_utils","_filterAsync","_utils2","_listGroupsFromDatabase","createModelGroupsCrud","params","getTenant","getIdentity","getLocale","storageOperations","accessControl","context","filterGroup","group","canAccessGroup","listDatabaseGroupsCache","createMemoryCache","listFilteredDatabaseGroupsCache","listPluginGroupsCache","clearGroupsCache","clear","fetchPluginGroups","tenant","locale","pluginGroups","plugins","byType","CmsGroupPlugin","type","cacheKey","createCacheKey","identity","security","isAuthorizationEnabled","id","undefined","groups","map","contentModelGroup","slug","savedOn","join","getOrSet","filter","plugin","t","l","webinyVersion","WEBINY_VERSION","filterAsync","fetchGroups","databaseGroups","listGroupsFromDatabase","filteredCacheKey","dbCacheKey","get","concat","onGroupBeforeCreate","createTopic","onGroupAfterCreate","onGroupCreateError","onGroupBeforeUpdate","onGroupAfterUpdate","onGroupUpdateError","onGroupBeforeDelete","onGroupAfterDelete","onGroupDeleteError","assignBeforeGroupCreate","assignBeforeGroupUpdate","assignBeforeGroupDelete","getGroup","ensureCanAccessGroup","withoutAuthorization","code","find","NotFoundError","listGroups","where","createGroup","input","rwd","result","createGroupCreateValidation","safeParseAsync","success","createZodError","error","data","mdbid","createdOn","Date","toISOString","createdBy","displayName","publish","create","ex","WebinyError","message","updateGroup","original","createGroupUpdateValidation","Object","keys","length","updatedGroup","update","deleteGroup","delete","benchmark","measure","exports"],"sources":["contentModelGroup.crud.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { NotFoundError } from \"@webiny/handler-graphql\";\nimport {\n CmsContext,\n CmsGroup,\n CmsGroupContext,\n HeadlessCmsStorageOperations,\n OnGroupAfterCreateTopicParams,\n OnGroupAfterDeleteTopicParams,\n OnGroupAfterUpdateTopicParams,\n OnGroupBeforeCreateTopicParams,\n OnGroupBeforeDeleteTopicParams,\n OnGroupBeforeUpdateTopicParams,\n OnGroupCreateErrorTopicParams,\n OnGroupDeleteErrorTopicParams,\n OnGroupUpdateErrorTopicParams\n} from \"~/types\";\nimport { CmsGroupPlugin } from \"~/plugins/CmsGroupPlugin\";\nimport { Tenant } from \"@webiny/api-tenancy/types\";\nimport { I18NLocale } from \"@webiny/api-i18n/types\";\nimport { SecurityIdentity } from \"@webiny/api-security/types\";\nimport { createTopic } from \"@webiny/pubsub\";\nimport { assignBeforeGroupUpdate } from \"./contentModelGroup/beforeUpdate\";\nimport { assignBeforeGroupCreate } from \"./contentModelGroup/beforeCreate\";\nimport { assignBeforeGroupDelete } from \"./contentModelGroup/beforeDelete\";\nimport {\n createGroupCreateValidation,\n createGroupUpdateValidation\n} from \"~/crud/contentModelGroup/validation\";\nimport { createZodError, mdbid } from \"@webiny/utils\";\nimport { filterAsync } from \"~/utils/filterAsync\";\nimport { createCacheKey, createMemoryCache } from \"~/utils\";\nimport { listGroupsFromDatabase } from \"~/crud/contentModelGroup/listGroupsFromDatabase\";\nimport { AccessControl } from \"./AccessControl/AccessControl\";\n\nexport interface CreateModelGroupsCrudParams {\n getTenant: () => Tenant;\n getLocale: () => I18NLocale;\n storageOperations: HeadlessCmsStorageOperations;\n accessControl: AccessControl;\n context: CmsContext;\n getIdentity: () => SecurityIdentity;\n}\n\nexport const createModelGroupsCrud = (params: CreateModelGroupsCrudParams): CmsGroupContext => {\n const { getTenant, getIdentity, getLocale, storageOperations, accessControl, context } = params;\n\n const filterGroup = async (group?: CmsGroup) => {\n if (!group) {\n return false;\n }\n\n return accessControl.canAccessGroup({ group });\n };\n\n const listDatabaseGroupsCache = createMemoryCache<Promise<CmsGroup[]>>();\n const listFilteredDatabaseGroupsCache = createMemoryCache<Promise<CmsGroup[]>>();\n const listPluginGroupsCache = createMemoryCache<Promise<CmsGroup[]>>();\n const clearGroupsCache = (): void => {\n listPluginGroupsCache.clear();\n listDatabaseGroupsCache.clear();\n listFilteredDatabaseGroupsCache.clear();\n };\n\n const fetchPluginGroups = (tenant: string, locale: string): Promise<CmsGroup[]> => {\n const pluginGroups = context.plugins.byType<CmsGroupPlugin>(CmsGroupPlugin.type);\n\n const cacheKey = createCacheKey({\n tenant,\n locale,\n identity: context.security.isAuthorizationEnabled() ? getIdentity()?.id : undefined,\n groups: pluginGroups\n .map(({ contentModelGroup: group }) => {\n return `${group.id}#${group.slug}#${group.savedOn || \"unknown\"}`;\n })\n .join(\"/\")\n });\n\n return listPluginGroupsCache.getOrSet(cacheKey, async (): Promise<CmsGroup[]> => {\n const groups = pluginGroups\n /**\n * We need to filter out groups that are not for this tenant or locale.\n * If it does not have tenant or locale define, it is for every locale and tenant\n */\n .filter(plugin => {\n const { tenant: t, locale: l } = plugin.contentModelGroup;\n if (t && t !== tenant) {\n return false;\n } else if (l && l !== locale) {\n return false;\n }\n return true;\n })\n .map(plugin => {\n return {\n ...plugin.contentModelGroup,\n tenant,\n locale,\n webinyVersion: context.WEBINY_VERSION\n };\n });\n return filterAsync(groups, filterGroup);\n });\n };\n\n const fetchGroups = async (tenant: string, locale: string) => {\n const pluginGroups = await fetchPluginGroups(tenant, locale);\n /**\n * Maybe we can cache based on permissions, not the identity id?\n *\n * TODO: @adrian please check if possible.\n */\n const cacheKey = createCacheKey({\n tenant,\n locale\n });\n const databaseGroups = await listDatabaseGroupsCache.getOrSet(cacheKey, async () => {\n return await listGroupsFromDatabase({\n storageOperations,\n tenant,\n locale\n });\n });\n const filteredCacheKey = createCacheKey({\n dbCacheKey: cacheKey.get(),\n identity: context.security.isAuthorizationEnabled() ? getIdentity()?.id : undefined\n });\n\n const groups = await listFilteredDatabaseGroupsCache.getOrSet(\n filteredCacheKey,\n async () => {\n return filterAsync(databaseGroups, filterGroup);\n }\n );\n\n return groups.concat(pluginGroups);\n };\n\n /**\n * Create\n */\n const onGroupBeforeCreate =\n createTopic<OnGroupBeforeCreateTopicParams>(\"cms.onGroupBeforeCreate\");\n const onGroupAfterCreate = createTopic<OnGroupAfterCreateTopicParams>(\"cms.onGroupAfterCreate\");\n const onGroupCreateError = createTopic<OnGroupCreateErrorTopicParams>(\"cms.onGroupCreateError\");\n /**\n * Update\n */\n const onGroupBeforeUpdate =\n createTopic<OnGroupBeforeUpdateTopicParams>(\"cms.onGroupBeforeUpdate\");\n const onGroupAfterUpdate = createTopic<OnGroupAfterUpdateTopicParams>(\"cms.onGroupAfterUpdate\");\n const onGroupUpdateError = createTopic<OnGroupUpdateErrorTopicParams>(\"cms.onGroupUpdateError\");\n /**\n * Delete\n */\n const onGroupBeforeDelete =\n createTopic<OnGroupBeforeDeleteTopicParams>(\"cms.onGroupBeforeDelete\");\n const onGroupAfterDelete = createTopic<OnGroupAfterDeleteTopicParams>(\"cms.onGroupAfterDelete\");\n const onGroupDeleteError = createTopic<OnGroupDeleteErrorTopicParams>(\"cms.onGroupDeleteError\");\n\n /**\n * We need to assign some default behaviors.\n */\n assignBeforeGroupCreate({\n onGroupBeforeCreate,\n plugins: context.plugins,\n storageOperations\n });\n assignBeforeGroupUpdate({\n onGroupBeforeUpdate,\n plugins: context.plugins\n });\n assignBeforeGroupDelete({\n onGroupBeforeDelete,\n plugins: context.plugins,\n storageOperations\n });\n /**\n * CRUD Methods\n */\n const getGroup: CmsGroupContext[\"getGroup\"] = async id => {\n await accessControl.ensureCanAccessGroup();\n\n const groups = await context.security.withoutAuthorization(async () => {\n return fetchGroups(getTenant().id, getLocale().code);\n });\n const group = groups.find(group => group.id === id);\n if (!group) {\n throw new NotFoundError(`Cms Group \"${id}\" was not found!`);\n }\n\n await accessControl.ensureCanAccessGroup({ group });\n\n return group;\n };\n\n const listGroups: CmsGroupContext[\"listGroups\"] = async params => {\n const { where } = params || {};\n\n const { tenant, locale } = where || {};\n\n await accessControl.ensureCanAccessGroup();\n\n return fetchGroups(tenant || getTenant().id, locale || getLocale().code);\n };\n\n const createGroup: CmsGroupContext[\"createGroup\"] = async input => {\n await accessControl.ensureCanAccessGroup({ rwd: \"w\" });\n\n const result = await createGroupCreateValidation().safeParseAsync(input);\n\n if (!result.success) {\n throw createZodError(result.error);\n }\n const data = result.data;\n\n const identity = getIdentity();\n\n const id = data.id || mdbid();\n const group: CmsGroup = {\n ...data,\n id,\n tenant: getTenant().id,\n locale: getLocale().code,\n createdOn: new Date().toISOString(),\n savedOn: new Date().toISOString(),\n createdBy: {\n id: identity.id,\n displayName: identity.displayName,\n type: identity.type\n },\n webinyVersion: context.WEBINY_VERSION\n };\n\n await accessControl.ensureCanAccessGroup({ group, rwd: \"w\" });\n\n try {\n await onGroupBeforeCreate.publish({\n group\n });\n\n const result = await storageOperations.groups.create({\n group\n });\n\n clearGroupsCache();\n\n await onGroupAfterCreate.publish({\n group: result\n });\n\n return group;\n } catch (ex) {\n await onGroupCreateError.publish({\n input,\n group,\n error: ex\n });\n throw new WebinyError(\n ex.message || \"Could not save data model group.\",\n ex.code || \"ERROR_ON_CREATE\",\n {\n ...(ex.data || {}),\n group,\n input\n }\n );\n }\n };\n const updateGroup: CmsGroupContext[\"updateGroup\"] = async (id, input) => {\n await accessControl.ensureCanAccessGroup({ rwd: \"w\" });\n\n const original = await getGroup(id);\n\n await accessControl.ensureCanAccessGroup({ group: original });\n\n const result = await createGroupUpdateValidation().safeParseAsync(input);\n\n if (!result.success) {\n throw createZodError(result.error);\n }\n const data = result.data;\n\n /**\n * No need to continue if no values were changed\n */\n if (Object.keys(data).length === 0) {\n return original;\n }\n\n const group: CmsGroup = {\n ...original,\n ...data,\n locale: getLocale().code,\n tenant: getTenant().id,\n savedOn: new Date().toISOString()\n };\n\n try {\n await onGroupBeforeUpdate.publish({\n original,\n group\n });\n\n const updatedGroup = await storageOperations.groups.update({\n group\n });\n clearGroupsCache();\n\n await onGroupAfterUpdate.publish({\n original,\n group: updatedGroup\n });\n\n return updatedGroup;\n } catch (ex) {\n await onGroupUpdateError.publish({\n input,\n original,\n group,\n error: ex\n });\n throw new WebinyError(ex.message, ex.code || \"UPDATE_ERROR\", {\n error: ex,\n original,\n group,\n input\n });\n }\n };\n const deleteGroup: CmsGroupContext[\"deleteGroup\"] = async id => {\n await accessControl.ensureCanAccessGroup({ rwd: \"d\" });\n\n const group = await getGroup(id);\n\n await accessControl.ensureCanAccessGroup({ group });\n\n try {\n await onGroupBeforeDelete.publish({\n group\n });\n\n await storageOperations.groups.delete({ group });\n clearGroupsCache();\n\n await onGroupAfterDelete.publish({\n group\n });\n } catch (ex) {\n await onGroupDeleteError.publish({\n group,\n error: ex\n });\n throw new WebinyError(ex.message, ex.code || \"DELETE_ERROR\", {\n ...(ex.data || {}),\n id\n });\n }\n\n return true;\n };\n\n return {\n onGroupBeforeCreate,\n onGroupAfterCreate,\n onGroupCreateError,\n onGroupBeforeUpdate,\n onGroupAfterUpdate,\n onGroupUpdateError,\n onGroupBeforeDelete,\n onGroupAfterDelete,\n onGroupDeleteError,\n clearGroupsCache,\n getGroup: async id => {\n return context.benchmark.measure(\"headlessCms.crud.groups.getGroup\", async () => {\n return getGroup(id);\n });\n },\n listGroups: async params => {\n return context.benchmark.measure(\"headlessCms.crud.groups.listGroups\", async () => {\n return listGroups(params);\n });\n },\n createGroup: async input => {\n return context.benchmark.measure(\"headlessCms.crud.groups.createGroup\", async () => {\n return createGroup(input);\n });\n },\n updateGroup: async (id, input) => {\n return context.benchmark.measure(\"headlessCms.crud.groups.updateGroup\", async () => {\n return updateGroup(id, input);\n });\n },\n deleteGroup: async id => {\n return context.benchmark.measure(\"headlessCms.crud.groups.deleteGroup\", async () => {\n return deleteGroup(id);\n });\n }\n };\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,eAAA,GAAAD,OAAA;AAgBA,IAAAE,eAAA,GAAAF,OAAA;AAIA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AACA,IAAAK,aAAA,GAAAL,OAAA;AACA,IAAAM,aAAA,GAAAN,OAAA;AACA,IAAAO,WAAA,GAAAP,OAAA;AAIA,IAAAQ,MAAA,GAAAR,OAAA;AACA,IAAAS,YAAA,GAAAT,OAAA;AACA,IAAAU,OAAA,GAAAV,OAAA;AACA,IAAAW,uBAAA,GAAAX,OAAA;AAYO,MAAMY,qBAAqB,GAAIC,MAAmC,IAAsB;EAC3F,MAAM;IAAEC,SAAS;IAAEC,WAAW;IAAEC,SAAS;IAAEC,iBAAiB;IAAEC,aAAa;IAAEC;EAAQ,CAAC,GAAGN,MAAM;EAE/F,MAAMO,WAAW,GAAG,MAAOC,KAAgB,IAAK;IAC5C,IAAI,CAACA,KAAK,EAAE;MACR,OAAO,KAAK;IAChB;IAEA,OAAOH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OAAOvB,OAAO,CAACkG,SAAS,CAACC,OAAO,CAAC,qCAAqC,EAAE,YAAY;QAChF,OAAOH,WAAW,CAACzE,EAAE,CAAC;MAC1B,CAAC,CAAC;IACN;EACJ,CAAC;AACL,CAAC;AAAC6E,OAAA,CAAA3G,qBAAA,GAAAA,qBAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_types","require","importModels","params","context","models","groups","cms","listGroups","results","model","group","find","id","push","action","related","imported","error","message","code","data","CmsImportAction","NONE","CODE","UPDATE","result","updateModel","modelId","ex","createModel","exports"],"sources":["importModels.ts"],"sourcesContent":["import { CmsContext } from \"~/types\";\nimport { CmsImportAction, CmsModelImportResult, ValidCmsModelResult } from \"~/export/types\";\n\ninterface Params {\n context: CmsContext;\n models: ValidCmsModelResult[];\n}\n\nexport const importModels = async (params: Params) => {\n const { context, models } = params;\n\n const groups = await context.cms.listGroups();\n\n const results: CmsModelImportResult[] = [];\n\n for (const model of models) {\n /**\n * There is a possibility that group does not exist.\n */\n const group = groups.find(group => {\n return group.id === model.model.group;\n });\n if (!group) {\n results.push({\n action: model.action,\n model: model.model,\n related: model.related,\n imported: false,\n error: {\n message: `Group \"${model.model.group}\" does not exist.`,\n code: \"GROUP_NOT_FOUND\",\n data: {\n model\n }\n }\n });\n continue;\n }\n /**\n * No update action or there is a validation error.\n */\n if (model.action === CmsImportAction.NONE || model.error) {\n results.push({\n action: model.action,\n model: model.model,\n related: model.related,\n imported: false,\n error: model.error || {\n message: \"No action to be ran on the model.\",\n code: \"NO_ACTION\"\n }\n });\n continue;\n }\n /**\n * Cannot update a model if it is created via plugin.\n */\n if (model.action === CmsImportAction.CODE) {\n results.push({\n action: model.action,\n model: model.model,\n related: model.related,\n imported: true\n });\n continue;\n }\n\n /**\n * Update the model\n */\n //\n if (model.action === CmsImportAction.UPDATE) {\n try {\n const result = await context.cms.updateModel(model.model.modelId, model.model);\n results.push({\n action: model.action,\n model: {\n ...result,\n group: group.id\n },\n related: model.related,\n imported: true\n });\n } catch (ex) {\n results.push({\n action: model.action,\n model: model.model,\n imported: false,\n related: model.related,\n error: {\n message: ex.message,\n code: ex.code || \"UPDATE_MODEL_ERROR\",\n data: {\n model: model.model,\n ...ex.data\n }\n }\n });\n }\n continue;\n }\n /**\n * Create a new model.\n */\n try {\n const result = await context.cms.createModel(model.model);\n results.push({\n action: model.action,\n model: {\n ...result,\n group: group.id\n },\n related: model.related,\n imported: true\n });\n } catch (ex) {\n results.push({\n action: model.action,\n model: model.model,\n imported: false,\n related: model.related,\n error: {\n message: ex.message,\n code: ex.code || \"CREATE_MODEL_ERROR\",\n data: {\n model: model.model,\n ...ex.data\n }\n }\n });\n }\n }\n\n return results;\n};\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AAOO,MAAMC,YAAY,GAAG,MAAOC,MAAc,IAAK;EAClD,MAAM;IAAEC,OAAO;IAAEC;EAAO,CAAC,GAAGF,MAAM;EAElC,MAAMG,MAAM,GAAG,MAAMF,OAAO,CAACG,GAAG,CAACC,UAAU,CAAC,CAAC;EAE7C,MAAMC,OAA+B,GAAG,EAAE;EAE1C,KAAK,MAAMC,KAAK,IAAIL,MAAM,EAAE;IACxB;AACR;AACA;IACQ,MAAMM,KAAK,GAAGL,MAAM,CAACM,IAAI,CAACD,KAAK,IAAI;MAC/B,OAAOA,KAAK,CAACE,EAAE,KAAKH,KAAK,CAACA,KAAK,CAACC,KAAK;IACzC,CAAC,CAAC;IACF,IAAI,CAACA,KAAK,EAAE;MACRF,OAAO,CAACK,IAAI,CAAC;QACTC,MAAM,EAAEL,KAAK,CAACK,MAAM;QACpBL,KAAK,EAAEA,KAAK,CAACA,KAAK;QAClBM,OAAO,EAAEN,KAAK,CAACM,OAAO;QACtBC,QAAQ,EAAE,KAAK;QACfC,KAAK,EAAE;UACHC,OAAO,
|
|
1
|
+
{"version":3,"names":["_types","require","importModels","params","context","models","groups","cms","listGroups","results","model","group","find","id","push","action","related","imported","error","message","code","data","CmsImportAction","NONE","CODE","UPDATE","result","updateModel","modelId","ex","createModel","exports"],"sources":["importModels.ts"],"sourcesContent":["import { CmsContext } from \"~/types\";\nimport { CmsImportAction, CmsModelImportResult, ValidCmsModelResult } from \"~/export/types\";\n\ninterface Params {\n context: CmsContext;\n models: ValidCmsModelResult[];\n}\n\nexport const importModels = async (params: Params) => {\n const { context, models } = params;\n\n const groups = await context.cms.listGroups();\n\n const results: CmsModelImportResult[] = [];\n\n for (const model of models) {\n /**\n * There is a possibility that group does not exist.\n */\n const group = groups.find(group => {\n return group.id === model.model.group;\n });\n if (!group) {\n results.push({\n action: model.action,\n model: model.model,\n related: model.related,\n imported: false,\n error: {\n message: `Group \"${model.model.group}\" does not exist.`,\n code: \"GROUP_NOT_FOUND\",\n data: {\n model\n }\n }\n });\n continue;\n }\n /**\n * No update action or there is a validation error.\n */\n if (model.action === CmsImportAction.NONE || model.error) {\n results.push({\n action: model.action,\n model: model.model,\n related: model.related,\n imported: false,\n error: model.error || {\n message: \"No action to be ran on the model.\",\n code: \"NO_ACTION\"\n }\n });\n continue;\n }\n /**\n * Cannot update a model if it is created via plugin.\n */\n if (model.action === CmsImportAction.CODE) {\n results.push({\n action: model.action,\n model: model.model,\n related: model.related,\n imported: true\n });\n continue;\n }\n\n /**\n * Update the model\n */\n //\n if (model.action === CmsImportAction.UPDATE) {\n try {\n const result = await context.cms.updateModel(model.model.modelId, model.model);\n results.push({\n action: model.action,\n model: {\n ...result,\n group: group.id\n },\n related: model.related,\n imported: true\n });\n } catch (ex) {\n results.push({\n action: model.action,\n model: model.model,\n imported: false,\n related: model.related,\n error: {\n message: ex.message,\n code: ex.code || \"UPDATE_MODEL_ERROR\",\n data: {\n model: model.model,\n ...ex.data\n }\n }\n });\n }\n continue;\n }\n /**\n * Create a new model.\n */\n try {\n const result = await context.cms.createModel(model.model);\n results.push({\n action: model.action,\n model: {\n ...result,\n group: group.id\n },\n related: model.related,\n imported: true\n });\n } catch (ex) {\n results.push({\n action: model.action,\n model: model.model,\n imported: false,\n related: model.related,\n error: {\n message: ex.message,\n code: ex.code || \"CREATE_MODEL_ERROR\",\n data: {\n model: model.model,\n ...ex.data\n }\n }\n });\n }\n }\n\n return results;\n};\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AAOO,MAAMC,YAAY,GAAG,MAAOC,MAAc,IAAK;EAClD,MAAM;IAAEC,OAAO;IAAEC;EAAO,CAAC,GAAGF,MAAM;EAElC,MAAMG,MAAM,GAAG,MAAMF,OAAO,CAACG,GAAG,CAACC,UAAU,CAAC,CAAC;EAE7C,MAAMC,OAA+B,GAAG,EAAE;EAE1C,KAAK,MAAMC,KAAK,IAAIL,MAAM,EAAE;IACxB;AACR;AACA;IACQ,MAAMM,KAAK,GAAGL,MAAM,CAACM,IAAI,CAACD,KAAK,IAAI;MAC/B,OAAOA,KAAK,CAACE,EAAE,KAAKH,KAAK,CAACA,KAAK,CAACC,KAAK;IACzC,CAAC,CAAC;IACF,IAAI,CAACA,KAAK,EAAE;MACRF,OAAO,CAACK,IAAI,CAAC;QACTC,MAAM,EAAEL,KAAK,CAACK,MAAM;QACpBL,KAAK,EAAEA,KAAK,CAACA,KAAK;QAClBM,OAAO,EAAEN,KAAK,CAACM,OAAO;QACtBC,QAAQ,EAAE,KAAK;QACfC,KAAK,EAAE;UACHC,OAAO,EAAE,UAAUT,KAAK,CAACA,KAAK,CAACC,KAAK,mBAAmB;UACvDS,IAAI,EAAE,iBAAiB;UACvBC,IAAI,EAAE;YACFX;UACJ;QACJ;MACJ,CAAC,CAAC;MACF;IACJ;IACA;AACR;AACA;IACQ,IAAIA,KAAK,CAACK,MAAM,KAAKO,sBAAe,CAACC,IAAI,IAAIb,KAAK,CAACQ,KAAK,EAAE;MACtDT,OAAO,CAACK,IAAI,CAAC;QACTC,MAAM,EAAEL,KAAK,CAACK,MAAM;QACpBL,KAAK,EAAEA,KAAK,CAACA,KAAK;QAClBM,OAAO,EAAEN,KAAK,CAAC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AK,EAAEA,KAAK,CAACA,KAAK;cAClB,GAAGmB,EAAE,CAACR;YACV;UACJ;QACJ,CAAC,CAAC;MACN;MACA;IACJ;IACA;AACR;AACA;IACQ,IAAI;MACA,MAAMK,MAAM,GAAG,MAAMtB,OAAO,CAACG,GAAG,CAACuB,WAAW,CAACpB,KAAK,CAACA,KAAK,CAAC;MACzDD,OAAO,CAACK,IAAI,CAAC;QACTC,MAAM,EAAEL,KAAK,CAACK,MAAM;QACpBL,KAAK,EAAE;UACH,GAAGgB,MAAM;UACTf,KAAK,EAAEA,KAAK,CAACE;QACjB,CAAC;QACDG,OAAO,EAAEN,KAAK,CAACM,OAAO;QACtBC,QAAQ,EAAE;MACd,CAAC,CAAC;IACN,CAAC,CAAC,OAAOY,EAAE,EAAE;MACTpB,OAAO,CAACK,IAAI,CAAC;QACTC,MAAM,EAAEL,KAAK,CAACK,MAAM;QACpBL,KAAK,EAAEA,KAAK,CAACA,KAAK;QAClBO,QAAQ,EAAE,KAAK;QACfD,OAAO,EAAEN,KAAK,CAACM,OAAO;QACtBE,KAAK,EAAE;UACHC,OAAO,EAAEU,EAAE,CAACV,OAAO;UACnBC,IAAI,EAAES,EAAE,CAACT,IAAI,IAAI,oBAAoB;UACrCC,IAAI,EAAE;YACFX,KAAK,EAAEA,KAAK,CAACA,KAAK;YAClB,GAAGmB,EAAE,CAACR;UACV;QACJ;MACJ,CAAC,CAAC;IACN;EACJ;EAEA,OAAOZ,OAAO;AAClB,CAAC;AAACsB,OAAA,CAAA7B,YAAA,GAAAA,YAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_validation","require","_utils","_types","validateGroups","params","groups","input","validation","createGroupCreateValidation","Promise","all","map","group","result","safeParseAsync","success","error","createZodError","action","CmsImportAction","NONE","message","code","data","id","slug","isPluginGroup","some","g","isPlugin","CODE","canBeUpdated","UPDATE","groupWithIdExists","groupWithSlugExists","find","target","CREATE","exports"],"sources":["validateGroups.ts"],"sourcesContent":["import { CmsGroup } from \"~/types\";\nimport { createGroupCreateValidation } from \"~/crud/contentModelGroup/validation\";\nimport { createZodError } from \"@webiny/utils\";\nimport { CmsImportAction, ValidatedCmsGroupResult } from \"~/export/types\";\n\ninterface Params {\n groups: Pick<CmsGroup, \"id\" | \"slug\" | \"isPlugin\">[];\n input: Partial<CmsGroup>[];\n}\n\nexport const validateGroups = async (params: Params): Promise<ValidatedCmsGroupResult[]> => {\n const { groups, input } = params;\n\n const validation = createGroupCreateValidation();\n\n return await Promise.all(\n input.map(async (group): Promise<ValidatedCmsGroupResult> => {\n const result = await validation.safeParseAsync(group);\n if (!result.success) {\n const error = createZodError(result.error);\n return {\n group: group as CmsGroup,\n action: CmsImportAction.NONE,\n error: {\n message: error.message,\n code: error.code,\n data: error.data\n }\n };\n }\n const data = result.data as CmsGroup;\n if (!data.id) {\n return {\n group: data,\n action: CmsImportAction.NONE,\n error: {\n message: `Group is missing ID.`,\n code: \"GROUP_ID_MISSING\"\n }\n };\n }\n if (!data.slug) {\n return {\n group: data,\n action: CmsImportAction.NONE,\n error: {\n message: `Group is missing slug.`,\n code: \"GROUP_SLUG_MISSING\"\n }\n };\n }\n\n const isPluginGroup = groups.some(g => {\n if (!g.isPlugin) {\n return false;\n }\n return g.id === data.id || g.slug === data.slug;\n });\n if (isPluginGroup) {\n return {\n group: data,\n action: CmsImportAction.CODE,\n error: {\n message: `Group already exists, but it is a plugin group - cannot be updated.`,\n code: \"GROUP_IS_PLUGIN\"\n }\n };\n }\n\n const canBeUpdated = groups.some(g => {\n return g.id === data.id && g.slug === data.slug;\n });\n if (canBeUpdated) {\n return {\n group: data,\n action: CmsImportAction.UPDATE\n };\n }\n\n const groupWithIdExists = groups.some(g => g.id === data.id);\n if (groupWithIdExists) {\n return {\n group: data,\n action: CmsImportAction.NONE,\n error: {\n message: `Group with ID \"${data.id}\" already exists. Cannot update it because the slug is different.`,\n code: \"GROUP_ID_EXISTS\"\n }\n };\n }\n\n const groupWithSlugExists = groups.find(g => g.slug === data.slug);\n if (groupWithSlugExists) {\n /**\n * If group with given slug already exists, we will map the ID to the existing group.\n *\n * We will also point all models from the imported group to the existing group.\n * We will not update the existing group.\n */\n return {\n group: {\n ...data,\n id: groupWithSlugExists.id\n },\n target: data.id,\n action: CmsImportAction.NONE\n };\n }\n\n return {\n group: data,\n action: CmsImportAction.CREATE\n };\n })\n );\n};\n"],"mappings":";;;;;;AACA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAOO,MAAMG,cAAc,GAAG,MAAOC,MAAc,IAAyC;EACxF,MAAM;IAAEC,MAAM;IAAEC;EAAM,CAAC,GAAGF,MAAM;EAEhC,MAAMG,UAAU,GAAG,IAAAC,uCAA2B,EAAC,CAAC;EAEhD,OAAO,MAAMC,OAAO,CAACC,GAAG,CACpBJ,KAAK,CAACK,GAAG,CAAC,MAAOC,KAAK,IAAuC;IACzD,MAAMC,MAAM,GAAG,MAAMN,UAAU,CAACO,cAAc,CAACF,KAAK,CAAC;IACrD,IAAI,CAACC,MAAM,CAACE,OAAO,EAAE;MACjB,MAAMC,KAAK,GAAG,IAAAC,qBAAc,EAACJ,MAAM,CAACG,KAAK,CAAC;MAC1C,OAAO;QACHJ,KAAK,EAAEA,KAAiB;QACxBM,MAAM,EAAEC,sBAAe,CAACC,IAAI;QAC5BJ,KAAK,EAAE;UACHK,OAAO,EAAEL,KAAK,CAACK,OAAO;UACtBC,IAAI,EAAEN,KAAK,CAACM,IAAI;UAChBC,IAAI,EAAEP,KAAK,CAACO;QAChB;MACJ,CAAC;IACL;IACA,MAAMA,IAAI,GAAGV,MAAM,CAACU,IAAgB;IACpC,IAAI,CAACA,IAAI,CAACC,EAAE,EAAE;MACV,OAAO;QACHZ,KAAK,EAAEW,IAAI;QACXL,MAAM,EAAEC,sBAAe,CAACC,IAAI;QAC5BJ,KAAK,EAAE;UACHK,OAAO,
|
|
1
|
+
{"version":3,"names":["_validation","require","_utils","_types","validateGroups","params","groups","input","validation","createGroupCreateValidation","Promise","all","map","group","result","safeParseAsync","success","error","createZodError","action","CmsImportAction","NONE","message","code","data","id","slug","isPluginGroup","some","g","isPlugin","CODE","canBeUpdated","UPDATE","groupWithIdExists","groupWithSlugExists","find","target","CREATE","exports"],"sources":["validateGroups.ts"],"sourcesContent":["import { CmsGroup } from \"~/types\";\nimport { createGroupCreateValidation } from \"~/crud/contentModelGroup/validation\";\nimport { createZodError } from \"@webiny/utils\";\nimport { CmsImportAction, ValidatedCmsGroupResult } from \"~/export/types\";\n\ninterface Params {\n groups: Pick<CmsGroup, \"id\" | \"slug\" | \"isPlugin\">[];\n input: Partial<CmsGroup>[];\n}\n\nexport const validateGroups = async (params: Params): Promise<ValidatedCmsGroupResult[]> => {\n const { groups, input } = params;\n\n const validation = createGroupCreateValidation();\n\n return await Promise.all(\n input.map(async (group): Promise<ValidatedCmsGroupResult> => {\n const result = await validation.safeParseAsync(group);\n if (!result.success) {\n const error = createZodError(result.error);\n return {\n group: group as CmsGroup,\n action: CmsImportAction.NONE,\n error: {\n message: error.message,\n code: error.code,\n data: error.data\n }\n };\n }\n const data = result.data as CmsGroup;\n if (!data.id) {\n return {\n group: data,\n action: CmsImportAction.NONE,\n error: {\n message: `Group is missing ID.`,\n code: \"GROUP_ID_MISSING\"\n }\n };\n }\n if (!data.slug) {\n return {\n group: data,\n action: CmsImportAction.NONE,\n error: {\n message: `Group is missing slug.`,\n code: \"GROUP_SLUG_MISSING\"\n }\n };\n }\n\n const isPluginGroup = groups.some(g => {\n if (!g.isPlugin) {\n return false;\n }\n return g.id === data.id || g.slug === data.slug;\n });\n if (isPluginGroup) {\n return {\n group: data,\n action: CmsImportAction.CODE,\n error: {\n message: `Group already exists, but it is a plugin group - cannot be updated.`,\n code: \"GROUP_IS_PLUGIN\"\n }\n };\n }\n\n const canBeUpdated = groups.some(g => {\n return g.id === data.id && g.slug === data.slug;\n });\n if (canBeUpdated) {\n return {\n group: data,\n action: CmsImportAction.UPDATE\n };\n }\n\n const groupWithIdExists = groups.some(g => g.id === data.id);\n if (groupWithIdExists) {\n return {\n group: data,\n action: CmsImportAction.NONE,\n error: {\n message: `Group with ID \"${data.id}\" already exists. Cannot update it because the slug is different.`,\n code: \"GROUP_ID_EXISTS\"\n }\n };\n }\n\n const groupWithSlugExists = groups.find(g => g.slug === data.slug);\n if (groupWithSlugExists) {\n /**\n * If group with given slug already exists, we will map the ID to the existing group.\n *\n * We will also point all models from the imported group to the existing group.\n * We will not update the existing group.\n */\n return {\n group: {\n ...data,\n id: groupWithSlugExists.id\n },\n target: data.id,\n action: CmsImportAction.NONE\n };\n }\n\n return {\n group: data,\n action: CmsImportAction.CREATE\n };\n })\n );\n};\n"],"mappings":";;;;;;AACA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAOO,MAAMG,cAAc,GAAG,MAAOC,MAAc,IAAyC;EACxF,MAAM;IAAEC,MAAM;IAAEC;EAAM,CAAC,GAAGF,MAAM;EAEhC,MAAMG,UAAU,GAAG,IAAAC,uCAA2B,EAAC,CAAC;EAEhD,OAAO,MAAMC,OAAO,CAACC,GAAG,CACpBJ,KAAK,CAACK,GAAG,CAAC,MAAOC,KAAK,IAAuC;IACzD,MAAMC,MAAM,GAAG,MAAMN,UAAU,CAACO,cAAc,CAACF,KAAK,CAAC;IACrD,IAAI,CAACC,MAAM,CAACE,OAAO,EAAE;MACjB,MAAMC,KAAK,GAAG,IAAAC,qBAAc,EAACJ,MAAM,CAACG,KAAK,CAAC;MAC1C,OAAO;QACHJ,KAAK,EAAEA,KAAiB;QACxBM,MAAM,EAAEC,sBAAe,CAACC,IAAI;QAC5BJ,KAAK,EAAE;UACHK,OAAO,EAAEL,KAAK,CAACK,OAAO;UACtBC,IAAI,EAAEN,KAAK,CAACM,IAAI;UAChBC,IAAI,EAAEP,KAAK,CAACO;QAChB;MACJ,C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iB,GAAG5B,MAAM,CAACsB,IAAI,CAACC,CAAC,IAAIA,CAAC,CAACJ,EAAE,KAAKD,IAAI,CAACC,EAAE,CAAC;IAC5D,IAAIS,iBAAiB,EAAE;MACnB,OAAO;QACHrB,KAAK,EAAEW,IAAI;QACXL,MAAM,EAAEC,sBAAe,CAACC,IAAI;QAC5BJ,KAAK,EAAE;UACHK,OAAO,EAAE,kBAAkBE,IAAI,CAACC,EAAE,mEAAmE;UACrGF,IAAI,EAAE;QACV;MACJ,CAAC;IACL;IAEA,MAAMY,mBAAmB,GAAG7B,MAAM,CAAC8B,IAAI,CAACP,CAAC,IAAIA,CAAC,CAACH,IAAI,KAAKF,IAAI,CAACE,IAAI,CAAC;IAClE,IAAIS,mBAAmB,EAAE;MACrB;AAChB;AACA;AACA;AACA;AACA;MACgB,OAAO;QACHtB,KAAK,EAAE;UACH,GAAGW,IAAI;UACPC,EAAE,EAAEU,mBAAmB,CAACV;QAC5B,CAAC;QACDY,MAAM,EAAEb,IAAI,CAACC,EAAE;QACfN,MAAM,EAAEC,sBAAe,CAACC;MAC5B,CAAC;IACL;IAEA,OAAO;MACHR,KAAK,EAAEW,IAAI;MACXL,MAAM,EAAEC,sBAAe,CAACkB;IAC5B,CAAC;EACL,CAAC,CACL,CAAC;AACL,CAAC;AAACC,OAAA,CAAAnC,cAAA,GAAAA,cAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_validation","require","_types","_utils","addCodeMessage","params","action","CmsImportAction","CODE","errors","message","code","validateModel","model","models","existingModelId","find","m","modelId","toLowerCase","existingSingularApiName","singularApiName","pluralApiName","toString","existingPluralApiName","UPDATE_KEYWORD","isPlugin","UPDATE","CREATE","NONE","data","getRelatedModels","fields","result","field","type","settings","push","templates","tpl","Array","from","Set","validateModels","groups","input","validation","createModelImportValidation","Promise","all","map","safeParseAsync","success","error","createZodError","group","g","id","target","length","targetModel","modelValidationResult","related","exports"],"sources":["validateModels.ts"],"sourcesContent":["import { createModelImportValidation } from \"~/crud/contentModel/validation\";\nimport {\n CmsImportAction,\n CmsImportError,\n HeadlessCmsImportStructureParamsDataModel,\n ValidatedCmsModel,\n ValidatedCmsModelResult\n} from \"~/export/types\";\nimport { CmsDynamicZoneTemplate, CmsGroup, CmsModel, CmsModelField } from \"~/types\";\nimport { createZodError } from \"@webiny/utils\";\n\ninterface CreateModelValidationParams {\n model: ValidatedCmsModel;\n models: CmsModel[];\n}\n\ninterface AddCodeMessageParams {\n action: CmsImportAction;\n}\n\nconst addCodeMessage = (params: AddCodeMessageParams) => {\n if (params.action !== CmsImportAction.CODE) {\n return params;\n }\n return {\n ...params,\n errors: [\n {\n message: `The model is defined via plugin and it cannot be updated.`,\n code: \"MODEL_IS_A_PLUGIN\"\n }\n ]\n };\n};\n\ninterface ValidationResult {\n errors?: CmsImportError[];\n action: CmsImportAction;\n}\n\nconst validateModel = (params: CreateModelValidationParams): ValidationResult => {\n const { model, models } = params;\n /**\n * Let's check if model values that must be unique, already exist.\n */\n const existingModelId = models.find(\n m => m.modelId.toLowerCase() === model.modelId.toLowerCase()\n );\n const existingSingularApiName = models.find(\n m =>\n m.singularApiName.toLowerCase() === model.singularApiName.toLowerCase() ||\n m.singularApiName.toLowerCase() === model.pluralApiName.toString()\n );\n const existingPluralApiName = models.find(\n m =>\n m.pluralApiName.toLowerCase() === model.pluralApiName.toLowerCase() ||\n m.pluralApiName.toLowerCase() === model.singularApiName.toString()\n );\n\n const UPDATE_KEYWORD = existingModelId?.isPlugin\n ? CmsImportAction.CODE\n : CmsImportAction.UPDATE;\n /**\n * There are few cases that we must address:\n *\n * 1. modelId, singular and plural names do not exist in any of the models\n * - this is OK, we can create the model\n */\n if (!existingModelId && !existingSingularApiName && !existingPluralApiName) {\n return {\n action: CmsImportAction.CREATE\n };\n }\n /**\n * 2. modelId, singular and plural names are a part of a single model\n * - this is OK, we can update the model\n */\n if (\n existingModelId &&\n existingSingularApiName &&\n existingPluralApiName &&\n existingModelId.modelId === existingSingularApiName.modelId &&\n existingModelId.modelId === existingPluralApiName.modelId\n ) {\n return addCodeMessage({\n action: UPDATE_KEYWORD\n });\n }\n /**\n * 3. modelId already exists, but singular and plural names do not\n * - this is OK, we can update the model\n */\n if (existingModelId && !existingSingularApiName && !existingPluralApiName) {\n return addCodeMessage({\n action: UPDATE_KEYWORD\n });\n }\n /**\n * 4. modelId already exists, but only the singular name exists.\n * - this is OK, we can update the model\n */\n if (\n existingModelId &&\n existingSingularApiName?.modelId === existingModelId.modelId &&\n !existingPluralApiName\n ) {\n return addCodeMessage({\n action: UPDATE_KEYWORD\n });\n }\n /**\n * 5. modelId already exists, but only the plural name exists.\n * - this is OK, we can update the model\n */\n if (\n existingModelId &&\n existingPluralApiName?.modelId === existingModelId.modelId &&\n !existingSingularApiName\n ) {\n return addCodeMessage({\n action: UPDATE_KEYWORD\n });\n }\n /**\n * 6. modelId already exists, but singular and plural names are in different models.\n */\n if (\n existingModelId &&\n (existingSingularApiName?.modelId !== existingModelId.modelId ||\n existingPluralApiName?.modelId !== existingModelId.modelId)\n ) {\n return {\n action: CmsImportAction.NONE,\n errors: [\n {\n message: `The model has singular or plural API names same as some other model.`,\n code: \"MODEL_API_NAMES_ERROR\"\n }\n ]\n };\n }\n\n return {\n action: CmsImportAction.NONE,\n errors: [\n {\n message: `The model cannot be imported.`,\n code: \"MODEL_IMPORT_ERROR\",\n data: {\n modelId: existingModelId?.modelId,\n singularApiName: existingSingularApiName?.modelId,\n pluralApiName: existingPluralApiName?.modelId\n }\n }\n ]\n };\n};\n\ninterface InputGroup extends Pick<CmsGroup, \"id\" | \"slug\"> {\n target: string;\n}\n\ninterface Params {\n groups: InputGroup[];\n models: CmsModel[];\n input: HeadlessCmsImportStructureParamsDataModel[];\n}\n\ninterface GetRelatedModelsParams {\n fields: CmsModelField[];\n models: CmsModel[];\n}\n\nconst getRelatedModels = (params: GetRelatedModelsParams): string[] => {\n const { fields, models } = params;\n\n const result: string[] = [];\n for (const field of fields) {\n if (field.type === \"ref\") {\n for (const model of field.settings?.models || []) {\n result.push(model.modelId);\n }\n } else if (field.type === \"object\") {\n result.push(...getRelatedModels({ fields: field.settings?.fields || [], models }));\n } else if (field.type === \"dynamicZone\") {\n const templates = (field.settings?.templates || []) as CmsDynamicZoneTemplate[];\n for (const tpl of templates) {\n result.push(\n ...getRelatedModels({\n fields: tpl.fields || [],\n models\n })\n );\n }\n }\n }\n\n return Array.from(new Set(result));\n};\n\nexport const validateModels = async (params: Params): Promise<ValidatedCmsModelResult[]> => {\n const { groups, models, input } = params;\n\n const validation = createModelImportValidation();\n\n return await Promise.all(\n input.map(async (model): Promise<ValidatedCmsModelResult> => {\n const result = await validation.safeParseAsync(model);\n if (!result.success) {\n const error = createZodError(result.error);\n return {\n model: model as ValidatedCmsModel,\n action: CmsImportAction.NONE,\n error: {\n message: error.message,\n code: error.code,\n data: error.data\n }\n };\n }\n const data = result.data as unknown as ValidatedCmsModel;\n const group = groups.find(g => g.id === data.group || g.target === data.group);\n if (!group) {\n return {\n model: data,\n action: CmsImportAction.NONE,\n error: {\n message: `The model group \"${data.group}\" does not exist.`,\n code: \"MODEL_GROUP_NOT_FOUND\"\n }\n };\n } else if (!model.fields?.length) {\n return {\n model: data,\n action: CmsImportAction.NONE,\n error: {\n message: `Model is missing fields.`,\n code: \"MODEL_FIELDS_MISSING\"\n }\n };\n }\n\n const targetModel: ValidatedCmsModel = {\n ...data,\n group: group.id\n };\n\n const modelValidationResult = validateModel({\n model: targetModel,\n models\n });\n\n if (!modelValidationResult.errors?.length) {\n return {\n model: targetModel,\n related: getRelatedModels({\n fields: targetModel.fields,\n models\n }),\n action: modelValidationResult.action\n };\n }\n return {\n model: targetModel,\n action: modelValidationResult.action,\n error: modelValidationResult.errors[0]\n };\n })\n );\n};\n"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAQA,IAAAE,MAAA,GAAAF,OAAA;AAWA,MAAMG,cA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AACmB,MAAM,EAAE2B,MAAM,EAAE;MAC9B,OAAO;QACH9C,KAAK,EAAEiB,IAAI;QACXxB,MAAM,EAAEC,sBAAe,CAACsB,IAAI;QAC5BwB,KAAK,EAAE;UACH3C,OAAO,EAAG,0BAAyB;UACnCC,IAAI,EAAE;QACV;MACJ,CAAC;IACL;IAEA,MAAMiD,WAA8B,GAAG;MACnC,GAAG9B,IAAI;MACPyB,KAAK,EAAEA,KAAK,CAACE;IACjB,CAAC;IAED,MAAMI,qBAAqB,GAAGjD,aAAa,CAAC;MACxCC,KAAK,EAAE+C,WAAW;MAClB9C;IACJ,CAAC,CAAC;IAEF,IAAI,CAAC+C,qBAAqB,CAACpD,MAAM,EAAEkD,MAAM,EAAE;MACvC,OAAO;QACH9C,KAAK,EAAE+C,WAAW;QAClBE,OAAO,EAAE/B,gBAAgB,CAAC;UACtBC,MAAM,EAAE4B,WAAW,CAAC5B,MAAM;UAC1BlB;QACJ,CAAC,CAAC;QACFR,MAAM,EAAEuD,qBAAqB,CAACvD;MAClC,CAAC;IACL;IACA,OAAO;MACHO,KAAK,EAAE+C,WAAW;MAClBtD,MAAM,EAAEuD,qBAAqB,CAACvD,MAAM;MACpC+C,KAAK,EAAEQ,qBAAqB,CAACpD,MAAM,CAAC,CAAC;IACzC,CAAC;EACL,CAAC,CACL,CAAC;AACL,CAAC;AAACsD,OAAA,CAAApB,cAAA,GAAAA,cAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_validation","require","_types","_utils","addCodeMessage","params","action","CmsImportAction","CODE","errors","message","code","validateModel","model","models","existingModelId","find","m","modelId","toLowerCase","existingSingularApiName","singularApiName","pluralApiName","toString","existingPluralApiName","UPDATE_KEYWORD","isPlugin","UPDATE","CREATE","NONE","data","getRelatedModels","fields","result","field","type","settings","push","templates","tpl","Array","from","Set","validateModels","groups","input","validation","createModelImportValidation","Promise","all","map","safeParseAsync","success","error","createZodError","group","g","id","target","length","targetModel","modelValidationResult","related","exports"],"sources":["validateModels.ts"],"sourcesContent":["import { createModelImportValidation } from \"~/crud/contentModel/validation\";\nimport {\n CmsImportAction,\n CmsImportError,\n HeadlessCmsImportStructureParamsDataModel,\n ValidatedCmsModel,\n ValidatedCmsModelResult\n} from \"~/export/types\";\nimport { CmsDynamicZoneTemplate, CmsGroup, CmsModel, CmsModelField } from \"~/types\";\nimport { createZodError } from \"@webiny/utils\";\n\ninterface CreateModelValidationParams {\n model: ValidatedCmsModel;\n models: CmsModel[];\n}\n\ninterface AddCodeMessageParams {\n action: CmsImportAction;\n}\n\nconst addCodeMessage = (params: AddCodeMessageParams) => {\n if (params.action !== CmsImportAction.CODE) {\n return params;\n }\n return {\n ...params,\n errors: [\n {\n message: `The model is defined via plugin and it cannot be updated.`,\n code: \"MODEL_IS_A_PLUGIN\"\n }\n ]\n };\n};\n\ninterface ValidationResult {\n errors?: CmsImportError[];\n action: CmsImportAction;\n}\n\nconst validateModel = (params: CreateModelValidationParams): ValidationResult => {\n const { model, models } = params;\n /**\n * Let's check if model values that must be unique, already exist.\n */\n const existingModelId = models.find(\n m => m.modelId.toLowerCase() === model.modelId.toLowerCase()\n );\n const existingSingularApiName = models.find(\n m =>\n m.singularApiName.toLowerCase() === model.singularApiName.toLowerCase() ||\n m.singularApiName.toLowerCase() === model.pluralApiName.toString()\n );\n const existingPluralApiName = models.find(\n m =>\n m.pluralApiName.toLowerCase() === model.pluralApiName.toLowerCase() ||\n m.pluralApiName.toLowerCase() === model.singularApiName.toString()\n );\n\n const UPDATE_KEYWORD = existingModelId?.isPlugin\n ? CmsImportAction.CODE\n : CmsImportAction.UPDATE;\n /**\n * There are few cases that we must address:\n *\n * 1. modelId, singular and plural names do not exist in any of the models\n * - this is OK, we can create the model\n */\n if (!existingModelId && !existingSingularApiName && !existingPluralApiName) {\n return {\n action: CmsImportAction.CREATE\n };\n }\n /**\n * 2. modelId, singular and plural names are a part of a single model\n * - this is OK, we can update the model\n */\n if (\n existingModelId &&\n existingSingularApiName &&\n existingPluralApiName &&\n existingModelId.modelId === existingSingularApiName.modelId &&\n existingModelId.modelId === existingPluralApiName.modelId\n ) {\n return addCodeMessage({\n action: UPDATE_KEYWORD\n });\n }\n /**\n * 3. modelId already exists, but singular and plural names do not\n * - this is OK, we can update the model\n */\n if (existingModelId && !existingSingularApiName && !existingPluralApiName) {\n return addCodeMessage({\n action: UPDATE_KEYWORD\n });\n }\n /**\n * 4. modelId already exists, but only the singular name exists.\n * - this is OK, we can update the model\n */\n if (\n existingModelId &&\n existingSingularApiName?.modelId === existingModelId.modelId &&\n !existingPluralApiName\n ) {\n return addCodeMessage({\n action: UPDATE_KEYWORD\n });\n }\n /**\n * 5. modelId already exists, but only the plural name exists.\n * - this is OK, we can update the model\n */\n if (\n existingModelId &&\n existingPluralApiName?.modelId === existingModelId.modelId &&\n !existingSingularApiName\n ) {\n return addCodeMessage({\n action: UPDATE_KEYWORD\n });\n }\n /**\n * 6. modelId already exists, but singular and plural names are in different models.\n */\n if (\n existingModelId &&\n (existingSingularApiName?.modelId !== existingModelId.modelId ||\n existingPluralApiName?.modelId !== existingModelId.modelId)\n ) {\n return {\n action: CmsImportAction.NONE,\n errors: [\n {\n message: `The model has singular or plural API names same as some other model.`,\n code: \"MODEL_API_NAMES_ERROR\"\n }\n ]\n };\n }\n\n return {\n action: CmsImportAction.NONE,\n errors: [\n {\n message: `The model cannot be imported.`,\n code: \"MODEL_IMPORT_ERROR\",\n data: {\n modelId: existingModelId?.modelId,\n singularApiName: existingSingularApiName?.modelId,\n pluralApiName: existingPluralApiName?.modelId\n }\n }\n ]\n };\n};\n\ninterface InputGroup extends Pick<CmsGroup, \"id\" | \"slug\"> {\n target: string;\n}\n\ninterface Params {\n groups: InputGroup[];\n models: CmsModel[];\n input: HeadlessCmsImportStructureParamsDataModel[];\n}\n\ninterface GetRelatedModelsParams {\n fields: CmsModelField[];\n models: CmsModel[];\n}\n\nconst getRelatedModels = (params: GetRelatedModelsParams): string[] => {\n const { fields, models } = params;\n\n const result: string[] = [];\n for (const field of fields) {\n if (field.type === \"ref\") {\n for (const model of field.settings?.models || []) {\n result.push(model.modelId);\n }\n } else if (field.type === \"object\") {\n result.push(...getRelatedModels({ fields: field.settings?.fields || [], models }));\n } else if (field.type === \"dynamicZone\") {\n const templates = (field.settings?.templates || []) as CmsDynamicZoneTemplate[];\n for (const tpl of templates) {\n result.push(\n ...getRelatedModels({\n fields: tpl.fields || [],\n models\n })\n );\n }\n }\n }\n\n return Array.from(new Set(result));\n};\n\nexport const validateModels = async (params: Params): Promise<ValidatedCmsModelResult[]> => {\n const { groups, models, input } = params;\n\n const validation = createModelImportValidation();\n\n return await Promise.all(\n input.map(async (model): Promise<ValidatedCmsModelResult> => {\n const result = await validation.safeParseAsync(model);\n if (!result.success) {\n const error = createZodError(result.error);\n return {\n model: model as ValidatedCmsModel,\n action: CmsImportAction.NONE,\n error: {\n message: error.message,\n code: error.code,\n data: error.data\n }\n };\n }\n const data = result.data as unknown as ValidatedCmsModel;\n const group = groups.find(g => g.id === data.group || g.target === data.group);\n if (!group) {\n return {\n model: data,\n action: CmsImportAction.NONE,\n error: {\n message: `The model group \"${data.group}\" does not exist.`,\n code: \"MODEL_GROUP_NOT_FOUND\"\n }\n };\n } else if (!model.fields?.length) {\n return {\n model: data,\n action: CmsImportAction.NONE,\n error: {\n message: `Model is missing fields.`,\n code: \"MODEL_FIELDS_MISSING\"\n }\n };\n }\n\n const targetModel: ValidatedCmsModel = {\n ...data,\n group: group.id\n };\n\n const modelValidationResult = validateModel({\n model: targetModel,\n models\n });\n\n if (!modelValidationResult.errors?.length) {\n return {\n model: targetModel,\n related: getRelatedModels({\n fields: targetModel.fields,\n models\n }),\n action: modelValidationResult.action\n };\n }\n return {\n model: targetModel,\n action: modelValidationResult.action,\n error: modelValidationResult.errors[0]\n };\n })\n );\n};\n"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAQA,IAAAE,MAAA,GAAAF,OAAA;AAW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AACE,KAAK,CAACmB,MAAM,EAAE2B,MAAM,EAAE;MAC9B,OAAO;QACH9C,KAAK,EAAEiB,IAAI;QACXxB,MAAM,EAAEC,sBAAe,CAACsB,IAAI;QAC5BwB,KAAK,EAAE;UACH3C,OAAO,EAAE,0BAA0B;UACnCC,IAAI,EAAE;QACV;MACJ,CAAC;IACL;IAEA,MAAMiD,WAA8B,GAAG;MACnC,GAAG9B,IAAI;MACPyB,KAAK,EAAEA,KAAK,CAACE;IACjB,CAAC;IAED,MAAMI,qBAAqB,GAAGjD,aAAa,CAAC;MACxCC,KAAK,EAAE+C,WAAW;MAClB9C;IACJ,CAAC,CAAC;IAEF,IAAI,CAAC+C,qBAAqB,CAACpD,MAAM,EAAEkD,MAAM,EAAE;MACvC,OAAO;QACH9C,KAAK,EAAE+C,WAAW;QAClBE,OAAO,EAAE/B,gBAAgB,CAAC;UACtBC,MAAM,EAAE4B,WAAW,CAAC5B,MAAM;UAC1BlB;QACJ,CAAC,CAAC;QACFR,MAAM,EAAEuD,qBAAqB,CAACvD;MAClC,CAAC;IACL;IACA,OAAO;MACHO,KAAK,EAAE+C,WAAW;MAClBtD,MAAM,EAAEuD,qBAAqB,CAACvD,MAAM;MACpC+C,KAAK,EAAEQ,qBAAqB,CAACpD,MAAM,CAAC,CAAC;IACzC,CAAC;EACL,CAAC,CACL,CAAC;AACL,CAAC;AAACsD,OAAA,CAAApB,cAAA,GAAAA,cAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_plugins","require","_handlerGraphql","_handler","plugin","createCmsGraphQLSchemaPlugin","typeDefs","resolvers","Query","exportStructure","_","args","context","result","cms","export","structure","models","Response","JSON","stringify","ex","ErrorResponse","Mutation","validateImportStructure","importing","validate","data","importStructure","name","createExportGraphQL","ContextPlugin","MANAGE","plugins","register","exports"],"sources":["index.ts"],"sourcesContent":["import { createCmsGraphQLSchemaPlugin } from \"~/plugins\";\nimport { ErrorResponse, Response } from \"@webiny/handler-graphql\";\nimport { ContextPlugin } from \"@webiny/handler\";\nimport { CmsContext } from \"~/types\";\n\nconst plugin = createCmsGraphQLSchemaPlugin({\n typeDefs: /* GraphQL */ `\n type CmsExportStructureResponse {\n data: String\n error: CmsError\n }\n\n input CmsImportStructureGroupInput {\n id: ID!\n name: String!\n slug: String\n description: String\n icon: String!\n }\n\n input CmsImportStructureModelInput {\n name: String!\n singularApiName: String!\n pluralApiName: String!\n modelId: String!\n group: String!\n icon: String\n description: String\n layout: [[ID!]!]!\n fields: [CmsContentModelFieldInput!]!\n titleFieldId: String!\n descriptionFieldId: String\n imageFieldId: String\n tags: [String!]\n }\n\n enum CmsImportGroupStructureAction {\n create\n update\n code\n none\n }\n\n enum CmsImportModelStructureAction {\n create\n update\n code\n none\n }\n\n input CmsImportStructureInput {\n groups: [CmsImportStructureGroupInput!]!\n models: [CmsImportStructureModelInput!]!\n }\n\n type CmsImportValidateResponseDataGroupResultItem {\n id: String\n name: String\n }\n\n type CmsImportValidateResponseDataGroupResult {\n group: CmsImportValidateResponseDataGroupResultItem!\n error: CmsError\n action: CmsImportGroupStructureAction\n }\n\n type CmsImportValidateResponseDataModelResultItem {\n modelId: String\n name: String\n group: String\n }\n\n type CmsImportValidateResponseDataModelResult {\n model: CmsImportValidateResponseDataModelResultItem!\n related: [String!]\n error: CmsError\n action: CmsImportModelStructureAction\n }\n\n type CmsImportValidateResponseData {\n groups: [CmsImportValidateResponseDataGroupResult!]!\n models: [CmsImportValidateResponseDataModelResult!]!\n message: String!\n }\n\n type CmsImportValidateResponse {\n data: CmsImportValidateResponseData\n error: CmsError\n }\n\n type CmsImportStructureResponseDataGroupResultItem {\n id: String!\n name: String!\n }\n type CmsImportStructureResponseDataGroupResult {\n group: CmsImportStructureResponseDataGroupResultItem!\n error: CmsError\n action: CmsImportGroupStructureAction\n imported: Boolean\n }\n\n type CmsImportStructureResponseDataResultItem {\n modelId: String!\n name: String!\n group: String!\n }\n\n type CmsImportStructureResponseDataModelResult {\n model: CmsImportStructureResponseDataResultItem!\n related: [String!]\n error: CmsError\n action: CmsImportModelStructureAction\n imported: Boolean\n }\n\n type CmsImportStructureResponseData {\n groups: [CmsImportStructureResponseDataGroupResult!]!\n models: [CmsImportStructureResponseDataModelResult!]!\n message: String\n }\n\n type CmsImportStructureResponse {\n data: CmsImportStructureResponseData\n error: CmsError\n }\n\n extend type Query {\n exportStructure(models: [String!]): CmsExportStructureResponse!\n }\n\n extend type Mutation {\n validateImportStructure(data: CmsImportStructureInput!): CmsImportValidateResponse!\n importStructure(data: CmsImportStructureInput!): CmsImportStructureResponse!\n }\n `,\n resolvers: {\n Query: {\n exportStructure: async (_, args, context) => {\n try {\n const result = await context.cms.export.structure({\n models: args.models\n });\n return new Response(JSON.stringify(result));\n } catch (ex) {\n return new ErrorResponse(ex);\n }\n }\n },\n Mutation: {\n validateImportStructure: async (_, args, context) => {\n try {\n const result = await context.cms.importing.validate({\n data: args.data\n });\n return new Response(result);\n } catch (ex) {\n return new ErrorResponse(ex);\n }\n },\n importStructure: async (_, args, context) => {\n try {\n const result = await context.cms.importing.structure({\n data: args.data\n });\n return new Response(result);\n } catch (ex) {\n return new ErrorResponse(ex);\n }\n }\n }\n }\n});\nplugin.name = \"headless-cms.graphql.export\";\n\nexport const createExportGraphQL = () => {\n return new ContextPlugin<CmsContext>(async context => {\n if (!context.cms.MANAGE) {\n return;\n }\n context.plugins.register(plugin);\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,eAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAGA,MAAMG,MAAM,GAAG,IAAAC,qCAA4B,EAAC;EACxCC,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"names":["_plugins","require","_handlerGraphql","_handler","plugin","createCmsGraphQLSchemaPlugin","typeDefs","resolvers","Query","exportStructure","_","args","context","result","cms","export","structure","models","Response","JSON","stringify","ex","ErrorResponse","Mutation","validateImportStructure","importing","validate","data","importStructure","name","createExportGraphQL","ContextPlugin","MANAGE","plugins","register","exports"],"sources":["index.ts"],"sourcesContent":["import { createCmsGraphQLSchemaPlugin } from \"~/plugins\";\nimport { ErrorResponse, Response } from \"@webiny/handler-graphql\";\nimport { ContextPlugin } from \"@webiny/handler\";\nimport { CmsContext } from \"~/types\";\n\nconst plugin = createCmsGraphQLSchemaPlugin({\n typeDefs: /* GraphQL */ `\n type CmsExportStructureResponse {\n data: String\n error: CmsError\n }\n\n input CmsImportStructureGroupInput {\n id: ID!\n name: String!\n slug: String\n description: String\n icon: String!\n }\n\n input CmsImportStructureModelInput {\n name: String!\n singularApiName: String!\n pluralApiName: String!\n modelId: String!\n group: String!\n icon: String\n description: String\n layout: [[ID!]!]!\n fields: [CmsContentModelFieldInput!]!\n titleFieldId: String!\n descriptionFieldId: String\n imageFieldId: String\n tags: [String!]\n }\n\n enum CmsImportGroupStructureAction {\n create\n update\n code\n none\n }\n\n enum CmsImportModelStructureAction {\n create\n update\n code\n none\n }\n\n input CmsImportStructureInput {\n groups: [CmsImportStructureGroupInput!]!\n models: [CmsImportStructureModelInput!]!\n }\n\n type CmsImportValidateResponseDataGroupResultItem {\n id: String\n name: String\n }\n\n type CmsImportValidateResponseDataGroupResult {\n group: CmsImportValidateResponseDataGroupResultItem!\n error: CmsError\n action: CmsImportGroupStructureAction\n }\n\n type CmsImportValidateResponseDataModelResultItem {\n modelId: String\n name: String\n group: String\n }\n\n type CmsImportValidateResponseDataModelResult {\n model: CmsImportValidateResponseDataModelResultItem!\n related: [String!]\n error: CmsError\n action: CmsImportModelStructureAction\n }\n\n type CmsImportValidateResponseData {\n groups: [CmsImportValidateResponseDataGroupResult!]!\n models: [CmsImportValidateResponseDataModelResult!]!\n message: String!\n }\n\n type CmsImportValidateResponse {\n data: CmsImportValidateResponseData\n error: CmsError\n }\n\n type CmsImportStructureResponseDataGroupResultItem {\n id: String!\n name: String!\n }\n type CmsImportStructureResponseDataGroupResult {\n group: CmsImportStructureResponseDataGroupResultItem!\n error: CmsError\n action: CmsImportGroupStructureAction\n imported: Boolean\n }\n\n type CmsImportStructureResponseDataResultItem {\n modelId: String!\n name: String!\n group: String!\n }\n\n type CmsImportStructureResponseDataModelResult {\n model: CmsImportStructureResponseDataResultItem!\n related: [String!]\n error: CmsError\n action: CmsImportModelStructureAction\n imported: Boolean\n }\n\n type CmsImportStructureResponseData {\n groups: [CmsImportStructureResponseDataGroupResult!]!\n models: [CmsImportStructureResponseDataModelResult!]!\n message: String\n }\n\n type CmsImportStructureResponse {\n data: CmsImportStructureResponseData\n error: CmsError\n }\n\n extend type Query {\n exportStructure(models: [String!]): CmsExportStructureResponse!\n }\n\n extend type Mutation {\n validateImportStructure(data: CmsImportStructureInput!): CmsImportValidateResponse!\n importStructure(data: CmsImportStructureInput!): CmsImportStructureResponse!\n }\n `,\n resolvers: {\n Query: {\n exportStructure: async (_, args, context) => {\n try {\n const result = await context.cms.export.structure({\n models: args.models\n });\n return new Response(JSON.stringify(result));\n } catch (ex) {\n return new ErrorResponse(ex);\n }\n }\n },\n Mutation: {\n validateImportStructure: async (_, args, context) => {\n try {\n const result = await context.cms.importing.validate({\n data: args.data\n });\n return new Response(result);\n } catch (ex) {\n return new ErrorResponse(ex);\n }\n },\n importStructure: async (_, args, context) => {\n try {\n const result = await context.cms.importing.structure({\n data: args.data\n });\n return new Response(result);\n } catch (ex) {\n return new ErrorResponse(ex);\n }\n }\n }\n }\n});\nplugin.name = \"headless-cms.graphql.export\";\n\nexport const createExportGraphQL = () => {\n return new ContextPlugin<CmsContext>(async context => {\n if (!context.cms.MANAGE) {\n return;\n }\n context.plugins.register(plugin);\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,eAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAGA,MAAMG,MAAM,GAAG,IAAAC,qCAA4B,EAAC;EACxCC,QAAQ,EAAE,aAAc;AAC5B;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;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;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;AACA,KAAK;EACDC,SAAS,EAAE;IACPC,KAAK,EAAE;MACHC,eAAe,EAAE,MAAAA,CAAOC,CAAC,EAAEC,IAAI,EAAEC,OAAO,KAAK;QACzC,IAAI;UACA,MAAMC,MAAM,GAAG,MAAMD,OAAO,CAACE,GAAG,CAACC,MAAM,CAACC,SAAS,CAAC;YAC9CC,MAAM,EAAEN,IAAI,CAACM;UACjB,CAAC,CAAC;UACF,OAAO,IAAIC,wBAAQ,CAACC,IAAI,CAACC,SAAS,CAACP,MAAM,CAAC,CAAC;QAC/C,CAAC,CAAC,OAAOQ,EAAE,EAAE;UACT,OAAO,IAAIC,6BAAa,CAACD,EAAE,CAAC;QAChC;MACJ;IACJ,CAAC;IACDE,QAAQ,EAAE;MACNC,uBAAuB,EAAE,MAAAA,CAAOd,CAAC,EAAEC,IAAI,EAAEC,OAAO,KAAK;QACjD,IAAI;UACA,MAAMC,MAAM,GAAG,MAAMD,OAAO,CAACE,GAAG,CAACW,SAAS,CAACC,QAAQ,CAAC;YAChDC,IAAI,EAAEhB,IAAI,CAACgB;UACf,CAAC,CAAC;UACF,OAAO,IAAIT,wBAAQ,CAACL,MAAM,CAAC;QAC/B,CAAC,CAAC,OAAOQ,EAAE,EAAE;UACT,OAAO,IAAIC,6BAAa,CAACD,EAAE,CAAC;QAChC;MACJ,CAAC;MACDO,eAAe,EAAE,MAAAA,CAAOlB,CAAC,EAAEC,IAAI,EAAEC,OAAO,KAAK;QACzC,IAAI;UACA,MAAMC,MAAM,GAAG,MAAMD,OAAO,CAACE,GAAG,CAACW,SAAS,CAACT,SAAS,CAAC;YACjDW,IAAI,EAAEhB,IAAI,CAACgB;UACf,CAAC,CAAC;UACF,OAAO,IAAIT,wBAAQ,CAACL,MAAM,CAAC;QAC/B,CAAC,CAAC,OAAOQ,EAAE,EAAE;UACT,OAAO,IAAIC,6BAAa,CAACD,EAAE,CAAC;QAChC;MACJ;IACJ;EACJ;AACJ,CAAC,CAAC;AACFjB,MAAM,CAACyB,IAAI,GAAG,6BAA6B;AAEpC,MAAMC,mBAAmB,GAAGA,CAAA,KAAM;EACrC,OAAO,IAAIC,sBAAa,CAAa,MAAMnB,OAAO,IAAI;IAClD,IAAI,CAACA,OAAO,CAACE,GAAG,CAACkB,MAAM,EAAE;MACrB;IACJ;IACApB,OAAO,CAACqB,OAAO,CAACC,QAAQ,CAAC9B,MAAM,CAAC;EACpC,CAAC,CAAC;AACN,CAAC;AAAC+B,OAAA,CAAAL,mBAAA,GAAAA,mBAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_error","_interopRequireDefault","require","_CmsModelFieldConverterPlugin","CmsModelDynamicZoneFieldConverterPlugin","CmsModelFieldConverterPlugin","name","getFieldType","getTemplates","field","settings","templates","convertToStorage","params","value","converterCollection","length","multipleValues","Array","isArray","storageId","map","item","processToStorage","processedValue","undefined","templateId","_templateId","template","find","t","id","fields","reduce","values","converter","getConverter","type","converted","fieldId","Object","assign","convertFromStorage","arrayValue","processFromStorage","WebinyError","exports"],"sources":["CmsModelDynamicZoneFieldConverterPlugin.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport {\n CmsModelFieldConverterPlugin,\n ConvertParams\n} from \"~/plugins/CmsModelFieldConverterPlugin\";\nimport { CmsDynamicZoneTemplate, CmsEntryValues, CmsModelDynamicZoneField } from \"~/types\";\nimport { ConverterCollection } from \"~/utils/converters/ConverterCollection\";\nimport { GenericRecord } from \"@webiny/api/types\";\n\ntype DynamicZoneValue = GenericRecord<string>;\n\ninterface ProcessValue {\n templates: CmsDynamicZoneTemplate[];\n value: DynamicZoneValue | null;\n converterCollection: ConverterCollection;\n}\n\nexport class CmsModelDynamicZoneFieldConverterPlugin extends CmsModelFieldConverterPlugin {\n public override name = \"cms.field.converter.dynamicZone\";\n\n public override getFieldType(): string {\n return \"dynamicZone\";\n }\n\n private getTemplates(field: CmsModelDynamicZoneField): CmsDynamicZoneTemplate[] {\n return field.settings?.templates || [];\n }\n\n public override convertToStorage(\n params: ConvertParams<CmsModelDynamicZoneField>\n ): CmsEntryValues {\n const { field, value, converterCollection } = params;\n\n const templates = this.getTemplates(field);\n\n if (templates.length === 0) {\n return {};\n }\n\n if (field.multipleValues) {\n if (Array.isArray(value)) {\n return {\n [field.storageId]: value.map(item => {\n return this.processToStorage({\n templates,\n converterCollection,\n value: item\n });\n })\n };\n }\n\n // If a multi-value dynamic zone receives anything other than an array, ignore the value.\n return {};\n }\n\n // If a single-value dynamic zone receives an array, ignore the value.\n if (Array.isArray(value)) {\n return {};\n }\n\n const processedValue = this.processToStorage({\n templates,\n converterCollection,\n value\n });\n\n return {\n [field.storageId]: processedValue\n };\n }\n\n private processToStorage(params: ProcessValue) {\n const { templates, converterCollection } = params;\n const { value } = params;\n if (value === null || value === undefined) {\n return undefined;\n }\n\n const templateId = value._templateId;\n const template = templates.find(t => {\n return templateId === t.id;\n });\n\n if (!template) {\n return undefined;\n }\n\n return template.fields.reduce<GenericRecord<string>>(\n (values, field) => {\n const converter = converterCollection.getConverter(field.type);\n const converted = converter.convertToStorage({\n field,\n value: value ? value[field.fieldId] : undefined\n });\n Object.assign(values, converted);\n return values;\n },\n {\n _templateId: template.id\n }\n );\n }\n\n public override convertFromStorage(\n params: ConvertParams<CmsModelDynamicZoneField>\n ): CmsEntryValues {\n const { field, value, converterCollection } = params;\n\n const templates = this.getTemplates(field);\n\n if (templates.length === 0) {\n return {};\n }\n\n if (field.multipleValues) {\n const arrayValue = Array.isArray(value) ? value : [];\n\n return {\n [field.fieldId]: arrayValue.map(item => {\n return this.processFromStorage({\n templates,\n converterCollection,\n value: item\n });\n })\n };\n }\n\n if (Array.isArray(value)) {\n throw new WebinyError(\n `Dynamic zone field \"${field.fieldId}\" is expecting a non-array value.`,\n \"DYNAMIC_ZONE_EXPECTING_NON_ARRAY_VALUE\",\n {\n field,\n value\n }\n );\n }\n\n const processedValue = this.processFromStorage({\n templates,\n converterCollection,\n value\n });\n\n return {\n [field.fieldId]: processedValue\n };\n }\n\n private processFromStorage(params: ProcessValue) {\n const { templates, value, converterCollection } = params;\n if (value === null || value === undefined) {\n return undefined;\n }\n\n const { _templateId } = value;\n\n const template = templates.find(t => t.id === _templateId);\n if (!template) {\n throw new WebinyError(\n \"Unknown template - converting from storage.\",\n \"UNKNOWN_TEMPLATE\",\n {\n templateId: _templateId\n }\n );\n }\n\n return template.fields.reduce<GenericRecord<string>>(\n (values, field) => {\n const converter = converterCollection.getConverter(field.type);\n const converted = converter.convertFromStorage({\n field,\n value: value[field.storageId]\n });\n Object.assign(values, converted);\n return values;\n },\n {\n _templateId: template.id\n }\n );\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,6BAAA,GAAAD,OAAA;AAgBO,MAAME,uCAAuC,SAASC,0DAA4B,CAAC;EACtEC,IAAI,GAAG,iCAAiC;EAExCC,YAAYA,CAAA,EAAW;IACnC,OAAO,aAAa;EACxB;EAEQC,YAAYA,CAACC,KAA+B,EAA4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AAC;MAChC,OAAOJ,MAAM;IACjB,CAAC,EACD;MACIP,WAAW,EAAEC,QAAQ,CAACG;IAC1B,CACJ,CAAC;EACL;AACJ;AAACe,OAAA,CAAA1C,uCAAA,GAAAA,uCAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_CmsModelFieldConverterPlugin","CmsModelDynamicZoneFieldConverterPlugin","CmsModelFieldConverterPlugin","name","getFieldType","getTemplates","field","settings","templates","convertToStorage","params","value","converterCollection","length","multipleValues","Array","isArray","storageId","map","item","processToStorage","processedValue","undefined","templateId","_templateId","template","find","t","id","fields","reduce","values","converter","getConverter","type","converted","fieldId","Object","assign","convertFromStorage","arrayValue","processFromStorage","WebinyError","exports"],"sources":["CmsModelDynamicZoneFieldConverterPlugin.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport {\n CmsModelFieldConverterPlugin,\n ConvertParams\n} from \"~/plugins/CmsModelFieldConverterPlugin\";\nimport { CmsDynamicZoneTemplate, CmsEntryValues, CmsModelDynamicZoneField } from \"~/types\";\nimport { ConverterCollection } from \"~/utils/converters/ConverterCollection\";\nimport { GenericRecord } from \"@webiny/api/types\";\n\ntype DynamicZoneValue = GenericRecord<string>;\n\ninterface ProcessValue {\n templates: CmsDynamicZoneTemplate[];\n value: DynamicZoneValue | null;\n converterCollection: ConverterCollection;\n}\n\nexport class CmsModelDynamicZoneFieldConverterPlugin extends CmsModelFieldConverterPlugin {\n public override name = \"cms.field.converter.dynamicZone\";\n\n public override getFieldType(): string {\n return \"dynamicZone\";\n }\n\n private getTemplates(field: CmsModelDynamicZoneField): CmsDynamicZoneTemplate[] {\n return field.settings?.templates || [];\n }\n\n public override convertToStorage(\n params: ConvertParams<CmsModelDynamicZoneField>\n ): CmsEntryValues {\n const { field, value, converterCollection } = params;\n\n const templates = this.getTemplates(field);\n\n if (templates.length === 0) {\n return {};\n }\n\n if (field.multipleValues) {\n if (Array.isArray(value)) {\n return {\n [field.storageId]: value.map(item => {\n return this.processToStorage({\n templates,\n converterCollection,\n value: item\n });\n })\n };\n }\n\n // If a multi-value dynamic zone receives anything other than an array, ignore the value.\n return {};\n }\n\n // If a single-value dynamic zone receives an array, ignore the value.\n if (Array.isArray(value)) {\n return {};\n }\n\n const processedValue = this.processToStorage({\n templates,\n converterCollection,\n value\n });\n\n return {\n [field.storageId]: processedValue\n };\n }\n\n private processToStorage(params: ProcessValue) {\n const { templates, converterCollection } = params;\n const { value } = params;\n if (value === null || value === undefined) {\n return undefined;\n }\n\n const templateId = value._templateId;\n const template = templates.find(t => {\n return templateId === t.id;\n });\n\n if (!template) {\n return undefined;\n }\n\n return template.fields.reduce<GenericRecord<string>>(\n (values, field) => {\n const converter = converterCollection.getConverter(field.type);\n const converted = converter.convertToStorage({\n field,\n value: value ? value[field.fieldId] : undefined\n });\n Object.assign(values, converted);\n return values;\n },\n {\n _templateId: template.id\n }\n );\n }\n\n public override convertFromStorage(\n params: ConvertParams<CmsModelDynamicZoneField>\n ): CmsEntryValues {\n const { field, value, converterCollection } = params;\n\n const templates = this.getTemplates(field);\n\n if (templates.length === 0) {\n return {};\n }\n\n if (field.multipleValues) {\n const arrayValue = Array.isArray(value) ? value : [];\n\n return {\n [field.fieldId]: arrayValue.map(item => {\n return this.processFromStorage({\n templates,\n converterCollection,\n value: item\n });\n })\n };\n }\n\n if (Array.isArray(value)) {\n throw new WebinyError(\n `Dynamic zone field \"${field.fieldId}\" is expecting a non-array value.`,\n \"DYNAMIC_ZONE_EXPECTING_NON_ARRAY_VALUE\",\n {\n field,\n value\n }\n );\n }\n\n const processedValue = this.processFromStorage({\n templates,\n converterCollection,\n value\n });\n\n return {\n [field.fieldId]: processedValue\n };\n }\n\n private processFromStorage(params: ProcessValue) {\n const { templates, value, converterCollection } = params;\n if (value === null || value === undefined) {\n return undefined;\n }\n\n const { _templateId } = value;\n\n const template = templates.find(t => t.id === _templateId);\n if (!template) {\n throw new WebinyError(\n \"Unknown template - converting from storage.\",\n \"UNKNOWN_TEMPLATE\",\n {\n templateId: _templateId\n }\n );\n }\n\n return template.fields.reduce<GenericRecord<string>>(\n (values, field) => {\n const converter = converterCollection.getConverter(field.type);\n const converted = converter.convertFromStorage({\n field,\n value: value[field.storageId]\n });\n Object.assign(values, converted);\n return values;\n },\n {\n _templateId: template.id\n }\n );\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,6BAAA,GAAAD,OAAA;AAgBO,MAAME,uCAAuC,SAASC,0DAA4B,CAAC;EACtEC,IAAI,GAAG,iCAAiC;EAExCC,YAAYA,CAAA,EAAW;IACnC,OAAO,aAAa;EACxB;EAEQC,YAAYA,CAACC,KAA+B,EAA4B;IAC5E,OAAOA,KAAK,CAACC,QAAQ,EAAEC,SAAS,IAAI,EAAE;EAC1C;EAEgBC,gBAAgBA,CAC5BC,MAA+C,EACjC;IACd,MAAM;MAAEJ,KAAK;MAAEK,KAAK;MAAEC;IAAoB,CAAC,GAAGF,MAAM;IAEpD,MAAMF,SAAS,GAAG,IAAI,CAACH,YAAY,CAACC,KAAK,CAAC;IAE1C,IAAIE,SAAS,CAACK,MAAM,KAAK,CAAC,EAAE;MACxB,OAAO,CAAC,CAAC;IACb;IAEA,IAAIP,KAAK,CAACQ,cAAc,EAAE;MACtB,IAAIC,KAAK,CAACC,OAAO,CAACL,KAAK,CAAC,EAAE;QACtB,OAAO;UACH,CAACL,KAAK,CAACW,SAAS,GAAGN,KAAK,CAACO,GAAG,CAACC,IAAI,IAAI;YACjC,OAAO,IAAI,CAACC,gBAAgB,CAAC;cACzBZ,SAAS;cACTI,mBAAmB;cACnBD,KAAK,EAAEQ;YACX,CAAC,CAAC;UACN,CAAC;QACL,CAAC;MACL;;MAEA;MACA,OAAO,CAAC,CAAC;IACb;;IAEA;IACA,IAAIJ,KAAK,CAACC,OAAO,CAACL,KAAK,CAAC,EAAE;MACtB,OAAO,CAAC,CAAC;IACb;IAEA,MAAMU,cA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,MAAM,IAAIiB,cAAW,CACjB,6CAA6C,EAC7C,kBAAkB,EAClB;QACInB,UAAU,EAAEC;MAChB,CACJ,CAAC;IACL;IAEA,OAAOC,QAAQ,CAACI,MAAM,CAACC,MAAM,CACzB,CAACC,MAAM,EAAEzB,KAAK,KAAK;MACf,MAAM0B,SAAS,GAAGpB,mBAAmB,CAACqB,YAAY,CAAC3B,KAAK,CAAC4B,IAAI,CAAC;MAC9D,MAAMC,SAAS,GAAGH,SAAS,CAACO,kBAAkB,CAAC;QAC3CjC,KAAK;QACLK,KAAK,EAAEA,KAAK,CAACL,KAAK,CAACW,SAAS;MAChC,CAAC,CAAC;MACFoB,MAAM,CAACC,MAAM,CAACP,MAAM,EAAEI,SAAS,CAAC;MAChC,OAAOJ,MAAM;IACjB,CAAC,EACD;MACIP,WAAW,EAAEC,QAAQ,CAACG;IAC1B,CACJ,CAAC;EACL;AACJ;AAACe,OAAA,CAAA1C,uCAAA,GAAAA,uCAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_apiSecurity","require","checkEndpointAccess","context","permission","security","getPermission","cms","type","NotAuthorizedError","data","reason","exports"],"sources":["checkEndpointAccess.ts"],"sourcesContent":["import { CmsContext } from \"~/types\";\nimport { NotAuthorizedError } from \"@webiny/api-security\";\n\nexport const 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"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AAEO,MAAMC,mBAAmB,GAAG,MAAOC,OAAmB,IAAoB;EAC7E,MAAMC,UAAU,GAAG,MAAMD,OAAO,CAACE,QAAQ,CAACC,aAAa,
|
|
1
|
+
{"version":3,"names":["_apiSecurity","require","checkEndpointAccess","context","permission","security","getPermission","cms","type","NotAuthorizedError","data","reason","exports"],"sources":["checkEndpointAccess.ts"],"sourcesContent":["import { CmsContext } from \"~/types\";\nimport { NotAuthorizedError } from \"@webiny/api-security\";\n\nexport const 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"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AAEO,MAAMC,mBAAmB,GAAG,MAAOC,OAAmB,IAAoB;EAC7E,MAAMC,UAAU,GAAG,MAAMD,OAAO,CAACE,QAAQ,CAACC,aAAa,CAAC,gBAAgBH,OAAO,CAACI,GAAG,CAACC,IAAI,EAAE,CAAC;EAC3F,IAAI,CAACJ,UAAU,EAAE;IACb,MAAM,IAAIK,+BAAkB,CAAC;MACzBC,IAAI,EAAE;QACFC,MAAM,EAAE,0BAA0BR,OAAO,CAACI,GAAG,CAACC,IAAI;MACtD;IACJ,CAAC,CAAC;EACN;AACJ,CAAC;AAACI,OAAA,CAAAV,mBAAA,GAAAA,mBAAA","ignoreList":[]}
|
|
@@ -23,7 +23,12 @@ const generateSchema = async params => {
|
|
|
23
23
|
throw ex;
|
|
24
24
|
}
|
|
25
25
|
context.plugins.register(generatedSchemaPlugins);
|
|
26
|
-
const schemaPlugins = context.plugins.byType(_plugins.CmsGraphQLSchemaPlugin.type)
|
|
26
|
+
const schemaPlugins = context.plugins.byType(_plugins.CmsGraphQLSchemaPlugin.type).filter(pl => {
|
|
27
|
+
if (typeof pl.isApplicable === "function") {
|
|
28
|
+
return pl.isApplicable(context);
|
|
29
|
+
}
|
|
30
|
+
return true;
|
|
31
|
+
});
|
|
27
32
|
return (0, _createExecutableSchema.createExecutableSchema)({
|
|
28
33
|
plugins: schemaPlugins
|
|
29
34
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_buildSchemaPlugins","require","_createExecutableSchema","_plugins","generateSchema","params","context","models","generatedSchemaPlugins","buildSchemaPlugins","ex","console","log","plugins","register","schemaPlugins","byType","CmsGraphQLSchemaPlugin","type","createExecutableSchema","exports"],"sources":["generateSchema.ts"],"sourcesContent":["import { CmsContext, CmsModel } from \"~/types\";\nimport { buildSchemaPlugins } from \"./buildSchemaPlugins\";\nimport { createExecutableSchema } from \"./createExecutableSchema\";\nimport { GraphQLSchema } from \"graphql/type\";\nimport { CmsGraphQLSchemaPlugin, ICmsGraphQLSchemaPlugin } from \"~/plugins\";\n\ninterface GenerateSchemaParams {\n context: CmsContext;\n models: CmsModel[];\n}\nexport const generateSchema = async (params: GenerateSchemaParams): Promise<GraphQLSchema> => {\n const { context, models } = params;\n\n let generatedSchemaPlugins: ICmsGraphQLSchemaPlugin[] = [];\n try {\n generatedSchemaPlugins = await buildSchemaPlugins({ context, models });\n } catch (ex) {\n console.log(`Error while building schema plugins.`);\n throw ex;\n }\n\n context.plugins.register(generatedSchemaPlugins);\n\n const schemaPlugins = context.plugins.byType<ICmsGraphQLSchemaPlugin>(\n
|
|
1
|
+
{"version":3,"names":["_buildSchemaPlugins","require","_createExecutableSchema","_plugins","generateSchema","params","context","models","generatedSchemaPlugins","buildSchemaPlugins","ex","console","log","plugins","register","schemaPlugins","byType","CmsGraphQLSchemaPlugin","type","filter","pl","isApplicable","createExecutableSchema","exports"],"sources":["generateSchema.ts"],"sourcesContent":["import { CmsContext, CmsModel } from \"~/types\";\nimport { buildSchemaPlugins } from \"./buildSchemaPlugins\";\nimport { createExecutableSchema } from \"./createExecutableSchema\";\nimport { GraphQLSchema } from \"graphql/type\";\nimport { CmsGraphQLSchemaPlugin, ICmsGraphQLSchemaPlugin } from \"~/plugins\";\n\ninterface GenerateSchemaParams {\n context: CmsContext;\n models: CmsModel[];\n}\nexport const generateSchema = async (params: GenerateSchemaParams): Promise<GraphQLSchema> => {\n const { context, models } = params;\n\n let generatedSchemaPlugins: ICmsGraphQLSchemaPlugin[] = [];\n try {\n generatedSchemaPlugins = await buildSchemaPlugins({ context, models });\n } catch (ex) {\n console.log(`Error while building schema plugins.`);\n throw ex;\n }\n\n context.plugins.register(generatedSchemaPlugins);\n\n const schemaPlugins = context.plugins\n .byType<ICmsGraphQLSchemaPlugin>(CmsGraphQLSchemaPlugin.type)\n .filter(pl => {\n if (typeof pl.isApplicable === \"function\") {\n return pl.isApplicable(context);\n }\n return true;\n });\n\n return createExecutableSchema({\n plugins: schemaPlugins\n });\n};\n"],"mappings":";;;;;;AACA,IAAAA,mBAAA,GAAAC,OAAA;AACA,IAAAC,uBAAA,GAAAD,OAAA;AAEA,IAAAE,QAAA,GAAAF,OAAA;AAMO,MAAMG,cAAc,GAAG,MAAOC,MAA4B,IAA6B;EAC1F,MAAM;IAAEC,OAAO;IAAEC;EAAO,CAAC,GAAGF,MAAM;EAElC,IAAIG,sBAAiD,GAAG,EAAE;EAC1D,IAAI;IACAA,sBAAsB,GAAG,MAAM,IAAAC,sCAAkB,EAAC;MAAEH,OAAO;MAAEC;IAAO,CAAC,CAAC;EAC1E,CAAC,CAAC,OAAOG,EAAE,EAAE;IACTC,OAAO,CAACC,GAAG,CAAC,sCAAsC,CAAC;IACnD,MAAMF,EAAE;EACZ;EAEAJ,OAAO,CAACO,OAAO,CAACC,QAAQ,CAACN,sBAAsB,CAAC;EAEhD,MAAMO,aAAa,GAAGT,OAAO,CAACO,OAAO,CAChCG,MAAM,CAA0BC,+BAAsB,CAACC,IAAI,CAAC,CAC5DC,MAAM,CAACC,EAAE,IAAI;IACV,IAAI,OAAOA,EAAE,CAACC,YAAY,KAAK,UAAU,EAAE;MACvC,OAAOD,EAAE,CAACC,YAAY,CAACf,OAAO,CAAC;IACnC;IACA,OAAO,IAAI;EACf,CAAC,CAAC;EAEN,OAAO,IAAAgB,8CAAsB,EAAC;IAC1BT,OAAO,EAAEE;EACb,CAAC,CAAC;AACN,CAAC;AAACQ,OAAA,CAAAnB,cAAA,GAAAA,cAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["generateCacheId","params","getTenant","type","getLocale","id","code","join","exports"],"sources":["generateCacheId.ts"],"sourcesContent":["import { ApiEndpoint } from \"~/types\";\nimport { Tenant } from \"@webiny/api-tenancy/types\";\nimport { I18NLocale } from \"@webiny/api-i18n/types\";\n\ninterface GenerateCacheIdParams {\n type: ApiEndpoint;\n getTenant: () => Tenant;\n getLocale: () => I18NLocale;\n}\n\nexport const generateCacheId = (params: GenerateCacheIdParams): string => {\n const { getTenant, type, getLocale } = params;\n return [`tenant:${getTenant().id}`, `endpoint:${type}`, `locale:${getLocale().code}`].join(\"#\");\n};\n"],"mappings":";;;;;;AAUO,MAAMA,eAAe,GAAIC,MAA6B,IAAa;EACtE,MAAM;IAAEC,SAAS;IAAEC,IAAI;IAAEC;EAAU,CAAC,GAAGH,MAAM;EAC7C,OAAO,
|
|
1
|
+
{"version":3,"names":["generateCacheId","params","getTenant","type","getLocale","id","code","join","exports"],"sources":["generateCacheId.ts"],"sourcesContent":["import { ApiEndpoint } from \"~/types\";\nimport { Tenant } from \"@webiny/api-tenancy/types\";\nimport { I18NLocale } from \"@webiny/api-i18n/types\";\n\ninterface GenerateCacheIdParams {\n type: ApiEndpoint;\n getTenant: () => Tenant;\n getLocale: () => I18NLocale;\n}\n\nexport const generateCacheId = (params: GenerateCacheIdParams): string => {\n const { getTenant, type, getLocale } = params;\n return [`tenant:${getTenant().id}`, `endpoint:${type}`, `locale:${getLocale().code}`].join(\"#\");\n};\n"],"mappings":";;;;;;AAUO,MAAMA,eAAe,GAAIC,MAA6B,IAAa;EACtE,MAAM;IAAEC,SAAS;IAAEC,IAAI;IAAEC;EAAU,CAAC,GAAGH,MAAM;EAC7C,OAAO,CAAC,UAAUC,SAAS,CAAC,CAAC,CAACG,EAAE,EAAE,EAAE,YAAYF,IAAI,EAAE,EAAE,UAAUC,SAAS,CAAC,CAAC,CAACE,IAAI,EAAE,CAAC,CAACC,IAAI,CAAC,GAAG,CAAC;AACnG,CAAC;AAACC,OAAA,CAAAR,eAAA,GAAAA,eAAA","ignoreList":[]}
|
package/graphql/getSchema.js
CHANGED
|
@@ -26,8 +26,9 @@ const getSchema = async params => {
|
|
|
26
26
|
* Private models are hidden in the GraphQL, so filter them out.
|
|
27
27
|
*/
|
|
28
28
|
const models = await context.security.withoutAuthorization(async () => {
|
|
29
|
-
return
|
|
30
|
-
|
|
29
|
+
return await context.cms.listModels({
|
|
30
|
+
includePrivate: false,
|
|
31
|
+
includePlugins: true
|
|
31
32
|
});
|
|
32
33
|
});
|
|
33
34
|
const cacheId = (0, _generateCacheId.generateCacheId)(params);
|
package/graphql/getSchema.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_codeFrame","require","_error","_interopRequireDefault","_generateSchema","_generateCacheId","_generateCacheKey","schemaList","Map","getSchema","params","context","models","security","withoutAuthorization","cms","listModels","
|
|
1
|
+
{"version":3,"names":["_codeFrame","require","_error","_interopRequireDefault","_generateSchema","_generateCacheId","_generateCacheKey","schemaList","Map","getSchema","params","context","models","security","withoutAuthorization","cms","listModels","includePrivate","includePlugins","cacheId","generateCacheId","cacheKey","generateCacheKey","cachedSchema","get","key","schema","generateSchema","set","err","Array","isArray","locations","WebinyError","message","code","data","endpoint","type","location","invalidSegment","codeFrameColumns","source","body","start","line","column","exports"],"sources":["getSchema.ts"],"sourcesContent":["import { codeFrameColumns } from \"@babel/code-frame\";\nimport WebinyError from \"@webiny/error\";\nimport { generateSchema } from \"./generateSchema\";\nimport { ApiEndpoint, CmsContext } from \"~/types\";\nimport { Tenant } from \"@webiny/api-tenancy/types\";\nimport { I18NLocale } from \"@webiny/api-i18n/types\";\nimport { GraphQLSchema } from \"graphql\";\nimport { generateCacheId } from \"./getSchema/generateCacheId\";\nimport { generateCacheKey } from \"./getSchema/generateCacheKey\";\n\ninterface SchemaCache {\n key: string;\n schema: GraphQLSchema;\n}\n\ninterface GetSchemaParams {\n context: CmsContext;\n type: ApiEndpoint;\n getTenant: () => Tenant;\n getLocale: () => I18NLocale;\n}\n\nconst schemaList = new Map<string, SchemaCache>();\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 */\nexport const getSchema = async (params: GetSchemaParams): Promise<GraphQLSchema> => {\n const { context } = params;\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({\n includePrivate: false,\n includePlugins: true\n });\n });\n\n const cacheId = generateCacheId(params);\n\n const cacheKey = await generateCacheKey({ ...params, models });\n const cachedSchema = schemaList.get(cacheId);\n if (cachedSchema?.key === cacheKey) {\n return cachedSchema.schema;\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 endpoint: context.cms.type\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: codeFrameColumns(err.source.body, {\n start: {\n line: location.line,\n column: location.column\n }\n })\n }\n });\n }\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AAKA,IAAAI,gBAAA,GAAAJ,OAAA;AACA,IAAAK,iBAAA,GAAAL,OAAA;AAcA,MAAMM,UAAU,GAAG,IAAIC,GAAG,CAAsB,CAAC;;AAEjD;AACA;AACA;AACA;AACO,MAAMC,SAAS,GAAG,MAAOC,MAAuB,IAA6B;EAChF,MAAM;IAAEC;EAAQ,CAAC,GAAGD,MAAM;;EAE1B;AACJ;AACA;AACA;EACI,M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E,wBAAwB;MAC9BD,OAAO,EAAEL,GAAG,CAACK,OAAO;MACpBE,IAAI,EAAE;QACFI,cAAc,EAAE,IAAAC,2BAAgB,EAACZ,GAAG,CAACa,MAAM,CAACC,IAAI,EAAE;UAC9CC,KAAK,EAAE;YACHC,IAAI,EAAEN,QAAQ,CAACM,IAAI;YACnBC,MAAM,EAAEP,QAAQ,CAACO;UACrB;QACJ,CAAC;MACL;IACJ,CAAC,CAAC;EACN;AACJ,CAAC;AAACC,OAAA,CAAAtC,SAAA,GAAAA,SAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_checkEndpointAccess","require","_createRequestBody","_formatErrorPayload","_getSchema","_handlerGraphql","handleRequest","params","context","request","reply","checkEndpointAccess","ex","code","send","data","error","message","stack","getTenant","tenancy","getCurrentTenant","getLocale","cms","schema","benchmark","measure","getSchema","type","console","formatErrorPayload","body","createRequestBody","result","processRequestBody","exports"],"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 schema = await context.benchmark.measure(\"headlessCms.graphql.getSchema\", async () => {\n try {\n return await getSchema({\n context,\n getTenant,\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,IAAAA,oBAAA,GAAAC,OAAA;AACA,IAAAC,kBAAA,GAAAD,OAAA;AACA,IAAAE,mBAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AAEA,IAAAI,eAAA,GAAAJ,OAAA;AAaO,MAAMK,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,KAAK,EAAE;QACHC,OAAO,EAAEL,EAAE,CAACK,OAAO,IAAI,iBAAiB;QACxCJ,IAAI,EAAED,EAAE,CAACC,IAAI,IAAI,yBAAyB;QAC1CE,IAAI,EAAEH,EAAE,CAACG,IAAI,IAAI,IAAI;QACrBG,KAAK,EAAE;MACX;IACJ,CAAC,CAAC;EACN;EAEA,MAAMC,SAAS,GAAGA,CAAA,KAAM;IACpB,OAAOX,OAAO,CAACY,OAAO,CAACC,gBAAgB,CAAC,CAAC;EAC7C,CAAC;EAED,MAAMC,SAAS,GAAGA,CAAA,KAAM;IACpB,OAAOd,OAAO,CAACe,GAAG,CAACD,SAAS,CAAC,CAAC;EAClC,CAAC;EAED,MAAME,MAAM,GAAG,MAAMhB,OAAO,CAACiB,SAAS,CAACC,OAAO,CAAC,+BAA+B,EAAE,YAAY;IACxF,IAAI;MACA,OAAO,MAAM,IAAAC,oBAAS,EAAC;QACnBnB,OAAO;QACPW,SAAS;QACTG,SAAS;QACTM,IAAI,EAAEpB,OAAO,CAACe,GAAG,CAACK;MACtB,CAAC,CAAC;IACN,CAAC,CAAC,OAAOhB,EAAE,EAAE;MACTiB,OAAO,CAACb,KAAK,
|
|
1
|
+
{"version":3,"names":["_checkEndpointAccess","require","_createRequestBody","_formatErrorPayload","_getSchema","_handlerGraphql","handleRequest","params","context","request","reply","checkEndpointAccess","ex","code","send","data","error","message","stack","getTenant","tenancy","getCurrentTenant","getLocale","cms","schema","benchmark","measure","getSchema","type","console","formatErrorPayload","body","createRequestBody","result","processRequestBody","exports"],"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 schema = await context.benchmark.measure(\"headlessCms.graphql.getSchema\", async () => {\n try {\n return await getSchema({\n context,\n getTenant,\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,IAAAA,oBAAA,GAAAC,OAAA;AACA,IAAAC,kBAAA,GAAAD,OAAA;AACA,IAAAE,mBAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AAEA,IAAAI,eAAA,GAAAJ,OAAA;AAaO,MAAMK,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,C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AAC;MACvDa,OAAO,CAACb,KAAK,CAAC,IAAAc,sCAAkB,EAAClB,EAAE,CAAC,CAAC;MACrC,MAAMA,EAAE;IACZ;EACJ,CACJ,CAAC;;EAED;AACJ;AACA;AACA;EACI,IAAIqB,MAAkD,GAAG,IAAI;EAE7D,MAAMzB,OAAO,CAACiB,SAAS,CAACC,OAAO,CAAC,wCAAwC,EAAE,YAAY;IAClF,IAAI;MACAO,MAAM,GAAG,MAAM,IAAAC,kCAAkB,EAACH,IAAI,EAAEP,MAAM,EAAEhB,OAAO,CAAC;IAC5D,CAAC,CAAC,OAAOI,EAAE,EAAE;MACTiB,OAAO,CAACb,KAAK,CAAC,0CAA0C,CAAC;MACzDa,OAAO,CAACb,KAAK,CAAC,IAAAc,sCAAkB,EAAClB,EAAE,CAAC,CAAC;MACrC,MAAMA,EAAE;IACZ;EACJ,CAAC,CAAC;EAEF,OAAOF,KAAK,CAACG,IAAI,CAAC,GAAG,CAAC,CAACC,IAAI,CAACmB,MAAM,CAAC;AACvC,CAAC;AAACE,OAAA,CAAA7B,aAAA,GAAAA,aAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_graphql","require","_utils","RevisionIdScalar","exports","GraphQLScalarType","name","description","parseValue","value","Error","result","parseIdentifier","version"],"sources":["RevisionId.ts"],"sourcesContent":["import { GraphQLScalarType } from \"graphql\";\nimport { parseIdentifier } from \"@webiny/utils\";\n\nexport const RevisionIdScalar = new GraphQLScalarType({\n name: \"RevisionId\",\n description: \"A Headless CMS Reference field input type.\",\n parseValue: value => {\n if (!value) {\n return null;\n } else if (typeof value !== \"string\") {\n throw new Error(\"RevisionId value must be a string!\");\n }\n\n const result = parseIdentifier(value);\n if (!result.version) {\n throw new Error(\n `RevisionId value must be a valid Revision ID property! Example: \"abcdef#0001\"`\n );\n }\n return value;\n }\n});\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEO,MAAME,gBAAgB,GAAAC,OAAA,CAAAD,gBAAA,GAAG,IAAIE,0BAAiB,CAAC;EAClDC,IAAI,EAAE,YAAY;EAClBC,WAAW,EAAE,4CAA4C;EACzDC,UAAU,EAAEC,KAAK,IAAI;IACjB,IAAI,CAACA,KAAK,EAAE;MACR,OAAO,IAAI;IACf,CAAC,MAAM,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;MAClC,MAAM,IAAIC,KAAK,CAAC,oCAAoC,CAAC;IACzD;IAEA,MAAMC,MAAM,GAAG,IAAAC,sBAAe,EAACH,KAAK,CAAC;IACrC,IAAI,CAACE,MAAM,CAACE,OAAO,EAAE;MACjB,MAAM,IAAIH,KAAK,
|
|
1
|
+
{"version":3,"names":["_graphql","require","_utils","RevisionIdScalar","exports","GraphQLScalarType","name","description","parseValue","value","Error","result","parseIdentifier","version"],"sources":["RevisionId.ts"],"sourcesContent":["import { GraphQLScalarType } from \"graphql\";\nimport { parseIdentifier } from \"@webiny/utils\";\n\nexport const RevisionIdScalar = new GraphQLScalarType({\n name: \"RevisionId\",\n description: \"A Headless CMS Reference field input type.\",\n parseValue: value => {\n if (!value) {\n return null;\n } else if (typeof value !== \"string\") {\n throw new Error(\"RevisionId value must be a string!\");\n }\n\n const result = parseIdentifier(value);\n if (!result.version) {\n throw new Error(\n `RevisionId value must be a valid Revision ID property! Example: \"abcdef#0001\"`\n );\n }\n return value;\n }\n});\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEO,MAAME,gBAAgB,GAAAC,OAAA,CAAAD,gBAAA,GAAG,IAAIE,0BAAiB,CAAC;EAClDC,IAAI,EAAE,YAAY;EAClBC,WAAW,EAAE,4CAA4C;EACzDC,UAAU,EAAEC,KAAK,IAAI;IACjB,IAAI,CAACA,KAAK,EAAE;MACR,OAAO,IAAI;IACf,CAAC,MAAM,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;MAClC,MAAM,IAAIC,KAAK,CAAC,oCAAoC,CAAC;IACzD;IAEA,MAAMC,MAAM,GAAG,IAAAC,sBAAe,EAACH,KAAK,CAAC;IACrC,IAAI,CAACE,MAAM,CAACE,OAAO,EAAE;MACjB,MAAM,IAAIH,KAAK,CACX,+EACJ,CAAC;IACL;IACA,OAAOD,KAAK;EAChB;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_builtInTypes","require","_plugins","createBaseContentSchema","context","scalars","plugins","byType","map","item","scalar","plugin","createCmsGraphQLSchemaPlugin","typeDefs","name","join","resolvers","reduce","acc","s","JSON","JsonScalar","Long","LongScalar","RefInput","RefInputScalar","Number","NumberScalar","Any","AnyScalar","DateTime","DateTimeScalar","DateTimeZ","DateTimeZScalar","Date","DateScalar","Time","TimeScalar","Mutation","_empty","exports"],"sources":["baseContentSchema.ts"],"sourcesContent":["import { GraphQLScalarPlugin } from \"@webiny/handler-graphql/types\";\nimport { CmsContext } from \"~/types\";\nimport {\n AnyScalar,\n DateScalar,\n DateTimeScalar,\n DateTimeZScalar,\n JsonScalar,\n LongScalar,\n NumberScalar,\n RefInputScalar,\n TimeScalar\n} from \"@webiny/handler-graphql/builtInTypes\";\nimport { GraphQLScalarType } from \"graphql\";\nimport { createCmsGraphQLSchemaPlugin, ICmsGraphQLSchemaPlugin } from \"~/plugins\";\n\ninterface Params {\n context: CmsContext;\n}\n\nexport const createBaseContentSchema = ({ context }: Params): ICmsGraphQLSchemaPlugin => {\n const scalars = context.plugins\n .byType<GraphQLScalarPlugin>(\"graphql-scalar\")\n .map(item => item.scalar);\n\n const plugin = createCmsGraphQLSchemaPlugin({\n typeDefs: /* GraphQL */ `\n ${scalars.map(scalar => `scalar ${scalar.name}`).join(\" \")}\n scalar JSON\n scalar Long\n scalar RefInput\n scalar Number\n scalar Any\n scalar Date\n scalar DateTime\n scalar DateTimeZ\n scalar Time\n\n type Query\n\n type Mutation {\n _empty: String\n }\n\n enum CmsEntryStatusType {\n latest\n published\n }\n `,\n resolvers: {\n ...scalars.reduce<Record<string, GraphQLScalarType>>((acc, s) => {\n acc[s.name] = s;\n return acc;\n }, {}),\n JSON: JsonScalar,\n Long: LongScalar,\n RefInput: RefInputScalar,\n Number: NumberScalar,\n Any: AnyScalar,\n DateTime: DateTimeScalar,\n DateTimeZ: DateTimeZScalar,\n Date: DateScalar,\n Time: TimeScalar,\n Mutation: {\n _empty: () => \"_empty\"\n }\n }\n });\n plugin.name = `headless-cms.graphql.schema.baseContentSchema`;\n\n return plugin;\n};\n"],"mappings":";;;;;;AAEA,IAAAA,aAAA,GAAAC,OAAA;AAYA,IAAAC,QAAA,GAAAD,OAAA;AAMO,MAAME,uBAAuB,GAAGA,CAAC;EAAEC;AAAgB,CAAC,KAA8B;EACrF,MAAMC,OAAO,GAAGD,OAAO,CAACE,OAAO,CAC1BC,MAAM,CAAsB,gBAAgB,CAAC,CAC7CC,GAAG,CAACC,IAAI,IAAIA,IAAI,CAACC,MAAM,CAAC;EAE7B,MAAMC,MAAM,GAAG,IAAAC,qCAA4B,EAAC;IACxCC,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"names":["_builtInTypes","require","_plugins","createBaseContentSchema","context","scalars","plugins","byType","map","item","scalar","plugin","createCmsGraphQLSchemaPlugin","typeDefs","name","join","resolvers","reduce","acc","s","JSON","JsonScalar","Long","LongScalar","RefInput","RefInputScalar","Number","NumberScalar","Any","AnyScalar","DateTime","DateTimeScalar","DateTimeZ","DateTimeZScalar","Date","DateScalar","Time","TimeScalar","Mutation","_empty","exports"],"sources":["baseContentSchema.ts"],"sourcesContent":["import { GraphQLScalarPlugin } from \"@webiny/handler-graphql/types\";\nimport { CmsContext } from \"~/types\";\nimport {\n AnyScalar,\n DateScalar,\n DateTimeScalar,\n DateTimeZScalar,\n JsonScalar,\n LongScalar,\n NumberScalar,\n RefInputScalar,\n TimeScalar\n} from \"@webiny/handler-graphql/builtInTypes\";\nimport { GraphQLScalarType } from \"graphql\";\nimport { createCmsGraphQLSchemaPlugin, ICmsGraphQLSchemaPlugin } from \"~/plugins\";\n\ninterface Params {\n context: CmsContext;\n}\n\nexport const createBaseContentSchema = ({ context }: Params): ICmsGraphQLSchemaPlugin => {\n const scalars = context.plugins\n .byType<GraphQLScalarPlugin>(\"graphql-scalar\")\n .map(item => item.scalar);\n\n const plugin = createCmsGraphQLSchemaPlugin({\n typeDefs: /* GraphQL */ `\n ${scalars.map(scalar => `scalar ${scalar.name}`).join(\" \")}\n scalar JSON\n scalar Long\n scalar RefInput\n scalar Number\n scalar Any\n scalar Date\n scalar DateTime\n scalar DateTimeZ\n scalar Time\n\n type Query\n\n type Mutation {\n _empty: String\n }\n\n enum CmsEntryStatusType {\n latest\n published\n }\n `,\n resolvers: {\n ...scalars.reduce<Record<string, GraphQLScalarType>>((acc, s) => {\n acc[s.name] = s;\n return acc;\n }, {}),\n JSON: JsonScalar,\n Long: LongScalar,\n RefInput: RefInputScalar,\n Number: NumberScalar,\n Any: AnyScalar,\n DateTime: DateTimeScalar,\n DateTimeZ: DateTimeZScalar,\n Date: DateScalar,\n Time: TimeScalar,\n Mutation: {\n _empty: () => \"_empty\"\n }\n }\n });\n plugin.name = `headless-cms.graphql.schema.baseContentSchema`;\n\n return plugin;\n};\n"],"mappings":";;;;;;AAEA,IAAAA,aAAA,GAAAC,OAAA;AAYA,IAAAC,QAAA,GAAAD,OAAA;AAMO,MAAME,uBAAuB,GAAGA,CAAC;EAAEC;AAAgB,CAAC,KAA8B;EACrF,MAAMC,OAAO,GAAGD,OAAO,CAACE,OAAO,CAC1BC,MAAM,CAAsB,gBAAgB,CAAC,CAC7CC,GAAG,CAACC,IAAI,IAAIA,IAAI,CAACC,MAAM,CAAC;EAE7B,MAAMC,MAAM,GAAG,IAAAC,qCAA4B,EAAC;IACxCC,QAAQ,EAAE,aAAc;AAChC,cAAcR,OAAO,CAACG,GAAG,CAACE,MAAM,IAAI,UAAUA,MAAM,CAACI,IAAI,EAAE,CAAC,CAACC,IAAI,CAAC,GAAG,CAAC;AACtE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;IACDC,SAAS,EAAE;MACP,GAAGX,OAAO,CAACY,MAAM,CAAoC,CAACC,GAAG,EAAEC,CAAC,KAAK;QAC7DD,GAAG,CAACC,CAAC,CAACL,IAAI,CAAC,GAAGK,CAAC;QACf,OAAOD,GAAG;MACd,CAAC,EAAE,CAAC,CAAC,CAAC;MACNE,IAAI,EAAEC,wBAAU;MAChBC,IAAI,EAAEC,wBAAU;MAChBC,QAAQ,EAAEC,4BAAc;MACxBC,MAAM,EAAEC,0BAAY;MACpBC,GAAG,EAAEC,uBAAS;MACdC,QAAQ,EAAEC,4BAAc;MACxBC,SAAS,EAAEC,6BAAe;MAC1BC,IAAI,EAAEC,wBAAU;MAChBC,IAAI,EAAEC,wBAAU;MAChBC,QAAQ,EAAE;QACNC,MAAM,EAAEA,CAAA,KAAM;MAClB;IACJ;EACJ,CAAC,CAAC;EACF5B,MAAM,CAACG,IAAI,GAAG,+CAA+C;EAE7D,OAAOH,MAAM;AACjB,CAAC;AAAC6B,OAAA,CAAArC,uBAAA,GAAAA,uBAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_plugins","require","_handlerGraphql","_api","_camelCase","_interopRequireDefault","createSkipValidatorEnum","plugins","validators","byType","reduce","collection","validator","name","camelCase","includes","push","length","join","createSchema","skipValidatorEnum","cmsPlugin","createCmsGraphQLSchemaPlugin","typeDefs","resolvers","corePlugin","GraphQLSchemaPlugin","schema","createBaseSchema","ContextPlugin","context","register","exports"],"sources":["baseSchema.ts"],"sourcesContent":["import { CmsContext, CmsModelFieldValidatorPlugin } from \"~/types\";\nimport { createCmsGraphQLSchemaPlugin } from \"~/plugins\";\nimport { GraphQLSchemaPlugin, IGraphQLSchemaPlugin } from \"@webiny/handler-graphql\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { ContextPlugin } from \"@webiny/api\";\nimport camelCase from \"lodash/camelCase\";\n\nconst createSkipValidatorEnum = (plugins: PluginsContainer) => {\n const validators = plugins\n .byType<CmsModelFieldValidatorPlugin>(\"cms-model-field-validator\")\n .reduce<string[]>((collection, validator) => {\n const name = camelCase(validator.validator.name);\n if (collection.includes(name)) {\n return collection;\n }\n collection.push(name);\n return collection;\n }, []);\n\n if (validators.length === 0) {\n validators.push(\"_empty\");\n }\n return /* GraphQL */ `\n enum SkipValidatorEnum {\n ${validators.join(\"\\n\")}\n }\n `;\n};\n\nconst createSchema = (plugins: PluginsContainer): IGraphQLSchemaPlugin<CmsContext>[] => {\n const skipValidatorEnum = createSkipValidatorEnum(plugins);\n\n const cmsPlugin = createCmsGraphQLSchemaPlugin({\n typeDefs: /* GraphQL */ `\n type CmsIdentity {\n id: String\n displayName: String\n type: String\n }\n\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 # permanently delete an entry without moving it to the bin\n permanently: 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 # Advanced Content Organization\n type WbyAcoLocation {\n folderId: ID\n }\n\n input WbyAcoLocationInput {\n folderId: ID!\n }\n\n input WbyAcoLocationWhereInput {\n folderId: ID\n folderId_in: [ID!]\n folderId_not: ID\n folderId_not_in: [ID!]\n }\n\n ${skipValidatorEnum}\n\n input CreateCmsEntryOptionsInput {\n skipValidators: [SkipValidatorEnum!]\n }\n\n input CreateRevisionCmsEntryOptionsInput {\n skipValidators: [SkipValidatorEnum!]\n }\n\n input UpdateCmsEntryOptionsInput {\n skipValidators: [SkipValidatorEnum!]\n }\n\n input CmsIdentityInput {\n id: String!\n displayName: String!\n type: String!\n }\n\n type CmsEntryValidationResponseData {\n error: String!\n id: String!\n fieldId: String!\n parents: [String!]!\n }\n\n type CmsEntryValidationResponse {\n data: [CmsEntryValidationResponseData!]\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\nexport const createBaseSchema = () => {\n return new ContextPlugin(async context => {\n context.plugins.register(...createSchema(context.plugins));\n });\n};\n"],"mappings":";;;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,eAAA,GAAAD,OAAA;AAEA,IAAAE,IAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAC,sBAAA,CAAAJ,OAAA;AAEA,MAAMK,uBAAuB,GAAIC,OAAyB,IAAK;EAC3D,MAAMC,UAAU,GAAGD,OAAO,CACrBE,MAAM,CAA+B,2BAA2B,CAAC,CACjEC,MAAM,CAAW,CAACC,UAAU,EAAEC,SAAS,KAAK;IACzC,MAAMC,IAAI,GAAG,IAAAC,kBAAS,EAACF,SAAS,CAACA,SAAS,CAACC,IAAI,CAAC;IAChD,IAAIF,UAAU,CAACI,QAAQ,CAACF,IAAI,CAAC,EAAE;MAC3B,OAAOF,UAAU;IACrB;IACAA,UAAU,CAACK,IAAI,CAACH,IAAI,CAAC;IACrB,OAAOF,UAAU;EACrB,CAAC,EAAE,EAAE,CAAC;EAEV,IAAIH,UAAU,CAACS,MAAM,KAAK,CAAC,EAAE;IACzBT,UAAU,CAACQ,IAAI,CAAC,QAAQ,CAAC;EAC7B;EACA,OAAO,
|
|
1
|
+
{"version":3,"names":["_plugins","require","_handlerGraphql","_api","_camelCase","_interopRequireDefault","createSkipValidatorEnum","plugins","validators","byType","reduce","collection","validator","name","camelCase","includes","push","length","join","createSchema","skipValidatorEnum","cmsPlugin","createCmsGraphQLSchemaPlugin","typeDefs","resolvers","corePlugin","GraphQLSchemaPlugin","schema","createBaseSchema","ContextPlugin","context","register","exports"],"sources":["baseSchema.ts"],"sourcesContent":["import { CmsContext, CmsModelFieldValidatorPlugin } from \"~/types\";\nimport { createCmsGraphQLSchemaPlugin } from \"~/plugins\";\nimport { GraphQLSchemaPlugin, IGraphQLSchemaPlugin } from \"@webiny/handler-graphql\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { ContextPlugin } from \"@webiny/api\";\nimport camelCase from \"lodash/camelCase\";\n\nconst createSkipValidatorEnum = (plugins: PluginsContainer) => {\n const validators = plugins\n .byType<CmsModelFieldValidatorPlugin>(\"cms-model-field-validator\")\n .reduce<string[]>((collection, validator) => {\n const name = camelCase(validator.validator.name);\n if (collection.includes(name)) {\n return collection;\n }\n collection.push(name);\n return collection;\n }, []);\n\n if (validators.length === 0) {\n validators.push(\"_empty\");\n }\n return /* GraphQL */ `\n enum SkipValidatorEnum {\n ${validators.join(\"\\n\")}\n }\n `;\n};\n\nconst createSchema = (plugins: PluginsContainer): IGraphQLSchemaPlugin<CmsContext>[] => {\n const skipValidatorEnum = createSkipValidatorEnum(plugins);\n\n const cmsPlugin = createCmsGraphQLSchemaPlugin({\n typeDefs: /* GraphQL */ `\n type CmsIdentity {\n id: String\n displayName: String\n type: String\n }\n\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 # permanently delete an entry without moving it to the bin\n permanently: 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 # Advanced Content Organization\n type WbyAcoLocation {\n folderId: ID\n }\n\n input WbyAcoLocationInput {\n folderId: ID!\n }\n\n input WbyAcoLocationWhereInput {\n folderId: ID\n folderId_in: [ID!]\n folderId_not: ID\n folderId_not_in: [ID!]\n }\n\n ${skipValidatorEnum}\n\n input CreateCmsEntryOptionsInput {\n skipValidators: [SkipValidatorEnum!]\n }\n\n input CreateRevisionCmsEntryOptionsInput {\n skipValidators: [SkipValidatorEnum!]\n }\n\n input UpdateCmsEntryOptionsInput {\n skipValidators: [SkipValidatorEnum!]\n }\n\n input CmsIdentityInput {\n id: String!\n displayName: String!\n type: String!\n }\n\n type CmsEntryValidationResponseData {\n error: String!\n id: String!\n fieldId: String!\n parents: [String!]!\n }\n\n type CmsEntryValidationResponse {\n data: [CmsEntryValidationResponseData!]\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\nexport const createBaseSchema = () => {\n return new ContextPlugin(async context => {\n context.plugins.register(...createSchema(context.plugins));\n });\n};\n"],"mappings":";;;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,eAA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C/B;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;IACDI,SAAS,EAAE,CAAC;EAChB,CAAC,CAAC;EACFH,SAAS,CAACR,IAAI,GAAG,kCAAkC;EACnD,MAAMY,UAAU,GAAG,IAAIC,mCAAmB,CAAa;IACnDH,QAAQ,EAAEF,SAAS,CAACM,MAAM,CAACJ,QAAQ;IACnCC,SAAS,EAAEH,SAAS,CAACM,MAAM,CAACH;EAChC,CAAC,CAAC;EACFC,UAAU,CAACZ,IAAI,GAAG,uCAAuC;EACzD;AACJ;AACA;EACI,OAAO,CAACQ,SAAS,EAAEI,UAAU,CAAC;AAClC,CAAC;AAEM,MAAMG,gBAAgB,GAAGA,CAAA,KAAM;EAClC,OAAO,IAAIC,kBAAa,CAAC,MAAMC,OAAO,IAAI;IACtCA,OAAO,CAACvB,OAAO,CAACwB,QAAQ,CAAC,GAAGZ,YAAY,CAACW,OAAO,CAACvB,OAAO,CAAC,CAAC;EAC9D,CAAC,CAAC;AACN,CAAC;AAACyB,OAAA,CAAAJ,gBAAA,GAAAA,gBAAA","ignoreList":[]}
|