@webiny/api-headless-cms 6.4.0-beta.3 → 6.4.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/features/contentEntry/entryDataFactories/CreateEntryDataFactory/CreateEntryDataFactory.js +5 -1
- package/features/contentEntry/entryDataFactories/CreateEntryDataFactory/CreateEntryDataFactory.js.map +1 -1
- package/features/contentEntry/entryDataFactories/CreateEntryRevisionFromDataFactory/CreateEntryRevisionFromDataFactory.js +2 -1
- package/features/contentEntry/entryDataFactories/CreateEntryRevisionFromDataFactory/CreateEntryRevisionFromDataFactory.js.map +1 -1
- package/features/contentEntry/entryDataFactories/UpdateEntryDataFactory/UpdateEntryDataFactory.js +5 -1
- package/features/contentEntry/entryDataFactories/UpdateEntryDataFactory/UpdateEntryDataFactory.js.map +1 -1
- package/features/contentEntry/entryDataFactories/expiresAt.d.ts +5 -0
- package/features/contentEntry/entryDataFactories/expiresAt.js +9 -0
- package/features/contentEntry/entryDataFactories/expiresAt.js.map +1 -0
- package/features/webhooks/CmsWebhookFactory.js +7 -3
- package/features/webhooks/CmsWebhookFactory.js.map +1 -1
- package/features/webhooks/feature.js +4 -0
- package/features/webhooks/feature.js.map +1 -1
- package/features/webhooks/handlers/OnEntryDeletedHandler.d.ts +1 -1
- package/features/webhooks/handlers/OnEntryDeletedHandler.js +2 -1
- package/features/webhooks/handlers/OnEntryDeletedHandler.js.map +1 -1
- package/features/webhooks/handlers/OnEntryRestoredHandler.d.ts +11 -0
- package/features/webhooks/handlers/OnEntryRestoredHandler.js +22 -0
- package/features/webhooks/handlers/OnEntryRestoredHandler.js.map +1 -0
- package/features/webhooks/handlers/OnEntryTrashedHandler.d.ts +11 -0
- package/features/webhooks/handlers/OnEntryTrashedHandler.js +23 -0
- package/features/webhooks/handlers/OnEntryTrashedHandler.js.map +1 -0
- package/graphql/schema/createSingularSDL.js +2 -0
- package/graphql/schema/createSingularSDL.js.map +1 -1
- package/package.json +26 -24
- package/types/types.d.ts +6 -0
- package/types/types.js.map +1 -1
package/features/contentEntry/entryDataFactories/CreateEntryDataFactory/CreateEntryDataFactory.js
CHANGED
|
@@ -13,6 +13,7 @@ import { STATUS_DRAFT, STATUS_PUBLISHED, STATUS_UNPUBLISHED } from "../statuses.
|
|
|
13
13
|
import { getIdentity } from "../../../../utils/identity.js";
|
|
14
14
|
import { NotAuthorizedError } from "../../../../utils/errors.js";
|
|
15
15
|
import { getSystem } from "../system.js";
|
|
16
|
+
import { getExpiresAt } from "../expiresAt.js";
|
|
16
17
|
const convertDefaultValue = (field, value)=>{
|
|
17
18
|
switch(field.type){
|
|
18
19
|
case "boolean":
|
|
@@ -169,7 +170,10 @@ class CreateEntryDataFactoryImpl {
|
|
|
169
170
|
live: status === STATUS_PUBLISHED ? {
|
|
170
171
|
version
|
|
171
172
|
} : null,
|
|
172
|
-
revisionDescription: ""
|
|
173
|
+
revisionDescription: "",
|
|
174
|
+
expiresAt: getExpiresAt({
|
|
175
|
+
expiresAt: rawInput.expiresAt
|
|
176
|
+
})
|
|
173
177
|
};
|
|
174
178
|
if (status !== STATUS_DRAFT) {
|
|
175
179
|
if (status === STATUS_PUBLISHED) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/contentEntry/entryDataFactories/CreateEntryDataFactory/CreateEntryDataFactory.js","sources":["../../../../../src/features/contentEntry/entryDataFactories/CreateEntryDataFactory/CreateEntryDataFactory.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/feature/api\";\nimport {\n CreateEntryDataFactory as FactoryAbstraction,\n type ICreateEntryDataFactory,\n type ICreateEntryDataResponse\n} from \"./abstractions.js\";\nimport { AccessControl, CmsContext } from \"~/features/shared/abstractions.js\";\nimport { TenantContext } from \"@webiny/api-core/features/tenancy/TenantContext/index.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport type {\n CmsEntry,\n CmsEntryValues,\n CmsModel,\n CmsModelField,\n CreateCmsEntryInput,\n CreateCmsEntryOptionsInput\n} from \"~/types/index.js\";\nimport { getDate } from \"~/utils/date.js\";\nimport { ROOT_FOLDER } from \"~/constants.js\";\nimport WebinyError from \"@webiny/error\";\nimport { validateModelEntryDataOrThrow } from \"~/crud/contentEntry/entryDataValidation.js\";\nimport { referenceFieldsMapping } from \"~/crud/contentEntry/referenceFieldsMapping.js\";\nimport { createIdentifier, mdbid } from \"@webiny/utils\";\nimport { STATUS_DRAFT, STATUS_PUBLISHED, STATUS_UNPUBLISHED } from \"../statuses.js\";\nimport { getIdentity } from \"~/utils/identity.js\";\nimport { NotAuthorizedError } from \"~/utils/errors.js\";\nimport { getSystem } from \"../system.js\";\n\ntype DefaultValue = boolean | number | string | null;\n\nconst convertDefaultValue = (field: CmsModelField, value: DefaultValue): DefaultValue => {\n switch (field.type) {\n case \"boolean\":\n return Boolean(value);\n case \"number\":\n return Number(value);\n default:\n return value;\n }\n};\n\nconst getDefaultValue = (field: CmsModelField): (DefaultValue | DefaultValue[]) | undefined => {\n const { settings, list } = field;\n if (settings && settings.defaultValue !== undefined) {\n return convertDefaultValue(field, settings.defaultValue);\n }\n const { predefinedValues } = field;\n if (\n !predefinedValues ||\n !predefinedValues.enabled ||\n Array.isArray(predefinedValues.values) === false\n ) {\n return undefined;\n }\n if (!list) {\n const selectedValue = predefinedValues.values.find(value => {\n return !!value.selected;\n });\n if (selectedValue) {\n return convertDefaultValue(field, selectedValue.value);\n }\n return undefined;\n }\n return predefinedValues.values\n .filter(({ selected }) => !!selected)\n .map(({ value }) => {\n return convertDefaultValue(field, value);\n });\n};\n\nconst cleanInputValues = <TValues extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n input: TValues\n) => {\n return model.fields.reduce<TValues>((acc, field) => {\n if (!field.fieldId) {\n throw new WebinyError(\"Field does not have an fieldId.\", \"MISSING_FIELD_ID\", {\n field\n });\n }\n const key = field.fieldId as keyof TValues;\n const value = input[key] as TValues[keyof TValues];\n acc[key] = value === undefined ? (getDefaultValue(field) as TValues[keyof TValues]) : value;\n return acc;\n }, {} as TValues);\n};\n\nconst createEntryId = (input: CreateCmsEntryInput) => {\n let entryId = mdbid();\n if (input.id) {\n if (input.id.match(/^([a-zA-Z0-9])([a-zA-Z0-9-]+)([a-zA-Z0-9])$/) === null) {\n throw new WebinyError(\n \"The provided ID is not valid. It must be a string which can be A-Z, a-z, 0-9, - and it cannot start or end with a -.\",\n \"INVALID_ID\",\n {\n id: input.id\n }\n );\n }\n entryId = input.id;\n }\n const version = 1;\n return {\n entryId,\n version,\n id: createIdentifier({\n id: entryId,\n version\n })\n };\n};\n\nclass CreateEntryDataFactoryImpl implements ICreateEntryDataFactory {\n public constructor(\n private readonly cmsContext: CmsContext.Interface,\n private readonly identityContext: IdentityContext.Interface,\n private readonly tenantContext: TenantContext.Interface,\n private readonly accessControl: AccessControl.Interface\n ) {}\n\n public async create<TValues extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n rawInput: CreateCmsEntryInput<TValues>,\n options?: CreateCmsEntryOptionsInput\n ): Promise<ICreateEntryDataResponse<TValues>> {\n const initialValues = cleanInputValues<TValues>(model, rawInput.values || ({} as TValues));\n\n await validateModelEntryDataOrThrow({\n context: this.cmsContext,\n model,\n values: initialValues,\n skipValidators: options?.skipValidators\n });\n\n const values = await referenceFieldsMapping<TValues>({\n context: this.cmsContext,\n model,\n values: initialValues,\n validateEntries: true\n });\n\n const { id, entryId, version } = createEntryId(rawInput);\n\n const currentIdentity = this.identityContext.getIdentity();\n const currentDateTime = new Date();\n\n const status = rawInput.status || STATUS_DRAFT;\n if (status !== STATUS_DRAFT) {\n if (status === STATUS_PUBLISHED) {\n const canPublish = await this.accessControl.canAccessEntry({ model, pw: \"p\" });\n if (!canPublish) {\n throw new NotAuthorizedError(\n `Not allowed to access \"${model.modelId}\" entries.`\n );\n }\n } else if (status === STATUS_UNPUBLISHED) {\n const canUnpublish = await this.accessControl.canAccessEntry({ model, pw: \"u\" });\n if (!canUnpublish) {\n throw new NotAuthorizedError(\n `Not allowed to access \"${model.modelId}\" entries.`\n );\n }\n }\n }\n\n const locked = status !== STATUS_DRAFT;\n\n let revisionLevelPublishingMetaFields: Pick<\n CmsEntry,\n | \"revisionFirstPublishedOn\"\n | \"revisionLastPublishedOn\"\n | \"revisionFirstPublishedBy\"\n | \"revisionLastPublishedBy\"\n > = {\n revisionFirstPublishedOn: null,\n revisionLastPublishedOn: null,\n revisionFirstPublishedBy: null,\n revisionLastPublishedBy: null\n };\n\n let entryLevelPublishingMetaFields: Pick<\n CmsEntry,\n \"firstPublishedOn\" | \"lastPublishedOn\" | \"firstPublishedBy\" | \"lastPublishedBy\"\n > = {\n firstPublishedOn: null,\n lastPublishedOn: null,\n firstPublishedBy: null,\n lastPublishedBy: null\n };\n\n if (status === STATUS_PUBLISHED) {\n revisionLevelPublishingMetaFields = {\n revisionFirstPublishedOn: getDate(\n rawInput.revisionFirstPublishedOn,\n currentDateTime\n ),\n revisionLastPublishedOn: getDate(rawInput.revisionLastPublishedOn, currentDateTime),\n revisionFirstPublishedBy: getIdentity(\n rawInput.revisionFirstPublishedBy,\n currentIdentity\n ),\n revisionLastPublishedBy: getIdentity(\n rawInput.revisionLastPublishedBy,\n currentIdentity\n )\n };\n\n entryLevelPublishingMetaFields = {\n firstPublishedOn: getDate(rawInput.firstPublishedOn, currentDateTime),\n lastPublishedOn: getDate(rawInput.lastPublishedOn, currentDateTime),\n firstPublishedBy: getIdentity(rawInput.firstPublishedBy, currentIdentity),\n lastPublishedBy: getIdentity(rawInput.lastPublishedBy, currentIdentity)\n };\n }\n\n const entry: CmsEntry<TValues> = {\n tenant: this.tenantContext.getTenant().id,\n entryId,\n id,\n modelId: model.modelId,\n createdOn: getDate(rawInput.createdOn, currentDateTime),\n modifiedOn: getDate(rawInput.modifiedOn, null),\n savedOn: getDate(rawInput.savedOn, currentDateTime),\n deletedOn: getDate(rawInput.deletedOn, null),\n restoredOn: getDate(rawInput.restoredOn, null),\n createdBy: getIdentity(rawInput.createdBy, currentIdentity)!,\n modifiedBy: getIdentity(rawInput.modifiedBy, null),\n savedBy: getIdentity(rawInput.savedBy, currentIdentity)!,\n deletedBy: getIdentity(rawInput.deletedBy, null),\n restoredBy: getIdentity(rawInput.restoredBy, null),\n ...entryLevelPublishingMetaFields,\n revisionCreatedOn: getDate(rawInput.revisionCreatedOn, currentDateTime),\n revisionModifiedOn: getDate(rawInput.revisionModifiedOn, null),\n revisionSavedOn: getDate(rawInput.revisionSavedOn, currentDateTime),\n revisionDeletedOn: getDate(rawInput.revisionDeletedOn, null),\n revisionRestoredOn: getDate(rawInput.revisionRestoredOn, null),\n revisionCreatedBy: getIdentity(rawInput.revisionCreatedBy, currentIdentity)!,\n revisionModifiedBy: getIdentity(rawInput.revisionModifiedBy, null),\n revisionSavedBy: getIdentity(rawInput.revisionSavedBy, currentIdentity)!,\n revisionDeletedBy: getIdentity(rawInput.revisionDeletedBy, null),\n revisionRestoredBy: getIdentity(rawInput.revisionRestoredBy, null),\n ...revisionLevelPublishingMetaFields,\n version,\n status,\n locked,\n values,\n location: {\n folderId:\n rawInput.location?.folderId || rawInput.wbyAco_location?.folderId || ROOT_FOLDER\n },\n system: getSystem({\n input: rawInput\n }),\n live:\n status === STATUS_PUBLISHED\n ? {\n version\n }\n : null,\n revisionDescription: \"\"\n };\n\n if (status !== STATUS_DRAFT) {\n if (status === STATUS_PUBLISHED) {\n const canPublish = await this.accessControl.canAccessEntry({\n model,\n entry,\n pw: \"p\"\n });\n if (!canPublish) {\n throw new NotAuthorizedError(`Not allowed to access entry \"${entry.entryId}\".`);\n }\n } else if (status === STATUS_UNPUBLISHED) {\n const canUnpublish = await this.accessControl.canAccessEntry({\n model,\n entry,\n pw: \"u\"\n });\n if (!canUnpublish) {\n throw new NotAuthorizedError(`Not allowed to access entry \"${entry.entryId}\".`);\n }\n }\n }\n\n return {\n entry,\n input: {\n ...rawInput,\n values: structuredClone(values)\n }\n };\n }\n}\n\nexport const CreateEntryDataFactory = createImplementation({\n abstraction: FactoryAbstraction,\n implementation: CreateEntryDataFactoryImpl,\n dependencies: [CmsContext, IdentityContext, TenantContext, AccessControl]\n});\n"],"names":["convertDefaultValue","field","value","Boolean","Number","getDefaultValue","settings","list","undefined","predefinedValues","Array","selectedValue","selected","cleanInputValues","model","input","acc","WebinyError","key","createEntryId","entryId","mdbid","version","createIdentifier","CreateEntryDataFactoryImpl","cmsContext","identityContext","tenantContext","accessControl","rawInput","options","initialValues","validateModelEntryDataOrThrow","values","referenceFieldsMapping","id","currentIdentity","currentDateTime","Date","status","STATUS_DRAFT","STATUS_PUBLISHED","canPublish","NotAuthorizedError","STATUS_UNPUBLISHED","canUnpublish","locked","revisionLevelPublishingMetaFields","entryLevelPublishingMetaFields","getDate","getIdentity","entry","ROOT_FOLDER","getSystem","structuredClone","CreateEntryDataFactory","createImplementation","FactoryAbstraction","CmsContext","IdentityContext","TenantContext","AccessControl"],"mappings":";;;;;;;;;;;;;;;AA8BA,MAAMA,sBAAsB,CAACC,OAAsBC;IAC/C,OAAQD,MAAM,IAAI;QACd,KAAK;YACD,OAAOE,QAAQD;QACnB,KAAK;YACD,OAAOE,OAAOF;QAClB;YACI,OAAOA;IACf;AACJ;AAEA,MAAMG,kBAAkB,CAACJ;IACrB,MAAM,EAAEK,QAAQ,EAAEC,IAAI,EAAE,GAAGN;IAC3B,IAAIK,YAAYA,AAA0BE,WAA1BF,SAAS,YAAY,EACjC,OAAON,oBAAoBC,OAAOK,SAAS,YAAY;IAE3D,MAAM,EAAEG,gBAAgB,EAAE,GAAGR;IAC7B,IACI,CAACQ,oBACD,CAACA,iBAAiB,OAAO,IACzBC,AAA2C,UAA3CA,MAAM,OAAO,CAACD,iBAAiB,MAAM,GAErC;IAEJ,IAAI,CAACF,MAAM;QACP,MAAMI,gBAAgBF,iBAAiB,MAAM,CAAC,IAAI,CAACP,CAAAA,QACxC,CAAC,CAACA,MAAM,QAAQ;QAE3B,IAAIS,eACA,OAAOX,oBAAoBC,OAAOU,cAAc,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B,SAAS,kBAAkB,EAAE;YAC7D,GAAGkB,iCAAiC;YACpCzB;YACAiB;YACAO;YACAb;YACA,UAAU;gBACN,UACIJ,SAAS,QAAQ,EAAE,YAAYA,SAAS,eAAe,EAAE,YAAYuB;YAC7E;YACA,QAAQC,UAAU;gBACd,OAAOxB;YACX;YACA,MACIU,WAAWE,mBACL;gBACInB;YACJ,IACA;YACV,qBAAqB;QACzB;QAEA,IAAIiB,WAAWC,cACX;YAAA,IAAID,WAAWE,kBAAkB;gBAC7B,MAAMC,aAAa,MAAM,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC;oBACvD5B;oBACAqC;oBACA,IAAI;gBACR;gBACA,IAAI,CAACT,YACD,MAAM,IAAIC,mBAAmB,CAAC,6BAA6B,EAAEQ,MAAM,OAAO,CAAC,EAAE,CAAC;YAEtF,OAAO,IAAIZ,WAAWK,oBAAoB;gBACtC,MAAMC,eAAe,MAAM,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC;oBACzD/B;oBACAqC;oBACA,IAAI;gBACR;gBACA,IAAI,CAACN,cACD,MAAM,IAAIF,mBAAmB,CAAC,6BAA6B,EAAEQ,MAAM,OAAO,CAAC,EAAE,CAAC;YAEtF;QAAA;QAGJ,OAAO;YACHA;YACA,OAAO;gBACH,GAAGtB,QAAQ;gBACX,QAAQyB,gBAAgBrB;YAC5B;QACJ;IACJ;AACJ;AAEO,MAAMsB,gDAAyBC,qBAAqB;IACvD,aAAaC;IACb,gBAAgBjC;IAChB,cAAc;QAACkC;QAAYC;QAAiBC;QAAeC;KAAc;AAC7E"}
|
|
1
|
+
{"version":3,"file":"features/contentEntry/entryDataFactories/CreateEntryDataFactory/CreateEntryDataFactory.js","sources":["../../../../../src/features/contentEntry/entryDataFactories/CreateEntryDataFactory/CreateEntryDataFactory.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/feature/api\";\nimport {\n CreateEntryDataFactory as FactoryAbstraction,\n type ICreateEntryDataFactory,\n type ICreateEntryDataResponse\n} from \"./abstractions.js\";\nimport { AccessControl, CmsContext } from \"~/features/shared/abstractions.js\";\nimport { TenantContext } from \"@webiny/api-core/features/tenancy/TenantContext/index.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport type {\n CmsEntry,\n CmsEntryValues,\n CmsModel,\n CmsModelField,\n CreateCmsEntryInput,\n CreateCmsEntryOptionsInput\n} from \"~/types/index.js\";\nimport { getDate } from \"~/utils/date.js\";\nimport { ROOT_FOLDER } from \"~/constants.js\";\nimport WebinyError from \"@webiny/error\";\nimport { validateModelEntryDataOrThrow } from \"~/crud/contentEntry/entryDataValidation.js\";\nimport { referenceFieldsMapping } from \"~/crud/contentEntry/referenceFieldsMapping.js\";\nimport { createIdentifier, mdbid } from \"@webiny/utils\";\nimport { STATUS_DRAFT, STATUS_PUBLISHED, STATUS_UNPUBLISHED } from \"../statuses.js\";\nimport { getIdentity } from \"~/utils/identity.js\";\nimport { NotAuthorizedError } from \"~/utils/errors.js\";\nimport { getSystem } from \"../system.js\";\nimport { getExpiresAt } from \"../expiresAt.js\";\n\ntype DefaultValue = boolean | number | string | null;\n\nconst convertDefaultValue = (field: CmsModelField, value: DefaultValue): DefaultValue => {\n switch (field.type) {\n case \"boolean\":\n return Boolean(value);\n case \"number\":\n return Number(value);\n default:\n return value;\n }\n};\n\nconst getDefaultValue = (field: CmsModelField): (DefaultValue | DefaultValue[]) | undefined => {\n const { settings, list } = field;\n if (settings && settings.defaultValue !== undefined) {\n return convertDefaultValue(field, settings.defaultValue);\n }\n const { predefinedValues } = field;\n if (\n !predefinedValues ||\n !predefinedValues.enabled ||\n Array.isArray(predefinedValues.values) === false\n ) {\n return undefined;\n }\n if (!list) {\n const selectedValue = predefinedValues.values.find(value => {\n return !!value.selected;\n });\n if (selectedValue) {\n return convertDefaultValue(field, selectedValue.value);\n }\n return undefined;\n }\n return predefinedValues.values\n .filter(({ selected }) => !!selected)\n .map(({ value }) => {\n return convertDefaultValue(field, value);\n });\n};\n\nconst cleanInputValues = <TValues extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n input: TValues\n) => {\n return model.fields.reduce<TValues>((acc, field) => {\n if (!field.fieldId) {\n throw new WebinyError(\"Field does not have an fieldId.\", \"MISSING_FIELD_ID\", {\n field\n });\n }\n const key = field.fieldId as keyof TValues;\n const value = input[key] as TValues[keyof TValues];\n acc[key] = value === undefined ? (getDefaultValue(field) as TValues[keyof TValues]) : value;\n return acc;\n }, {} as TValues);\n};\n\nconst createEntryId = (input: CreateCmsEntryInput) => {\n let entryId = mdbid();\n if (input.id) {\n if (input.id.match(/^([a-zA-Z0-9])([a-zA-Z0-9-]+)([a-zA-Z0-9])$/) === null) {\n throw new WebinyError(\n \"The provided ID is not valid. It must be a string which can be A-Z, a-z, 0-9, - and it cannot start or end with a -.\",\n \"INVALID_ID\",\n {\n id: input.id\n }\n );\n }\n entryId = input.id;\n }\n const version = 1;\n return {\n entryId,\n version,\n id: createIdentifier({\n id: entryId,\n version\n })\n };\n};\n\nclass CreateEntryDataFactoryImpl implements ICreateEntryDataFactory {\n public constructor(\n private readonly cmsContext: CmsContext.Interface,\n private readonly identityContext: IdentityContext.Interface,\n private readonly tenantContext: TenantContext.Interface,\n private readonly accessControl: AccessControl.Interface\n ) {}\n\n public async create<TValues extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n rawInput: CreateCmsEntryInput<TValues>,\n options?: CreateCmsEntryOptionsInput\n ): Promise<ICreateEntryDataResponse<TValues>> {\n const initialValues = cleanInputValues<TValues>(model, rawInput.values || ({} as TValues));\n\n await validateModelEntryDataOrThrow({\n context: this.cmsContext,\n model,\n values: initialValues,\n skipValidators: options?.skipValidators\n });\n\n const values = await referenceFieldsMapping<TValues>({\n context: this.cmsContext,\n model,\n values: initialValues,\n validateEntries: true\n });\n\n const { id, entryId, version } = createEntryId(rawInput);\n\n const currentIdentity = this.identityContext.getIdentity();\n const currentDateTime = new Date();\n\n const status = rawInput.status || STATUS_DRAFT;\n if (status !== STATUS_DRAFT) {\n if (status === STATUS_PUBLISHED) {\n const canPublish = await this.accessControl.canAccessEntry({ model, pw: \"p\" });\n if (!canPublish) {\n throw new NotAuthorizedError(\n `Not allowed to access \"${model.modelId}\" entries.`\n );\n }\n } else if (status === STATUS_UNPUBLISHED) {\n const canUnpublish = await this.accessControl.canAccessEntry({ model, pw: \"u\" });\n if (!canUnpublish) {\n throw new NotAuthorizedError(\n `Not allowed to access \"${model.modelId}\" entries.`\n );\n }\n }\n }\n\n const locked = status !== STATUS_DRAFT;\n\n let revisionLevelPublishingMetaFields: Pick<\n CmsEntry,\n | \"revisionFirstPublishedOn\"\n | \"revisionLastPublishedOn\"\n | \"revisionFirstPublishedBy\"\n | \"revisionLastPublishedBy\"\n > = {\n revisionFirstPublishedOn: null,\n revisionLastPublishedOn: null,\n revisionFirstPublishedBy: null,\n revisionLastPublishedBy: null\n };\n\n let entryLevelPublishingMetaFields: Pick<\n CmsEntry,\n \"firstPublishedOn\" | \"lastPublishedOn\" | \"firstPublishedBy\" | \"lastPublishedBy\"\n > = {\n firstPublishedOn: null,\n lastPublishedOn: null,\n firstPublishedBy: null,\n lastPublishedBy: null\n };\n\n if (status === STATUS_PUBLISHED) {\n revisionLevelPublishingMetaFields = {\n revisionFirstPublishedOn: getDate(\n rawInput.revisionFirstPublishedOn,\n currentDateTime\n ),\n revisionLastPublishedOn: getDate(rawInput.revisionLastPublishedOn, currentDateTime),\n revisionFirstPublishedBy: getIdentity(\n rawInput.revisionFirstPublishedBy,\n currentIdentity\n ),\n revisionLastPublishedBy: getIdentity(\n rawInput.revisionLastPublishedBy,\n currentIdentity\n )\n };\n\n entryLevelPublishingMetaFields = {\n firstPublishedOn: getDate(rawInput.firstPublishedOn, currentDateTime),\n lastPublishedOn: getDate(rawInput.lastPublishedOn, currentDateTime),\n firstPublishedBy: getIdentity(rawInput.firstPublishedBy, currentIdentity),\n lastPublishedBy: getIdentity(rawInput.lastPublishedBy, currentIdentity)\n };\n }\n\n const entry: CmsEntry<TValues> = {\n tenant: this.tenantContext.getTenant().id,\n entryId,\n id,\n modelId: model.modelId,\n createdOn: getDate(rawInput.createdOn, currentDateTime),\n modifiedOn: getDate(rawInput.modifiedOn, null),\n savedOn: getDate(rawInput.savedOn, currentDateTime),\n deletedOn: getDate(rawInput.deletedOn, null),\n restoredOn: getDate(rawInput.restoredOn, null),\n createdBy: getIdentity(rawInput.createdBy, currentIdentity)!,\n modifiedBy: getIdentity(rawInput.modifiedBy, null),\n savedBy: getIdentity(rawInput.savedBy, currentIdentity)!,\n deletedBy: getIdentity(rawInput.deletedBy, null),\n restoredBy: getIdentity(rawInput.restoredBy, null),\n ...entryLevelPublishingMetaFields,\n revisionCreatedOn: getDate(rawInput.revisionCreatedOn, currentDateTime),\n revisionModifiedOn: getDate(rawInput.revisionModifiedOn, null),\n revisionSavedOn: getDate(rawInput.revisionSavedOn, currentDateTime),\n revisionDeletedOn: getDate(rawInput.revisionDeletedOn, null),\n revisionRestoredOn: getDate(rawInput.revisionRestoredOn, null),\n revisionCreatedBy: getIdentity(rawInput.revisionCreatedBy, currentIdentity)!,\n revisionModifiedBy: getIdentity(rawInput.revisionModifiedBy, null),\n revisionSavedBy: getIdentity(rawInput.revisionSavedBy, currentIdentity)!,\n revisionDeletedBy: getIdentity(rawInput.revisionDeletedBy, null),\n revisionRestoredBy: getIdentity(rawInput.revisionRestoredBy, null),\n ...revisionLevelPublishingMetaFields,\n version,\n status,\n locked,\n values,\n location: {\n folderId:\n rawInput.location?.folderId || rawInput.wbyAco_location?.folderId || ROOT_FOLDER\n },\n system: getSystem({\n input: rawInput\n }),\n live:\n status === STATUS_PUBLISHED\n ? {\n version\n }\n : null,\n revisionDescription: \"\",\n expiresAt: getExpiresAt({ expiresAt: rawInput.expiresAt })\n };\n\n if (status !== STATUS_DRAFT) {\n if (status === STATUS_PUBLISHED) {\n const canPublish = await this.accessControl.canAccessEntry({\n model,\n entry,\n pw: \"p\"\n });\n if (!canPublish) {\n throw new NotAuthorizedError(`Not allowed to access entry \"${entry.entryId}\".`);\n }\n } else if (status === STATUS_UNPUBLISHED) {\n const canUnpublish = await this.accessControl.canAccessEntry({\n model,\n entry,\n pw: \"u\"\n });\n if (!canUnpublish) {\n throw new NotAuthorizedError(`Not allowed to access entry \"${entry.entryId}\".`);\n }\n }\n }\n\n return {\n entry,\n input: {\n ...rawInput,\n values: structuredClone(values)\n }\n };\n }\n}\n\nexport const CreateEntryDataFactory = createImplementation({\n abstraction: FactoryAbstraction,\n implementation: CreateEntryDataFactoryImpl,\n dependencies: [CmsContext, IdentityContext, TenantContext, AccessControl]\n});\n"],"names":["convertDefaultValue","field","value","Boolean","Number","getDefaultValue","settings","list","undefined","predefinedValues","Array","selectedValue","selected","cleanInputValues","model","input","acc","WebinyError","key","createEntryId","entryId","mdbid","version","createIdentifier","CreateEntryDataFactoryImpl","cmsContext","identityContext","tenantContext","accessControl","rawInput","options","initialValues","validateModelEntryDataOrThrow","values","referenceFieldsMapping","id","currentIdentity","currentDateTime","Date","status","STATUS_DRAFT","STATUS_PUBLISHED","canPublish","NotAuthorizedError","STATUS_UNPUBLISHED","canUnpublish","locked","revisionLevelPublishingMetaFields","entryLevelPublishingMetaFields","getDate","getIdentity","entry","ROOT_FOLDER","getSystem","getExpiresAt","structuredClone","CreateEntryDataFactory","createImplementation","FactoryAbstraction","CmsContext","IdentityContext","TenantContext","AccessControl"],"mappings":";;;;;;;;;;;;;;;;AA+BA,MAAMA,sBAAsB,CAACC,OAAsBC;IAC/C,OAAQD,MAAM,IAAI;QACd,KAAK;YACD,OAAOE,QAAQD;QACnB,KAAK;YACD,OAAOE,OAAOF;QAClB;YACI,OAAOA;IACf;AACJ;AAEA,MAAMG,kBAAkB,CAACJ;IACrB,MAAM,EAAEK,QAAQ,EAAEC,IAAI,EAAE,GAAGN;IAC3B,IAAIK,YAAYA,AAA0BE,WAA1BF,SAAS,YAAY,EACjC,OAAON,oBAAoBC,OAAOK,SAAS,YAAY;IAE3D,MAAM,EAAE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BC,qBAAqB;IACvD,aAAaC;IACb,gBAAgBlC;IAChB,cAAc;QAACmC;QAAYC;QAAiBC;QAAeC;KAAc;AAC7E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/contentEntry/entryDataFactories/CreateEntryRevisionFromDataFactory/CreateEntryRevisionFromDataFactory.js","sources":["../../../../../src/features/contentEntry/entryDataFactories/CreateEntryRevisionFromDataFactory/CreateEntryRevisionFromDataFactory.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/feature/api\";\nimport {\n CreateEntryRevisionFromDataFactory as FactoryAbstraction,\n type ICreateEntryRevisionFromDataFactory,\n type ICreateEntryRevisionFromDataResponse\n} from \"./abstractions.js\";\nimport { AccessControl, CmsContext } from \"~/features/shared/abstractions.js\";\nimport { TenantContext } from \"@webiny/api-core/features/tenancy/TenantContext/index.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport type {\n CmsEntry,\n CmsEntryValues,\n CmsModel,\n CreateCmsEntryInput,\n CreateCmsEntryOptionsInput\n} from \"~/types/index.js\";\nimport { getDate } from \"~/utils/date.js\";\nimport { getIdentity } from \"~/utils/identity.js\";\nimport { mapAndCleanUpdatedInputData } from \"../mapAndCleanUpdatedInputData.js\";\nimport { validateModelEntryDataOrThrow } from \"~/crud/contentEntry/entryDataValidation.js\";\nimport { referenceFieldsMapping } from \"~/crud/contentEntry/referenceFieldsMapping.js\";\nimport { createIdentifier, parseIdentifier } from \"@webiny/utils\";\nimport WebinyError from \"@webiny/error\";\nimport { STATUS_DRAFT, STATUS_PUBLISHED, STATUS_UNPUBLISHED } from \"../statuses.js\";\nimport { NotAuthorizedError } from \"~/utils/errors.js\";\nimport { getSystem } from \"../system.js\";\n\nconst increaseEntryIdVersion = (id: string) => {\n const { id: entryId, version } = parseIdentifier(id);\n if (!version) {\n throw new WebinyError(\n \"Cannot increase version on the ID without the version part.\",\n \"WRONG_ID\",\n {\n id\n }\n );\n }\n return {\n entryId,\n version: version + 1,\n id: createIdentifier({\n id: entryId,\n version: version + 1\n })\n };\n};\n\nclass CreateEntryRevisionFromDataFactoryImpl implements ICreateEntryRevisionFromDataFactory {\n public constructor(\n private readonly cmsContext: CmsContext.Interface,\n private readonly identityContext: IdentityContext.Interface,\n private readonly tenantContext: TenantContext.Interface,\n private readonly accessControl: AccessControl.Interface\n ) {}\n\n public async create<TValues extends CmsEntryValues = CmsEntryValues>(\n sourceId: string,\n model: CmsModel,\n rawInput: CreateCmsEntryInput<TValues>,\n originalEntry: CmsEntry<TValues>,\n latestStorageEntry: CmsEntry<TValues>,\n options?: CreateCmsEntryOptionsInput\n ): Promise<ICreateEntryRevisionFromDataResponse<TValues>> {\n const initialValues = {\n ...originalEntry.values,\n ...mapAndCleanUpdatedInputData<TValues>(model, rawInput.values)\n };\n\n await validateModelEntryDataOrThrow({\n context: this.cmsContext,\n model,\n values: initialValues,\n entry: originalEntry,\n skipValidators: options?.skipValidators\n });\n\n const values = await referenceFieldsMapping<TValues>({\n context: this.cmsContext,\n model,\n values: initialValues,\n validateEntries: false\n });\n\n const latestId = latestStorageEntry ? latestStorageEntry.id : sourceId;\n const { id, version: nextVersion } = increaseEntryIdVersion(latestId);\n\n const currentIdentity = this.identityContext.getIdentity();\n const currentDateTime = new Date();\n\n const status = rawInput.status || STATUS_DRAFT;\n if (status !== STATUS_DRAFT) {\n if (status === STATUS_PUBLISHED) {\n const canPublish = await this.accessControl.canAccessEntry({ model, pw: \"p\" });\n if (!canPublish) {\n throw new NotAuthorizedError(\n `Not allowed to access \"${model.modelId}\" entries.`\n );\n }\n } else if (status === STATUS_UNPUBLISHED) {\n const canUnpublish = await this.accessControl.canAccessEntry({ model, pw: \"u\" });\n if (!canUnpublish) {\n throw new NotAuthorizedError(\n `Not allowed to access \"${model.modelId}\" entries.`\n );\n }\n }\n }\n\n const locked = status !== STATUS_DRAFT;\n\n let revisionLevelPublishingMetaFields: Pick<\n CmsEntry,\n | \"revisionFirstPublishedOn\"\n | \"revisionLastPublishedOn\"\n | \"revisionFirstPublishedBy\"\n | \"revisionLastPublishedBy\"\n > = {\n revisionFirstPublishedOn: getDate(rawInput.revisionFirstPublishedOn, null),\n revisionLastPublishedOn: getDate(rawInput.revisionLastPublishedOn, null),\n revisionFirstPublishedBy: getIdentity(rawInput.revisionFirstPublishedBy, null),\n revisionLastPublishedBy: getIdentity(rawInput.revisionLastPublishedBy, null)\n };\n\n let entryLevelPublishingMetaFields: Pick<\n CmsEntry,\n \"firstPublishedOn\" | \"lastPublishedOn\" | \"firstPublishedBy\" | \"lastPublishedBy\"\n > = {\n firstPublishedOn: getDate(\n rawInput.firstPublishedOn,\n latestStorageEntry.firstPublishedOn\n ),\n lastPublishedOn: getDate(rawInput.lastPublishedOn, latestStorageEntry.lastPublishedOn),\n firstPublishedBy: getIdentity(\n rawInput.firstPublishedBy,\n latestStorageEntry.firstPublishedBy\n ),\n lastPublishedBy: getIdentity(\n rawInput.lastPublishedBy,\n latestStorageEntry.lastPublishedBy\n )\n };\n\n if (status === STATUS_PUBLISHED) {\n revisionLevelPublishingMetaFields = {\n revisionFirstPublishedOn: getDate(\n rawInput.revisionFirstPublishedOn,\n currentDateTime\n ),\n revisionLastPublishedOn: getDate(rawInput.revisionLastPublishedOn, currentDateTime),\n revisionFirstPublishedBy: getIdentity(\n rawInput.revisionFirstPublishedBy,\n currentIdentity\n ),\n revisionLastPublishedBy: getIdentity(\n rawInput.revisionLastPublishedBy,\n currentIdentity\n )\n };\n\n entryLevelPublishingMetaFields = {\n firstPublishedOn: getDate(\n rawInput.firstPublishedOn,\n latestStorageEntry.firstPublishedOn\n ),\n lastPublishedOn: getDate(rawInput.lastPublishedOn, currentDateTime),\n firstPublishedBy: getIdentity(\n rawInput.firstPublishedBy,\n latestStorageEntry.firstPublishedBy\n ),\n lastPublishedBy: getIdentity(rawInput.lastPublishedBy, currentIdentity)\n };\n }\n\n const entry: CmsEntry<TValues> = {\n ...originalEntry,\n id,\n version: nextVersion,\n createdOn: getDate(rawInput.createdOn, latestStorageEntry.createdOn),\n savedOn: getDate(rawInput.savedOn, currentDateTime),\n modifiedOn: getDate(rawInput.modifiedOn, currentDateTime),\n createdBy: getIdentity(rawInput.createdBy, latestStorageEntry.createdBy)!,\n savedBy: getIdentity(rawInput.savedBy, currentIdentity)!,\n modifiedBy: getIdentity(rawInput.modifiedBy, currentIdentity),\n ...entryLevelPublishingMetaFields,\n revisionCreatedOn: getDate(rawInput.revisionCreatedOn, currentDateTime),\n revisionSavedOn: getDate(rawInput.revisionSavedOn, currentDateTime),\n revisionModifiedOn: getDate(rawInput.revisionModifiedOn, null),\n revisionCreatedBy: getIdentity(rawInput.revisionCreatedBy, currentIdentity)!,\n revisionSavedBy: getIdentity(rawInput.revisionSavedBy, currentIdentity)!,\n revisionModifiedBy: getIdentity(rawInput.revisionModifiedBy, null),\n ...revisionLevelPublishingMetaFields,\n locked,\n status,\n values,\n system: getSystem({\n input: rawInput,\n original: originalEntry\n }),\n live: originalEntry.live\n };\n\n return {\n entry,\n input: {\n ...rawInput,\n values: structuredClone(values)\n }\n };\n }\n}\n\nexport const CreateEntryRevisionFromDataFactory = createImplementation({\n abstraction: FactoryAbstraction,\n implementation: CreateEntryRevisionFromDataFactoryImpl,\n dependencies: [CmsContext, IdentityContext, TenantContext, AccessControl]\n});\n"],"names":["increaseEntryIdVersion","id","entryId","version","parseIdentifier","WebinyError","createIdentifier","CreateEntryRevisionFromDataFactoryImpl","cmsContext","identityContext","tenantContext","accessControl","sourceId","model","rawInput","originalEntry","latestStorageEntry","options","initialValues","mapAndCleanUpdatedInputData","validateModelEntryDataOrThrow","values","referenceFieldsMapping","latestId","nextVersion","currentIdentity","currentDateTime","Date","status","STATUS_DRAFT","STATUS_PUBLISHED","canPublish","NotAuthorizedError","STATUS_UNPUBLISHED","canUnpublish","locked","revisionLevelPublishingMetaFields","getDate","getIdentity","entryLevelPublishingMetaFields","entry","getSystem","structuredClone","CreateEntryRevisionFromDataFactory","createImplementation","FactoryAbst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ataFactory.js","sources":["../../../../../src/features/contentEntry/entryDataFactories/CreateEntryRevisionFromDataFactory/CreateEntryRevisionFromDataFactory.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/feature/api\";\nimport {\n CreateEntryRevisionFromDataFactory as FactoryAbstraction,\n type ICreateEntryRevisionFromDataFactory,\n type ICreateEntryRevisionFromDataResponse\n} from \"./abstractions.js\";\nimport { AccessControl, CmsContext } from \"~/features/shared/abstractions.js\";\nimport { TenantContext } from \"@webiny/api-core/features/tenancy/TenantContext/index.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport type {\n CmsEntry,\n CmsEntryValues,\n CmsModel,\n CreateCmsEntryInput,\n CreateCmsEntryOptionsInput\n} from \"~/types/index.js\";\nimport { getDate } from \"~/utils/date.js\";\nimport { getIdentity } from \"~/utils/identity.js\";\nimport { mapAndCleanUpdatedInputData } from \"../mapAndCleanUpdatedInputData.js\";\nimport { validateModelEntryDataOrThrow } from \"~/crud/contentEntry/entryDataValidation.js\";\nimport { referenceFieldsMapping } from \"~/crud/contentEntry/referenceFieldsMapping.js\";\nimport { createIdentifier, parseIdentifier } from \"@webiny/utils\";\nimport WebinyError from \"@webiny/error\";\nimport { STATUS_DRAFT, STATUS_PUBLISHED, STATUS_UNPUBLISHED } from \"../statuses.js\";\nimport { NotAuthorizedError } from \"~/utils/errors.js\";\nimport { getSystem } from \"../system.js\";\n\nconst increaseEntryIdVersion = (id: string) => {\n const { id: entryId, version } = parseIdentifier(id);\n if (!version) {\n throw new WebinyError(\n \"Cannot increase version on the ID without the version part.\",\n \"WRONG_ID\",\n {\n id\n }\n );\n }\n return {\n entryId,\n version: version + 1,\n id: createIdentifier({\n id: entryId,\n version: version + 1\n })\n };\n};\n\nclass CreateEntryRevisionFromDataFactoryImpl implements ICreateEntryRevisionFromDataFactory {\n public constructor(\n private readonly cmsContext: CmsContext.Interface,\n private readonly identityContext: IdentityContext.Interface,\n private readonly tenantContext: TenantContext.Interface,\n private readonly accessControl: AccessControl.Interface\n ) {}\n\n public async create<TValues extends CmsEntryValues = CmsEntryValues>(\n sourceId: string,\n model: CmsModel,\n rawInput: CreateCmsEntryInput<TValues>,\n originalEntry: CmsEntry<TValues>,\n latestStorageEntry: CmsEntry<TValues>,\n options?: CreateCmsEntryOptionsInput\n ): Promise<ICreateEntryRevisionFromDataResponse<TValues>> {\n const initialValues = {\n ...originalEntry.values,\n ...mapAndCleanUpdatedInputData<TValues>(model, rawInput.values)\n };\n\n await validateModelEntryDataOrThrow({\n context: this.cmsContext,\n model,\n values: initialValues,\n entry: originalEntry,\n skipValidators: options?.skipValidators\n });\n\n const values = await referenceFieldsMapping<TValues>({\n context: this.cmsContext,\n model,\n values: initialValues,\n validateEntries: false\n });\n\n const latestId = latestStorageEntry ? latestStorageEntry.id : sourceId;\n const { id, version: nextVersion } = increaseEntryIdVersion(latestId);\n\n const currentIdentity = this.identityContext.getIdentity();\n const currentDateTime = new Date();\n\n const status = rawInput.status || STATUS_DRAFT;\n if (status !== STATUS_DRAFT) {\n if (status === STATUS_PUBLISHED) {\n const canPublish = await this.accessControl.canAccessEntry({ model, pw: \"p\" });\n if (!canPublish) {\n throw new NotAuthorizedError(\n `Not allowed to access \"${model.modelId}\" entries.`\n );\n }\n } else if (status === STATUS_UNPUBLISHED) {\n const canUnpublish = await this.accessControl.canAccessEntry({ model, pw: \"u\" });\n if (!canUnpublish) {\n throw new NotAuthorizedError(\n `Not allowed to access \"${model.modelId}\" entries.`\n );\n }\n }\n }\n\n const locked = status !== STATUS_DRAFT;\n\n let revisionLevelPublishingMetaFields: Pick<\n CmsEntry,\n | \"revisionFirstPublishedOn\"\n | \"revisionLastPublishedOn\"\n | \"revisionFirstPublishedBy\"\n | \"revisionLastPublishedBy\"\n > = {\n revisionFirstPublishedOn: getDate(rawInput.revisionFirstPublishedOn, null),\n revisionLastPublishedOn: getDate(rawInput.revisionLastPublishedOn, null),\n revisionFirstPublishedBy: getIdentity(rawInput.revisionFirstPublishedBy, null),\n revisionLastPublishedBy: getIdentity(rawInput.revisionLastPublishedBy, null)\n };\n\n let entryLevelPublishingMetaFields: Pick<\n CmsEntry,\n \"firstPublishedOn\" | \"lastPublishedOn\" | \"firstPublishedBy\" | \"lastPublishedBy\"\n > = {\n firstPublishedOn: getDate(\n rawInput.firstPublishedOn,\n latestStorageEntry.firstPublishedOn\n ),\n lastPublishedOn: getDate(rawInput.lastPublishedOn, latestStorageEntry.lastPublishedOn),\n firstPublishedBy: getIdentity(\n rawInput.firstPublishedBy,\n latestStorageEntry.firstPublishedBy\n ),\n lastPublishedBy: getIdentity(\n rawInput.lastPublishedBy,\n latestStorageEntry.lastPublishedBy\n )\n };\n\n if (status === STATUS_PUBLISHED) {\n revisionLevelPublishingMetaFields = {\n revisionFirstPublishedOn: getDate(\n rawInput.revisionFirstPublishedOn,\n currentDateTime\n ),\n revisionLastPublishedOn: getDate(rawInput.revisionLastPublishedOn, currentDateTime),\n revisionFirstPublishedBy: getIdentity(\n rawInput.revisionFirstPublishedBy,\n currentIdentity\n ),\n revisionLastPublishedBy: getIdentity(\n rawInput.revisionLastPublishedBy,\n currentIdentity\n )\n };\n\n entryLevelPublishingMetaFields = {\n firstPublishedOn: getDate(\n rawInput.firstPublishedOn,\n latestStorageEntry.firstPublishedOn\n ),\n lastPublishedOn: getDate(rawInput.lastPublishedOn, currentDateTime),\n firstPublishedBy: getIdentity(\n rawInput.firstPublishedBy,\n latestStorageEntry.firstPublishedBy\n ),\n lastPublishedBy: getIdentity(rawInput.lastPublishedBy, currentIdentity)\n };\n }\n\n const entry: CmsEntry<TValues> = {\n ...originalEntry,\n id,\n version: nextVersion,\n createdOn: getDate(rawInput.createdOn, latestStorageEntry.createdOn),\n savedOn: getDate(rawInput.savedOn, currentDateTime),\n modifiedOn: getDate(rawInput.modifiedOn, currentDateTime),\n createdBy: getIdentity(rawInput.createdBy, latestStorageEntry.createdBy)!,\n savedBy: getIdentity(rawInput.savedBy, currentIdentity)!,\n modifiedBy: getIdentity(rawInput.modifiedBy, currentIdentity),\n ...entryLevelPublishingMetaFields,\n revisionCreatedOn: getDate(rawInput.revisionCreatedOn, currentDateTime),\n revisionSavedOn: getDate(rawInput.revisionSavedOn, currentDateTime),\n revisionModifiedOn: getDate(rawInput.revisionModifiedOn, null),\n revisionCreatedBy: getIdentity(rawInput.revisionCreatedBy, currentIdentity)!,\n revisionSavedBy: getIdentity(rawInput.revisionSavedBy, currentIdentity)!,\n revisionModifiedBy: getIdentity(rawInput.revisionModifiedBy, null),\n ...revisionLevelPublishingMetaFields,\n locked,\n status,\n values,\n system: getSystem({\n input: rawInput,\n original: originalEntry\n }),\n live: originalEntry.live,\n expiresAt: null\n };\n\n return {\n entry,\n input: {\n ...rawInput,\n values: structuredClone(values)\n }\n };\n }\n}\n\nexport const CreateEntryRevisionFromDataFactory = createImplementation({\n abstraction: FactoryAbstraction,\n implementation: CreateEntryRevisionFromDataFactoryImpl,\n dependencies: [CmsContext, IdentityContext, TenantContext, AccessControl]\n});\n"],"names":["increaseEntryIdVersion","id","entryId","version","parseIdentifier","WebinyError","createIdentifier","CreateEntryRevisionFromDataFactoryImpl","cmsContext","identityContext","tenantContext","accessControl","sourceId","model","rawInput","originalEntry","latestStorageEntry","options","initialValues","mapAndCleanUpdatedInputData","validateModelEntryDataOrThrow","values","referenceFieldsMapping","latestId","nextVersion","currentIdentity","currentDateTime","Date","status","STATUS_DRAFT","STATUS_PUBLISHED","canPublish","NotAuthorizedError","STATUS_UNPUBLISHED","canUnpublish","locked","revisionLevelPublishingMetaFields","getDate","getIdentity","entryLevelPublishingMetaFields","entry","getSystem","structuredClone","CreateEntryRevisionFromDataFactory","createImplementation","FactoryAbstraction","CmsContext","IdentityContext","TenantContext","AccessControl"],"mappings":";;;;;;;;;;;;;;;AA2BA,MAAMA,yBAAyB,CAACC;IAC5B,MAAM,EAAE,IAAIC,OAAO,EAAEC,OAAO,EAAE,GAAGC,gBAAgBH;IACjD,IAAI,CAACE,SACD,MAAM,IAA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QAA2B;YAC7B,GAAGzB,aAAa;YAChBd;YACA,SAASuB;YACT,WAAWa,QAAQvB,SAAS,SAAS,EAAEE,mBAAmB,SAAS;YACnE,SAASqB,QAAQvB,SAAS,OAAO,EAAEY;YACnC,YAAYW,QAAQvB,SAAS,UAAU,EAAEY;YACzC,WAAWY,YAAYxB,SAAS,SAAS,EAAEE,mBAAmB,SAAS;YACvE,SAASsB,YAAYxB,SAAS,OAAO,EAAEW;YACvC,YAAYa,YAAYxB,SAAS,UAAU,EAAEW;YAC7C,GAAGc,8BAA8B;YACjC,mBAAmBF,QAAQvB,SAAS,iBAAiB,EAAEY;YACvD,iBAAiBW,QAAQvB,SAAS,eAAe,EAAEY;YACnD,oBAAoBW,QAAQvB,SAAS,kBAAkB,EAAE;YACzD,mBAAmBwB,YAAYxB,SAAS,iBAAiB,EAAEW;YAC3D,iBAAiBa,YAAYxB,SAAS,eAAe,EAAEW;YACvD,oBAAoBa,YAAYxB,SAAS,kBAAkB,EAAE;YAC7D,GAAGsB,iCAAiC;YACpCD;YACAP;YACAP;YACA,QAAQoB,UAAU;gBACd,OAAO3B;gBACP,UAAUC;YACd;YACA,MAAMA,cAAc,IAAI;YACxB,WAAW;QACf;QAEA,OAAO;YACHyB;YACA,OAAO;gBACH,GAAG1B,QAAQ;gBACX,QAAQ4B,gBAAgBrB;YAC5B;QACJ;IACJ;AACJ;AAEO,MAAMsB,wEAAqCC,qBAAqB;IACnE,aAAaC;IACb,gBAAgBtC;IAChB,cAAc;QAACuC;QAAYC;QAAiBC;QAAeC;KAAc;AAC7E"}
|
package/features/contentEntry/entryDataFactories/UpdateEntryDataFactory/UpdateEntryDataFactory.js
CHANGED
|
@@ -8,6 +8,7 @@ import { validateModelEntryDataOrThrow } from "../../../../crud/contentEntry/ent
|
|
|
8
8
|
import { referenceFieldsMapping } from "../../../../crud/contentEntry/referenceFieldsMapping.js";
|
|
9
9
|
import { mapAndCleanUpdatedInputData } from "../mapAndCleanUpdatedInputData.js";
|
|
10
10
|
import { getSystem } from "../system.js";
|
|
11
|
+
import { getExpiresAt } from "../expiresAt.js";
|
|
11
12
|
const allowedEntryStatus = [
|
|
12
13
|
"draft",
|
|
13
14
|
"published",
|
|
@@ -76,7 +77,10 @@ class UpdateEntryDataFactoryImpl {
|
|
|
76
77
|
input: rawInput,
|
|
77
78
|
original: originalEntry
|
|
78
79
|
}),
|
|
79
|
-
live: originalEntry.live
|
|
80
|
+
live: originalEntry.live,
|
|
81
|
+
expiresAt: getExpiresAt({
|
|
82
|
+
expiresAt: rawInput.expiresAt
|
|
83
|
+
}, originalEntry)
|
|
80
84
|
};
|
|
81
85
|
const folderId = rawInput.wbyAco_location?.folderId;
|
|
82
86
|
if (folderId) entry.location = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/contentEntry/entryDataFactories/UpdateEntryDataFactory/UpdateEntryDataFactory.js","sources":["../../../../../src/features/contentEntry/entryDataFactories/UpdateEntryDataFactory/UpdateEntryDataFactory.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/feature/api\";\nimport {\n type IUpdateEntryDataFactory,\n type IUpdateEntryDataResponse,\n UpdateEntryDataFactory as FactoryAbstraction\n} from \"./abstractions.js\";\nimport { CmsContext } from \"~/features/shared/abstractions.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport type {\n CmsEntry,\n CmsEntryStatus,\n CmsEntryValues,\n CmsModel,\n UpdateCmsEntryInput,\n UpdateCmsEntryOptionsInput\n} from \"~/types/index.js\";\nimport { getDate } from \"~/utils/date.js\";\nimport { getIdentity } from \"~/utils/identity.js\";\nimport { validateModelEntryDataOrThrow } from \"~/crud/contentEntry/entryDataValidation.js\";\nimport { referenceFieldsMapping } from \"~/crud/contentEntry/referenceFieldsMapping.js\";\nimport { mapAndCleanUpdatedInputData } from \"../mapAndCleanUpdatedInputData.js\";\nimport { getSystem } from \"../system.js\";\n\nconst allowedEntryStatus: string[] = [\"draft\", \"published\", \"unpublished\"];\n\nconst transformEntryStatus = (status: CmsEntryStatus | string): CmsEntryStatus => {\n return allowedEntryStatus.includes(status) ? (status as CmsEntryStatus) : \"draft\";\n};\n\nclass UpdateEntryDataFactoryImpl implements IUpdateEntryDataFactory {\n public constructor(\n private readonly cmsContext: CmsContext.Interface,\n private readonly identityContext: IdentityContext.Interface\n ) {}\n\n public async create<TValues extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n rawInput: UpdateCmsEntryInput<TValues>,\n originalEntry: CmsEntry<TValues>,\n options?: UpdateCmsEntryOptionsInput\n ): Promise<IUpdateEntryDataResponse<TValues>> {\n const cleanedValues = mapAndCleanUpdatedInputData<TValues>(\n model,\n rawInput?.values || ({} as TValues)\n );\n\n await validateModelEntryDataOrThrow({\n context: this.cmsContext,\n model,\n values: cleanedValues,\n entry: originalEntry,\n skipValidators: options?.skipValidators\n });\n\n const mergedValues: TValues = {\n ...originalEntry.values,\n ...cleanedValues\n };\n\n const values = await referenceFieldsMapping<TValues>({\n context: this.cmsContext,\n model,\n values: mergedValues,\n validateEntries: false\n });\n\n const currentIdentity = this.identityContext.getIdentity();\n const currentDateTime = new Date();\n\n const entry: CmsEntry<TValues> = {\n ...originalEntry,\n revisionCreatedOn: getDate(rawInput.revisionCreatedOn, originalEntry.revisionCreatedOn),\n revisionModifiedOn: getDate(rawInput.revisionModifiedOn, currentDateTime),\n revisionSavedOn: getDate(rawInput.revisionSavedOn, currentDateTime),\n revisionDeletedOn: getDate(rawInput.revisionDeletedOn, null),\n revisionRestoredOn: getDate(rawInput.revisionRestoredOn, null),\n revisionFirstPublishedOn: getDate(\n rawInput.revisionFirstPublishedOn,\n originalEntry.revisionFirstPublishedOn\n ),\n revisionLastPublishedOn: getDate(\n rawInput.revisionLastPublishedOn,\n originalEntry.revisionLastPublishedOn\n ),\n revisionCreatedBy: getIdentity(\n rawInput.revisionCreatedBy,\n originalEntry.revisionCreatedBy\n )!,\n revisionModifiedBy: getIdentity(rawInput.revisionModifiedBy, currentIdentity),\n revisionSavedBy: getIdentity(rawInput.revisionSavedBy, currentIdentity)!,\n revisionDeletedBy: getIdentity(rawInput.revisionSavedBy, null),\n revisionRestoredBy: getIdentity(rawInput.revisionRestoredBy, null),\n revisionFirstPublishedBy: getIdentity(\n rawInput.revisionFirstPublishedBy,\n originalEntry.revisionFirstPublishedBy\n ),\n revisionLastPublishedBy: getIdentity(\n rawInput.revisionLastPublishedBy,\n originalEntry.revisionLastPublishedBy\n ),\n createdOn: getDate(rawInput.createdOn, originalEntry.createdOn),\n savedOn: getDate(rawInput.savedOn, currentDateTime),\n modifiedOn: getDate(rawInput.modifiedOn, currentDateTime),\n deletedOn: getDate(rawInput.deletedOn, null),\n restoredOn: getDate(rawInput.restoredOn, null),\n firstPublishedOn: getDate(rawInput.firstPublishedOn, originalEntry.firstPublishedOn),\n lastPublishedOn: getDate(rawInput.lastPublishedOn, originalEntry.lastPublishedOn),\n createdBy: getIdentity(rawInput.createdBy, originalEntry.createdBy)!,\n savedBy: getIdentity(rawInput.savedBy, currentIdentity)!,\n modifiedBy: getIdentity(rawInput.modifiedBy, currentIdentity),\n deletedBy: getIdentity(rawInput.deletedBy, null),\n restoredBy: getIdentity(rawInput.restoredBy, null),\n firstPublishedBy: getIdentity(\n rawInput.firstPublishedBy,\n originalEntry.firstPublishedBy\n ),\n lastPublishedBy: getIdentity(rawInput.lastPublishedBy, originalEntry.lastPublishedBy),\n values,\n status: transformEntryStatus(originalEntry.status),\n system: getSystem({\n input: rawInput,\n original: originalEntry\n }),\n live: originalEntry.live\n };\n\n const folderId = rawInput.wbyAco_location?.folderId;\n if (folderId) {\n entry.location = {\n folderId\n };\n }\n\n return {\n entry,\n input: {\n ...rawInput,\n values: structuredClone(values)\n }\n };\n }\n}\n\nexport const UpdateEntryDataFactory = createImplementation({\n abstraction: FactoryAbstraction,\n implementation: UpdateEntryDataFactoryImpl,\n dependencies: [CmsContext, IdentityContext]\n});\n"],"names":["allowedEntryStatus","transformEntryStatus","status","UpdateEntryDataFactoryImpl","cmsContext","identityContext","model","rawInput","originalEntry","options","cleanedValues","mapAndCleanUpdatedInputData","validateModelEntryDataOrThrow","mergedValues","values","referenceFieldsMapping","currentIdentity","currentDateTime","Date","entry","getDate","getIdentity","getSystem","folderId","structuredClone","UpdateEntryDataFactory","createImplementation","FactoryAbstraction","CmsContext","IdentityContext"],"mappings":"
|
|
1
|
+
{"version":3,"file":"features/contentEntry/entryDataFactories/UpdateEntryDataFactory/UpdateEntryDataFactory.js","sources":["../../../../../src/features/contentEntry/entryDataFactories/UpdateEntryDataFactory/UpdateEntryDataFactory.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/feature/api\";\nimport {\n type IUpdateEntryDataFactory,\n type IUpdateEntryDataResponse,\n UpdateEntryDataFactory as FactoryAbstraction\n} from \"./abstractions.js\";\nimport { CmsContext } from \"~/features/shared/abstractions.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport type {\n CmsEntry,\n CmsEntryStatus,\n CmsEntryValues,\n CmsModel,\n UpdateCmsEntryInput,\n UpdateCmsEntryOptionsInput\n} from \"~/types/index.js\";\nimport { getDate } from \"~/utils/date.js\";\nimport { getIdentity } from \"~/utils/identity.js\";\nimport { validateModelEntryDataOrThrow } from \"~/crud/contentEntry/entryDataValidation.js\";\nimport { referenceFieldsMapping } from \"~/crud/contentEntry/referenceFieldsMapping.js\";\nimport { mapAndCleanUpdatedInputData } from \"../mapAndCleanUpdatedInputData.js\";\nimport { getSystem } from \"../system.js\";\nimport { getExpiresAt } from \"../expiresAt.js\";\n\nconst allowedEntryStatus: string[] = [\"draft\", \"published\", \"unpublished\"];\n\nconst transformEntryStatus = (status: CmsEntryStatus | string): CmsEntryStatus => {\n return allowedEntryStatus.includes(status) ? (status as CmsEntryStatus) : \"draft\";\n};\n\nclass UpdateEntryDataFactoryImpl implements IUpdateEntryDataFactory {\n public constructor(\n private readonly cmsContext: CmsContext.Interface,\n private readonly identityContext: IdentityContext.Interface\n ) {}\n\n public async create<TValues extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n rawInput: UpdateCmsEntryInput<TValues>,\n originalEntry: CmsEntry<TValues>,\n options?: UpdateCmsEntryOptionsInput\n ): Promise<IUpdateEntryDataResponse<TValues>> {\n const cleanedValues = mapAndCleanUpdatedInputData<TValues>(\n model,\n rawInput?.values || ({} as TValues)\n );\n\n await validateModelEntryDataOrThrow({\n context: this.cmsContext,\n model,\n values: cleanedValues,\n entry: originalEntry,\n skipValidators: options?.skipValidators\n });\n\n const mergedValues: TValues = {\n ...originalEntry.values,\n ...cleanedValues\n };\n\n const values = await referenceFieldsMapping<TValues>({\n context: this.cmsContext,\n model,\n values: mergedValues,\n validateEntries: false\n });\n\n const currentIdentity = this.identityContext.getIdentity();\n const currentDateTime = new Date();\n\n const entry: CmsEntry<TValues> = {\n ...originalEntry,\n revisionCreatedOn: getDate(rawInput.revisionCreatedOn, originalEntry.revisionCreatedOn),\n revisionModifiedOn: getDate(rawInput.revisionModifiedOn, currentDateTime),\n revisionSavedOn: getDate(rawInput.revisionSavedOn, currentDateTime),\n revisionDeletedOn: getDate(rawInput.revisionDeletedOn, null),\n revisionRestoredOn: getDate(rawInput.revisionRestoredOn, null),\n revisionFirstPublishedOn: getDate(\n rawInput.revisionFirstPublishedOn,\n originalEntry.revisionFirstPublishedOn\n ),\n revisionLastPublishedOn: getDate(\n rawInput.revisionLastPublishedOn,\n originalEntry.revisionLastPublishedOn\n ),\n revisionCreatedBy: getIdentity(\n rawInput.revisionCreatedBy,\n originalEntry.revisionCreatedBy\n )!,\n revisionModifiedBy: getIdentity(rawInput.revisionModifiedBy, currentIdentity),\n revisionSavedBy: getIdentity(rawInput.revisionSavedBy, currentIdentity)!,\n revisionDeletedBy: getIdentity(rawInput.revisionSavedBy, null),\n revisionRestoredBy: getIdentity(rawInput.revisionRestoredBy, null),\n revisionFirstPublishedBy: getIdentity(\n rawInput.revisionFirstPublishedBy,\n originalEntry.revisionFirstPublishedBy\n ),\n revisionLastPublishedBy: getIdentity(\n rawInput.revisionLastPublishedBy,\n originalEntry.revisionLastPublishedBy\n ),\n createdOn: getDate(rawInput.createdOn, originalEntry.createdOn),\n savedOn: getDate(rawInput.savedOn, currentDateTime),\n modifiedOn: getDate(rawInput.modifiedOn, currentDateTime),\n deletedOn: getDate(rawInput.deletedOn, null),\n restoredOn: getDate(rawInput.restoredOn, null),\n firstPublishedOn: getDate(rawInput.firstPublishedOn, originalEntry.firstPublishedOn),\n lastPublishedOn: getDate(rawInput.lastPublishedOn, originalEntry.lastPublishedOn),\n createdBy: getIdentity(rawInput.createdBy, originalEntry.createdBy)!,\n savedBy: getIdentity(rawInput.savedBy, currentIdentity)!,\n modifiedBy: getIdentity(rawInput.modifiedBy, currentIdentity),\n deletedBy: getIdentity(rawInput.deletedBy, null),\n restoredBy: getIdentity(rawInput.restoredBy, null),\n firstPublishedBy: getIdentity(\n rawInput.firstPublishedBy,\n originalEntry.firstPublishedBy\n ),\n lastPublishedBy: getIdentity(rawInput.lastPublishedBy, originalEntry.lastPublishedBy),\n values,\n status: transformEntryStatus(originalEntry.status),\n system: getSystem({\n input: rawInput,\n original: originalEntry\n }),\n live: originalEntry.live,\n expiresAt: getExpiresAt({ expiresAt: rawInput.expiresAt }, originalEntry)\n };\n\n const folderId = rawInput.wbyAco_location?.folderId;\n if (folderId) {\n entry.location = {\n folderId\n };\n }\n\n return {\n entry,\n input: {\n ...rawInput,\n values: structuredClone(values)\n }\n };\n }\n}\n\nexport const UpdateEntryDataFactory = createImplementation({\n abstraction: FactoryAbstraction,\n implementation: UpdateEntryDataFactoryImpl,\n dependencies: [CmsContext, IdentityContext]\n});\n"],"names":["allowedEntryStatus","transformEntryStatus","status","UpdateEntryDataFactoryImpl","cmsContext","identityContext","model","rawInput","originalEntry","options","cleanedValues","mapAndCleanUpdatedInputData","validateModelEntryDataOrThrow","mergedValues","values","referenceFieldsMapping","currentIdentity","currentDateTime","Date","entry","getDate","getIdentity","getSystem","getExpiresAt","folderId","structuredClone","UpdateEntryDataFactory","createImplementation","FactoryAbstraction","CmsContext","IdentityContext"],"mappings":";;;;;;;;;;;AAwBA,MAAMA,qBAA+B;IAAC;IAAS;IAAa;CAAc;AAE1E,MAAMC,uBAAuB,CAACC,SACnBF,mBAAmB,QAAQ,CAACE,UAAWA,SAA4B;AAG9E,MAAMC;IACF,YACqBC,UAAgC,EAChCC,eAA0C,CAC7D;aAFmBD,UAAU,GAAVA;aACAC,eAAe,GAAfA;IAClB;IAEH,MAAa,OACTC,KAAe,EACfC,QAAsC,EACtCC,aAAgC,EAChCC,OAAoC,EACM;QAC1C,MAAMC,gBAAgBC,4BAClBL,OACAC,UAAU,UAAW,CAAC;QAG1B,MAAMK,8BAA8B;YAChC,SAAS,IAAI,CAAC,UAAU;YACxBN;YACA,QAAQI;YACR,OAAOF;YACP,gBAAgBC,SAAS;QAC7B;QAEA,MAAMI,eAAwB;YAC1B,GAAGL,cAAc,MAAM;YACvB,GAAGE,aAAa;QACpB;QAEA,MAAMI,SAAS,MAAMC,uBAAgC;YACjD,SAAS,IAAI,CAAC,UAAU;YACxBT;YACA,QAAQO;YACR,iBAAiB;QACrB;QAEA,MAAMG,kBAAkB,IAAI,CAAC,eAAe,CAAC,WAAW;QACxD,MAAMC,kBAAkB,IAAIC;QAE5B,MAAMC,QAA2B;YAC7B,GAAGX,aAAa;YAChB,mBAAmBY,QAAQb,SAAS,iBAAiB,EAAEC,cAAc,iBAAiB;YACtF,oBAAoBY,QAAQb,SAAS,kBAAkB,EAAEU;YACzD,iBAAiBG,QAAQb,SAAS,eAAe,EAAEU;YACnD,mBAAmBG,QAAQb,SAAS,iBAAiB,EAAE;YACvD,oBAAoBa,QAAQb,SAAS,kBAAkB,EAAE;YACzD,0BAA0Ba,QACtBb,SAAS,wBAAwB,EACjCC,cAAc,wBAAwB;YAE1C,yBAAyBY,QACrBb,SAAS,uBAAuB,EAChCC,cAAc,uBAAuB;YAEzC,mBAAmBa,YACfd,SAAS,iBAA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QACJ;QAGJ,OAAO;YACHL;YACA,OAAO;gBACH,GAAGZ,QAAQ;gBACX,QAAQkB,gBAAgBX;YAC5B;QACJ;IACJ;AACJ;AAEO,MAAMY,gDAAyBC,qBAAqB;IACvD,aAAaC;IACb,gBAAgBzB;IAChB,cAAc;QAAC0B;QAAYC;KAAgB;AAC/C"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const getExpiresAt = (input, original)=>{
|
|
2
|
+
if (void 0 === input.expiresAt) return original?.expiresAt ?? null;
|
|
3
|
+
if (input.expiresAt instanceof Date) return input.expiresAt.getTime() / 1000;
|
|
4
|
+
if ("number" == typeof input.expiresAt && !isNaN(input.expiresAt) && input.expiresAt > 0) return input.expiresAt;
|
|
5
|
+
return null;
|
|
6
|
+
};
|
|
7
|
+
export { getExpiresAt };
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=expiresAt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/contentEntry/entryDataFactories/expiresAt.js","sources":["../../../../src/features/contentEntry/entryDataFactories/expiresAt.ts"],"sourcesContent":["import type { CmsEntry } from \"~/types/index.js\";\n\nexport interface IRawInput {\n expiresAt: Date | number | null | undefined;\n}\n\nexport const getExpiresAt = (input: IRawInput, original?: CmsEntry): number | null => {\n if (input.expiresAt === undefined) {\n return original?.expiresAt ?? null;\n } else if (input.expiresAt instanceof Date) {\n return input.expiresAt.getTime() / 1000;\n } else if (\n typeof input.expiresAt === \"number\" &&\n !isNaN(input.expiresAt) &&\n input.expiresAt > 0\n ) {\n return input.expiresAt;\n }\n return null;\n};\n"],"names":["getExpiresAt","input","original","undefined","Date","isNaN"],"mappings":"AAMO,MAAMA,eAAe,CAACC,OAAkBC;IAC3C,IAAID,AAAoBE,WAApBF,MAAM,SAAS,EACf,OAAOC,UAAU,aAAa;IAC3B,IAAID,MAAM,SAAS,YAAYG,MAClC,OAAOH,MAAM,SAAS,CAAC,OAAO,KAAK;IAChC,IACH,AAA2B,YAA3B,OAAOA,MAAM,SAAS,IACtB,CAACI,MAAMJ,MAAM,SAAS,KACtBA,MAAM,SAAS,GAAG,GAElB,OAAOA,MAAM,SAAS;IAE1B,OAAO;AACX"}
|
|
@@ -5,7 +5,9 @@ const ACTIONS = [
|
|
|
5
5
|
"updated",
|
|
6
6
|
"deleted",
|
|
7
7
|
"published",
|
|
8
|
-
"unpublished"
|
|
8
|
+
"unpublished",
|
|
9
|
+
"trashed",
|
|
10
|
+
"restored"
|
|
9
11
|
];
|
|
10
12
|
class CmsWebhookFactoryImpl {
|
|
11
13
|
constructor(listModels){
|
|
@@ -13,7 +15,8 @@ class CmsWebhookFactoryImpl {
|
|
|
13
15
|
}
|
|
14
16
|
async execute() {
|
|
15
17
|
const result = await this.listModels.execute({
|
|
16
|
-
includePrivate: false
|
|
18
|
+
includePrivate: false,
|
|
19
|
+
includePlugins: true
|
|
17
20
|
});
|
|
18
21
|
if (result.isFail()) return [];
|
|
19
22
|
return result.value.reduce((events, model)=>{
|
|
@@ -22,8 +25,9 @@ class CmsWebhookFactoryImpl {
|
|
|
22
25
|
app: "cms",
|
|
23
26
|
appLabel: "Headless CMS",
|
|
24
27
|
entity: model.modelId,
|
|
28
|
+
entityLabel: model.name,
|
|
25
29
|
eventName: `cms.entry.${model.modelId}.${action}`,
|
|
26
|
-
label:
|
|
30
|
+
label: `Entry ${action.charAt(0).toUpperCase() + action.slice(1)}`
|
|
27
31
|
});
|
|
28
32
|
return events;
|
|
29
33
|
}, []);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/webhooks/CmsWebhookFactory.js","sources":["../../../src/features/webhooks/CmsWebhookFactory.ts"],"sourcesContent":["import { WebhookFactory as WebhookFactoryAbstraction } from \"@webiny/api-core/features/webhooks/index.js\";\nimport { ListModelsUseCase } from \"~/features/contentModel/ListModels/abstractions.js\";\n\nconst ACTIONS = [\"created\"
|
|
1
|
+
{"version":3,"file":"features/webhooks/CmsWebhookFactory.js","sources":["../../../src/features/webhooks/CmsWebhookFactory.ts"],"sourcesContent":["import { WebhookFactory as WebhookFactoryAbstraction } from \"@webiny/api-core/features/webhooks/index.js\";\nimport { ListModelsUseCase } from \"~/features/contentModel/ListModels/abstractions.js\";\n\nconst ACTIONS = [\n \"created\",\n \"updated\",\n \"deleted\",\n \"published\",\n \"unpublished\",\n \"trashed\",\n \"restored\"\n] as const;\n\nclass CmsWebhookFactoryImpl implements WebhookFactoryAbstraction.Interface {\n constructor(private listModels: ListModelsUseCase.Interface) {}\n\n public async execute(): Promise<WebhookFactoryAbstraction.Definition[]> {\n const result = await this.listModels.execute({\n includePrivate: false,\n includePlugins: true\n });\n if (result.isFail()) {\n return [];\n }\n\n return result.value.reduce<WebhookFactoryAbstraction.Definition[]>((events, model) => {\n if (model.tags?.includes(\"$hidden:true\")) {\n return events;\n }\n\n for (const action of ACTIONS) {\n events.push({\n app: \"cms\",\n appLabel: \"Headless CMS\",\n entity: model.modelId,\n entityLabel: model.name,\n eventName: `cms.entry.${model.modelId}.${action}`,\n label: `Entry ${action.charAt(0).toUpperCase() + action.slice(1)}`\n });\n }\n return events;\n }, []);\n }\n}\n\nexport const CmsWebhookFactory = WebhookFactoryAbstraction.createImplementation({\n implementation: CmsWebhookFactoryImpl,\n dependencies: [ListModelsUseCase]\n});\n"],"names":["ACTIONS","CmsWebhookFactoryImpl","listModels","result","events","model","action","CmsWebhookFactory","WebhookFactoryAbstraction","ListModelsUseCase"],"mappings":";;AAGA,MAAMA,UAAU;IACZ;IACA;IACA;IACA;IACA;IACA;IACA;CACH;AAED,MAAMC;IACF,YAAoBC,UAAuC,CAAE;aAAzCA,UAAU,GAAVA;IAA0C;IAE9D,MAAa,UAA2D;QACpE,MAAMC,SAAS,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;YACzC,gBAAgB;YAChB,gBAAgB;QACpB;QACA,IAAIA,OAAO,MAAM,IACb,OAAO,EAAE;QAGb,OAAOA,OAAO,KAAK,CAAC,MAAM,CAAyC,CAACC,QAAQC;YACxE,IAAIA,MAAM,IAAI,EAAE,SAAS,iBACrB,OAAOD;YAGX,KAAK,MAAME,UAAUN,QACjBI,OAAO,IAAI,CAAC;gBACR,KAAK;gBACL,UAAU;gBACV,QAAQC,MAAM,OAAO;gBACrB,aAAaA,MAAM,IAAI;gBACvB,WAAW,CAAC,UAAU,EAAEA,MAAM,OAAO,CAAC,CAAC,EAAEC,QAAQ;gBACjD,OAAO,CAAC,MAAM,EAAEA,OAAO,MAAM,CAAC,GAAG,WAAW,KAAKA,OAAO,KAAK,CAAC,IAAI;YACtE;YAEJ,OAAOF;QACX,GAAG,EAAE;IACT;AACJ;AAEO,MAAMG,oBAAoBC,eAAAA,oBAA8C,CAAC;IAC5E,gBAAgBP;IAChB,cAAc;QAACQ;KAAkB;AACrC"}
|
|
@@ -5,6 +5,8 @@ import { OnEntryUpdatedHandler } from "./handlers/OnEntryUpdatedHandler.js";
|
|
|
5
5
|
import { OnEntryDeletedHandler } from "./handlers/OnEntryDeletedHandler.js";
|
|
6
6
|
import { OnEntryPublishedHandler } from "./handlers/OnEntryPublishedHandler.js";
|
|
7
7
|
import { OnEntryUnpublishedHandler } from "./handlers/OnEntryUnpublishedHandler.js";
|
|
8
|
+
import { OnEntryTrashedHandler } from "./handlers/OnEntryTrashedHandler.js";
|
|
9
|
+
import { OnEntryRestoredHandler } from "./handlers/OnEntryRestoredHandler.js";
|
|
8
10
|
const CmsWebhooksFeature = createFeature({
|
|
9
11
|
name: "CmsWebhooks",
|
|
10
12
|
register (container) {
|
|
@@ -14,6 +16,8 @@ const CmsWebhooksFeature = createFeature({
|
|
|
14
16
|
container.register(OnEntryDeletedHandler);
|
|
15
17
|
container.register(OnEntryPublishedHandler);
|
|
16
18
|
container.register(OnEntryUnpublishedHandler);
|
|
19
|
+
container.register(OnEntryTrashedHandler);
|
|
20
|
+
container.register(OnEntryRestoredHandler);
|
|
17
21
|
}
|
|
18
22
|
});
|
|
19
23
|
export { CmsWebhooksFeature };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/webhooks/feature.js","sources":["../../../src/features/webhooks/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { CmsWebhookFactory } from \"./CmsWebhookFactory.js\";\nimport { OnEntryCreatedHandler } from \"./handlers/OnEntryCreatedHandler.js\";\nimport { OnEntryUpdatedHandler } from \"./handlers/OnEntryUpdatedHandler.js\";\nimport { OnEntryDeletedHandler } from \"./handlers/OnEntryDeletedHandler.js\";\nimport { OnEntryPublishedHandler } from \"./handlers/OnEntryPublishedHandler.js\";\nimport { OnEntryUnpublishedHandler } from \"./handlers/OnEntryUnpublishedHandler.js\";\n\nexport const CmsWebhooksFeature = createFeature({\n name: \"CmsWebhooks\",\n register(container) {\n container.register(CmsWebhookFactory).inSingletonScope();\n container.register(OnEntryCreatedHandler);\n container.register(OnEntryUpdatedHandler);\n container.register(OnEntryDeletedHandler);\n container.register(OnEntryPublishedHandler);\n container.register(OnEntryUnpublishedHandler);\n }\n});\n"],"names":["CmsWebhooksFeature","createFeature","container","CmsWebhookFactory","OnEntryCreatedHandler","OnEntryUpdatedHandler","OnEntryDeletedHandler","OnEntryPublishedHandler","OnEntryUnpublishedHandler"],"mappings":"
|
|
1
|
+
{"version":3,"file":"features/webhooks/feature.js","sources":["../../../src/features/webhooks/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { CmsWebhookFactory } from \"./CmsWebhookFactory.js\";\nimport { OnEntryCreatedHandler } from \"./handlers/OnEntryCreatedHandler.js\";\nimport { OnEntryUpdatedHandler } from \"./handlers/OnEntryUpdatedHandler.js\";\nimport { OnEntryDeletedHandler } from \"./handlers/OnEntryDeletedHandler.js\";\nimport { OnEntryPublishedHandler } from \"./handlers/OnEntryPublishedHandler.js\";\nimport { OnEntryUnpublishedHandler } from \"./handlers/OnEntryUnpublishedHandler.js\";\nimport { OnEntryTrashedHandler } from \"./handlers/OnEntryTrashedHandler.js\";\nimport { OnEntryRestoredHandler } from \"./handlers/OnEntryRestoredHandler.js\";\n\nexport const CmsWebhooksFeature = createFeature({\n name: \"CmsWebhooks\",\n register(container) {\n container.register(CmsWebhookFactory).inSingletonScope();\n container.register(OnEntryCreatedHandler);\n container.register(OnEntryUpdatedHandler);\n container.register(OnEntryDeletedHandler);\n container.register(OnEntryPublishedHandler);\n container.register(OnEntryUnpublishedHandler);\n container.register(OnEntryTrashedHandler);\n container.register(OnEntryRestoredHandler);\n }\n});\n"],"names":["CmsWebhooksFeature","createFeature","container","CmsWebhookFactory","OnEntryCreatedHandler","OnEntryUpdatedHandler","OnEntryDeletedHandler","OnEntryPublishedHandler","OnEntryUnpublishedHandler","OnEntryTrashedHandler","OnEntryRestoredHandler"],"mappings":";;;;;;;;;AAUO,MAAMA,qBAAqBC,cAAc;IAC5C,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC,mBAAmB,gBAAgB;QACtDD,UAAU,QAAQ,CAACE;QACnBF,UAAU,QAAQ,CAACG;QACnBH,UAAU,QAAQ,CAACI;QACnBJ,UAAU,QAAQ,CAACK;QACnBL,UAAU,QAAQ,CAACM;QACnBN,UAAU,QAAQ,CAACO;QACnBP,UAAU,QAAQ,CAACQ;IACvB;AACJ"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EntryAfterDeleteEventHandler } from "../../../features/contentEntry/DeleteEntry/events.js";
|
|
2
2
|
import { WebhookDispatcher } from "@webiny/api-core/features/webhooks/index.js";
|
|
3
3
|
declare class OnEntryDeletedHandlerImpl implements EntryAfterDeleteEventHandler.Interface {
|
|
4
|
-
private dispatcher;
|
|
4
|
+
private readonly dispatcher;
|
|
5
5
|
constructor(dispatcher: WebhookDispatcher.Interface);
|
|
6
6
|
handle(event: EntryAfterDeleteEventHandler.Event): Promise<void>;
|
|
7
7
|
}
|
|
@@ -5,7 +5,8 @@ class OnEntryDeletedHandlerImpl {
|
|
|
5
5
|
this.dispatcher = dispatcher;
|
|
6
6
|
}
|
|
7
7
|
async handle(event) {
|
|
8
|
-
const { entry, model } = event.payload;
|
|
8
|
+
const { entry, model, permanent } = event.payload;
|
|
9
|
+
if (!permanent) return;
|
|
9
10
|
await this.dispatcher.dispatch(`cms.entry.${model.modelId}.deleted`, {
|
|
10
11
|
entry
|
|
11
12
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/webhooks/handlers/OnEntryDeletedHandler.js","sources":["../../../../src/features/webhooks/handlers/OnEntryDeletedHandler.ts"],"sourcesContent":["import { EntryAfterDeleteEventHandler } from \"~/features/contentEntry/DeleteEntry/events.js\";\nimport { WebhookDispatcher } from \"@webiny/api-core/features/webhooks/index.js\";\n\nclass OnEntryDeletedHandlerImpl implements EntryAfterDeleteEventHandler.Interface {\n constructor(private dispatcher: WebhookDispatcher.Interface) {}\n\n async handle(event: EntryAfterDeleteEventHandler.Event): Promise<void> {\n const { entry, model } = event.payload;\n await this.dispatcher.dispatch(`cms.entry.${model.modelId}.deleted`, { entry });\n }\n}\n\nexport const OnEntryDeletedHandler = EntryAfterDeleteEventHandler.createImplementation({\n implementation: OnEntryDeletedHandlerImpl,\n dependencies: [WebhookDispatcher]\n});\n"],"names":["OnEntryDeletedHandlerImpl","dispatcher","event","entry","model","OnEntryDeletedHandler","EntryAfterDeleteEventHandler","WebhookDispatcher"],"mappings":";;AAGA,MAAMA;IACF,
|
|
1
|
+
{"version":3,"file":"features/webhooks/handlers/OnEntryDeletedHandler.js","sources":["../../../../src/features/webhooks/handlers/OnEntryDeletedHandler.ts"],"sourcesContent":["import { EntryAfterDeleteEventHandler } from \"~/features/contentEntry/DeleteEntry/events.js\";\nimport { WebhookDispatcher } from \"@webiny/api-core/features/webhooks/index.js\";\n\nclass OnEntryDeletedHandlerImpl implements EntryAfterDeleteEventHandler.Interface {\n constructor(private readonly dispatcher: WebhookDispatcher.Interface) {}\n\n async handle(event: EntryAfterDeleteEventHandler.Event): Promise<void> {\n const { entry, model, permanent } = event.payload;\n if (!permanent) {\n return;\n }\n await this.dispatcher.dispatch(`cms.entry.${model.modelId}.deleted`, { entry });\n }\n}\n\nexport const OnEntryDeletedHandler = EntryAfterDeleteEventHandler.createImplementation({\n implementation: OnEntryDeletedHandlerImpl,\n dependencies: [WebhookDispatcher]\n});\n"],"names":["OnEntryDeletedHandlerImpl","dispatcher","event","entry","model","permanent","OnEntryDeletedHandler","EntryAfterDeleteEventHandler","WebhookDispatcher"],"mappings":";;AAGA,MAAMA;IACF,YAA6BC,UAAuC,CAAE;aAAzCA,UAAU,GAAVA;IAA0C;IAEvE,MAAM,OAAOC,KAAyC,EAAiB;QACnE,MAAM,EAAEC,KAAK,EAAEC,KAAK,EAAEC,SAAS,EAAE,GAAGH,MAAM,OAAO;QACjD,IAAI,CAACG,WACD;QAEJ,MAAM,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,UAAU,EAAED,MAAM,OAAO,CAAC,QAAQ,CAAC,EAAE;YAAED;QAAM;IACjF;AACJ;AAEO,MAAMG,wBAAwBC,6BAA6B,oBAAoB,CAAC;IACnF,gBAAgBP;IAChB,cAAc;QAACQ;KAAkB;AACrC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { EntryAfterRestoreFromBinEventHandler } from "../../../features/contentEntry/RestoreEntryFromBin/events.js";
|
|
2
|
+
import { WebhookDispatcher } from "@webiny/api-core/features/webhooks/index.js";
|
|
3
|
+
declare class OnEntryRestoredHandlerImpl implements EntryAfterRestoreFromBinEventHandler.Interface {
|
|
4
|
+
private readonly dispatcher;
|
|
5
|
+
constructor(dispatcher: WebhookDispatcher.Interface);
|
|
6
|
+
handle(event: EntryAfterRestoreFromBinEventHandler.Event): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
export declare const OnEntryRestoredHandler: typeof OnEntryRestoredHandlerImpl & {
|
|
9
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/eventPublisher").IEventHandler<import("~/features/contentEntry/RestoreEntryFromBin/events.js").EntryAfterRestoreFromBinEvent>>;
|
|
10
|
+
};
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { EntryAfterRestoreFromBinEventHandler } from "../../contentEntry/RestoreEntryFromBin/events.js";
|
|
2
|
+
import { WebhookDispatcher } from "@webiny/api-core/features/webhooks/index.js";
|
|
3
|
+
class OnEntryRestoredHandlerImpl {
|
|
4
|
+
constructor(dispatcher){
|
|
5
|
+
this.dispatcher = dispatcher;
|
|
6
|
+
}
|
|
7
|
+
async handle(event) {
|
|
8
|
+
const { entry, model } = event.payload;
|
|
9
|
+
await this.dispatcher.dispatch(`cms.entry.${model.modelId}.restored`, {
|
|
10
|
+
entry
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
const OnEntryRestoredHandler = EntryAfterRestoreFromBinEventHandler.createImplementation({
|
|
15
|
+
implementation: OnEntryRestoredHandlerImpl,
|
|
16
|
+
dependencies: [
|
|
17
|
+
WebhookDispatcher
|
|
18
|
+
]
|
|
19
|
+
});
|
|
20
|
+
export { OnEntryRestoredHandler };
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=OnEntryRestoredHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/webhooks/handlers/OnEntryRestoredHandler.js","sources":["../../../../src/features/webhooks/handlers/OnEntryRestoredHandler.ts"],"sourcesContent":["import { EntryAfterRestoreFromBinEventHandler } from \"~/features/contentEntry/RestoreEntryFromBin/events.js\";\nimport { WebhookDispatcher } from \"@webiny/api-core/features/webhooks/index.js\";\n\nclass OnEntryRestoredHandlerImpl implements EntryAfterRestoreFromBinEventHandler.Interface {\n constructor(private readonly dispatcher: WebhookDispatcher.Interface) {}\n\n async handle(event: EntryAfterRestoreFromBinEventHandler.Event): Promise<void> {\n const { entry, model } = event.payload;\n await this.dispatcher.dispatch(`cms.entry.${model.modelId}.restored`, { entry });\n }\n}\n\nexport const OnEntryRestoredHandler = EntryAfterRestoreFromBinEventHandler.createImplementation({\n implementation: OnEntryRestoredHandlerImpl,\n dependencies: [WebhookDispatcher]\n});\n"],"names":["OnEntryRestoredHandlerImpl","dispatcher","event","entry","model","OnEntryRestoredHandler","EntryAfterRestoreFromBinEventHandler","WebhookDispatcher"],"mappings":";;AAGA,MAAMA;IACF,YAA6BC,UAAuC,CAAE;aAAzCA,UAAU,GAAVA;IAA0C;IAEvE,MAAM,OAAOC,KAAiD,EAAiB;QAC3E,MAAM,EAAEC,KAAK,EAAEC,KAAK,EAAE,GAAGF,MAAM,OAAO;QACtC,MAAM,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,UAAU,EAAEE,MAAM,OAAO,CAAC,SAAS,CAAC,EAAE;YAAED;QAAM;IAClF;AACJ;AAEO,MAAME,yBAAyBC,qCAAqC,oBAAoB,CAAC;IAC5F,gBAAgBN;IAChB,cAAc;QAACO;KAAkB;AACrC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { EntryAfterDeleteEventHandler } from "../../../features/contentEntry/DeleteEntry/events.js";
|
|
2
|
+
import { WebhookDispatcher } from "@webiny/api-core/features/webhooks/index.js";
|
|
3
|
+
declare class OnEntryTrashedHandlerImpl implements EntryAfterDeleteEventHandler.Interface {
|
|
4
|
+
private readonly dispatcher;
|
|
5
|
+
constructor(dispatcher: WebhookDispatcher.Interface);
|
|
6
|
+
handle(event: EntryAfterDeleteEventHandler.Event): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
export declare const OnEntryTrashedHandler: typeof OnEntryTrashedHandlerImpl & {
|
|
9
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/eventPublisher").IEventHandler<import("~/features/contentEntry/DeleteEntry/events.js").EntryAfterDeleteEvent>>;
|
|
10
|
+
};
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { EntryAfterDeleteEventHandler } from "../../contentEntry/DeleteEntry/events.js";
|
|
2
|
+
import { WebhookDispatcher } from "@webiny/api-core/features/webhooks/index.js";
|
|
3
|
+
class OnEntryTrashedHandlerImpl {
|
|
4
|
+
constructor(dispatcher){
|
|
5
|
+
this.dispatcher = dispatcher;
|
|
6
|
+
}
|
|
7
|
+
async handle(event) {
|
|
8
|
+
const { entry, model, permanent } = event.payload;
|
|
9
|
+
if (permanent) return;
|
|
10
|
+
await this.dispatcher.dispatch(`cms.entry.${model.modelId}.trashed`, {
|
|
11
|
+
entry
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
const OnEntryTrashedHandler = EntryAfterDeleteEventHandler.createImplementation({
|
|
16
|
+
implementation: OnEntryTrashedHandlerImpl,
|
|
17
|
+
dependencies: [
|
|
18
|
+
WebhookDispatcher
|
|
19
|
+
]
|
|
20
|
+
});
|
|
21
|
+
export { OnEntryTrashedHandler };
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=OnEntryTrashedHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/webhooks/handlers/OnEntryTrashedHandler.js","sources":["../../../../src/features/webhooks/handlers/OnEntryTrashedHandler.ts"],"sourcesContent":["import { EntryAfterDeleteEventHandler } from \"~/features/contentEntry/DeleteEntry/events.js\";\nimport { WebhookDispatcher } from \"@webiny/api-core/features/webhooks/index.js\";\n\nclass OnEntryTrashedHandlerImpl implements EntryAfterDeleteEventHandler.Interface {\n constructor(private readonly dispatcher: WebhookDispatcher.Interface) {}\n\n async handle(event: EntryAfterDeleteEventHandler.Event): Promise<void> {\n const { entry, model, permanent } = event.payload;\n if (permanent) {\n return;\n }\n await this.dispatcher.dispatch(`cms.entry.${model.modelId}.trashed`, { entry });\n }\n}\n\nexport const OnEntryTrashedHandler = EntryAfterDeleteEventHandler.createImplementation({\n implementation: OnEntryTrashedHandlerImpl,\n dependencies: [WebhookDispatcher]\n});\n"],"names":["OnEntryTrashedHandlerImpl","dispatcher","event","entry","model","permanent","OnEntryTrashedHandler","EntryAfterDeleteEventHandler","WebhookDispatcher"],"mappings":";;AAGA,MAAMA;IACF,YAA6BC,UAAuC,CAAE;aAAzCA,UAAU,GAAVA;IAA0C;IAEvE,MAAM,OAAOC,KAAyC,EAAiB;QACnE,MAAM,EAAEC,KAAK,EAAEC,KAAK,EAAEC,SAAS,EAAE,GAAGH,MAAM,OAAO;QACjD,IAAIG,WACA;QAEJ,MAAM,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,UAAU,EAAED,MAAM,OAAO,CAAC,QAAQ,CAAC,EAAE;YAAED;QAAM;IACjF;AACJ;AAEO,MAAMG,wBAAwBC,6BAA6B,oBAAoB,CAAC;IACnF,gBAAgBP;IAChB,cAAc;QAACQ;KAAkB;AACrC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphql/schema/createSingularSDL.js","sources":["../../../src/graphql/schema/createSingularSDL.ts"],"sourcesContent":["import type { ApiEndpoint, CmsModel } from \"~/types/index.js\";\nimport { renderInputFields } from \"~/utils/renderInputFields.js\";\nimport { renderFields } from \"~/utils/renderFields.js\";\nimport { ENTRY_META_FIELDS, isDateTimeEntryMetaField } from \"~/constants.js\";\nimport type { CmsModelFieldToGraphQLRegistry } from \"~/features/graphql/index.js\";\n\ninterface CreateSingularSDLParams {\n models: CmsModel[];\n model: CmsModel;\n fieldRegistry: CmsModelFieldToGraphQLRegistry.Interface;\n type: ApiEndpoint;\n}\n\ninterface CreateSingularSDL {\n (params: CreateSingularSDLParams): string;\n}\n\nexport const createSingularSDL: CreateSingularSDL = ({\n models,\n model,\n fieldRegistry,\n type\n}): string => {\n const inputFields = renderInputFields({\n models,\n model,\n fields: model.fields,\n fieldRegistry\n });\n if (inputFields.length === 0) {\n return \"\";\n }\n\n const fields = renderFields({\n models,\n model,\n fields: model.fields,\n type,\n fieldRegistry\n });\n\n const { singularApiName: singularName } = model;\n\n const inputGqlFields = inputFields.map(f => f.fields).join(\"\\n\");\n\n const onByMetaInputGqlFields = ENTRY_META_FIELDS.map(field => {\n const fieldType = isDateTimeEntryMetaField(field) ? \"DateTime\" : \"CmsIdentityInput\";\n\n return `${field}: ${fieldType}`;\n }).join(\"\\n\");\n\n const onByMetaGqlFields = ENTRY_META_FIELDS.map(field => {\n const fieldType = isDateTimeEntryMetaField(field) ? \"DateTime\" : \"CmsIdentity\";\n\n return `${field}: ${fieldType}`;\n }).join(\"\\n\");\n\n // Had to remove /* GraphQL */ because it causes issues with oxfmt formatting.\n const read = `\n \"\"\"${model.description || singularName}\"\"\"\n \n type ${singularName}Values {\n ${fields.map(f => f.fields).join(\"\\n\") || \"_empty: String\"}\n }\n \n type ${singularName} {\n id: ID!\n entryId: String!\n \n ${onByMetaGqlFields}\n values: ${singularName}Values\n live: CmsEntryLive\n }\n\n ${fields.map(f => f.typeDefs).join(\"\\n\")}\n \n input ${singularName}ListWhereInput {\n id: String\n }\n\n type ${singularName}Response {\n data: ${singularName}\n error: CmsError\n }\n \n extend type Query {\n get${singularName}: ${singularName}Response\n }\n\n `;\n if (type !== \"manage\") {\n return read;\n }\n return `\n ${read}\n \n ${inputFields.map(f => f.typeDefs).join(\"\\n\")}\n \n input ${singularName}InputValues {\n ${inputGqlFields || \"_empty: String\"}\n }\n \n input ${singularName}Input {\n ${onByMetaInputGqlFields}\n values: ${singularName}InputValues!\n }\n \n extend type Mutation {\n update${singularName}(data: ${singularName}Input!, options: UpdateCmsEntryOptionsInput): ${singularName}Response\n }\n `;\n};\n"],"names":["createSingularSDL","models","model","fieldRegistry","type","inputFields","renderInputFields","fields","renderFields","singularName","inputGqlFields","f","onByMetaInputGqlFields","ENTRY_META_FIELDS","field","fieldType","isDateTimeEntryMetaField","onByMetaGqlFields","read"],"mappings":";;;AAiBO,MAAMA,oBAAuC,CAAC,EACjDC,MAAM,EACNC,KAAK,EACLC,aAAa,EACbC,IAAI,EACP;IACG,MAAMC,cAAcC,kBAAkB;QAClCL;QACAC;QACA,QAAQA,MAAM,MAAM;QACpBC;IACJ;IACA,IAAIE,AAAuB,MAAvBA,YAAY,MAAM,EAClB,OAAO;IAGX,MAAME,SAASC,aAAa;QACxBP;QACAC;QACA,QAAQA,MAAM,MAAM;QACpBE;QACAD;IACJ;IAEA,MAAM,EAAE,iBAAiBM,YAAY,EAAE,GAAGP;IAE1C,MAAMQ,iBAAiBL,YAAY,GAAG,CAACM,CAAAA,IAAKA,EAAE,MAAM,EAAE,IAAI,CAAC;IAE3D,MAAMC,yBAAyBC,kBAAkB,GAAG,CAACC,CAAAA;QACjD,MAAMC,YAAYC,yBAAyBF,SAAS,aAAa;QAEjE,OAAO,GAAGA,MAAM,EAAE,EAAEC,WAAW;IACnC,GAAG,IAAI,CAAC;IAER,MAAME,oBAAoBJ,kBAAkB,GAAG,CAACC,CAAAA;QAC5C,MAAMC,YAAYC,yBAAyBF,SAAS,aAAa;QAEjE,OAAO,GAAGA,MAAM,EAAE,EAAEC,WAAW;IACnC,GAAG,IAAI,CAAC;IAGR,MAAMG,OAAO,CAAC;WACP,EAAEhB,MAAM,WAAW,IAAIO,aAAa;;aAElC,EAAEA,aAAa;YAChB,EAAEF,OAAO,GAAG,CAACI,CAAAA,IAAKA,EAAE,MAAM,EAAE,IAAI,CAAC,SAAS,iBAAiB;;;aAG1D,EAAEF,aAAa;;;;YAIhB,EAAEQ,kBAAkB;oBACZ,EAAER,aAAa
|
|
1
|
+
{"version":3,"file":"graphql/schema/createSingularSDL.js","sources":["../../../src/graphql/schema/createSingularSDL.ts"],"sourcesContent":["import type { ApiEndpoint, CmsModel } from \"~/types/index.js\";\nimport { renderInputFields } from \"~/utils/renderInputFields.js\";\nimport { renderFields } from \"~/utils/renderFields.js\";\nimport { ENTRY_META_FIELDS, isDateTimeEntryMetaField } from \"~/constants.js\";\nimport type { CmsModelFieldToGraphQLRegistry } from \"~/features/graphql/index.js\";\n\ninterface CreateSingularSDLParams {\n models: CmsModel[];\n model: CmsModel;\n fieldRegistry: CmsModelFieldToGraphQLRegistry.Interface;\n type: ApiEndpoint;\n}\n\ninterface CreateSingularSDL {\n (params: CreateSingularSDLParams): string;\n}\n\nexport const createSingularSDL: CreateSingularSDL = ({\n models,\n model,\n fieldRegistry,\n type\n}): string => {\n const inputFields = renderInputFields({\n models,\n model,\n fields: model.fields,\n fieldRegistry\n });\n if (inputFields.length === 0) {\n return \"\";\n }\n\n const fields = renderFields({\n models,\n model,\n fields: model.fields,\n type,\n fieldRegistry\n });\n\n const { singularApiName: singularName } = model;\n\n const inputGqlFields = inputFields.map(f => f.fields).join(\"\\n\");\n\n const onByMetaInputGqlFields = ENTRY_META_FIELDS.map(field => {\n const fieldType = isDateTimeEntryMetaField(field) ? \"DateTime\" : \"CmsIdentityInput\";\n\n return `${field}: ${fieldType}`;\n }).join(\"\\n\");\n\n const onByMetaGqlFields = ENTRY_META_FIELDS.map(field => {\n const fieldType = isDateTimeEntryMetaField(field) ? \"DateTime\" : \"CmsIdentity\";\n\n return `${field}: ${fieldType}`;\n }).join(\"\\n\");\n\n // Had to remove /* GraphQL */ because it causes issues with oxfmt formatting.\n const read = `\n \"\"\"${model.description || singularName}\"\"\"\n \n type ${singularName}Values {\n ${fields.map(f => f.fields).join(\"\\n\") || \"_empty: String\"}\n }\n \n type ${singularName} {\n id: ID!\n entryId: String!\n \n ${onByMetaGqlFields}\n values: ${singularName}Values\n live: CmsEntryLive\n \n revisionDescription: String\n }\n\n ${fields.map(f => f.typeDefs).join(\"\\n\")}\n \n input ${singularName}ListWhereInput {\n id: String\n }\n\n type ${singularName}Response {\n data: ${singularName}\n error: CmsError\n }\n \n extend type Query {\n get${singularName}: ${singularName}Response\n }\n\n `;\n if (type !== \"manage\") {\n return read;\n }\n return `\n ${read}\n \n ${inputFields.map(f => f.typeDefs).join(\"\\n\")}\n \n input ${singularName}InputValues {\n ${inputGqlFields || \"_empty: String\"}\n }\n \n input ${singularName}Input {\n ${onByMetaInputGqlFields}\n values: ${singularName}InputValues!\n }\n \n extend type Mutation {\n update${singularName}(data: ${singularName}Input!, options: UpdateCmsEntryOptionsInput): ${singularName}Response\n }\n `;\n};\n"],"names":["createSingularSDL","models","model","fieldRegistry","type","inputFields","renderInputFields","fields","renderFields","singularName","inputGqlFields","f","onByMetaInputGqlFields","ENTRY_META_FIELDS","field","fieldType","isDateTimeEntryMetaField","onByMetaGqlFields","read"],"mappings":";;;AAiBO,MAAMA,oBAAuC,CAAC,EACjDC,MAAM,EACNC,KAAK,EACLC,aAAa,EACbC,IAAI,EACP;IACG,MAAMC,cAAcC,kBAAkB;QAClCL;QACAC;QACA,QAAQA,MAAM,MAAM;QACpBC;IACJ;IACA,IAAIE,AAAuB,MAAvBA,YAAY,MAAM,EAClB,OAAO;IAGX,MAAME,SAASC,aAAa;QACxBP;QACAC;QACA,QAAQA,MAAM,MAAM;QACpBE;QACAD;IACJ;IAEA,MAAM,EAAE,iBAAiBM,YAAY,EAAE,GAAGP;IAE1C,MAAMQ,iBAAiBL,YAAY,GAAG,CAACM,CAAAA,IAAKA,EAAE,MAAM,EAAE,IAAI,CAAC;IAE3D,MAAMC,yBAAyBC,kBAAkB,GAAG,CAACC,CAAAA;QACjD,MAAMC,YAAYC,yBAAyBF,SAAS,aAAa;QAEjE,OAAO,GAAGA,MAAM,EAAE,EAAEC,WAAW;IACnC,GAAG,IAAI,CAAC;IAER,MAAME,oBAAoBJ,kBAAkB,GAAG,CAACC,CAAAA;QAC5C,MAAMC,YAAYC,yBAAyBF,SAAS,aAAa;QAEjE,OAAO,GAAGA,MAAM,EAAE,EAAEC,WAAW;IACnC,GAAG,IAAI,CAAC;IAGR,MAAMG,OAAO,CAAC;WACP,EAAEhB,MAAM,WAAW,IAAIO,aAAa;;aAElC,EAAEA,aAAa;YAChB,EAAEF,OAAO,GAAG,CAACI,CAAAA,IAAKA,EAAE,MAAM,EAAE,IAAI,CAAC,SAAS,iBAAiB;;;aAG1D,EAAEF,aAAa;;;;YAIhB,EAAEQ,kBAAkB;oBACZ,EAAER,aAAa;;;;;;QAM3B,EAAEF,OAAO,GAAG,CAACI,CAAAA,IAAKA,EAAE,QAAQ,EAAE,IAAI,CAAC,MAAM;;cAEnC,EAAEF,aAAa;;;;aAIhB,EAAEA,aAAa;kBACV,EAAEA,aAAa;;;;;eAKlB,EAAEA,aAAa,EAAE,EAAEA,aAAa;;;IAG3C,CAAC;IACD,IAAIL,AAAS,aAATA,MACA,OAAOc;IAEX,OAAO,CAAC;QACJ,EAAEA,KAAK;;QAEP,EAAEb,YAAY,GAAG,CAACM,CAAAA,IAAKA,EAAE,QAAQ,EAAE,IAAI,CAAC,MAAM;;cAExC,EAAEF,aAAa;YACjB,EAAEC,kBAAkB,iBAAiB;;;cAGnC,EAAED,aAAa;YACjB,EAAEG,uBAAuB;oBACjB,EAAEH,aAAa;;;;kBAIjB,EAAEA,aAAa,OAAO,EAAEA,aAAa,8CAA8C,EAAEA,aAAa;;IAEhH,CAAC;AACL"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-headless-cms",
|
|
3
|
-
"version": "6.4.0-beta.
|
|
3
|
+
"version": "6.4.0-beta.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./index.js",
|
|
@@ -25,19 +25,19 @@
|
|
|
25
25
|
"@babel/code-frame": "7.29.0",
|
|
26
26
|
"@graphql-tools/merge": "9.1.9",
|
|
27
27
|
"@graphql-tools/schema": "10.0.33",
|
|
28
|
-
"@webiny/api": "6.4.0-beta.
|
|
29
|
-
"@webiny/api-core": "6.4.0-beta.
|
|
28
|
+
"@webiny/api": "6.4.0-beta.4",
|
|
29
|
+
"@webiny/api-core": "6.4.0-beta.4",
|
|
30
30
|
"@webiny/di": "1.0.1",
|
|
31
|
-
"@webiny/error": "6.4.0-beta.
|
|
32
|
-
"@webiny/feature": "6.4.0-beta.
|
|
33
|
-
"@webiny/handler": "6.4.0-beta.
|
|
34
|
-
"@webiny/handler-aws": "6.4.0-beta.
|
|
35
|
-
"@webiny/handler-db": "6.4.0-beta.
|
|
36
|
-
"@webiny/handler-graphql": "6.4.0-beta.
|
|
37
|
-
"@webiny/plugins": "6.4.0-beta.
|
|
38
|
-
"@webiny/project": "6.4.0-beta.
|
|
39
|
-
"@webiny/utils": "6.4.0-beta.
|
|
40
|
-
"@webiny/validation": "6.4.0-beta.
|
|
31
|
+
"@webiny/error": "6.4.0-beta.4",
|
|
32
|
+
"@webiny/feature": "6.4.0-beta.4",
|
|
33
|
+
"@webiny/handler": "6.4.0-beta.4",
|
|
34
|
+
"@webiny/handler-aws": "6.4.0-beta.4",
|
|
35
|
+
"@webiny/handler-db": "6.4.0-beta.4",
|
|
36
|
+
"@webiny/handler-graphql": "6.4.0-beta.4",
|
|
37
|
+
"@webiny/plugins": "6.4.0-beta.4",
|
|
38
|
+
"@webiny/project": "6.4.0-beta.4",
|
|
39
|
+
"@webiny/utils": "6.4.0-beta.4",
|
|
40
|
+
"@webiny/validation": "6.4.0-beta.4",
|
|
41
41
|
"dot-prop-immutable": "2.1.1",
|
|
42
42
|
"graphql": "16.14.0",
|
|
43
43
|
"graphql-tag": "2.12.6",
|
|
@@ -51,24 +51,26 @@
|
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@types/babel__code-frame": "7.27.0",
|
|
53
53
|
"@types/pluralize": "0.0.33",
|
|
54
|
-
"@webiny/aws-sdk": "6.4.0-beta.
|
|
55
|
-
"@webiny/build-tools": "6.4.0-beta.
|
|
56
|
-
"@webiny/db-dynamodb": "6.4.0-beta.
|
|
57
|
-
"@webiny/handler-db": "
|
|
58
|
-
"@webiny/project-utils": "6.4.0-beta.
|
|
59
|
-
"@webiny/sdk": "6.4.0-beta.
|
|
60
|
-
"@webiny/wcp": "6.4.0-beta.
|
|
54
|
+
"@webiny/aws-sdk": "6.4.0-beta.4",
|
|
55
|
+
"@webiny/build-tools": "6.4.0-beta.4",
|
|
56
|
+
"@webiny/db-dynamodb": "6.4.0-beta.4",
|
|
57
|
+
"@webiny/handler-db": "6.4.0-beta.4",
|
|
58
|
+
"@webiny/project-utils": "6.4.0-beta.4",
|
|
59
|
+
"@webiny/sdk": "6.4.0-beta.4",
|
|
60
|
+
"@webiny/wcp": "6.4.0-beta.4",
|
|
61
61
|
"apollo-graphql": "0.9.7",
|
|
62
62
|
"graphql": "16.14.0",
|
|
63
63
|
"oxfmt": "0.51.0",
|
|
64
64
|
"rimraf": "6.1.3",
|
|
65
65
|
"typescript": "6.0.3",
|
|
66
|
-
"vitest": "4.1.
|
|
66
|
+
"vitest": "4.1.7",
|
|
67
67
|
"write-json-file": "7.0.0"
|
|
68
68
|
},
|
|
69
69
|
"publishConfig": {
|
|
70
|
-
"access": "public"
|
|
71
|
-
"directory": "dist"
|
|
70
|
+
"access": "public"
|
|
72
71
|
},
|
|
73
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "b8aec8a1be3f25c3b428b357fe1e352c7cbff9ae",
|
|
73
|
+
"webiny": {
|
|
74
|
+
"publishFrom": "dist"
|
|
75
|
+
}
|
|
74
76
|
}
|
package/types/types.d.ts
CHANGED
|
@@ -402,6 +402,10 @@ export interface CmsEntry<TValues extends CmsEntryValues = CmsEntryValues> {
|
|
|
402
402
|
* A revision description.
|
|
403
403
|
*/
|
|
404
404
|
revisionDescription: string | undefined;
|
|
405
|
+
/**
|
|
406
|
+
* A timestamp of when the entry should be automatically deleted from the database.
|
|
407
|
+
*/
|
|
408
|
+
expiresAt: number | null;
|
|
405
409
|
}
|
|
406
410
|
export interface CmsStorageEntry<T extends CmsEntryValues = CmsEntryValues> extends CmsEntry<T> {
|
|
407
411
|
[key: string]: any;
|
|
@@ -640,6 +644,7 @@ export interface CreateCmsEntryInput<TValues extends CmsEntryValues = CmsEntryVa
|
|
|
640
644
|
};
|
|
641
645
|
system?: Partial<ICmsEntrySystem>;
|
|
642
646
|
values: TValues | undefined;
|
|
647
|
+
expiresAt?: Date | undefined;
|
|
643
648
|
}
|
|
644
649
|
export interface CreateCmsEntryOptionsInput {
|
|
645
650
|
skipValidators?: string[];
|
|
@@ -728,6 +733,7 @@ export interface UpdateCmsEntryInput<TValues extends CmsEntryValues = CmsEntryVa
|
|
|
728
733
|
};
|
|
729
734
|
system?: Partial<ICmsEntrySystem>;
|
|
730
735
|
values?: Partial<TValues>;
|
|
736
|
+
expiresAt?: Date | number | null | undefined;
|
|
731
737
|
}
|
|
732
738
|
export interface UpdateCmsEntryOptionsInput {
|
|
733
739
|
skipValidators?: string[];
|
package/types/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types/types.js","sources":["../../src/types/types.ts"],"sourcesContent":["import type { Context, GenericRecord } from \"@webiny/api/types.js\";\nimport type { GraphQLFieldResolver, GraphQLRequestBody } from \"@webiny/handler-graphql/types.js\";\nimport type { processRequestBody } from \"@webiny/handler-graphql\";\nimport type { DbContext } from \"@webiny/handler-db/types.js\";\nimport type { CmsModelConverterCallable } from \"~/utils/converters/ConverterCollection.js\";\nimport type { HeadlessCmsExport, HeadlessCmsImport } from \"~/export/types.js\";\nimport type { AccessControl } from \"~/crud/AccessControl/AccessControl.js\";\nimport type { CmsModelToAstConverter } from \"~/utils/contentModelAst/CmsModelToAstConverter.js\";\nimport type { ICmsModelFieldToGraphQLRegistry } from \"~/features/graphql/fields/abstractions/CmsModelFieldToGraphQLRegistry.js\";\nimport type { CmsEntryContext } from \"./context.js\";\nimport type { CmsModelField, CmsModelFieldValidation, CmsModelUpdateInput } from \"./modelField.js\";\nimport type {\n CmsModel,\n CmsModelCreateFromInput,\n CmsModelCreateInput,\n StorageCmsModel\n} from \"./model.js\";\nimport type { CmsGroup } from \"./modelGroup.js\";\nimport type { CmsIdentity } from \"./identity.js\";\nimport type { ApiCoreContext } from \"@webiny/api-core/types/core.js\";\nimport type { SecurityPermission } from \"@webiny/api-core/types/security.js\";\nimport type {\n DateStringInterfaceGenerator,\n IdentityInterfaceGenerator,\n IdInterfaceGenerator,\n IdMixedInterfaceGenerator,\n NumericInterfaceGenerator,\n TruthfulInterfaceGenerator\n} from \"@webiny/api\";\n\nexport type CmsIcon = {\n type: string;\n name: string;\n value?: string;\n};\n\nexport interface CmsError {\n message: string;\n code: string;\n data: GenericRecord;\n stack?: string;\n}\n\nexport type ApiEndpoint = \"manage\" | \"preview\" | \"read\";\n\nexport interface HeadlessCms extends CmsGroupContext, CmsModelContext, CmsEntryContext {\n /**\n * API type\n */\n type: ApiEndpoint | null;\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 /**\n * Use to ensure perform authorization and ensure identities have access to the groups, models and entries.\n */\n accessControl: AccessControl;\n\n /**\n * Export operations.\n */\n export: HeadlessCmsExport;\n importing: HeadlessCmsImport;\n getExecutableSchema: GetExecutableSchema;\n}\n\nexport type GetExecutableSchema = (\n type: ApiEndpoint\n) => Promise<\n <TData = Record<string, any>, TExtensions = Record<string, any>>(\n input: GraphQLRequestBody | GraphQLRequestBody[]\n ) => ReturnType<typeof processRequestBody<TData, TExtensions>>\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, ApiCoreContext {\n cms: HeadlessCms;\n}\n\n/**\n * Used for our internal functionality.\n */\nexport interface CmsModelFieldWithParent extends CmsModelField {\n parent?: CmsModelFieldWithParent | 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 extends CmsEntryValues = CmsEntryValues> {\n /**\n * A value to be validated.\n */\n value: T[keyof 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<T>;\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<\n T extends CmsEntryValues = CmsEntryValues\n> extends CmsModel {\n convertValueKeyToStorage: CmsModelConverterCallable<T>;\n convertValueKeyFromStorage: CmsModelConverterCallable<T>;\n}\n\n/**\n * @category ModelField\n */\nexport interface CmsModelFieldDefinition {\n fields: string;\n typeDefs?: string;\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 id?: string;\n name: string;\n slug?: string;\n description?: string | null;\n icon?: CmsIcon | null;\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?: CmsIcon;\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 };\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>;\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\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\nexport interface ICmsEntryLocation {\n folderId?: string;\n}\n\nexport interface ICmsEntryLive {\n version: number;\n}\n\nexport interface ICmsEntrySystem {\n // to be extended\n}\n/**\n * A content entry definition for and from the database.\n *\n * @category Database model\n * @category CmsEntry\n */\nexport interface CmsEntry<TValues extends CmsEntryValues = CmsEntryValues> {\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 /**\n * Revision-level meta fields. 👇\n */\n\n /**\n * An ISO 8601 date/time string.\n */\n revisionCreatedOn: string;\n /**\n * An ISO 8601 date/time string.\n */\n revisionSavedOn: string;\n /**\n * An ISO 8601 date/time string.\n */\n revisionModifiedOn: string | null;\n /**\n * An ISO 8601 date/time string.\n */\n revisionDeletedOn: string | null;\n /**\n * An ISO 8601 date/time string.\n */\n revisionRestoredOn: string | null;\n /**\n * An ISO 8601 date/time string.\n */\n revisionFirstPublishedOn: string | null;\n /**\n * An ISO 8601 date/time string.\n */\n revisionLastPublishedOn: string | null;\n\n /**\n * Identity that last ionCreated the entry.\n */\n revisionCreatedBy: CmsIdentity;\n /**\n * Identity that last ionSaved the entry.\n */\n revisionSavedBy: CmsIdentity;\n /**\n * Identity that last ionModified the entry.\n */\n revisionModifiedBy: CmsIdentity | null;\n /**\n * Identity that last deleted the revision.\n */\n revisionDeletedBy: CmsIdentity | null;\n /**\n * Identity that last restored the revision.\n */\n revisionRestoredBy: CmsIdentity | null;\n /**\n * Identity that first published the entry.\n */\n revisionFirstPublishedBy: CmsIdentity | null;\n /**\n * Identity that last published the entry.\n */\n revisionLastPublishedBy: CmsIdentity | null;\n\n /**\n * An ISO 8601 date/time string.\n */\n createdOn: string;\n /**\n * An ISO 8601 date/time string.\n */\n savedOn: string;\n /**\n * An ISO 8601 date/time string.\n */\n modifiedOn: string | null;\n /**\n * An ISO 8601 date/time string.\n */\n deletedOn: string | null;\n /**\n * An ISO 8601 date/time string.\n */\n restoredOn: string | null;\n /**\n * An ISO 8601 date/time string.\n */\n firstPublishedOn: string | null;\n /**\n * An ISO 8601 date/time string.\n */\n lastPublishedOn: string | null;\n\n /**\n * Identity that last created the entry.\n */\n createdBy: CmsIdentity;\n /**\n * Identity that last saved the entry.\n */\n savedBy: CmsIdentity;\n /**\n * Identity that last modified the entry.\n */\n modifiedBy: CmsIdentity | null;\n /**\n * Identity that last deleted the entry.\n */\n deletedBy: CmsIdentity | null;\n /**\n * Identity that last restored the entry.\n */\n restoredBy: CmsIdentity | null;\n /**\n * Identity that first published the entry.\n */\n firstPublishedBy: CmsIdentity | null;\n /**\n * Identity that last published the entry.\n */\n lastPublishedBy: CmsIdentity | null;\n\n /**\n * Model ID of the definition for the entry.\n * @see CmsModel\n */\n modelId: 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: TValues;\n /**\n * Advanced Content Organization\n */\n location?: ICmsEntryLocation;\n /**\n * Is the entry in the bin?\n */\n wbyDeleted?: boolean | null;\n /**\n * This field preserves the original folderId value, as the ROOT_FOLDER is set upon deletion.\n * The value is used when restoring the entry from the trash bin.\n */\n binOriginalFolderId?: string;\n\n system?: ICmsEntrySystem;\n /**\n * Is this CMS Entry live (no matter the revision).\n */\n live: ICmsEntryLive | null;\n /**\n * A revision description.\n */\n revisionDescription: string | undefined;\n}\n\nexport interface CmsStorageEntry<T extends CmsEntryValues = CmsEntryValues> extends CmsEntry<T> {\n [key: string]: any;\n}\n\nexport interface CmsEntryUniqueValue {\n value: string;\n count: number;\n}\n\nexport interface ICmsModelListParams {\n /**\n * Defaults to true.\n */\n includePrivate?: boolean;\n includePlugins?: boolean;\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 * @throws NotFoundError\n */\n getModel(modelId: string): Promise<CmsModel>;\n /**\n * Get model to AST converter.\n */\n getModelToAstConverter: () => CmsModelToAstConverter;\n /**\n * Get all content models.\n */\n listModels(params?: ICmsModelListParams): 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.\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 * Clear all the model caches.\n */\n clearModelsCache(): void;\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 extends\n IdInterfaceGenerator<\"id\">,\n IdInterfaceGenerator<\"entryId\">,\n IdInterfaceGenerator<\"modelId\"> {}\n\nexport interface CmsEntryListWhereValues {\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 | Date\n | undefined\n | string[]\n | number[]\n | null\n | CmsEntryListWhereValues[]\n | CmsEntryListWhereValues\n | CmsEntryListWhereRef;\n}\n/**\n * Entry listing where params.\n *\n * @category CmsEntry\n * @category GraphQL params\n */\n\nexport interface CmsEntryListWhere\n extends\n IdMixedInterfaceGenerator<\"id\">,\n IdMixedInterfaceGenerator<\"entryId\">,\n IdInterfaceGenerator<\"status\", CmsEntryStatus>,\n /**\n * Revision-level meta fields. 👇\n */\n IdentityInterfaceGenerator<\"revisionCreatedBy\">,\n IdentityInterfaceGenerator<\"revisionModifiedBy\">,\n IdentityInterfaceGenerator<\"revisionSavedBy\">,\n IdentityInterfaceGenerator<\"revisionFirstPublishedBy\">,\n IdentityInterfaceGenerator<\"revisionLastPublishedBy\">,\n /**\n * Entry-level meta fields. 👇\n */\n IdentityInterfaceGenerator<\"createdBy\">,\n IdentityInterfaceGenerator<\"modifiedBy\">,\n IdentityInterfaceGenerator<\"savedBy\">,\n IdentityInterfaceGenerator<\"firstPublishedBy\">,\n IdentityInterfaceGenerator<\"lastPublishedBy\">,\n DateStringInterfaceGenerator<\"createdOn\">,\n DateStringInterfaceGenerator<\"savedOn\">,\n DateStringInterfaceGenerator<\"deletedOn\">,\n /**\n * Version of the entry.\n *\n * It is not meant to be used via the API.\n * @internal\n */\n NumericInterfaceGenerator<\"version\">,\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 TruthfulInterfaceGenerator<\"published\">,\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 TruthfulInterfaceGenerator<\"latest\"> {\n /**\n * ACO related parameters.\n */\n wbyAco_location?: {\n folderId?: string;\n folderId_not?: string;\n folderId_in?: string[];\n folderId_not_in?: string[];\n };\n location?: {\n folderId?: string;\n folderId_not?: string;\n folderId_in?: string[];\n folderId_not_in?: string[];\n };\n\n values?: CmsEntryListWhereValues;\n /**\n * Is the entry in the bin?\n */\n wbyDeleted?: boolean;\n wbyDeleted_not?: boolean;\n\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 CmsEntryListSortAsc = `${string}_ASC`;\nexport type CmsEntryListSortDesc = `${string}_DESC`;\nexport type CmsEntryListSort = (CmsEntryListSortAsc | CmsEntryListSortDesc)[];\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 * @category Context\n * @category CmsEntry\n */\nexport interface CreateCmsEntryInput<TValues extends CmsEntryValues = CmsEntryValues> {\n id?: string;\n status?: CmsEntryStatus;\n\n /**\n * Entry-level meta fields. 👇\n */\n createdOn?: Date | string;\n modifiedOn?: Date | string | null;\n savedOn?: Date | string;\n deletedOn?: Date | string | null;\n restoredOn?: Date | string | null;\n createdBy?: CmsIdentity;\n modifiedBy?: CmsIdentity;\n savedBy?: CmsIdentity;\n deletedBy?: CmsIdentity | null;\n restoredBy?: CmsIdentity | null;\n firstPublishedOn?: Date | string;\n lastPublishedOn?: Date | string;\n firstPublishedBy?: CmsIdentity;\n lastPublishedBy?: CmsIdentity;\n\n /**\n * Revision-level meta fields. 👇\n */\n revisionCreatedOn?: Date | string;\n revisionModifiedOn?: Date | string | null;\n revisionSavedOn?: Date | string;\n revisionDeletedOn?: Date | string | null;\n revisionRestoredOn?: Date | string | null;\n revisionCreatedBy?: CmsIdentity;\n revisionModifiedBy?: CmsIdentity | null;\n revisionSavedBy?: CmsIdentity;\n revisionDeletedBy?: CmsIdentity | null;\n revisionRestoredBy?: CmsIdentity | null;\n revisionFirstPublishedOn?: Date | string;\n revisionLastPublishedOn?: Date | string;\n revisionFirstPublishedBy?: CmsIdentity;\n revisionLastPublishedBy?: CmsIdentity;\n // TODO remove wbyAco_location\n wbyAco_location?: {\n folderId?: string | null;\n };\n location?: {\n folderId?: string | null;\n };\n\n system?: Partial<ICmsEntrySystem>;\n\n values: TValues | undefined;\n}\n\nexport interface CreateCmsEntryOptionsInput {\n skipValidators?: string[];\n}\n\n/**\n * @category Context\n * @category CmsEntry\n */\nexport interface CreateFromCmsEntryInput<TValues extends CmsEntryValues = CmsEntryValues> {\n /**\n * Revision-level meta fields. 👇\n */\n revisionCreatedOn?: Date;\n revisionSavedOn?: Date;\n revisionModifiedOn?: Date;\n revisionCreatedBy?: CmsIdentity;\n revisionModifiedBy?: CmsIdentity;\n revisionSavedBy?: CmsIdentity;\n revisionFirstPublishedOn?: Date | string;\n revisionLastPublishedOn?: Date | string;\n revisionFirstPublishedBy?: CmsIdentity;\n revisionLastPublishedBy?: CmsIdentity;\n\n /**\n * Entry-level meta fields. 👇\n */\n createdOn?: Date;\n savedOn?: Date;\n modifiedOn?: Date;\n createdBy?: CmsIdentity;\n modifiedBy?: CmsIdentity;\n savedBy?: CmsIdentity;\n firstPublishedOn?: Date | string;\n lastPublishedOn?: Date | string;\n firstPublishedBy?: CmsIdentity;\n lastPublishedBy?: CmsIdentity;\n\n system?: Partial<ICmsEntrySystem>;\n\n values: TValues;\n}\n\nexport interface CreateRevisionCmsEntryOptionsInput {\n skipValidators?: string[];\n}\n\n/**\n * @category Context\n * @category CmsEntry\n */\nexport interface UpdateCmsEntryInput<TValues extends CmsEntryValues = CmsEntryValues> {\n /**\n * Revision-level meta fields. 👇\n */\n revisionCreatedOn?: Date | string | null;\n revisionModifiedOn?: Date | string | null;\n revisionSavedOn?: Date | string | null;\n revisionDeletedOn?: Date | string | null;\n revisionRestoredOn?: Date | string | null;\n revisionFirstPublishedOn?: Date | string | null;\n revisionLastPublishedOn?: Date | string | null;\n revisionModifiedBy?: CmsIdentity | null;\n revisionCreatedBy?: CmsIdentity | null;\n revisionSavedBy?: CmsIdentity | null;\n revisionDeletedBy?: CmsIdentity | null;\n revisionRestoredBy?: CmsIdentity | null;\n revisionFirstPublishedBy?: CmsIdentity | null;\n revisionLastPublishedBy?: CmsIdentity | null;\n\n /**\n * Entry-level meta fields. 👇\n */\n createdOn?: Date | string | null;\n modifiedOn?: Date | string | null;\n savedOn?: Date | string | null;\n deletedOn?: Date | string | null;\n restoredOn?: Date | string | null;\n firstPublishedOn?: Date | string | null;\n lastPublishedOn?: Date | string | null;\n createdBy?: CmsIdentity | null;\n modifiedBy?: CmsIdentity | null;\n savedBy?: CmsIdentity | null;\n deletedBy?: CmsIdentity | null;\n restoredBy?: CmsIdentity | null;\n firstPublishedBy?: CmsIdentity | null;\n lastPublishedBy?: CmsIdentity | null;\n\n wbyAco_location?: {\n folderId?: string | null;\n };\n\n location?: {\n folderId?: string | null;\n };\n\n system?: Partial<ICmsEntrySystem>;\n\n values?: Partial<TValues>;\n}\n\nexport interface UpdateCmsEntryOptionsInput {\n skipValidators?: string[];\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 * Destroying the entry directly, without moving it to the bin.\n */\n permanently?: boolean;\n}\n\n/**\n * @category Context\n * @category CmsEntry\n */\nexport interface DeleteMultipleEntriesParams {\n entries: string[];\n}\n\nexport type DeleteMultipleEntriesResponse = {\n id: string;\n}[];\n\nexport interface CmsEntryValidateResponse {\n [key: string]: any;\n}\n\n/**\n * Parameters for CmsEntryResolverFactory.\n *\n * @category GraphQL resolver\n * @category CmsEntry\n */\ninterface CmsEntryResolverFactoryParams {\n model: CmsModel;\n fieldRegistry: ICmsModelFieldToGraphQLRegistry;\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 * A base security permission for CMS.\n *\n * @category SecurityPermission\n */\nexport interface BaseCmsSecurityPermission extends SecurityPermission {\n own?: boolean;\n rwd: string;\n}\n\n/**\n * A security permission for content model.\n *\n * @category SecurityPermission\n * @category CmsModel\n */\nexport interface CmsModelPermission extends BaseCmsSecurityPermission {\n models?: string[];\n groups?: string[];\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 groups?: string[];\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 models?: string[];\n groups?: string[];\n}\n\nexport interface CmsGroupStorageOperationsGetParams {\n id: string;\n tenant: string;\n}\n\nexport interface CmsGroupStorageOperationsListWhereParams {\n tenant: string;\n\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<void>;\n /**\n * Update existing content model group.\n */\n update: (params: CmsGroupStorageOperationsUpdateParams) => Promise<void>;\n /**\n * Delete the content model group.\n */\n delete: (params: CmsGroupStorageOperationsDeleteParams) => Promise<void>;\n}\n\nexport interface CmsModelStorageOperationsGetParams {\n tenant: string;\n modelId: string;\n}\n\nexport interface CmsModelStorageOperationsListWhereParams {\n tenant: string;\n\n [key: string]: string;\n}\n\nexport interface CmsModelStorageOperationsListParams {\n where: CmsModelStorageOperationsListWhereParams;\n}\n\nexport interface CmsModelStorageOperationsCreateParams {\n model: StorageCmsModel;\n}\n\nexport interface CmsModelStorageOperationsUpdateParams {\n model: StorageCmsModel;\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<StorageCmsModel | null>;\n /**\n * List all content models. Filterable via params.\n */\n list: (params: CmsModelStorageOperationsListParams) => Promise<StorageCmsModel[]>;\n /**\n * Create a new content model.\n */\n create: (params: CmsModelStorageOperationsCreateParams) => Promise<StorageCmsModel>;\n /**\n * Update existing content model.\n */\n update: (params: CmsModelStorageOperationsUpdateParams) => Promise<StorageCmsModel>;\n /**\n * Delete the content model.\n */\n delete: (params: CmsModelStorageOperationsDeleteParams) => Promise<void>;\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<T extends CmsEntryValues = CmsEntryValues> {\n /**\n * Real entry, with no transformations on it.\n */\n entry: CmsEntry<T>;\n /**\n * Entry prepared for the storage.\n */\n storageEntry: CmsStorageEntry<T>;\n}\n\nexport interface CmsEntryStorageOperationsCreateRevisionFromParams<\n T extends CmsEntryValues = CmsEntryValues\n> {\n /**\n * Real entry, with no transformations on it.\n */\n entry: CmsEntry<T>;\n /**\n * Entry prepared for the storage.\n */\n storageEntry: CmsStorageEntry<T>;\n}\n\nexport interface CmsEntryStorageOperationsUpdateParams<T extends CmsEntryValues = CmsEntryValues> {\n /**\n * Real entry, with no transformations on it.\n */\n entry: CmsEntry<T>;\n /**\n * Entry prepared for the storage.\n */\n storageEntry: CmsStorageEntry<T>;\n}\n\nexport interface CmsEntryStorageOperationsDeleteRevisionParams<\n T extends CmsEntryValues = CmsEntryValues\n> {\n /**\n * Entry that was deleted.\n */\n entry: CmsEntry<T>;\n /**\n * Entry that was deleted, directly from storage, with transformations.\n */\n storageEntry: CmsStorageEntry<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: CmsStorageEntry<T> | null;\n}\n\nexport interface CmsEntryStorageOperationsDeleteParams<T extends CmsEntryValues = CmsEntryValues> {\n entry: CmsEntry<T>;\n}\n\nexport interface CmsEntryStorageOperationsMoveToBinParams<\n T extends CmsEntryValues = CmsEntryValues\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<T>;\n /**\n * The modified entry and prepared for the storage.\n */\n storageEntry: CmsStorageEntry<T>;\n}\n\nexport interface CmsEntryStorageOperationsRestoreFromBinParams<\n T extends CmsEntryValues = CmsEntryValues\n> {\n /**\n * The modified entry that is going to be saved as restored.\n * Entry is in its original form.\n */\n entry: CmsEntry<T>;\n /**\n * The modified entry and prepared for the storage.\n */\n storageEntry: CmsStorageEntry<T>;\n}\n\nexport interface CmsEntryStorageOperationsDeleteEntriesParams {\n entries: string[];\n}\n\nexport interface CmsEntryStorageOperationsPublishParams<T extends CmsEntryValues = CmsEntryValues> {\n /**\n * The modified entry that is going to be saved as published.\n * Entry is in its original form.\n */\n entry: CmsEntry<T>;\n /**\n * The modified entry and prepared for the storage.\n */\n storageEntry: CmsStorageEntry<T>;\n}\n\nexport interface CmsEntryStorageOperationsUnpublishParams<\n T extends CmsEntryValues = CmsEntryValues\n> {\n /**\n * The modified entry that is going to be saved as unpublished.\n */\n entry: CmsEntry<T>;\n /**\n * The modified entry that is going to be saved as unpublished, with transformations on it.\n */\n storageEntry: CmsStorageEntry<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 {\n /**\n * Get all the entries of the ids.\n */\n getByIds: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsGetByIdsParams\n ) => Promise<CmsEntry<T>[]>;\n /**\n * Get all the published entries of the ids.\n */\n getPublishedByIds: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsGetPublishedByIdsParams\n ) => Promise<CmsEntry<T>[]>;\n /**\n * Get all the latest entries of the ids.\n */\n getLatestByIds: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsGetLatestByIdsParams\n ) => Promise<CmsEntry<T>[]>;\n /**\n * Get all revisions of the given entry id.\n */\n getRevisions: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsGetRevisionsParams\n ) => Promise<CmsEntry<T>[]>;\n /**\n * Get the entry by the given revision id.\n */\n getRevisionById: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsGetRevisionParams\n ) => Promise<CmsEntry<T> | null>;\n /**\n * Get the published entry by given entryId.\n */\n getPublishedRevisionByEntryId: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsGetPublishedRevisionParams\n ) => Promise<CmsEntry<T> | null>;\n /**\n * Get the latest entry by given entryId.\n */\n getLatestRevisionByEntryId: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsGetLatestRevisionParams\n ) => Promise<CmsEntry<T> | null>;\n /**\n * Get the revision of the entry before given one.\n */\n getPreviousRevision: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsGetPreviousRevisionParams\n ) => Promise<CmsEntry<T> | null>;\n /**\n * Gets entry by given params.\n */\n get: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsGetParams\n ) => Promise<CmsEntry<T> | null>;\n /**\n * List all entries. Filterable via params.\n */\n list: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsListParams\n ) => Promise<CmsEntryStorageOperationsListResponse<CmsEntry<T>>>;\n /**\n * Create a new entry.\n */\n create: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsCreateParams<T>\n ) => Promise<CmsEntry<T>>;\n /**\n * Create a new entry from existing one.\n */\n createRevisionFrom: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsCreateRevisionFromParams<T>\n ) => Promise<CmsEntry<T>>;\n /**\n * Update existing entry.\n */\n update: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsUpdateParams<T>\n ) => Promise<CmsEntry<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: <T extends CmsEntryValues = CmsEntryValues>(\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 * Move the entry to bin.\n */\n moveToBin: (model: CmsModel, params: CmsEntryStorageOperationsMoveToBinParams) => Promise<void>;\n /**\n * Restore the entry from the bin.\n */\n restoreFromBin: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsRestoreFromBinParams<T>\n ) => Promise<CmsEntry<T>>;\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: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsPublishParams<T>\n ) => Promise<CmsEntry<T>>;\n /**\n * Unpublish the entry.\n */\n unpublish: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsUnpublishParams<T>\n ) => Promise<CmsEntry<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 HeadlessCmsStorageOperations<C extends CmsContext = CmsContext> {\n name: string;\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"],"names":["CONTENT_ENTRY_STATUS"],"mappings":"AAm4CO,IAAKA,6BAAoBA,WAAAA,GAAAA,SAApBA,oBAAoB;;;;WAApBA"}
|
|
1
|
+
{"version":3,"file":"types/types.js","sources":["../../src/types/types.ts"],"sourcesContent":["import type { Context, GenericRecord } from \"@webiny/api/types.js\";\nimport type { GraphQLFieldResolver, GraphQLRequestBody } from \"@webiny/handler-graphql/types.js\";\nimport type { processRequestBody } from \"@webiny/handler-graphql\";\nimport type { DbContext } from \"@webiny/handler-db/types.js\";\nimport type { CmsModelConverterCallable } from \"~/utils/converters/ConverterCollection.js\";\nimport type { HeadlessCmsExport, HeadlessCmsImport } from \"~/export/types.js\";\nimport type { AccessControl } from \"~/crud/AccessControl/AccessControl.js\";\nimport type { CmsModelToAstConverter } from \"~/utils/contentModelAst/CmsModelToAstConverter.js\";\nimport type { ICmsModelFieldToGraphQLRegistry } from \"~/features/graphql/fields/abstractions/CmsModelFieldToGraphQLRegistry.js\";\nimport type { CmsEntryContext } from \"./context.js\";\nimport type { CmsModelField, CmsModelFieldValidation, CmsModelUpdateInput } from \"./modelField.js\";\nimport type {\n CmsModel,\n CmsModelCreateFromInput,\n CmsModelCreateInput,\n StorageCmsModel\n} from \"./model.js\";\nimport type { CmsGroup } from \"./modelGroup.js\";\nimport type { CmsIdentity } from \"./identity.js\";\nimport type { ApiCoreContext } from \"@webiny/api-core/types/core.js\";\nimport type { SecurityPermission } from \"@webiny/api-core/types/security.js\";\nimport type {\n DateStringInterfaceGenerator,\n IdentityInterfaceGenerator,\n IdInterfaceGenerator,\n IdMixedInterfaceGenerator,\n NumericInterfaceGenerator,\n TruthfulInterfaceGenerator\n} from \"@webiny/api\";\n\nexport type CmsIcon = {\n type: string;\n name: string;\n value?: string;\n};\n\nexport interface CmsError {\n message: string;\n code: string;\n data: GenericRecord;\n stack?: string;\n}\n\nexport type ApiEndpoint = \"manage\" | \"preview\" | \"read\";\n\nexport interface HeadlessCms extends CmsGroupContext, CmsModelContext, CmsEntryContext {\n /**\n * API type\n */\n type: ApiEndpoint | null;\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 /**\n * Use to ensure perform authorization and ensure identities have access to the groups, models and entries.\n */\n accessControl: AccessControl;\n\n /**\n * Export operations.\n */\n export: HeadlessCmsExport;\n importing: HeadlessCmsImport;\n getExecutableSchema: GetExecutableSchema;\n}\n\nexport type GetExecutableSchema = (\n type: ApiEndpoint\n) => Promise<\n <TData = Record<string, any>, TExtensions = Record<string, any>>(\n input: GraphQLRequestBody | GraphQLRequestBody[]\n ) => ReturnType<typeof processRequestBody<TData, TExtensions>>\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, ApiCoreContext {\n cms: HeadlessCms;\n}\n\n/**\n * Used for our internal functionality.\n */\nexport interface CmsModelFieldWithParent extends CmsModelField {\n parent?: CmsModelFieldWithParent | 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 extends CmsEntryValues = CmsEntryValues> {\n /**\n * A value to be validated.\n */\n value: T[keyof 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<T>;\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<\n T extends CmsEntryValues = CmsEntryValues\n> extends CmsModel {\n convertValueKeyToStorage: CmsModelConverterCallable<T>;\n convertValueKeyFromStorage: CmsModelConverterCallable<T>;\n}\n\n/**\n * @category ModelField\n */\nexport interface CmsModelFieldDefinition {\n fields: string;\n typeDefs?: string;\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 id?: string;\n name: string;\n slug?: string;\n description?: string | null;\n icon?: CmsIcon | null;\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?: CmsIcon;\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 };\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>;\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\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\nexport interface ICmsEntryLocation {\n folderId?: string;\n}\n\nexport interface ICmsEntryLive {\n version: number;\n}\n\nexport interface ICmsEntrySystem {\n // to be extended\n}\n/**\n * A content entry definition for and from the database.\n *\n * @category Database model\n * @category CmsEntry\n */\nexport interface CmsEntry<TValues extends CmsEntryValues = CmsEntryValues> {\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 /**\n * Revision-level meta fields. 👇\n */\n\n /**\n * An ISO 8601 date/time string.\n */\n revisionCreatedOn: string;\n /**\n * An ISO 8601 date/time string.\n */\n revisionSavedOn: string;\n /**\n * An ISO 8601 date/time string.\n */\n revisionModifiedOn: string | null;\n /**\n * An ISO 8601 date/time string.\n */\n revisionDeletedOn: string | null;\n /**\n * An ISO 8601 date/time string.\n */\n revisionRestoredOn: string | null;\n /**\n * An ISO 8601 date/time string.\n */\n revisionFirstPublishedOn: string | null;\n /**\n * An ISO 8601 date/time string.\n */\n revisionLastPublishedOn: string | null;\n\n /**\n * Identity that last ionCreated the entry.\n */\n revisionCreatedBy: CmsIdentity;\n /**\n * Identity that last ionSaved the entry.\n */\n revisionSavedBy: CmsIdentity;\n /**\n * Identity that last ionModified the entry.\n */\n revisionModifiedBy: CmsIdentity | null;\n /**\n * Identity that last deleted the revision.\n */\n revisionDeletedBy: CmsIdentity | null;\n /**\n * Identity that last restored the revision.\n */\n revisionRestoredBy: CmsIdentity | null;\n /**\n * Identity that first published the entry.\n */\n revisionFirstPublishedBy: CmsIdentity | null;\n /**\n * Identity that last published the entry.\n */\n revisionLastPublishedBy: CmsIdentity | null;\n\n /**\n * An ISO 8601 date/time string.\n */\n createdOn: string;\n /**\n * An ISO 8601 date/time string.\n */\n savedOn: string;\n /**\n * An ISO 8601 date/time string.\n */\n modifiedOn: string | null;\n /**\n * An ISO 8601 date/time string.\n */\n deletedOn: string | null;\n /**\n * An ISO 8601 date/time string.\n */\n restoredOn: string | null;\n /**\n * An ISO 8601 date/time string.\n */\n firstPublishedOn: string | null;\n /**\n * An ISO 8601 date/time string.\n */\n lastPublishedOn: string | null;\n\n /**\n * Identity that last created the entry.\n */\n createdBy: CmsIdentity;\n /**\n * Identity that last saved the entry.\n */\n savedBy: CmsIdentity;\n /**\n * Identity that last modified the entry.\n */\n modifiedBy: CmsIdentity | null;\n /**\n * Identity that last deleted the entry.\n */\n deletedBy: CmsIdentity | null;\n /**\n * Identity that last restored the entry.\n */\n restoredBy: CmsIdentity | null;\n /**\n * Identity that first published the entry.\n */\n firstPublishedBy: CmsIdentity | null;\n /**\n * Identity that last published the entry.\n */\n lastPublishedBy: CmsIdentity | null;\n\n /**\n * Model ID of the definition for the entry.\n * @see CmsModel\n */\n modelId: 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: TValues;\n /**\n * Advanced Content Organization\n */\n location?: ICmsEntryLocation;\n /**\n * Is the entry in the bin?\n */\n wbyDeleted?: boolean | null;\n /**\n * This field preserves the original folderId value, as the ROOT_FOLDER is set upon deletion.\n * The value is used when restoring the entry from the trash bin.\n */\n binOriginalFolderId?: string;\n\n system?: ICmsEntrySystem;\n /**\n * Is this CMS Entry live (no matter the revision).\n */\n live: ICmsEntryLive | null;\n /**\n * A revision description.\n */\n revisionDescription: string | undefined;\n /**\n * A timestamp of when the entry should be automatically deleted from the database.\n */\n expiresAt: number | null;\n}\n\nexport interface CmsStorageEntry<T extends CmsEntryValues = CmsEntryValues> extends CmsEntry<T> {\n [key: string]: any;\n}\n\nexport interface CmsEntryUniqueValue {\n value: string;\n count: number;\n}\n\nexport interface ICmsModelListParams {\n /**\n * Defaults to true.\n */\n includePrivate?: boolean;\n includePlugins?: boolean;\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 * @throws NotFoundError\n */\n getModel(modelId: string): Promise<CmsModel>;\n /**\n * Get model to AST converter.\n */\n getModelToAstConverter: () => CmsModelToAstConverter;\n /**\n * Get all content models.\n */\n listModels(params?: ICmsModelListParams): 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.\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 * Clear all the model caches.\n */\n clearModelsCache(): void;\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 extends\n IdInterfaceGenerator<\"id\">,\n IdInterfaceGenerator<\"entryId\">,\n IdInterfaceGenerator<\"modelId\"> {}\n\nexport interface CmsEntryListWhereValues {\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 | Date\n | undefined\n | string[]\n | number[]\n | null\n | CmsEntryListWhereValues[]\n | CmsEntryListWhereValues\n | CmsEntryListWhereRef;\n}\n/**\n * Entry listing where params.\n *\n * @category CmsEntry\n * @category GraphQL params\n */\n\nexport interface CmsEntryListWhere\n extends\n IdMixedInterfaceGenerator<\"id\">,\n IdMixedInterfaceGenerator<\"entryId\">,\n IdInterfaceGenerator<\"status\", CmsEntryStatus>,\n /**\n * Revision-level meta fields. 👇\n */\n IdentityInterfaceGenerator<\"revisionCreatedBy\">,\n IdentityInterfaceGenerator<\"revisionModifiedBy\">,\n IdentityInterfaceGenerator<\"revisionSavedBy\">,\n IdentityInterfaceGenerator<\"revisionFirstPublishedBy\">,\n IdentityInterfaceGenerator<\"revisionLastPublishedBy\">,\n /**\n * Entry-level meta fields. 👇\n */\n IdentityInterfaceGenerator<\"createdBy\">,\n IdentityInterfaceGenerator<\"modifiedBy\">,\n IdentityInterfaceGenerator<\"savedBy\">,\n IdentityInterfaceGenerator<\"firstPublishedBy\">,\n IdentityInterfaceGenerator<\"lastPublishedBy\">,\n DateStringInterfaceGenerator<\"createdOn\">,\n DateStringInterfaceGenerator<\"savedOn\">,\n DateStringInterfaceGenerator<\"deletedOn\">,\n /**\n * Version of the entry.\n *\n * It is not meant to be used via the API.\n * @internal\n */\n NumericInterfaceGenerator<\"version\">,\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 TruthfulInterfaceGenerator<\"published\">,\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 TruthfulInterfaceGenerator<\"latest\"> {\n /**\n * ACO related parameters.\n */\n wbyAco_location?: {\n folderId?: string;\n folderId_not?: string;\n folderId_in?: string[];\n folderId_not_in?: string[];\n };\n location?: {\n folderId?: string;\n folderId_not?: string;\n folderId_in?: string[];\n folderId_not_in?: string[];\n };\n\n values?: CmsEntryListWhereValues;\n /**\n * Is the entry in the bin?\n */\n wbyDeleted?: boolean;\n wbyDeleted_not?: boolean;\n\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 CmsEntryListSortAsc = `${string}_ASC`;\nexport type CmsEntryListSortDesc = `${string}_DESC`;\nexport type CmsEntryListSort = (CmsEntryListSortAsc | CmsEntryListSortDesc)[];\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 * @category Context\n * @category CmsEntry\n */\nexport interface CreateCmsEntryInput<TValues extends CmsEntryValues = CmsEntryValues> {\n id?: string;\n status?: CmsEntryStatus;\n\n /**\n * Entry-level meta fields. 👇\n */\n createdOn?: Date | string;\n modifiedOn?: Date | string | null;\n savedOn?: Date | string;\n deletedOn?: Date | string | null;\n restoredOn?: Date | string | null;\n createdBy?: CmsIdentity;\n modifiedBy?: CmsIdentity;\n savedBy?: CmsIdentity;\n deletedBy?: CmsIdentity | null;\n restoredBy?: CmsIdentity | null;\n firstPublishedOn?: Date | string;\n lastPublishedOn?: Date | string;\n firstPublishedBy?: CmsIdentity;\n lastPublishedBy?: CmsIdentity;\n\n /**\n * Revision-level meta fields. 👇\n */\n revisionCreatedOn?: Date | string;\n revisionModifiedOn?: Date | string | null;\n revisionSavedOn?: Date | string;\n revisionDeletedOn?: Date | string | null;\n revisionRestoredOn?: Date | string | null;\n revisionCreatedBy?: CmsIdentity;\n revisionModifiedBy?: CmsIdentity | null;\n revisionSavedBy?: CmsIdentity;\n revisionDeletedBy?: CmsIdentity | null;\n revisionRestoredBy?: CmsIdentity | null;\n revisionFirstPublishedOn?: Date | string;\n revisionLastPublishedOn?: Date | string;\n revisionFirstPublishedBy?: CmsIdentity;\n revisionLastPublishedBy?: CmsIdentity;\n // TODO remove wbyAco_location\n wbyAco_location?: {\n folderId?: string | null;\n };\n location?: {\n folderId?: string | null;\n };\n\n system?: Partial<ICmsEntrySystem>;\n\n values: TValues | undefined;\n\n expiresAt?: Date | undefined;\n}\n\nexport interface CreateCmsEntryOptionsInput {\n skipValidators?: string[];\n}\n\n/**\n * @category Context\n * @category CmsEntry\n */\nexport interface CreateFromCmsEntryInput<TValues extends CmsEntryValues = CmsEntryValues> {\n /**\n * Revision-level meta fields. 👇\n */\n revisionCreatedOn?: Date;\n revisionSavedOn?: Date;\n revisionModifiedOn?: Date;\n revisionCreatedBy?: CmsIdentity;\n revisionModifiedBy?: CmsIdentity;\n revisionSavedBy?: CmsIdentity;\n revisionFirstPublishedOn?: Date | string;\n revisionLastPublishedOn?: Date | string;\n revisionFirstPublishedBy?: CmsIdentity;\n revisionLastPublishedBy?: CmsIdentity;\n\n /**\n * Entry-level meta fields. 👇\n */\n createdOn?: Date;\n savedOn?: Date;\n modifiedOn?: Date;\n createdBy?: CmsIdentity;\n modifiedBy?: CmsIdentity;\n savedBy?: CmsIdentity;\n firstPublishedOn?: Date | string;\n lastPublishedOn?: Date | string;\n firstPublishedBy?: CmsIdentity;\n lastPublishedBy?: CmsIdentity;\n\n system?: Partial<ICmsEntrySystem>;\n\n values: TValues;\n}\n\nexport interface CreateRevisionCmsEntryOptionsInput {\n skipValidators?: string[];\n}\n\n/**\n * @category Context\n * @category CmsEntry\n */\nexport interface UpdateCmsEntryInput<TValues extends CmsEntryValues = CmsEntryValues> {\n /**\n * Revision-level meta fields. 👇\n */\n revisionCreatedOn?: Date | string | null;\n revisionModifiedOn?: Date | string | null;\n revisionSavedOn?: Date | string | null;\n revisionDeletedOn?: Date | string | null;\n revisionRestoredOn?: Date | string | null;\n revisionFirstPublishedOn?: Date | string | null;\n revisionLastPublishedOn?: Date | string | null;\n revisionModifiedBy?: CmsIdentity | null;\n revisionCreatedBy?: CmsIdentity | null;\n revisionSavedBy?: CmsIdentity | null;\n revisionDeletedBy?: CmsIdentity | null;\n revisionRestoredBy?: CmsIdentity | null;\n revisionFirstPublishedBy?: CmsIdentity | null;\n revisionLastPublishedBy?: CmsIdentity | null;\n\n /**\n * Entry-level meta fields. 👇\n */\n createdOn?: Date | string | null;\n modifiedOn?: Date | string | null;\n savedOn?: Date | string | null;\n deletedOn?: Date | string | null;\n restoredOn?: Date | string | null;\n firstPublishedOn?: Date | string | null;\n lastPublishedOn?: Date | string | null;\n createdBy?: CmsIdentity | null;\n modifiedBy?: CmsIdentity | null;\n savedBy?: CmsIdentity | null;\n deletedBy?: CmsIdentity | null;\n restoredBy?: CmsIdentity | null;\n firstPublishedBy?: CmsIdentity | null;\n lastPublishedBy?: CmsIdentity | null;\n\n wbyAco_location?: {\n folderId?: string | null;\n };\n\n location?: {\n folderId?: string | null;\n };\n\n system?: Partial<ICmsEntrySystem>;\n\n values?: Partial<TValues>;\n\n expiresAt?: Date | number | null | undefined;\n}\n\nexport interface UpdateCmsEntryOptionsInput {\n skipValidators?: string[];\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 * Destroying the entry directly, without moving it to the bin.\n */\n permanently?: boolean;\n}\n\n/**\n * @category Context\n * @category CmsEntry\n */\nexport interface DeleteMultipleEntriesParams {\n entries: string[];\n}\n\nexport type DeleteMultipleEntriesResponse = {\n id: string;\n}[];\n\nexport interface CmsEntryValidateResponse {\n [key: string]: any;\n}\n\n/**\n * Parameters for CmsEntryResolverFactory.\n *\n * @category GraphQL resolver\n * @category CmsEntry\n */\ninterface CmsEntryResolverFactoryParams {\n model: CmsModel;\n fieldRegistry: ICmsModelFieldToGraphQLRegistry;\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 * A base security permission for CMS.\n *\n * @category SecurityPermission\n */\nexport interface BaseCmsSecurityPermission extends SecurityPermission {\n own?: boolean;\n rwd: string;\n}\n\n/**\n * A security permission for content model.\n *\n * @category SecurityPermission\n * @category CmsModel\n */\nexport interface CmsModelPermission extends BaseCmsSecurityPermission {\n models?: string[];\n groups?: string[];\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 groups?: string[];\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 models?: string[];\n groups?: string[];\n}\n\nexport interface CmsGroupStorageOperationsGetParams {\n id: string;\n tenant: string;\n}\n\nexport interface CmsGroupStorageOperationsListWhereParams {\n tenant: string;\n\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<void>;\n /**\n * Update existing content model group.\n */\n update: (params: CmsGroupStorageOperationsUpdateParams) => Promise<void>;\n /**\n * Delete the content model group.\n */\n delete: (params: CmsGroupStorageOperationsDeleteParams) => Promise<void>;\n}\n\nexport interface CmsModelStorageOperationsGetParams {\n tenant: string;\n modelId: string;\n}\n\nexport interface CmsModelStorageOperationsListWhereParams {\n tenant: string;\n\n [key: string]: string;\n}\n\nexport interface CmsModelStorageOperationsListParams {\n where: CmsModelStorageOperationsListWhereParams;\n}\n\nexport interface CmsModelStorageOperationsCreateParams {\n model: StorageCmsModel;\n}\n\nexport interface CmsModelStorageOperationsUpdateParams {\n model: StorageCmsModel;\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<StorageCmsModel | null>;\n /**\n * List all content models. Filterable via params.\n */\n list: (params: CmsModelStorageOperationsListParams) => Promise<StorageCmsModel[]>;\n /**\n * Create a new content model.\n */\n create: (params: CmsModelStorageOperationsCreateParams) => Promise<StorageCmsModel>;\n /**\n * Update existing content model.\n */\n update: (params: CmsModelStorageOperationsUpdateParams) => Promise<StorageCmsModel>;\n /**\n * Delete the content model.\n */\n delete: (params: CmsModelStorageOperationsDeleteParams) => Promise<void>;\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<T extends CmsEntryValues = CmsEntryValues> {\n /**\n * Real entry, with no transformations on it.\n */\n entry: CmsEntry<T>;\n /**\n * Entry prepared for the storage.\n */\n storageEntry: CmsStorageEntry<T>;\n}\n\nexport interface CmsEntryStorageOperationsCreateRevisionFromParams<\n T extends CmsEntryValues = CmsEntryValues\n> {\n /**\n * Real entry, with no transformations on it.\n */\n entry: CmsEntry<T>;\n /**\n * Entry prepared for the storage.\n */\n storageEntry: CmsStorageEntry<T>;\n}\n\nexport interface CmsEntryStorageOperationsUpdateParams<T extends CmsEntryValues = CmsEntryValues> {\n /**\n * Real entry, with no transformations on it.\n */\n entry: CmsEntry<T>;\n /**\n * Entry prepared for the storage.\n */\n storageEntry: CmsStorageEntry<T>;\n}\n\nexport interface CmsEntryStorageOperationsDeleteRevisionParams<\n T extends CmsEntryValues = CmsEntryValues\n> {\n /**\n * Entry that was deleted.\n */\n entry: CmsEntry<T>;\n /**\n * Entry that was deleted, directly from storage, with transformations.\n */\n storageEntry: CmsStorageEntry<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: CmsStorageEntry<T> | null;\n}\n\nexport interface CmsEntryStorageOperationsDeleteParams<T extends CmsEntryValues = CmsEntryValues> {\n entry: CmsEntry<T>;\n}\n\nexport interface CmsEntryStorageOperationsMoveToBinParams<\n T extends CmsEntryValues = CmsEntryValues\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<T>;\n /**\n * The modified entry and prepared for the storage.\n */\n storageEntry: CmsStorageEntry<T>;\n}\n\nexport interface CmsEntryStorageOperationsRestoreFromBinParams<\n T extends CmsEntryValues = CmsEntryValues\n> {\n /**\n * The modified entry that is going to be saved as restored.\n * Entry is in its original form.\n */\n entry: CmsEntry<T>;\n /**\n * The modified entry and prepared for the storage.\n */\n storageEntry: CmsStorageEntry<T>;\n}\n\nexport interface CmsEntryStorageOperationsDeleteEntriesParams {\n entries: string[];\n}\n\nexport interface CmsEntryStorageOperationsPublishParams<T extends CmsEntryValues = CmsEntryValues> {\n /**\n * The modified entry that is going to be saved as published.\n * Entry is in its original form.\n */\n entry: CmsEntry<T>;\n /**\n * The modified entry and prepared for the storage.\n */\n storageEntry: CmsStorageEntry<T>;\n}\n\nexport interface CmsEntryStorageOperationsUnpublishParams<\n T extends CmsEntryValues = CmsEntryValues\n> {\n /**\n * The modified entry that is going to be saved as unpublished.\n */\n entry: CmsEntry<T>;\n /**\n * The modified entry that is going to be saved as unpublished, with transformations on it.\n */\n storageEntry: CmsStorageEntry<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 {\n /**\n * Get all the entries of the ids.\n */\n getByIds: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsGetByIdsParams\n ) => Promise<CmsEntry<T>[]>;\n /**\n * Get all the published entries of the ids.\n */\n getPublishedByIds: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsGetPublishedByIdsParams\n ) => Promise<CmsEntry<T>[]>;\n /**\n * Get all the latest entries of the ids.\n */\n getLatestByIds: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsGetLatestByIdsParams\n ) => Promise<CmsEntry<T>[]>;\n /**\n * Get all revisions of the given entry id.\n */\n getRevisions: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsGetRevisionsParams\n ) => Promise<CmsEntry<T>[]>;\n /**\n * Get the entry by the given revision id.\n */\n getRevisionById: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsGetRevisionParams\n ) => Promise<CmsEntry<T> | null>;\n /**\n * Get the published entry by given entryId.\n */\n getPublishedRevisionByEntryId: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsGetPublishedRevisionParams\n ) => Promise<CmsEntry<T> | null>;\n /**\n * Get the latest entry by given entryId.\n */\n getLatestRevisionByEntryId: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsGetLatestRevisionParams\n ) => Promise<CmsEntry<T> | null>;\n /**\n * Get the revision of the entry before given one.\n */\n getPreviousRevision: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsGetPreviousRevisionParams\n ) => Promise<CmsEntry<T> | null>;\n /**\n * Gets entry by given params.\n */\n get: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsGetParams\n ) => Promise<CmsEntry<T> | null>;\n /**\n * List all entries. Filterable via params.\n */\n list: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsListParams\n ) => Promise<CmsEntryStorageOperationsListResponse<CmsEntry<T>>>;\n /**\n * Create a new entry.\n */\n create: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsCreateParams<T>\n ) => Promise<CmsEntry<T>>;\n /**\n * Create a new entry from existing one.\n */\n createRevisionFrom: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsCreateRevisionFromParams<T>\n ) => Promise<CmsEntry<T>>;\n /**\n * Update existing entry.\n */\n update: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsUpdateParams<T>\n ) => Promise<CmsEntry<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: <T extends CmsEntryValues = CmsEntryValues>(\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 * Move the entry to bin.\n */\n moveToBin: (model: CmsModel, params: CmsEntryStorageOperationsMoveToBinParams) => Promise<void>;\n /**\n * Restore the entry from the bin.\n */\n restoreFromBin: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsRestoreFromBinParams<T>\n ) => Promise<CmsEntry<T>>;\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: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsPublishParams<T>\n ) => Promise<CmsEntry<T>>;\n /**\n * Unpublish the entry.\n */\n unpublish: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsUnpublishParams<T>\n ) => Promise<CmsEntry<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 HeadlessCmsStorageOperations<C extends CmsContext = CmsContext> {\n name: string;\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"],"names":["CONTENT_ENTRY_STATUS"],"mappings":"AA24CO,IAAKA,6BAAoBA,WAAAA,GAAAA,SAApBA,oBAAoB;;;;WAApBA"}
|