@webiny/api-headless-cms 5.37.7-beta.0 → 5.37.8-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.
@@ -70,10 +70,12 @@ const createModelsCrud = params => {
70
70
  })];
71
71
  })
72
72
  };
73
+ const listModelsCache = new Map();
73
74
  const clearModelsCache = () => {
74
75
  for (const loader of Object.values(loaders)) {
75
76
  loader.clearAll();
76
77
  }
78
+ listModelsCache.clear();
77
79
  };
78
80
  const managers = new Map();
79
81
  const updateManager = async (context, model) => {
@@ -137,23 +139,44 @@ const createModelsCrud = params => {
137
139
  const pluginsModels = getModelsAsPlugins();
138
140
  return databaseModels.concat(pluginsModels);
139
141
  };
142
+ /**
143
+ * The list models cache is a key -> Promise pair so it the listModels() can be called multiple times but executed only once.
144
+ */
140
145
  const listModels = async () => {
141
- return context.benchmark.measure("headlessCms.crud.models.listModels", async () => {
142
- const models = await modelsList();
143
- return (0, _filterAsync.filterAsync)(models, async model => {
144
- const ownsModel = await modelsPermissions.ensure({
145
- owns: model.createdBy
146
- }, {
147
- throw: false
148
- });
149
- if (!ownsModel) {
150
- return false;
151
- }
152
- return modelsPermissions.canAccessModel({
153
- model
146
+ var _getIdentity;
147
+ /**
148
+ * Maybe we can cache based on permissions, not the identity id?
149
+ *
150
+ * TODO: @adrian please check if possible.
151
+ */
152
+ const key = JSON.stringify({
153
+ tenant: getTenant().id,
154
+ locale: getLocale().code,
155
+ identity: context.security.isAuthorizationEnabled() ? (_getIdentity = getIdentity()) === null || _getIdentity === void 0 ? void 0 : _getIdentity.id : undefined
156
+ });
157
+ if (listModelsCache.has(key)) {
158
+ return listModelsCache.get(key);
159
+ }
160
+ const cachedModelList = async () => {
161
+ return context.benchmark.measure("headlessCms.crud.models.listModels", async () => {
162
+ const models = await modelsList();
163
+ return (0, _filterAsync.filterAsync)(models, async model => {
164
+ const ownsModel = await modelsPermissions.ensure({
165
+ owns: model.createdBy
166
+ }, {
167
+ throw: false
168
+ });
169
+ if (!ownsModel) {
170
+ return false;
171
+ }
172
+ return modelsPermissions.canAccessModel({
173
+ model
174
+ });
154
175
  });
155
176
  });
156
- });
177
+ };
178
+ listModelsCache.set(key, cachedModelList());
179
+ return listModelsCache.get(key);
157
180
  };
158
181
  const getModel = async modelId => {
159
182
  return context.benchmark.measure("headlessCms.crud.models.getModel", async () => {
@@ -304,7 +327,7 @@ const createModelsCrud = params => {
304
327
  const createdModel = await storageOperations.models.create({
305
328
  model
306
329
  });
307
- loaders.listModels.clearAll();
330
+ clearModelsCache();
308
331
  await updateManager(context, model);
309
332
  await onModelAfterCreate.publish({
310
333
  input: data,
@@ -411,7 +434,7 @@ const createModelsCrud = params => {
411
434
  model
412
435
  });
413
436
  await updateManager(context, resultModel);
414
- loaders.listModels.clearAll();
437
+ clearModelsCache();
415
438
  await onModelAfterUpdate.publish({
416
439
  input: {},
417
440
  original,
@@ -488,7 +511,7 @@ const createModelsCrud = params => {
488
511
  const createdModel = await storageOperations.models.create({
489
512
  model
490
513
  });
491
- loaders.listModels.clearAll();
514
+ clearModelsCache();
492
515
  await updateManager(context, model);
493
516
  await onModelAfterCreateFrom.publish({
494
517
  input: data,
@@ -523,6 +546,7 @@ const createModelsCrud = params => {
523
546
  modelId: model.modelId
524
547
  });
525
548
  }
549
+ clearModelsCache();
526
550
  await onModelAfterDelete.publish({
527
551
  model
528
552
  });
@@ -1 +1 @@
1
- {"version":3,"names":["_dataloader","_interopRequireDefault","require","_error","_handlerGraphql","_contentModelManagerFactory","_pubsub","_beforeCreate","_beforeUpdate","_beforeDelete","_afterCreate","_afterUpdate","_afterDelete","_afterCreateFrom","_CmsModelPlugin","_filterAsync","_validation","_utils","_defaultFields","_modelApiName","_excluded","ensureTypeTag","model","tags","some","tag","startsWith","push","createModelsCrud","params","getTenant","getIdentity","getLocale","storageOperations","modelsPermissions","context","loaders","listModels","DataLoader","models","list","where","tenant","id","locale","code","map","_objectSpread2","default","singularApiName","ensureSingularApiName","pluralApiName","ensurePluralApiName","clearModelsCache","loader","Object","values","clearAll","managers","Map","updateManager","manager","contentModelManagerFactory","set","modelId","checkModelPermissions","rwd","ensure","getModelsAsPlugins","plugins","byType","CmsModelPlugin","type","filter","plugin","modelTenant","modelLocale","contentModel","webinyVersion","WEBINY_VERSION","modelsGet","pluginModel","find","get","NotFoundError","modelsList","databaseModels","load","pluginsModels","concat","benchmark","measure","filterAsync","ownsModel","owns","createdBy","throw","canAccessModel","getModel","ensureCanAccessModel","getModelManager","target","has","m","onModelBeforeCreate","createTopic","onModelAfterCreate","onModelCreateError","onModelBeforeCreateFrom","onModelAfterCreateFrom","onModelCreateFromError","onModelBeforeUpdate","onModelAfterUpdate","onModelUpdateError","onModelBeforeDelete","onModelAfterDelete","onModelDeleteError","onModelInitialize","assignModelBeforeCreate","assignModelAfterCreate","assignModelBeforeUpdate","assignModelAfterUpdate","assignModelAfterCreateFrom","assignModelBeforeDelete","assignModelAfterDelete","createModel","input","result","createModelCreateValidation","safeParseAsync","success","createZodError","error","_removeUndefinedValue","removeUndefinedValues","data","defaultFields","_objectWithoutProperties2","assignModelDefaultFields","group","security","withoutAuthorization","cms","getGroup","identity","titleFieldId","descriptionFieldId","imageFieldId","description","name","displayName","createdOn","Date","toISOString","savedOn","lockedFields","publish","createdModel","create","ex","updateModel","original","createModelUpdateValidation","keys","length","groupId","groupData","undefined","resultModel","update","updateModelDirect","initialModel","createModelFrom","createModelCreateFromValidation","i18n","groups","icon","deleteModel","delete","WebinyError","message","initializeModel","onBeforeModelCreate","onAfterModelCreate","onBeforeModelCreateFrom","onAfterModelCreateFrom","onBeforeModelUpdate","onAfterModelUpdate","onBeforeModelDelete","onAfterModelDelete","userInput","getEntryManager","getManagers","getEntryManagers","exports"],"sources":["contentModel.crud.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport WebinyError from \"@webiny/error\";\nimport {\n CmsContext,\n CmsModel,\n CmsModelContext,\n CmsModelGroup,\n CmsModelManager,\n CmsModelUpdateInput,\n HeadlessCmsStorageOperations,\n OnModelAfterCreateFromTopicParams,\n OnModelAfterCreateTopicParams,\n OnModelAfterDeleteTopicParams,\n OnModelAfterUpdateTopicParams,\n OnModelBeforeCreateFromTopicParams,\n OnModelBeforeCreateTopicParams,\n OnModelBeforeDeleteTopicParams,\n OnModelBeforeUpdateTopicParams,\n OnModelCreateErrorTopicParams,\n OnModelCreateFromErrorParams,\n OnModelDeleteErrorTopicParams,\n OnModelInitializeParams,\n OnModelUpdateErrorTopicParams\n} from \"~/types\";\nimport { NotFoundError } from \"@webiny/handler-graphql\";\nimport { contentModelManagerFactory } from \"./contentModel/contentModelManagerFactory\";\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 { assignModelBeforeCreate } from \"./contentModel/beforeCreate\";\nimport { assignModelBeforeUpdate } from \"./contentModel/beforeUpdate\";\nimport { assignModelBeforeDelete } from \"./contentModel/beforeDelete\";\nimport { assignModelAfterCreate } from \"./contentModel/afterCreate\";\nimport { assignModelAfterUpdate } from \"./contentModel/afterUpdate\";\nimport { assignModelAfterDelete } from \"./contentModel/afterDelete\";\nimport { assignModelAfterCreateFrom } from \"./contentModel/afterCreateFrom\";\nimport { CmsModelPlugin } from \"~/plugins/CmsModelPlugin\";\nimport { filterAsync } from \"~/utils/filterAsync\";\nimport {\n createModelCreateFromValidation,\n createModelCreateValidation,\n createModelUpdateValidation\n} from \"~/crud/contentModel/validation\";\nimport { createZodError, removeUndefinedValues } from \"@webiny/utils\";\nimport { assignModelDefaultFields } from \"~/crud/contentModel/defaultFields\";\nimport {\n ensurePluralApiName,\n ensureSingularApiName\n} from \"./contentModel/compatibility/modelApiName\";\nimport { ModelsPermissions } from \"~/utils/permissions/ModelsPermissions\";\n\n/**\n * Given a model, return an array of tags ensuring the `type` tag is set.\n */\nconst ensureTypeTag = (model: Pick<CmsModel, \"tags\">) => {\n // Let's make sure we have a `type` tag assigned.\n // If `type` tag is not set, set it to a default one (`model`).\n const tags = model.tags || [];\n if (!tags.some(tag => tag.startsWith(\"type:\"))) {\n tags.push(\"type:model\");\n }\n\n return tags;\n};\n\nexport interface CreateModelsCrudParams {\n getTenant: () => Tenant;\n getLocale: () => I18NLocale;\n storageOperations: HeadlessCmsStorageOperations;\n modelsPermissions: ModelsPermissions;\n context: CmsContext;\n getIdentity: () => SecurityIdentity;\n}\n\nexport const createModelsCrud = (params: CreateModelsCrudParams): CmsModelContext => {\n const { getTenant, getIdentity, getLocale, storageOperations, modelsPermissions, context } =\n params;\n\n const loaders = {\n listModels: new DataLoader(async () => {\n const models = await storageOperations.models.list({\n where: {\n tenant: getTenant().id,\n locale: getLocale().code\n }\n });\n return [\n models.map(model => {\n return {\n ...model,\n tags: ensureTypeTag(model),\n tenant: model.tenant || getTenant().id,\n locale: model.locale || getLocale().code,\n /**\n * TODO: remove in v5.36.0\n * This is for backward compatibility while migrations are not yet executed.\n */\n singularApiName: ensureSingularApiName(model),\n pluralApiName: ensurePluralApiName(model)\n };\n })\n ];\n })\n };\n\n const clearModelsCache = (): void => {\n for (const loader of Object.values(loaders)) {\n loader.clearAll();\n }\n };\n\n const managers = new Map<string, CmsModelManager>();\n const updateManager = async (\n context: CmsContext,\n model: CmsModel\n ): Promise<CmsModelManager> => {\n const manager = await contentModelManagerFactory(context, model);\n managers.set(model.modelId, manager);\n return manager;\n };\n\n const checkModelPermissions = (rwd: string) => {\n return modelsPermissions.ensure({ rwd });\n };\n\n const getModelsAsPlugins = (): CmsModel[] => {\n const tenant = getTenant().id;\n const locale = getLocale().code;\n\n return (\n context.plugins\n .byType<CmsModelPlugin>(CmsModelPlugin.type)\n /**\n * We need to filter out models 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: modelTenant, locale: modelLocale } = plugin.contentModel;\n if (modelTenant && modelTenant !== tenant) {\n return false;\n } else if (modelLocale && modelLocale !== locale) {\n return false;\n }\n return true;\n })\n .map(plugin => {\n return {\n ...plugin.contentModel,\n tags: ensureTypeTag(plugin.contentModel),\n tenant,\n locale,\n webinyVersion: context.WEBINY_VERSION\n };\n })\n );\n };\n\n const modelsGet = async (modelId: string) => {\n const pluginModel = getModelsAsPlugins().find(model => model.modelId === modelId);\n\n if (pluginModel) {\n return pluginModel;\n }\n\n const model = await storageOperations.models.get({\n tenant: getTenant().id,\n locale: getLocale().code,\n modelId\n });\n\n if (!model) {\n throw new NotFoundError(`Content model \"${modelId}\" was not found!`);\n }\n\n return {\n ...model,\n tags: ensureTypeTag(model),\n tenant: model.tenant || getTenant().id,\n locale: model.locale || getLocale().code\n };\n };\n\n const modelsList = async (): Promise<CmsModel[]> => {\n const databaseModels: CmsModel[] = await loaders.listModels.load(\"listModels\");\n\n const pluginsModels = getModelsAsPlugins();\n\n return databaseModels.concat(pluginsModels);\n };\n\n const listModels = async () => {\n return context.benchmark.measure(\"headlessCms.crud.models.listModels\", async () => {\n const models = await modelsList();\n return filterAsync(models, async model => {\n const ownsModel = await modelsPermissions.ensure(\n { owns: model.createdBy },\n { throw: false }\n );\n\n if (!ownsModel) {\n return false;\n }\n\n return modelsPermissions.canAccessModel({\n model\n });\n });\n });\n };\n\n const getModel = async (modelId: string): Promise<CmsModel> => {\n return context.benchmark.measure(\"headlessCms.crud.models.getModel\", async () => {\n await checkModelPermissions(\"r\");\n\n const model = await modelsGet(modelId);\n\n await modelsPermissions.ensure({ owns: model.createdBy });\n await modelsPermissions.ensureCanAccessModel({\n model\n });\n\n return model;\n });\n };\n\n const getModelManager: CmsModelContext[\"getModelManager\"] = async (\n target\n ): Promise<CmsModelManager> => {\n const modelId = typeof target === \"string\" ? target : target.modelId;\n if (managers.has(modelId)) {\n return managers.get(modelId) as CmsModelManager;\n }\n const models = await modelsList();\n const model = models.find(m => m.modelId === modelId);\n if (!model) {\n throw new NotFoundError(`There is no content model \"${modelId}\".`);\n }\n return await updateManager(context, model);\n };\n\n /**\n * Create\n */\n const onModelBeforeCreate =\n createTopic<OnModelBeforeCreateTopicParams>(\"cms.onModelBeforeCreate\");\n const onModelAfterCreate = createTopic<OnModelAfterCreateTopicParams>(\"cms.onModelAfterCreate\");\n const onModelCreateError = createTopic<OnModelCreateErrorTopicParams>(\"cms.onModelCreateError\");\n /**\n * Create from / clone\n */\n const onModelBeforeCreateFrom = createTopic<OnModelBeforeCreateFromTopicParams>(\n \"cms.onModelBeforeCreateFrom\"\n );\n const onModelAfterCreateFrom = createTopic<OnModelAfterCreateFromTopicParams>(\n \"cms.onModelAfterCreateFrom\"\n );\n const onModelCreateFromError = createTopic<OnModelCreateFromErrorParams>(\n \"cms.onModelCreateFromError\"\n );\n /**\n * Update\n */\n const onModelBeforeUpdate =\n createTopic<OnModelBeforeUpdateTopicParams>(\"cms.onModelBeforeUpdate\");\n const onModelAfterUpdate = createTopic<OnModelAfterUpdateTopicParams>(\"cms.onModelAfterUpdate\");\n const onModelUpdateError = createTopic<OnModelUpdateErrorTopicParams>(\"cms.onModelUpdateError\");\n /**\n * Delete\n */\n const onModelBeforeDelete =\n createTopic<OnModelBeforeDeleteTopicParams>(\"cms.onModelBeforeDelete\");\n const onModelAfterDelete = createTopic<OnModelAfterDeleteTopicParams>(\"cms.onModelAfterDelete\");\n const onModelDeleteError = createTopic<OnModelDeleteErrorTopicParams>(\"cms.onModelDeleteError\");\n /**\n * Initialize\n */\n const onModelInitialize = createTopic<OnModelInitializeParams>(\"cms.onModelInitialize\");\n /**\n * We need to assign some default behaviors.\n */\n assignModelBeforeCreate({\n onModelBeforeCreate,\n onModelBeforeCreateFrom,\n context,\n storageOperations\n });\n assignModelAfterCreate({\n context,\n onModelAfterCreate\n });\n assignModelBeforeUpdate({\n onModelBeforeUpdate,\n context\n });\n assignModelAfterUpdate({\n context,\n onModelAfterUpdate\n });\n assignModelAfterCreateFrom({\n context,\n onModelAfterCreateFrom\n });\n assignModelBeforeDelete({\n onModelBeforeDelete,\n plugins: context.plugins,\n storageOperations\n });\n assignModelAfterDelete({\n context,\n onModelAfterDelete\n });\n\n /**\n * CRUD methods\n */\n const createModel: CmsModelContext[\"createModel\"] = async input => {\n await checkModelPermissions(\"w\");\n\n const result = await createModelCreateValidation().safeParseAsync(input);\n if (!result.success) {\n throw createZodError(result.error);\n }\n /**\n * We need to extract the defaultFields because it is not for the CmsModel object.\n */\n const { defaultFields, ...data } = removeUndefinedValues(result.data);\n if (defaultFields) {\n assignModelDefaultFields(data);\n }\n\n const group = await context.security.withoutAuthorization(async () => {\n return context.cms.getGroup(data.group);\n });\n if (!group) {\n throw new NotFoundError(`There is no group \"${data.group}\".`);\n }\n\n const identity = getIdentity();\n const model: CmsModel = {\n ...data,\n modelId: data.modelId || \"\",\n singularApiName: data.singularApiName,\n pluralApiName: data.pluralApiName,\n titleFieldId: \"id\",\n descriptionFieldId: null,\n imageFieldId: null,\n description: data.description || \"\",\n locale: getLocale().code,\n tenant: getTenant().id,\n group: {\n id: group.id,\n name: group.name\n },\n createdBy: {\n id: identity.id,\n displayName: identity.displayName,\n type: identity.type\n },\n createdOn: new Date().toISOString(),\n savedOn: new Date().toISOString(),\n lockedFields: [],\n webinyVersion: context.WEBINY_VERSION\n };\n\n model.tags = ensureTypeTag(model);\n\n try {\n await onModelBeforeCreate.publish({\n input: data,\n model\n });\n\n const createdModel = await storageOperations.models.create({\n model\n });\n\n loaders.listModels.clearAll();\n\n await updateManager(context, model);\n\n await onModelAfterCreate.publish({\n input: data,\n model: createdModel\n });\n\n return createdModel;\n } catch (ex) {\n await onModelCreateError.publish({\n input: data,\n model,\n error: ex\n });\n throw ex;\n }\n };\n const updateModel: CmsModelContext[\"updateModel\"] = async (modelId, input) => {\n await checkModelPermissions(\"w\");\n\n // Get a model record; this will also perform ownership validation.\n const original = await getModel(modelId);\n\n const result = await createModelUpdateValidation().safeParseAsync(input);\n if (!result.success) {\n throw createZodError(result.error);\n }\n\n const data = removeUndefinedValues(result.data);\n\n if (Object.keys(data).length === 0) {\n /**\n * We need to return the original if nothing is to be updated.\n */\n return original;\n }\n let group: CmsModelGroup = {\n id: original.group.id,\n name: original.group.name\n };\n const groupId = data.group;\n if (groupId) {\n const groupData = await context.security.withoutAuthorization(async () => {\n return context.cms.getGroup(groupId);\n });\n if (!groupData) {\n throw new NotFoundError(`There is no group \"${groupId}\".`);\n }\n group = {\n id: groupData.id,\n name: groupData.name\n };\n }\n const model: CmsModel = {\n ...original,\n ...data,\n titleFieldId:\n data.titleFieldId === undefined\n ? original.titleFieldId\n : (data.titleFieldId as string),\n descriptionFieldId:\n data.descriptionFieldId === undefined\n ? original.descriptionFieldId\n : data.descriptionFieldId,\n imageFieldId:\n data.imageFieldId === undefined ? original.imageFieldId : data.imageFieldId,\n group,\n description: data.description || original.description,\n tenant: original.tenant || getTenant().id,\n locale: original.locale || getLocale().code,\n webinyVersion: context.WEBINY_VERSION,\n savedOn: new Date().toISOString()\n };\n\n model.tags = ensureTypeTag(model);\n\n try {\n await onModelBeforeUpdate.publish({\n input: data,\n original,\n model\n });\n\n const resultModel = await storageOperations.models.update({\n model\n });\n\n await updateManager(context, resultModel);\n\n await onModelAfterUpdate.publish({\n input: data,\n original,\n model: resultModel\n });\n\n return resultModel;\n } catch (ex) {\n await onModelUpdateError.publish({\n input: data,\n model,\n original,\n error: ex\n });\n\n throw ex;\n }\n };\n const updateModelDirect: CmsModelContext[\"updateModelDirect\"] = async params => {\n const { model: initialModel, original } = params;\n\n const model: CmsModel = {\n ...initialModel,\n tenant: initialModel.tenant || getTenant().id,\n locale: initialModel.locale || getLocale().code,\n webinyVersion: context.WEBINY_VERSION\n };\n\n try {\n await onModelBeforeUpdate.publish({\n input: {} as CmsModelUpdateInput,\n original,\n model\n });\n\n const resultModel = await storageOperations.models.update({\n model\n });\n\n await updateManager(context, resultModel);\n\n loaders.listModels.clearAll();\n\n await onModelAfterUpdate.publish({\n input: {} as CmsModelUpdateInput,\n original,\n model: resultModel\n });\n\n return resultModel;\n } catch (ex) {\n await onModelUpdateError.publish({\n input: {} as CmsModelUpdateInput,\n original,\n model,\n error: ex\n });\n throw ex;\n }\n };\n const createModelFrom: CmsModelContext[\"createModelFrom\"] = async (modelId, input) => {\n await checkModelPermissions(\"w\");\n /**\n * Get a model record; this will also perform ownership validation.\n */\n const original = await getModel(modelId);\n\n const result = await createModelCreateFromValidation().safeParseAsync({\n ...input,\n description: input.description || original.description\n });\n if (!result.success) {\n throw createZodError(result.error);\n }\n\n const data = removeUndefinedValues(result.data);\n\n const locale = await context.i18n.getLocale(data.locale || original.locale);\n if (!locale) {\n throw new NotFoundError(`There is no locale \"${data.locale}\".`);\n }\n /**\n * Use storage operations directly because we cannot get group from different locale via context methods.\n */\n const group = await context.cms.storageOperations.groups.get({\n id: data.group,\n tenant: original.tenant,\n locale: locale.code\n });\n if (!group) {\n throw new NotFoundError(`There is no group \"${data.group}\".`);\n }\n\n const identity = getIdentity();\n const model: CmsModel = {\n ...original,\n singularApiName: data.singularApiName,\n pluralApiName: data.pluralApiName,\n locale: locale.code,\n group: {\n id: group.id,\n name: group.name\n },\n icon: data.icon,\n name: data.name,\n modelId: data.modelId || \"\",\n description: data.description || \"\",\n createdBy: {\n id: identity.id,\n displayName: identity.displayName,\n type: identity.type\n },\n createdOn: new Date().toISOString(),\n savedOn: new Date().toISOString(),\n lockedFields: [],\n webinyVersion: context.WEBINY_VERSION\n };\n\n try {\n await onModelBeforeCreateFrom.publish({\n input: data,\n model,\n original\n });\n\n const createdModel = await storageOperations.models.create({\n model\n });\n\n loaders.listModels.clearAll();\n\n await updateManager(context, model);\n\n await onModelAfterCreateFrom.publish({\n input: data,\n original,\n model: createdModel\n });\n\n return createdModel;\n } catch (ex) {\n await onModelCreateFromError.publish({\n input: data,\n original,\n model,\n error: ex\n });\n throw ex;\n }\n };\n const deleteModel: CmsModelContext[\"deleteModel\"] = async modelId => {\n await checkModelPermissions(\"d\");\n\n const model = await getModel(modelId);\n\n try {\n await onModelBeforeDelete.publish({\n model\n });\n\n try {\n await storageOperations.models.delete({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete the content model\",\n ex.code || \"CONTENT_MODEL_DELETE_ERROR\",\n {\n error: ex,\n modelId: model.modelId\n }\n );\n }\n\n await onModelAfterDelete.publish({\n model\n });\n\n managers.delete(model.modelId);\n } catch (ex) {\n await onModelDeleteError.publish({\n model,\n error: ex\n });\n throw ex;\n }\n };\n const initializeModel: CmsModelContext[\"initializeModel\"] = async (modelId, data) => {\n /**\n * We require that users have write permissions to initialize models.\n * Maybe introduce another permission for it?\n */\n await checkModelPermissions(\"w\");\n\n const model = await getModel(modelId);\n\n await onModelInitialize.publish({ model, data });\n\n return true;\n };\n return {\n /**\n * Deprecated - will be removed in 5.36.0\n */\n onBeforeModelCreate: onModelBeforeCreate,\n onAfterModelCreate: onModelAfterCreate,\n onBeforeModelCreateFrom: onModelBeforeCreateFrom,\n onAfterModelCreateFrom: onModelAfterCreateFrom,\n onBeforeModelUpdate: onModelBeforeUpdate,\n onAfterModelUpdate: onModelAfterUpdate,\n onBeforeModelDelete: onModelBeforeDelete,\n onAfterModelDelete: onModelAfterDelete,\n /**\n * Released in 5.34.0\n */\n onModelBeforeCreate,\n onModelAfterCreate,\n onModelCreateError,\n onModelBeforeCreateFrom,\n onModelAfterCreateFrom,\n onModelCreateFromError,\n onModelBeforeUpdate,\n onModelAfterUpdate,\n onModelUpdateError,\n onModelBeforeDelete,\n onModelAfterDelete,\n onModelDeleteError,\n onModelInitialize,\n clearModelsCache,\n getModel,\n listModels,\n async createModel(input) {\n return context.benchmark.measure(\"headlessCms.crud.models.createModel\", async () => {\n return createModel(input);\n });\n },\n /**\n * Method does not check for permissions or ownership.\n * @internal\n */\n async updateModelDirect(params) {\n return context.benchmark.measure(\n \"headlessCms.crud.models.updateModelDirect\",\n async () => {\n return updateModelDirect(params);\n }\n );\n },\n async createModelFrom(modelId, userInput) {\n return context.benchmark.measure(\n \"headlessCms.crud.models.createModelFrom\",\n async () => {\n return createModelFrom(modelId, userInput);\n }\n );\n },\n async updateModel(modelId, input) {\n return context.benchmark.measure(\"headlessCms.crud.models.updateModel\", async () => {\n return updateModel(modelId, input);\n });\n },\n async deleteModel(modelId) {\n return context.benchmark.measure(\"headlessCms.crud.models.deleteModel\", async () => {\n return deleteModel(modelId);\n });\n },\n async initializeModel(modelId, data) {\n return context.benchmark.measure(\n \"headlessCms.crud.models.initializeModel\",\n async () => {\n return initializeModel(modelId, data);\n }\n );\n },\n getModelManager,\n getEntryManager: async model => {\n return getModelManager(model);\n },\n getManagers: () => managers,\n getEntryManagers: () => managers\n };\n};\n"],"mappings":";;;;;;;;;AAAA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAF,sBAAA,CAAAC,OAAA;AAuBA,IAAAE,eAAA,GAAAF,OAAA;AACA,IAAAG,2BAAA,GAAAH,OAAA;AAIA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,aAAA,GAAAL,OAAA;AACA,IAAAM,aAAA,GAAAN,OAAA;AACA,IAAAO,aAAA,GAAAP,OAAA;AACA,IAAAQ,YAAA,GAAAR,OAAA;AACA,IAAAS,YAAA,GAAAT,OAAA;AACA,IAAAU,YAAA,GAAAV,OAAA;AACA,IAAAW,gBAAA,GAAAX,OAAA;AACA,IAAAY,eAAA,GAAAZ,OAAA;AACA,IAAAa,YAAA,GAAAb,OAAA;AACA,IAAAc,WAAA,GAAAd,OAAA;AAKA,IAAAe,MAAA,GAAAf,OAAA;AACA,IAAAgB,cAAA,GAAAhB,OAAA;AACA,IAAAiB,aAAA,GAAAjB,OAAA;AAGmD,MAAAkB,SAAA;AAGnD;AACA;AACA;AACA,MAAMC,aAAa,GAAIC,KAA6B,IAAK;EACrD;EACA;EACA,MAAMC,IAAI,GAAGD,KAAK,CAACC,IAAI,IAAI,EAAE;EAC7B,IAAI,CAACA,IAAI,CAACC,IAAI,CAACC,GAAG,IAAIA,GAAG,CAACC,U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,CAAC;MAC/B,CAAC,CAAC;IACN,CAAC;IACD,MAAMqH,eAAeA,CAACrH,OAAO,EAAEuE,IAAI,EAAE;MACjC,OAAOpG,OAAO,CAACuD,SAAS,CAACC,OAAO,CAC5B,yCAAyC,EACzC,YAAY;QACR,OAAO0F,eAAe,CAACrH,OAAO,EAAEuE,IAAI,CAAC;MACzC,CACJ,CAAC;IACL,CAAC;IACDnC,eAAe;IACf2F,eAAe,EAAE,MAAMzK,KAAK,IAAI;MAC5B,OAAO8E,eAAe,CAAC9E,KAAK,CAAC;IACjC,CAAC;IACD0K,WAAW,EAAEA,CAAA,KAAMtI,QAAQ;IAC3BuI,gBAAgB,EAAEA,CAAA,KAAMvI;EAC5B,CAAC;AACL,CAAC;AAACwI,OAAA,CAAAtK,gBAAA,GAAAA,gBAAA"}
1
+ {"version":3,"names":["_dataloader","_interopRequireDefault","require","_error","_handlerGraphql","_contentModelManagerFactory","_pubsub","_beforeCreate","_beforeUpdate","_beforeDelete","_afterCreate","_afterUpdate","_afterDelete","_afterCreateFrom","_CmsModelPlugin","_filterAsync","_validation","_utils","_defaultFields","_modelApiName","_excluded","ensureTypeTag","model","tags","some","tag","startsWith","push","createModelsCrud","params","getTenant","getIdentity","getLocale","storageOperations","modelsPermissions","context","loaders","listModels","DataLoader","models","list","where","tenant","id","locale","code","map","_objectSpread2","default","singularApiName","ensureSingularApiName","pluralApiName","ensurePluralApiName","listModelsCache","Map","clearModelsCache","loader","Object","values","clearAll","clear","managers","updateManager","manager","contentModelManagerFactory","set","modelId","checkModelPermissions","rwd","ensure","getModelsAsPlugins","plugins","byType","CmsModelPlugin","type","filter","plugin","modelTenant","modelLocale","contentModel","webinyVersion","WEBINY_VERSION","modelsGet","pluginModel","find","get","NotFoundError","modelsList","databaseModels","load","pluginsModels","concat","_getIdentity","key","JSON","stringify","identity","security","isAuthorizationEnabled","undefined","has","cachedModelList","benchmark","measure","filterAsync","ownsModel","owns","createdBy","throw","canAccessModel","getModel","ensureCanAccessModel","getModelManager","target","m","onModelBeforeCreate","createTopic","onModelAfterCreate","onModelCreateError","onModelBeforeCreateFrom","onModelAfterCreateFrom","onModelCreateFromError","onModelBeforeUpdate","onModelAfterUpdate","onModelUpdateError","onModelBeforeDelete","onModelAfterDelete","onModelDeleteError","onModelInitialize","assignModelBeforeCreate","assignModelAfterCreate","assignModelBeforeUpdate","assignModelAfterUpdate","assignModelAfterCreateFrom","assignModelBeforeDelete","assignModelAfterDelete","createModel","input","result","createModelCreateValidation","safeParseAsync","success","createZodError","error","_removeUndefinedValue","removeUndefinedValues","data","defaultFields","_objectWithoutProperties2","assignModelDefaultFields","group","withoutAuthorization","cms","getGroup","titleFieldId","descriptionFieldId","imageFieldId","description","name","displayName","createdOn","Date","toISOString","savedOn","lockedFields","publish","createdModel","create","ex","updateModel","original","createModelUpdateValidation","keys","length","groupId","groupData","resultModel","update","updateModelDirect","initialModel","createModelFrom","createModelCreateFromValidation","i18n","groups","icon","deleteModel","delete","WebinyError","message","initializeModel","onBeforeModelCreate","onAfterModelCreate","onBeforeModelCreateFrom","onAfterModelCreateFrom","onBeforeModelUpdate","onAfterModelUpdate","onBeforeModelDelete","onAfterModelDelete","userInput","getEntryManager","getManagers","getEntryManagers","exports"],"sources":["contentModel.crud.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport WebinyError from \"@webiny/error\";\nimport {\n CmsContext,\n CmsModel,\n CmsModelContext,\n CmsModelGroup,\n CmsModelManager,\n CmsModelUpdateInput,\n HeadlessCmsStorageOperations,\n OnModelAfterCreateFromTopicParams,\n OnModelAfterCreateTopicParams,\n OnModelAfterDeleteTopicParams,\n OnModelAfterUpdateTopicParams,\n OnModelBeforeCreateFromTopicParams,\n OnModelBeforeCreateTopicParams,\n OnModelBeforeDeleteTopicParams,\n OnModelBeforeUpdateTopicParams,\n OnModelCreateErrorTopicParams,\n OnModelCreateFromErrorParams,\n OnModelDeleteErrorTopicParams,\n OnModelInitializeParams,\n OnModelUpdateErrorTopicParams\n} from \"~/types\";\nimport { NotFoundError } from \"@webiny/handler-graphql\";\nimport { contentModelManagerFactory } from \"./contentModel/contentModelManagerFactory\";\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 { assignModelBeforeCreate } from \"./contentModel/beforeCreate\";\nimport { assignModelBeforeUpdate } from \"./contentModel/beforeUpdate\";\nimport { assignModelBeforeDelete } from \"./contentModel/beforeDelete\";\nimport { assignModelAfterCreate } from \"./contentModel/afterCreate\";\nimport { assignModelAfterUpdate } from \"./contentModel/afterUpdate\";\nimport { assignModelAfterDelete } from \"./contentModel/afterDelete\";\nimport { assignModelAfterCreateFrom } from \"./contentModel/afterCreateFrom\";\nimport { CmsModelPlugin } from \"~/plugins/CmsModelPlugin\";\nimport { filterAsync } from \"~/utils/filterAsync\";\nimport {\n createModelCreateFromValidation,\n createModelCreateValidation,\n createModelUpdateValidation\n} from \"~/crud/contentModel/validation\";\nimport { createZodError, removeUndefinedValues } from \"@webiny/utils\";\nimport { assignModelDefaultFields } from \"~/crud/contentModel/defaultFields\";\nimport {\n ensurePluralApiName,\n ensureSingularApiName\n} from \"./contentModel/compatibility/modelApiName\";\nimport { ModelsPermissions } from \"~/utils/permissions/ModelsPermissions\";\n\n/**\n * Given a model, return an array of tags ensuring the `type` tag is set.\n */\nconst ensureTypeTag = (model: Pick<CmsModel, \"tags\">) => {\n // Let's make sure we have a `type` tag assigned.\n // If `type` tag is not set, set it to a default one (`model`).\n const tags = model.tags || [];\n if (!tags.some(tag => tag.startsWith(\"type:\"))) {\n tags.push(\"type:model\");\n }\n\n return tags;\n};\n\nexport interface CreateModelsCrudParams {\n getTenant: () => Tenant;\n getLocale: () => I18NLocale;\n storageOperations: HeadlessCmsStorageOperations;\n modelsPermissions: ModelsPermissions;\n context: CmsContext;\n getIdentity: () => SecurityIdentity;\n}\n\nexport const createModelsCrud = (params: CreateModelsCrudParams): CmsModelContext => {\n const { getTenant, getIdentity, getLocale, storageOperations, modelsPermissions, context } =\n params;\n\n const loaders = {\n listModels: new DataLoader(async () => {\n const models = await storageOperations.models.list({\n where: {\n tenant: getTenant().id,\n locale: getLocale().code\n }\n });\n return [\n models.map(model => {\n return {\n ...model,\n tags: ensureTypeTag(model),\n tenant: model.tenant || getTenant().id,\n locale: model.locale || getLocale().code,\n /**\n * TODO: remove in v5.36.0\n * This is for backward compatibility while migrations are not yet executed.\n */\n singularApiName: ensureSingularApiName(model),\n pluralApiName: ensurePluralApiName(model)\n };\n })\n ];\n })\n };\n\n const listModelsCache = new Map<string, Promise<CmsModel[]>>();\n const clearModelsCache = (): void => {\n for (const loader of Object.values(loaders)) {\n loader.clearAll();\n }\n listModelsCache.clear();\n };\n\n const managers = new Map<string, CmsModelManager>();\n const updateManager = async (\n context: CmsContext,\n model: CmsModel\n ): Promise<CmsModelManager> => {\n const manager = await contentModelManagerFactory(context, model);\n managers.set(model.modelId, manager);\n return manager;\n };\n\n const checkModelPermissions = (rwd: string) => {\n return modelsPermissions.ensure({ rwd });\n };\n\n const getModelsAsPlugins = (): CmsModel[] => {\n const tenant = getTenant().id;\n const locale = getLocale().code;\n\n return (\n context.plugins\n .byType<CmsModelPlugin>(CmsModelPlugin.type)\n /**\n * We need to filter out models 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: modelTenant, locale: modelLocale } = plugin.contentModel;\n if (modelTenant && modelTenant !== tenant) {\n return false;\n } else if (modelLocale && modelLocale !== locale) {\n return false;\n }\n return true;\n })\n .map(plugin => {\n return {\n ...plugin.contentModel,\n tags: ensureTypeTag(plugin.contentModel),\n tenant,\n locale,\n webinyVersion: context.WEBINY_VERSION\n };\n })\n );\n };\n\n const modelsGet = async (modelId: string) => {\n const pluginModel = getModelsAsPlugins().find(model => model.modelId === modelId);\n\n if (pluginModel) {\n return pluginModel;\n }\n\n const model = await storageOperations.models.get({\n tenant: getTenant().id,\n locale: getLocale().code,\n modelId\n });\n\n if (!model) {\n throw new NotFoundError(`Content model \"${modelId}\" was not found!`);\n }\n\n return {\n ...model,\n tags: ensureTypeTag(model),\n tenant: model.tenant || getTenant().id,\n locale: model.locale || getLocale().code\n };\n };\n\n const modelsList = async (): Promise<CmsModel[]> => {\n const databaseModels: CmsModel[] = await loaders.listModels.load(\"listModels\");\n const pluginsModels = getModelsAsPlugins();\n return databaseModels.concat(pluginsModels);\n };\n /**\n * The list models cache is a key -> Promise pair so it the listModels() can be called multiple times but executed only once.\n */\n const listModels = async () => {\n /**\n * Maybe we can cache based on permissions, not the identity id?\n *\n * TODO: @adrian please check if possible.\n */\n const key = JSON.stringify({\n tenant: getTenant().id,\n locale: getLocale().code,\n identity: context.security.isAuthorizationEnabled() ? getIdentity()?.id : undefined\n });\n if (listModelsCache.has(key)) {\n return listModelsCache.get(key) as Promise<CmsModel[]>;\n }\n const cachedModelList = async () => {\n return context.benchmark.measure(\"headlessCms.crud.models.listModels\", async () => {\n const models = await modelsList();\n return filterAsync(models, async model => {\n const ownsModel = await modelsPermissions.ensure(\n { owns: model.createdBy },\n { throw: false }\n );\n\n if (!ownsModel) {\n return false;\n }\n\n return modelsPermissions.canAccessModel({\n model\n });\n });\n });\n };\n\n listModelsCache.set(key, cachedModelList());\n\n return listModelsCache.get(key) as Promise<CmsModel[]>;\n };\n\n const getModel = async (modelId: string): Promise<CmsModel> => {\n return context.benchmark.measure(\"headlessCms.crud.models.getModel\", async () => {\n await checkModelPermissions(\"r\");\n\n const model = await modelsGet(modelId);\n\n await modelsPermissions.ensure({ owns: model.createdBy });\n await modelsPermissions.ensureCanAccessModel({\n model\n });\n\n return model;\n });\n };\n\n const getModelManager: CmsModelContext[\"getModelManager\"] = async (\n target\n ): Promise<CmsModelManager> => {\n const modelId = typeof target === \"string\" ? target : target.modelId;\n if (managers.has(modelId)) {\n return managers.get(modelId) as CmsModelManager;\n }\n const models = await modelsList();\n const model = models.find(m => m.modelId === modelId);\n if (!model) {\n throw new NotFoundError(`There is no content model \"${modelId}\".`);\n }\n return await updateManager(context, model);\n };\n\n /**\n * Create\n */\n const onModelBeforeCreate =\n createTopic<OnModelBeforeCreateTopicParams>(\"cms.onModelBeforeCreate\");\n const onModelAfterCreate = createTopic<OnModelAfterCreateTopicParams>(\"cms.onModelAfterCreate\");\n const onModelCreateError = createTopic<OnModelCreateErrorTopicParams>(\"cms.onModelCreateError\");\n /**\n * Create from / clone\n */\n const onModelBeforeCreateFrom = createTopic<OnModelBeforeCreateFromTopicParams>(\n \"cms.onModelBeforeCreateFrom\"\n );\n const onModelAfterCreateFrom = createTopic<OnModelAfterCreateFromTopicParams>(\n \"cms.onModelAfterCreateFrom\"\n );\n const onModelCreateFromError = createTopic<OnModelCreateFromErrorParams>(\n \"cms.onModelCreateFromError\"\n );\n /**\n * Update\n */\n const onModelBeforeUpdate =\n createTopic<OnModelBeforeUpdateTopicParams>(\"cms.onModelBeforeUpdate\");\n const onModelAfterUpdate = createTopic<OnModelAfterUpdateTopicParams>(\"cms.onModelAfterUpdate\");\n const onModelUpdateError = createTopic<OnModelUpdateErrorTopicParams>(\"cms.onModelUpdateError\");\n /**\n * Delete\n */\n const onModelBeforeDelete =\n createTopic<OnModelBeforeDeleteTopicParams>(\"cms.onModelBeforeDelete\");\n const onModelAfterDelete = createTopic<OnModelAfterDeleteTopicParams>(\"cms.onModelAfterDelete\");\n const onModelDeleteError = createTopic<OnModelDeleteErrorTopicParams>(\"cms.onModelDeleteError\");\n /**\n * Initialize\n */\n const onModelInitialize = createTopic<OnModelInitializeParams>(\"cms.onModelInitialize\");\n /**\n * We need to assign some default behaviors.\n */\n assignModelBeforeCreate({\n onModelBeforeCreate,\n onModelBeforeCreateFrom,\n context,\n storageOperations\n });\n assignModelAfterCreate({\n context,\n onModelAfterCreate\n });\n assignModelBeforeUpdate({\n onModelBeforeUpdate,\n context\n });\n assignModelAfterUpdate({\n context,\n onModelAfterUpdate\n });\n assignModelAfterCreateFrom({\n context,\n onModelAfterCreateFrom\n });\n assignModelBeforeDelete({\n onModelBeforeDelete,\n plugins: context.plugins,\n storageOperations\n });\n assignModelAfterDelete({\n context,\n onModelAfterDelete\n });\n\n /**\n * CRUD methods\n */\n const createModel: CmsModelContext[\"createModel\"] = async input => {\n await checkModelPermissions(\"w\");\n\n const result = await createModelCreateValidation().safeParseAsync(input);\n if (!result.success) {\n throw createZodError(result.error);\n }\n /**\n * We need to extract the defaultFields because it is not for the CmsModel object.\n */\n const { defaultFields, ...data } = removeUndefinedValues(result.data);\n if (defaultFields) {\n assignModelDefaultFields(data);\n }\n\n const group = await context.security.withoutAuthorization(async () => {\n return context.cms.getGroup(data.group);\n });\n if (!group) {\n throw new NotFoundError(`There is no group \"${data.group}\".`);\n }\n\n const identity = getIdentity();\n const model: CmsModel = {\n ...data,\n modelId: data.modelId || \"\",\n singularApiName: data.singularApiName,\n pluralApiName: data.pluralApiName,\n titleFieldId: \"id\",\n descriptionFieldId: null,\n imageFieldId: null,\n description: data.description || \"\",\n locale: getLocale().code,\n tenant: getTenant().id,\n group: {\n id: group.id,\n name: group.name\n },\n createdBy: {\n id: identity.id,\n displayName: identity.displayName,\n type: identity.type\n },\n createdOn: new Date().toISOString(),\n savedOn: new Date().toISOString(),\n lockedFields: [],\n webinyVersion: context.WEBINY_VERSION\n };\n\n model.tags = ensureTypeTag(model);\n\n try {\n await onModelBeforeCreate.publish({\n input: data,\n model\n });\n\n const createdModel = await storageOperations.models.create({\n model\n });\n\n clearModelsCache();\n\n await updateManager(context, model);\n\n await onModelAfterCreate.publish({\n input: data,\n model: createdModel\n });\n\n return createdModel;\n } catch (ex) {\n await onModelCreateError.publish({\n input: data,\n model,\n error: ex\n });\n throw ex;\n }\n };\n const updateModel: CmsModelContext[\"updateModel\"] = async (modelId, input) => {\n await checkModelPermissions(\"w\");\n\n // Get a model record; this will also perform ownership validation.\n const original = await getModel(modelId);\n\n const result = await createModelUpdateValidation().safeParseAsync(input);\n if (!result.success) {\n throw createZodError(result.error);\n }\n\n const data = removeUndefinedValues(result.data);\n\n if (Object.keys(data).length === 0) {\n /**\n * We need to return the original if nothing is to be updated.\n */\n return original;\n }\n let group: CmsModelGroup = {\n id: original.group.id,\n name: original.group.name\n };\n const groupId = data.group;\n if (groupId) {\n const groupData = await context.security.withoutAuthorization(async () => {\n return context.cms.getGroup(groupId);\n });\n if (!groupData) {\n throw new NotFoundError(`There is no group \"${groupId}\".`);\n }\n group = {\n id: groupData.id,\n name: groupData.name\n };\n }\n const model: CmsModel = {\n ...original,\n ...data,\n titleFieldId:\n data.titleFieldId === undefined\n ? original.titleFieldId\n : (data.titleFieldId as string),\n descriptionFieldId:\n data.descriptionFieldId === undefined\n ? original.descriptionFieldId\n : data.descriptionFieldId,\n imageFieldId:\n data.imageFieldId === undefined ? original.imageFieldId : data.imageFieldId,\n group,\n description: data.description || original.description,\n tenant: original.tenant || getTenant().id,\n locale: original.locale || getLocale().code,\n webinyVersion: context.WEBINY_VERSION,\n savedOn: new Date().toISOString()\n };\n\n model.tags = ensureTypeTag(model);\n\n try {\n await onModelBeforeUpdate.publish({\n input: data,\n original,\n model\n });\n\n const resultModel = await storageOperations.models.update({\n model\n });\n\n await updateManager(context, resultModel);\n\n await onModelAfterUpdate.publish({\n input: data,\n original,\n model: resultModel\n });\n\n return resultModel;\n } catch (ex) {\n await onModelUpdateError.publish({\n input: data,\n model,\n original,\n error: ex\n });\n\n throw ex;\n }\n };\n const updateModelDirect: CmsModelContext[\"updateModelDirect\"] = async params => {\n const { model: initialModel, original } = params;\n\n const model: CmsModel = {\n ...initialModel,\n tenant: initialModel.tenant || getTenant().id,\n locale: initialModel.locale || getLocale().code,\n webinyVersion: context.WEBINY_VERSION\n };\n\n try {\n await onModelBeforeUpdate.publish({\n input: {} as CmsModelUpdateInput,\n original,\n model\n });\n\n const resultModel = await storageOperations.models.update({\n model\n });\n\n await updateManager(context, resultModel);\n\n clearModelsCache();\n\n await onModelAfterUpdate.publish({\n input: {} as CmsModelUpdateInput,\n original,\n model: resultModel\n });\n\n return resultModel;\n } catch (ex) {\n await onModelUpdateError.publish({\n input: {} as CmsModelUpdateInput,\n original,\n model,\n error: ex\n });\n throw ex;\n }\n };\n const createModelFrom: CmsModelContext[\"createModelFrom\"] = async (modelId, input) => {\n await checkModelPermissions(\"w\");\n /**\n * Get a model record; this will also perform ownership validation.\n */\n const original = await getModel(modelId);\n\n const result = await createModelCreateFromValidation().safeParseAsync({\n ...input,\n description: input.description || original.description\n });\n if (!result.success) {\n throw createZodError(result.error);\n }\n\n const data = removeUndefinedValues(result.data);\n\n const locale = await context.i18n.getLocale(data.locale || original.locale);\n if (!locale) {\n throw new NotFoundError(`There is no locale \"${data.locale}\".`);\n }\n /**\n * Use storage operations directly because we cannot get group from different locale via context methods.\n */\n const group = await context.cms.storageOperations.groups.get({\n id: data.group,\n tenant: original.tenant,\n locale: locale.code\n });\n if (!group) {\n throw new NotFoundError(`There is no group \"${data.group}\".`);\n }\n\n const identity = getIdentity();\n const model: CmsModel = {\n ...original,\n singularApiName: data.singularApiName,\n pluralApiName: data.pluralApiName,\n locale: locale.code,\n group: {\n id: group.id,\n name: group.name\n },\n icon: data.icon,\n name: data.name,\n modelId: data.modelId || \"\",\n description: data.description || \"\",\n createdBy: {\n id: identity.id,\n displayName: identity.displayName,\n type: identity.type\n },\n createdOn: new Date().toISOString(),\n savedOn: new Date().toISOString(),\n lockedFields: [],\n webinyVersion: context.WEBINY_VERSION\n };\n\n try {\n await onModelBeforeCreateFrom.publish({\n input: data,\n model,\n original\n });\n\n const createdModel = await storageOperations.models.create({\n model\n });\n\n clearModelsCache();\n\n await updateManager(context, model);\n\n await onModelAfterCreateFrom.publish({\n input: data,\n original,\n model: createdModel\n });\n\n return createdModel;\n } catch (ex) {\n await onModelCreateFromError.publish({\n input: data,\n original,\n model,\n error: ex\n });\n throw ex;\n }\n };\n const deleteModel: CmsModelContext[\"deleteModel\"] = async modelId => {\n await checkModelPermissions(\"d\");\n\n const model = await getModel(modelId);\n\n try {\n await onModelBeforeDelete.publish({\n model\n });\n\n try {\n await storageOperations.models.delete({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete the content model\",\n ex.code || \"CONTENT_MODEL_DELETE_ERROR\",\n {\n error: ex,\n modelId: model.modelId\n }\n );\n }\n\n clearModelsCache();\n\n await onModelAfterDelete.publish({\n model\n });\n\n managers.delete(model.modelId);\n } catch (ex) {\n await onModelDeleteError.publish({\n model,\n error: ex\n });\n throw ex;\n }\n };\n const initializeModel: CmsModelContext[\"initializeModel\"] = async (modelId, data) => {\n /**\n * We require that users have write permissions to initialize models.\n * Maybe introduce another permission for it?\n */\n await checkModelPermissions(\"w\");\n\n const model = await getModel(modelId);\n\n await onModelInitialize.publish({ model, data });\n\n return true;\n };\n return {\n /**\n * Deprecated - will be removed in 5.36.0\n */\n onBeforeModelCreate: onModelBeforeCreate,\n onAfterModelCreate: onModelAfterCreate,\n onBeforeModelCreateFrom: onModelBeforeCreateFrom,\n onAfterModelCreateFrom: onModelAfterCreateFrom,\n onBeforeModelUpdate: onModelBeforeUpdate,\n onAfterModelUpdate: onModelAfterUpdate,\n onBeforeModelDelete: onModelBeforeDelete,\n onAfterModelDelete: onModelAfterDelete,\n /**\n * Released in 5.34.0\n */\n onModelBeforeCreate,\n onModelAfterCreate,\n onModelCreateError,\n onModelBeforeCreateFrom,\n onModelAfterCreateFrom,\n onModelCreateFromError,\n onModelBeforeUpdate,\n onModelAfterUpdate,\n onModelUpdateError,\n onModelBeforeDelete,\n onModelAfterDelete,\n onModelDeleteError,\n onModelInitialize,\n clearModelsCache,\n getModel,\n listModels,\n async createModel(input) {\n return context.benchmark.measure(\"headlessCms.crud.models.createModel\", async () => {\n return createModel(input);\n });\n },\n /**\n * Method does not check for permissions or ownership.\n * @internal\n */\n async updateModelDirect(params) {\n return context.benchmark.measure(\n \"headlessCms.crud.models.updateModelDirect\",\n async () => {\n return updateModelDirect(params);\n }\n );\n },\n async createModelFrom(modelId, userInput) {\n return context.benchmark.measure(\n \"headlessCms.crud.models.createModelFrom\",\n async () => {\n return createModelFrom(modelId, userInput);\n }\n );\n },\n async updateModel(modelId, input) {\n return context.benchmark.measure(\"headlessCms.crud.models.updateModel\", async () => {\n return updateModel(modelId, input);\n });\n },\n async deleteModel(modelId) {\n return context.benchmark.measure(\"headlessCms.crud.models.deleteModel\", async () => {\n return deleteModel(modelId);\n });\n },\n async initializeModel(modelId, data) {\n return context.benchmark.measure(\n \"headlessCms.crud.models.initializeModel\",\n async () => {\n return initializeModel(modelId, data);\n }\n );\n },\n getModelManager,\n getEntryManager: async model => {\n return getModelManager(model);\n },\n getManagers: () => managers,\n getEntryManagers: () => managers\n };\n};\n"],"mappings":";;;;;;;;;AAAA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAF,sBAAA,CAAAC,OAAA;AAuBA,IAAAE,eAAA,GAAAF,OAAA;AACA,IAAAG,2BAAA,GAAAH,OAAA;AAIA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,aAAA,GAAAL,OAAA;AACA,IAAAM,aAAA,GAAAN,OAAA;AACA,IAAAO,aAAA,GAAAP,OAAA;AACA,IAAAQ,YAAA,GAAAR,OAAA;AACA,IAAAS,YAAA,GAAAT,OAAA;AACA,IAAAU,YAAA,GAAAV,OAAA;AACA,IAAAW,gBAAA,GAAAX,OAAA;AACA,IAAAY,eAAA,GAAAZ,OAAA;AACA,IAAAa,YAAA,GAAAb,OAAA;AACA,IAAAc,WAAA,GAAAd,OAAA;AAKA,IAAAe,MAAA,GAAAf,OAAA;AACA,IAAAgB,cAAA,GAAAhB,OAAA;AACA,IAAAiB,aAAA,GAAAjB,OAAA;AAGmD,MAAAkB,SAAA;AAGnD;AACA;AACA;AACA,MAAMC,aAAa,GAAIC,KAA6B,IAAK;EACrD;EACA;EACA,MAAMC,IAAI,GAAGD,KAAK,CAACC,IAAI,IAAI,EAAE;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AAA,KAAM3I,QAAQ;IAC3B4I,gBAAgB,EAAEA,CAAA,KAAM5I;EAC5B,CAAC;AACL,CAAC;AAAC6I,OAAA,CAAA9K,gBAAA,GAAAA,gBAAA"}
@@ -45,6 +45,7 @@ const createModelGroupsCrud = params => {
45
45
  return [groups.concat(pluginsGroups)];
46
46
  })
47
47
  };
48
+ const listGroupsCache = new Map();
48
49
  const clearGroupsCache = () => {
49
50
  for (const loader of Object.values(dataLoaders)) {
50
51
  loader.clearAll();
@@ -84,16 +85,11 @@ const createModelGroupsCrud = params => {
84
85
  }
85
86
  return group;
86
87
  };
87
- const listGroupsViaDataLoader = async params => {
88
- const {
89
- where
90
- } = params || {};
88
+ const listGroupsViaDataLoader = async () => {
91
89
  try {
92
90
  return await dataLoaders.listGroups.load("listGroups");
93
91
  } catch (ex) {
94
- throw new _error.default(ex.message, ex.code || "LIST_ERROR", (0, _objectSpread2.default)((0, _objectSpread2.default)({}, ex.data || {}), {}, {
95
- where
96
- }));
92
+ throw new _error.default(ex.message, ex.code || "LIST_ERROR", (0, _objectSpread2.default)({}, ex.data || {}));
97
93
  }
98
94
  };
99
95
 
@@ -150,6 +146,7 @@ const createModelGroupsCrud = params => {
150
146
  return group;
151
147
  };
152
148
  const listGroups = async params => {
149
+ var _getIdentity;
153
150
  const {
154
151
  where
155
152
  } = params || {};
@@ -160,25 +157,38 @@ const createModelGroupsCrud = params => {
160
157
  await modelGroupsPermissions.ensure({
161
158
  rwd: "r"
162
159
  });
163
- const response = await listGroupsViaDataLoader((0, _objectSpread2.default)((0, _objectSpread2.default)({}, params || {}), {}, {
164
- where: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, where || {}), {}, {
165
- tenant: tenant || getTenant().id,
166
- locale: locale || getLocale().code
167
- })
168
- }));
169
- return (0, _filterAsync.filterAsync)(response, async group => {
170
- const ownsGroup = await modelGroupsPermissions.ensure({
171
- owns: group.createdBy
172
- }, {
173
- throw: false
174
- });
175
- if (!ownsGroup) {
176
- return false;
177
- }
178
- return await modelGroupsPermissions.canAccessGroup({
179
- group
180
- });
160
+
161
+ /**
162
+ * Maybe we can cache based on permissions, not the identity id?
163
+ *
164
+ * TODO: @adrian please check if possible.
165
+ */
166
+ const key = JSON.stringify({
167
+ tenant: tenant || getTenant().id,
168
+ locale: locale || getLocale().code,
169
+ identity: context.security.isAuthorizationEnabled() ? (_getIdentity = getIdentity()) === null || _getIdentity === void 0 ? void 0 : _getIdentity.id : undefined
181
170
  });
171
+ if (listGroupsCache.has(key)) {
172
+ return listGroupsCache.get(key);
173
+ }
174
+ const cached = async () => {
175
+ const response = await listGroupsViaDataLoader();
176
+ return (0, _filterAsync.filterAsync)(response, async group => {
177
+ const ownsGroup = await modelGroupsPermissions.ensure({
178
+ owns: group.createdBy
179
+ }, {
180
+ throw: false
181
+ });
182
+ if (!ownsGroup) {
183
+ return false;
184
+ }
185
+ return await modelGroupsPermissions.canAccessGroup({
186
+ group
187
+ });
188
+ });
189
+ };
190
+ listGroupsCache.set(key, cached());
191
+ return listGroupsCache.get(key);
182
192
  };
183
193
  const createGroup = async input => {
184
194
  await modelGroupsPermissions.ensure({
@@ -1 +1 @@
1
- {"version":3,"names":["_dataloader","_interopRequireDefault","require","_error","_handlerGraphql","_CmsGroupPlugin","_pubsub","_beforeUpdate","_beforeCreate","_beforeDelete","_validation","_utils","_filterAsync","createModelGroupsCrud","params","getTenant","getIdentity","getLocale","storageOperations","modelGroupsPermissions","context","dataLoaders","listGroups","DataLoader","tenant","id","locale","code","pluginsGroups","getGroupsAsPlugins","map","group","_objectSpread2","default","groups","list","where","concat","clearGroupsCache","loader","Object","values","clearAll","plugins","byType","CmsGroupPlugin","type","filter","plugin","t","l","contentModelGroup","webinyVersion","WEBINY_VERSION","getGroupViaDataLoader","load","find","g","NotFoundError","listGroupsViaDataLoader","ex","WebinyError","message","data","onGroupBeforeCreate","createTopic","onGroupAfterCreate","onGroupCreateError","onGroupBeforeUpdate","onGroupAfterUpdate","onGroupUpdateError","onGroupBeforeDelete","onGroupAfterDelete","onGroupDeleteError","assignBeforeGroupCreate","assignBeforeGroupUpdate","assignBeforeGroupDelete","getGroup","ensure","rwd","owns","createdBy","ensureCanAccessGroup","response","filterAsync","ownsGroup","throw","canAccessGroup","createGroup","input","result","createGroupCreateValidation","safeParseAsync","success","createZodError","error","identity","mdbid","createdOn","Date","toISOString","savedOn","displayName","publish","create","updateGroup","original","createGroupUpdateValidation","keys","length","updatedGroup","update","deleteGroup","delete","onBeforeGroupCreate","onAfterGroupCreate","onBeforeGroupUpdate","onAfterGroupUpdate","onBeforeGroupDelete","onAfterGroupDelete","benchmark","measure","exports"],"sources":["contentModelGroup.crud.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport WebinyError from \"@webiny/error\";\nimport {\n CmsContext,\n CmsGroup,\n CmsGroupContext,\n CmsGroupListParams,\n HeadlessCmsStorageOperations,\n OnGroupAfterCreateTopicParams,\n OnGroupAfterDeleteTopicParams,\n OnGroupAfterUpdateTopicParams,\n OnGroupBeforeCreateTopicParams,\n OnGroupBeforeDeleteTopicParams,\n OnGroupBeforeUpdateTopicParams,\n OnGroupCreateErrorTopicParams,\n OnGroupDeleteErrorTopicParams,\n OnGroupUpdateErrorTopicParams\n} from \"~/types\";\nimport { NotFoundError } from \"@webiny/handler-graphql\";\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 { ModelGroupsPermissions } from \"~/utils/permissions/ModelGroupsPermissions\";\nimport { filterAsync } from \"~/utils/filterAsync\";\n\nexport interface CreateModelGroupsCrudParams {\n getTenant: () => Tenant;\n getLocale: () => I18NLocale;\n storageOperations: HeadlessCmsStorageOperations;\n modelGroupsPermissions: ModelGroupsPermissions;\n context: CmsContext;\n getIdentity: () => SecurityIdentity;\n}\n\nexport const createModelGroupsCrud = (params: CreateModelGroupsCrudParams): CmsGroupContext => {\n const {\n getTenant,\n getIdentity,\n getLocale,\n storageOperations,\n modelGroupsPermissions,\n context\n } = params;\n\n const dataLoaders = {\n listGroups: new DataLoader(async () => {\n const tenant = getTenant().id;\n const locale = getLocale().code;\n\n const pluginsGroups = getGroupsAsPlugins().map(group => {\n return {\n ...group,\n tenant: group.tenant || tenant,\n locale: group.locale || locale\n };\n });\n\n const groups = await storageOperations.groups.list({\n where: {\n tenant: getTenant().id,\n locale: getLocale().code\n }\n });\n\n return [groups.concat(pluginsGroups)];\n })\n };\n\n const clearGroupsCache = (): void => {\n for (const loader of Object.values(dataLoaders)) {\n loader.clearAll();\n }\n };\n\n const getGroupsAsPlugins = (): CmsGroup[] => {\n const tenant = getTenant().id;\n const locale = getLocale().code;\n\n return (\n context.plugins\n .byType<CmsGroupPlugin>(CmsGroupPlugin.type)\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 );\n };\n\n const getGroupViaDataLoader = async (id: string) => {\n const groups = await dataLoaders.listGroups.load(\"listGroups\");\n\n const group = groups.find(g => g.id === id);\n\n if (!group) {\n throw new NotFoundError(`Cms Group \"${id}\" was not found!`);\n }\n return group;\n };\n\n const listGroupsViaDataLoader = async (params: CmsGroupListParams) => {\n const { where } = params || {};\n\n try {\n return await dataLoaders.listGroups.load(\"listGroups\");\n } catch (ex) {\n throw new WebinyError(ex.message, ex.code || \"LIST_ERROR\", {\n ...(ex.data || {}),\n where\n });\n }\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 modelGroupsPermissions.ensure({ rwd: \"r\" });\n\n const group = await getGroupViaDataLoader(id);\n\n await modelGroupsPermissions.ensure({ owns: group.createdBy });\n await modelGroupsPermissions.ensureCanAccessGroup({\n group\n });\n\n return group;\n };\n const listGroups: CmsGroupContext[\"listGroups\"] = async params => {\n const { where } = params || {};\n\n const { tenant, locale } = where || {};\n\n await modelGroupsPermissions.ensure({ rwd: \"r\" });\n\n const response = await listGroupsViaDataLoader({\n ...(params || {}),\n where: {\n ...(where || {}),\n tenant: tenant || getTenant().id,\n locale: locale || getLocale().code\n }\n });\n\n return filterAsync(response, async group => {\n const ownsGroup = await modelGroupsPermissions.ensure(\n { owns: group.createdBy },\n { throw: false }\n );\n\n if (!ownsGroup) {\n return false;\n }\n\n return await modelGroupsPermissions.canAccessGroup({\n group\n });\n });\n };\n const createGroup: CmsGroupContext[\"createGroup\"] = async input => {\n await modelGroupsPermissions.ensure({ 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 = 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 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 modelGroupsPermissions.ensure({ rwd: \"w\" });\n\n const original = await getGroupViaDataLoader(id);\n\n await modelGroupsPermissions.ensure({ owns: original.createdBy });\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 modelGroupsPermissions.ensure({ rwd: \"d\" });\n\n const group = await getGroupViaDataLoader(id);\n\n await modelGroupsPermissions.ensure({ owns: group.createdBy });\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 /**\n * Deprecated - will be removed in 5.36.0\n */\n onBeforeGroupCreate: onGroupBeforeCreate,\n onAfterGroupCreate: onGroupAfterCreate,\n onBeforeGroupUpdate: onGroupBeforeUpdate,\n onAfterGroupUpdate: onGroupAfterUpdate,\n onBeforeGroupDelete: onGroupBeforeDelete,\n onAfterGroupDelete: onGroupAfterDelete,\n /**\n * Released in 5.34.0\n */\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,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAF,sBAAA,CAAAC,OAAA;AAiBA,IAAAE,eAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AAIA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,aAAA,GAAAL,OAAA;AACA,IAAAM,aAAA,GAAAN,OAAA;AACA,IAAAO,aAAA,GAAAP,OAAA;AACA,IAAAQ,WAAA,GAAAR,OAAA;AAIA,IAAAS,MAAA,GAAAT,OAAA;AAEA,IAAAU,YAAA,GAAAV,OAAA;AAWO,MAAMW,qBAAqB,GAAIC,MAAmC,IAAsB;EAC3F,MAAM;IACFC,SAAS;IACTC,WAAW;IACXC,SAAS;IACTC,iBAAiB;IACjBC,sBAAsB;IACtBC;EACJ,CAAC,GAAGN,MAAM;EAEV,MAAMO,WAAW,GAAG;IAChBC,UAAU,EAAE,IAAIC,mBAAU,CAAC,YAAY;MACnC,MAAMC,MAAM,GAAGT,SAAS,CAAC,CAAC,CAACU,EAAE;MAC7B,MAAMC,MAAM,GAAGT,SAAS,CAAC,CAAC,CAACU,IAAI;MAE/B,MAAMC,aAAa,GAAGC,kBAAkB,CAAC,CAAC,CAACC,GAAG,CAACC,KAAK,IAAI;QACpD,WAAAC,cAAA,CAAAC,OAAA,MAAAD,cAAA,CAAAC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AACC,KAAK,CAAC;MAC7B,CAAC,CAAC;IACN,CAAC;IACDgB,WAAW,EAAE,MAAAA,CAAOhF,EAAE,EAAEgE,KAAK,KAAK;MAC9B,OAAOrE,OAAO,CAACoG,SAAS,CAACC,OAAO,CAAC,qCAAqC,EAAE,YAAY;QAChF,OAAOhB,WAAW,CAAChF,EAAE,EAAEgE,KAAK,CAAC;MACjC,CAAC,CAAC;IACN,CAAC;IACDuB,WAAW,EAAE,MAAMvF,EAAE,IAAI;MACrB,OAAOL,OAAO,CAACoG,SAAS,CAACC,OAAO,CAAC,qCAAqC,EAAE,YAAY;QAChF,OAAOT,WAAW,CAACvF,EAAE,CAAC;MAC1B,CAAC,CAAC;IACN;EACJ,CAAC;AACL,CAAC;AAACiG,OAAA,CAAA7G,qBAAA,GAAAA,qBAAA"}
1
+ {"version":3,"names":["_dataloader","_interopRequireDefault","require","_error","_handlerGraphql","_CmsGroupPlugin","_pubsub","_beforeUpdate","_beforeCreate","_beforeDelete","_validation","_utils","_filterAsync","createModelGroupsCrud","params","getTenant","getIdentity","getLocale","storageOperations","modelGroupsPermissions","context","dataLoaders","listGroups","DataLoader","tenant","id","locale","code","pluginsGroups","getGroupsAsPlugins","map","group","_objectSpread2","default","groups","list","where","concat","listGroupsCache","Map","clearGroupsCache","loader","Object","values","clearAll","plugins","byType","CmsGroupPlugin","type","filter","plugin","t","l","contentModelGroup","webinyVersion","WEBINY_VERSION","getGroupViaDataLoader","load","find","g","NotFoundError","listGroupsViaDataLoader","ex","WebinyError","message","data","onGroupBeforeCreate","createTopic","onGroupAfterCreate","onGroupCreateError","onGroupBeforeUpdate","onGroupAfterUpdate","onGroupUpdateError","onGroupBeforeDelete","onGroupAfterDelete","onGroupDeleteError","assignBeforeGroupCreate","assignBeforeGroupUpdate","assignBeforeGroupDelete","getGroup","ensure","rwd","owns","createdBy","ensureCanAccessGroup","_getIdentity","key","JSON","stringify","identity","security","isAuthorizationEnabled","undefined","has","get","cached","response","filterAsync","ownsGroup","throw","canAccessGroup","set","createGroup","input","result","createGroupCreateValidation","safeParseAsync","success","createZodError","error","mdbid","createdOn","Date","toISOString","savedOn","displayName","publish","create","updateGroup","original","createGroupUpdateValidation","keys","length","updatedGroup","update","deleteGroup","delete","onBeforeGroupCreate","onAfterGroupCreate","onBeforeGroupUpdate","onAfterGroupUpdate","onBeforeGroupDelete","onAfterGroupDelete","benchmark","measure","exports"],"sources":["contentModelGroup.crud.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport WebinyError from \"@webiny/error\";\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 { NotFoundError } from \"@webiny/handler-graphql\";\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 { ModelGroupsPermissions } from \"~/utils/permissions/ModelGroupsPermissions\";\nimport { filterAsync } from \"~/utils/filterAsync\";\n\nexport interface CreateModelGroupsCrudParams {\n getTenant: () => Tenant;\n getLocale: () => I18NLocale;\n storageOperations: HeadlessCmsStorageOperations;\n modelGroupsPermissions: ModelGroupsPermissions;\n context: CmsContext;\n getIdentity: () => SecurityIdentity;\n}\n\nexport const createModelGroupsCrud = (params: CreateModelGroupsCrudParams): CmsGroupContext => {\n const {\n getTenant,\n getIdentity,\n getLocale,\n storageOperations,\n modelGroupsPermissions,\n context\n } = params;\n\n const dataLoaders = {\n listGroups: new DataLoader(async () => {\n const tenant = getTenant().id;\n const locale = getLocale().code;\n\n const pluginsGroups = getGroupsAsPlugins().map(group => {\n return {\n ...group,\n tenant: group.tenant || tenant,\n locale: group.locale || locale\n };\n });\n\n const groups = await storageOperations.groups.list({\n where: {\n tenant: getTenant().id,\n locale: getLocale().code\n }\n });\n\n return [groups.concat(pluginsGroups)];\n })\n };\n\n const listGroupsCache = new Map<string, Promise<CmsGroup[]>>();\n const clearGroupsCache = (): void => {\n for (const loader of Object.values(dataLoaders)) {\n loader.clearAll();\n }\n };\n\n const getGroupsAsPlugins = (): CmsGroup[] => {\n const tenant = getTenant().id;\n const locale = getLocale().code;\n\n return (\n context.plugins\n .byType<CmsGroupPlugin>(CmsGroupPlugin.type)\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 );\n };\n\n const getGroupViaDataLoader = async (id: string) => {\n const groups = await dataLoaders.listGroups.load(\"listGroups\");\n\n const group = groups.find(g => g.id === id);\n\n if (!group) {\n throw new NotFoundError(`Cms Group \"${id}\" was not found!`);\n }\n return group;\n };\n\n const listGroupsViaDataLoader = async () => {\n try {\n return await dataLoaders.listGroups.load(\"listGroups\");\n } catch (ex) {\n throw new WebinyError(ex.message, ex.code || \"LIST_ERROR\", {\n ...(ex.data || {})\n });\n }\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 modelGroupsPermissions.ensure({ rwd: \"r\" });\n\n const group = await getGroupViaDataLoader(id);\n\n await modelGroupsPermissions.ensure({ owns: group.createdBy });\n await modelGroupsPermissions.ensureCanAccessGroup({\n group\n });\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 modelGroupsPermissions.ensure({ rwd: \"r\" });\n\n /**\n * Maybe we can cache based on permissions, not the identity id?\n *\n * TODO: @adrian please check if possible.\n */\n const key = JSON.stringify({\n tenant: tenant || getTenant().id,\n locale: locale || getLocale().code,\n identity: context.security.isAuthorizationEnabled() ? getIdentity()?.id : undefined\n });\n if (listGroupsCache.has(key)) {\n return listGroupsCache.get(key) as Promise<CmsGroup[]>;\n }\n\n const cached = async () => {\n const response = await listGroupsViaDataLoader();\n\n return filterAsync(response, async group => {\n const ownsGroup = await modelGroupsPermissions.ensure(\n { owns: group.createdBy },\n { throw: false }\n );\n\n if (!ownsGroup) {\n return false;\n }\n\n return await modelGroupsPermissions.canAccessGroup({\n group\n });\n });\n };\n\n listGroupsCache.set(key, cached());\n\n return listGroupsCache.get(key) as Promise<CmsGroup[]>;\n };\n\n const createGroup: CmsGroupContext[\"createGroup\"] = async input => {\n await modelGroupsPermissions.ensure({ 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 = 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 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 modelGroupsPermissions.ensure({ rwd: \"w\" });\n\n const original = await getGroupViaDataLoader(id);\n\n await modelGroupsPermissions.ensure({ owns: original.createdBy });\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 modelGroupsPermissions.ensure({ rwd: \"d\" });\n\n const group = await getGroupViaDataLoader(id);\n\n await modelGroupsPermissions.ensure({ owns: group.createdBy });\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 /**\n * Deprecated - will be removed in 5.36.0\n */\n onBeforeGroupCreate: onGroupBeforeCreate,\n onAfterGroupCreate: onGroupAfterCreate,\n onBeforeGroupUpdate: onGroupBeforeUpdate,\n onAfterGroupUpdate: onGroupAfterUpdate,\n onBeforeGroupDelete: onGroupBeforeDelete,\n onAfterGroupDelete: onGroupAfterDelete,\n /**\n * Released in 5.34.0\n */\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,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAF,sBAAA,CAAAC,OAAA;AAgBA,IAAAE,eAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AAIA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,aAAA,GAAAL,OAAA;AACA,IAAAM,aAAA,GAAAN,OAAA;AACA,IAAAO,aAAA,GAAAP,OAAA;AACA,IAAAQ,WAAA,GAAAR,OAAA;AAIA,IAAAS,MAAA,GAAAT,OAAA;AAEA,IAAAU,YAAA,GAAAV,OAAA;AAWO,MAAMW,qBAAqB,GAAIC,MAAmC,IAAsB;EAC3F,MAAM;IACFC,SAAS;IACTC,WAAW;IACXC,SAAS;IACTC,iBAAiB;IACjBC,sBAAsB;IACtBC;EACJ,CAAC,GAAGN,MAAM;EAEV,MAAMO,WAAW,GAAG;IAChBC,UAAU,EAAE,IAAIC,mBAAU,CAAC,YAAY;MACnC,MAAMC,MAAM,GAAGT,SAAS,CAAC,CAAC,CAACU,EAAE;MAC7B,MAAMC,MAAM,GAAGT,SAAS,CAAC,CAAC,CAACU,IAAI;MAE/B,MAAMC,aAAa,GAAGC,kBAAkB,CAAC,CAAC,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,OAAO,CAAC,kCAAkC,EAAE,YAAY;QAC7E,OAAOvD,QAAQ,CAACtD,EAAE,CAAC;MACvB,CAAC,CAAC;IACN,CAAC;IACDH,UAAU,EAAE,MAAMR,MAAM,IAAI;MACxB,OAAOM,OAAO,CAACiH,SAAS,CAACC,OAAO,CAAC,oCAAoC,EAAE,YAAY;QAC/E,OAAOhH,UAAU,CAACR,MAAM,CAAC;MAC7B,CAAC,CAAC;IACN,CAAC;IACDwF,WAAW,EAAE,MAAMC,KAAK,IAAI;MACxB,OAAOnF,OAAO,CAACiH,SAAS,CAACC,OAAO,CAAC,qCAAqC,EAAE,YAAY;QAChF,OAAOhC,WAAW,CAACC,KAAK,CAAC;MAC7B,CAAC,CAAC;IACN,CAAC;IACDe,WAAW,EAAE,MAAAA,CAAO7F,EAAE,EAAE8E,KAAK,KAAK;MAC9B,OAAOnF,OAAO,CAACiH,SAAS,CAACC,OAAO,CAAC,qCAAqC,EAAE,YAAY;QAChF,OAAOhB,WAAW,CAAC7F,EAAE,EAAE8E,KAAK,CAAC;MACjC,CAAC,CAAC;IACN,CAAC;IACDsB,WAAW,EAAE,MAAMpG,EAAE,IAAI;MACrB,OAAOL,OAAO,CAACiH,SAAS,CAACC,OAAO,CAAC,qCAAqC,EAAE,YAAY;QAChF,OAAOT,WAAW,CAACpG,EAAE,CAAC;MAC1B,CAAC,CAAC;IACN;EACJ,CAAC;AACL,CAAC;AAAC8G,OAAA,CAAA1H,qBAAA,GAAAA,qBAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-headless-cms",
3
- "version": "5.37.7-beta.0",
3
+ "version": "5.37.8-beta.0",
4
4
  "main": "index.js",
5
5
  "keywords": [
6
6
  "cms:base"
@@ -20,19 +20,19 @@
20
20
  "dependencies": {
21
21
  "@babel/runtime": "7.22.6",
22
22
  "@graphql-tools/schema": "7.1.5",
23
- "@webiny/api": "5.37.7-beta.0",
24
- "@webiny/api-i18n": "5.37.7-beta.0",
25
- "@webiny/api-security": "5.37.7-beta.0",
26
- "@webiny/api-tenancy": "5.37.7-beta.0",
27
- "@webiny/error": "5.37.7-beta.0",
28
- "@webiny/handler": "5.37.7-beta.0",
29
- "@webiny/handler-aws": "5.37.7-beta.0",
30
- "@webiny/handler-db": "5.37.7-beta.0",
31
- "@webiny/handler-graphql": "5.37.7-beta.0",
32
- "@webiny/plugins": "5.37.7-beta.0",
33
- "@webiny/pubsub": "5.37.7-beta.0",
34
- "@webiny/utils": "5.37.7-beta.0",
35
- "@webiny/validation": "5.37.7-beta.0",
23
+ "@webiny/api": "5.37.8-beta.0",
24
+ "@webiny/api-i18n": "5.37.8-beta.0",
25
+ "@webiny/api-security": "5.37.8-beta.0",
26
+ "@webiny/api-tenancy": "5.37.8-beta.0",
27
+ "@webiny/error": "5.37.8-beta.0",
28
+ "@webiny/handler": "5.37.8-beta.0",
29
+ "@webiny/handler-aws": "5.37.8-beta.0",
30
+ "@webiny/handler-db": "5.37.8-beta.0",
31
+ "@webiny/handler-graphql": "5.37.8-beta.0",
32
+ "@webiny/plugins": "5.37.8-beta.0",
33
+ "@webiny/pubsub": "5.37.8-beta.0",
34
+ "@webiny/utils": "5.37.8-beta.0",
35
+ "@webiny/validation": "5.37.8-beta.0",
36
36
  "code-frame": "5.0.0",
37
37
  "dataloader": "2.2.1",
38
38
  "dot-prop": "6.0.1",
@@ -49,9 +49,9 @@
49
49
  "@babel/cli": "7.22.6",
50
50
  "@babel/core": "7.22.8",
51
51
  "@babel/preset-env": "7.22.7",
52
- "@webiny/api-wcp": "5.37.7-beta.0",
53
- "@webiny/cli": "5.37.7-beta.0",
54
- "@webiny/project-utils": "5.37.7-beta.0",
52
+ "@webiny/api-wcp": "5.37.8-beta.0",
53
+ "@webiny/cli": "5.37.8-beta.0",
54
+ "@webiny/project-utils": "5.37.8-beta.0",
55
55
  "apollo-graphql": "0.9.7",
56
56
  "get-yarn-workspaces": "1.0.2",
57
57
  "graphql": "15.8.0",
@@ -71,5 +71,5 @@
71
71
  "build": "yarn webiny run build",
72
72
  "watch": "yarn webiny run watch"
73
73
  },
74
- "gitHead": "115054c51d8e6699eed34ab574ae30cb6a716be0"
74
+ "gitHead": "7af94ec35e4614ac89549a544352fd2ceba1ba42"
75
75
  }
package/types.d.ts CHANGED
@@ -1037,7 +1037,6 @@ export interface CmsGroupListParams {
1037
1037
  where: {
1038
1038
  tenant: string;
1039
1039
  locale: string;
1040
- [key: string]: any;
1041
1040
  };
1042
1041
  }
1043
1042
  /**
package/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["CONTENT_ENTRY_STATUS","exports"],"sources":["types.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins/types\";\nimport { I18NContext, I18NLocale } from \"@webiny/api-i18n/types\";\nimport { Context } from \"@webiny/api/types\";\nimport {\n GraphQLFieldResolver,\n GraphQLSchemaDefinition,\n Resolvers\n} from \"@webiny/handler-graphql/types\";\nimport { SecurityPermission } from \"@webiny/api-security/types\";\nimport { DbContext } from \"@webiny/handler-db/types\";\nimport { Topic } from \"@webiny/pubsub/types\";\nimport { CmsModelConverterCallable } from \"~/utils/converters/ConverterCollection\";\nimport { ModelGroupsPermissions } from \"~/utils/permissions/ModelGroupsPermissions\";\nimport { ModelsPermissions } from \"~/utils/permissions/ModelsPermissions\";\nimport { EntriesPermissions } from \"~/utils/permissions/EntriesPermissions\";\nimport { SettingsPermissions } from \"~/utils/permissions/SettingsPermissions\";\n\nexport type ApiEndpoint = \"manage\" | \"preview\" | \"read\";\n\ninterface HeadlessCmsPermissions {\n groups: ModelGroupsPermissions;\n models: ModelsPermissions;\n entries: EntriesPermissions;\n settings: SettingsPermissions;\n}\n\nexport interface HeadlessCms\n extends CmsSettingsContext,\n CmsSystemContext,\n CmsGroupContext,\n CmsModelContext,\n CmsEntryContext {\n /**\n * API type\n */\n type: ApiEndpoint | null;\n /**\n * Requested locale\n */\n locale: string;\n /**\n * returns an instance of current locale\n */\n getLocale: () => I18NLocale;\n /**\n * Means this request is a READ API\n */\n READ: boolean;\n /**\n * Means this request is a MANAGE API\n */\n MANAGE: boolean;\n /**\n * Means this request is a PREVIEW API\n */\n PREVIEW: boolean;\n /**\n * The storage operations loaded for current context.\n */\n storageOperations: HeadlessCmsStorageOperations;\n /**\n * Permissions for settings, groups, models and entries.\n *\n * @internal\n */\n permissions: HeadlessCmsPermissions;\n}\n\n/**\n * @description This combines all contexts used in the CMS into a single one.\n *\n * @category Context\n */\nexport interface CmsContext extends Context, DbContext, I18NContext {\n cms: HeadlessCms;\n}\n\ninterface CmsModelFieldPredefinedValuesValue {\n value: string;\n label: string;\n /**\n * Default selected predefined value.\n */\n selected?: boolean;\n}\n\n/**\n * Object containing content model field predefined options and values.\n *\n * @category CmsModelField\n */\nexport interface CmsModelFieldPredefinedValues {\n /**\n * Are predefined field values enabled?\n */\n enabled: boolean;\n /**\n * Predefined values array.\n */\n values: CmsModelFieldPredefinedValuesValue[];\n}\n\n/**\n * Object containing content model field renderer options.\n *\n * @category CmsModelField\n */\ninterface CmsModelFieldRenderer {\n /**\n * Name of the field renderer. Must have one in field renderer plugins.\n * Can be blank to let automatically determine the renderer.\n */\n name: string;\n}\n\n/**\n * A definition for content model field settings.\n *\n * @category ModelField\n * @category Database model\n */\nexport interface CmsModelFieldSettings {\n /**\n * Predefined values (text, number)\n * The default value for the field in case it is not predefined values field.\n */\n defaultValue?: string | number | null | undefined;\n /**\n * Object field has child fields.\n */\n fields?: CmsModelField[];\n /**\n * Is the file field images only one?\n */\n imagesOnly?: boolean;\n /**\n * Object field has child fields - so it needs to have a layout.\n */\n layout?: string[][];\n /**\n * Ref field.\n */\n models?: Pick<CmsModel, \"modelId\">[];\n /**\n * Date field.\n */\n type?: string;\n /**\n * There are a lot of other settings that are possible to add, so we keep the type opened.\n */\n [key: string]: any;\n}\n\nexport type CmsModelFieldType =\n | \"boolean\"\n | \"datetime\"\n | \"file\"\n | \"long-text\"\n | \"number\"\n | \"object\"\n | \"ref\"\n | \"rich-text\"\n | \"text\"\n | \"dynamicZone\"\n | string;\n/**\n * A definition for content model field. This type exists on the app side as well.\n *\n * @category ModelField\n * @category Database model\n */\nexport interface CmsModelField {\n /**\n * A generated unique ID for the model field.\n * MUST be absolute unique throughout the models.\n * Must be in form of a-zA-Z0-9.\n *\n * We generate a unique id value when you're building a model via UI,\n * but when user is creating a model via a plugin it is up to them to be careful about this.\n */\n id: string;\n /**\n * A type of the field.\n * We are defining our built-in fields, so people know which are available by the default.\n */\n type: CmsModelFieldType;\n /**\n * A unique storage ID for storing actual values.\n * Must in form of a-zA-Z0-9@a-zA-Z0-9\n *\n * This is an auto-generated value: uses `id` and `type`\n *\n * This is used as path for the entry value.\n */\n storageId: `${string}@${string}` | string;\n /**\n * Field identifier for the model field that will be available to the outside world.\n * `storageId` is used as path (or column) to store the data.\n *\n * Must in form of a-zA-Z0-9.\n *\n * This value MUST be unique in the CmsModel.\n */\n fieldId: string;\n /**\n * A label for the field\n */\n label: string;\n /**\n * Text below the field to clarify what is it meant to be in the field value\n */\n helpText?: string | null;\n /**\n * Text to be displayed in the field\n */\n placeholderText?: string | null;\n /**\n * Are predefined values enabled? And list of them\n */\n predefinedValues?: CmsModelFieldPredefinedValues;\n /**\n * Field renderer. Blank if determined automatically.\n */\n renderer?: CmsModelFieldRenderer;\n /**\n * List of validations for the field\n *\n * @default []\n */\n validation?: CmsModelFieldValidation[];\n /**\n * List of validations for the list of values, when a field is set to accept a list of values.\n * These validations will be applied to the entire list, and `validation` (see above) will be applied\n * to each individual value in the list.\n *\n * @default []\n */\n listValidation?: CmsModelFieldValidation[];\n /**\n * Is this a multiple values field?\n *\n */\n multipleValues?: boolean;\n /**\n * Fields can be tagged to give them contextual meaning.\n */\n tags?: string[];\n /**\n * Any user defined settings.\n *\n * @default {}\n */\n settings?: CmsModelFieldSettings;\n}\n\nexport interface CmsDynamicZoneTemplate {\n id: string;\n name: string;\n gqlTypeName: string;\n description: string;\n icon: string;\n fields: CmsModelField[];\n layout: string[][];\n validation: CmsModelFieldValidation[];\n}\n\n/**\n * A definition for dynamic-zone field to show possible type of the field in settings.\n */\nexport interface CmsModelDynamicZoneField extends CmsModelField {\n /**\n * Settings object for the field. Contains `templates` property.\n */\n settings: {\n templates: CmsDynamicZoneTemplate[];\n };\n}\n\n/**\n * Used for our internal functionality.\n */\nexport interface CmsModelFieldWithParent extends CmsModelField {\n parent?: CmsModelFieldWithParent | null;\n}\n\nexport interface CmsModelDynamicZoneFieldWithParent extends CmsModelDynamicZoneField {\n parent?: CmsModelDynamicZoneFieldWithParent | null;\n}\n\n/**\n * A definition for dateTime field to show possible type of the field in settings.\n */\nexport interface CmsModelDateTimeField extends CmsModelField {\n /**\n * Settings object for the field. Contains `type` property.\n */\n settings: {\n type: \"time\" | \"date\" | \"dateTimeWithoutTimezone\" | \"dateTimeWithTimezone\";\n };\n}\n\n/**\n * Arguments for the field validator validate method.\n *\n * @category ModelField\n * @category FieldValidation\n */\nexport interface CmsModelFieldValidatorValidateParams<T = any> {\n /**\n * A value to be validated.\n */\n value: T;\n /**\n * Options from the CmsModelField validations.\n *\n * @see CmsModelField.validation\n * @see CmsModelField.listValidation\n */\n validator: CmsModelFieldValidation;\n /**\n * An instance of the current context.\n */\n context: CmsContext;\n /**\n * Field being validated.\n */\n field: CmsModelField;\n /**\n * An instance of the content model being validated.\n */\n model: CmsModel;\n /**\n * If entry is sent it means it is an update operation.\n * First usage is for the unique field value.\n */\n entry?: CmsEntry;\n}\n\n/**\n * Definition for the field validator.\n *\n * @category Plugin\n * @category ModelField\n * @category FieldValidation\n */\nexport interface CmsModelFieldValidatorPlugin extends Plugin {\n /**\n * A plugin type.\n */\n type: \"cms-model-field-validator\";\n /**\n * Actual validator definition.\n */\n validator: {\n /**\n * Name of the validator.\n */\n name: string;\n /**\n * Validation method.\n */\n validate(params: CmsModelFieldValidatorValidateParams): Promise<boolean>;\n };\n}\n\n/**\n * A pattern validator for the content entry field value.\n *\n * @category Plugin\n * @category ModelField\n * @category FieldValidation\n */\nexport interface CmsModelFieldPatternValidatorPlugin extends Plugin {\n /**\n * A plugin type\n */\n type: \"cms-model-field-validator-pattern\";\n /**\n * A pattern object for the validator.\n */\n pattern: {\n /**\n * name of the pattern.\n */\n name: string;\n /**\n * RegExp of the validator.\n */\n regex: string;\n /**\n * RegExp flags\n */\n flags: string;\n };\n}\n\n/**\n * Locked field in the content model\n *\n * @see CmsModel.lockedFields\n *\n * @category ModelField\n */\nexport interface LockedField {\n /**\n * Locked field storage ID - one used to store values.\n * We cannot change this due to old systems.\n */\n fieldId: string;\n /**\n * Is the field multiple values field?\n */\n multipleValues: boolean;\n /**\n * Field type.\n */\n type: string;\n [key: string]: any;\n}\n\n/**\n * @category Database model\n * @category CmsModel\n */\nexport interface CmsModelGroup {\n /**\n * Generated ID of the group\n */\n id: string;\n /**\n * Name of the group\n */\n name: string;\n}\n\n/**\n * Base CMS Model. Should not be exported and used outside of this package.\n *\n * @category Database model\n * @category CmsModel\n */\nexport interface CmsModel {\n /**\n * Name of the content model.\n */\n name: string;\n /**\n * Unique ID for the content model. Created from name if not defined by user.\n */\n modelId: string;\n /**\n * Name of the content model in singular form to be used in the API.\n * example:\n * - Article\n * - Fruit\n * - Vegetable\n * - Car\n */\n singularApiName: string;\n /**\n * Name of the content model in plural form to be used in the API.\n * example:\n * - Articles\n * - Fruits\n * - Vegetables\n * - Cars\n */\n pluralApiName: string;\n /**\n * Model tenant.\n */\n tenant: string;\n /**\n * Locale this model belongs to.\n */\n locale: string;\n /**\n * Cms Group reference object.\n */\n group: CmsModelGroup;\n /**\n * Icon for the content model.\n */\n icon?: string | null;\n /**\n * Description for the content model.\n */\n description: string | null;\n /**\n * Date created\n */\n createdOn?: string;\n /**\n * Date saved. Changes on both save and create.\n */\n savedOn?: string;\n /**\n * CreatedBy object wrapper. Contains id, name and type of the user.\n */\n createdBy?: CmsIdentity;\n /**\n * List of fields defining entry values.\n */\n fields: CmsModelField[];\n /**\n * Admin UI field layout\n *\n * ```ts\n * layout: [\n * [field1id, field2id],\n * [field3id]\n * ]\n * ```\n */\n layout: string[][];\n /**\n * Models can be tagged to give them contextual meaning.\n */\n tags?: string[];\n /**\n * List of locked fields. Updated when entry is saved and a field has been used.\n */\n lockedFields?: LockedField[];\n /**\n * The field that is being displayed as entry title.\n * It is picked as first available text field. Or user can select own field.\n */\n titleFieldId: string;\n /**\n * The field which is displayed as the description one.\n * Only way this is null or undefined is that there are no long-text fields to be set as description.\n */\n descriptionFieldId?: string | null;\n /**\n * The field which is displayed as the image.\n * Only way this is null or undefined is that there are no file fields, with images only set, to be set as image.\n */\n imageFieldId?: string | null;\n /**\n * The version of Webiny which this record was stored with.\n */\n webinyVersion: string;\n\n /**\n * Is model private?\n * This is meant to be used for some internal models - will not be visible in the schema.\n * Only available for the plugin constructed models.\n */\n isPrivate?: boolean;\n}\n\n/**\n * When sending model to the storage operations, it must contain createValueKeyToStorageConverter and createValueKeyFromStorageConverter\n *\n * @category CmsModel\n */\nexport interface StorageOperationsCmsModel extends CmsModel {\n convertValueKeyToStorage: CmsModelConverterCallable;\n convertValueKeyFromStorage: CmsModelConverterCallable;\n}\n\n/**\n * @category ModelField\n */\nexport interface CmsModelFieldDefinition {\n fields: string;\n typeDefs?: string;\n}\n\ninterface CmsModelFieldToGraphQLCreateResolverParams<TField> {\n models: CmsModel[];\n model: CmsModel;\n graphQLType: string;\n field: TField;\n createFieldResolvers: any;\n fieldTypePlugins: CmsFieldTypePlugins;\n}\n\nexport interface CmsModelFieldToGraphQLCreateResolver<TField = CmsModelField> {\n (params: CmsModelFieldToGraphQLCreateResolverParams<TField>):\n | GraphQLFieldResolver\n | { resolver: GraphQLFieldResolver | null; typeResolvers: Resolvers<CmsContext> }\n | false;\n}\n\nexport interface CmsModelFieldToGraphQLPluginValidateChildFieldsValidateParams<\n TField extends CmsModelField = CmsModelField\n> {\n fields: TField[];\n originalFields: TField[];\n}\n\nexport interface CmsModelFieldToGraphQLPluginValidateChildFieldsValidate {\n (params: CmsModelFieldToGraphQLPluginValidateChildFieldsValidateParams): void;\n}\n\nexport interface CmsModelFieldToGraphQLPluginValidateChildFieldsParams<\n TField extends CmsModelField = CmsModelField\n> {\n field: TField;\n originalField?: TField;\n validate: CmsModelFieldToGraphQLPluginValidateChildFieldsValidate;\n}\n\nexport interface CmsModelFieldToGraphQLPluginValidateChildFields<\n TField extends CmsModelField = CmsModelField\n> {\n (params: CmsModelFieldToGraphQLPluginValidateChildFieldsParams<TField>): void;\n}\n\n/**\n * @category Plugin\n * @category ModelField\n * @category GraphQL\n */\nexport interface CmsModelFieldToGraphQLPlugin<TField extends CmsModelField = CmsModelField>\n extends Plugin {\n /**\n * A plugin type\n */\n type: \"cms-model-field-to-graphql\";\n /**\n * Field type name which must be exact as the one in `CmsEditorFieldTypePlugin` plugin.\n *\n * ```ts\n * fieldType: \"myField\"\n * ```\n */\n fieldType: string;\n /**\n * Is the field searchable via the GraphQL?\n *\n * ```ts\n * isSearchable: false\n * ```\n */\n isSearchable: boolean;\n /**\n * Is the field searchable via full text search?\n *\n * Field is not full text searchable by default.\n * ```ts\n * fullTextSearch: false\n * ```\n */\n fullTextSearch?: boolean;\n /**\n * Is the field sortable via the GraphQL?\n *\n * ```ts\n * isSortable: true\n * ```\n */\n isSortable: boolean;\n /**\n * Optional method which creates the storageId.\n * Primary use is for the datetime field, but if users has some specific fields, they can customize the storageId to their needs.\n *\n * ```ts\n * createStorageId: ({field}) => {\n * if (field.settings.type === \"time) {\n * return `${field.type}_time@${field.id}`\n * }\n * // use default method\n * return undefined;\n * }\n * ```\n */\n createStorageId?: (params: {\n model: CmsModel;\n field: Omit<TField, \"storageId\"> & Partial<Pick<TField, \"storageId\">>;\n }) => string | null | undefined;\n /**\n * Read API methods.\n */\n read: {\n /**\n * Definition for get filtering for GraphQL.\n *\n * ```ts\n * read: {\n * createGetFilters({ field }) {\n * return `${field.fieldId}: MyField`;\n * }\n * }\n * ```\n */\n createGetFilters?(params: { field: TField }): string;\n /**\n * Definition for list filtering for GraphQL.\n *\n * ```ts\n * read: {\n * createListFilters({ field }) {\n * return `\n * ${field.fieldId}: MyType\n * ${field.fieldId}_not: MyType\n * ${field.fieldId}_in: [MyType]\n * ${field.fieldId}_not_in: [MyType]\n * `;\n * }\n * }\n * ```\n */\n createListFilters?(params: {\n model: Pick<CmsModel, \"singularApiName\">;\n field: TField;\n plugins: CmsFieldTypePlugins;\n }): string;\n /**\n * Definition of the field type for GraphQL - be aware if multiple values is selected.\n *\n * ```ts\n * read: {\n * createTypeField({ field }) {\n * if (field.multipleValues) {\n * return `${field.fieldId}: [MyFieldType]`;\n * }\n *\n * return `${field.fieldId}: MyField`;\n * }\n * }\n * ```\n */\n createTypeField(params: {\n models: CmsModel[];\n model: CmsModel;\n field: TField;\n fieldTypePlugins: CmsFieldTypePlugins;\n }): CmsModelFieldDefinition | string | null;\n /**\n * Definition for field resolver.\n * By default, it is simple return of the `instance.values[storageId]` but if required, users can define their own.\n *\n * ```ts\n * read: {\n * createResolver({ field }) {\n * return instance => {\n * return instance.values[field.storageId];\n * };\n * }\n * }\n * ```\n */\n createResolver?: CmsModelFieldToGraphQLCreateResolver<TField>;\n /**\n * Read API schema definitions for the field and resolvers for them.\n *\n * ```ts\n * read: {\n * createSchema() {\n * return {\n * typeDefs: `\n * myField {\n * id\n * date\n * }\n * `,\n * resolvers: {}\n * }\n * }\n * }\n * ```\n */\n createSchema?: (params: { models: CmsModel[] }) => GraphQLSchemaDefinition<CmsContext>;\n };\n manage: {\n /**\n * Definition for list filtering for GraphQL.\n *\n * ```ts\n * manage: {\n * createListFilters({ field }) {\n * return `\n * ${field.fieldId}: MyType\n * ${field.fieldId}_not: MyType\n * ${field.fieldId}_in: [MyType]\n * ${field.fieldId}_not_in: [MyType]\n * `;\n * }\n * }\n * ```\n */\n createListFilters?: (params: {\n model: Pick<CmsModel, \"singularApiName\">;\n field: TField;\n plugins: CmsFieldTypePlugins;\n }) => string;\n /**\n * Manage API schema definitions for the field and resolvers for them. Probably similar to `read.createSchema`.\n *\n * ```ts\n * createSchema() {\n * return {\n * typeDefs: `\n * myField {\n * id\n * date\n * }\n * `,\n * resolvers: {}\n * }\n * }\n * ```\n */\n createSchema?: (params: { models: CmsModel[] }) => GraphQLSchemaDefinition<CmsContext>;\n /**\n * Definition of the field type for GraphQL - be aware if multiple values is selected. Probably same as `read.createTypeField`.\n *\n * ```ts\n * manage: {\n * createTypeField({ field }) {\n * if (field.multipleValues) {\n * return field.fieldId + \": [MyType]\";\n * }\n *\n * return field.fieldId + \": MyType\";\n * }\n * }\n * ```\n */\n createTypeField: (params: {\n models: CmsModel[];\n model: CmsModel;\n field: TField;\n fieldTypePlugins: CmsFieldTypePlugins;\n }) => CmsModelFieldDefinition | string | null;\n /**\n * Definition for input GraphQL field type.\n *\n * ```ts\n * manage: {\n * createInputField({ field }) {\n * if (field.multipleValues) {\n * return field.fieldId + \": [MyField]\";\n * }\n *\n * return field.fieldId + \": MyField\";\n * }\n * }\n * ```\n */\n createInputField: (params: {\n models: CmsModel[];\n model: CmsModel;\n field: TField;\n fieldTypePlugins: CmsFieldTypePlugins;\n }) => CmsModelFieldDefinition | string | null;\n /**\n * Definition for field resolver.\n * By default, it is simple return of the `instance.values[storageId]` but if required, users can define their own.\n *\n * ```ts\n * manage: {\n * createResolver({ field }) {\n * return instance => {\n * return instance.values[field.storageId];\n * };\n * }\n * }\n * ```\n */\n createResolver?: CmsModelFieldToGraphQLCreateResolver<TField>;\n };\n /**\n *\n * @param field\n */\n validateChildFields?: CmsModelFieldToGraphQLPluginValidateChildFields<TField>;\n}\n\n/**\n * Check for content model locked field.\n * A custom plugin definable by the user.\n *\n * @category CmsModel\n * @category Plugin\n */\nexport interface CmsModelLockedFieldPlugin extends Plugin {\n /**\n * A plugin type\n */\n type: \"cms-model-locked-field\";\n /**\n * A unique identifier of the field type (text, number, json, myField, ...).\n */\n fieldType: string;\n /**\n * A method to check if field really is locked.\n */\n checkLockedField?: (params: { lockedField: LockedField; field: CmsModelField }) => void;\n /**\n * A method to get the locked field data.\n */\n getLockedFieldData?: (params: { field: CmsModelField }) => Record<string, any>;\n}\n\n/**\n * @category ModelField\n */\nexport interface CmsFieldTypePlugins {\n [key: string]: CmsModelFieldToGraphQLPlugin;\n}\n\n/**\n * An interface describing the reference to a user that created some data in the database.\n *\n * @category General\n */\nexport interface CmsIdentity {\n /**\n * ID if the user.\n */\n id: string;\n /**\n * Full name of the user.\n */\n displayName: string | null;\n /**\n * Type of the user (admin, user)\n */\n type: string;\n}\n\n/**\n * Representation of settings database model.\n *\n * @category Database model\n */\nexport interface CmsSettings {\n /**\n * Last content model change. Used to cache GraphQL schema.\n */\n contentModelLastChange: Date;\n /**\n * Settings tenant.\n */\n tenant: string;\n /**\n * Settings locale.\n */\n locale: string;\n}\n\n/**\n * Settings CRUD in context.\n *\n * @category Context\n */\nexport interface CmsSettingsContext {\n /**\n * Gets settings model from the database.\n */\n getSettings: () => Promise<CmsSettings | null>;\n /**\n * Updates settings model with a new date.\n */\n updateModelLastChange: () => Promise<void>;\n /**\n * Get the datetime when content model last changed.\n */\n getModelLastChange: () => Promise<Date | null>;\n}\n\nexport interface OnSystemBeforeInstallTopicParams {\n tenant: string;\n locale: string;\n}\n\nexport interface OnSystemAfterInstallTopicParams {\n tenant: string;\n locale: string;\n}\n\nexport interface OnSystemInstallErrorTopicParams {\n error: Error;\n tenant: string;\n locale: string;\n}\n\nexport type CmsSystemContext = {\n getSystemVersion: () => Promise<string | null>;\n setSystemVersion: (version: string) => Promise<void>;\n installSystem: () => Promise<void>;\n /**\n * Lifecycle events - deprecated\n */\n /**\n * @deprecated\n */\n onBeforeSystemInstall: Topic<OnSystemBeforeInstallTopicParams>;\n /**\n * @deprecated\n */\n onAfterSystemInstall: Topic<OnSystemAfterInstallTopicParams>;\n /**\n * Released in 5.34.0\n */\n onSystemBeforeInstall: Topic<OnSystemBeforeInstallTopicParams>;\n onSystemAfterInstall: Topic<OnSystemAfterInstallTopicParams>;\n onSystemInstallError: Topic<OnSystemInstallErrorTopicParams>;\n};\n\n/**\n * A GraphQL `params.data` parameter received when creating content model group.\n *\n * @category CmsGroup\n * @category GraphQL params\n */\nexport interface CmsGroupCreateInput {\n name: string;\n slug?: string;\n description?: string;\n icon: string;\n}\n\n/**\n * A GraphQL `params.data` parameter received when updating content model group.\n *\n * @category CmsGroup\n * @category GraphQL params\n */\nexport interface CmsGroupUpdateInput {\n name?: string;\n slug?: string;\n description?: string;\n icon?: string;\n}\n\n/**\n * A representation of content model group in the database.\n *\n * @category CmsGroup\n * @category Database model\n */\nexport interface CmsGroup {\n /**\n * Generated ID.\n */\n id: string;\n /**\n * Name of the group.\n */\n name: string;\n /**\n * Slug for the group. Must be unique.\n */\n slug: string;\n /**\n * Group tenant.\n */\n tenant: string;\n /**\n * Locale this group belongs to.\n */\n locale: string;\n /**\n * Description for the group.\n */\n description: string;\n /**\n * Icon for the group. In a form of \"ico/ico\".\n */\n icon: string;\n /**\n * CreatedBy reference object.\n */\n createdBy?: CmsIdentity;\n /**\n * Date group was created on.\n */\n createdOn?: string;\n /**\n * Date group was created or changed on.\n */\n savedOn?: string;\n /**\n * Which Webiny version was this record stored with.\n */\n webinyVersion: string;\n /**\n * Is group private?\n * This is meant to be used for some internal groups - will not be visible in the schema.\n * Only available for the plugin constructed groups.\n */\n isPrivate?: boolean;\n}\n\n/**\n * A `data.where` parameter received when listing content model groups.\n *\n * @category CmsGroup\n * @category GraphQL params\n */\nexport interface CmsGroupListParams {\n where: {\n tenant: string;\n locale: string;\n [key: string]: any;\n };\n}\n\n/**\n * @category CmsGroup\n * @category Topic\n */\nexport interface OnGroupBeforeCreateTopicParams {\n group: CmsGroup;\n}\n\n/**\n * @category CmsGroup\n * @category Topic\n */\nexport interface OnGroupAfterCreateTopicParams {\n group: CmsGroup;\n}\n\n/**\n * @category CmsGroup\n * @category Topic\n */\nexport interface OnGroupCreateErrorTopicParams {\n input: CmsGroupCreateInput;\n group: CmsGroup;\n error: Error;\n}\n\n/**\n * @category CmsGroup\n * @category Topic\n */\nexport interface OnGroupBeforeUpdateTopicParams {\n original: CmsGroup;\n group: CmsGroup;\n}\n\n/**\n * @category CmsGroup\n * @category Topic\n */\nexport interface OnGroupAfterUpdateTopicParams {\n original: CmsGroup;\n group: CmsGroup;\n}\n\n/**\n * @category CmsGroup\n * @category Topic\n */\nexport interface OnGroupUpdateErrorTopicParams {\n input: CmsGroupUpdateInput;\n original: CmsGroup;\n group: CmsGroup;\n error: Error;\n}\n\n/**\n * @category CmsGroup\n * @category Topic\n */\nexport interface OnGroupBeforeDeleteTopicParams {\n group: CmsGroup;\n}\n\n/**\n * @category CmsGroup\n * @category Topic\n */\nexport interface OnGroupAfterDeleteTopicParams {\n group: CmsGroup;\n}\n\n/**\n * @category CmsGroup\n * @category Topic\n */\nexport interface OnGroupDeleteErrorTopicParams {\n group: CmsGroup;\n error: Error;\n}\n\n/**\n * Cms Group in context.\n *\n * @category Context\n * @category CmsGroup\n */\nexport interface CmsGroupContext {\n /**\n * Gets content model group by given id.\n */\n getGroup: (id: string) => Promise<CmsGroup | null>;\n /**\n * List all content model groups. Filterable via params.\n */\n listGroups: (params?: CmsGroupListParams) => Promise<CmsGroup[]>;\n /**\n * Create a new content model group.\n */\n createGroup: (data: CmsGroupCreateInput) => Promise<CmsGroup>;\n /**\n * Update existing content model group.\n */\n updateGroup: (id: string, data: CmsGroupUpdateInput) => Promise<CmsGroup>;\n /**\n * Delete content model group by given id.\n */\n deleteGroup: (id: string) => Promise<boolean>;\n /**\n * Clear the cached groups.\n */\n clearGroupsCache: () => void;\n /**\n * Lifecycle events - deprecated\n */\n /**\n * @deprecated\n */\n onBeforeGroupCreate: Topic<OnGroupBeforeCreateTopicParams>;\n /**\n * @deprecated\n */\n onAfterGroupCreate: Topic<OnGroupAfterCreateTopicParams>;\n /**\n * @deprecated\n */\n onBeforeGroupUpdate: Topic<OnGroupBeforeUpdateTopicParams>;\n /**\n * @deprecated\n */\n onAfterGroupUpdate: Topic<OnGroupAfterUpdateTopicParams>;\n /**\n * @deprecated\n */\n onBeforeGroupDelete: Topic<OnGroupBeforeDeleteTopicParams>;\n /**\n * @deprecated\n */\n onAfterGroupDelete: Topic<OnGroupAfterDeleteTopicParams>;\n /**\n * Lifecycle events released in 5.33.0\n */\n onGroupBeforeCreate: Topic<OnGroupBeforeCreateTopicParams>;\n onGroupAfterCreate: Topic<OnGroupAfterCreateTopicParams>;\n onGroupCreateError: Topic<OnGroupCreateErrorTopicParams>;\n onGroupBeforeUpdate: Topic<OnGroupBeforeUpdateTopicParams>;\n onGroupAfterUpdate: Topic<OnGroupAfterUpdateTopicParams>;\n onGroupUpdateError: Topic<OnGroupUpdateErrorTopicParams>;\n onGroupBeforeDelete: Topic<OnGroupBeforeDeleteTopicParams>;\n onGroupAfterDelete: Topic<OnGroupAfterDeleteTopicParams>;\n onGroupDeleteError: Topic<OnGroupDeleteErrorTopicParams>;\n}\n\n/**\n * Definition for content model field validator.\n *\n * @category ModelField\n * @category FieldValidation\n */\nexport interface CmsModelFieldValidation {\n name: string;\n message: string;\n settings?: {\n value?: string | number;\n values?: string[];\n preset?: string;\n [key: string]: any;\n };\n}\n\n/**\n * A GraphQL `params.data` parameter received when creating content model.\n *\n * @category GraphQL params\n * @category CmsModel\n */\nexport interface CmsModelCreateInput {\n /**\n * Name of the content model.\n */\n name: string;\n /**\n * Singular name of the content model to be used in the API.\n */\n singularApiName: string;\n /**\n * Plural name of the content model to be used in the API.\n */\n pluralApiName: string;\n /**\n * Unique ID of the content model. Created from name if not sent by the user. Cannot be changed.\n */\n modelId?: string;\n /**\n * Description of the content model.\n */\n description?: string | null;\n /**\n * Group where to put the content model in.\n */\n group: string;\n /**\n * A list of content model fields to define the entry values.\n */\n fields?: CmsModelFieldInput[];\n /**\n * Admin UI field layout\n *\n * ```ts\n * layout: [\n * [field1id, field2id],\n * [field3id]\n * ]\n * ```\n */\n layout?: string[][];\n /**\n * Models can be tagged to give them contextual meaning.\n */\n tags?: string[];\n /**\n * Fields fieldId which are picked to represent the CMS entry.\n */\n titleFieldId?: string | null;\n descriptionFieldId?: string | null;\n imageFieldId?: string | null;\n}\n\n/**\n * A GraphQL `params.data` parameter received when creating content model from existing model.\n *\n * @category GraphQL params\n * @category CmsModel\n */\nexport interface CmsModelCreateFromInput extends CmsModelCreateInput {\n /**\n * Locale into which we want to clone the model into.\n */\n locale?: string;\n}\n\n/**\n * A definition for content model field received from the user.\n *\n * Input type for `CmsModelField`.\n * @see CmsModelField\n *\n * @category GraphQL params\n * @category ModelField\n */\nexport interface CmsModelFieldInput {\n /**\n * Generated ID.\n */\n id: string;\n /**\n * Type of the field. A plugin for the field must be defined.\n * @see CmsModelFieldToGraphQLPlugin\n */\n type: string;\n /**\n * Field outside world identifier for the field. Must be unique in the model.\n */\n fieldId: string;\n /**\n * Label for the field.\n */\n label: string;\n /**\n * Text to display below the field to help user what to write in the field.\n */\n helpText?: string | null;\n /**\n * Text to display in the field.\n */\n placeholderText?: string | null;\n /**\n * Fields can be tagged to give them contextual meaning.\n */\n tags?: string[];\n /**\n * Are multiple values allowed?\n */\n multipleValues?: boolean;\n /**\n * Predefined values options for the field. Check the reference for more information.\n */\n predefinedValues?: CmsModelFieldPredefinedValues;\n /**\n * Renderer options for the field. Check the reference for more information.\n */\n renderer?: CmsModelFieldRenderer;\n /**\n * List of validations for the field.\n */\n validation?: CmsModelFieldValidation[];\n /**\n * @see CmsModelField.listValidation\n */\n listValidation?: CmsModelFieldValidation[];\n /**\n * User defined settings.\n */\n settings?: Record<string, any>;\n}\n\n/**\n * A GraphQL `params.data` parameter received when updating content model.\n *\n * @category GraphQL params\n * @category CmsModel\n */\nexport interface CmsModelUpdateInput {\n /**\n * A new content model name.\n */\n name?: string;\n /**\n * A new singular name of the content model to be used in the API.\n */\n singularApiName?: string;\n /**\n * A new plural name of the content model to be used in the API.\n */\n pluralApiName?: string;\n /**\n * A group we want to move the model to.\n */\n group?: string;\n /**\n * A new description of the content model.\n */\n description?: string | null;\n /**\n * A list of content model fields to define the entry values.\n */\n fields: CmsModelFieldInput[];\n /**\n * Admin UI field layout\n *\n * ```ts\n * layout: [\n * [field1id, field2id],\n * [field3id]\n * ]\n * ```\n */\n layout: string[][];\n /**\n * Fields fieldId which are picked to represent the CMS entry.\n */\n titleFieldId?: string | null;\n descriptionFieldId?: string | null;\n imageFieldId?: string | null;\n}\n\n/**\n * A plugin to load a CmsModelManager.\n *\n * @see CmsModelManager\n *\n * @category Plugin\n * @category CmsModel\n * @category CmsEntry\n */\nexport interface ModelManagerPlugin extends Plugin {\n /**\n * A plugin type.\n */\n type: \"cms-content-model-manager\";\n /**\n * Specific model CmsModelManager loader. Can target exact modelId(s).\n * Be aware that if you define multiple plugins without `modelId`, last one will run.\n */\n modelId?: string[] | string;\n /**\n * Create a CmsModelManager for specific type - or new default one.\n * For reference in how is this plugin run check [contentModelManagerFactory](https://github.com/webiny/webiny-js/blob/f15676/packages/api-headless-cms/src/content/plugins/CRUD/contentModel/contentModelManagerFactory.ts)\n */\n create: (context: CmsContext, model: CmsModel) => Promise<CmsModelManager>;\n}\n\n/**\n * A content entry values definition for and from the database.\n *\n * @category Database model\n * @category CmsEntry\n */\nexport interface CmsEntryValues {\n [key: string]: any;\n}\n\n/**\n * A content entry definition for and from the database.\n *\n * @category Database model\n * @category CmsEntry\n */\nexport interface CmsEntry<T = CmsEntryValues> {\n /**\n * A version of the webiny this entry was created with.\n * This can be used when upgrading the system, so we know which entries to update.\n */\n webinyVersion: string;\n /**\n * Tenant id which is this entry for. Can be used in case of shared storage.\n */\n tenant: string;\n /**\n * Generated ID of the entry. It is shared across all the records in the database that represent a single entry.\n * So version 1, 2, ..., 2371 will have the same value in this field to link them together.\n */\n entryId: string;\n /**\n * Generated ID + version of the entry.\n */\n id: string;\n /**\n * CreatedBy object reference.\n */\n createdBy: CmsIdentity;\n /**\n * OwnedBy object reference. Can be different from CreatedBy.\n */\n ownedBy: CmsIdentity;\n /**\n * ModifiedBy object reference. Last person who modified the entry.\n */\n modifiedBy?: CmsIdentity | null;\n /**\n * A string of Date.toISOString() type.\n * Populated on creation.\n */\n createdOn: string;\n /**\n * A string of Date.toISOString() type.\n * Populated every time entry is saved.\n */\n savedOn: string;\n /**\n * Model ID of the definition for the entry.\n * @see CmsModel\n */\n modelId: string;\n /**\n * A locale of the entry.\n * @see I18NLocale.code\n */\n locale: string;\n /**\n * A string of Date.toISOString() type - if published.\n * Populated when entry is published.\n */\n publishedOn?: string;\n /**\n * A revision version of the entry.\n */\n version: number;\n /**\n * Is the entry locked?\n */\n locked: boolean;\n /**\n * Status type of the entry.\n */\n status: CmsEntryStatus;\n /**\n * A mapped storageId -> value object.\n *\n * @see CmsModelField\n */\n values: T;\n /**\n * Advanced Content Organization\n */\n location?: {\n folderId?: string | null;\n };\n /**\n * Settings for the given entry.\n *\n * Introduced with Advanced Publishing Workflow. Will always be inserted once this PR is merged.\n * Be aware that when accessing properties in it on old systems, it will break if not checked first.\n *\n * Available only on the Manage API in entry GraphQL type `meta.data` property.\n */\n meta?: {\n [key: string]: any;\n };\n}\n\nexport interface CmsStorageEntry extends CmsEntry {\n [key: string]: any;\n}\n\nexport interface CmsEntryUniqueValue {\n value: string;\n count: number;\n}\n\n/**\n * A definition for content model manager to be used in the code.\n * The default one uses `CmsEntryContext` methods internally, but devs can change to what every they want.\n *\n * @see CmsEntryContext\n *\n * @category Context\n * @category CmsEntry\n * @category CmsModel\n */\nexport interface CmsModelManager {\n /**\n * List only published entries in the content model.\n */\n listPublished: (params: CmsEntryListParams) => Promise<[CmsEntry[], CmsEntryMeta]>;\n /**\n * List latest entries in the content model. Used for administration.\n */\n listLatest: (params: CmsEntryListParams) => Promise<[CmsEntry[], CmsEntryMeta]>;\n /**\n * Get a list of published entries by the ID list.\n */\n getPublishedByIds: (ids: string[]) => Promise<CmsEntry[]>;\n /**\n * Get a list of the latest entries by the ID list.\n */\n getLatestByIds: (ids: string[]) => Promise<CmsEntry[]>;\n /**\n * Get an entry filtered by given params. Will always get one.\n */\n get: (id: string) => Promise<CmsEntry>;\n /**\n * Create an entry.\n */\n create: (data: CreateCmsEntryInput) => Promise<CmsEntry>;\n /**\n * Update an entry.\n */\n update: (id: string, data: UpdateCmsEntryInput) => Promise<CmsEntry>;\n /**\n * Delete an entry.\n */\n delete: (id: string) => Promise<void>;\n}\n\n/**\n * Create\n */\nexport interface OnModelBeforeCreateTopicParams {\n input: CmsModelCreateInput;\n model: CmsModel;\n}\n\nexport interface OnModelAfterCreateTopicParams {\n input: CmsModelCreateInput;\n model: CmsModel;\n}\n\nexport interface OnModelCreateErrorTopicParams {\n input: CmsModelCreateInput;\n model: CmsModel;\n error: Error;\n}\n\n/**\n * Create From / Clone\n */\nexport interface OnModelBeforeCreateFromTopicParams {\n input: CmsModelCreateInput;\n original: CmsModel;\n model: CmsModel;\n}\n\nexport interface OnModelAfterCreateFromTopicParams {\n input: CmsModelCreateInput;\n original: CmsModel;\n model: CmsModel;\n}\n\nexport interface OnModelCreateFromErrorParams {\n input: CmsModelCreateInput;\n original: CmsModel;\n model: CmsModel;\n error: Error;\n}\n\n/**\n * Update\n */\nexport interface OnModelBeforeUpdateTopicParams {\n input: CmsModelUpdateInput;\n original: CmsModel;\n model: CmsModel;\n}\n\nexport interface OnModelAfterUpdateTopicParams {\n input: CmsModelUpdateInput;\n original: CmsModel;\n model: CmsModel;\n}\n\nexport interface OnModelUpdateErrorTopicParams {\n input: CmsModelUpdateInput;\n original: CmsModel;\n model: CmsModel;\n error: Error;\n}\n\n/**\n * Delete\n */\nexport interface OnModelBeforeDeleteTopicParams {\n model: CmsModel;\n}\n\nexport interface OnModelAfterDeleteTopicParams {\n model: CmsModel;\n}\n\nexport interface OnModelDeleteErrorTopicParams {\n model: CmsModel;\n error: Error;\n}\n\n/**\n * Initialize\n */\nexport interface OnModelInitializeParams {\n model: CmsModel;\n data: Record<string, any>;\n}\n\n/**\n *\n */\nexport interface CmsModelUpdateDirectParams {\n model: CmsModel;\n original: CmsModel;\n}\n\n/**\n * Cms Model in the context.\n *\n * @category Context\n * @category CmsModel\n */\nexport interface CmsModelContext {\n /**\n * Get a single content model.\n */\n getModel: (modelId: string) => Promise<CmsModel | null>;\n /**\n * Get all content models.\n */\n listModels: () => Promise<CmsModel[]>;\n /**\n * Create a content model.\n */\n createModel: (data: CmsModelCreateInput) => Promise<CmsModel>;\n /**\n * Create a content model from the given model - clone.\n */\n createModelFrom: (modelId: string, data: CmsModelCreateFromInput) => Promise<CmsModel>;\n /**\n * Update content model without data validation. Used internally.\n * @hidden\n */\n updateModelDirect: (params: CmsModelUpdateDirectParams) => Promise<CmsModel>;\n /**\n * Update content model.\n */\n updateModel: (modelId: string, data: CmsModelUpdateInput) => Promise<CmsModel>;\n /**\n * Delete content model. Should not allow deletion if there are entries connected to it.\n */\n deleteModel: (modelId: string) => Promise<void>;\n /**\n * Possibility for users to trigger the model initialization.\n * They can hook into it and do what ever they want to.\n *\n * Primary idea behind this is creating the index, for the code models, in the ES.\n */\n initializeModel: (modelId: string, data: Record<string, any>) => Promise<boolean>;\n /**\n * Get an instance of CmsModelManager for given content modelId.\n *\n * @see CmsModelManager\n *\n * @deprecated use the getEntryManager() method instead\n */\n getModelManager: (model: CmsModel | string) => Promise<CmsModelManager>;\n getEntryManager: (model: CmsModel | string) => Promise<CmsModelManager>;\n /**\n * Get all content model managers mapped by modelId.\n * @see CmsModelManager\n * @deprecated use getEntryManagers instead\n */\n getManagers: () => Map<string, CmsModelManager>;\n getEntryManagers: () => Map<string, CmsModelManager>;\n /**\n * Clear all the model caches.\n */\n clearModelsCache: () => void;\n /**\n * Lifecycle events - deprecated.\n */\n /**\n * @deprecated\n */\n onBeforeModelCreate: Topic<OnModelBeforeCreateTopicParams>;\n /**\n * @deprecated\n */\n onAfterModelCreate: Topic<OnModelAfterCreateTopicParams>;\n /**\n * @deprecated\n */\n onBeforeModelCreateFrom: Topic<OnModelBeforeCreateFromTopicParams>;\n /**\n * @deprecated\n */\n onAfterModelCreateFrom: Topic<OnModelAfterCreateFromTopicParams>;\n /**\n * @deprecated\n */\n onBeforeModelUpdate: Topic<OnModelBeforeUpdateTopicParams>;\n /**\n * @deprecated\n */\n onAfterModelUpdate: Topic<OnModelAfterUpdateTopicParams>;\n /**\n * @deprecated\n */\n onBeforeModelDelete: Topic<OnModelBeforeDeleteTopicParams>;\n /**\n * @deprecated\n */\n onAfterModelDelete: Topic<OnModelAfterDeleteTopicParams>;\n /**\n * Lifecycle events - released in 5.33.0\n */\n onModelBeforeCreate: Topic<OnModelBeforeCreateTopicParams>;\n onModelAfterCreate: Topic<OnModelAfterCreateTopicParams>;\n onModelCreateError: Topic<OnModelCreateErrorTopicParams>;\n onModelBeforeCreateFrom: Topic<OnModelBeforeCreateFromTopicParams>;\n onModelAfterCreateFrom: Topic<OnModelAfterCreateFromTopicParams>;\n onModelCreateFromError: Topic<OnModelCreateFromErrorParams>;\n onModelBeforeUpdate: Topic<OnModelBeforeUpdateTopicParams>;\n onModelAfterUpdate: Topic<OnModelAfterUpdateTopicParams>;\n onModelUpdateError: Topic<OnModelUpdateErrorTopicParams>;\n onModelBeforeDelete: Topic<OnModelBeforeDeleteTopicParams>;\n onModelAfterDelete: Topic<OnModelAfterDeleteTopicParams>;\n onModelDeleteError: Topic<OnModelDeleteErrorTopicParams>;\n onModelInitialize: Topic<OnModelInitializeParams>;\n}\n\n/**\n * Available statuses for content entry.\n *\n * @category CmsEntry\n */\nexport type CmsEntryStatus = \"published\" | \"unpublished\" | \"draft\";\n\nexport interface CmsEntryListWhereRef {\n id?: string;\n id_in?: string[];\n id_not?: string;\n id_not_in?: string[];\n entryId?: string;\n entryId_not?: string;\n entryId_in?: string[];\n entryId_not_in?: string[];\n}\n\n/**\n * Entry listing where params.\n *\n * @category CmsEntry\n * @category GraphQL params\n */\nexport interface CmsEntryListWhere {\n /**\n * Fields.\n */\n id?: string;\n id_in?: string[];\n id_not?: string;\n id_not_in?: string[];\n /**\n * Generated ID without the version.\n */\n entryId?: string;\n entryId_not?: string;\n entryId_in?: string[];\n entryId_not_in?: string[];\n /**\n * Contains the owner of the entry. An \"owner\" is the identity who originally created the entry.\n * Subsequent revisions can be created by other identities, and those will be stored in `createdBy`,\n * but the `owner` is always the original author of the entry.\n *\n * Can be sent via the API or set internal if user can see only their own entries.\n */\n ownedBy?: string;\n ownedBy_not?: string;\n ownedBy_in?: string[];\n ownedBy_not_in?: string[];\n /**\n * Who created the entry?\n */\n createdBy?: string;\n createdBy_not?: string;\n createdBy_in?: string[];\n createdBy_not_in?: string[];\n /**\n * Version of the entry.\n *\n * It is not meant to be used via the API.\n * @internal\n */\n version?: number;\n version_lt?: number;\n version_gt?: number;\n /**\n * Each storage operations implementation MUST determine how to use this field.\n * In SQL, it can be a `published` field, and in DynamoDB it can be an SK.\n *\n * It is not meant to be used via the API.\n * @internal\n */\n published?: boolean;\n /**\n * Each storage operations implementation MUST determine how to use this field.\n * In SQL, it can be a `latest` field, and in DynamoDB it can be an SK.\n *\n * It is not meant to be used via the API.\n * @internal\n */\n latest?: boolean;\n /**\n * This is to allow querying by any content model field defined by the user.\n */\n [key: string]:\n | string\n | number\n | boolean\n | undefined\n | string[]\n | number[]\n | null\n | CmsEntryListWhere[]\n | CmsEntryListWhere\n | CmsEntryListWhereRef;\n /**\n * To allow querying via nested queries, we added the AND / OR properties.\n */\n AND?: CmsEntryListWhere[];\n OR?: CmsEntryListWhere[];\n}\n\n/**\n * Entry listing sort.\n *\n * @category CmsEntry\n * @category GraphQL params\n */\nexport type CmsEntryListSort = string[];\n\n/**\n * Get entry GraphQL resolver params.\n *\n * @category CmsEntry\n * @category GraphQL params\n */\nexport interface CmsEntryGetParams {\n where: CmsEntryListWhere;\n sort?: CmsEntryListSort;\n}\n\n/**\n * List entries GraphQL resolver params.\n *\n * @category CmsEntry\n * @category GraphQL params\n */\nexport interface CmsEntryListParams {\n where?: CmsEntryListWhere;\n sort?: CmsEntryListSort;\n search?: string;\n fields?: string[];\n limit?: number;\n after?: string | null;\n}\n\n/**\n * Meta information for GraphQL output.\n *\n * @category CmsEntry\n * @category GraphQL output\n */\nexport interface CmsEntryMeta {\n /**\n * A cursor for pagination.\n */\n cursor: string | null;\n /**\n * Is there more items to load?\n */\n hasMoreItems: boolean;\n /**\n * Total count of the items in the storage.\n */\n totalCount: number;\n}\n\n/**\n * Create\n */\nexport interface OnEntryBeforeCreateTopicParams {\n input: CreateCmsEntryInput;\n entry: CmsEntry;\n model: CmsModel;\n}\n\nexport interface OnEntryAfterCreateTopicParams {\n input: CreateCmsEntryInput;\n entry: CmsEntry;\n model: CmsModel;\n storageEntry: CmsEntry;\n}\n\nexport interface OnEntryCreateErrorTopicParams {\n error: Error;\n input: CreateCmsEntryInput;\n entry: CmsEntry;\n model: CmsModel;\n}\n\n/**\n * Revision Create\n */\nexport interface OnEntryRevisionBeforeCreateTopicParams {\n input: CreateFromCmsEntryInput;\n entry: CmsEntry;\n original: CmsEntry;\n model: CmsModel;\n}\n\nexport interface OnEntryRevisionAfterCreateTopicParams {\n input: CreateFromCmsEntryInput;\n entry: CmsEntry;\n original: CmsEntry;\n model: CmsModel;\n storageEntry: CmsEntry;\n}\n\nexport interface OnEntryCreateRevisionErrorTopicParams {\n error: Error;\n input: CreateFromCmsEntryInput;\n original: CmsEntry;\n entry: CmsEntry;\n model: CmsModel;\n}\n\n/**\n * Update\n */\nexport interface OnEntryBeforeUpdateTopicParams {\n input: UpdateCmsEntryInput;\n original: CmsEntry;\n entry: CmsEntry;\n model: CmsModel;\n}\n\nexport interface OnEntryAfterUpdateTopicParams {\n input: UpdateCmsEntryInput;\n original: CmsEntry;\n entry: CmsEntry;\n model: CmsModel;\n storageEntry: CmsEntry;\n}\n\nexport interface OnEntryUpdateErrorTopicParams {\n error: Error;\n input: UpdateCmsEntryInput;\n entry: CmsEntry;\n model: CmsModel;\n}\n\n/**\n * Move\n */\nexport interface OnEntryBeforeMoveTopicParams {\n folderId: string;\n entry: CmsEntry;\n model: CmsModel;\n}\n\nexport interface OnEntryAfterMoveTopicParams {\n folderId: string;\n entry: CmsEntry;\n model: CmsModel;\n}\n\nexport interface OnEntryMoveErrorTopicParams {\n error: Error;\n folderId: string;\n entry: CmsEntry;\n model: CmsModel;\n}\n\n/**\n * Publish\n */\n\nexport interface OnEntryBeforePublishTopicParams {\n entry: CmsEntry;\n model: CmsModel;\n}\n\nexport interface OnEntryAfterPublishTopicParams {\n entry: CmsEntry;\n model: CmsModel;\n storageEntry: CmsEntry;\n}\n\nexport interface OnEntryPublishErrorTopicParams {\n error: Error;\n entry: CmsEntry;\n model: CmsModel;\n}\n\n/**\n * Republish\n */\nexport interface OnEntryBeforeRepublishTopicParams {\n entry: CmsEntry;\n model: CmsModel;\n}\n\nexport interface OnEntryAfterRepublishTopicParams {\n entry: CmsEntry;\n model: CmsModel;\n storageEntry: CmsEntry;\n}\n\nexport interface OnEntryRepublishErrorTopicParams {\n error: Error;\n entry: CmsEntry;\n model: CmsModel;\n}\n\n/**\n * Unpublish\n */\n\nexport interface OnEntryBeforeUnpublishTopicParams {\n entry: CmsEntry;\n model: CmsModel;\n}\n\nexport interface OnEntryAfterUnpublishTopicParams {\n entry: CmsEntry;\n model: CmsModel;\n storageEntry: CmsEntry;\n}\n\nexport interface OnEntryUnpublishErrorTopicParams {\n error: Error;\n entry: CmsEntry;\n model: CmsModel;\n}\n\nexport interface OnEntryBeforeDeleteTopicParams {\n entry: CmsEntry;\n model: CmsModel;\n}\n\nexport interface OnEntryAfterDeleteTopicParams {\n entry: CmsEntry;\n model: CmsModel;\n}\n\nexport interface OnEntryDeleteErrorTopicParams {\n error: Error;\n entry: CmsEntry;\n model: CmsModel;\n}\n\nexport interface OnEntryRevisionBeforeDeleteTopicParams {\n entry: CmsEntry;\n model: CmsModel;\n}\n\nexport interface OnEntryRevisionAfterDeleteTopicParams {\n entry: CmsEntry;\n model: CmsModel;\n}\n\nexport interface OnEntryRevisionDeleteErrorTopicParams {\n error: Error;\n entry: CmsEntry;\n model: CmsModel;\n}\n\nexport interface OnEntryBeforeDeleteMultipleTopicParams {\n model: CmsModel;\n entries: CmsEntry[];\n ids: string[];\n}\n\nexport interface OnEntryAfterDeleteMultipleTopicParams {\n model: CmsModel;\n entries: CmsEntry[];\n ids: string[];\n}\n\nexport interface OnEntryDeleteMultipleErrorTopicParams {\n model: CmsModel;\n entries: CmsEntry[];\n ids: string[];\n error: Error;\n}\n\nexport interface OnEntryBeforeGetTopicParams {\n model: CmsModel;\n where: CmsEntryListWhere;\n}\n\nexport interface EntryBeforeListTopicParams {\n where: CmsEntryListWhere;\n model: CmsModel;\n}\n\n/**\n * @category Context\n * @category CmsEntry\n */\nexport interface CreateCmsEntryInput {\n id?: string;\n wbyAco_location?: {\n folderId?: string | null;\n };\n [key: string]: any;\n}\n\n/**\n * @category Context\n * @category CmsEntry\n */\nexport interface CreateFromCmsEntryInput {\n [key: string]: any;\n}\n\n/**\n * @category Context\n * @category CmsEntry\n */\nexport interface UpdateCmsEntryInput {\n wbyAco_location?: {\n folderId?: string | null;\n };\n [key: string]: any;\n}\n\n/**\n * @category Context\n * @category CmsEntry\n */\nexport interface GetUniqueFieldValuesParams {\n where: CmsEntryListWhere;\n fieldId: string;\n}\n\n/**\n * @category CmsEntry\n */\nexport interface CmsDeleteEntryOptions {\n /**\n * Runs the delete commands even if the entry is not found in the DynamoDB.\n * This is to force clean the entry records that might have been left behind a failed delete.\n */\n force?: boolean;\n}\n\n/**\n * @category Context\n * @category CmsEntry\n */\nexport interface DeleteMultipleEntriesParams {\n entries: string[];\n}\n\nexport type DeleteMultipleEntriesResponse = { id: string }[];\n\n/**\n * Cms Entry CRUD methods in the context.\n *\n * @category Context\n * @category CmsEntry\n */\nexport interface CmsEntryContext {\n /**\n * Get a single content entry for a model.\n */\n getEntry: (model: CmsModel, params: CmsEntryGetParams) => Promise<CmsEntry>;\n /**\n * Get a list of entries for a model by a given ID (revision).\n */\n getEntriesByIds: (model: CmsModel, revisions: string[]) => Promise<CmsEntry[]>;\n /**\n * Get the entry for a model by a given ID.\n */\n getEntryById: (model: CmsModel, revision: string) => Promise<CmsEntry>;\n /**\n * List entries for a model. Internal method used by get, listLatest and listPublished.\n */\n listEntries: <T = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryListParams\n ) => Promise<[CmsEntry<T>[], CmsEntryMeta]>;\n /**\n * Lists the latest entries. Used for manage API.\n */\n listLatestEntries: <T = CmsEntryValues>(\n model: CmsModel,\n params?: CmsEntryListParams\n ) => Promise<[CmsEntry<T>[], CmsEntryMeta]>;\n /**\n * List published entries. Used for read API.\n */\n listPublishedEntries: <T = CmsEntryValues>(\n model: CmsModel,\n params?: CmsEntryListParams\n ) => Promise<[CmsEntry<T>[], CmsEntryMeta]>;\n /**\n * List published entries by IDs.\n */\n getPublishedEntriesByIds: (model: CmsModel, ids: string[]) => Promise<CmsEntry[]>;\n /**\n * List latest entries by IDs.\n */\n getLatestEntriesByIds: (model: CmsModel, ids: string[]) => Promise<CmsEntry[]>;\n /**\n * Create a new content entry.\n */\n createEntry: (model: CmsModel, input: CreateCmsEntryInput) => Promise<CmsEntry>;\n /**\n * Create a new entry from already existing entry.\n */\n createEntryRevisionFrom: (\n model: CmsModel,\n id: string,\n input: CreateFromCmsEntryInput\n ) => Promise<CmsEntry>;\n /**\n * Update existing entry.\n */\n updateEntry: (\n model: CmsModel,\n id: string,\n input: UpdateCmsEntryInput,\n meta?: Record<string, any>\n ) => Promise<CmsEntry>;\n /**\n * Move entry, and all its revisions, to a new folder.\n */\n moveEntry: (model: CmsModel, id: string, folderId: string) => Promise<CmsEntry>;\n /**\n * Method that republishes entry with given identifier.\n * @internal\n */\n republishEntry: (model: CmsModel, id: string) => Promise<CmsEntry>;\n /**\n * Delete only a certain revision of the entry.\n */\n deleteEntryRevision: (model: CmsModel, id: string) => Promise<void>;\n /**\n * Delete entry with all its revisions.\n */\n deleteEntry: (model: CmsModel, id: string, options?: CmsDeleteEntryOptions) => Promise<void>;\n /**\n * Delete multiple entries\n */\n deleteMultipleEntries: (\n model: CmsModel,\n params: DeleteMultipleEntriesParams\n ) => Promise<DeleteMultipleEntriesResponse>;\n /**\n * Publish entry.\n */\n publishEntry: (model: CmsModel, id: string) => Promise<CmsEntry>;\n /**\n * Unpublish entry.\n */\n unpublishEntry: (model: CmsModel, id: string) => Promise<CmsEntry>;\n /**\n * Get all entry revisions.\n */\n getEntryRevisions: (model: CmsModel, id: string) => Promise<CmsEntry[]>;\n /**\n * List all unique values for a given field.\n *\n * @internal\n */\n getUniqueFieldValues: (\n model: CmsModel,\n params: GetUniqueFieldValuesParams\n ) => Promise<CmsEntryUniqueValue[]>;\n /**\n * Lifecycle events - deprecated.\n */\n /**\n * @deprecated\n */\n onBeforeEntryCreate: Topic<OnEntryBeforeCreateTopicParams>;\n /**\n * @deprecated\n */\n onAfterEntryCreate: Topic<OnEntryAfterCreateTopicParams>;\n /**\n * @deprecated\n */\n onBeforeEntryCreateRevision: Topic<OnEntryRevisionBeforeCreateTopicParams>;\n /**\n * @deprecated\n */\n onAfterEntryCreateRevision: Topic<OnEntryRevisionAfterCreateTopicParams>;\n /**\n * @deprecated\n */\n onBeforeEntryUpdate: Topic<OnEntryBeforeUpdateTopicParams>;\n /**\n * @deprecated\n */\n onAfterEntryUpdate: Topic<OnEntryAfterUpdateTopicParams>;\n /**\n * @deprecated\n */\n onBeforeEntryDelete: Topic<OnEntryBeforeDeleteTopicParams>;\n /**\n * @deprecated\n */\n onAfterEntryDelete: Topic<OnEntryAfterDeleteTopicParams>;\n /**\n * @deprecated\n */\n onBeforeEntryDeleteRevision: Topic<OnEntryRevisionBeforeDeleteTopicParams>;\n /**\n * @deprecated\n */\n onAfterEntryDeleteRevision: Topic<OnEntryRevisionAfterDeleteTopicParams>;\n /**\n * @deprecated\n */\n onBeforeEntryPublish: Topic<OnEntryBeforePublishTopicParams>;\n /**\n * @deprecated\n */\n onAfterEntryPublish: Topic<OnEntryAfterPublishTopicParams>;\n /**\n * @deprecated\n */\n onBeforeEntryUnpublish: Topic<OnEntryBeforeUnpublishTopicParams>;\n /**\n * @deprecated\n */\n onAfterEntryUnpublish: Topic<OnEntryAfterUnpublishTopicParams>;\n /**\n * @deprecated\n */\n onBeforeEntryGet: Topic<OnEntryBeforeGetTopicParams>;\n /**\n * @deprecated\n */\n onBeforeEntryList: Topic<EntryBeforeListTopicParams>;\n /**\n * Lifecycle events released in 5.33.0\n */\n onEntryBeforeCreate: Topic<OnEntryBeforeCreateTopicParams>;\n onEntryAfterCreate: Topic<OnEntryAfterCreateTopicParams>;\n onEntryCreateError: Topic<OnEntryCreateErrorTopicParams>;\n\n onEntryRevisionBeforeCreate: Topic<OnEntryRevisionBeforeCreateTopicParams>;\n onEntryRevisionAfterCreate: Topic<OnEntryRevisionAfterCreateTopicParams>;\n onEntryRevisionCreateError: Topic<OnEntryCreateRevisionErrorTopicParams>;\n\n onEntryBeforeUpdate: Topic<OnEntryBeforeUpdateTopicParams>;\n onEntryAfterUpdate: Topic<OnEntryAfterUpdateTopicParams>;\n onEntryUpdateError: Topic<OnEntryUpdateErrorTopicParams>;\n\n onEntryBeforeMove: Topic<OnEntryBeforeMoveTopicParams>;\n onEntryAfterMove: Topic<OnEntryAfterMoveTopicParams>;\n onEntryMoveError: Topic<OnEntryMoveErrorTopicParams>;\n\n onEntryBeforeDelete: Topic<OnEntryBeforeDeleteTopicParams>;\n onEntryAfterDelete: Topic<OnEntryAfterDeleteTopicParams>;\n onEntryDeleteError: Topic<OnEntryDeleteErrorTopicParams>;\n\n onEntryRevisionBeforeDelete: Topic<OnEntryRevisionBeforeDeleteTopicParams>;\n onEntryRevisionAfterDelete: Topic<OnEntryRevisionAfterDeleteTopicParams>;\n onEntryRevisionDeleteError: Topic<OnEntryRevisionDeleteErrorTopicParams>;\n\n onEntryBeforePublish: Topic<OnEntryBeforePublishTopicParams>;\n onEntryAfterPublish: Topic<OnEntryAfterPublishTopicParams>;\n onEntryPublishError: Topic<OnEntryPublishErrorTopicParams>;\n\n onEntryBeforeRepublish: Topic<OnEntryBeforeRepublishTopicParams>;\n onEntryAfterRepublish: Topic<OnEntryAfterRepublishTopicParams>;\n onEntryRepublishError: Topic<OnEntryRepublishErrorTopicParams>;\n\n onEntryBeforeUnpublish: Topic<OnEntryBeforeUnpublishTopicParams>;\n onEntryAfterUnpublish: Topic<OnEntryAfterUnpublishTopicParams>;\n onEntryUnpublishError: Topic<OnEntryUnpublishErrorTopicParams>;\n\n onEntryBeforeGet: Topic<OnEntryBeforeGetTopicParams>;\n onEntryBeforeList: Topic<EntryBeforeListTopicParams>;\n}\n\n/**\n * Parameters for CmsEntryResolverFactory.\n *\n * @category GraphQL resolver\n * @category CmsEntry\n */\ninterface CmsEntryResolverFactoryParams {\n model: CmsModel;\n}\n\n/**\n * A type for EntryResolvers. Used when creating get, list, update, publish, ...etc.\n *\n * @category GraphQL resolver\n * @category CmsEntry\n */\nexport type CmsEntryResolverFactory<TSource = any, TArgs = any, TContext = CmsContext> = {\n (params: CmsEntryResolverFactoryParams): GraphQLFieldResolver<TSource, TArgs, TContext>;\n};\n\n/**\n * Settings security permission.\n *\n * @category SecurityPermission\n */\nexport interface CmsSettingsPermission extends SecurityPermission {} // eslint-disable-line\n\n/**\n * A base security permission for CMS.\n *\n * @category SecurityPermission\n */\nexport interface BaseCmsSecurityPermission extends SecurityPermission {\n own?: boolean;\n rwd: string | number;\n}\n\n/**\n * A security permission for content model.\n *\n * @category SecurityPermission\n * @category CmsModel\n */\nexport interface CmsModelPermission extends BaseCmsSecurityPermission {\n /**\n * An object representing `key: model.modelId` values where key is locale code.\n */\n models?: {\n [key: string]: string[];\n };\n /**\n * {locale: groupId[]} map, where key is a locale code.\n */\n groups?: {\n [key: string]: string[];\n };\n}\n\n/**\n * The security permission for content model groups.\n *\n * @category SecurityPermission\n * @category CmsGroup\n */\nexport interface CmsGroupPermission extends BaseCmsSecurityPermission {\n /**\n * {locale: groupId[]} map, where key is a locale code.\n */\n groups?: {\n [key: string]: string[];\n };\n}\n\n/**\n * The security permission for content entry.\n *\n * @category SecurityPermission\n * @category CmsEntry\n */\nexport interface CmsEntryPermission extends BaseCmsSecurityPermission {\n pw?: string;\n /**\n * An object representing `key: model.modelId` values where key is locale code.\n */\n models?: {\n [key: string]: string[];\n };\n /**\n * {locale: groupId[]} map, where key is a locale code.\n */\n groups?: {\n [key: string]: string[];\n };\n}\n\nexport interface CmsGroupStorageOperationsGetParams {\n id: string;\n tenant: string;\n locale: string;\n}\n\nexport interface CmsGroupStorageOperationsListWhereParams {\n tenant: string;\n locale: string;\n [key: string]: any;\n}\n\nexport interface CmsGroupStorageOperationsListParams {\n where: CmsGroupStorageOperationsListWhereParams;\n sort?: string[];\n}\n\nexport interface CmsGroupStorageOperationsCreateParams {\n group: CmsGroup;\n}\n\nexport interface CmsGroupStorageOperationsUpdateParams {\n group: CmsGroup;\n}\n\nexport interface CmsGroupStorageOperationsDeleteParams {\n group: CmsGroup;\n}\n\n/**\n * Description of the CmsGroup CRUD operations.\n * If user wants to add another database to the application, this is how it is done.\n * This is just plain read, update, write, delete and list - no authentication or permission checks.\n */\nexport interface CmsGroupStorageOperations {\n /**\n * Gets content model group by given id.\n */\n get: (params: CmsGroupStorageOperationsGetParams) => Promise<CmsGroup | null>;\n /**\n * List all content model groups. Filterable via params.\n */\n list: (params: CmsGroupStorageOperationsListParams) => Promise<CmsGroup[]>;\n /**\n * Create a new content model group.\n */\n create: (params: CmsGroupStorageOperationsCreateParams) => Promise<CmsGroup>;\n /**\n * Update existing content model group.\n */\n update: (params: CmsGroupStorageOperationsUpdateParams) => Promise<CmsGroup>;\n /**\n * Delete the content model group.\n */\n delete: (params: CmsGroupStorageOperationsDeleteParams) => Promise<CmsGroup>;\n}\n\nexport interface CmsModelStorageOperationsGetParams {\n tenant: string;\n locale: string;\n modelId: string;\n}\n\nexport interface CmsModelStorageOperationsListWhereParams {\n tenant: string;\n locale: string;\n [key: string]: string;\n}\n\nexport interface CmsModelStorageOperationsListParams {\n where: CmsModelStorageOperationsListWhereParams;\n}\n\nexport interface CmsModelStorageOperationsCreateParams {\n model: CmsModel;\n}\n\nexport interface CmsModelStorageOperationsUpdateParams {\n model: CmsModel;\n}\n\nexport interface CmsModelStorageOperationsDeleteParams {\n model: CmsModel;\n}\n\n/**\n * Description of the CmsModel storage operations.\n * If user wants to add another database to the application, this is how it is done.\n * This is just plain read, update, write, delete and list - no authentication or permission checks.\n */\nexport interface CmsModelStorageOperations {\n /**\n * Gets content model by given id.\n */\n get: (params: CmsModelStorageOperationsGetParams) => Promise<CmsModel | null>;\n /**\n * List all content models. Filterable via params.\n */\n list: (params: CmsModelStorageOperationsListParams) => Promise<CmsModel[]>;\n /**\n * Create a new content model.\n */\n create: (params: CmsModelStorageOperationsCreateParams) => Promise<CmsModel>;\n /**\n * Update existing content model.\n */\n update: (params: CmsModelStorageOperationsUpdateParams) => Promise<CmsModel>;\n /**\n * Delete the content model.\n */\n delete: (params: CmsModelStorageOperationsDeleteParams) => Promise<CmsModel>;\n}\n\nexport interface CmsEntryStorageOperationsGetParams {\n where: CmsEntryListWhere;\n sort?: CmsEntryListSort;\n limit?: number;\n}\n\nexport interface CmsEntryStorageOperationsListParams {\n where: CmsEntryListWhere;\n sort?: CmsEntryListSort;\n search?: string;\n fields?: string[];\n limit: number;\n after?: string | null;\n}\n\nexport interface CmsEntryStorageOperationsCreateParams<\n T extends CmsStorageEntry = CmsStorageEntry\n> {\n /**\n * Real entry, with no transformations on it.\n */\n entry: CmsEntry;\n /**\n * Entry prepared for the storage.\n */\n storageEntry: T;\n}\n\nexport interface CmsEntryStorageOperationsCreateRevisionFromParams<\n T extends CmsStorageEntry = CmsStorageEntry\n> {\n /**\n * Real entry, with no transformations on it.\n */\n entry: CmsEntry;\n /**\n * Entry prepared for the storage.\n */\n storageEntry: T;\n}\n\nexport interface CmsEntryStorageOperationsUpdateParams<\n T extends CmsStorageEntry = CmsStorageEntry\n> {\n /**\n * Real entry, with no transformations on it.\n */\n entry: CmsEntry;\n /**\n * Entry prepared for the storage.\n */\n storageEntry: T;\n}\n\nexport interface CmsEntryStorageOperationsDeleteRevisionParams<\n T extends CmsStorageEntry = CmsStorageEntry\n> {\n /**\n * Entry that was deleted.\n */\n entry: CmsEntry;\n /**\n * Entry that was deleted, directly from storage, with transformations.\n */\n storageEntry: T;\n /**\n * Entry that was set as latest.\n */\n latestEntry: CmsEntry | null;\n /**\n * Entry that was set as latest, directly from storage, with transformations.\n */\n latestStorageEntry: T | null;\n}\n\nexport interface CmsEntryStorageOperationsDeleteParams {\n entry: CmsEntry;\n}\n\nexport interface CmsEntryStorageOperationsDeleteEntriesParams {\n entries: string[];\n}\n\nexport interface CmsEntryStorageOperationsPublishParams<\n T extends CmsStorageEntry = CmsStorageEntry\n> {\n /**\n * The modified entry that is going to be saved as published.\n * Entry is in its original form.\n */\n entry: CmsEntry;\n /**\n * The modified entry and prepared for the storage.\n */\n storageEntry: T;\n}\n\nexport interface CmsEntryStorageOperationsUnpublishParams<\n T extends CmsStorageEntry = CmsStorageEntry\n> {\n /**\n * The modified entry that is going to be saved as unpublished.\n */\n entry: CmsEntry;\n /**\n * The modified entry that is going to be saved as unpublished, with transformations on it.\n */\n storageEntry: T;\n}\n\nexport interface CmsEntryStorageOperationsGetUniqueFieldValuesParams {\n where: CmsEntryListWhere;\n fieldId: string;\n}\n\nexport interface CmsEntryStorageOperationsGetByIdsParams {\n ids: readonly string[];\n}\n\nexport interface CmsEntryStorageOperationsGetLatestByIdsParams {\n ids: readonly string[];\n}\n\nexport interface CmsEntryStorageOperationsGetPublishedByIdsParams {\n ids: readonly string[];\n}\n\nexport interface CmsEntryStorageOperationsGetRevisionsParams {\n id: string;\n}\n\nexport interface CmsEntryStorageOperationsGetRevisionParams {\n id: string;\n}\n\nexport interface CmsEntryStorageOperationsGetPublishedRevisionParams {\n id: string;\n}\n\nexport interface CmsEntryStorageOperationsGetLatestRevisionParams {\n id: string;\n}\n\nexport interface CmsEntryStorageOperationsGetPreviousRevisionParams {\n entryId: string;\n version: number;\n}\n\nexport interface CmsEntryStorageOperationsListResponse<\n T extends CmsStorageEntry = CmsStorageEntry\n> {\n /**\n * Has more items to load with the current filtering?\n */\n hasMoreItems: boolean;\n /**\n * Items loaded with current filtering.\n */\n items: T[];\n /**\n * Pointer for where to start the new item set.\n */\n cursor: string | null;\n /**\n * Total amount of items with the current filter.\n */\n totalCount: number;\n}\n\n/**\n * Description of the CmsModel storage operations.\n * If user wants to add another database to the application, this is how it is done.\n * This is just plain read, update, write, delete and list - no authentication or permission checks.\n *\n *\n * @category StorageOperations\n * @category CmsEntry\n */\nexport interface CmsEntryStorageOperations<T extends CmsStorageEntry = CmsStorageEntry> {\n /**\n * Get all the entries of the ids.\n */\n getByIds: (model: CmsModel, params: CmsEntryStorageOperationsGetByIdsParams) => Promise<T[]>;\n /**\n * Get all the published entries of the ids.\n */\n getPublishedByIds: (\n model: CmsModel,\n params: CmsEntryStorageOperationsGetPublishedByIdsParams\n ) => Promise<T[]>;\n /**\n * Get all the latest entries of the ids.\n */\n getLatestByIds: (\n model: CmsModel,\n params: CmsEntryStorageOperationsGetLatestByIdsParams\n ) => Promise<T[]>;\n /**\n * Get all revisions of the given entry id.\n */\n getRevisions: (\n model: CmsModel,\n params: CmsEntryStorageOperationsGetRevisionsParams\n ) => Promise<T[]>;\n /**\n * Get the entry by the given revision id.\n */\n getRevisionById: (\n model: CmsModel,\n params: CmsEntryStorageOperationsGetRevisionParams\n ) => Promise<T | null>;\n /**\n * Get the published entry by given entryId.\n */\n getPublishedRevisionByEntryId: (\n model: CmsModel,\n params: CmsEntryStorageOperationsGetPublishedRevisionParams\n ) => Promise<T | null>;\n /**\n * Get the latest entry by given entryId.\n */\n getLatestRevisionByEntryId: (\n model: CmsModel,\n params: CmsEntryStorageOperationsGetLatestRevisionParams\n ) => Promise<T | null>;\n /**\n * Get the revision of the entry before given one.\n */\n getPreviousRevision: (\n model: CmsModel,\n params: CmsEntryStorageOperationsGetPreviousRevisionParams\n ) => Promise<T | null>;\n /**\n * Gets entry by given params.\n */\n get: (model: CmsModel, params: CmsEntryStorageOperationsGetParams) => Promise<T | null>;\n /**\n * List all entries. Filterable via params.\n */\n list: (\n model: CmsModel,\n params: CmsEntryStorageOperationsListParams\n ) => Promise<CmsEntryStorageOperationsListResponse<T>>;\n /**\n * Create a new entry.\n */\n create: (model: CmsModel, params: CmsEntryStorageOperationsCreateParams<T>) => Promise<T>;\n /**\n * Create a new entry from existing one.\n */\n createRevisionFrom: (\n model: CmsModel,\n params: CmsEntryStorageOperationsCreateRevisionFromParams<T>\n ) => Promise<T>;\n /**\n * Update existing entry.\n */\n update: (model: CmsModel, params: CmsEntryStorageOperationsUpdateParams<T>) => Promise<T>;\n /**\n * Move entry and all its entries into a new folder.\n */\n move: (model: CmsModel, id: string, folderId: string) => Promise<void>;\n /**\n * Delete the entry revision.\n */\n deleteRevision: (\n model: CmsModel,\n params: CmsEntryStorageOperationsDeleteRevisionParams<T>\n ) => Promise<void>;\n /**\n * Delete the entry.\n */\n delete: (model: CmsModel, params: CmsEntryStorageOperationsDeleteParams) => Promise<void>;\n /**\n * Delete multiple entries, with a limit on how much can be deleted in one call.\n */\n deleteMultipleEntries: (\n model: CmsModel,\n params: CmsEntryStorageOperationsDeleteEntriesParams\n ) => Promise<void>;\n /**\n * Publish the entry.\n */\n publish: (model: CmsModel, params: CmsEntryStorageOperationsPublishParams<T>) => Promise<T>;\n /**\n * Unpublish the entry.\n */\n unpublish: (model: CmsModel, params: CmsEntryStorageOperationsUnpublishParams<T>) => Promise<T>;\n /**\n * Method to list all the unique values for the given field id.\n * Simplest use case would be to aggregate tags for some content.\n * @internal\n */\n getUniqueFieldValues: (\n model: CmsModel,\n params: CmsEntryStorageOperationsGetUniqueFieldValuesParams\n ) => Promise<CmsEntryUniqueValue[]>;\n}\n\nexport enum CONTENT_ENTRY_STATUS {\n DRAFT = \"draft\",\n PUBLISHED = \"published\",\n UNPUBLISHED = \"unpublished\"\n}\n\nexport interface CmsSettingsStorageOperationsGetParams {\n locale: string;\n tenant: string;\n}\n\nexport interface CmsSettingsStorageOperationsCreateParams {\n settings: CmsSettings;\n}\n\nexport interface CmsSettingsStorageOperationsUpdateParams {\n settings: CmsSettings;\n}\n\nexport interface CmsSettingsStorageOperations {\n /**\n * Get the settings from the storage.\n */\n get: (params: CmsSettingsStorageOperationsGetParams) => Promise<CmsSettings | null>;\n /**\n * Create settings in the storage.\n */\n create: (params: CmsSettingsStorageOperationsCreateParams) => Promise<CmsSettings>;\n /**\n * Update the settings in the storage.\n */\n update: (params: CmsSettingsStorageOperationsUpdateParams) => Promise<CmsSettings>;\n}\n\nexport interface CmsSystem {\n version?: string;\n readAPIKey?: string;\n /**\n * System tenant.\n */\n tenant: string;\n}\n\nexport interface CmsSystemStorageOperationsGetParams {\n tenant: string;\n}\n\nexport interface CmsSystemStorageOperationsCreateParams {\n system: CmsSystem;\n}\n\nexport interface CmsSystemStorageOperationsUpdateParams {\n system: CmsSystem;\n}\n\nexport interface CmsSystemStorageOperations {\n /**\n * Get the system data.\n */\n get: (params: CmsSystemStorageOperationsGetParams) => Promise<CmsSystem | null>;\n /**\n * Create the system info in the storage.\n */\n create: (params: CmsSystemStorageOperationsCreateParams) => Promise<CmsSystem>;\n /**\n * Update the system info in the storage.\n */\n update: (params: CmsSystemStorageOperationsUpdateParams) => Promise<CmsSystem>;\n}\n\nexport interface HeadlessCmsStorageOperations<C = CmsContext> {\n name: string;\n system: CmsSystemStorageOperations;\n settings: CmsSettingsStorageOperations;\n groups: CmsGroupStorageOperations;\n models: CmsModelStorageOperations;\n entries: CmsEntryStorageOperations;\n /**\n * Either attach something from the storage operations or run something in it.\n */\n beforeInit: (context: C) => Promise<void>;\n init?: (context: C) => Promise<void>;\n}\n"],"mappings":";;;;;;AAoEA;AACA;AACA;AACA;AACA;AAcA;AACA;AACA;AACA;AACA;AAYA;AACA;AACA;AACA;AACA;AASA;AACA;AACA;AACA;AACA;AACA;AA6CA;AACA;AACA;AACA;AACA;AACA;AAgGA;AACA;AACA;AAUA;AACA;AACA;AASA;AACA;AACA;AAUA;AACA;AACA;AACA;AACA;AACA;AAgCA;AACA;AACA;AACA;AACA;AACA;AACA;AAqBA;AACA;AACA;AACA;AACA;AACA;AACA;AAyBA;AACA;AACA;AACA;AACA;AACA;AACA;AAkBA;AACA;AACA;AACA;AAYA;AACA;AACA;AACA;AACA;AACA;AA+GA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AA+CA;AACA;AACA;AACA;AACA;AAiQA;AACA;AACA;AACA;AACA;AACA;AACA;AAoBA;AACA;AACA;AAKA;AACA;AACA;AACA;AACA;AAgBA;AACA;AACA;AACA;AACA;AAgBA;AACA;AACA;AACA;AACA;AAuDA;AACA;AACA;AACA;AACA;AACA;AAQA;AACA;AACA;AACA;AACA;AACA;AAQA;AACA;AACA;AACA;AACA;AACA;AAsDA;AACA;AACA;AACA;AACA;AACA;AASA;AACA;AACA;AACA;AAKA;AACA;AACA;AACA;AAKA;AACA;AACA;AACA;AAOA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AAQA;AACA;AACA;AACA;AAKA;AACA;AACA;AACA;AAKA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AACA;AAmEA;AACA;AACA;AACA;AACA;AACA;AAYA;AACA;AACA;AACA;AACA;AACA;AAqDA;AACA;AACA;AACA;AACA;AACA;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAyDA;AACA;AACA;AACA;AACA;AACA;AA6CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAkBA;AACA;AACA;AACA;AACA;AACA;AAKA;AACA;AACA;AACA;AACA;AACA;AAuGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAoCA;AACA;AACA;AAiBA;AACA;AACA;AAoBA;AACA;AACA;AAoBA;AACA;AACA;AAcA;AACA;AACA;AAMA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AACA;AA+GA;AACA;AACA;AACA;AACA;AAcA;AACA;AACA;AACA;AACA;AACA;AAgFA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AACA;AAUA;AACA;AACA;AACA;AACA;AACA;AAgBA;AACA;AACA;AAqBA;AACA;AACA;AAwBA;AACA;AACA;AAuBA;AACA;AACA;AAoBA;AACA;AACA;AAmBA;AACA;AACA;AAkBA;AACA;AACA;AAgFA;AACA;AACA;AACA;AASA;AACA;AACA;AACA;AAKA;AACA;AACA;AACA;AAQA;AACA;AACA;AACA;AAMA;AACA;AACA;AASA;AACA;AACA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AA2NA;AACA;AACA;AACA;AACA;AACA;AAKA;AACA;AACA;AACA;AACA;AACA;AAKA;AACA;AACA;AACA;AACA;AACqE;AAErE;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AACA;AAgBA;AACA;AACA;AACA;AACA;AACA;AAUA;AACA;AACA;AACA;AACA;AACA;AA8CA;AACA;AACA;AACA;AACA;AAoDA;AACA;AACA;AACA;AACA;AAiMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AARA,IAkIYA,oBAAoB,0BAApBA,oBAAoB;EAApBA,oBAAoB;EAApBA,oBAAoB;EAApBA,oBAAoB;EAAA,OAApBA,oBAAoB;AAAA;AAAAC,OAAA,CAAAD,oBAAA,GAAAA,oBAAA"}
1
+ {"version":3,"names":["CONTENT_ENTRY_STATUS","exports"],"sources":["types.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins/types\";\nimport { I18NContext, I18NLocale } from \"@webiny/api-i18n/types\";\nimport { Context } from \"@webiny/api/types\";\nimport {\n GraphQLFieldResolver,\n GraphQLSchemaDefinition,\n Resolvers\n} from \"@webiny/handler-graphql/types\";\nimport { SecurityPermission } from \"@webiny/api-security/types\";\nimport { DbContext } from \"@webiny/handler-db/types\";\nimport { Topic } from \"@webiny/pubsub/types\";\nimport { CmsModelConverterCallable } from \"~/utils/converters/ConverterCollection\";\nimport { ModelGroupsPermissions } from \"~/utils/permissions/ModelGroupsPermissions\";\nimport { ModelsPermissions } from \"~/utils/permissions/ModelsPermissions\";\nimport { EntriesPermissions } from \"~/utils/permissions/EntriesPermissions\";\nimport { SettingsPermissions } from \"~/utils/permissions/SettingsPermissions\";\n\nexport type ApiEndpoint = \"manage\" | \"preview\" | \"read\";\n\ninterface HeadlessCmsPermissions {\n groups: ModelGroupsPermissions;\n models: ModelsPermissions;\n entries: EntriesPermissions;\n settings: SettingsPermissions;\n}\n\nexport interface HeadlessCms\n extends CmsSettingsContext,\n CmsSystemContext,\n CmsGroupContext,\n CmsModelContext,\n CmsEntryContext {\n /**\n * API type\n */\n type: ApiEndpoint | null;\n /**\n * Requested locale\n */\n locale: string;\n /**\n * returns an instance of current locale\n */\n getLocale: () => I18NLocale;\n /**\n * Means this request is a READ API\n */\n READ: boolean;\n /**\n * Means this request is a MANAGE API\n */\n MANAGE: boolean;\n /**\n * Means this request is a PREVIEW API\n */\n PREVIEW: boolean;\n /**\n * The storage operations loaded for current context.\n */\n storageOperations: HeadlessCmsStorageOperations;\n /**\n * Permissions for settings, groups, models and entries.\n *\n * @internal\n */\n permissions: HeadlessCmsPermissions;\n}\n\n/**\n * @description This combines all contexts used in the CMS into a single one.\n *\n * @category Context\n */\nexport interface CmsContext extends Context, DbContext, I18NContext {\n cms: HeadlessCms;\n}\n\ninterface CmsModelFieldPredefinedValuesValue {\n value: string;\n label: string;\n /**\n * Default selected predefined value.\n */\n selected?: boolean;\n}\n\n/**\n * Object containing content model field predefined options and values.\n *\n * @category CmsModelField\n */\nexport interface CmsModelFieldPredefinedValues {\n /**\n * Are predefined field values enabled?\n */\n enabled: boolean;\n /**\n * Predefined values array.\n */\n values: CmsModelFieldPredefinedValuesValue[];\n}\n\n/**\n * Object containing content model field renderer options.\n *\n * @category CmsModelField\n */\ninterface CmsModelFieldRenderer {\n /**\n * Name of the field renderer. Must have one in field renderer plugins.\n * Can be blank to let automatically determine the renderer.\n */\n name: string;\n}\n\n/**\n * A definition for content model field settings.\n *\n * @category ModelField\n * @category Database model\n */\nexport interface CmsModelFieldSettings {\n /**\n * Predefined values (text, number)\n * The default value for the field in case it is not predefined values field.\n */\n defaultValue?: string | number | null | undefined;\n /**\n * Object field has child fields.\n */\n fields?: CmsModelField[];\n /**\n * Is the file field images only one?\n */\n imagesOnly?: boolean;\n /**\n * Object field has child fields - so it needs to have a layout.\n */\n layout?: string[][];\n /**\n * Ref field.\n */\n models?: Pick<CmsModel, \"modelId\">[];\n /**\n * Date field.\n */\n type?: string;\n /**\n * There are a lot of other settings that are possible to add, so we keep the type opened.\n */\n [key: string]: any;\n}\n\nexport type CmsModelFieldType =\n | \"boolean\"\n | \"datetime\"\n | \"file\"\n | \"long-text\"\n | \"number\"\n | \"object\"\n | \"ref\"\n | \"rich-text\"\n | \"text\"\n | \"dynamicZone\"\n | string;\n/**\n * A definition for content model field. This type exists on the app side as well.\n *\n * @category ModelField\n * @category Database model\n */\nexport interface CmsModelField {\n /**\n * A generated unique ID for the model field.\n * MUST be absolute unique throughout the models.\n * Must be in form of a-zA-Z0-9.\n *\n * We generate a unique id value when you're building a model via UI,\n * but when user is creating a model via a plugin it is up to them to be careful about this.\n */\n id: string;\n /**\n * A type of the field.\n * We are defining our built-in fields, so people know which are available by the default.\n */\n type: CmsModelFieldType;\n /**\n * A unique storage ID for storing actual values.\n * Must in form of a-zA-Z0-9@a-zA-Z0-9\n *\n * This is an auto-generated value: uses `id` and `type`\n *\n * This is used as path for the entry value.\n */\n storageId: `${string}@${string}` | string;\n /**\n * Field identifier for the model field that will be available to the outside world.\n * `storageId` is used as path (or column) to store the data.\n *\n * Must in form of a-zA-Z0-9.\n *\n * This value MUST be unique in the CmsModel.\n */\n fieldId: string;\n /**\n * A label for the field\n */\n label: string;\n /**\n * Text below the field to clarify what is it meant to be in the field value\n */\n helpText?: string | null;\n /**\n * Text to be displayed in the field\n */\n placeholderText?: string | null;\n /**\n * Are predefined values enabled? And list of them\n */\n predefinedValues?: CmsModelFieldPredefinedValues;\n /**\n * Field renderer. Blank if determined automatically.\n */\n renderer?: CmsModelFieldRenderer;\n /**\n * List of validations for the field\n *\n * @default []\n */\n validation?: CmsModelFieldValidation[];\n /**\n * List of validations for the list of values, when a field is set to accept a list of values.\n * These validations will be applied to the entire list, and `validation` (see above) will be applied\n * to each individual value in the list.\n *\n * @default []\n */\n listValidation?: CmsModelFieldValidation[];\n /**\n * Is this a multiple values field?\n *\n */\n multipleValues?: boolean;\n /**\n * Fields can be tagged to give them contextual meaning.\n */\n tags?: string[];\n /**\n * Any user defined settings.\n *\n * @default {}\n */\n settings?: CmsModelFieldSettings;\n}\n\nexport interface CmsDynamicZoneTemplate {\n id: string;\n name: string;\n gqlTypeName: string;\n description: string;\n icon: string;\n fields: CmsModelField[];\n layout: string[][];\n validation: CmsModelFieldValidation[];\n}\n\n/**\n * A definition for dynamic-zone field to show possible type of the field in settings.\n */\nexport interface CmsModelDynamicZoneField extends CmsModelField {\n /**\n * Settings object for the field. Contains `templates` property.\n */\n settings: {\n templates: CmsDynamicZoneTemplate[];\n };\n}\n\n/**\n * Used for our internal functionality.\n */\nexport interface CmsModelFieldWithParent extends CmsModelField {\n parent?: CmsModelFieldWithParent | null;\n}\n\nexport interface CmsModelDynamicZoneFieldWithParent extends CmsModelDynamicZoneField {\n parent?: CmsModelDynamicZoneFieldWithParent | null;\n}\n\n/**\n * A definition for dateTime field to show possible type of the field in settings.\n */\nexport interface CmsModelDateTimeField extends CmsModelField {\n /**\n * Settings object for the field. Contains `type` property.\n */\n settings: {\n type: \"time\" | \"date\" | \"dateTimeWithoutTimezone\" | \"dateTimeWithTimezone\";\n };\n}\n\n/**\n * Arguments for the field validator validate method.\n *\n * @category ModelField\n * @category FieldValidation\n */\nexport interface CmsModelFieldValidatorValidateParams<T = any> {\n /**\n * A value to be validated.\n */\n value: T;\n /**\n * Options from the CmsModelField validations.\n *\n * @see CmsModelField.validation\n * @see CmsModelField.listValidation\n */\n validator: CmsModelFieldValidation;\n /**\n * An instance of the current context.\n */\n context: CmsContext;\n /**\n * Field being validated.\n */\n field: CmsModelField;\n /**\n * An instance of the content model being validated.\n */\n model: CmsModel;\n /**\n * If entry is sent it means it is an update operation.\n * First usage is for the unique field value.\n */\n entry?: CmsEntry;\n}\n\n/**\n * Definition for the field validator.\n *\n * @category Plugin\n * @category ModelField\n * @category FieldValidation\n */\nexport interface CmsModelFieldValidatorPlugin extends Plugin {\n /**\n * A plugin type.\n */\n type: \"cms-model-field-validator\";\n /**\n * Actual validator definition.\n */\n validator: {\n /**\n * Name of the validator.\n */\n name: string;\n /**\n * Validation method.\n */\n validate(params: CmsModelFieldValidatorValidateParams): Promise<boolean>;\n };\n}\n\n/**\n * A pattern validator for the content entry field value.\n *\n * @category Plugin\n * @category ModelField\n * @category FieldValidation\n */\nexport interface CmsModelFieldPatternValidatorPlugin extends Plugin {\n /**\n * A plugin type\n */\n type: \"cms-model-field-validator-pattern\";\n /**\n * A pattern object for the validator.\n */\n pattern: {\n /**\n * name of the pattern.\n */\n name: string;\n /**\n * RegExp of the validator.\n */\n regex: string;\n /**\n * RegExp flags\n */\n flags: string;\n };\n}\n\n/**\n * Locked field in the content model\n *\n * @see CmsModel.lockedFields\n *\n * @category ModelField\n */\nexport interface LockedField {\n /**\n * Locked field storage ID - one used to store values.\n * We cannot change this due to old systems.\n */\n fieldId: string;\n /**\n * Is the field multiple values field?\n */\n multipleValues: boolean;\n /**\n * Field type.\n */\n type: string;\n [key: string]: any;\n}\n\n/**\n * @category Database model\n * @category CmsModel\n */\nexport interface CmsModelGroup {\n /**\n * Generated ID of the group\n */\n id: string;\n /**\n * Name of the group\n */\n name: string;\n}\n\n/**\n * Base CMS Model. Should not be exported and used outside of this package.\n *\n * @category Database model\n * @category CmsModel\n */\nexport interface CmsModel {\n /**\n * Name of the content model.\n */\n name: string;\n /**\n * Unique ID for the content model. Created from name if not defined by user.\n */\n modelId: string;\n /**\n * Name of the content model in singular form to be used in the API.\n * example:\n * - Article\n * - Fruit\n * - Vegetable\n * - Car\n */\n singularApiName: string;\n /**\n * Name of the content model in plural form to be used in the API.\n * example:\n * - Articles\n * - Fruits\n * - Vegetables\n * - Cars\n */\n pluralApiName: string;\n /**\n * Model tenant.\n */\n tenant: string;\n /**\n * Locale this model belongs to.\n */\n locale: string;\n /**\n * Cms Group reference object.\n */\n group: CmsModelGroup;\n /**\n * Icon for the content model.\n */\n icon?: string | null;\n /**\n * Description for the content model.\n */\n description: string | null;\n /**\n * Date created\n */\n createdOn?: string;\n /**\n * Date saved. Changes on both save and create.\n */\n savedOn?: string;\n /**\n * CreatedBy object wrapper. Contains id, name and type of the user.\n */\n createdBy?: CmsIdentity;\n /**\n * List of fields defining entry values.\n */\n fields: CmsModelField[];\n /**\n * Admin UI field layout\n *\n * ```ts\n * layout: [\n * [field1id, field2id],\n * [field3id]\n * ]\n * ```\n */\n layout: string[][];\n /**\n * Models can be tagged to give them contextual meaning.\n */\n tags?: string[];\n /**\n * List of locked fields. Updated when entry is saved and a field has been used.\n */\n lockedFields?: LockedField[];\n /**\n * The field that is being displayed as entry title.\n * It is picked as first available text field. Or user can select own field.\n */\n titleFieldId: string;\n /**\n * The field which is displayed as the description one.\n * Only way this is null or undefined is that there are no long-text fields to be set as description.\n */\n descriptionFieldId?: string | null;\n /**\n * The field which is displayed as the image.\n * Only way this is null or undefined is that there are no file fields, with images only set, to be set as image.\n */\n imageFieldId?: string | null;\n /**\n * The version of Webiny which this record was stored with.\n */\n webinyVersion: string;\n\n /**\n * Is model private?\n * This is meant to be used for some internal models - will not be visible in the schema.\n * Only available for the plugin constructed models.\n */\n isPrivate?: boolean;\n}\n\n/**\n * When sending model to the storage operations, it must contain createValueKeyToStorageConverter and createValueKeyFromStorageConverter\n *\n * @category CmsModel\n */\nexport interface StorageOperationsCmsModel extends CmsModel {\n convertValueKeyToStorage: CmsModelConverterCallable;\n convertValueKeyFromStorage: CmsModelConverterCallable;\n}\n\n/**\n * @category ModelField\n */\nexport interface CmsModelFieldDefinition {\n fields: string;\n typeDefs?: string;\n}\n\ninterface CmsModelFieldToGraphQLCreateResolverParams<TField> {\n models: CmsModel[];\n model: CmsModel;\n graphQLType: string;\n field: TField;\n createFieldResolvers: any;\n fieldTypePlugins: CmsFieldTypePlugins;\n}\n\nexport interface CmsModelFieldToGraphQLCreateResolver<TField = CmsModelField> {\n (params: CmsModelFieldToGraphQLCreateResolverParams<TField>):\n | GraphQLFieldResolver\n | { resolver: GraphQLFieldResolver | null; typeResolvers: Resolvers<CmsContext> }\n | false;\n}\n\nexport interface CmsModelFieldToGraphQLPluginValidateChildFieldsValidateParams<\n TField extends CmsModelField = CmsModelField\n> {\n fields: TField[];\n originalFields: TField[];\n}\n\nexport interface CmsModelFieldToGraphQLPluginValidateChildFieldsValidate {\n (params: CmsModelFieldToGraphQLPluginValidateChildFieldsValidateParams): void;\n}\n\nexport interface CmsModelFieldToGraphQLPluginValidateChildFieldsParams<\n TField extends CmsModelField = CmsModelField\n> {\n field: TField;\n originalField?: TField;\n validate: CmsModelFieldToGraphQLPluginValidateChildFieldsValidate;\n}\n\nexport interface CmsModelFieldToGraphQLPluginValidateChildFields<\n TField extends CmsModelField = CmsModelField\n> {\n (params: CmsModelFieldToGraphQLPluginValidateChildFieldsParams<TField>): void;\n}\n\n/**\n * @category Plugin\n * @category ModelField\n * @category GraphQL\n */\nexport interface CmsModelFieldToGraphQLPlugin<TField extends CmsModelField = CmsModelField>\n extends Plugin {\n /**\n * A plugin type\n */\n type: \"cms-model-field-to-graphql\";\n /**\n * Field type name which must be exact as the one in `CmsEditorFieldTypePlugin` plugin.\n *\n * ```ts\n * fieldType: \"myField\"\n * ```\n */\n fieldType: string;\n /**\n * Is the field searchable via the GraphQL?\n *\n * ```ts\n * isSearchable: false\n * ```\n */\n isSearchable: boolean;\n /**\n * Is the field searchable via full text search?\n *\n * Field is not full text searchable by default.\n * ```ts\n * fullTextSearch: false\n * ```\n */\n fullTextSearch?: boolean;\n /**\n * Is the field sortable via the GraphQL?\n *\n * ```ts\n * isSortable: true\n * ```\n */\n isSortable: boolean;\n /**\n * Optional method which creates the storageId.\n * Primary use is for the datetime field, but if users has some specific fields, they can customize the storageId to their needs.\n *\n * ```ts\n * createStorageId: ({field}) => {\n * if (field.settings.type === \"time) {\n * return `${field.type}_time@${field.id}`\n * }\n * // use default method\n * return undefined;\n * }\n * ```\n */\n createStorageId?: (params: {\n model: CmsModel;\n field: Omit<TField, \"storageId\"> & Partial<Pick<TField, \"storageId\">>;\n }) => string | null | undefined;\n /**\n * Read API methods.\n */\n read: {\n /**\n * Definition for get filtering for GraphQL.\n *\n * ```ts\n * read: {\n * createGetFilters({ field }) {\n * return `${field.fieldId}: MyField`;\n * }\n * }\n * ```\n */\n createGetFilters?(params: { field: TField }): string;\n /**\n * Definition for list filtering for GraphQL.\n *\n * ```ts\n * read: {\n * createListFilters({ field }) {\n * return `\n * ${field.fieldId}: MyType\n * ${field.fieldId}_not: MyType\n * ${field.fieldId}_in: [MyType]\n * ${field.fieldId}_not_in: [MyType]\n * `;\n * }\n * }\n * ```\n */\n createListFilters?(params: {\n model: Pick<CmsModel, \"singularApiName\">;\n field: TField;\n plugins: CmsFieldTypePlugins;\n }): string;\n /**\n * Definition of the field type for GraphQL - be aware if multiple values is selected.\n *\n * ```ts\n * read: {\n * createTypeField({ field }) {\n * if (field.multipleValues) {\n * return `${field.fieldId}: [MyFieldType]`;\n * }\n *\n * return `${field.fieldId}: MyField`;\n * }\n * }\n * ```\n */\n createTypeField(params: {\n models: CmsModel[];\n model: CmsModel;\n field: TField;\n fieldTypePlugins: CmsFieldTypePlugins;\n }): CmsModelFieldDefinition | string | null;\n /**\n * Definition for field resolver.\n * By default, it is simple return of the `instance.values[storageId]` but if required, users can define their own.\n *\n * ```ts\n * read: {\n * createResolver({ field }) {\n * return instance => {\n * return instance.values[field.storageId];\n * };\n * }\n * }\n * ```\n */\n createResolver?: CmsModelFieldToGraphQLCreateResolver<TField>;\n /**\n * Read API schema definitions for the field and resolvers for them.\n *\n * ```ts\n * read: {\n * createSchema() {\n * return {\n * typeDefs: `\n * myField {\n * id\n * date\n * }\n * `,\n * resolvers: {}\n * }\n * }\n * }\n * ```\n */\n createSchema?: (params: { models: CmsModel[] }) => GraphQLSchemaDefinition<CmsContext>;\n };\n manage: {\n /**\n * Definition for list filtering for GraphQL.\n *\n * ```ts\n * manage: {\n * createListFilters({ field }) {\n * return `\n * ${field.fieldId}: MyType\n * ${field.fieldId}_not: MyType\n * ${field.fieldId}_in: [MyType]\n * ${field.fieldId}_not_in: [MyType]\n * `;\n * }\n * }\n * ```\n */\n createListFilters?: (params: {\n model: Pick<CmsModel, \"singularApiName\">;\n field: TField;\n plugins: CmsFieldTypePlugins;\n }) => string;\n /**\n * Manage API schema definitions for the field and resolvers for them. Probably similar to `read.createSchema`.\n *\n * ```ts\n * createSchema() {\n * return {\n * typeDefs: `\n * myField {\n * id\n * date\n * }\n * `,\n * resolvers: {}\n * }\n * }\n * ```\n */\n createSchema?: (params: { models: CmsModel[] }) => GraphQLSchemaDefinition<CmsContext>;\n /**\n * Definition of the field type for GraphQL - be aware if multiple values is selected. Probably same as `read.createTypeField`.\n *\n * ```ts\n * manage: {\n * createTypeField({ field }) {\n * if (field.multipleValues) {\n * return field.fieldId + \": [MyType]\";\n * }\n *\n * return field.fieldId + \": MyType\";\n * }\n * }\n * ```\n */\n createTypeField: (params: {\n models: CmsModel[];\n model: CmsModel;\n field: TField;\n fieldTypePlugins: CmsFieldTypePlugins;\n }) => CmsModelFieldDefinition | string | null;\n /**\n * Definition for input GraphQL field type.\n *\n * ```ts\n * manage: {\n * createInputField({ field }) {\n * if (field.multipleValues) {\n * return field.fieldId + \": [MyField]\";\n * }\n *\n * return field.fieldId + \": MyField\";\n * }\n * }\n * ```\n */\n createInputField: (params: {\n models: CmsModel[];\n model: CmsModel;\n field: TField;\n fieldTypePlugins: CmsFieldTypePlugins;\n }) => CmsModelFieldDefinition | string | null;\n /**\n * Definition for field resolver.\n * By default, it is simple return of the `instance.values[storageId]` but if required, users can define their own.\n *\n * ```ts\n * manage: {\n * createResolver({ field }) {\n * return instance => {\n * return instance.values[field.storageId];\n * };\n * }\n * }\n * ```\n */\n createResolver?: CmsModelFieldToGraphQLCreateResolver<TField>;\n };\n /**\n *\n * @param field\n */\n validateChildFields?: CmsModelFieldToGraphQLPluginValidateChildFields<TField>;\n}\n\n/**\n * Check for content model locked field.\n * A custom plugin definable by the user.\n *\n * @category CmsModel\n * @category Plugin\n */\nexport interface CmsModelLockedFieldPlugin extends Plugin {\n /**\n * A plugin type\n */\n type: \"cms-model-locked-field\";\n /**\n * A unique identifier of the field type (text, number, json, myField, ...).\n */\n fieldType: string;\n /**\n * A method to check if field really is locked.\n */\n checkLockedField?: (params: { lockedField: LockedField; field: CmsModelField }) => void;\n /**\n * A method to get the locked field data.\n */\n getLockedFieldData?: (params: { field: CmsModelField }) => Record<string, any>;\n}\n\n/**\n * @category ModelField\n */\nexport interface CmsFieldTypePlugins {\n [key: string]: CmsModelFieldToGraphQLPlugin;\n}\n\n/**\n * An interface describing the reference to a user that created some data in the database.\n *\n * @category General\n */\nexport interface CmsIdentity {\n /**\n * ID if the user.\n */\n id: string;\n /**\n * Full name of the user.\n */\n displayName: string | null;\n /**\n * Type of the user (admin, user)\n */\n type: string;\n}\n\n/**\n * Representation of settings database model.\n *\n * @category Database model\n */\nexport interface CmsSettings {\n /**\n * Last content model change. Used to cache GraphQL schema.\n */\n contentModelLastChange: Date;\n /**\n * Settings tenant.\n */\n tenant: string;\n /**\n * Settings locale.\n */\n locale: string;\n}\n\n/**\n * Settings CRUD in context.\n *\n * @category Context\n */\nexport interface CmsSettingsContext {\n /**\n * Gets settings model from the database.\n */\n getSettings: () => Promise<CmsSettings | null>;\n /**\n * Updates settings model with a new date.\n */\n updateModelLastChange: () => Promise<void>;\n /**\n * Get the datetime when content model last changed.\n */\n getModelLastChange: () => Promise<Date | null>;\n}\n\nexport interface OnSystemBeforeInstallTopicParams {\n tenant: string;\n locale: string;\n}\n\nexport interface OnSystemAfterInstallTopicParams {\n tenant: string;\n locale: string;\n}\n\nexport interface OnSystemInstallErrorTopicParams {\n error: Error;\n tenant: string;\n locale: string;\n}\n\nexport type CmsSystemContext = {\n getSystemVersion: () => Promise<string | null>;\n setSystemVersion: (version: string) => Promise<void>;\n installSystem: () => Promise<void>;\n /**\n * Lifecycle events - deprecated\n */\n /**\n * @deprecated\n */\n onBeforeSystemInstall: Topic<OnSystemBeforeInstallTopicParams>;\n /**\n * @deprecated\n */\n onAfterSystemInstall: Topic<OnSystemAfterInstallTopicParams>;\n /**\n * Released in 5.34.0\n */\n onSystemBeforeInstall: Topic<OnSystemBeforeInstallTopicParams>;\n onSystemAfterInstall: Topic<OnSystemAfterInstallTopicParams>;\n onSystemInstallError: Topic<OnSystemInstallErrorTopicParams>;\n};\n\n/**\n * A GraphQL `params.data` parameter received when creating content model group.\n *\n * @category CmsGroup\n * @category GraphQL params\n */\nexport interface CmsGroupCreateInput {\n name: string;\n slug?: string;\n description?: string;\n icon: string;\n}\n\n/**\n * A GraphQL `params.data` parameter received when updating content model group.\n *\n * @category CmsGroup\n * @category GraphQL params\n */\nexport interface CmsGroupUpdateInput {\n name?: string;\n slug?: string;\n description?: string;\n icon?: string;\n}\n\n/**\n * A representation of content model group in the database.\n *\n * @category CmsGroup\n * @category Database model\n */\nexport interface CmsGroup {\n /**\n * Generated ID.\n */\n id: string;\n /**\n * Name of the group.\n */\n name: string;\n /**\n * Slug for the group. Must be unique.\n */\n slug: string;\n /**\n * Group tenant.\n */\n tenant: string;\n /**\n * Locale this group belongs to.\n */\n locale: string;\n /**\n * Description for the group.\n */\n description: string;\n /**\n * Icon for the group. In a form of \"ico/ico\".\n */\n icon: string;\n /**\n * CreatedBy reference object.\n */\n createdBy?: CmsIdentity;\n /**\n * Date group was created on.\n */\n createdOn?: string;\n /**\n * Date group was created or changed on.\n */\n savedOn?: string;\n /**\n * Which Webiny version was this record stored with.\n */\n webinyVersion: string;\n /**\n * Is group private?\n * This is meant to be used for some internal groups - will not be visible in the schema.\n * Only available for the plugin constructed groups.\n */\n isPrivate?: boolean;\n}\n\n/**\n * A `data.where` parameter received when listing content model groups.\n *\n * @category CmsGroup\n * @category GraphQL params\n */\nexport interface CmsGroupListParams {\n where: {\n tenant: string;\n locale: string;\n };\n}\n\n/**\n * @category CmsGroup\n * @category Topic\n */\nexport interface OnGroupBeforeCreateTopicParams {\n group: CmsGroup;\n}\n\n/**\n * @category CmsGroup\n * @category Topic\n */\nexport interface OnGroupAfterCreateTopicParams {\n group: CmsGroup;\n}\n\n/**\n * @category CmsGroup\n * @category Topic\n */\nexport interface OnGroupCreateErrorTopicParams {\n input: CmsGroupCreateInput;\n group: CmsGroup;\n error: Error;\n}\n\n/**\n * @category CmsGroup\n * @category Topic\n */\nexport interface OnGroupBeforeUpdateTopicParams {\n original: CmsGroup;\n group: CmsGroup;\n}\n\n/**\n * @category CmsGroup\n * @category Topic\n */\nexport interface OnGroupAfterUpdateTopicParams {\n original: CmsGroup;\n group: CmsGroup;\n}\n\n/**\n * @category CmsGroup\n * @category Topic\n */\nexport interface OnGroupUpdateErrorTopicParams {\n input: CmsGroupUpdateInput;\n original: CmsGroup;\n group: CmsGroup;\n error: Error;\n}\n\n/**\n * @category CmsGroup\n * @category Topic\n */\nexport interface OnGroupBeforeDeleteTopicParams {\n group: CmsGroup;\n}\n\n/**\n * @category CmsGroup\n * @category Topic\n */\nexport interface OnGroupAfterDeleteTopicParams {\n group: CmsGroup;\n}\n\n/**\n * @category CmsGroup\n * @category Topic\n */\nexport interface OnGroupDeleteErrorTopicParams {\n group: CmsGroup;\n error: Error;\n}\n\n/**\n * Cms Group in context.\n *\n * @category Context\n * @category CmsGroup\n */\nexport interface CmsGroupContext {\n /**\n * Gets content model group by given id.\n */\n getGroup: (id: string) => Promise<CmsGroup | null>;\n /**\n * List all content model groups. Filterable via params.\n */\n listGroups: (params?: CmsGroupListParams) => Promise<CmsGroup[]>;\n /**\n * Create a new content model group.\n */\n createGroup: (data: CmsGroupCreateInput) => Promise<CmsGroup>;\n /**\n * Update existing content model group.\n */\n updateGroup: (id: string, data: CmsGroupUpdateInput) => Promise<CmsGroup>;\n /**\n * Delete content model group by given id.\n */\n deleteGroup: (id: string) => Promise<boolean>;\n /**\n * Clear the cached groups.\n */\n clearGroupsCache: () => void;\n /**\n * Lifecycle events - deprecated\n */\n /**\n * @deprecated\n */\n onBeforeGroupCreate: Topic<OnGroupBeforeCreateTopicParams>;\n /**\n * @deprecated\n */\n onAfterGroupCreate: Topic<OnGroupAfterCreateTopicParams>;\n /**\n * @deprecated\n */\n onBeforeGroupUpdate: Topic<OnGroupBeforeUpdateTopicParams>;\n /**\n * @deprecated\n */\n onAfterGroupUpdate: Topic<OnGroupAfterUpdateTopicParams>;\n /**\n * @deprecated\n */\n onBeforeGroupDelete: Topic<OnGroupBeforeDeleteTopicParams>;\n /**\n * @deprecated\n */\n onAfterGroupDelete: Topic<OnGroupAfterDeleteTopicParams>;\n /**\n * Lifecycle events released in 5.33.0\n */\n onGroupBeforeCreate: Topic<OnGroupBeforeCreateTopicParams>;\n onGroupAfterCreate: Topic<OnGroupAfterCreateTopicParams>;\n onGroupCreateError: Topic<OnGroupCreateErrorTopicParams>;\n onGroupBeforeUpdate: Topic<OnGroupBeforeUpdateTopicParams>;\n onGroupAfterUpdate: Topic<OnGroupAfterUpdateTopicParams>;\n onGroupUpdateError: Topic<OnGroupUpdateErrorTopicParams>;\n onGroupBeforeDelete: Topic<OnGroupBeforeDeleteTopicParams>;\n onGroupAfterDelete: Topic<OnGroupAfterDeleteTopicParams>;\n onGroupDeleteError: Topic<OnGroupDeleteErrorTopicParams>;\n}\n\n/**\n * Definition for content model field validator.\n *\n * @category ModelField\n * @category FieldValidation\n */\nexport interface CmsModelFieldValidation {\n name: string;\n message: string;\n settings?: {\n value?: string | number;\n values?: string[];\n preset?: string;\n [key: string]: any;\n };\n}\n\n/**\n * A GraphQL `params.data` parameter received when creating content model.\n *\n * @category GraphQL params\n * @category CmsModel\n */\nexport interface CmsModelCreateInput {\n /**\n * Name of the content model.\n */\n name: string;\n /**\n * Singular name of the content model to be used in the API.\n */\n singularApiName: string;\n /**\n * Plural name of the content model to be used in the API.\n */\n pluralApiName: string;\n /**\n * Unique ID of the content model. Created from name if not sent by the user. Cannot be changed.\n */\n modelId?: string;\n /**\n * Description of the content model.\n */\n description?: string | null;\n /**\n * Group where to put the content model in.\n */\n group: string;\n /**\n * A list of content model fields to define the entry values.\n */\n fields?: CmsModelFieldInput[];\n /**\n * Admin UI field layout\n *\n * ```ts\n * layout: [\n * [field1id, field2id],\n * [field3id]\n * ]\n * ```\n */\n layout?: string[][];\n /**\n * Models can be tagged to give them contextual meaning.\n */\n tags?: string[];\n /**\n * Fields fieldId which are picked to represent the CMS entry.\n */\n titleFieldId?: string | null;\n descriptionFieldId?: string | null;\n imageFieldId?: string | null;\n}\n\n/**\n * A GraphQL `params.data` parameter received when creating content model from existing model.\n *\n * @category GraphQL params\n * @category CmsModel\n */\nexport interface CmsModelCreateFromInput extends CmsModelCreateInput {\n /**\n * Locale into which we want to clone the model into.\n */\n locale?: string;\n}\n\n/**\n * A definition for content model field received from the user.\n *\n * Input type for `CmsModelField`.\n * @see CmsModelField\n *\n * @category GraphQL params\n * @category ModelField\n */\nexport interface CmsModelFieldInput {\n /**\n * Generated ID.\n */\n id: string;\n /**\n * Type of the field. A plugin for the field must be defined.\n * @see CmsModelFieldToGraphQLPlugin\n */\n type: string;\n /**\n * Field outside world identifier for the field. Must be unique in the model.\n */\n fieldId: string;\n /**\n * Label for the field.\n */\n label: string;\n /**\n * Text to display below the field to help user what to write in the field.\n */\n helpText?: string | null;\n /**\n * Text to display in the field.\n */\n placeholderText?: string | null;\n /**\n * Fields can be tagged to give them contextual meaning.\n */\n tags?: string[];\n /**\n * Are multiple values allowed?\n */\n multipleValues?: boolean;\n /**\n * Predefined values options for the field. Check the reference for more information.\n */\n predefinedValues?: CmsModelFieldPredefinedValues;\n /**\n * Renderer options for the field. Check the reference for more information.\n */\n renderer?: CmsModelFieldRenderer;\n /**\n * List of validations for the field.\n */\n validation?: CmsModelFieldValidation[];\n /**\n * @see CmsModelField.listValidation\n */\n listValidation?: CmsModelFieldValidation[];\n /**\n * User defined settings.\n */\n settings?: Record<string, any>;\n}\n\n/**\n * A GraphQL `params.data` parameter received when updating content model.\n *\n * @category GraphQL params\n * @category CmsModel\n */\nexport interface CmsModelUpdateInput {\n /**\n * A new content model name.\n */\n name?: string;\n /**\n * A new singular name of the content model to be used in the API.\n */\n singularApiName?: string;\n /**\n * A new plural name of the content model to be used in the API.\n */\n pluralApiName?: string;\n /**\n * A group we want to move the model to.\n */\n group?: string;\n /**\n * A new description of the content model.\n */\n description?: string | null;\n /**\n * A list of content model fields to define the entry values.\n */\n fields: CmsModelFieldInput[];\n /**\n * Admin UI field layout\n *\n * ```ts\n * layout: [\n * [field1id, field2id],\n * [field3id]\n * ]\n * ```\n */\n layout: string[][];\n /**\n * Fields fieldId which are picked to represent the CMS entry.\n */\n titleFieldId?: string | null;\n descriptionFieldId?: string | null;\n imageFieldId?: string | null;\n}\n\n/**\n * A plugin to load a CmsModelManager.\n *\n * @see CmsModelManager\n *\n * @category Plugin\n * @category CmsModel\n * @category CmsEntry\n */\nexport interface ModelManagerPlugin extends Plugin {\n /**\n * A plugin type.\n */\n type: \"cms-content-model-manager\";\n /**\n * Specific model CmsModelManager loader. Can target exact modelId(s).\n * Be aware that if you define multiple plugins without `modelId`, last one will run.\n */\n modelId?: string[] | string;\n /**\n * Create a CmsModelManager for specific type - or new default one.\n * For reference in how is this plugin run check [contentModelManagerFactory](https://github.com/webiny/webiny-js/blob/f15676/packages/api-headless-cms/src/content/plugins/CRUD/contentModel/contentModelManagerFactory.ts)\n */\n create: (context: CmsContext, model: CmsModel) => Promise<CmsModelManager>;\n}\n\n/**\n * A content entry values definition for and from the database.\n *\n * @category Database model\n * @category CmsEntry\n */\nexport interface CmsEntryValues {\n [key: string]: any;\n}\n\n/**\n * A content entry definition for and from the database.\n *\n * @category Database model\n * @category CmsEntry\n */\nexport interface CmsEntry<T = CmsEntryValues> {\n /**\n * A version of the webiny this entry was created with.\n * This can be used when upgrading the system, so we know which entries to update.\n */\n webinyVersion: string;\n /**\n * Tenant id which is this entry for. Can be used in case of shared storage.\n */\n tenant: string;\n /**\n * Generated ID of the entry. It is shared across all the records in the database that represent a single entry.\n * So version 1, 2, ..., 2371 will have the same value in this field to link them together.\n */\n entryId: string;\n /**\n * Generated ID + version of the entry.\n */\n id: string;\n /**\n * CreatedBy object reference.\n */\n createdBy: CmsIdentity;\n /**\n * OwnedBy object reference. Can be different from CreatedBy.\n */\n ownedBy: CmsIdentity;\n /**\n * ModifiedBy object reference. Last person who modified the entry.\n */\n modifiedBy?: CmsIdentity | null;\n /**\n * A string of Date.toISOString() type.\n * Populated on creation.\n */\n createdOn: string;\n /**\n * A string of Date.toISOString() type.\n * Populated every time entry is saved.\n */\n savedOn: string;\n /**\n * Model ID of the definition for the entry.\n * @see CmsModel\n */\n modelId: string;\n /**\n * A locale of the entry.\n * @see I18NLocale.code\n */\n locale: string;\n /**\n * A string of Date.toISOString() type - if published.\n * Populated when entry is published.\n */\n publishedOn?: string;\n /**\n * A revision version of the entry.\n */\n version: number;\n /**\n * Is the entry locked?\n */\n locked: boolean;\n /**\n * Status type of the entry.\n */\n status: CmsEntryStatus;\n /**\n * A mapped storageId -> value object.\n *\n * @see CmsModelField\n */\n values: T;\n /**\n * Advanced Content Organization\n */\n location?: {\n folderId?: string | null;\n };\n /**\n * Settings for the given entry.\n *\n * Introduced with Advanced Publishing Workflow. Will always be inserted once this PR is merged.\n * Be aware that when accessing properties in it on old systems, it will break if not checked first.\n *\n * Available only on the Manage API in entry GraphQL type `meta.data` property.\n */\n meta?: {\n [key: string]: any;\n };\n}\n\nexport interface CmsStorageEntry extends CmsEntry {\n [key: string]: any;\n}\n\nexport interface CmsEntryUniqueValue {\n value: string;\n count: number;\n}\n\n/**\n * A definition for content model manager to be used in the code.\n * The default one uses `CmsEntryContext` methods internally, but devs can change to what every they want.\n *\n * @see CmsEntryContext\n *\n * @category Context\n * @category CmsEntry\n * @category CmsModel\n */\nexport interface CmsModelManager {\n /**\n * List only published entries in the content model.\n */\n listPublished: (params: CmsEntryListParams) => Promise<[CmsEntry[], CmsEntryMeta]>;\n /**\n * List latest entries in the content model. Used for administration.\n */\n listLatest: (params: CmsEntryListParams) => Promise<[CmsEntry[], CmsEntryMeta]>;\n /**\n * Get a list of published entries by the ID list.\n */\n getPublishedByIds: (ids: string[]) => Promise<CmsEntry[]>;\n /**\n * Get a list of the latest entries by the ID list.\n */\n getLatestByIds: (ids: string[]) => Promise<CmsEntry[]>;\n /**\n * Get an entry filtered by given params. Will always get one.\n */\n get: (id: string) => Promise<CmsEntry>;\n /**\n * Create an entry.\n */\n create: (data: CreateCmsEntryInput) => Promise<CmsEntry>;\n /**\n * Update an entry.\n */\n update: (id: string, data: UpdateCmsEntryInput) => Promise<CmsEntry>;\n /**\n * Delete an entry.\n */\n delete: (id: string) => Promise<void>;\n}\n\n/**\n * Create\n */\nexport interface OnModelBeforeCreateTopicParams {\n input: CmsModelCreateInput;\n model: CmsModel;\n}\n\nexport interface OnModelAfterCreateTopicParams {\n input: CmsModelCreateInput;\n model: CmsModel;\n}\n\nexport interface OnModelCreateErrorTopicParams {\n input: CmsModelCreateInput;\n model: CmsModel;\n error: Error;\n}\n\n/**\n * Create From / Clone\n */\nexport interface OnModelBeforeCreateFromTopicParams {\n input: CmsModelCreateInput;\n original: CmsModel;\n model: CmsModel;\n}\n\nexport interface OnModelAfterCreateFromTopicParams {\n input: CmsModelCreateInput;\n original: CmsModel;\n model: CmsModel;\n}\n\nexport interface OnModelCreateFromErrorParams {\n input: CmsModelCreateInput;\n original: CmsModel;\n model: CmsModel;\n error: Error;\n}\n\n/**\n * Update\n */\nexport interface OnModelBeforeUpdateTopicParams {\n input: CmsModelUpdateInput;\n original: CmsModel;\n model: CmsModel;\n}\n\nexport interface OnModelAfterUpdateTopicParams {\n input: CmsModelUpdateInput;\n original: CmsModel;\n model: CmsModel;\n}\n\nexport interface OnModelUpdateErrorTopicParams {\n input: CmsModelUpdateInput;\n original: CmsModel;\n model: CmsModel;\n error: Error;\n}\n\n/**\n * Delete\n */\nexport interface OnModelBeforeDeleteTopicParams {\n model: CmsModel;\n}\n\nexport interface OnModelAfterDeleteTopicParams {\n model: CmsModel;\n}\n\nexport interface OnModelDeleteErrorTopicParams {\n model: CmsModel;\n error: Error;\n}\n\n/**\n * Initialize\n */\nexport interface OnModelInitializeParams {\n model: CmsModel;\n data: Record<string, any>;\n}\n\n/**\n *\n */\nexport interface CmsModelUpdateDirectParams {\n model: CmsModel;\n original: CmsModel;\n}\n\n/**\n * Cms Model in the context.\n *\n * @category Context\n * @category CmsModel\n */\nexport interface CmsModelContext {\n /**\n * Get a single content model.\n */\n getModel: (modelId: string) => Promise<CmsModel | null>;\n /**\n * Get all content models.\n */\n listModels: () => Promise<CmsModel[]>;\n /**\n * Create a content model.\n */\n createModel: (data: CmsModelCreateInput) => Promise<CmsModel>;\n /**\n * Create a content model from the given model - clone.\n */\n createModelFrom: (modelId: string, data: CmsModelCreateFromInput) => Promise<CmsModel>;\n /**\n * Update content model without data validation. Used internally.\n * @hidden\n */\n updateModelDirect: (params: CmsModelUpdateDirectParams) => Promise<CmsModel>;\n /**\n * Update content model.\n */\n updateModel: (modelId: string, data: CmsModelUpdateInput) => Promise<CmsModel>;\n /**\n * Delete content model. Should not allow deletion if there are entries connected to it.\n */\n deleteModel: (modelId: string) => Promise<void>;\n /**\n * Possibility for users to trigger the model initialization.\n * They can hook into it and do what ever they want to.\n *\n * Primary idea behind this is creating the index, for the code models, in the ES.\n */\n initializeModel: (modelId: string, data: Record<string, any>) => Promise<boolean>;\n /**\n * Get an instance of CmsModelManager for given content modelId.\n *\n * @see CmsModelManager\n *\n * @deprecated use the getEntryManager() method instead\n */\n getModelManager: (model: CmsModel | string) => Promise<CmsModelManager>;\n getEntryManager: (model: CmsModel | string) => Promise<CmsModelManager>;\n /**\n * Get all content model managers mapped by modelId.\n * @see CmsModelManager\n * @deprecated use getEntryManagers instead\n */\n getManagers: () => Map<string, CmsModelManager>;\n getEntryManagers: () => Map<string, CmsModelManager>;\n /**\n * Clear all the model caches.\n */\n clearModelsCache: () => void;\n /**\n * Lifecycle events - deprecated.\n */\n /**\n * @deprecated\n */\n onBeforeModelCreate: Topic<OnModelBeforeCreateTopicParams>;\n /**\n * @deprecated\n */\n onAfterModelCreate: Topic<OnModelAfterCreateTopicParams>;\n /**\n * @deprecated\n */\n onBeforeModelCreateFrom: Topic<OnModelBeforeCreateFromTopicParams>;\n /**\n * @deprecated\n */\n onAfterModelCreateFrom: Topic<OnModelAfterCreateFromTopicParams>;\n /**\n * @deprecated\n */\n onBeforeModelUpdate: Topic<OnModelBeforeUpdateTopicParams>;\n /**\n * @deprecated\n */\n onAfterModelUpdate: Topic<OnModelAfterUpdateTopicParams>;\n /**\n * @deprecated\n */\n onBeforeModelDelete: Topic<OnModelBeforeDeleteTopicParams>;\n /**\n * @deprecated\n */\n onAfterModelDelete: Topic<OnModelAfterDeleteTopicParams>;\n /**\n * Lifecycle events - released in 5.33.0\n */\n onModelBeforeCreate: Topic<OnModelBeforeCreateTopicParams>;\n onModelAfterCreate: Topic<OnModelAfterCreateTopicParams>;\n onModelCreateError: Topic<OnModelCreateErrorTopicParams>;\n onModelBeforeCreateFrom: Topic<OnModelBeforeCreateFromTopicParams>;\n onModelAfterCreateFrom: Topic<OnModelAfterCreateFromTopicParams>;\n onModelCreateFromError: Topic<OnModelCreateFromErrorParams>;\n onModelBeforeUpdate: Topic<OnModelBeforeUpdateTopicParams>;\n onModelAfterUpdate: Topic<OnModelAfterUpdateTopicParams>;\n onModelUpdateError: Topic<OnModelUpdateErrorTopicParams>;\n onModelBeforeDelete: Topic<OnModelBeforeDeleteTopicParams>;\n onModelAfterDelete: Topic<OnModelAfterDeleteTopicParams>;\n onModelDeleteError: Topic<OnModelDeleteErrorTopicParams>;\n onModelInitialize: Topic<OnModelInitializeParams>;\n}\n\n/**\n * Available statuses for content entry.\n *\n * @category CmsEntry\n */\nexport type CmsEntryStatus = \"published\" | \"unpublished\" | \"draft\";\n\nexport interface CmsEntryListWhereRef {\n id?: string;\n id_in?: string[];\n id_not?: string;\n id_not_in?: string[];\n entryId?: string;\n entryId_not?: string;\n entryId_in?: string[];\n entryId_not_in?: string[];\n}\n\n/**\n * Entry listing where params.\n *\n * @category CmsEntry\n * @category GraphQL params\n */\nexport interface CmsEntryListWhere {\n /**\n * Fields.\n */\n id?: string;\n id_in?: string[];\n id_not?: string;\n id_not_in?: string[];\n /**\n * Generated ID without the version.\n */\n entryId?: string;\n entryId_not?: string;\n entryId_in?: string[];\n entryId_not_in?: string[];\n /**\n * Contains the owner of the entry. An \"owner\" is the identity who originally created the entry.\n * Subsequent revisions can be created by other identities, and those will be stored in `createdBy`,\n * but the `owner` is always the original author of the entry.\n *\n * Can be sent via the API or set internal if user can see only their own entries.\n */\n ownedBy?: string;\n ownedBy_not?: string;\n ownedBy_in?: string[];\n ownedBy_not_in?: string[];\n /**\n * Who created the entry?\n */\n createdBy?: string;\n createdBy_not?: string;\n createdBy_in?: string[];\n createdBy_not_in?: string[];\n /**\n * Version of the entry.\n *\n * It is not meant to be used via the API.\n * @internal\n */\n version?: number;\n version_lt?: number;\n version_gt?: number;\n /**\n * Each storage operations implementation MUST determine how to use this field.\n * In SQL, it can be a `published` field, and in DynamoDB it can be an SK.\n *\n * It is not meant to be used via the API.\n * @internal\n */\n published?: boolean;\n /**\n * Each storage operations implementation MUST determine how to use this field.\n * In SQL, it can be a `latest` field, and in DynamoDB it can be an SK.\n *\n * It is not meant to be used via the API.\n * @internal\n */\n latest?: boolean;\n /**\n * This is to allow querying by any content model field defined by the user.\n */\n [key: string]:\n | string\n | number\n | boolean\n | undefined\n | string[]\n | number[]\n | null\n | CmsEntryListWhere[]\n | CmsEntryListWhere\n | CmsEntryListWhereRef;\n /**\n * To allow querying via nested queries, we added the AND / OR properties.\n */\n AND?: CmsEntryListWhere[];\n OR?: CmsEntryListWhere[];\n}\n\n/**\n * Entry listing sort.\n *\n * @category CmsEntry\n * @category GraphQL params\n */\nexport type CmsEntryListSort = string[];\n\n/**\n * Get entry GraphQL resolver params.\n *\n * @category CmsEntry\n * @category GraphQL params\n */\nexport interface CmsEntryGetParams {\n where: CmsEntryListWhere;\n sort?: CmsEntryListSort;\n}\n\n/**\n * List entries GraphQL resolver params.\n *\n * @category CmsEntry\n * @category GraphQL params\n */\nexport interface CmsEntryListParams {\n where?: CmsEntryListWhere;\n sort?: CmsEntryListSort;\n search?: string;\n fields?: string[];\n limit?: number;\n after?: string | null;\n}\n\n/**\n * Meta information for GraphQL output.\n *\n * @category CmsEntry\n * @category GraphQL output\n */\nexport interface CmsEntryMeta {\n /**\n * A cursor for pagination.\n */\n cursor: string | null;\n /**\n * Is there more items to load?\n */\n hasMoreItems: boolean;\n /**\n * Total count of the items in the storage.\n */\n totalCount: number;\n}\n\n/**\n * Create\n */\nexport interface OnEntryBeforeCreateTopicParams {\n input: CreateCmsEntryInput;\n entry: CmsEntry;\n model: CmsModel;\n}\n\nexport interface OnEntryAfterCreateTopicParams {\n input: CreateCmsEntryInput;\n entry: CmsEntry;\n model: CmsModel;\n storageEntry: CmsEntry;\n}\n\nexport interface OnEntryCreateErrorTopicParams {\n error: Error;\n input: CreateCmsEntryInput;\n entry: CmsEntry;\n model: CmsModel;\n}\n\n/**\n * Revision Create\n */\nexport interface OnEntryRevisionBeforeCreateTopicParams {\n input: CreateFromCmsEntryInput;\n entry: CmsEntry;\n original: CmsEntry;\n model: CmsModel;\n}\n\nexport interface OnEntryRevisionAfterCreateTopicParams {\n input: CreateFromCmsEntryInput;\n entry: CmsEntry;\n original: CmsEntry;\n model: CmsModel;\n storageEntry: CmsEntry;\n}\n\nexport interface OnEntryCreateRevisionErrorTopicParams {\n error: Error;\n input: CreateFromCmsEntryInput;\n original: CmsEntry;\n entry: CmsEntry;\n model: CmsModel;\n}\n\n/**\n * Update\n */\nexport interface OnEntryBeforeUpdateTopicParams {\n input: UpdateCmsEntryInput;\n original: CmsEntry;\n entry: CmsEntry;\n model: CmsModel;\n}\n\nexport interface OnEntryAfterUpdateTopicParams {\n input: UpdateCmsEntryInput;\n original: CmsEntry;\n entry: CmsEntry;\n model: CmsModel;\n storageEntry: CmsEntry;\n}\n\nexport interface OnEntryUpdateErrorTopicParams {\n error: Error;\n input: UpdateCmsEntryInput;\n entry: CmsEntry;\n model: CmsModel;\n}\n\n/**\n * Move\n */\nexport interface OnEntryBeforeMoveTopicParams {\n folderId: string;\n entry: CmsEntry;\n model: CmsModel;\n}\n\nexport interface OnEntryAfterMoveTopicParams {\n folderId: string;\n entry: CmsEntry;\n model: CmsModel;\n}\n\nexport interface OnEntryMoveErrorTopicParams {\n error: Error;\n folderId: string;\n entry: CmsEntry;\n model: CmsModel;\n}\n\n/**\n * Publish\n */\n\nexport interface OnEntryBeforePublishTopicParams {\n entry: CmsEntry;\n model: CmsModel;\n}\n\nexport interface OnEntryAfterPublishTopicParams {\n entry: CmsEntry;\n model: CmsModel;\n storageEntry: CmsEntry;\n}\n\nexport interface OnEntryPublishErrorTopicParams {\n error: Error;\n entry: CmsEntry;\n model: CmsModel;\n}\n\n/**\n * Republish\n */\nexport interface OnEntryBeforeRepublishTopicParams {\n entry: CmsEntry;\n model: CmsModel;\n}\n\nexport interface OnEntryAfterRepublishTopicParams {\n entry: CmsEntry;\n model: CmsModel;\n storageEntry: CmsEntry;\n}\n\nexport interface OnEntryRepublishErrorTopicParams {\n error: Error;\n entry: CmsEntry;\n model: CmsModel;\n}\n\n/**\n * Unpublish\n */\n\nexport interface OnEntryBeforeUnpublishTopicParams {\n entry: CmsEntry;\n model: CmsModel;\n}\n\nexport interface OnEntryAfterUnpublishTopicParams {\n entry: CmsEntry;\n model: CmsModel;\n storageEntry: CmsEntry;\n}\n\nexport interface OnEntryUnpublishErrorTopicParams {\n error: Error;\n entry: CmsEntry;\n model: CmsModel;\n}\n\nexport interface OnEntryBeforeDeleteTopicParams {\n entry: CmsEntry;\n model: CmsModel;\n}\n\nexport interface OnEntryAfterDeleteTopicParams {\n entry: CmsEntry;\n model: CmsModel;\n}\n\nexport interface OnEntryDeleteErrorTopicParams {\n error: Error;\n entry: CmsEntry;\n model: CmsModel;\n}\n\nexport interface OnEntryRevisionBeforeDeleteTopicParams {\n entry: CmsEntry;\n model: CmsModel;\n}\n\nexport interface OnEntryRevisionAfterDeleteTopicParams {\n entry: CmsEntry;\n model: CmsModel;\n}\n\nexport interface OnEntryRevisionDeleteErrorTopicParams {\n error: Error;\n entry: CmsEntry;\n model: CmsModel;\n}\n\nexport interface OnEntryBeforeDeleteMultipleTopicParams {\n model: CmsModel;\n entries: CmsEntry[];\n ids: string[];\n}\n\nexport interface OnEntryAfterDeleteMultipleTopicParams {\n model: CmsModel;\n entries: CmsEntry[];\n ids: string[];\n}\n\nexport interface OnEntryDeleteMultipleErrorTopicParams {\n model: CmsModel;\n entries: CmsEntry[];\n ids: string[];\n error: Error;\n}\n\nexport interface OnEntryBeforeGetTopicParams {\n model: CmsModel;\n where: CmsEntryListWhere;\n}\n\nexport interface EntryBeforeListTopicParams {\n where: CmsEntryListWhere;\n model: CmsModel;\n}\n\n/**\n * @category Context\n * @category CmsEntry\n */\nexport interface CreateCmsEntryInput {\n id?: string;\n wbyAco_location?: {\n folderId?: string | null;\n };\n [key: string]: any;\n}\n\n/**\n * @category Context\n * @category CmsEntry\n */\nexport interface CreateFromCmsEntryInput {\n [key: string]: any;\n}\n\n/**\n * @category Context\n * @category CmsEntry\n */\nexport interface UpdateCmsEntryInput {\n wbyAco_location?: {\n folderId?: string | null;\n };\n [key: string]: any;\n}\n\n/**\n * @category Context\n * @category CmsEntry\n */\nexport interface GetUniqueFieldValuesParams {\n where: CmsEntryListWhere;\n fieldId: string;\n}\n\n/**\n * @category CmsEntry\n */\nexport interface CmsDeleteEntryOptions {\n /**\n * Runs the delete commands even if the entry is not found in the DynamoDB.\n * This is to force clean the entry records that might have been left behind a failed delete.\n */\n force?: boolean;\n}\n\n/**\n * @category Context\n * @category CmsEntry\n */\nexport interface DeleteMultipleEntriesParams {\n entries: string[];\n}\n\nexport type DeleteMultipleEntriesResponse = { id: string }[];\n\n/**\n * Cms Entry CRUD methods in the context.\n *\n * @category Context\n * @category CmsEntry\n */\nexport interface CmsEntryContext {\n /**\n * Get a single content entry for a model.\n */\n getEntry: (model: CmsModel, params: CmsEntryGetParams) => Promise<CmsEntry>;\n /**\n * Get a list of entries for a model by a given ID (revision).\n */\n getEntriesByIds: (model: CmsModel, revisions: string[]) => Promise<CmsEntry[]>;\n /**\n * Get the entry for a model by a given ID.\n */\n getEntryById: (model: CmsModel, revision: string) => Promise<CmsEntry>;\n /**\n * List entries for a model. Internal method used by get, listLatest and listPublished.\n */\n listEntries: <T = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryListParams\n ) => Promise<[CmsEntry<T>[], CmsEntryMeta]>;\n /**\n * Lists the latest entries. Used for manage API.\n */\n listLatestEntries: <T = CmsEntryValues>(\n model: CmsModel,\n params?: CmsEntryListParams\n ) => Promise<[CmsEntry<T>[], CmsEntryMeta]>;\n /**\n * List published entries. Used for read API.\n */\n listPublishedEntries: <T = CmsEntryValues>(\n model: CmsModel,\n params?: CmsEntryListParams\n ) => Promise<[CmsEntry<T>[], CmsEntryMeta]>;\n /**\n * List published entries by IDs.\n */\n getPublishedEntriesByIds: (model: CmsModel, ids: string[]) => Promise<CmsEntry[]>;\n /**\n * List latest entries by IDs.\n */\n getLatestEntriesByIds: (model: CmsModel, ids: string[]) => Promise<CmsEntry[]>;\n /**\n * Create a new content entry.\n */\n createEntry: (model: CmsModel, input: CreateCmsEntryInput) => Promise<CmsEntry>;\n /**\n * Create a new entry from already existing entry.\n */\n createEntryRevisionFrom: (\n model: CmsModel,\n id: string,\n input: CreateFromCmsEntryInput\n ) => Promise<CmsEntry>;\n /**\n * Update existing entry.\n */\n updateEntry: (\n model: CmsModel,\n id: string,\n input: UpdateCmsEntryInput,\n meta?: Record<string, any>\n ) => Promise<CmsEntry>;\n /**\n * Move entry, and all its revisions, to a new folder.\n */\n moveEntry: (model: CmsModel, id: string, folderId: string) => Promise<CmsEntry>;\n /**\n * Method that republishes entry with given identifier.\n * @internal\n */\n republishEntry: (model: CmsModel, id: string) => Promise<CmsEntry>;\n /**\n * Delete only a certain revision of the entry.\n */\n deleteEntryRevision: (model: CmsModel, id: string) => Promise<void>;\n /**\n * Delete entry with all its revisions.\n */\n deleteEntry: (model: CmsModel, id: string, options?: CmsDeleteEntryOptions) => Promise<void>;\n /**\n * Delete multiple entries\n */\n deleteMultipleEntries: (\n model: CmsModel,\n params: DeleteMultipleEntriesParams\n ) => Promise<DeleteMultipleEntriesResponse>;\n /**\n * Publish entry.\n */\n publishEntry: (model: CmsModel, id: string) => Promise<CmsEntry>;\n /**\n * Unpublish entry.\n */\n unpublishEntry: (model: CmsModel, id: string) => Promise<CmsEntry>;\n /**\n * Get all entry revisions.\n */\n getEntryRevisions: (model: CmsModel, id: string) => Promise<CmsEntry[]>;\n /**\n * List all unique values for a given field.\n *\n * @internal\n */\n getUniqueFieldValues: (\n model: CmsModel,\n params: GetUniqueFieldValuesParams\n ) => Promise<CmsEntryUniqueValue[]>;\n /**\n * Lifecycle events - deprecated.\n */\n /**\n * @deprecated\n */\n onBeforeEntryCreate: Topic<OnEntryBeforeCreateTopicParams>;\n /**\n * @deprecated\n */\n onAfterEntryCreate: Topic<OnEntryAfterCreateTopicParams>;\n /**\n * @deprecated\n */\n onBeforeEntryCreateRevision: Topic<OnEntryRevisionBeforeCreateTopicParams>;\n /**\n * @deprecated\n */\n onAfterEntryCreateRevision: Topic<OnEntryRevisionAfterCreateTopicParams>;\n /**\n * @deprecated\n */\n onBeforeEntryUpdate: Topic<OnEntryBeforeUpdateTopicParams>;\n /**\n * @deprecated\n */\n onAfterEntryUpdate: Topic<OnEntryAfterUpdateTopicParams>;\n /**\n * @deprecated\n */\n onBeforeEntryDelete: Topic<OnEntryBeforeDeleteTopicParams>;\n /**\n * @deprecated\n */\n onAfterEntryDelete: Topic<OnEntryAfterDeleteTopicParams>;\n /**\n * @deprecated\n */\n onBeforeEntryDeleteRevision: Topic<OnEntryRevisionBeforeDeleteTopicParams>;\n /**\n * @deprecated\n */\n onAfterEntryDeleteRevision: Topic<OnEntryRevisionAfterDeleteTopicParams>;\n /**\n * @deprecated\n */\n onBeforeEntryPublish: Topic<OnEntryBeforePublishTopicParams>;\n /**\n * @deprecated\n */\n onAfterEntryPublish: Topic<OnEntryAfterPublishTopicParams>;\n /**\n * @deprecated\n */\n onBeforeEntryUnpublish: Topic<OnEntryBeforeUnpublishTopicParams>;\n /**\n * @deprecated\n */\n onAfterEntryUnpublish: Topic<OnEntryAfterUnpublishTopicParams>;\n /**\n * @deprecated\n */\n onBeforeEntryGet: Topic<OnEntryBeforeGetTopicParams>;\n /**\n * @deprecated\n */\n onBeforeEntryList: Topic<EntryBeforeListTopicParams>;\n /**\n * Lifecycle events released in 5.33.0\n */\n onEntryBeforeCreate: Topic<OnEntryBeforeCreateTopicParams>;\n onEntryAfterCreate: Topic<OnEntryAfterCreateTopicParams>;\n onEntryCreateError: Topic<OnEntryCreateErrorTopicParams>;\n\n onEntryRevisionBeforeCreate: Topic<OnEntryRevisionBeforeCreateTopicParams>;\n onEntryRevisionAfterCreate: Topic<OnEntryRevisionAfterCreateTopicParams>;\n onEntryRevisionCreateError: Topic<OnEntryCreateRevisionErrorTopicParams>;\n\n onEntryBeforeUpdate: Topic<OnEntryBeforeUpdateTopicParams>;\n onEntryAfterUpdate: Topic<OnEntryAfterUpdateTopicParams>;\n onEntryUpdateError: Topic<OnEntryUpdateErrorTopicParams>;\n\n onEntryBeforeMove: Topic<OnEntryBeforeMoveTopicParams>;\n onEntryAfterMove: Topic<OnEntryAfterMoveTopicParams>;\n onEntryMoveError: Topic<OnEntryMoveErrorTopicParams>;\n\n onEntryBeforeDelete: Topic<OnEntryBeforeDeleteTopicParams>;\n onEntryAfterDelete: Topic<OnEntryAfterDeleteTopicParams>;\n onEntryDeleteError: Topic<OnEntryDeleteErrorTopicParams>;\n\n onEntryRevisionBeforeDelete: Topic<OnEntryRevisionBeforeDeleteTopicParams>;\n onEntryRevisionAfterDelete: Topic<OnEntryRevisionAfterDeleteTopicParams>;\n onEntryRevisionDeleteError: Topic<OnEntryRevisionDeleteErrorTopicParams>;\n\n onEntryBeforePublish: Topic<OnEntryBeforePublishTopicParams>;\n onEntryAfterPublish: Topic<OnEntryAfterPublishTopicParams>;\n onEntryPublishError: Topic<OnEntryPublishErrorTopicParams>;\n\n onEntryBeforeRepublish: Topic<OnEntryBeforeRepublishTopicParams>;\n onEntryAfterRepublish: Topic<OnEntryAfterRepublishTopicParams>;\n onEntryRepublishError: Topic<OnEntryRepublishErrorTopicParams>;\n\n onEntryBeforeUnpublish: Topic<OnEntryBeforeUnpublishTopicParams>;\n onEntryAfterUnpublish: Topic<OnEntryAfterUnpublishTopicParams>;\n onEntryUnpublishError: Topic<OnEntryUnpublishErrorTopicParams>;\n\n onEntryBeforeGet: Topic<OnEntryBeforeGetTopicParams>;\n onEntryBeforeList: Topic<EntryBeforeListTopicParams>;\n}\n\n/**\n * Parameters for CmsEntryResolverFactory.\n *\n * @category GraphQL resolver\n * @category CmsEntry\n */\ninterface CmsEntryResolverFactoryParams {\n model: CmsModel;\n}\n\n/**\n * A type for EntryResolvers. Used when creating get, list, update, publish, ...etc.\n *\n * @category GraphQL resolver\n * @category CmsEntry\n */\nexport type CmsEntryResolverFactory<TSource = any, TArgs = any, TContext = CmsContext> = {\n (params: CmsEntryResolverFactoryParams): GraphQLFieldResolver<TSource, TArgs, TContext>;\n};\n\n/**\n * Settings security permission.\n *\n * @category SecurityPermission\n */\nexport interface CmsSettingsPermission extends SecurityPermission {} // eslint-disable-line\n\n/**\n * A base security permission for CMS.\n *\n * @category SecurityPermission\n */\nexport interface BaseCmsSecurityPermission extends SecurityPermission {\n own?: boolean;\n rwd: string | number;\n}\n\n/**\n * A security permission for content model.\n *\n * @category SecurityPermission\n * @category CmsModel\n */\nexport interface CmsModelPermission extends BaseCmsSecurityPermission {\n /**\n * An object representing `key: model.modelId` values where key is locale code.\n */\n models?: {\n [key: string]: string[];\n };\n /**\n * {locale: groupId[]} map, where key is a locale code.\n */\n groups?: {\n [key: string]: string[];\n };\n}\n\n/**\n * The security permission for content model groups.\n *\n * @category SecurityPermission\n * @category CmsGroup\n */\nexport interface CmsGroupPermission extends BaseCmsSecurityPermission {\n /**\n * {locale: groupId[]} map, where key is a locale code.\n */\n groups?: {\n [key: string]: string[];\n };\n}\n\n/**\n * The security permission for content entry.\n *\n * @category SecurityPermission\n * @category CmsEntry\n */\nexport interface CmsEntryPermission extends BaseCmsSecurityPermission {\n pw?: string;\n /**\n * An object representing `key: model.modelId` values where key is locale code.\n */\n models?: {\n [key: string]: string[];\n };\n /**\n * {locale: groupId[]} map, where key is a locale code.\n */\n groups?: {\n [key: string]: string[];\n };\n}\n\nexport interface CmsGroupStorageOperationsGetParams {\n id: string;\n tenant: string;\n locale: string;\n}\n\nexport interface CmsGroupStorageOperationsListWhereParams {\n tenant: string;\n locale: string;\n [key: string]: any;\n}\n\nexport interface CmsGroupStorageOperationsListParams {\n where: CmsGroupStorageOperationsListWhereParams;\n sort?: string[];\n}\n\nexport interface CmsGroupStorageOperationsCreateParams {\n group: CmsGroup;\n}\n\nexport interface CmsGroupStorageOperationsUpdateParams {\n group: CmsGroup;\n}\n\nexport interface CmsGroupStorageOperationsDeleteParams {\n group: CmsGroup;\n}\n\n/**\n * Description of the CmsGroup CRUD operations.\n * If user wants to add another database to the application, this is how it is done.\n * This is just plain read, update, write, delete and list - no authentication or permission checks.\n */\nexport interface CmsGroupStorageOperations {\n /**\n * Gets content model group by given id.\n */\n get: (params: CmsGroupStorageOperationsGetParams) => Promise<CmsGroup | null>;\n /**\n * List all content model groups. Filterable via params.\n */\n list: (params: CmsGroupStorageOperationsListParams) => Promise<CmsGroup[]>;\n /**\n * Create a new content model group.\n */\n create: (params: CmsGroupStorageOperationsCreateParams) => Promise<CmsGroup>;\n /**\n * Update existing content model group.\n */\n update: (params: CmsGroupStorageOperationsUpdateParams) => Promise<CmsGroup>;\n /**\n * Delete the content model group.\n */\n delete: (params: CmsGroupStorageOperationsDeleteParams) => Promise<CmsGroup>;\n}\n\nexport interface CmsModelStorageOperationsGetParams {\n tenant: string;\n locale: string;\n modelId: string;\n}\n\nexport interface CmsModelStorageOperationsListWhereParams {\n tenant: string;\n locale: string;\n [key: string]: string;\n}\n\nexport interface CmsModelStorageOperationsListParams {\n where: CmsModelStorageOperationsListWhereParams;\n}\n\nexport interface CmsModelStorageOperationsCreateParams {\n model: CmsModel;\n}\n\nexport interface CmsModelStorageOperationsUpdateParams {\n model: CmsModel;\n}\n\nexport interface CmsModelStorageOperationsDeleteParams {\n model: CmsModel;\n}\n\n/**\n * Description of the CmsModel storage operations.\n * If user wants to add another database to the application, this is how it is done.\n * This is just plain read, update, write, delete and list - no authentication or permission checks.\n */\nexport interface CmsModelStorageOperations {\n /**\n * Gets content model by given id.\n */\n get: (params: CmsModelStorageOperationsGetParams) => Promise<CmsModel | null>;\n /**\n * List all content models. Filterable via params.\n */\n list: (params: CmsModelStorageOperationsListParams) => Promise<CmsModel[]>;\n /**\n * Create a new content model.\n */\n create: (params: CmsModelStorageOperationsCreateParams) => Promise<CmsModel>;\n /**\n * Update existing content model.\n */\n update: (params: CmsModelStorageOperationsUpdateParams) => Promise<CmsModel>;\n /**\n * Delete the content model.\n */\n delete: (params: CmsModelStorageOperationsDeleteParams) => Promise<CmsModel>;\n}\n\nexport interface CmsEntryStorageOperationsGetParams {\n where: CmsEntryListWhere;\n sort?: CmsEntryListSort;\n limit?: number;\n}\n\nexport interface CmsEntryStorageOperationsListParams {\n where: CmsEntryListWhere;\n sort?: CmsEntryListSort;\n search?: string;\n fields?: string[];\n limit: number;\n after?: string | null;\n}\n\nexport interface CmsEntryStorageOperationsCreateParams<\n T extends CmsStorageEntry = CmsStorageEntry\n> {\n /**\n * Real entry, with no transformations on it.\n */\n entry: CmsEntry;\n /**\n * Entry prepared for the storage.\n */\n storageEntry: T;\n}\n\nexport interface CmsEntryStorageOperationsCreateRevisionFromParams<\n T extends CmsStorageEntry = CmsStorageEntry\n> {\n /**\n * Real entry, with no transformations on it.\n */\n entry: CmsEntry;\n /**\n * Entry prepared for the storage.\n */\n storageEntry: T;\n}\n\nexport interface CmsEntryStorageOperationsUpdateParams<\n T extends CmsStorageEntry = CmsStorageEntry\n> {\n /**\n * Real entry, with no transformations on it.\n */\n entry: CmsEntry;\n /**\n * Entry prepared for the storage.\n */\n storageEntry: T;\n}\n\nexport interface CmsEntryStorageOperationsDeleteRevisionParams<\n T extends CmsStorageEntry = CmsStorageEntry\n> {\n /**\n * Entry that was deleted.\n */\n entry: CmsEntry;\n /**\n * Entry that was deleted, directly from storage, with transformations.\n */\n storageEntry: T;\n /**\n * Entry that was set as latest.\n */\n latestEntry: CmsEntry | null;\n /**\n * Entry that was set as latest, directly from storage, with transformations.\n */\n latestStorageEntry: T | null;\n}\n\nexport interface CmsEntryStorageOperationsDeleteParams {\n entry: CmsEntry;\n}\n\nexport interface CmsEntryStorageOperationsDeleteEntriesParams {\n entries: string[];\n}\n\nexport interface CmsEntryStorageOperationsPublishParams<\n T extends CmsStorageEntry = CmsStorageEntry\n> {\n /**\n * The modified entry that is going to be saved as published.\n * Entry is in its original form.\n */\n entry: CmsEntry;\n /**\n * The modified entry and prepared for the storage.\n */\n storageEntry: T;\n}\n\nexport interface CmsEntryStorageOperationsUnpublishParams<\n T extends CmsStorageEntry = CmsStorageEntry\n> {\n /**\n * The modified entry that is going to be saved as unpublished.\n */\n entry: CmsEntry;\n /**\n * The modified entry that is going to be saved as unpublished, with transformations on it.\n */\n storageEntry: T;\n}\n\nexport interface CmsEntryStorageOperationsGetUniqueFieldValuesParams {\n where: CmsEntryListWhere;\n fieldId: string;\n}\n\nexport interface CmsEntryStorageOperationsGetByIdsParams {\n ids: readonly string[];\n}\n\nexport interface CmsEntryStorageOperationsGetLatestByIdsParams {\n ids: readonly string[];\n}\n\nexport interface CmsEntryStorageOperationsGetPublishedByIdsParams {\n ids: readonly string[];\n}\n\nexport interface CmsEntryStorageOperationsGetRevisionsParams {\n id: string;\n}\n\nexport interface CmsEntryStorageOperationsGetRevisionParams {\n id: string;\n}\n\nexport interface CmsEntryStorageOperationsGetPublishedRevisionParams {\n id: string;\n}\n\nexport interface CmsEntryStorageOperationsGetLatestRevisionParams {\n id: string;\n}\n\nexport interface CmsEntryStorageOperationsGetPreviousRevisionParams {\n entryId: string;\n version: number;\n}\n\nexport interface CmsEntryStorageOperationsListResponse<\n T extends CmsStorageEntry = CmsStorageEntry\n> {\n /**\n * Has more items to load with the current filtering?\n */\n hasMoreItems: boolean;\n /**\n * Items loaded with current filtering.\n */\n items: T[];\n /**\n * Pointer for where to start the new item set.\n */\n cursor: string | null;\n /**\n * Total amount of items with the current filter.\n */\n totalCount: number;\n}\n\n/**\n * Description of the CmsModel storage operations.\n * If user wants to add another database to the application, this is how it is done.\n * This is just plain read, update, write, delete and list - no authentication or permission checks.\n *\n *\n * @category StorageOperations\n * @category CmsEntry\n */\nexport interface CmsEntryStorageOperations<T extends CmsStorageEntry = CmsStorageEntry> {\n /**\n * Get all the entries of the ids.\n */\n getByIds: (model: CmsModel, params: CmsEntryStorageOperationsGetByIdsParams) => Promise<T[]>;\n /**\n * Get all the published entries of the ids.\n */\n getPublishedByIds: (\n model: CmsModel,\n params: CmsEntryStorageOperationsGetPublishedByIdsParams\n ) => Promise<T[]>;\n /**\n * Get all the latest entries of the ids.\n */\n getLatestByIds: (\n model: CmsModel,\n params: CmsEntryStorageOperationsGetLatestByIdsParams\n ) => Promise<T[]>;\n /**\n * Get all revisions of the given entry id.\n */\n getRevisions: (\n model: CmsModel,\n params: CmsEntryStorageOperationsGetRevisionsParams\n ) => Promise<T[]>;\n /**\n * Get the entry by the given revision id.\n */\n getRevisionById: (\n model: CmsModel,\n params: CmsEntryStorageOperationsGetRevisionParams\n ) => Promise<T | null>;\n /**\n * Get the published entry by given entryId.\n */\n getPublishedRevisionByEntryId: (\n model: CmsModel,\n params: CmsEntryStorageOperationsGetPublishedRevisionParams\n ) => Promise<T | null>;\n /**\n * Get the latest entry by given entryId.\n */\n getLatestRevisionByEntryId: (\n model: CmsModel,\n params: CmsEntryStorageOperationsGetLatestRevisionParams\n ) => Promise<T | null>;\n /**\n * Get the revision of the entry before given one.\n */\n getPreviousRevision: (\n model: CmsModel,\n params: CmsEntryStorageOperationsGetPreviousRevisionParams\n ) => Promise<T | null>;\n /**\n * Gets entry by given params.\n */\n get: (model: CmsModel, params: CmsEntryStorageOperationsGetParams) => Promise<T | null>;\n /**\n * List all entries. Filterable via params.\n */\n list: (\n model: CmsModel,\n params: CmsEntryStorageOperationsListParams\n ) => Promise<CmsEntryStorageOperationsListResponse<T>>;\n /**\n * Create a new entry.\n */\n create: (model: CmsModel, params: CmsEntryStorageOperationsCreateParams<T>) => Promise<T>;\n /**\n * Create a new entry from existing one.\n */\n createRevisionFrom: (\n model: CmsModel,\n params: CmsEntryStorageOperationsCreateRevisionFromParams<T>\n ) => Promise<T>;\n /**\n * Update existing entry.\n */\n update: (model: CmsModel, params: CmsEntryStorageOperationsUpdateParams<T>) => Promise<T>;\n /**\n * Move entry and all its entries into a new folder.\n */\n move: (model: CmsModel, id: string, folderId: string) => Promise<void>;\n /**\n * Delete the entry revision.\n */\n deleteRevision: (\n model: CmsModel,\n params: CmsEntryStorageOperationsDeleteRevisionParams<T>\n ) => Promise<void>;\n /**\n * Delete the entry.\n */\n delete: (model: CmsModel, params: CmsEntryStorageOperationsDeleteParams) => Promise<void>;\n /**\n * Delete multiple entries, with a limit on how much can be deleted in one call.\n */\n deleteMultipleEntries: (\n model: CmsModel,\n params: CmsEntryStorageOperationsDeleteEntriesParams\n ) => Promise<void>;\n /**\n * Publish the entry.\n */\n publish: (model: CmsModel, params: CmsEntryStorageOperationsPublishParams<T>) => Promise<T>;\n /**\n * Unpublish the entry.\n */\n unpublish: (model: CmsModel, params: CmsEntryStorageOperationsUnpublishParams<T>) => Promise<T>;\n /**\n * Method to list all the unique values for the given field id.\n * Simplest use case would be to aggregate tags for some content.\n * @internal\n */\n getUniqueFieldValues: (\n model: CmsModel,\n params: CmsEntryStorageOperationsGetUniqueFieldValuesParams\n ) => Promise<CmsEntryUniqueValue[]>;\n}\n\nexport enum CONTENT_ENTRY_STATUS {\n DRAFT = \"draft\",\n PUBLISHED = \"published\",\n UNPUBLISHED = \"unpublished\"\n}\n\nexport interface CmsSettingsStorageOperationsGetParams {\n locale: string;\n tenant: string;\n}\n\nexport interface CmsSettingsStorageOperationsCreateParams {\n settings: CmsSettings;\n}\n\nexport interface CmsSettingsStorageOperationsUpdateParams {\n settings: CmsSettings;\n}\n\nexport interface CmsSettingsStorageOperations {\n /**\n * Get the settings from the storage.\n */\n get: (params: CmsSettingsStorageOperationsGetParams) => Promise<CmsSettings | null>;\n /**\n * Create settings in the storage.\n */\n create: (params: CmsSettingsStorageOperationsCreateParams) => Promise<CmsSettings>;\n /**\n * Update the settings in the storage.\n */\n update: (params: CmsSettingsStorageOperationsUpdateParams) => Promise<CmsSettings>;\n}\n\nexport interface CmsSystem {\n version?: string;\n readAPIKey?: string;\n /**\n * System tenant.\n */\n tenant: string;\n}\n\nexport interface CmsSystemStorageOperationsGetParams {\n tenant: string;\n}\n\nexport interface CmsSystemStorageOperationsCreateParams {\n system: CmsSystem;\n}\n\nexport interface CmsSystemStorageOperationsUpdateParams {\n system: CmsSystem;\n}\n\nexport interface CmsSystemStorageOperations {\n /**\n * Get the system data.\n */\n get: (params: CmsSystemStorageOperationsGetParams) => Promise<CmsSystem | null>;\n /**\n * Create the system info in the storage.\n */\n create: (params: CmsSystemStorageOperationsCreateParams) => Promise<CmsSystem>;\n /**\n * Update the system info in the storage.\n */\n update: (params: CmsSystemStorageOperationsUpdateParams) => Promise<CmsSystem>;\n}\n\nexport interface HeadlessCmsStorageOperations<C = CmsContext> {\n name: string;\n system: CmsSystemStorageOperations;\n settings: CmsSettingsStorageOperations;\n groups: CmsGroupStorageOperations;\n models: CmsModelStorageOperations;\n entries: CmsEntryStorageOperations;\n /**\n * Either attach something from the storage operations or run something in it.\n */\n beforeInit: (context: C) => Promise<void>;\n init?: (context: C) => Promise<void>;\n}\n"],"mappings":";;;;;;AAoEA;AACA;AACA;AACA;AACA;AAcA;AACA;AACA;AACA;AACA;AAYA;AACA;AACA;AACA;AACA;AASA;AACA;AACA;AACA;AACA;AACA;AA6CA;AACA;AACA;AACA;AACA;AACA;AAgGA;AACA;AACA;AAUA;AACA;AACA;AASA;AACA;AACA;AAUA;AACA;AACA;AACA;AACA;AACA;AAgCA;AACA;AACA;AACA;AACA;AACA;AACA;AAqBA;AACA;AACA;AACA;AACA;AACA;AACA;AAyBA;AACA;AACA;AACA;AACA;AACA;AACA;AAkBA;AACA;AACA;AACA;AAYA;AACA;AACA;AACA;AACA;AACA;AA+GA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AA+CA;AACA;AACA;AACA;AACA;AAiQA;AACA;AACA;AACA;AACA;AACA;AACA;AAoBA;AACA;AACA;AAKA;AACA;AACA;AACA;AACA;AAgBA;AACA;AACA;AACA;AACA;AAgBA;AACA;AACA;AACA;AACA;AAuDA;AACA;AACA;AACA;AACA;AACA;AAQA;AACA;AACA;AACA;AACA;AACA;AAQA;AACA;AACA;AACA;AACA;AACA;AAsDA;AACA;AACA;AACA;AACA;AACA;AAQA;AACA;AACA;AACA;AAKA;AACA;AACA;AACA;AAKA;AACA;AACA;AACA;AAOA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AAQA;AACA;AACA;AACA;AAKA;AACA;AACA;AACA;AAKA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AACA;AAmEA;AACA;AACA;AACA;AACA;AACA;AAYA;AACA;AACA;AACA;AACA;AACA;AAqDA;AACA;AACA;AACA;AACA;AACA;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAyDA;AACA;AACA;AACA;AACA;AACA;AA6CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAkBA;AACA;AACA;AACA;AACA;AACA;AAKA;AACA;AACA;AACA;AACA;AACA;AAuGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAoCA;AACA;AACA;AAiBA;AACA;AACA;AAoBA;AACA;AACA;AAoBA;AACA;AACA;AAcA;AACA;AACA;AAMA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AACA;AA+GA;AACA;AACA;AACA;AACA;AAcA;AACA;AACA;AACA;AACA;AACA;AAgFA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AACA;AAUA;AACA;AACA;AACA;AACA;AACA;AAgBA;AACA;AACA;AAqBA;AACA;AACA;AAwBA;AACA;AACA;AAuBA;AACA;AACA;AAoBA;AACA;AACA;AAmBA;AACA;AACA;AAkBA;AACA;AACA;AAgFA;AACA;AACA;AACA;AASA;AACA;AACA;AACA;AAKA;AACA;AACA;AACA;AAQA;AACA;AACA;AACA;AAMA;AACA;AACA;AASA;AACA;AACA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AA2NA;AACA;AACA;AACA;AACA;AACA;AAKA;AACA;AACA;AACA;AACA;AACA;AAKA;AACA;AACA;AACA;AACA;AACqE;AAErE;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AACA;AAgBA;AACA;AACA;AACA;AACA;AACA;AAUA;AACA;AACA;AACA;AACA;AACA;AA8CA;AACA;AACA;AACA;AACA;AAoDA;AACA;AACA;AACA;AACA;AAiMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AARA,IAkIYA,oBAAoB,0BAApBA,oBAAoB;EAApBA,oBAAoB;EAApBA,oBAAoB;EAApBA,oBAAoB;EAAA,OAApBA,oBAAoB;AAAA;AAAAC,OAAA,CAAAD,oBAAA,GAAAA,oBAAA"}
@@ -5,14 +5,13 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.filterAsync = void 0;
7
7
  const filterAsync = async (items, predicate) => {
8
- const filteredItems = [];
9
- for (let i = 0; i < items.length; i++) {
10
- const item = items[i];
8
+ const filteredItems = await Promise.all(items.map(async item => {
11
9
  const valid = await predicate(item);
12
- if (valid) {
13
- filteredItems.push(item);
10
+ if (!valid) {
11
+ return null;
14
12
  }
15
- }
16
- return filteredItems;
13
+ return item;
14
+ }));
15
+ return filteredItems.filter(Boolean);
17
16
  };
18
17
  exports.filterAsync = filterAsync;
@@ -1 +1 @@
1
- {"version":3,"names":["filterAsync","items","predicate","filteredItems","i","length","item","valid","push","exports"],"sources":["filterAsync.ts"],"sourcesContent":["export const filterAsync = async <T = Record<string, any>>(\n items: T[],\n predicate: (param: T) => Promise<boolean>\n): Promise<T[]> => {\n const filteredItems = [];\n\n for (let i = 0; i < items.length; i++) {\n const item = items[i];\n const valid = await predicate(item);\n if (valid) {\n filteredItems.push(item);\n }\n }\n\n return filteredItems;\n};\n"],"mappings":";;;;;;AAAO,MAAMA,WAAW,GAAG,MAAAA,CACvBC,KAAU,EACVC,SAAyC,KAC1B;EACf,MAAMC,aAAa,GAAG,EAAE;EAExB,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGH,KAAK,CAACI,MAAM,EAAED,CAAC,EAAE,EAAE;IACnC,MAAME,IAAI,GAAGL,KAAK,CAACG,CAAC,CAAC;IACrB,MAAMG,KAAK,GAAG,MAAML,SAAS,CAACI,IAAI,CAAC;IACnC,IAAIC,KAAK,EAAE;MACPJ,aAAa,CAACK,IAAI,CAACF,IAAI,CAAC;IAC5B;EACJ;EAEA,OAAOH,aAAa;AACxB,CAAC;AAACM,OAAA,CAAAT,WAAA,GAAAA,WAAA"}
1
+ {"version":3,"names":["filterAsync","items","predicate","filteredItems","Promise","all","map","item","valid","filter","Boolean","exports"],"sources":["filterAsync.ts"],"sourcesContent":["export const filterAsync = async <T = Record<string, any>>(\n items: T[],\n predicate: (param: T) => Promise<boolean>\n): Promise<T[]> => {\n const filteredItems = await Promise.all(\n items.map(async item => {\n const valid = await predicate(item);\n if (!valid) {\n return null;\n }\n return item;\n })\n );\n\n return filteredItems.filter(Boolean) as T[];\n};\n"],"mappings":";;;;;;AAAO,MAAMA,WAAW,GAAG,MAAAA,CACvBC,KAAU,EACVC,SAAyC,KAC1B;EACf,MAAMC,aAAa,GAAG,MAAMC,OAAO,CAACC,GAAG,CACnCJ,KAAK,CAACK,GAAG,CAAC,MAAMC,IAAI,IAAI;IACpB,MAAMC,KAAK,GAAG,MAAMN,SAAS,CAACK,IAAI,CAAC;IACnC,IAAI,CAACC,KAAK,EAAE;MACR,OAAO,IAAI;IACf;IACA,OAAOD,IAAI;EACf,CAAC,CACL,CAAC;EAED,OAAOJ,aAAa,CAACM,MAAM,CAACC,OAAO,CAAC;AACxC,CAAC;AAACC,OAAA,CAAAX,WAAA,GAAAA,WAAA"}