@webiny/api-headless-cms 6.0.0-rc.1 → 6.0.0-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/constants.d.ts +2 -1
  2. package/constants.js +4 -0
  3. package/constants.js.map +1 -1
  4. package/crud/contentEntry/entryDataFactories/createEntryData.js +4 -3
  5. package/crud/contentEntry/entryDataFactories/createEntryData.js.map +1 -1
  6. package/crud/contentEntry/entryDataFactories/createEntryRevisionFromData.js +4 -3
  7. package/crud/contentEntry/entryDataFactories/createEntryRevisionFromData.js.map +1 -1
  8. package/crud/contentEntry/entryDataFactories/createPublishEntryData.js +4 -1
  9. package/crud/contentEntry/entryDataFactories/createPublishEntryData.js.map +1 -1
  10. package/crud/contentEntry/entryDataFactories/createRepublishEntryData.js +4 -1
  11. package/crud/contentEntry/entryDataFactories/createRepublishEntryData.js.map +1 -1
  12. package/crud/contentEntry/entryDataFactories/createUnpublishEntryData.js +2 -1
  13. package/crud/contentEntry/entryDataFactories/createUnpublishEntryData.js.map +1 -1
  14. package/crud/contentEntry/entryDataFactories/createUpdateEntryData.js +4 -3
  15. package/crud/contentEntry/entryDataFactories/createUpdateEntryData.js.map +1 -1
  16. package/crud/contentEntry/entryDataFactories/system.d.ts +10 -0
  17. package/crud/contentEntry/entryDataFactories/system.js +14 -0
  18. package/crud/contentEntry/entryDataFactories/system.js.map +1 -0
  19. package/graphql/schema/baseSchema.js +17 -15
  20. package/graphql/schema/baseSchema.js.map +1 -1
  21. package/graphql/schema/createManageSDL.js +4 -2
  22. package/graphql/schema/createManageSDL.js.map +1 -1
  23. package/package.json +22 -22
  24. package/types/types.d.ts +12 -9
  25. package/types/types.js.map +1 -1
  26. package/crud/contentEntry/entryDataFactories/state.d.ts +0 -10
  27. package/crud/contentEntry/entryDataFactories/state.js +0 -16
  28. package/crud/contentEntry/entryDataFactories/state.js.map +0 -1
package/constants.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { CmsIdentity } from "./types/index.js";
1
+ import type { CmsIdentity, ICmsEntryLive } from "./types/index.js";
2
2
  export declare const ROOT_FOLDER = "root";
3
3
  export declare const CMS_MODEL_SINGLETON_TAG = "singleEntry";
4
4
  export declare const ENTRY_META_FIELDS: readonly ["createdOn", "modifiedOn", "savedOn", "deletedOn", "restoredOn", "firstPublishedOn", "lastPublishedOn", "createdBy", "modifiedBy", "savedBy", "deletedBy", "restoredBy", "firstPublishedBy", "lastPublishedBy", "revisionCreatedOn", "revisionModifiedOn", "revisionSavedOn", "revisionDeletedOn", "revisionRestoredOn", "revisionFirstPublishedOn", "revisionLastPublishedOn", "revisionCreatedBy", "revisionModifiedBy", "revisionSavedBy", "revisionDeletedBy", "revisionRestoredBy", "revisionFirstPublishedBy", "revisionLastPublishedBy"];
@@ -32,6 +32,7 @@ export interface RecordWithEntryMetaFields {
32
32
  restoredBy: CmsIdentity | null;
33
33
  firstPublishedBy: CmsIdentity | null;
34
34
  lastPublishedBy: CmsIdentity | null;
35
+ live: ICmsEntryLive | null;
35
36
  }
36
37
  export declare const pickEntryMetaFields: (object: Partial<RecordWithEntryMetaFields>, filter?: (fieldName: EntryMetaFieldName | string) => boolean) => Partial<RecordWithEntryMetaFields>;
37
38
  export declare const isNullableEntryMetaField: (fieldName: string) => boolean;
package/constants.js CHANGED
@@ -21,6 +21,10 @@ export const pickEntryMetaFields = (object, filter) => {
21
21
  });
22
22
  }
23
23
  }
24
+ /**
25
+ * Also add live field, as it's not part of entry meta fields, but it's required to be transfered.
26
+ */
27
+ pickedEntryMetaFields.live = object.live;
24
28
  return pickedEntryMetaFields;
25
29
  };
26
30
  export const isNullableEntryMetaField = fieldName => {
package/constants.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["ROOT_FOLDER","CMS_MODEL_SINGLETON_TAG","ENTRY_META_FIELDS","pickEntryMetaFields","object","filter","pickedEntryMetaFields","entryMetaFieldName","fieldExists","undefined","mustPick","Object","assign","isNullableEntryMetaField","fieldName","lcFieldName","toLowerCase","includes","isNonNullableEntryMetaField","isDateTimeEntryMetaField","endsWith","isIdentityEntryMetaField","isRevisionEntryMetaField","startsWith","isEntryLevelEntryMetaField","isDeletedEntryMetaField","isRestoredEntryMetaField"],"sources":["constants.ts"],"sourcesContent":["import type { CmsIdentity } from \"~/types/index.js\";\n\nexport const ROOT_FOLDER = \"root\";\n\nexport const CMS_MODEL_SINGLETON_TAG = \"singleEntry\";\n\n// Content entries - xOn and xBy meta fields.\nexport const ENTRY_META_FIELDS = [\n // Entry-level meta fields.\n \"createdOn\",\n \"modifiedOn\",\n \"savedOn\",\n \"deletedOn\",\n \"restoredOn\",\n \"firstPublishedOn\",\n \"lastPublishedOn\",\n \"createdBy\",\n \"modifiedBy\",\n \"savedBy\",\n \"deletedBy\",\n \"restoredBy\",\n \"firstPublishedBy\",\n \"lastPublishedBy\",\n\n // Revision-level meta fields.\n \"revisionCreatedOn\",\n \"revisionModifiedOn\",\n \"revisionSavedOn\",\n \"revisionDeletedOn\",\n \"revisionRestoredOn\",\n \"revisionFirstPublishedOn\",\n \"revisionLastPublishedOn\",\n \"revisionCreatedBy\",\n \"revisionModifiedBy\",\n \"revisionSavedBy\",\n \"revisionDeletedBy\",\n \"revisionRestoredBy\",\n \"revisionFirstPublishedBy\",\n \"revisionLastPublishedBy\"\n] as const;\n\nexport type EntryMetaFieldName = (typeof ENTRY_META_FIELDS)[number];\n\nexport interface RecordWithEntryMetaFields {\n revisionCreatedOn: string;\n revisionSavedOn: string;\n revisionModifiedOn: string | null;\n revisionDeletedOn: string | null;\n revisionRestoredOn: string | null;\n revisionFirstPublishedOn: string | null;\n revisionLastPublishedOn: string | null;\n revisionCreatedBy: CmsIdentity;\n revisionSavedBy: CmsIdentity;\n revisionModifiedBy: CmsIdentity | null;\n revisionDeletedBy: CmsIdentity | null;\n revisionRestoredBy: CmsIdentity | null;\n revisionFirstPublishedBy: CmsIdentity | null;\n revisionLastPublishedBy: CmsIdentity | null;\n\n // Entry-level meta fields.\n createdOn: string;\n savedOn: string;\n modifiedOn: string | null;\n deletedOn: string | null;\n restoredOn: string | null;\n firstPublishedOn: string | null;\n lastPublishedOn: string | null;\n createdBy: CmsIdentity;\n savedBy: CmsIdentity;\n modifiedBy: CmsIdentity | null;\n deletedBy: CmsIdentity | null;\n restoredBy: CmsIdentity | null;\n firstPublishedBy: CmsIdentity | null;\n lastPublishedBy: CmsIdentity | null;\n}\n\nexport const pickEntryMetaFields = (\n object: Partial<RecordWithEntryMetaFields>,\n filter?: (fieldName: EntryMetaFieldName | string) => boolean\n) => {\n const pickedEntryMetaFields: Partial<RecordWithEntryMetaFields> = {};\n for (const entryMetaFieldName of ENTRY_META_FIELDS) {\n const fieldExists = entryMetaFieldName in object;\n if (!fieldExists) {\n object[entryMetaFieldName] = undefined;\n }\n\n const mustPick = !filter || filter(entryMetaFieldName);\n if (mustPick) {\n Object.assign(pickedEntryMetaFields, {\n [entryMetaFieldName]: object[entryMetaFieldName]\n });\n }\n }\n\n return pickedEntryMetaFields;\n};\n\nexport const isNullableEntryMetaField = (fieldName: string) => {\n // Only modifiedX, publishedX, deletedX fields are nullable.\n const lcFieldName = fieldName.toLowerCase();\n return (\n lcFieldName.includes(\"modified\") ||\n lcFieldName.includes(\"published\") ||\n lcFieldName.includes(\"deleted\") ||\n lcFieldName.includes(\"restored\")\n );\n};\n\nexport const isNonNullableEntryMetaField = (fieldName: string) => {\n return !isNullableEntryMetaField(fieldName);\n};\n\nexport const isDateTimeEntryMetaField = (fieldName: string) => {\n // Only field ending with \"On\" are date/time fields.\n return fieldName.endsWith(\"On\");\n};\n\nexport const isIdentityEntryMetaField = (fieldName: string) => {\n // Only field ending with \"On\" are date/time fields.\n return fieldName.endsWith(\"By\");\n};\n\nexport const isRevisionEntryMetaField = (fieldName: string) => {\n return (\n ENTRY_META_FIELDS.includes(fieldName as EntryMetaFieldName) &&\n fieldName.startsWith(\"revision\")\n );\n};\n\nexport const isEntryLevelEntryMetaField = (fieldName: string) => {\n return (\n ENTRY_META_FIELDS.includes(fieldName as EntryMetaFieldName) &&\n !fieldName.startsWith(\"revision\")\n );\n};\n\nexport const isDeletedEntryMetaField = (fieldName: string) => {\n return (\n ENTRY_META_FIELDS.includes(fieldName as EntryMetaFieldName) && fieldName.includes(\"deleted\")\n );\n};\n\nexport const isRestoredEntryMetaField = (fieldName: string) => {\n return (\n ENTRY_META_FIELDS.includes(fieldName as EntryMetaFieldName) &&\n fieldName.includes(\"restored\")\n );\n};\n"],"mappings":"AAEA,OAAO,MAAMA,WAAW,GAAG,MAAM;AAEjC,OAAO,MAAMC,uBAAuB,GAAG,aAAa;;AAEpD;AACA,OAAO,MAAMC,iBAAiB,GAAG;AAC7B;AACA,WAAW,EACX,YAAY,EACZ,SAAS,EACT,WAAW,EACX,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,WAAW,EACX,YAAY,EACZ,SAAS,EACT,WAAW,EACX,YAAY,EACZ,kBAAkB,EAClB,iBAAiB;AAEjB;AACA,mBAAmB,EACnB,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,EACpB,0BAA0B,EAC1B,yBAAyB,EACzB,mBAAmB,EACnB,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,EACpB,0BAA0B,EAC1B,yBAAyB,CACnB;AAqCV,OAAO,MAAMC,mBAAmB,GAAGA,CAC/BC,MAA0C,EAC1CC,MAA4D,KAC3D;EACD,MAAMC,qBAAyD,GAAG,CAAC,CAAC;EACpE,KAAK,MAAMC,kBAAkB,IAAIL,iBAAiB,EAAE;IAChD,MAAMM,WAAW,GAAGD,kBAAkB,IAAIH,MAAM;IAChD,IAAI,CAACI,WAAW,EAAE;MACdJ,MAAM,CAACG,kBAAkB,CAAC,GAAGE,SAAS;IAC1C;IAEA,MAAMC,QAAQ,GAAG,CAACL,MAAM,IAAIA,MAAM,CAACE,kBAAkB,CAAC;IACtD,IAAIG,QAAQ,EAAE;MACVC,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ACG,QAAQ,CAAC,SAAS,CAAC;AAEpG,CAAC;AAED,OAAO,MAAMS,wBAAwB,GAAIZ,SAAiB,IAAK;EAC3D,OACIZ,iBAAiB,CAACe,QAAQ,CAACH,SAA+B,CAAC,IAC3DA,SAAS,CAACG,QAAQ,CAAC,UAAU,CAAC;AAEtC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["ROOT_FOLDER","CMS_MODEL_SINGLETON_TAG","ENTRY_META_FIELDS","pickEntryMetaFields","object","filter","pickedEntryMetaFields","entryMetaFieldName","fieldExists","undefined","mustPick","Object","assign","live","isNullableEntryMetaField","fieldName","lcFieldName","toLowerCase","includes","isNonNullableEntryMetaField","isDateTimeEntryMetaField","endsWith","isIdentityEntryMetaField","isRevisionEntryMetaField","startsWith","isEntryLevelEntryMetaField","isDeletedEntryMetaField","isRestoredEntryMetaField"],"sources":["constants.ts"],"sourcesContent":["import type { CmsIdentity, ICmsEntryLive } from \"~/types/index.js\";\n\nexport const ROOT_FOLDER = \"root\";\n\nexport const CMS_MODEL_SINGLETON_TAG = \"singleEntry\";\n\n// Content entries - xOn and xBy meta fields.\nexport const ENTRY_META_FIELDS = [\n // Entry-level meta fields.\n \"createdOn\",\n \"modifiedOn\",\n \"savedOn\",\n \"deletedOn\",\n \"restoredOn\",\n \"firstPublishedOn\",\n \"lastPublishedOn\",\n \"createdBy\",\n \"modifiedBy\",\n \"savedBy\",\n \"deletedBy\",\n \"restoredBy\",\n \"firstPublishedBy\",\n \"lastPublishedBy\",\n\n // Revision-level meta fields.\n \"revisionCreatedOn\",\n \"revisionModifiedOn\",\n \"revisionSavedOn\",\n \"revisionDeletedOn\",\n \"revisionRestoredOn\",\n \"revisionFirstPublishedOn\",\n \"revisionLastPublishedOn\",\n \"revisionCreatedBy\",\n \"revisionModifiedBy\",\n \"revisionSavedBy\",\n \"revisionDeletedBy\",\n \"revisionRestoredBy\",\n \"revisionFirstPublishedBy\",\n \"revisionLastPublishedBy\"\n] as const;\n\nexport type EntryMetaFieldName = (typeof ENTRY_META_FIELDS)[number];\n\nexport interface RecordWithEntryMetaFields {\n revisionCreatedOn: string;\n revisionSavedOn: string;\n revisionModifiedOn: string | null;\n revisionDeletedOn: string | null;\n revisionRestoredOn: string | null;\n revisionFirstPublishedOn: string | null;\n revisionLastPublishedOn: string | null;\n revisionCreatedBy: CmsIdentity;\n revisionSavedBy: CmsIdentity;\n revisionModifiedBy: CmsIdentity | null;\n revisionDeletedBy: CmsIdentity | null;\n revisionRestoredBy: CmsIdentity | null;\n revisionFirstPublishedBy: CmsIdentity | null;\n revisionLastPublishedBy: CmsIdentity | null;\n\n // Entry-level meta fields.\n createdOn: string;\n savedOn: string;\n modifiedOn: string | null;\n deletedOn: string | null;\n restoredOn: string | null;\n firstPublishedOn: string | null;\n lastPublishedOn: string | null;\n createdBy: CmsIdentity;\n savedBy: CmsIdentity;\n modifiedBy: CmsIdentity | null;\n deletedBy: CmsIdentity | null;\n restoredBy: CmsIdentity | null;\n firstPublishedBy: CmsIdentity | null;\n lastPublishedBy: CmsIdentity | null;\n live: ICmsEntryLive | null;\n}\n\nexport const pickEntryMetaFields = (\n object: Partial<RecordWithEntryMetaFields>,\n filter?: (fieldName: EntryMetaFieldName | string) => boolean\n) => {\n const pickedEntryMetaFields: Partial<RecordWithEntryMetaFields> = {};\n for (const entryMetaFieldName of ENTRY_META_FIELDS) {\n const fieldExists = entryMetaFieldName in object;\n if (!fieldExists) {\n object[entryMetaFieldName] = undefined;\n }\n\n const mustPick = !filter || filter(entryMetaFieldName);\n if (mustPick) {\n Object.assign(pickedEntryMetaFields, {\n [entryMetaFieldName]: object[entryMetaFieldName]\n });\n }\n }\n /**\n * Also add live field, as it's not part of entry meta fields, but it's required to be transfered.\n */\n pickedEntryMetaFields.live = object.live;\n\n return pickedEntryMetaFields;\n};\n\nexport const isNullableEntryMetaField = (fieldName: string) => {\n // Only modifiedX, publishedX, deletedX fields are nullable.\n const lcFieldName = fieldName.toLowerCase();\n return (\n lcFieldName.includes(\"modified\") ||\n lcFieldName.includes(\"published\") ||\n lcFieldName.includes(\"deleted\") ||\n lcFieldName.includes(\"restored\")\n );\n};\n\nexport const isNonNullableEntryMetaField = (fieldName: string) => {\n return !isNullableEntryMetaField(fieldName);\n};\n\nexport const isDateTimeEntryMetaField = (fieldName: string) => {\n // Only field ending with \"On\" are date/time fields.\n return fieldName.endsWith(\"On\");\n};\n\nexport const isIdentityEntryMetaField = (fieldName: string) => {\n // Only field ending with \"On\" are date/time fields.\n return fieldName.endsWith(\"By\");\n};\n\nexport const isRevisionEntryMetaField = (fieldName: string) => {\n return (\n ENTRY_META_FIELDS.includes(fieldName as EntryMetaFieldName) &&\n fieldName.startsWith(\"revision\")\n );\n};\n\nexport const isEntryLevelEntryMetaField = (fieldName: string) => {\n return (\n ENTRY_META_FIELDS.includes(fieldName as EntryMetaFieldName) &&\n !fieldName.startsWith(\"revision\")\n );\n};\n\nexport const isDeletedEntryMetaField = (fieldName: string) => {\n return (\n ENTRY_META_FIELDS.includes(fieldName as EntryMetaFieldName) && fieldName.includes(\"deleted\")\n );\n};\n\nexport const isRestoredEntryMetaField = (fieldName: string) => {\n return (\n ENTRY_META_FIELDS.includes(fieldName as EntryMetaFieldName) &&\n fieldName.includes(\"restored\")\n );\n};\n"],"mappings":"AAEA,OAAO,MAAMA,WAAW,GAAG,MAAM;AAEjC,OAAO,MAAMC,uBAAuB,GAAG,aAAa;;AAEpD;AACA,OAAO,MAAMC,iBAAiB,GAAG;AAC7B;AACA,WAAW,EACX,YAAY,EACZ,SAAS,EACT,WAAW,EACX,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,WAAW,EACX,YAAY,EACZ,SAAS,EACT,WAAW,EACX,YAAY,EACZ,kBAAkB,EAClB,iBAAiB;AAEjB;AACA,mBAAmB,EACnB,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,EACpB,0BAA0B,EAC1B,yBAAyB,EACzB,mBAAmB,EACnB,oBAAoB,EACpB,i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C,wBAAwB,GAAIP,SAAiB,IAAK;EAC3D;EACA,OAAOA,SAAS,CAACM,QAAQ,CAAC,IAAI,CAAC;AACnC,CAAC;AAED,OAAO,MAAME,wBAAwB,GAAIR,SAAiB,IAAK;EAC3D,OACIb,iBAAiB,CAACgB,QAAQ,CAACH,SAA+B,CAAC,IAC3DA,SAAS,CAACS,UAAU,CAAC,UAAU,CAAC;AAExC,CAAC;AAED,OAAO,MAAMC,0BAA0B,GAAIV,SAAiB,IAAK;EAC7D,OACIb,iBAAiB,CAACgB,QAAQ,CAACH,SAA+B,CAAC,IAC3D,CAACA,SAAS,CAACS,UAAU,CAAC,UAAU,CAAC;AAEzC,CAAC;AAED,OAAO,MAAME,uBAAuB,GAAIX,SAAiB,IAAK;EAC1D,OACIb,iBAAiB,CAACgB,QAAQ,CAACH,SAA+B,CAAC,IAAIA,SAAS,CAACG,QAAQ,CAAC,SAAS,CAAC;AAEpG,CAAC;AAED,OAAO,MAAMS,wBAAwB,GAAIZ,SAAiB,IAAK;EAC3D,OACIb,iBAAiB,CAACgB,QAAQ,CAACH,SAA+B,CAAC,IAC3DA,SAAS,CAACG,QAAQ,CAAC,UAAU,CAAC;AAEtC,CAAC","ignoreList":[]}
@@ -6,7 +6,7 @@ import { referenceFieldsMapping } from "../referenceFieldsMapping.js";
6
6
  import { createIdentifier, mdbid } from "@webiny/utils";
7
7
  import { STATUS_DRAFT, STATUS_PUBLISHED, STATUS_UNPUBLISHED } from "./statuses.js";
8
8
  import { getIdentity } from "../../../utils/identity.js";
9
- import { getState } from "./state.js";
9
+ import { getSystem } from "./system.js";
10
10
  /**
11
11
  * Used for some fields to convert their values.
12
12
  */
@@ -217,9 +217,10 @@ export const createEntryData = async ({
217
217
  location: {
218
218
  folderId: rawInput.location?.folderId || rawInput.wbyAco_location?.folderId || ROOT_FOLDER
219
219
  },
220
- state: getState({
220
+ system: getSystem({
221
221
  input: rawInput
222
- })
222
+ }),
223
+ live: null
223
224
  };
224
225
  if (status !== STATUS_DRAFT) {
225
226
  if (status === STATUS_PUBLISHED) {
@@ -1 +1 @@
1
- {"version":3,"names":["getDate","ROOT_FOLDER","WebinyError","validateModelEntryDataOrThrow","referenceFieldsMapping","createIdentifier","mdbid","STATUS_DRAFT","STATUS_PUBLISHED","STATUS_UNPUBLISHED","getIdentity","getState","convertDefaultValue","field","value","type","Boolean","Number","getDefaultValue","settings","list","defaultValue","undefined","predefinedValues","enabled","Array","isArray","values","selectedValue","find","selected","filter","map","createEntryId","input","entryId","id","match","version","cleanInputValues","model","fields","reduce","acc","fieldId","key","createEntryData","rawInput","options","context","getSecurityIdentity","getTenant","accessControl","initialValues","skipValidators","validateEntries","currentIdentity","currentDateTime","Date","status","ensureCanAccessEntry","pw","locked","revisionLevelPublishingMetaFields","revisionFirstPublishedOn","revisionLastPublishedOn","revisionFirstPublishedBy","revisionLastPublishedBy","entryLevelPublishingMetaFields","firstPublishedOn","lastPublishedOn","firstPublishedBy","lastPublishedBy","entry","tenant","modelId","createdOn","modifiedOn","savedOn","deletedOn","restoredOn","createdBy","modifiedBy","savedBy","deletedBy","restoredBy","revisionCreatedOn","revisionModifiedOn","revisionSavedOn","revisionDeletedOn","revisionRestoredOn","revisionCreatedBy","revisionModifiedBy","revisionSavedBy","revisionDeletedBy","revisionRestoredBy","location","folderId","wbyAco_location","state","structuredClone"],"sources":["createEntryData.ts"],"sourcesContent":["import type {\n CmsContext,\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 type { AccessControl } from \"~/crud/AccessControl/AccessControl.js\";\nimport { getState } from \"./state.js\";\nimport type { SecurityIdentity } from \"@webiny/api-core/types/security.js\";\nimport type { Tenant } from \"@webiny/api-core/types/tenancy.js\";\n\ntype DefaultValue = boolean | number | string | null;\n\n/**\n * Used for some fields to convert their values.\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 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\n/**\n * Cleans and adds default values to create input data.\n */\nconst cleanInputValues = <TValues extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n input: TValues\n) => {\n return model.fields.reduce<TValues>((acc, field) => {\n /**\n * This should never happen, but let's make it sure.\n * The fix would be for the user to add the fieldId on the field definition.\n */\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 /**\n * We set the default value on create input if value is not defined.\n */\n acc[key] = value === undefined ? (getDefaultValue(field) as TValues[keyof TValues]) : value;\n return acc;\n }, {} as TValues);\n};\n\ninterface CreateEntryDataParams<TValues extends CmsEntryValues = CmsEntryValues> {\n model: CmsModel;\n rawInput: CreateCmsEntryInput<TValues>;\n options?: CreateCmsEntryOptionsInput;\n context: CmsContext;\n getIdentity: () => SecurityIdentity;\n getTenant: () => Tenant;\n accessControl: AccessControl;\n}\n\ninterface ICreateEntryDataResponse<TValues extends CmsEntryValues = CmsEntryValues> {\n entry: CmsEntry<TValues>;\n input: CreateCmsEntryInput<TValues>;\n}\n\nexport const createEntryData = async <TValues extends CmsEntryValues = CmsEntryValues>({\n model,\n rawInput,\n options,\n context,\n getIdentity: getSecurityIdentity,\n getTenant,\n accessControl\n}: CreateEntryDataParams<TValues>): Promise<ICreateEntryDataResponse<TValues>> => {\n const initialValues = cleanInputValues<TValues>(model, rawInput.values || ({} as TValues));\n\n await validateModelEntryDataOrThrow({\n context,\n model,\n values: initialValues,\n skipValidators: options?.skipValidators\n });\n\n const values = await referenceFieldsMapping<TValues>({\n context,\n model,\n values: initialValues,\n validateEntries: true\n });\n\n const { id, entryId, version } = createEntryId(rawInput);\n\n /**\n * There is a possibility that user sends an ID in the input, so we will use that one.\n * There is no check if the ID is unique or not, that is up to the user.\n */\n const currentIdentity = getSecurityIdentity();\n const currentDateTime = new Date();\n\n /**\n * Users can set the initial status of the entry. If so, we need to make\n * sure they have the required permissions and also that all the fields\n * are filled in correctly.\n */\n const status = rawInput.status || STATUS_DRAFT;\n if (status !== STATUS_DRAFT) {\n if (status === STATUS_PUBLISHED) {\n await accessControl.ensureCanAccessEntry({ model, pw: \"p\" });\n } else if (status === STATUS_UNPUBLISHED) {\n // If setting the status other than draft, we have to check if the user has permissions to publish.\n await accessControl.ensureCanAccessEntry({ model, pw: \"u\" });\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(rawInput.revisionFirstPublishedOn, currentDateTime),\n revisionLastPublishedOn: getDate(rawInput.revisionLastPublishedOn, currentDateTime),\n revisionFirstPublishedBy: getIdentity(\n rawInput.revisionFirstPublishedBy,\n currentIdentity\n ),\n revisionLastPublishedBy: getIdentity(rawInput.revisionLastPublishedBy, currentIdentity)\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: getTenant().id,\n entryId,\n id,\n modelId: model.modelId,\n\n /**\n * Entry-level meta fields. 👇\n */\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\n /**\n * Revision-level meta fields. 👇\n */\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\n version,\n status,\n locked,\n values,\n location: {\n folderId:\n rawInput.location?.folderId || rawInput.wbyAco_location?.folderId || ROOT_FOLDER\n },\n state: getState({\n input: rawInput\n })\n };\n\n if (status !== STATUS_DRAFT) {\n if (status === STATUS_PUBLISHED) {\n await accessControl.ensureCanAccessEntry({ model, entry, pw: \"p\" });\n } else if (status === STATUS_UNPUBLISHED) {\n // If setting the status other than draft, we have to check if the user has permissions to publish.\n await accessControl.ensureCanAccessEntry({ model, entry, pw: \"u\" });\n }\n }\n\n return {\n entry,\n input: {\n ...rawInput,\n values: structuredClone(values)\n }\n };\n};\n"],"mappings":"AASA,SAASA,OAAO;AAChB,SAASC,WAAW;AACpB,OAAOC,WAAW,MAAM,eAAe;AACvC,SAASC,6BAA6B;AACtC,SAAS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ateModelEntryDataOrThrow","referenceFieldsMapping","createIdentifier","mdbid","STATUS_DRAFT","STATUS_PUBLISHED","STATUS_UNPUBLISHED","getIdentity","getSystem","convertDefaultValue","field","value","type","Boolean","Number","getDefaultValue","settings","list","defaultValue","undefined","predefinedValues","enabled","Array","isArray","values","selectedValue","find","selected","filter","map","createEntryId","input","entryId","id","match","version","cleanInputValues","model","fields","reduce","acc","fieldId","key","createEntryData","rawInput","options","context","getSecurityIdentity","getTenant","accessControl","initialValues","skipValidators","validateEntries","currentIdentity","currentDateTime","Date","status","ensureCanAccessEntry","pw","locked","revisionLevelPublishingMetaFields","revisionFirstPublishedOn","revisionLastPublishedOn","revisionFirstPublishedBy","revisionLastPublishedBy","entryLevelPublishingMetaFields","firstPublishedOn","lastPublishedOn","firstPublishedBy","lastPublishedBy","entry","tenant","modelId","createdOn","modifiedOn","savedOn","deletedOn","restoredOn","createdBy","modifiedBy","savedBy","deletedBy","restoredBy","revisionCreatedOn","revisionModifiedOn","revisionSavedOn","revisionDeletedOn","revisionRestoredOn","revisionCreatedBy","revisionModifiedBy","revisionSavedBy","revisionDeletedBy","revisionRestoredBy","location","folderId","wbyAco_location","system","live","structuredClone"],"sources":["createEntryData.ts"],"sourcesContent":["import type {\n CmsContext,\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 type { AccessControl } from \"~/crud/AccessControl/AccessControl.js\";\nimport { getSystem } from \"./system.js\";\nimport type { SecurityIdentity } from \"@webiny/api-core/types/security.js\";\nimport type { Tenant } from \"@webiny/api-core/types/tenancy.js\";\n\ntype DefaultValue = boolean | number | string | null;\n\n/**\n * Used for some fields to convert their values.\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 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\n/**\n * Cleans and adds default values to create input data.\n */\nconst cleanInputValues = <TValues extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n input: TValues\n) => {\n return model.fields.reduce<TValues>((acc, field) => {\n /**\n * This should never happen, but let's make it sure.\n * The fix would be for the user to add the fieldId on the field definition.\n */\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 /**\n * We set the default value on create input if value is not defined.\n */\n acc[key] = value === undefined ? (getDefaultValue(field) as TValues[keyof TValues]) : value;\n return acc;\n }, {} as TValues);\n};\n\ninterface CreateEntryDataParams<TValues extends CmsEntryValues = CmsEntryValues> {\n model: CmsModel;\n rawInput: CreateCmsEntryInput<TValues>;\n options?: CreateCmsEntryOptionsInput;\n context: CmsContext;\n getIdentity: () => SecurityIdentity;\n getTenant: () => Tenant;\n accessControl: AccessControl;\n}\n\ninterface ICreateEntryDataResponse<TValues extends CmsEntryValues = CmsEntryValues> {\n entry: CmsEntry<TValues>;\n input: CreateCmsEntryInput<TValues>;\n}\n\nexport const createEntryData = async <TValues extends CmsEntryValues = CmsEntryValues>({\n model,\n rawInput,\n options,\n context,\n getIdentity: getSecurityIdentity,\n getTenant,\n accessControl\n}: CreateEntryDataParams<TValues>): Promise<ICreateEntryDataResponse<TValues>> => {\n const initialValues = cleanInputValues<TValues>(model, rawInput.values || ({} as TValues));\n\n await validateModelEntryDataOrThrow({\n context,\n model,\n values: initialValues,\n skipValidators: options?.skipValidators\n });\n\n const values = await referenceFieldsMapping<TValues>({\n context,\n model,\n values: initialValues,\n validateEntries: true\n });\n\n const { id, entryId, version } = createEntryId(rawInput);\n\n /**\n * There is a possibility that user sends an ID in the input, so we will use that one.\n * There is no check if the ID is unique or not, that is up to the user.\n */\n const currentIdentity = getSecurityIdentity();\n const currentDateTime = new Date();\n\n /**\n * Users can set the initial status of the entry. If so, we need to make\n * sure they have the required permissions and also that all the fields\n * are filled in correctly.\n */\n const status = rawInput.status || STATUS_DRAFT;\n if (status !== STATUS_DRAFT) {\n if (status === STATUS_PUBLISHED) {\n await accessControl.ensureCanAccessEntry({ model, pw: \"p\" });\n } else if (status === STATUS_UNPUBLISHED) {\n // If setting the status other than draft, we have to check if the user has permissions to publish.\n await accessControl.ensureCanAccessEntry({ model, pw: \"u\" });\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(rawInput.revisionFirstPublishedOn, currentDateTime),\n revisionLastPublishedOn: getDate(rawInput.revisionLastPublishedOn, currentDateTime),\n revisionFirstPublishedBy: getIdentity(\n rawInput.revisionFirstPublishedBy,\n currentIdentity\n ),\n revisionLastPublishedBy: getIdentity(rawInput.revisionLastPublishedBy, currentIdentity)\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: getTenant().id,\n entryId,\n id,\n modelId: model.modelId,\n\n /**\n * Entry-level meta fields. 👇\n */\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\n /**\n * Revision-level meta fields. 👇\n */\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\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: null\n };\n\n if (status !== STATUS_DRAFT) {\n if (status === STATUS_PUBLISHED) {\n await accessControl.ensureCanAccessEntry({ model, entry, pw: \"p\" });\n } else if (status === STATUS_UNPUBLISHED) {\n // If setting the status other than draft, we have to check if the user has permissions to publish.\n await accessControl.ensureCanAccessEntry({ model, entry, pw: \"u\" });\n }\n }\n\n return {\n entry,\n input: {\n ...rawInput,\n values: structuredClone(values)\n }\n };\n};\n"],"mappings":"AASA,SAASA,OAAO;AAChB,SAASC,WAAW;AACpB,OAAOC,WAAW,MAAM,eAAe;AACvC,SAASC,6BAA6B;AACtC,SAASC,sBAAsB;AAC/B,SAASC,gBAAgB,EAAEC,KAAK,QAAQ,eAAe;AACvD,SAASC,YAAY,EA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,EAAElF,WAAW,CAACqC,QAAQ,CAAC6C,kBAAkB,EAAE,IAAI,CAAC;IAClEC,eAAe,EAAEnF,WAAW,CAACqC,QAAQ,CAAC8C,eAAe,EAAErC,eAAe,CAAE;IACxEsC,iBAAiB,EAAEpF,WAAW,CAACqC,QAAQ,CAAC+C,iBAAiB,EAAE,IAAI,CAAC;IAChEC,kBAAkB,EAAErF,WAAW,CAACqC,QAAQ,CAACgD,kBAAkB,EAAE,IAAI,CAAC;IAClE,GAAGhC,iCAAiC;IAEpCzB,OAAO;IACPqB,MAAM;IACNG,MAAM;IACNnC,MAAM;IACNqE,QAAQ,EAAE;MACNC,QAAQ,EACJlD,QAAQ,CAACiD,QAAQ,EAAEC,QAAQ,IAAIlD,QAAQ,CAACmD,eAAe,EAAED,QAAQ,IAAIhG;IAC7E,CAAC;IACDkG,MAAM,EAAExF,SAAS,CAAC;MACduB,KAAK,EAAEa;IACX,CAAC,CAAC;IACFqD,IAAI,EAAE;EACV,CAAC;EAED,IAAIzC,MAAM,KAAKpD,YAAY,EAAE;IACzB,IAAIoD,MAAM,KAAKnD,gBAAgB,EAAE;MAC7B,MAAM4C,aAAa,CAACQ,oBAAoB,CAAC;QAAEpB,KAAK;QAAEiC,KAAK;QAAEZ,EAAE,EAAE;MAAI,CAAC,CAAC;IACvE,CAAC,MAAM,IAAIF,MAAM,KAAKlD,kBAAkB,EAAE;MACtC;MACA,MAAM2C,aAAa,CAACQ,oBAAoB,CAAC;QAAEpB,KAAK;QAAEiC,KAAK;QAAEZ,EAAE,EAAE;MAAI,CAAC,CAAC;IACvE;EACJ;EAEA,OAAO;IACHY,KAAK;IACLvC,KAAK,EAAE;MACH,GAAGa,QAAQ;MACXpB,MAAM,EAAE0E,eAAe,CAAC1E,MAAM;IAClC;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
@@ -6,7 +6,7 @@ import { referenceFieldsMapping } from "../referenceFieldsMapping.js";
6
6
  import { createIdentifier, parseIdentifier } from "@webiny/utils";
7
7
  import WebinyError from "@webiny/error";
8
8
  import { STATUS_DRAFT, STATUS_PUBLISHED, STATUS_UNPUBLISHED } from "./statuses.js";
9
- import { getState } from "./state.js";
9
+ import { getSystem } from "./system.js";
10
10
  export const createEntryRevisionFromData = async ({
11
11
  sourceId,
12
12
  model,
@@ -122,10 +122,11 @@ export const createEntryRevisionFromData = async ({
122
122
  locked,
123
123
  status,
124
124
  values,
125
- state: getState({
125
+ system: getSystem({
126
126
  input: rawInput,
127
127
  original: originalEntry
128
- })
128
+ }),
129
+ live: originalEntry.live
129
130
  };
130
131
  return {
131
132
  entry,
@@ -1 +1 @@
1
- {"version":3,"names":["getDate","getIdentity","mapAndCleanUpdatedInputData","validateModelEntryDataOrThrow","referenceFieldsMapping","createIdentifier","parseIdentifier","WebinyError","STATUS_DRAFT","STATUS_PUBLISHED","STATUS_UNPUBLISHED","getState","createEntryRevisionFromData","sourceId","model","rawInput","options","context","getSecurityIdentity","originalEntry","latestStorageEntry","accessControl","initialValues","values","entry","skipValidators","validateEntries","latestId","id","version","nextVersion","increaseEntryIdVersion","currentIdentity","currentDateTime","Date","status","ensureCanAccessEntry","pw","locked","revisionLevelPublishingMetaFields","revisionFirstPublishedOn","revisionLastPublishedOn","revisionFirstPublishedBy","revisionLastPublishedBy","entryLevelPublishingMetaFields","firstPublishedOn","lastPublishedOn","firstPublishedBy","lastPublishedBy","createdOn","savedOn","modifiedOn","createdBy","savedBy","modifiedBy","revisionCreatedOn","revisionSavedOn","revisionModifiedOn","revisionCreatedBy","revisionSavedBy","revisionModifiedBy","state","input","original","structuredClone","entryId"],"sources":["createEntryRevisionFromData.ts"],"sourcesContent":["import type {\n CmsContext,\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 \"../entryDataValidation.js\";\nimport { referenceFieldsMapping } from \"../referenceFieldsMapping.js\";\nimport { createIdentifier, parseIdentifier } from \"@webiny/utils\";\nimport WebinyError from \"@webiny/error\";\nimport type { SecurityIdentity } from \"@webiny/api-core/types/security.js\";\nimport type { Tenant } from \"@webiny/api-core/types/tenancy.js\";\nimport { STATUS_DRAFT, STATUS_PUBLISHED, STATUS_UNPUBLISHED } from \"./statuses.js\";\nimport type { AccessControl } from \"~/crud/AccessControl/AccessControl.js\";\nimport { getState } from \"./state.js\";\n\ninterface CreateEntryRevisionFromDataParams<TValues extends CmsEntryValues = CmsEntryValues> {\n sourceId: string;\n model: CmsModel;\n rawInput: CreateCmsEntryInput<TValues>;\n options?: CreateCmsEntryOptionsInput;\n context: CmsContext;\n getIdentity: () => SecurityIdentity;\n getTenant: () => Tenant;\n originalEntry: CmsEntry<TValues>;\n latestStorageEntry: CmsEntry<TValues>;\n accessControl: AccessControl;\n}\n\ninterface ICreateEntryRevisionFromDataResponse<TValues extends CmsEntryValues = CmsEntryValues> {\n entry: CmsEntry<TValues>;\n input: CreateCmsEntryInput<TValues>;\n}\n\nexport const createEntryRevisionFromData = async <TValues extends CmsEntryValues = CmsEntryValues>({\n sourceId,\n model,\n rawInput,\n options,\n context,\n getIdentity: getSecurityIdentity,\n originalEntry,\n latestStorageEntry,\n accessControl\n}: CreateEntryRevisionFromDataParams<TValues>): Promise<\n ICreateEntryRevisionFromDataResponse<TValues>\n> => {\n /**\n * Make sure we only work with fields that are defined in the model.\n *\n * Also, we can be certain to cast as TValues because originalValues and new ones are being merged.\n */\n const initialValues = {\n ...originalEntry.values,\n ...mapAndCleanUpdatedInputData<TValues>(model, rawInput.values)\n };\n\n await validateModelEntryDataOrThrow({\n context,\n model,\n values: initialValues,\n entry: originalEntry,\n skipValidators: options?.skipValidators\n });\n\n const values = await referenceFieldsMapping<TValues>({\n context,\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 = getSecurityIdentity();\n const currentDateTime = new Date();\n\n /**\n * Users can set the initial status of the entry. If so, we need to make\n * sure they have the required permissions and also that all the fields\n * are filled in correctly.\n */\n const status = rawInput.status || STATUS_DRAFT;\n if (status !== STATUS_DRAFT) {\n if (status === STATUS_PUBLISHED) {\n await accessControl.ensureCanAccessEntry({ model, pw: \"p\" });\n } else if (status === STATUS_UNPUBLISHED) {\n // If setting the status other than draft, we have to check if the user has permissions to publish.\n await accessControl.ensureCanAccessEntry({ model, pw: \"u\" });\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(rawInput.firstPublishedOn, latestStorageEntry.firstPublishedOn),\n lastPublishedOn: getDate(rawInput.lastPublishedOn, latestStorageEntry.lastPublishedOn),\n firstPublishedBy: getIdentity(\n rawInput.firstPublishedBy,\n latestStorageEntry.firstPublishedBy\n ),\n lastPublishedBy: getIdentity(rawInput.lastPublishedBy, latestStorageEntry.lastPublishedBy)\n };\n\n if (status === STATUS_PUBLISHED) {\n revisionLevelPublishingMetaFields = {\n revisionFirstPublishedOn: getDate(rawInput.revisionFirstPublishedOn, currentDateTime),\n revisionLastPublishedOn: getDate(rawInput.revisionLastPublishedOn, currentDateTime),\n revisionFirstPublishedBy: getIdentity(\n rawInput.revisionFirstPublishedBy,\n currentIdentity\n ),\n revisionLastPublishedBy: getIdentity(rawInput.revisionLastPublishedBy, currentIdentity)\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\n /**\n * Entry-level meta fields. 👇\n */\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\n /**\n * Revision-level meta fields. 👇\n */\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\n locked,\n status,\n values,\n state: getState({\n input: rawInput,\n original: originalEntry\n })\n };\n\n return {\n entry,\n input: {\n ...rawInput,\n values: structuredClone(values)\n }\n };\n};\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"],"mappings":"AAQA,SAASA,OAAO;AAChB,SAASC,WAAW;AACpB,SAASC,2BAA2B;AACpC,SAASC,6BAA6B;AACtC,SAASC,sBAAsB;AAC/B,SAASC,gBAAgB,EAAEC,eAAe,QAAQ,eAAe;AACjE,OAAOC,WAAW,MAAM,eAAe;AAGvC,SAASC,YAAY,EAAEC,gBAAgB,EAAEC,kBAAkB;AAE3D,SAASC,QAAQ;AAoBjB,OAAO,MAAMC,2BAA2B,GAAG,MAAAA,CAAwD;EAC/FC,QAAQ;EACRC,KAAK;EACLC,QAAQ;EACRC,OAAO;EACPC,OAAO;EACPhB,WAAW,EAAEiB,mBAAmB;EAChCC,aAAa;EACbC,kBAAkB;EAClBC;AACwC,CAAC,KAExC;EACD;AACJ;AACA;AACA;AACA;EACI,MAAMC,aAAa,GAAG;IAClB,GAAGH,aAAa,CAACI,MAAM;IACvB,GAAGrB,2BAA2B,CAAUY,KAAK,EAAEC,QAAQ,CAACQ,MAAM;EAClE,CAAC;EAED,MAAMpB,6BAA6B,CAAC;IAChCc,OAAO;IACPH,KAAK;IACLS,MAAM,EAAED,aAAa;IACrBE,KAAK,EAAEL,aAAa;IACpBM,cAAc,EAAET,OAAO,EAAES;EAC7B,CAAC,CAAC;EAEF,MAAMF,MAAM,GAAG,MAAMnB,sBAAsB,CAAU;IACjDa,OAAO;IACPH,KAAK;IACLS,MAAM,EAAED,aAAa;IACrBI,eAAe,EAAE;EACrB,CAAC,CAAC;EAEF,MAAMC,QAAQ,GAAGP,kBAAkB,GAAGA,kBAAkB,CAACQ,EAAE,GAAGf,QAAQ;EACtE,MAAM;IAAEe,EAAE;IAAEC,OAAO,EAAEC;EAAY,CAAC,GAAGC,sBAAsB,CAACJ,QAAQ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CACjB,6DAA6D,EAC7D,UAAU,EACV;MACIqB;IACJ,CACJ,CAAC;EACL;EACA,OAAO;IACHqC,OAAO;IACPpC,OAAO,EAAEA,OAAO,GAAG,CAAC;IACpBD,EAAE,EAAEvB,gBAAgB,CAAC;MACjBuB,EAAE,EAAEqC,OAAO;MACXpC,OAAO,EAAEA,OAAO,GAAG;IACvB,CAAC;EACL,CAAC;AACL,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["getDate","getIdentity","mapAndCleanUpdatedInputData","validateModelEntryDataOrThrow","referenceFieldsMapping","createIdentifier","parseIdentifier","WebinyError","STATUS_DRAFT","STATUS_PUBLISHED","STATUS_UNPUBLISHED","getSystem","createEntryRevisionFromData","sourceId","model","rawInput","options","context","getSecurityIdentity","originalEntry","latestStorageEntry","accessControl","initialValues","values","entry","skipValidators","validateEntries","latestId","id","version","nextVersion","increaseEntryIdVersion","currentIdentity","currentDateTime","Date","status","ensureCanAccessEntry","pw","locked","revisionLevelPublishingMetaFields","revisionFirstPublishedOn","revisionLastPublishedOn","revisionFirstPublishedBy","revisionLastPublishedBy","entryLevelPublishingMetaFields","firstPublishedOn","lastPublishedOn","firstPublishedBy","lastPublishedBy","createdOn","savedOn","modifiedOn","createdBy","savedBy","modifiedBy","revisionCreatedOn","revisionSavedOn","revisionModifiedOn","revisionCreatedBy","revisionSavedBy","revisionModifiedBy","system","input","original","live","structuredClone","entryId"],"sources":["createEntryRevisionFromData.ts"],"sourcesContent":["import type {\n CmsContext,\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 \"../entryDataValidation.js\";\nimport { referenceFieldsMapping } from \"../referenceFieldsMapping.js\";\nimport { createIdentifier, parseIdentifier } from \"@webiny/utils\";\nimport WebinyError from \"@webiny/error\";\nimport type { SecurityIdentity } from \"@webiny/api-core/types/security.js\";\nimport type { Tenant } from \"@webiny/api-core/types/tenancy.js\";\nimport { STATUS_DRAFT, STATUS_PUBLISHED, STATUS_UNPUBLISHED } from \"./statuses.js\";\nimport type { AccessControl } from \"~/crud/AccessControl/AccessControl.js\";\nimport { getSystem } from \"./system.js\";\n\ninterface CreateEntryRevisionFromDataParams<TValues extends CmsEntryValues = CmsEntryValues> {\n sourceId: string;\n model: CmsModel;\n rawInput: CreateCmsEntryInput<TValues>;\n options?: CreateCmsEntryOptionsInput;\n context: CmsContext;\n getIdentity: () => SecurityIdentity;\n getTenant: () => Tenant;\n originalEntry: CmsEntry<TValues>;\n latestStorageEntry: CmsEntry<TValues>;\n accessControl: AccessControl;\n}\n\ninterface ICreateEntryRevisionFromDataResponse<TValues extends CmsEntryValues = CmsEntryValues> {\n entry: CmsEntry<TValues>;\n input: CreateCmsEntryInput<TValues>;\n}\n\nexport const createEntryRevisionFromData = async <TValues extends CmsEntryValues = CmsEntryValues>({\n sourceId,\n model,\n rawInput,\n options,\n context,\n getIdentity: getSecurityIdentity,\n originalEntry,\n latestStorageEntry,\n accessControl\n}: CreateEntryRevisionFromDataParams<TValues>): Promise<\n ICreateEntryRevisionFromDataResponse<TValues>\n> => {\n /**\n * Make sure we only work with fields that are defined in the model.\n *\n * Also, we can be certain to cast as TValues because originalValues and new ones are being merged.\n */\n const initialValues = {\n ...originalEntry.values,\n ...mapAndCleanUpdatedInputData<TValues>(model, rawInput.values)\n };\n\n await validateModelEntryDataOrThrow({\n context,\n model,\n values: initialValues,\n entry: originalEntry,\n skipValidators: options?.skipValidators\n });\n\n const values = await referenceFieldsMapping<TValues>({\n context,\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 = getSecurityIdentity();\n const currentDateTime = new Date();\n\n /**\n * Users can set the initial status of the entry. If so, we need to make\n * sure they have the required permissions and also that all the fields\n * are filled in correctly.\n */\n const status = rawInput.status || STATUS_DRAFT;\n if (status !== STATUS_DRAFT) {\n if (status === STATUS_PUBLISHED) {\n await accessControl.ensureCanAccessEntry({ model, pw: \"p\" });\n } else if (status === STATUS_UNPUBLISHED) {\n // If setting the status other than draft, we have to check if the user has permissions to publish.\n await accessControl.ensureCanAccessEntry({ model, pw: \"u\" });\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(rawInput.firstPublishedOn, latestStorageEntry.firstPublishedOn),\n lastPublishedOn: getDate(rawInput.lastPublishedOn, latestStorageEntry.lastPublishedOn),\n firstPublishedBy: getIdentity(\n rawInput.firstPublishedBy,\n latestStorageEntry.firstPublishedBy\n ),\n lastPublishedBy: getIdentity(rawInput.lastPublishedBy, latestStorageEntry.lastPublishedBy)\n };\n\n if (status === STATUS_PUBLISHED) {\n revisionLevelPublishingMetaFields = {\n revisionFirstPublishedOn: getDate(rawInput.revisionFirstPublishedOn, currentDateTime),\n revisionLastPublishedOn: getDate(rawInput.revisionLastPublishedOn, currentDateTime),\n revisionFirstPublishedBy: getIdentity(\n rawInput.revisionFirstPublishedBy,\n currentIdentity\n ),\n revisionLastPublishedBy: getIdentity(rawInput.revisionLastPublishedBy, currentIdentity)\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\n /**\n * Entry-level meta fields. 👇\n */\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\n /**\n * Revision-level meta fields. 👇\n */\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\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\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"],"mappings":"AAQA,SAASA,OAAO;AAChB,SAASC,WAAW;AACpB,SAASC,2BAA2B;AACpC,SAASC,6BAA6B;AACtC,SAASC,sBAAsB;AAC/B,SAASC,gBAAgB,EAAEC,eAAe,QAAQ,eAAe;AACjE,OAAOC,WAAW,MAAM,eAAe;AAGvC,SAASC,YAAY,EAAEC,gBAAgB,EAAEC,kBAAkB;AAE3D,SAASC,SAAS;AAoBlB,OAAO,MAAMC,2BAA2B,GAAG,MAAAA,CAAwD;EAC/FC,QAAQ;EACRC,KAAK;EACLC,QAAQ;EACRC,OAAO;EACPC,OAAO;EACPhB,WAAW,EAAEiB,mBAAmB;EAChCC,aAAa;EACbC,kBAAkB;EAClBC;AACwC,CAAC,KAExC;EACD;AACJ;AACA;AACA;AACA;EACI,MAAMC,aAAa,GAAG;IAClB,GAAGH,aAAa,CAACI,MAAM;IACvB,GAAGrB,2BAA2B,CAAUY,KAAK,EAAEC,QAAQ,CAACQ,MAAM;EAClE,CAAC;EAED,MAAMpB,6BAA6B,CAAC;IAChCc,OAAO;IACPH,KAAK;IACLS,MAAM,EAAED,aAAa;IACrBE,KAAK,EAAEL,aAAa;IACpBM,cAAc,EAAET,OAAO,EAAES;EAC7B,CAAC,CAAC;EAEF,MAAMF,MAAM,GAAG,MAAMnB,sBAAsB,CAAU;IACjDa,OAAO;IACPH,KAAK;IACLS,MAAM,EAAED,aAAa;IACrBI,eAAe,EAAE;EACrB,CAAC,CAAC;EAEF,MAAMC,QAAQ,GAAGP,kBAAkB,GAAGA,kBAAkB,CAACQ,EAAE,GAAGf,QAAQ;EACtE,MAAM;IAAEe,EAAE;IAAEC,OAAO,EAAEC;EAAY,CAAC,GAAGC,sBAAsB,CAACJ,QAAQ,CAAC;EAErE,MAAMK,eAAe,GAAGd,mBAAmB,CAAC,CAAC;EAC7C,MAAMe,eAAe,GAAG,IAAIC,IAA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J,CAAC;EACL;EACA,OAAO;IACHsC,OAAO;IACPrC,OAAO,EAAEA,OAAO,GAAG,CAAC;IACpBD,EAAE,EAAEvB,gBAAgB,CAAC;MACjBuB,EAAE,EAAEsC,OAAO;MACXrC,OAAO,EAAEA,OAAO,GAAG;IACvB,CAAC;EACL,CAAC;AACL,CAAC","ignoreList":[]}
@@ -46,7 +46,10 @@ export const createPublishEntryData = async ({
46
46
  revisionSavedBy: getIdentity(currentIdentity),
47
47
  revisionModifiedBy: getIdentity(currentIdentity),
48
48
  revisionFirstPublishedBy: getIdentity(originalEntry.revisionFirstPublishedBy, currentIdentity),
49
- revisionLastPublishedBy: getIdentity(currentIdentity)
49
+ revisionLastPublishedBy: getIdentity(currentIdentity),
50
+ live: {
51
+ version: originalEntry.version
52
+ }
50
53
  };
51
54
  return {
52
55
  entry
@@ -1 +1 @@
1
- {"version":3,"names":["STATUS_PUBLISHED","validateModelEntryDataOrThrow","getIdentity","getDate","createPublishEntryData","model","context","getSecurityIdentity","originalEntry","latestEntry","values","entry","currentDateTime","Date","toISOString","currentIdentity","status","locked","createdOn","modifiedOn","savedOn","firstPublishedOn","lastPublishedOn","createdBy","modifiedBy","savedBy","firstPublishedBy","lastPublishedBy","revisionCreatedOn","revisionSavedOn","revisionModifiedOn","revisionFirstPublishedOn","revisionLastPublishedOn","revisionCreatedBy","revisionSavedBy","revisionModifiedBy","revisionFirstPublishedBy","revisionLastPublishedBy"],"sources":["createPublishEntryData.ts"],"sourcesContent":["import type { CmsContext, CmsEntry, CmsEntryValues, CmsModel } from \"~/types/index.js\";\nimport { STATUS_PUBLISHED } from \"./statuses.js\";\nimport { validateModelEntryDataOrThrow } from \"~/crud/contentEntry/entryDataValidation.js\";\nimport { getIdentity } from \"~/utils/identity.js\";\nimport { getDate } from \"~/utils/date.js\";\nimport type { SecurityIdentity } from \"@webiny/api-core/types/security.js\";\n\ninterface ICreatePublishEntryDataParams<TValues extends CmsEntryValues = CmsEntryValues> {\n model: CmsModel;\n context: CmsContext;\n getIdentity: () => SecurityIdentity;\n originalEntry: CmsEntry<TValues>;\n latestEntry: CmsEntry<TValues>;\n}\n\ninterface ICreatePublishEntryDataResponse<T extends CmsEntryValues = CmsEntryValues> {\n entry: CmsEntry<T>;\n}\n\nexport const createPublishEntryData = async <T extends CmsEntryValues = CmsEntryValues>({\n model,\n context,\n getIdentity: getSecurityIdentity,\n originalEntry,\n latestEntry\n}: ICreatePublishEntryDataParams<T>): Promise<ICreatePublishEntryDataResponse<T>> => {\n await validateModelEntryDataOrThrow({\n context,\n model,\n values: originalEntry.values,\n entry: originalEntry\n });\n\n const currentDateTime = new Date().toISOString();\n const currentIdentity = getSecurityIdentity();\n\n const entry: CmsEntry<T> = {\n ...originalEntry,\n status: STATUS_PUBLISHED,\n locked: true,\n\n /**\n * Entry-level meta fields. 👇\n */\n createdOn: getDate(latestEntry.createdOn),\n modifiedOn: getDate(currentDateTime),\n savedOn: getDate(currentDateTime),\n firstPublishedOn: getDate(latestEntry.firstPublishedOn, currentDateTime),\n lastPublishedOn: getDate(currentDateTime),\n createdBy: getIdentity(latestEntry.createdBy),\n modifiedBy: getIdentity(currentIdentity),\n savedBy: getIdentity(currentIdentity),\n firstPublishedBy: getIdentity(latestEntry.firstPublishedBy, currentIdentity),\n lastPublishedBy: getIdentity(currentIdentity),\n\n /**\n * Revision-level meta fields. 👇\n */\n revisionCreatedOn: getDate(originalEntry.revisionCreatedOn),\n revisionSavedOn: getDate(currentDateTime),\n revisionModifiedOn: getDate(currentDateTime),\n revisionFirstPublishedOn: getDate(originalEntry.revisionFirstPublishedOn, currentDateTime),\n revisionLastPublishedOn: getDate(currentDateTime),\n revisionCreatedBy: getIdentity(originalEntry.revisionCreatedBy),\n revisionSavedBy: getIdentity(currentIdentity),\n revisionModifiedBy: getIdentity(currentIdentity),\n revisionFirstPublishedBy: getIdentity(\n originalEntry.revisionFirstPublishedBy,\n currentIdentity\n ),\n revisionLastPublishedBy: getIdentity(currentIdentity)\n };\n\n return {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DC,eAAe,EAAE1B,OAAO,CAACS,eAAe,CAAC;IACzCkB,kBAAkB,EAAE3B,OAAO,CAACS,eAAe,CAAC;IAC5CmB,wBAAwB,EAAE5B,OAAO,CAACK,aAAa,CAACuB,wBAAwB,EAAEnB,eAAe,CAAC;IAC1FoB,uBAAuB,EAAE7B,OAAO,CAACS,eAAe,CAAC;IACjDqB,iBAAiB,EAAE/B,WAAW,CAACM,aAAa,CAACyB,iBAAiB,CAAC;IAC/DC,eAAe,EAAEhC,WAAW,CAACa,eAAe,CAAC;IAC7CoB,kBAAkB,EAAEjC,WAAW,CAACa,eAAe,CAAC;IAChDqB,wBAAwB,EAAElC,WAAW,CACjCM,aAAa,CAAC4B,wBAAwB,EACtCrB,eACJ,CAAC;IACDsB,uBAAuB,EAAEnC,WAAW,CAACa,eAAe;EACxD,CAAC;EAED,OAAO;IAAEJ;EAAM,CAAC;AACpB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["STATUS_PUBLISHED","validateModelEntryDataOrThrow","getIdentity","getDate","createPublishEntryData","model","context","getSecurityIdentity","originalEntry","latestEntry","values","entry","currentDateTime","Date","toISOString","currentIdentity","status","locked","createdOn","modifiedOn","savedOn","firstPublishedOn","lastPublishedOn","createdBy","modifiedBy","savedBy","firstPublishedBy","lastPublishedBy","revisionCreatedOn","revisionSavedOn","revisionModifiedOn","revisionFirstPublishedOn","revisionLastPublishedOn","revisionCreatedBy","revisionSavedBy","revisionModifiedBy","revisionFirstPublishedBy","revisionLastPublishedBy","live","version"],"sources":["createPublishEntryData.ts"],"sourcesContent":["import type { CmsContext, CmsEntry, CmsEntryValues, CmsModel } from \"~/types/index.js\";\nimport { STATUS_PUBLISHED } from \"./statuses.js\";\nimport { validateModelEntryDataOrThrow } from \"~/crud/contentEntry/entryDataValidation.js\";\nimport { getIdentity } from \"~/utils/identity.js\";\nimport { getDate } from \"~/utils/date.js\";\nimport type { SecurityIdentity } from \"@webiny/api-core/types/security.js\";\n\ninterface ICreatePublishEntryDataParams<TValues extends CmsEntryValues = CmsEntryValues> {\n model: CmsModel;\n context: CmsContext;\n getIdentity: () => SecurityIdentity;\n originalEntry: CmsEntry<TValues>;\n latestEntry: CmsEntry<TValues>;\n}\n\ninterface ICreatePublishEntryDataResponse<T extends CmsEntryValues = CmsEntryValues> {\n entry: CmsEntry<T>;\n}\n\nexport const createPublishEntryData = async <T extends CmsEntryValues = CmsEntryValues>({\n model,\n context,\n getIdentity: getSecurityIdentity,\n originalEntry,\n latestEntry\n}: ICreatePublishEntryDataParams<T>): Promise<ICreatePublishEntryDataResponse<T>> => {\n await validateModelEntryDataOrThrow({\n context,\n model,\n values: originalEntry.values,\n entry: originalEntry\n });\n\n const currentDateTime = new Date().toISOString();\n const currentIdentity = getSecurityIdentity();\n\n const entry: CmsEntry<T> = {\n ...originalEntry,\n status: STATUS_PUBLISHED,\n locked: true,\n\n /**\n * Entry-level meta fields. 👇\n */\n createdOn: getDate(latestEntry.createdOn),\n modifiedOn: getDate(currentDateTime),\n savedOn: getDate(currentDateTime),\n firstPublishedOn: getDate(latestEntry.firstPublishedOn, currentDateTime),\n lastPublishedOn: getDate(currentDateTime),\n createdBy: getIdentity(latestEntry.createdBy),\n modifiedBy: getIdentity(currentIdentity),\n savedBy: getIdentity(currentIdentity),\n firstPublishedBy: getIdentity(latestEntry.firstPublishedBy, currentIdentity),\n lastPublishedBy: getIdentity(currentIdentity),\n\n /**\n * Revision-level meta fields. 👇\n */\n revisionCreatedOn: getDate(originalEntry.revisionCreatedOn),\n revisionSavedOn: getDate(currentDateTime),\n revisionModifiedOn: getDate(currentDateTime),\n revisionFirstPublishedOn: getDate(originalEntry.revisionFirstPublishedOn, currentDateTime),\n revisionLastPublishedOn: getDate(currentDateTime),\n revisionCreatedBy: getIdentity(originalEntry.revisionCreatedBy),\n revisionSavedBy: getIdentity(currentIdentity),\n revisionModifiedBy: getIdentity(currentIdentity),\n revisionFirstPublishedBy: getIdentity(\n originalEntry.revisionFirstPublishedBy,\n currentIdentity\n ),\n revisionLastPublishedBy: getIdentity(currentIdentity),\n\n live: {\n version: originalEntry.version\n }\n };\n\n return { entry };\n};\n"],"mappings":"AACA,SAASA,gBAAgB;AACzB,SAASC,6BAA6B;AACtC,SAASC,WAAW;AACpB,SAASC,OAAO;AAehB,OAAO,MAAMC,sBAAsB,GAAG,MAAAA,CAAkD;EACpFC,KAAK;EACLC,OAAO;EACPJ,WAAW,EAAEK,mBAAmB;EAChCC,aAAa;EACbC;AAC8B,CAAC,KAAkD;EACjF,MAAMR,6BAA6B,CAAC;IAChCK,OAAO;IACPD,KAAK;IACLK,MAAM,EAAEF,aAAa,CAACE,MAAM;IAC5BC,KAAK,EAAEH;EACX,CAAC,CAAC;EAEF,MAAMI,eAAe,GAAG,IAAIC,IAAI,CAAC,CAAC,CAACC,WAAW,CAAC,CAAC;EAChD,MAAMC,eAAe,GAAGR,mBAAmB,CAAC,CAAC;EAE7C,MAAMI,KAAkB,GAAG;IACvB,GAAGH,aAAa;IAChBQ,MAAM,EAAEhB,gBAAgB;IACxBiB,MAAM,EAAE,IAAI;IAEZ;AACR;AACA;IACQC,SAAS,EAAEf,OAAO,CAACM,WAAW,CAACS,SAAS,CAAC;IACzCC,UAAU,EAAEhB,OAAO,CAACS,eAAe,CAAC;IACpCQ,OAAO,EAAEjB,OAAO,CAACS,eAAe,CAAC;IACjCS,gBAAgB,EAAElB,OAAO,CAACM,WAAW,CAACY,gBAAgB,EAAET,eAAe,CAAC;IACxEU,eAAe,EAAEnB,OAAO,CAACS,eAAe,CAAC;IACzCW,SAAS,EAAErB,WAAW,CAACO,WAAW,CAACc,SAAS,CAAC;IAC7CC,UAAU,EAAEtB,WAAW,CAACa,eAAe,CAAC;IACxCU,OAAO,EAAEvB,WAAW,CAACa,eAAe,CAAC;IACrCW,gBAAgB,EAAExB,WAAW,CAACO,WAAW,CAACiB,gBAAgB,EAAEX,eAAe,CAAC;IAC5EY,eAAe,EAAEzB,WAAW,CAACa,eAAe,CAAC;IAE7C;AACR;AACA;IACQa,iBAAiB,EAAEzB,OAAO,CAACK,aAAa,CAACoB,iBAAiB,CAAC;IAC3DC,eAAe,EAAE1B,OAAO,CAACS,eAAe,CAAC;IACzCkB,kBAAkB,EAAE3B,OAAO,CAACS,eAAe,CAAC;IAC5CmB,wBAAwB,EAAE5B,OAAO,CAACK,aAAa,CAACuB,wBAAwB,EAAEnB,eAAe,CAAC;IAC1FoB,uBAAuB,EAAE7B,OAAO,CAACS,eAAe,CAAC;IACjDqB,iBAAiB,EAAE/B,WAAW,CAACM,aAAa,CAACyB,iBAAiB,CAAC;IAC/DC,eAAe,EAAEhC,WAAW,CAACa,eAAe,CAAC;IAC7CoB,kBAAkB,EAAEjC,WAAW,CAACa,eAAe,CAAC;IAChDqB,wBAAwB,EAAElC,WAAW,CACjCM,aAAa,CAAC4B,wBAAwB,EACtCrB,eACJ,CAAC;IACDsB,uBAAuB,EAAEnC,WAAW,CAACa,eAAe,CAAC;IAErDuB,IAAI,EAAE;MACFC,OAAO,EAAE/B,aAAa,CAAC+B;IAC3B;EACJ,CAAC;EAED,OAAO;IAAE5B;EAAM,CAAC;AACpB,CAAC","ignoreList":[]}
@@ -41,7 +41,10 @@ export const createRepublishEntryData = async ({
41
41
  revisionFirstPublishedBy: getIdentity(originalEntry.revisionFirstPublishedBy, currentIdentity),
42
42
  revisionLastPublishedOn: getDate(currentDateTime),
43
43
  revisionLastPublishedBy: getIdentity(currentIdentity),
44
- values
44
+ values,
45
+ live: {
46
+ version: originalEntry.version
47
+ }
45
48
  };
46
49
  return {
47
50
  entry
@@ -1 +1 @@
1
- {"version":3,"names":["referenceFieldsMapping","STATUS_PUBLISHED","getIdentity","getDate","createRepublishEntryData","model","context","getSecurityIdentity","originalEntry","values","validateEntries","currentDateTime","Date","toISOString","currentIdentity","entry","status","savedOn","modifiedOn","savedBy","modifiedBy","firstPublishedOn","firstPublishedBy","lastPublishedOn","lastPublishedBy","revisionSavedOn","revisionModifiedOn","revisionSavedBy","revisionModifiedBy","revisionFirstPublishedOn","revisionFirstPublishedBy","revisionLastPublishedOn","revisionLastPublishedBy"],"sources":["createRepublishEntryData.ts"],"sourcesContent":["import type { CmsContext, CmsEntry, CmsEntryValues, CmsModel } from \"~/types/index.js\";\nimport { referenceFieldsMapping } from \"~/crud/contentEntry/referenceFieldsMapping.js\";\nimport { STATUS_PUBLISHED } from \"./statuses.js\";\nimport { getIdentity } from \"~/utils/identity.js\";\nimport { getDate } from \"~/utils/date.js\";\nimport type { SecurityIdentity } from \"@webiny/api-core/types/security.js\";\n\ntype CreateRepublishEntryDataParams<TValues extends CmsEntryValues = CmsEntryValues> = {\n model: CmsModel;\n context: CmsContext;\n getIdentity: () => SecurityIdentity;\n originalEntry: CmsEntry<TValues>;\n};\n\ninterface ICreateRepublishEntryDataResponse<TValues extends CmsEntryValues = CmsEntryValues> {\n entry: CmsEntry<TValues>;\n}\n\nexport const createRepublishEntryData = async <TValues extends CmsEntryValues = CmsEntryValues>({\n model,\n context,\n getIdentity: getSecurityIdentity,\n originalEntry\n}: CreateRepublishEntryDataParams<TValues>): Promise<\n ICreateRepublishEntryDataResponse<TValues>\n> => {\n const values = await referenceFieldsMapping<TValues>({\n context,\n model,\n values: originalEntry.values,\n validateEntries: false\n });\n\n const currentDateTime = new Date().toISOString();\n const currentIdentity = getSecurityIdentity();\n\n const entry: CmsEntry<TValues> = {\n ...originalEntry,\n status: STATUS_PUBLISHED,\n /**\n * Entry-level meta fields. 👇\n */\n savedOn: getDate(currentDateTime),\n modifiedOn: getDate(currentDateTime),\n savedBy: getIdentity(currentIdentity)!,\n modifiedBy: getIdentity(currentIdentity),\n firstPublishedOn: getDate(originalEntry.firstPublishedOn, currentDateTime),\n firstPublishedBy: getIdentity(originalEntry.firstPublishedBy, currentIdentity),\n lastPublishedOn: getDate(currentDateTime),\n lastPublishedBy: getIdentity(currentIdentity),\n\n /**\n * Revision-level meta fields. 👇\n */\n revisionSavedOn: getDate(currentDateTime),\n revisionModifiedOn: getDate(currentDateTime),\n revisionSavedBy: getIdentity(currentIdentity)!,\n revisionModifiedBy: getIdentity(currentIdentity),\n revisionFirstPublishedOn: getDate(originalEntry.revisionFirstPublishedOn, currentDateTime),\n revisionFirstPublishedBy: getIdentity(\n originalEntry.revisionFirstPublishedBy,\n currentIdentity\n ),\n revisionLastPublishedOn: getDate(currentDateTime),\n revisionLastPublishedBy: getIdentity(currentIdentity),\n values\n };\n\n return {\n entry\n };\n};\n"],"mappings":"AACA,SAASA,sBAAsB;AAC/B,SAASC,gBAAgB;AACzB,SAASC,WAAW;AACpB,SAASC,OAAO;AAchB,OAAO,MAAMC,wBAAwB,GAAG,MAAAA,CAAwD;EAC5FC,KAAK;EACLC,OAAO;EACPJ,WAAW,EAAEK,mBAAmB;EAChCC;AACqC,CAAC,KAErC;EACD,MAAMC,MAAM,GAAG,MAAMT,sBAAsB,CAAU;IACjDM,OAAO;IACPD,KAAK;IACLI,MAAM,EAAED,aAAa,CAACC,MAAM;IAC5BC,eAAe,EAAE;EACrB,CAAC,CAAC;EAEF,MAAMC,eAAe,GAAG,IAAIC,IAAI,CAAC,CAAC,CAACC,WAAW,CAAC,CAAC;EAChD,MAAMC,eAAe,GAAGP,mBAAmB,CAAC,CAAC;EAE7C,MAAMQ,KAAwB,GAAG;IAC7B,GAAGP,aAAa;IAChBQ,MAAM,EAAEf,gBAAgB;IACxB;AACR;AACA;IACQgB,OAAO,EAAEd,OAAO,CAACQ,eAAe,CAAC;IACjCO,UAAU,EAAEf,OAAO,CAACQ,eAAe,CAAC;IACpCQ,OAAO,EAAEjB,WAAW,CAACY,eAAe,CAAE;IACtCM,UAAU,EAAElB,WAAW,CAACY,eAAe,CAAC;IACxCO,gBAAgB,EAAElB,OAAO,CAACK,aAAa,CAACa,gBAAgB,EAAEV,eAAe,CAAC;IAC1EW,gBAAgB,EAAEpB,WAAW,CAACM,aAAa,CAACc,gBAAgB,EAAER,eAAe,CAAC;IAC9ES,eAAe,EAAEpB,OAAO,CAACQ,eAAe,CAAC;IACzCa,eAAe,EAAEtB,WAAW,CAACY,eAAe,CAAC;IAE7C;AACR;AACA;IACQW,eAAe,EAAEtB,OAAO,CAACQ,eAAe,CAAC;IACzCe,kBAAkB,EAAEvB,OAAO,CAACQ,eAAe,CAAC;IAC5CgB,eAAe,EAAEzB,WAAW,CAACY,eAAe,CAAE;IAC9Cc,kBAAkB,EAAE1B,WAAW,CAACY,eAAe,CAAC;IAChDe,wBAAwB,EAAE1B,OAAO,CAACK,aAAa,CAACqB,wBAAwB,EAAElB,eAAe,CAAC;IAC1FmB,wBAAwB,EAAE5B,WAAW,CACjCM,aAAa,CAACsB,wBAAwB,EACtChB,eACJ,CAAC;IACDiB,uBAAuB,EAAE5B,OAAO,CAACQ,eAAe,CAAC;IACjDqB,uBAAuB,EAAE9B,WAAW,CAACY,eAAe,CAAC;IACrDL;EACJ,CAAC;EAED,OAAO;IACHM;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["referenceFieldsMapping","STATUS_PUBLISHED","getIdentity","getDate","createRepublishEntryData","model","context","getSecurityIdentity","originalEntry","values","validateEntries","currentDateTime","Date","toISOString","currentIdentity","entry","status","savedOn","modifiedOn","savedBy","modifiedBy","firstPublishedOn","firstPublishedBy","lastPublishedOn","lastPublishedBy","revisionSavedOn","revisionModifiedOn","revisionSavedBy","revisionModifiedBy","revisionFirstPublishedOn","revisionFirstPublishedBy","revisionLastPublishedOn","revisionLastPublishedBy","live","version"],"sources":["createRepublishEntryData.ts"],"sourcesContent":["import type { CmsContext, CmsEntry, CmsEntryValues, CmsModel } from \"~/types/index.js\";\nimport { referenceFieldsMapping } from \"~/crud/contentEntry/referenceFieldsMapping.js\";\nimport { STATUS_PUBLISHED } from \"./statuses.js\";\nimport { getIdentity } from \"~/utils/identity.js\";\nimport { getDate } from \"~/utils/date.js\";\nimport type { SecurityIdentity } from \"@webiny/api-core/types/security.js\";\n\ntype CreateRepublishEntryDataParams<TValues extends CmsEntryValues = CmsEntryValues> = {\n model: CmsModel;\n context: CmsContext;\n getIdentity: () => SecurityIdentity;\n originalEntry: CmsEntry<TValues>;\n};\n\ninterface ICreateRepublishEntryDataResponse<TValues extends CmsEntryValues = CmsEntryValues> {\n entry: CmsEntry<TValues>;\n}\n\nexport const createRepublishEntryData = async <TValues extends CmsEntryValues = CmsEntryValues>({\n model,\n context,\n getIdentity: getSecurityIdentity,\n originalEntry\n}: CreateRepublishEntryDataParams<TValues>): Promise<\n ICreateRepublishEntryDataResponse<TValues>\n> => {\n const values = await referenceFieldsMapping<TValues>({\n context,\n model,\n values: originalEntry.values,\n validateEntries: false\n });\n\n const currentDateTime = new Date().toISOString();\n const currentIdentity = getSecurityIdentity();\n\n const entry: CmsEntry<TValues> = {\n ...originalEntry,\n status: STATUS_PUBLISHED,\n /**\n * Entry-level meta fields. 👇\n */\n savedOn: getDate(currentDateTime),\n modifiedOn: getDate(currentDateTime),\n savedBy: getIdentity(currentIdentity)!,\n modifiedBy: getIdentity(currentIdentity),\n firstPublishedOn: getDate(originalEntry.firstPublishedOn, currentDateTime),\n firstPublishedBy: getIdentity(originalEntry.firstPublishedBy, currentIdentity),\n lastPublishedOn: getDate(currentDateTime),\n lastPublishedBy: getIdentity(currentIdentity),\n\n /**\n * Revision-level meta fields. 👇\n */\n revisionSavedOn: getDate(currentDateTime),\n revisionModifiedOn: getDate(currentDateTime),\n revisionSavedBy: getIdentity(currentIdentity)!,\n revisionModifiedBy: getIdentity(currentIdentity),\n revisionFirstPublishedOn: getDate(originalEntry.revisionFirstPublishedOn, currentDateTime),\n revisionFirstPublishedBy: getIdentity(\n originalEntry.revisionFirstPublishedBy,\n currentIdentity\n ),\n revisionLastPublishedOn: getDate(currentDateTime),\n revisionLastPublishedBy: getIdentity(currentIdentity),\n values,\n\n live: {\n version: originalEntry.version\n }\n };\n\n return {\n entry\n };\n};\n"],"mappings":"AACA,SAASA,sBAAsB;AAC/B,SAASC,gBAAgB;AACzB,SAASC,WAAW;AACpB,SAASC,OAAO;AAchB,O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ACjCM,aAAa,CAACsB,wBAAwB,EACtChB,eACJ,CAAC;IACDiB,uBAAuB,EAAE5B,OAAO,CAACQ,eAAe,CAAC;IACjDqB,uBAAuB,EAAE9B,WAAW,CAACY,eAAe,CAAC;IACrDL,MAAM;IAENwB,IAAI,EAAE;MACFC,OAAO,EAAE1B,aAAa,CAAC0B;IAC3B;EACJ,CAAC;EAED,OAAO;IACHnB;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
@@ -23,7 +23,8 @@ export const createUnpublishEntryData = async ({
23
23
  revisionSavedOn: getDate(currentDateTime),
24
24
  revisionModifiedOn: getDate(currentDateTime),
25
25
  revisionSavedBy: getIdentity(currentIdentity),
26
- revisionModifiedBy: getIdentity(currentIdentity)
26
+ revisionModifiedBy: getIdentity(currentIdentity),
27
+ live: null
27
28
  };
28
29
  return {
29
30
  entry
@@ -1 +1 @@
1
- {"version":3,"names":["STATUS_UNPUBLISHED","getIdentity","getDate","createUnpublishEntryData","getSecurityIdentity","originalEntry","currentDateTime","Date","toISOString","currentIdentity","entry","status","savedOn","modifiedOn","savedBy","modifiedBy","revisionSavedOn","revisionModifiedOn","revisionSavedBy","revisionModifiedBy"],"sources":["createUnpublishEntryData.ts"],"sourcesContent":["import type { CmsEntry, CmsEntryValues } from \"~/types/index.js\";\nimport { STATUS_UNPUBLISHED } from \"./statuses.js\";\nimport { getIdentity } from \"~/utils/identity.js\";\nimport { getDate } from \"~/utils/date.js\";\nimport type { SecurityIdentity } from \"@webiny/api-core/types/security.js\";\n\ninterface CreateRepublishEntryDataParams<TValues extends CmsEntryValues = CmsEntryValues> {\n getIdentity: () => SecurityIdentity;\n originalEntry: CmsEntry<TValues>;\n}\n\ninterface ICreateUnpublishEntryDataResponse<TValues extends CmsEntryValues = CmsEntryValues> {\n entry: CmsEntry<TValues>;\n}\n\nexport const createUnpublishEntryData = async <TValues extends CmsEntryValues = CmsEntryValues>({\n getIdentity: getSecurityIdentity,\n originalEntry\n}: CreateRepublishEntryDataParams<TValues>): Promise<\n ICreateUnpublishEntryDataResponse<TValues>\n> => {\n const currentDateTime = new Date().toISOString();\n const currentIdentity = getSecurityIdentity();\n\n const entry: CmsEntry<TValues> = {\n ...originalEntry,\n status: STATUS_UNPUBLISHED,\n\n /**\n * Entry-level meta fields. 👇\n */\n savedOn: getDate(currentDateTime),\n modifiedOn: getDate(currentDateTime),\n savedBy: getIdentity(currentIdentity),\n modifiedBy: getIdentity(currentIdentity),\n\n /**\n * Revision-level meta fields. 👇\n */\n revisionSavedOn: getDate(currentDateTime),\n revisionModifiedOn: getDate(currentDateTime),\n revisionSavedBy: getIdentity(currentIdentity),\n revisionModifiedBy: getIdentity(currentIdentity)\n };\n\n return {\n entry\n };\n};\n"],"mappings":"AACA,SAASA,kBAAkB;AAC3B,SAASC,WAAW;AACpB,SAASC,OAAO;AAYhB,OAAO,MAAMC,wBAAwB,GAAG,MAAAA,CAAwD;EAC5FF,WAAW,EAAEG,mBAAmB;EAChCC;AACqC,CAAC,KAErC;EACD,MAAMC,eAAe,GAAG,IAAIC,IAAI,CAAC,CAAC,CAACC,WAAW,CAAC,CAAC;EAChD,MAAMC,eAAe,GAAGL,mBAAmB,CAAC,CAAC;EAE7C,MAAMM,KAAwB,GAAG;IAC7B,GAAGL,aAAa;IAChBM,MAAM,EAAEX,kBAAkB;IAE1B;AACR;AACA;IACQY,OAAO,EAAEV,OAAO,CAACI,eAAe,CAAC;IACjCO,UAAU,EAAEX,OAAO,CAACI,eAAe,CAAC;IACpCQ,OAAO,EAAEb,WAAW,CAACQ,eAAe,CAAC;IACrCM,UAAU,EAAEd,WAAW,CAACQ,eAAe,CAAC;IAExC;AACR;AACA;IACQO,eAAe,EAAEd,OAAO,CAACI,eAAe,CAAC;IACzCW,kBAAkB,EAAEf,OAAO,CAACI,eAAe,CAAC;IAC5CY,eAAe,EAAEjB,WAAW,CAACQ,eAAe,CAAC;IAC7CU,kBAAkB,EAAElB,WAAW,CAACQ,eAAe;EACnD,CAAC;EAED,OAAO;IACHC;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["STATUS_UNPUBLISHED","getIdentity","getDate","createUnpublishEntryData","getSecurityIdentity","originalEntry","currentDateTime","Date","toISOString","currentIdentity","entry","status","savedOn","modifiedOn","savedBy","modifiedBy","revisionSavedOn","revisionModifiedOn","revisionSavedBy","revisionModifiedBy","live"],"sources":["createUnpublishEntryData.ts"],"sourcesContent":["import type { CmsEntry, CmsEntryValues } from \"~/types/index.js\";\nimport { STATUS_UNPUBLISHED } from \"./statuses.js\";\nimport { getIdentity } from \"~/utils/identity.js\";\nimport { getDate } from \"~/utils/date.js\";\nimport type { SecurityIdentity } from \"@webiny/api-core/types/security.js\";\n\ninterface CreateRepublishEntryDataParams<TValues extends CmsEntryValues = CmsEntryValues> {\n getIdentity: () => SecurityIdentity;\n originalEntry: CmsEntry<TValues>;\n}\n\ninterface ICreateUnpublishEntryDataResponse<TValues extends CmsEntryValues = CmsEntryValues> {\n entry: CmsEntry<TValues>;\n}\n\nexport const createUnpublishEntryData = async <TValues extends CmsEntryValues = CmsEntryValues>({\n getIdentity: getSecurityIdentity,\n originalEntry\n}: CreateRepublishEntryDataParams<TValues>): Promise<\n ICreateUnpublishEntryDataResponse<TValues>\n> => {\n const currentDateTime = new Date().toISOString();\n const currentIdentity = getSecurityIdentity();\n\n const entry: CmsEntry<TValues> = {\n ...originalEntry,\n status: STATUS_UNPUBLISHED,\n\n /**\n * Entry-level meta fields. 👇\n */\n savedOn: getDate(currentDateTime),\n modifiedOn: getDate(currentDateTime),\n savedBy: getIdentity(currentIdentity),\n modifiedBy: getIdentity(currentIdentity),\n\n /**\n * Revision-level meta fields. 👇\n */\n revisionSavedOn: getDate(currentDateTime),\n revisionModifiedOn: getDate(currentDateTime),\n revisionSavedBy: getIdentity(currentIdentity),\n revisionModifiedBy: getIdentity(currentIdentity),\n live: null\n };\n\n return {\n entry\n };\n};\n"],"mappings":"AACA,SAASA,kBAAkB;AAC3B,SAASC,WAAW;AACpB,SAASC,OAAO;AAYhB,OAAO,MAAMC,wBAAwB,GAAG,MAAAA,CAAwD;EAC5FF,WAAW,EAAEG,mBAAmB;EAChCC;AACqC,CAAC,KAErC;EACD,MAAMC,eAAe,GAAG,IAAIC,IAAI,CAAC,CAAC,CAACC,WAAW,CAAC,CAAC;EAChD,MAAMC,eAAe,GAAGL,mBAAmB,CAAC,CAAC;EAE7C,MAAMM,KAAwB,GAAG;IAC7B,GAAGL,aAAa;IAChBM,MAAM,EAAEX,kBAAkB;IAE1B;AACR;AACA;IACQY,OAAO,EAAEV,OAAO,CAACI,eAAe,CAAC;IACjCO,UAAU,EAAEX,OAAO,CAACI,eAAe,CAAC;IACpCQ,OAAO,EAAEb,WAAW,CAACQ,eAAe,CAAC;IACrCM,UAAU,EAAEd,WAAW,CAACQ,eAAe,CAAC;IAExC;AACR;AACA;IACQO,eAAe,EAAEd,OAAO,CAACI,eAAe,CAAC;IACzCW,kBAAkB,EAAEf,OAAO,CAACI,eAAe,CAAC;IAC5CY,eAAe,EAAEjB,WAAW,CAACQ,eAAe,CAAC;IAC7CU,kBAAkB,EAAElB,WAAW,CAACQ,eAAe,CAAC;IAChDW,IAAI,EAAE;EACV,CAAC;EAED,OAAO;IACHV;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
@@ -5,7 +5,7 @@ import { referenceFieldsMapping } from "../referenceFieldsMapping.js";
5
5
  import { mapAndCleanUpdatedInputData } from "./mapAndCleanUpdatedInputData.js";
6
6
  import lodashMerge from "lodash/merge.js";
7
7
  import { removeNullValues, removeUndefinedValues } from "@webiny/utils";
8
- import { getState } from "./state.js";
8
+ import { getSystem } from "./system.js";
9
9
  export const createUpdateEntryData = async ({
10
10
  model,
11
11
  rawInput,
@@ -94,10 +94,11 @@ export const createUpdateEntryData = async ({
94
94
  values,
95
95
  meta,
96
96
  status: transformEntryStatus(originalEntry.status),
97
- state: getState({
97
+ system: getSystem({
98
98
  input: rawInput,
99
99
  original: originalEntry
100
- })
100
+ }),
101
+ live: originalEntry.live
101
102
  };
102
103
  const folderId = rawInput.wbyAco_location?.folderId;
103
104
  if (folderId) {
@@ -1 +1 @@
1
- {"version":3,"names":["getDate","getIdentity","validateModelEntryDataOrThrow","referenceFieldsMapping","mapAndCleanUpdatedInputData","lodashMerge","removeNullValues","removeUndefinedValues","getState","createUpdateEntryData","model","rawInput","options","context","metaInput","getSecurityIdentity","originalEntry","cleanedValues","values","entry","skipValidators","mergedValues","validateEntries","meta","createEntryMeta","currentIdentity","currentDateTime","Date","revisionCreatedOn","revisionModifiedOn","revisionSavedOn","revisionDeletedOn","revisionRestoredOn","revisionFirstPublishedOn","revisionLastPublishedOn","revisionCreatedBy","revisionModifiedBy","revisionSavedBy","revisionDeletedBy","revisionRestoredBy","revisionFirstPublishedBy","revisionLastPublishedBy","createdOn","savedOn","modifiedOn","deletedOn","restoredOn","firstPublishedOn","lastPublishedOn","createdBy","savedBy","modifiedBy","deletedBy","restoredBy","firstPublishedBy","lastPublishedBy","status","transformEntryStatus","state","input","original","folderId","wbyAco_location","location","structuredClone","allowedEntryStatus","includes"],"sources":["createUpdateEntryData.ts"],"sourcesContent":["import type {\n CmsContext,\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 \"../entryDataValidation.js\";\nimport { referenceFieldsMapping } from \"../referenceFieldsMapping.js\";\nimport { mapAndCleanUpdatedInputData } from \"./mapAndCleanUpdatedInputData.js\";\nimport lodashMerge from \"lodash/merge.js\";\nimport { removeNullValues, removeUndefinedValues } from \"@webiny/utils\";\nimport { getState } from \"./state.js\";\nimport type { SecurityIdentity } from \"@webiny/api-core/types/security.js\";\nimport type { Tenant } from \"@webiny/api-core/types/tenancy.js\";\n\ninterface UpdateEntryFromDataParams<TValues extends CmsEntryValues = CmsEntryValues> {\n metaInput?: Record<string, any>;\n model: CmsModel;\n rawInput: UpdateCmsEntryInput<TValues>;\n options?: UpdateCmsEntryOptionsInput;\n context: CmsContext;\n getIdentity: () => SecurityIdentity;\n getTenant: () => Tenant;\n originalEntry: CmsEntry<TValues>;\n}\n\ninterface UpdateEntryDataResponse<TValues extends CmsEntryValues = CmsEntryValues> {\n entry: CmsEntry<TValues>;\n input: UpdateCmsEntryInput<TValues>;\n}\n\nexport const createUpdateEntryData = async <TValues extends CmsEntryValues = CmsEntryValues>({\n model,\n rawInput,\n options,\n context,\n metaInput,\n getIdentity: getSecurityIdentity,\n originalEntry\n}: UpdateEntryFromDataParams<TValues>): Promise<UpdateEntryDataResponse<TValues>> => {\n /**\n * Make sure we only work with fields that are defined in the model.\n */\n const cleanedValues = mapAndCleanUpdatedInputData<TValues>(\n model,\n rawInput?.values || ({} as TValues)\n );\n\n await validateModelEntryDataOrThrow({\n context,\n model,\n values: cleanedValues,\n entry: originalEntry,\n skipValidators: options?.skipValidators\n });\n\n const mergedValues: TValues = {\n /**\n * Existing values from the database, transformed back to original, of course.\n */\n ...originalEntry.values,\n /**\n * Add new values.\n */\n ...cleanedValues\n };\n\n const values = await referenceFieldsMapping<TValues>({\n context,\n model,\n values: mergedValues,\n validateEntries: false\n });\n\n /**\n * If users wants to remove a key from meta values, they need to send meta key with the null value.\n */\n const meta = createEntryMeta(metaInput, originalEntry.meta);\n\n const currentIdentity = getSecurityIdentity();\n const currentDateTime = new Date();\n\n /**\n * We always send the full entry to the hooks and storage operations update.\n */\n const entry: CmsEntry<TValues> = {\n ...originalEntry,\n\n /**\n * Revision-level meta fields. 👇\n */\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\n /**\n * Entry-level meta fields. 👇\n * If required, within storage operations, these entry-level updates\n * will be propagated to the latest revision too.\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(rawInput.firstPublishedBy, originalEntry.firstPublishedBy),\n lastPublishedBy: getIdentity(rawInput.lastPublishedBy, originalEntry.lastPublishedBy),\n\n values,\n meta,\n status: transformEntryStatus(originalEntry.status),\n state: getState({\n input: rawInput,\n original: originalEntry\n })\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/**\n * This method takes original entry meta and new input.\n * When new meta is merged onto the existing one, everything that has undefined or null value is removed.\n */\nconst createEntryMeta = (input?: Record<string, any>, original?: Record<string, any>) => {\n const meta = lodashMerge(original || {}, input || {});\n return removeUndefinedValues(removeNullValues(meta));\n};\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"],"mappings":"AASA,SAASA,OAAO;AAChB,SAASC,WAAW;AACpB,SAASC,6BAA6B;AACtC,SAASC,sBAAsB;AAC/B,SAASC,2BAA2B;AACpC,OAAOC,WAAW,MAAM,iBAAiB;AACzC,SAASC,gBAAgB,EAAEC,qBAAqB,QAAQ,eAAe;AACvE,SAASC,QAAQ;AAoBjB,OAAO,MAAMC,qBAAqB,GAAG,MAAAA,CAAwD;EACzFC,KAAK;EACLC,QAAQ;EACRC,OAAO;EACPC,OAAO;EACPC,SAAS;EACTb,WAAW,EAAEc,mBAAmB;EAChCC;AACgC,CAAC,KAAgD;EACjF;AACJ;AACA;EACI,MAAMC,aAAa,GAAGb,2BAA2B,CAC7CM,KAAK,EACLC,QAAQ,EAAEO,MAAM,IAAK,CAAC,CAC1B,CAAC;EAED,MAAMhB,6BAA6B,CAAC;IAChCW,OAAO;IACPH,KAAK;IACLQ,MAAM,EAAED,aAAa;IACrBE,KAAK,EAAEH,aAAa;IACpBI,cAAc,EAAER,OAAO,EAAEQ;EAC7B,CAAC,CAAC;EAEF,MAAMC,YAAqB,GAAG;IAC1B;AACR;AACA;IACQ,GAAGL,aAAa,CAACE,MAAM;IAC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AAIA,MAAM,GAAsB,OAAO;AACrF,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["getDate","getIdentity","validateModelEntryDataOrThrow","referenceFieldsMapping","mapAndCleanUpdatedInputData","lodashMerge","removeNullValues","removeUndefinedValues","getSystem","createUpdateEntryData","model","rawInput","options","context","metaInput","getSecurityIdentity","originalEntry","cleanedValues","values","entry","skipValidators","mergedValues","validateEntries","meta","createEntryMeta","currentIdentity","currentDateTime","Date","revisionCreatedOn","revisionModifiedOn","revisionSavedOn","revisionDeletedOn","revisionRestoredOn","revisionFirstPublishedOn","revisionLastPublishedOn","revisionCreatedBy","revisionModifiedBy","revisionSavedBy","revisionDeletedBy","revisionRestoredBy","revisionFirstPublishedBy","revisionLastPublishedBy","createdOn","savedOn","modifiedOn","deletedOn","restoredOn","firstPublishedOn","lastPublishedOn","createdBy","savedBy","modifiedBy","deletedBy","restoredBy","firstPublishedBy","lastPublishedBy","status","transformEntryStatus","system","input","original","live","folderId","wbyAco_location","location","structuredClone","allowedEntryStatus","includes"],"sources":["createUpdateEntryData.ts"],"sourcesContent":["import type {\n CmsContext,\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 \"../entryDataValidation.js\";\nimport { referenceFieldsMapping } from \"../referenceFieldsMapping.js\";\nimport { mapAndCleanUpdatedInputData } from \"./mapAndCleanUpdatedInputData.js\";\nimport lodashMerge from \"lodash/merge.js\";\nimport { removeNullValues, removeUndefinedValues } from \"@webiny/utils\";\nimport { getSystem } from \"./system.js\";\nimport type { SecurityIdentity } from \"@webiny/api-core/types/security.js\";\nimport type { Tenant } from \"@webiny/api-core/types/tenancy.js\";\n\ninterface UpdateEntryFromDataParams<TValues extends CmsEntryValues = CmsEntryValues> {\n metaInput?: Record<string, any>;\n model: CmsModel;\n rawInput: UpdateCmsEntryInput<TValues>;\n options?: UpdateCmsEntryOptionsInput;\n context: CmsContext;\n getIdentity: () => SecurityIdentity;\n getTenant: () => Tenant;\n originalEntry: CmsEntry<TValues>;\n}\n\ninterface UpdateEntryDataResponse<TValues extends CmsEntryValues = CmsEntryValues> {\n entry: CmsEntry<TValues>;\n input: UpdateCmsEntryInput<TValues>;\n}\n\nexport const createUpdateEntryData = async <TValues extends CmsEntryValues = CmsEntryValues>({\n model,\n rawInput,\n options,\n context,\n metaInput,\n getIdentity: getSecurityIdentity,\n originalEntry\n}: UpdateEntryFromDataParams<TValues>): Promise<UpdateEntryDataResponse<TValues>> => {\n /**\n * Make sure we only work with fields that are defined in the model.\n */\n const cleanedValues = mapAndCleanUpdatedInputData<TValues>(\n model,\n rawInput?.values || ({} as TValues)\n );\n\n await validateModelEntryDataOrThrow({\n context,\n model,\n values: cleanedValues,\n entry: originalEntry,\n skipValidators: options?.skipValidators\n });\n\n const mergedValues: TValues = {\n /**\n * Existing values from the database, transformed back to original, of course.\n */\n ...originalEntry.values,\n /**\n * Add new values.\n */\n ...cleanedValues\n };\n\n const values = await referenceFieldsMapping<TValues>({\n context,\n model,\n values: mergedValues,\n validateEntries: false\n });\n\n /**\n * If users wants to remove a key from meta values, they need to send meta key with the null value.\n */\n const meta = createEntryMeta(metaInput, originalEntry.meta);\n\n const currentIdentity = getSecurityIdentity();\n const currentDateTime = new Date();\n\n /**\n * We always send the full entry to the hooks and storage operations update.\n */\n const entry: CmsEntry<TValues> = {\n ...originalEntry,\n\n /**\n * Revision-level meta fields. 👇\n */\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\n /**\n * Entry-level meta fields. 👇\n * If required, within storage operations, these entry-level updates\n * will be propagated to the latest revision too.\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(rawInput.firstPublishedBy, originalEntry.firstPublishedBy),\n lastPublishedBy: getIdentity(rawInput.lastPublishedBy, originalEntry.lastPublishedBy),\n\n values,\n meta,\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/**\n * This method takes original entry meta and new input.\n * When new meta is merged onto the existing one, everything that has undefined or null value is removed.\n */\nconst createEntryMeta = (input?: Record<string, any>, original?: Record<string, any>) => {\n const meta = lodashMerge(original || {}, input || {});\n return removeUndefinedValues(removeNullValues(meta));\n};\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"],"mappings":"AASA,SAASA,OAAO;AAChB,SAASC,WAAW;AACpB,SAASC,6BAA6B;AACtC,SAASC,sBAAsB;AAC/B,SAASC,2BAA2B;AACpC,OAAOC,WAAW,MAAM,iBAAiB;AACzC,SAASC,gBAAgB,EAAEC,qBAAqB,QAAQ,eAAe;AACvE,SAASC,SAAS;AAoBlB,OAAO,MAAMC,qBAAqB,GAAG,MAAAA,CAAwD;EACzFC,KAAK;EACLC,QAAQ;EACRC,OAAO;EACPC,OAAO;EACPC,SAAS;EACTb,WAAW,EAAEc,mBAAmB;EAChCC;AACgC,CAAC,KAAgD;EACjF;AACJ;AACA;EACI,MAAMC,aAAa,GAAGb,2BAA2B,CAC7CM,KAAK,EACLC,QAAQ,EAAEO,MAAM,IAAK,CAAC,CAC1B,CAAC;EAED,MAAMhB,6BAA6B,CAAC;IAChCW,OAAO;IACPH,KAAK;IACLQ,MAAM,EAAED,aAAa;IACrBE,KAAK,EAAEH,aAAa;IACpBI,cAAc,EAAER,OAAO,EAAEQ;EAC7B,CAAC,CAAC;EAEF,MAAMC,YAAqB,GAAG;IAC1B;AACR;AACA;IACQ,GAAGL,aAAa,CAACE,MAAM;IACvB;AACR;AACA;IACQ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Q,CAACX,MAAM,CAAC,GAAIA,MAAM,GAAsB,OAAO;AACrF,CAAC","ignoreList":[]}
@@ -0,0 +1,10 @@
1
+ import type { CmsEntry, ICmsEntrySystem } from "../../../types/index.js";
2
+ interface IInputWithPossibleSystem {
3
+ system: Partial<ICmsEntrySystem>;
4
+ }
5
+ interface IParams {
6
+ input: Partial<IInputWithPossibleSystem>;
7
+ original?: CmsEntry | null;
8
+ }
9
+ export declare const getSystem: ({ input, original }: IParams) => ICmsEntrySystem | undefined;
10
+ export {};
@@ -0,0 +1,14 @@
1
+ export const getSystem = ({
2
+ input,
3
+ original
4
+ }) => {
5
+ if (!input.system) {
6
+ return original?.system;
7
+ }
8
+ return {
9
+ ...original?.system,
10
+ ...input.system
11
+ };
12
+ };
13
+
14
+ //# sourceMappingURL=system.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getSystem","input","original","system"],"sources":["system.ts"],"sourcesContent":["import type { CmsEntry, ICmsEntrySystem } from \"~/types/index.js\";\n\ninterface IInputWithPossibleSystem {\n system: Partial<ICmsEntrySystem>;\n}\ninterface IParams {\n input: Partial<IInputWithPossibleSystem>;\n original?: CmsEntry | null;\n}\n\nexport const getSystem = ({ input, original }: IParams): ICmsEntrySystem | undefined => {\n if (!input.system) {\n return original?.system;\n }\n return {\n ...original?.system,\n ...input.system\n };\n};\n"],"mappings":"AAUA,OAAO,MAAMA,SAAS,GAAGA,CAAC;EAAEC,KAAK;EAAEC;AAAkB,CAAC,KAAkC;EACpF,IAAI,CAACD,KAAK,CAACE,MAAM,EAAE;IACf,OAAOD,QAAQ,EAAEC,MAAM;EAC3B;EACA,OAAO;IACH,GAAGD,QAAQ,EAAEC,MAAM;IACnB,GAAGF,KAAK,CAACE;EACb,CAAC;AACL,CAAC","ignoreList":[]}
@@ -123,25 +123,27 @@ const createSchema = plugins => {
123
123
  error: CmsError
124
124
  }
125
125
 
126
- enum CmsEntryStateType {
127
- pending
128
- inReview
129
- rejected
130
- approved
126
+ type CmsEntrySystem {
127
+ _empty: String
131
128
  }
132
129
 
133
- type CmsEntryState {
134
- workflowId: String
135
- stepId: ID
136
- stepName: String
137
- state: CmsEntryStateType
130
+ type CmsEntryLive {
131
+ version: Int!
138
132
  }
139
133
 
140
- input ListWhereInputCmsEntryState {
141
- workflowId: String
142
- stepId: ID
143
- state: CmsEntryStateType
144
- stepName: String
134
+ input CmsEntryLiveWhereInput {
135
+ version: Int
136
+ version_gt: Int
137
+ version_gte: Int
138
+ version_lt: Int
139
+ version_lte: Int
140
+ version_not: Int
141
+ version_in: [Int!]
142
+ version_not_in: [Int!]
143
+ }
144
+
145
+ input ListWhereInputCmsEntrySystem {
146
+ _empty: String
145
147
  }
146
148
  `,
147
149
  resolvers: {}
@@ -1 +1 @@
1
- {"version":3,"names":["createCmsGraphQLSchemaPlugin","GraphQLSchemaPlugin","ContextPlugin","camelCase","createSkipValidatorEnum","plugins","validators","byType","reduce","collection","validator","name","includes","push","length","join","createSchema","skipValidatorEnum","cmsPlugin","typeDefs","resolvers","corePlugin","schema","createBaseSchema","plugin","context","register"],"sources":["baseSchema.ts"],"sourcesContent":["import type { CmsContext, CmsModelFieldValidatorPlugin } from \"~/types/index.js\";\nimport { createCmsGraphQLSchemaPlugin } from \"~/plugins/index.js\";\nimport type { IGraphQLSchemaPlugin } from \"@webiny/handler-graphql\";\nimport { GraphQLSchemaPlugin } from \"@webiny/handler-graphql\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\nimport { ContextPlugin } from \"@webiny/api\";\nimport camelCase from \"lodash/camelCase.js\";\n\nconst createSkipValidatorEnum = (plugins: PluginsContainer) => {\n const validators = plugins\n .byType<CmsModelFieldValidatorPlugin>(\"cms-model-field-validator\")\n .reduce<string[]>((collection, validator) => {\n const name = camelCase(validator.validator.name);\n if (collection.includes(name)) {\n return collection;\n }\n collection.push(name);\n return collection;\n }, []);\n\n if (validators.length === 0) {\n validators.push(\"_empty\");\n }\n return /* GraphQL */ `\n enum SkipValidatorEnum {\n ${validators.join(\"\\n\")}\n }\n `;\n};\n\nconst createSchema = (plugins: PluginsContainer): IGraphQLSchemaPlugin<CmsContext>[] => {\n const skipValidatorEnum = createSkipValidatorEnum(plugins);\n\n const cmsPlugin = createCmsGraphQLSchemaPlugin({\n typeDefs: /* GraphQL */ `\n type CmsIdentity {\n id: String\n displayName: String\n type: String\n }\n\n type CmsError {\n code: String\n message: String\n data: JSON\n stack: String\n }\n\n type CmsCursors {\n next: String\n previous: String\n }\n\n type CmsListMeta {\n cursor: String\n hasMoreItems: Boolean\n totalCount: Int\n }\n\n input CmsDeleteEntryOptions {\n # force delete an entry that might have some records left behind in the database\n # see CmsDeleteEntryOptions in types.ts\n force: Boolean\n # permanently delete an entry without moving it to the bin\n permanently: Boolean\n }\n\n type CmsDeleteResponse {\n data: Boolean\n error: CmsError\n }\n\n type CmsDeleteMultipleDataResponse {\n id: ID!\n }\n\n type CmsDeleteMultipleResponse {\n data: [CmsDeleteMultipleDataResponse!]\n error: CmsError\n }\n\n type CmsBooleanResponse {\n data: Boolean\n error: CmsError\n }\n\n # Advanced Content Organization\n type WbyAcoLocation {\n folderId: ID\n }\n\n input WbyAcoLocationInput {\n folderId: ID!\n }\n\n input WbyAcoLocationWhereInput {\n folderId: ID\n folderId_in: [ID!]\n folderId_not: ID\n folderId_not_in: [ID!]\n }\n\n ${skipValidatorEnum}\n\n input CreateCmsEntryOptionsInput {\n skipValidators: [SkipValidatorEnum!]\n }\n\n input CreateRevisionCmsEntryOptionsInput {\n skipValidators: [SkipValidatorEnum!]\n }\n\n input UpdateCmsEntryOptionsInput {\n skipValidators: [SkipValidatorEnum!]\n }\n\n input CmsIdentityInput {\n id: String!\n displayName: String!\n type: String!\n }\n\n type CmsEntryValidationResponseData {\n error: String!\n id: String!\n fieldId: String!\n parents: [String!]!\n }\n\n type CmsEntryValidationResponse {\n data: [CmsEntryValidationResponseData!]\n error: CmsError\n }\n\n enum CmsEntryStateType {\n pending\n inReview\n rejected\n approved\n }\n\n type CmsEntryState {\n workflowId: String\n stepId: ID\n stepName: String\n state: CmsEntryStateType\n }\n\n input ListWhereInputCmsEntryState {\n workflowId: String\n stepId: ID\n state: CmsEntryStateType\n stepName: String\n }\n `,\n resolvers: {}\n });\n cmsPlugin.name = \"headless-cms.graphql.schema.base\";\n const corePlugin = new GraphQLSchemaPlugin<CmsContext>({\n typeDefs: cmsPlugin.schema.typeDefs,\n resolvers: cmsPlugin.schema.resolvers\n });\n corePlugin.name = \"headless-cms.graphql.core.schema.base\";\n /**\n * Due to splitting of CMS and Core schema plugins, we must have both defined for CMS to work.\n */\n return [cmsPlugin, corePlugin];\n};\n\nexport const createBaseSchema = () => {\n const plugin = new ContextPlugin(async context => {\n context.plugins.register(...createSchema(context.plugins));\n });\n\n plugin.name = \"headless-cms.graphql.createBaseSchema\";\n\n return plugin;\n};\n"],"mappings":"AACA,SAASA,4BAA4B;AAErC,SAASC,mBAAmB,QAAQ,yBAAyB;AAE7D,SAASC,aAAa,QAAQ,aAAa;AAC3C,OAAOC,SAAS,MAAM,qBAAqB;AAE3C,MAAMC,uBAAuB,GAAIC,OAAyB,IAAK;EAC3D,MAAMC,UAAU,GAAGD,OAAO,CACrBE,MAAM,CAA+B,2BAA2B,CAAC,CACjEC,MAAM,CAAW,CAACC,UAAU,EAAEC,SAAS,KAAK;IACzC,MAAMC,IAAI,GAAGR,SAAS,CAACO,SAAS,CAACA,SAAS,CAACC,IAAI,CAAC;IAChD,IAAIF,UAAU,CAACG,QAAQ,CAACD,IAAI,CAAC,EAAE;MAC3B,OAAOF,UAAU;IACrB;IACAA,UAAU,CAACI,IAAI,CAACF,IAAI,CAAC;IACrB,OAAOF,UAAU;EACrB,CAAC,EAAE,EAAE,CAAC;EAEV,IAAIH,UAAU,CAACQ,MAAM,KAAK,CAAC,EAAE;IACzBR,UAAU,CAACO,IAAI,CAAC,QAAQ,CAAC;EAC7B;EACA,OAAO,aAAc;AACzB;AACA,aAAaP,UAAU,CAACS,IAAI,CAAC,IAAI,CAAC;AAClC;AACA,KAAK;AACL,CAAC;AAED,MAAMC,YAAY,GAAIX,OAAyB,IAAyC;EACpF,MAAMY,iBAAiB,GAAGb,uBAAuB,CAACC,OAAO,CAAC;EAE1D,MAAMa,SAAS,GAAGlB,4BAA4B,CAAC;IAC3CmB,QAAQ,EAAE,aAAc;AAChC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAcF,iBAAiB;AAC/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;IACDG,SAAS,EAAE,CAAC;EAChB,CAAC,CAAC;EACFF,SAAS,CAACP,IAAI,GAAG,kCAAkC;EACnD,MAAMU,UAAU,GAAG,IAAIpB,mBAAmB,CAAa;IACnDkB,QAAQ,EAAED,SAAS,CAACI,MAAM,CAACH,QAAQ;IACnCC,SAAS,EAAEF,SAAS,CAACI,MAAM,CAACF;EAChC,CAAC,CAAC;EACFC,UAAU,CAACV,IAAI,GAAG,uCAAuC;EACzD;AACJ;AACA;EACI,OAAO,CAACO,SAAS,EAAEG,UAAU,CAAC;AAClC,CAAC;AAED,OAAO,MAAME,gBAAgB,GAAGA,CAAA,KAAM;EAClC,MAAMC,MAAM,GAAG,IAAItB,aAAa,CAAC,MAAMuB,OAAO,IAAI;IAC9CA,OAAO,CAACpB,OAAO,CAACqB,QAAQ,CAAC,GAAGV,YAAY,CAACS,OAAO,CAACpB,OAAO,CAAC,CAAC;EAC9D,CAAC,CAAC;EAEFmB,MAAM,CAACb,IAAI,GAAG,uCAAuC;EAErD,OAAOa,MAAM;AACjB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["createCmsGraphQLSchemaPlugin","GraphQLSchemaPlugin","ContextPlugin","camelCase","createSkipValidatorEnum","plugins","validators","byType","reduce","collection","validator","name","includes","push","length","join","createSchema","skipValidatorEnum","cmsPlugin","typeDefs","resolvers","corePlugin","schema","createBaseSchema","plugin","context","register"],"sources":["baseSchema.ts"],"sourcesContent":["import type { CmsContext, CmsModelFieldValidatorPlugin } from \"~/types/index.js\";\nimport { createCmsGraphQLSchemaPlugin } from \"~/plugins/index.js\";\nimport type { IGraphQLSchemaPlugin } from \"@webiny/handler-graphql\";\nimport { GraphQLSchemaPlugin } from \"@webiny/handler-graphql\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\nimport { ContextPlugin } from \"@webiny/api\";\nimport camelCase from \"lodash/camelCase.js\";\n\nconst createSkipValidatorEnum = (plugins: PluginsContainer) => {\n const validators = plugins\n .byType<CmsModelFieldValidatorPlugin>(\"cms-model-field-validator\")\n .reduce<string[]>((collection, validator) => {\n const name = camelCase(validator.validator.name);\n if (collection.includes(name)) {\n return collection;\n }\n collection.push(name);\n return collection;\n }, []);\n\n if (validators.length === 0) {\n validators.push(\"_empty\");\n }\n return /* GraphQL */ `\n enum SkipValidatorEnum {\n ${validators.join(\"\\n\")}\n }\n `;\n};\n\nconst createSchema = (plugins: PluginsContainer): IGraphQLSchemaPlugin<CmsContext>[] => {\n const skipValidatorEnum = createSkipValidatorEnum(plugins);\n\n const cmsPlugin = createCmsGraphQLSchemaPlugin({\n typeDefs: /* GraphQL */ `\n type CmsIdentity {\n id: String\n displayName: String\n type: String\n }\n\n type CmsError {\n code: String\n message: String\n data: JSON\n stack: String\n }\n\n type CmsCursors {\n next: String\n previous: String\n }\n\n type CmsListMeta {\n cursor: String\n hasMoreItems: Boolean\n totalCount: Int\n }\n\n input CmsDeleteEntryOptions {\n # force delete an entry that might have some records left behind in the database\n # see CmsDeleteEntryOptions in types.ts\n force: Boolean\n # permanently delete an entry without moving it to the bin\n permanently: Boolean\n }\n\n type CmsDeleteResponse {\n data: Boolean\n error: CmsError\n }\n\n type CmsDeleteMultipleDataResponse {\n id: ID!\n }\n\n type CmsDeleteMultipleResponse {\n data: [CmsDeleteMultipleDataResponse!]\n error: CmsError\n }\n\n type CmsBooleanResponse {\n data: Boolean\n error: CmsError\n }\n\n # Advanced Content Organization\n type WbyAcoLocation {\n folderId: ID\n }\n\n input WbyAcoLocationInput {\n folderId: ID!\n }\n\n input WbyAcoLocationWhereInput {\n folderId: ID\n folderId_in: [ID!]\n folderId_not: ID\n folderId_not_in: [ID!]\n }\n\n ${skipValidatorEnum}\n\n input CreateCmsEntryOptionsInput {\n skipValidators: [SkipValidatorEnum!]\n }\n\n input CreateRevisionCmsEntryOptionsInput {\n skipValidators: [SkipValidatorEnum!]\n }\n\n input UpdateCmsEntryOptionsInput {\n skipValidators: [SkipValidatorEnum!]\n }\n\n input CmsIdentityInput {\n id: String!\n displayName: String!\n type: String!\n }\n\n type CmsEntryValidationResponseData {\n error: String!\n id: String!\n fieldId: String!\n parents: [String!]!\n }\n\n type CmsEntryValidationResponse {\n data: [CmsEntryValidationResponseData!]\n error: CmsError\n }\n\n type CmsEntrySystem {\n _empty: String\n }\n\n type CmsEntryLive {\n version: Int!\n }\n\n input CmsEntryLiveWhereInput {\n version: Int\n version_gt: Int\n version_gte: Int\n version_lt: Int\n version_lte: Int\n version_not: Int\n version_in: [Int!]\n version_not_in: [Int!]\n }\n\n input ListWhereInputCmsEntrySystem {\n _empty: String\n }\n `,\n resolvers: {}\n });\n cmsPlugin.name = \"headless-cms.graphql.schema.base\";\n const corePlugin = new GraphQLSchemaPlugin<CmsContext>({\n typeDefs: cmsPlugin.schema.typeDefs,\n resolvers: cmsPlugin.schema.resolvers\n });\n corePlugin.name = \"headless-cms.graphql.core.schema.base\";\n /**\n * Due to splitting of CMS and Core schema plugins, we must have both defined for CMS to work.\n */\n return [cmsPlugin, corePlugin];\n};\n\nexport const createBaseSchema = () => {\n const plugin = new ContextPlugin(async context => {\n context.plugins.register(...createSchema(context.plugins));\n });\n\n plugin.name = \"headless-cms.graphql.createBaseSchema\";\n\n return plugin;\n};\n"],"mappings":"AACA,SAASA,4BAA4B;AAErC,SAASC,mBAAmB,QAAQ,yBAAyB;AAE7D,SAASC,aAAa,QAAQ,aAAa;AAC3C,OAAOC,SAAS,MAAM,qBAAqB;AAE3C,MAAMC,uBAAuB,GAAIC,OAAyB,IAAK;EAC3D,MAAMC,UAAU,GAAGD,OAAO,CACrBE,MAAM,CAA+B,2BAA2B,CAAC,CACjEC,MAAM,CAAW,CAACC,UAAU,EAAEC,SAAS,KAAK;IACzC,MAAMC,IAAI,GAAGR,SAAS,CAACO,SAAS,CAACA,SAAS,CAACC,IAAI,CAAC;IAChD,IAAIF,UAAU,CAACG,QAAQ,CAACD,IAAI,CAAC,EAAE;MAC3B,OAAOF,UAAU;IACrB;IACAA,UAAU,CAACI,IAAI,CAACF,IAAI,CAAC;IACrB,OAAOF,UAAU;EACrB,CAAC,EAAE,EAAE,CAAC;EAEV,IAAIH,UAAU,CAACQ,MAAM,KAAK,CAAC,EAAE;IACzBR,UAAU,CAACO,IAAI,CAAC,QAAQ,CAAC;EAC7B;EACA,OAAO,aAAc;AACzB;AACA,aAAaP,UAAU,CAACS,IAAI,CAAC,IAAI,CAAC;AAClC;AACA,KAAK;AACL,CAAC;AAED,MAAMC,YAAY,GAAIX,OAAyB,IAAyC;EACpF,MAAMY,iBAAiB,GAAGb,uBAAuB,CAACC,OAAO,CAAC;EAE1D,MAAMa,SAAS,GAAGlB,4BAA4B,CAAC;IAC3CmB,QAAQ,EAAE,aAAc;AAChC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAcF,iBAAiB;AAC/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;IACDG,SAAS,EAAE,CAAC;EAChB,CAAC,CAAC;EACFF,SAAS,CAACP,IAAI,GAAG,kCAAkC;EACnD,MAAMU,UAAU,GAAG,IAAIpB,mBAAmB,CAAa;IACnDkB,QAAQ,EAAED,SAAS,CAACI,MAAM,CAACH,QAAQ;IACnCC,SAAS,EAAEF,SAAS,CAACI,MAAM,CAACF;EAChC,CAAC,CAAC;EACFC,UAAU,CAACV,IAAI,GAAG,uCAAuC;EACzD;AACJ;AACA;EACI,OAAO,CAACO,SAAS,EAAEG,UAAU,CAAC;AAClC,CAAC;AAED,OAAO,MAAME,gBAAgB,GAAGA,CAAA,KAAM;EAClC,MAAMC,MAAM,GAAG,IAAItB,aAAa,CAAC,MAAMuB,OAAO,IAAI;IAC9CA,OAAO,CAACpB,OAAO,CAACqB,QAAQ,CAAC,GAAGV,YAAY,CAACS,OAAO,CAACpB,OAAO,CAAC,CAAC;EAC9D,CAAC,CAAC;EAEFmB,MAAM,CAACb,IAAI,GAAG,uCAAuC;EAErD,OAAOa,MAAM;AACjB,CAAC","ignoreList":[]}
@@ -68,6 +68,7 @@ export const createManageSDL = ({
68
68
  ${onByMetaGqlFields}
69
69
  meta: ${singularName}Meta
70
70
  wbyAco_location: WbyAcoLocation
71
+ live: CmsEntryLive
71
72
 
72
73
  values: ${singularName}Values
73
74
  }
@@ -78,7 +79,7 @@ export const createManageSDL = ({
78
79
  locked: Boolean
79
80
 
80
81
  status: String
81
- state: CmsEntryState
82
+ system: CmsEntrySystem
82
83
  """
83
84
  CAUTION: this field is resolved by making an extra query to DB.
84
85
  RECOMMENDATION: Use it only with "get" queries (avoid in "list")
@@ -130,8 +131,9 @@ export const createManageSDL = ({
130
131
  input ${singularName}ListWhereInput {
131
132
  ${listFilterFieldsRender.baseFiltersAsString()}
132
133
 
133
- state: ListWhereInputCmsEntryState
134
+ system: ListWhereInputCmsEntrySystem
134
135
  wbyAco_location: WbyAcoLocationWhereInput
136
+ live: CmsEntryLiveWhereInput
135
137
 
136
138
  values: ${singularName}ListWhereInputValues
137
139
  AND: [${singularName}ListWhereInput!]
@@ -1 +1 @@
1
- {"version":3,"names":["renderListFilterFields","renderSortEnum","renderGetFilterFields","renderInputFields","renderFields","ENTRY_META_FIELDS","isDateTimeEntryMetaField","createManageSDL","models","model","fieldTypePlugins","sorterPlugins","inputFields","fields","listFilterFieldsRender","type","sortEnumRender","getFilterFieldsRender","singularApiName","singularName","pluralApiName","pluralName","inputGqlFields","map","f","join","onByMetaInputGqlFields","field","fieldType","onByMetaGqlFields","description","typeDefs","fieldFiltersAsString","baseFiltersAsString"],"sources":["createManageSDL.ts"],"sourcesContent":["import type { CmsFieldTypePlugins, CmsModel } from \"~/types/index.js\";\nimport { renderListFilterFields } from \"~/utils/renderListFilterFields.js\";\nimport { renderSortEnum } from \"~/utils/renderSortEnum.js\";\nimport { renderGetFilterFields } from \"~/utils/renderGetFilterFields.js\";\nimport { renderInputFields } from \"~/utils/renderInputFields.js\";\nimport { renderFields } from \"~/utils/renderFields.js\";\nimport type { CmsGraphQLSchemaSorterPlugin } from \"~/plugins/index.js\";\nimport { ENTRY_META_FIELDS, isDateTimeEntryMetaField } from \"~/constants.js\";\n\ninterface CreateManageSDLParams {\n models: CmsModel[];\n model: CmsModel;\n fieldTypePlugins: CmsFieldTypePlugins;\n sorterPlugins: CmsGraphQLSchemaSorterPlugin[];\n}\n\ninterface CreateManageSDL {\n (params: CreateManageSDLParams): string;\n}\n\nexport const createManageSDL: CreateManageSDL = ({\n models,\n model,\n fieldTypePlugins,\n sorterPlugins\n}): string => {\n const inputFields = renderInputFields({\n models,\n model,\n fields: model.fields,\n fieldTypePlugins\n });\n\n const listFilterFieldsRender = renderListFilterFields({\n model,\n fields: model.fields,\n type: \"manage\",\n fieldTypePlugins\n });\n\n const sortEnumRender = renderSortEnum({\n model,\n fields: model.fields,\n fieldTypePlugins,\n sorterPlugins\n });\n const getFilterFieldsRender = renderGetFilterFields({\n fields: model.fields,\n fieldTypePlugins\n });\n\n const fields = renderFields({\n models,\n model,\n fields: model.fields,\n type: \"manage\",\n fieldTypePlugins\n });\n\n const { singularApiName: singularName, pluralApiName: pluralName } = 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 prettier would not format the code correctly.\n return `\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 meta: ${singularName}Meta\n wbyAco_location: WbyAcoLocation\n \n values: ${singularName}Values\n }\n\n type ${singularName}Meta {\n modelId: String\n version: Int\n locked: Boolean\n \n status: String\n state: CmsEntryState\n \"\"\"\n CAUTION: this field is resolved by making an extra query to DB.\n RECOMMENDATION: Use it only with \"get\" queries (avoid in \"list\")\n \"\"\"\n revisions: [${singularName}!]\n title: String\n description: String\n image: String\n \"\"\"\n Custom meta data stored in the root of the entry object.\n \"\"\"\n data: JSON\n }\n\n ${fields.map(f => f.typeDefs).join(\"\\n\")}\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 id: ID\n \n # Set status of the entry.\n status: String\n \n ${onByMetaInputGqlFields}\n \n wbyAco_location: WbyAcoLocationInput\n \n values: ${singularName}InputValues\n }\n \n input ${singularName}GetWhereInputValues {\n ${getFilterFieldsRender.fieldFiltersAsString() || \"_empty: String\"}\n }\n \n input ${singularName}GetWhereInput {\n ${getFilterFieldsRender.baseFiltersAsString()}\n values: ${singularName}GetWhereInputValues\n }\n \n input ${singularName}ListWhereInputValues {\n ${listFilterFieldsRender.fieldFiltersAsString() || \"_empty: String\"}\n }\n\n input ${singularName}ListWhereInput {\n ${listFilterFieldsRender.baseFiltersAsString()}\n\n state: ListWhereInputCmsEntryState\n wbyAco_location: WbyAcoLocationWhereInput\n \n values: ${singularName}ListWhereInputValues\n AND: [${singularName}ListWhereInput!]\n OR: [${singularName}ListWhereInput!]\n }\n\n type ${singularName}Response {\n data: ${singularName}\n error: CmsError\n }\n \n type ${singularName}MoveResponse {\n data: Boolean\n error: CmsError\n }\n\n type ${singularName}ArrayResponse {\n data: [${singularName}]\n error: CmsError\n }\n\n type ${singularName}ListResponse {\n data: [${singularName}]\n meta: CmsListMeta\n error: CmsError\n }\n\n\n enum ${singularName}ListSorter {\n ${sortEnumRender}\n }\n\n extend type Query {\n get${singularName}(revision: ID, entryId: ID, status: CmsEntryStatusType): ${singularName}Response\n \n get${singularName}Revisions(id: ID!): ${singularName}ArrayResponse\n \n get${pluralName}ByIds(revisions: [ID!]!): ${singularName}ArrayResponse\n \n list${pluralName} (\n where: ${singularName}ListWhereInput\n sort: [${singularName}ListSorter]\n limit: Int\n after: String\n search: String\n ): ${singularName}ListResponse\n \n listDeleted${pluralName} (\n where: ${singularName}ListWhereInput\n sort: [${singularName}ListSorter]\n limit: Int\n after: String\n search: String\n ): ${singularName}ListResponse\n }\n\n extend type Mutation {\n create${singularName}(data: ${singularName}Input!, options: CreateCmsEntryOptionsInput): ${singularName}Response\n\n create${singularName}From(revision: ID!, data: ${singularName}Input, options: CreateRevisionCmsEntryOptionsInput): ${singularName}Response\n \n update${singularName}(revision: ID!, data: ${singularName}Input!, options: UpdateCmsEntryOptionsInput): ${singularName}Response\n\n validate${singularName}(revision: ID, data: ${singularName}Input!): CmsEntryValidationResponse!\n \n move${singularName}(revision: ID!, folderId: ID!): ${singularName}MoveResponse\n\n delete${singularName}(revision: ID!, options: CmsDeleteEntryOptions): CmsDeleteResponse\n \n restore${singularName}FromBin(revision: ID!): ${singularName}Response\n\n deleteMultiple${pluralName}(entries: [ID!]!): CmsDeleteMultipleResponse!\n \n publish${singularName}(revision: ID!): ${singularName}Response\n \n republish${singularName}(revision: ID!): ${singularName}Response\n \n unpublish${singularName}(revision: ID!): ${singularName}Response\n }\n `;\n};\n"],"mappings":"AACA,SAASA,sBAAsB;AAC/B,SAASC,cAAc;AACvB,SAASC,qBAAqB;AAC9B,SAASC,iBAAiB;AAC1B,SAASC,YAAY;AAErB,SAASC,iBAAiB,EAAEC,wBAAwB;AAapD,OAAO,MAAMC,eAAgC,GAAGA,CAAC;EAC7CC,MAAM;EACNC,KAAK;EACLC,gBAAgB;EAChBC;AACJ,CAAC,KAAa;EACV,MAAMC,WAAW,GAAGT,iBAAiB,CAAC;IAClCK,MAAM;IACNC,KAAK;IACLI,MAAM,EAAEJ,KAAK,CAACI,MAAM;IACpBH;EACJ,CAAC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;AACL,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["renderListFilterFields","renderSortEnum","renderGetFilterFields","renderInputFields","renderFields","ENTRY_META_FIELDS","isDateTimeEntryMetaField","createManageSDL","models","model","fieldTypePlugins","sorterPlugins","inputFields","fields","listFilterFieldsRender","type","sortEnumRender","getFilterFieldsRender","singularApiName","singularName","pluralApiName","pluralName","inputGqlFields","map","f","join","onByMetaInputGqlFields","field","fieldType","onByMetaGqlFields","description","typeDefs","fieldFiltersAsString","baseFiltersAsString"],"sources":["createManageSDL.ts"],"sourcesContent":["import type { CmsFieldTypePlugins, CmsModel } from \"~/types/index.js\";\nimport { renderListFilterFields } from \"~/utils/renderListFilterFields.js\";\nimport { renderSortEnum } from \"~/utils/renderSortEnum.js\";\nimport { renderGetFilterFields } from \"~/utils/renderGetFilterFields.js\";\nimport { renderInputFields } from \"~/utils/renderInputFields.js\";\nimport { renderFields } from \"~/utils/renderFields.js\";\nimport type { CmsGraphQLSchemaSorterPlugin } from \"~/plugins/index.js\";\nimport { ENTRY_META_FIELDS, isDateTimeEntryMetaField } from \"~/constants.js\";\n\ninterface CreateManageSDLParams {\n models: CmsModel[];\n model: CmsModel;\n fieldTypePlugins: CmsFieldTypePlugins;\n sorterPlugins: CmsGraphQLSchemaSorterPlugin[];\n}\n\ninterface CreateManageSDL {\n (params: CreateManageSDLParams): string;\n}\n\nexport const createManageSDL: CreateManageSDL = ({\n models,\n model,\n fieldTypePlugins,\n sorterPlugins\n}): string => {\n const inputFields = renderInputFields({\n models,\n model,\n fields: model.fields,\n fieldTypePlugins\n });\n\n const listFilterFieldsRender = renderListFilterFields({\n model,\n fields: model.fields,\n type: \"manage\",\n fieldTypePlugins\n });\n\n const sortEnumRender = renderSortEnum({\n model,\n fields: model.fields,\n fieldTypePlugins,\n sorterPlugins\n });\n const getFilterFieldsRender = renderGetFilterFields({\n fields: model.fields,\n fieldTypePlugins\n });\n\n const fields = renderFields({\n models,\n model,\n fields: model.fields,\n type: \"manage\",\n fieldTypePlugins\n });\n\n const { singularApiName: singularName, pluralApiName: pluralName } = 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 prettier would not format the code correctly.\n return `\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 meta: ${singularName}Meta\n wbyAco_location: WbyAcoLocation\n live: CmsEntryLive\n \n values: ${singularName}Values\n }\n\n type ${singularName}Meta {\n modelId: String\n version: Int\n locked: Boolean\n \n status: String\n system: CmsEntrySystem\n \"\"\"\n CAUTION: this field is resolved by making an extra query to DB.\n RECOMMENDATION: Use it only with \"get\" queries (avoid in \"list\")\n \"\"\"\n revisions: [${singularName}!]\n title: String\n description: String\n image: String\n \"\"\"\n Custom meta data stored in the root of the entry object.\n \"\"\"\n data: JSON\n }\n\n ${fields.map(f => f.typeDefs).join(\"\\n\")}\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 id: ID\n \n # Set status of the entry.\n status: String\n \n ${onByMetaInputGqlFields}\n \n wbyAco_location: WbyAcoLocationInput\n \n values: ${singularName}InputValues\n }\n \n input ${singularName}GetWhereInputValues {\n ${getFilterFieldsRender.fieldFiltersAsString() || \"_empty: String\"}\n }\n \n input ${singularName}GetWhereInput {\n ${getFilterFieldsRender.baseFiltersAsString()}\n values: ${singularName}GetWhereInputValues\n }\n \n input ${singularName}ListWhereInputValues {\n ${listFilterFieldsRender.fieldFiltersAsString() || \"_empty: String\"}\n }\n\n input ${singularName}ListWhereInput {\n ${listFilterFieldsRender.baseFiltersAsString()}\n\n system: ListWhereInputCmsEntrySystem\n wbyAco_location: WbyAcoLocationWhereInput\n live: CmsEntryLiveWhereInput\n \n values: ${singularName}ListWhereInputValues\n AND: [${singularName}ListWhereInput!]\n OR: [${singularName}ListWhereInput!]\n }\n\n type ${singularName}Response {\n data: ${singularName}\n error: CmsError\n }\n \n type ${singularName}MoveResponse {\n data: Boolean\n error: CmsError\n }\n\n type ${singularName}ArrayResponse {\n data: [${singularName}]\n error: CmsError\n }\n\n type ${singularName}ListResponse {\n data: [${singularName}]\n meta: CmsListMeta\n error: CmsError\n }\n\n\n enum ${singularName}ListSorter {\n ${sortEnumRender}\n }\n\n extend type Query {\n get${singularName}(revision: ID, entryId: ID, status: CmsEntryStatusType): ${singularName}Response\n \n get${singularName}Revisions(id: ID!): ${singularName}ArrayResponse\n \n get${pluralName}ByIds(revisions: [ID!]!): ${singularName}ArrayResponse\n \n list${pluralName} (\n where: ${singularName}ListWhereInput\n sort: [${singularName}ListSorter]\n limit: Int\n after: String\n search: String\n ): ${singularName}ListResponse\n \n listDeleted${pluralName} (\n where: ${singularName}ListWhereInput\n sort: [${singularName}ListSorter]\n limit: Int\n after: String\n search: String\n ): ${singularName}ListResponse\n }\n\n extend type Mutation {\n create${singularName}(data: ${singularName}Input!, options: CreateCmsEntryOptionsInput): ${singularName}Response\n\n create${singularName}From(revision: ID!, data: ${singularName}Input, options: CreateRevisionCmsEntryOptionsInput): ${singularName}Response\n \n update${singularName}(revision: ID!, data: ${singularName}Input!, options: UpdateCmsEntryOptionsInput): ${singularName}Response\n\n validate${singularName}(revision: ID, data: ${singularName}Input!): CmsEntryValidationResponse!\n \n move${singularName}(revision: ID!, folderId: ID!): ${singularName}MoveResponse\n\n delete${singularName}(revision: ID!, options: CmsDeleteEntryOptions): CmsDeleteResponse\n \n restore${singularName}FromBin(revision: ID!): ${singularName}Response\n\n deleteMultiple${pluralName}(entries: [ID!]!): CmsDeleteMultipleResponse!\n \n publish${singularName}(revision: ID!): ${singularName}Response\n \n republish${singularName}(revision: ID!): ${singularName}Response\n \n unpublish${singularName}(revision: ID!): ${singularName}Response\n }\n `;\n};\n"],"mappings":"AACA,SAASA,sBAAsB;AAC/B,SAASC,cAAc;AACvB,SAASC,qBAAqB;AAC9B,SAASC,iBAAiB;AAC1B,SAASC,YAAY;AAErB,SAASC,iBAAiB,EAAEC,wBAAwB;AAapD,OAAO,MAAMC,eAAgC,GAAGA,CAAC;EAC7CC,MAAM;EACNC,KAAK;EACLC,gBAAgB;EAChBC;AACJ,CAAC,KAAa;EACV,MAAMC,WAAW,GAAGT,iBAAiB,CAAC;IAClCK,MAAM;IACNC,KAAK;IACLI,MAAM,EAAEJ,KAAK,CAACI,MAAM;IACpBH;EACJ,CAAC,CAAC;EAEF,MAAMI,sBAAsB,GAAGd,sBAAsB,CAAC;IAClDS,KAAK;IACLI,MAAM,EAAEJ,KAAK,CAACI,MAAM;IACpBE,IAAI,EAAE,QAAQ;IACdL;EACJ,CAAC,CAAC;EAEF,MAAMM,cAAc,GAAGf,cAAc,CAAC;IAClCQ,KAAK;IACLI,MAAM,EAAEJ,KAAK,CAACI,MAAM;IACpBH,gBAAgB;IAChBC;EACJ,CAAC,CAAC;EACF,MAAMM,qBAAqB,GAAGf,qBAAqB,CAAC;IAChDW,MAAM,EAAEJ,KAAK,CAACI,MAAM;IACpBH;EACJ,CAAC,CAAC;EAEF,MAAMG,MAAM,GAAGT,YAAY,CAAC;IACxBI,MAAM;IACNC,KAAK;IACLI,MAAM,EAAEJ,KAAK,CAACI,MAAM;IACpBE,IAAI,EAAE,QAAQ;IACdL;EACJ,CAAC,CAAC;EAEF,MAAM;IAAEQ,eAAe,EAAEC,YAAY;IAAEC,aAAa,EAAEC;E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A;AACA,iBAAiBA,YAAY;AAC7B;AACA,yBAAyBE,UAAU;AACnC,yBAAyBF,YAAY;AACrC,yBAAyBA,YAAY;AACrC;AACA;AACA;AACA,iBAAiBA,YAAY;AAC7B;AACA;AACA;AACA,oBAAoBA,YAAY,UAAUA,YAAY,iDAAiDA,YAAY;AACnH;AACA,oBAAoBA,YAAY,6BAA6BA,YAAY,wDAAwDA,YAAY;AAC7I;AACA,oBAAoBA,YAAY,yBAAyBA,YAAY,iDAAiDA,YAAY;AAClI;AACA,sBAAsBA,YAAY,wBAAwBA,YAAY;AACtE;AACA,kBAAkBA,YAAY,mCAAmCA,YAAY;AAC7E;AACA,oBAAoBA,YAAY;AAChC;AACA,qBAAqBA,YAAY,2BAA2BA,YAAY;AACxE;AACA,4BAA4BE,UAAU;AACtC;AACA,qBAAqBF,YAAY,oBAAoBA,YAAY;AACjE;AACA,uBAAuBA,YAAY,oBAAoBA,YAAY;AACnE;AACA,uBAAuBA,YAAY,oBAAoBA,YAAY;AACnE;AACA,KAAK;AACL,CAAC","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-headless-cms",
3
- "version": "6.0.0-rc.1",
3
+ "version": "6.0.0-rc.2",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "keywords": [
@@ -22,21 +22,21 @@
22
22
  "@babel/code-frame": "7.29.0",
23
23
  "@graphql-tools/merge": "9.1.7",
24
24
  "@graphql-tools/schema": "10.0.31",
25
- "@webiny/api": "6.0.0-rc.1",
26
- "@webiny/api-core": "6.0.0-rc.1",
25
+ "@webiny/api": "6.0.0-rc.2",
26
+ "@webiny/api-core": "6.0.0-rc.2",
27
27
  "@webiny/di": "0.2.3",
28
- "@webiny/error": "6.0.0-rc.1",
29
- "@webiny/feature": "6.0.0-rc.1",
30
- "@webiny/handler": "6.0.0-rc.1",
31
- "@webiny/handler-aws": "6.0.0-rc.1",
32
- "@webiny/handler-db": "6.0.0-rc.1",
33
- "@webiny/handler-graphql": "6.0.0-rc.1",
34
- "@webiny/plugins": "6.0.0-rc.1",
35
- "@webiny/project": "6.0.0-rc.1",
36
- "@webiny/utils": "6.0.0-rc.1",
37
- "@webiny/validation": "6.0.0-rc.1",
28
+ "@webiny/error": "6.0.0-rc.2",
29
+ "@webiny/feature": "6.0.0-rc.2",
30
+ "@webiny/handler": "6.0.0-rc.2",
31
+ "@webiny/handler-aws": "6.0.0-rc.2",
32
+ "@webiny/handler-db": "6.0.0-rc.2",
33
+ "@webiny/handler-graphql": "6.0.0-rc.2",
34
+ "@webiny/plugins": "6.0.0-rc.2",
35
+ "@webiny/project": "6.0.0-rc.2",
36
+ "@webiny/utils": "6.0.0-rc.2",
37
+ "@webiny/validation": "6.0.0-rc.2",
38
38
  "dot-prop-immutable": "2.1.1",
39
- "graphql": "16.12.0",
39
+ "graphql": "16.13.0",
40
40
  "graphql-tag": "2.12.6",
41
41
  "lodash": "4.17.23",
42
42
  "p-map": "7.0.4",
@@ -48,15 +48,15 @@
48
48
  "devDependencies": {
49
49
  "@types/babel__code-frame": "7.27.0",
50
50
  "@types/pluralize": "0.0.33",
51
- "@webiny/aws-sdk": "6.0.0-rc.1",
52
- "@webiny/build-tools": "6.0.0-rc.1",
53
- "@webiny/db-dynamodb": "6.0.0-rc.1",
51
+ "@webiny/aws-sdk": "6.0.0-rc.2",
52
+ "@webiny/build-tools": "6.0.0-rc.2",
53
+ "@webiny/db-dynamodb": "6.0.0-rc.2",
54
54
  "@webiny/handler-db": "0.0.0",
55
- "@webiny/project-utils": "6.0.0-rc.1",
56
- "@webiny/sdk": "6.0.0-rc.1",
57
- "@webiny/wcp": "6.0.0-rc.1",
55
+ "@webiny/project-utils": "6.0.0-rc.2",
56
+ "@webiny/sdk": "6.0.0-rc.2",
57
+ "@webiny/wcp": "6.0.0-rc.2",
58
58
  "apollo-graphql": "0.9.7",
59
- "graphql": "16.12.0",
59
+ "graphql": "16.13.0",
60
60
  "prettier": "3.6.2",
61
61
  "rimraf": "6.1.3",
62
62
  "typescript": "5.9.3",
@@ -67,5 +67,5 @@
67
67
  "access": "public",
68
68
  "directory": "dist"
69
69
  },
70
- "gitHead": "36d702721ff9ed39fb21d6f5fe7922a2a8716e63"
70
+ "gitHead": "5facada4cbb8617cc60e3c98be0f1839f44be38e"
71
71
  }
package/types/types.d.ts CHANGED
@@ -257,11 +257,10 @@ export interface CmsEntryValues {
257
257
  export interface ICmsEntryLocation {
258
258
  folderId?: string;
259
259
  }
260
- export interface IEntryState {
261
- state: string;
262
- workflowId: string;
263
- stepId: string;
264
- stepName: string;
260
+ export interface ICmsEntryLive {
261
+ version: number;
262
+ }
263
+ export interface ICmsEntrySystem {
265
264
  }
266
265
  /**
267
266
  * A content entry definition for and from the database.
@@ -443,7 +442,11 @@ export interface CmsEntry<TValues extends CmsEntryValues = CmsEntryValues> {
443
442
  * The value is used when restoring the entry from the trash bin.
444
443
  */
445
444
  binOriginalFolderId?: string;
446
- state?: IEntryState;
445
+ system?: ICmsEntrySystem;
446
+ /**
447
+ * Is this CMS Entry live (no matter the revision).
448
+ */
449
+ live: ICmsEntryLive | null;
447
450
  }
448
451
  export interface CmsStorageEntry<T extends CmsEntryValues = CmsEntryValues> extends CmsEntry<T> {
449
452
  [key: string]: any;
@@ -680,7 +683,7 @@ export interface CreateCmsEntryInput<TValues extends CmsEntryValues = CmsEntryVa
680
683
  location?: {
681
684
  folderId?: string | null;
682
685
  };
683
- state?: Partial<IEntryState>;
686
+ system?: Partial<ICmsEntrySystem>;
684
687
  values: TValues | undefined;
685
688
  }
686
689
  export interface CreateCmsEntryOptionsInput {
@@ -717,7 +720,7 @@ export interface CreateFromCmsEntryInput<TValues extends CmsEntryValues = CmsEnt
717
720
  lastPublishedOn?: Date | string;
718
721
  firstPublishedBy?: CmsIdentity;
719
722
  lastPublishedBy?: CmsIdentity;
720
- state?: Partial<IEntryState>;
723
+ system?: Partial<ICmsEntrySystem>;
721
724
  values: TValues;
722
725
  }
723
726
  export interface CreateRevisionCmsEntryOptionsInput {
@@ -768,7 +771,7 @@ export interface UpdateCmsEntryInput<TValues extends CmsEntryValues = CmsEntryVa
768
771
  location?: {
769
772
  folderId?: string | null;
770
773
  };
771
- state?: Partial<IEntryState>;
774
+ system?: Partial<ICmsEntrySystem>;
772
775
  values?: Partial<TValues>;
773
776
  }
774
777
  export interface UpdateCmsEntryOptionsInput {
@@ -1 +1 @@
1
- {"version":3,"names":["CONTENT_ENTRY_STATUS"],"sources":["types.ts"],"sourcesContent":["import type { Context, GenericRecord } from \"@webiny/api/types.js\";\nimport type {\n GraphQLFieldResolver,\n GraphQLRequestBody,\n Resolvers\n} 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 { CmsModelFieldToGraphQLPlugin } from \"./plugins.js\";\nimport type { CmsEntryContext } from \"./context.js\";\nimport type { CmsModelField, CmsModelFieldValidation, CmsModelUpdateInput } from \"./modelField.js\";\nimport type { CmsModel, CmsModelCreateFromInput, CmsModelCreateInput } 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<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\nexport interface CmsModelFieldToGraphQLNormalizeInputParams<TField> {\n model: CmsModel;\n field: TField;\n input: GenericRecord<string> | Array<GenericRecord<string>>;\n}\n\ninterface CmsModelFieldToGraphQLCreateResolverParams<TField> {\n models: CmsModel[];\n model: CmsModel;\n graphQLType: string;\n field: TField;\n createFieldResolvers: any;\n fieldTypePlugins: CmsFieldTypePlugins;\n}\n\nexport interface CmsModelFieldToGraphQLCreateResolver<TField = CmsModelField> {\n (params: CmsModelFieldToGraphQLCreateResolverParams<TField>):\n | GraphQLFieldResolver\n | {\n resolver: GraphQLFieldResolver | null;\n typeResolvers: Resolvers<CmsContext>;\n }\n | false;\n}\n\nexport interface CmsModelFieldToGraphQLPluginValidateChildFieldsValidateParams<\n TField extends CmsModelField = CmsModelField\n> {\n fields: TField[];\n originalFields: TField[];\n}\n\nexport interface CmsModelFieldToGraphQLPluginValidateChildFieldsValidate {\n (params: CmsModelFieldToGraphQLPluginValidateChildFieldsValidateParams): void;\n}\n\nexport interface CmsModelFieldToGraphQLPluginValidateChildFieldsParams<\n TField extends CmsModelField = CmsModelField\n> {\n field: TField;\n originalField?: TField;\n validate: CmsModelFieldToGraphQLPluginValidateChildFieldsValidate;\n}\n\nexport interface CmsModelFieldToGraphQLPluginValidateChildFields<\n TField extends CmsModelField = CmsModelField\n> {\n (params: CmsModelFieldToGraphQLPluginValidateChildFieldsParams<TField>): void;\n}\n\n/**\n * @category ModelField\n */\nexport interface CmsFieldTypePlugins {\n [key: string]: CmsModelFieldToGraphQLPlugin;\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 IEntryState {\n state: string;\n workflowId: string;\n stepId: string;\n stepName: string;\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 * Settings for the given entry.\n *\n * Introduced with Advanced Publishing Workflow. Will always be inserted once this PR is merged.\n * Be aware that when accessing properties in it on old systems, it will break if not checked first.\n *\n * Available only on the Manage API in entry GraphQL type `meta.data` property.\n */\n meta?: GenericRecord;\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 state?: IEntryState;\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 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 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 state?: Partial<IEntryState>;\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 state?: Partial<IEntryState>;\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 state?: Partial<IEntryState>;\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 fieldTypePlugins: CmsFieldTypePlugins;\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: CmsModel;\n}\n\nexport interface CmsModelStorageOperationsUpdateParams {\n model: CmsModel;\n}\n\nexport interface CmsModelStorageOperationsDeleteParams {\n model: CmsModel;\n}\n\n/**\n * Description of the CmsModel storage operations.\n * If user wants to add another database to the application, this is how it is done.\n * This is just plain read, update, write, delete and list - no authentication or permission checks.\n */\nexport interface CmsModelStorageOperations {\n /**\n * Gets content model by given id.\n */\n get: (params: CmsModelStorageOperationsGetParams) => Promise<CmsModel | null>;\n /**\n * List all content models. Filterable via params.\n */\n list: (params: CmsModelStorageOperationsListParams) => Promise<CmsModel[]>;\n /**\n * Create a new content model.\n */\n create: (params: CmsModelStorageOperationsCreateParams) => Promise<CmsModel>;\n /**\n * Update existing content model.\n */\n update: (params: CmsModelStorageOperationsUpdateParams) => Promise<CmsModel>;\n /**\n * Delete the content model.\n */\n delete: (params: CmsModelStorageOperationsDeleteParams) => Promise<CmsModel>;\n}\n\nexport interface CmsEntryStorageOperationsGetParams {\n where: CmsEntryListWhere;\n sort?: CmsEntryListSort;\n limit?: number;\n}\n\nexport interface CmsEntryStorageOperationsListParams {\n where: CmsEntryListWhere;\n sort?: CmsEntryListSort;\n search?: string;\n fields?: string[];\n limit: number;\n after?: string | null;\n}\n\nexport interface CmsEntryStorageOperationsCreateParams<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 = 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"],"mappings":"AAuFA;AACA;AACA;AACA;AACA;;AAKA;AACA;AACA;;AAKA;AACA;AACA;;AAUA;AACA;AACA;AACA;AACA;AACA;;AAgCA;AACA;AACA;AACA;AACA;;AAOA;AACA;AACA;;AAwDA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;;AASA;AACA;AACA;AACA;AACA;AACA;;AAQA;AACA;AACA;AACA;AACA;AACA;;AAOA;AACA;AACA;AACA;AACA;AACA;;AA4BA;AACA;AACA;AACA;AACA;AACA;;AAeA;AACA;AACA;AACA;AACA;AACA;;AA0MA;AACA;AACA;AACA;AACA;AACA;;AAsCA;AACA;AACA;AACA;AACA;;AAyBA;AACA;AACA;AACA;AACA;AACA;;AA8EA;AACA;AACA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;;AAUA;AACA;AACA;AACA;AACA;AACA;;AAgBA;AACA;AACA;AACA;;AAyDA;AACA;AACA;AACA;;AAuCA;AACA;AACA;AACA;;AAuDA;AACA;AACA;AACA;;AAMA;AACA;AACA;;AAaA;AACA;AACA;AACA;;AAaA;AACA;AACA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;;AAmCA;AACA;AACA;AACA;AACA;;AAmDA;AACA;AACA;AACA;AACA;;AAuNA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAuJA,WAAYA,oBAAoB,0BAApBA,oBAAoB;EAApBA,oBAAoB;EAApBA,oBAAoB;EAApBA,oBAAoB;EAAA,OAApBA,oBAAoB;AAAA","ignoreList":[]}
1
+ {"version":3,"names":["CONTENT_ENTRY_STATUS"],"sources":["types.ts"],"sourcesContent":["import type { Context, GenericRecord } from \"@webiny/api/types.js\";\nimport type {\n GraphQLFieldResolver,\n GraphQLRequestBody,\n Resolvers\n} 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 { CmsModelFieldToGraphQLPlugin } from \"./plugins.js\";\nimport type { CmsEntryContext } from \"./context.js\";\nimport type { CmsModelField, CmsModelFieldValidation, CmsModelUpdateInput } from \"./modelField.js\";\nimport type { CmsModel, CmsModelCreateFromInput, CmsModelCreateInput } 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<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\nexport interface CmsModelFieldToGraphQLNormalizeInputParams<TField> {\n model: CmsModel;\n field: TField;\n input: GenericRecord<string> | Array<GenericRecord<string>>;\n}\n\ninterface CmsModelFieldToGraphQLCreateResolverParams<TField> {\n models: CmsModel[];\n model: CmsModel;\n graphQLType: string;\n field: TField;\n createFieldResolvers: any;\n fieldTypePlugins: CmsFieldTypePlugins;\n}\n\nexport interface CmsModelFieldToGraphQLCreateResolver<TField = CmsModelField> {\n (params: CmsModelFieldToGraphQLCreateResolverParams<TField>):\n | GraphQLFieldResolver\n | {\n resolver: GraphQLFieldResolver | null;\n typeResolvers: Resolvers<CmsContext>;\n }\n | false;\n}\n\nexport interface CmsModelFieldToGraphQLPluginValidateChildFieldsValidateParams<\n TField extends CmsModelField = CmsModelField\n> {\n fields: TField[];\n originalFields: TField[];\n}\n\nexport interface CmsModelFieldToGraphQLPluginValidateChildFieldsValidate {\n (params: CmsModelFieldToGraphQLPluginValidateChildFieldsValidateParams): void;\n}\n\nexport interface CmsModelFieldToGraphQLPluginValidateChildFieldsParams<\n TField extends CmsModelField = CmsModelField\n> {\n field: TField;\n originalField?: TField;\n validate: CmsModelFieldToGraphQLPluginValidateChildFieldsValidate;\n}\n\nexport interface CmsModelFieldToGraphQLPluginValidateChildFields<\n TField extends CmsModelField = CmsModelField\n> {\n (params: CmsModelFieldToGraphQLPluginValidateChildFieldsParams<TField>): void;\n}\n\n/**\n * @category ModelField\n */\nexport interface CmsFieldTypePlugins {\n [key: string]: CmsModelFieldToGraphQLPlugin;\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 * Settings for the given entry.\n *\n * Introduced with Advanced Publishing Workflow. Will always be inserted once this PR is merged.\n * Be aware that when accessing properties in it on old systems, it will break if not checked first.\n *\n * Available only on the Manage API in entry GraphQL type `meta.data` property.\n */\n meta?: GenericRecord;\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\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 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 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 fieldTypePlugins: CmsFieldTypePlugins;\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: CmsModel;\n}\n\nexport interface CmsModelStorageOperationsUpdateParams {\n model: CmsModel;\n}\n\nexport interface CmsModelStorageOperationsDeleteParams {\n model: CmsModel;\n}\n\n/**\n * Description of the CmsModel storage operations.\n * If user wants to add another database to the application, this is how it is done.\n * This is just plain read, update, write, delete and list - no authentication or permission checks.\n */\nexport interface CmsModelStorageOperations {\n /**\n * Gets content model by given id.\n */\n get: (params: CmsModelStorageOperationsGetParams) => Promise<CmsModel | null>;\n /**\n * List all content models. Filterable via params.\n */\n list: (params: CmsModelStorageOperationsListParams) => Promise<CmsModel[]>;\n /**\n * Create a new content model.\n */\n create: (params: CmsModelStorageOperationsCreateParams) => Promise<CmsModel>;\n /**\n * Update existing content model.\n */\n update: (params: CmsModelStorageOperationsUpdateParams) => Promise<CmsModel>;\n /**\n * Delete the content model.\n */\n delete: (params: CmsModelStorageOperationsDeleteParams) => Promise<CmsModel>;\n}\n\nexport interface CmsEntryStorageOperationsGetParams {\n where: CmsEntryListWhere;\n sort?: CmsEntryListSort;\n limit?: number;\n}\n\nexport interface CmsEntryStorageOperationsListParams {\n where: CmsEntryListWhere;\n sort?: CmsEntryListSort;\n search?: string;\n fields?: string[];\n limit: number;\n after?: string | null;\n}\n\nexport interface CmsEntryStorageOperationsCreateParams<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 = 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"],"mappings":"AAuFA;AACA;AACA;AACA;AACA;;AAKA;AACA;AACA;;AAKA;AACA;AACA;;AAUA;AACA;AACA;AACA;AACA;AACA;;AAgCA;AACA;AACA;AACA;AACA;;AAOA;AACA;AACA;;AAwDA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;;AASA;AACA;AACA;AACA;AACA;AACA;;AAQA;AACA;AACA;AACA;AACA;AACA;;AAOA;AACA;AACA;AACA;AACA;AACA;;AA4BA;AACA;AACA;AACA;AACA;AACA;;AAgBA;AACA;AACA;AACA;AACA;AACA;;AA8MA;AACA;AACA;AACA;AACA;AACA;;AAsCA;AACA;AACA;AACA;AACA;;AAyBA;AACA;AACA;AACA;AACA;AACA;;AA8EA;AACA;AACA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;;AAUA;AACA;AACA;AACA;AACA;AACA;;AAgBA;AACA;AACA;AACA;;AAyDA;AACA;AACA;AACA;;AAuCA;AACA;AACA;AACA;;AAuDA;AACA;AACA;AACA;;AAMA;AACA;AACA;;AAaA;AACA;AACA;AACA;;AAaA;AACA;AACA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;;AAmCA;AACA;AACA;AACA;AACA;;AAmDA;AACA;AACA;AACA;AACA;;AAuNA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAuJA,WAAYA,oBAAoB,0BAApBA,oBAAoB;EAApBA,oBAAoB;EAApBA,oBAAoB;EAApBA,oBAAoB;EAAA,OAApBA,oBAAoB;AAAA","ignoreList":[]}
@@ -1,10 +0,0 @@
1
- import type { CmsEntry, IEntryState } from "../../../types/index.js";
2
- interface IInputWithPossibleState {
3
- state: Partial<IEntryState> | null;
4
- }
5
- interface IParams {
6
- input: Partial<IInputWithPossibleState>;
7
- original?: CmsEntry | null;
8
- }
9
- export declare const getState: ({ input, original }: IParams) => IEntryState | undefined;
10
- export {};
@@ -1,16 +0,0 @@
1
- export const getState = ({
2
- input,
3
- original
4
- }) => {
5
- if (!input?.state?.stepId || !input.state.state || !input.state.stepName || !input.state.workflowId) {
6
- return original?.state;
7
- }
8
- return {
9
- workflowId: input.state.workflowId,
10
- stepId: input.state.stepId,
11
- stepName: input.state.stepName,
12
- state: input.state.state
13
- };
14
- };
15
-
16
- //# sourceMappingURL=state.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["getState","input","original","state","stepId","stepName","workflowId"],"sources":["state.ts"],"sourcesContent":["import type { CmsEntry, IEntryState } from \"~/types/index.js\";\n\ninterface IInputWithPossibleState {\n state: Partial<IEntryState> | null;\n}\ninterface IParams {\n input: Partial<IInputWithPossibleState>;\n original?: CmsEntry | null;\n}\n\nexport const getState = ({ input, original }: IParams): IEntryState | undefined => {\n if (\n !input?.state?.stepId ||\n !input.state.state ||\n !input.state.stepName ||\n !input.state.workflowId\n ) {\n return original?.state;\n }\n return {\n workflowId: input.state.workflowId,\n stepId: input.state.stepId,\n stepName: input.state.stepName,\n state: input.state.state\n };\n};\n"],"mappings":"AAUA,OAAO,MAAMA,QAAQ,GAAGA,CAAC;EAAEC,KAAK;EAAEC;AAAkB,CAAC,KAA8B;EAC/E,IACI,CAACD,KAAK,EAAEE,KAAK,EAAEC,MAAM,IACrB,CAACH,KAAK,CAACE,KAAK,CAACA,KAAK,IAClB,CAACF,KAAK,CAACE,KAAK,CAACE,QAAQ,IACrB,CAACJ,KAAK,CAACE,KAAK,CAACG,UAAU,EACzB;IACE,OAAOJ,QAAQ,EAAEC,KAAK;EAC1B;EACA,OAAO;IACHG,UAAU,EAAEL,KAAK,CAACE,KAAK,CAACG,UAAU;IAClCF,MAAM,EAAEH,KAAK,CAACE,KAAK,CAACC,MAAM;IAC1BC,QAAQ,EAAEJ,KAAK,CAACE,KAAK,CAACE,QAAQ;IAC9BF,KAAK,EAAEF,KAAK,CAACE,KAAK,CAACA;EACvB,CAAC;AACL,CAAC","ignoreList":[]}