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

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 (118) 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/crud/contentModel/validation.d.ts +9 -9
  20. package/crud/contentModel/validation.js +3 -3
  21. package/crud/contentModel/validation.js.map +1 -1
  22. package/domain/contentModel/errors.d.ts +1 -1
  23. package/domain/contentModel/errors.js.map +1 -1
  24. package/domain/contentModel/schemas.d.ts +126 -8
  25. package/domain/contentModel/schemas.js +12 -13
  26. package/domain/contentModel/schemas.js.map +1 -1
  27. package/export/graphql/index.js +1 -1
  28. package/export/graphql/index.js.map +1 -1
  29. package/features/contentModel/CreateModel/CreateModelRepository.js +4 -1
  30. package/features/contentModel/CreateModel/CreateModelRepository.js.map +1 -1
  31. package/features/contentModel/CreateModelFrom/CreateModelFromRepository.js +12 -3
  32. package/features/contentModel/CreateModelFrom/CreateModelFromRepository.js.map +1 -1
  33. package/features/contentModel/UpdateModel/UpdateModelRepository.js +8 -2
  34. package/features/contentModel/UpdateModel/UpdateModelRepository.js.map +1 -1
  35. package/features/contentModel/UpdateModel/UpdateModelUseCase.js +4 -1
  36. package/features/contentModel/UpdateModel/UpdateModelUseCase.js.map +1 -1
  37. package/features/modelBuilder/feature.js +2 -2
  38. package/features/modelBuilder/feature.js.map +1 -1
  39. package/features/modelBuilder/fields/BaseFieldBuilder.d.ts +36 -0
  40. package/features/modelBuilder/fields/BaseFieldBuilder.js +41 -0
  41. package/features/modelBuilder/fields/BaseFieldBuilder.js.map +1 -0
  42. package/features/modelBuilder/fields/DataFieldBuilder.d.ts +228 -0
  43. package/features/modelBuilder/fields/DataFieldBuilder.js +219 -0
  44. package/features/modelBuilder/fields/DataFieldBuilder.js.map +1 -0
  45. package/features/modelBuilder/fields/DynamicZoneFieldType.d.ts +2 -2
  46. package/features/modelBuilder/fields/DynamicZoneFieldType.js +6 -3
  47. package/features/modelBuilder/fields/DynamicZoneFieldType.js.map +1 -1
  48. package/features/modelBuilder/fields/FieldBuilder.d.ts +5 -228
  49. package/features/modelBuilder/fields/FieldBuilder.js +3 -231
  50. package/features/modelBuilder/fields/FieldBuilder.js.map +1 -1
  51. package/features/modelBuilder/fields/LayoutFieldBuilder.d.ts +7 -0
  52. package/features/modelBuilder/fields/LayoutFieldBuilder.js +9 -0
  53. package/features/modelBuilder/fields/LayoutFieldBuilder.js.map +1 -0
  54. package/features/modelBuilder/fields/ObjectFieldType.d.ts +4 -3
  55. package/features/modelBuilder/fields/ObjectFieldType.js +19 -4
  56. package/features/modelBuilder/fields/ObjectFieldType.js.map +1 -1
  57. package/features/modelBuilder/fields/UiAlertFieldType.d.ts +8 -4
  58. package/features/modelBuilder/fields/UiAlertFieldType.js +23 -6
  59. package/features/modelBuilder/fields/UiAlertFieldType.js.map +1 -1
  60. package/features/modelBuilder/fields/UiSeparatorFieldType.d.ts +6 -4
  61. package/features/modelBuilder/fields/UiSeparatorFieldType.js +18 -4
  62. package/features/modelBuilder/fields/UiSeparatorFieldType.js.map +1 -1
  63. package/features/modelBuilder/fields/UiTabsFieldType.d.ts +28 -0
  64. package/features/modelBuilder/fields/UiTabsFieldType.js +75 -0
  65. package/features/modelBuilder/fields/UiTabsFieldType.js.map +1 -0
  66. package/features/modelBuilder/fields/abstractions.d.ts +2 -2
  67. package/features/modelBuilder/fields/abstractions.js.map +1 -1
  68. package/features/modelBuilder/index.d.ts +2 -0
  69. package/features/modelBuilder/index.js +2 -0
  70. package/features/modelBuilder/index.js.map +1 -1
  71. package/features/modelBuilder/models/BaseModelBuilder.d.ts +8 -3
  72. package/features/modelBuilder/models/BaseModelBuilder.js +19 -0
  73. package/features/modelBuilder/models/BaseModelBuilder.js.map +1 -1
  74. package/features/modelBuilder/models/PrivateModelBuilder.js +4 -2
  75. package/features/modelBuilder/models/PrivateModelBuilder.js.map +1 -1
  76. package/features/modelBuilder/models/PublicModelBuilder.js +16 -11
  77. package/features/modelBuilder/models/PublicModelBuilder.js.map +1 -1
  78. package/graphql/schema/baseSchema.js +17 -15
  79. package/graphql/schema/baseSchema.js.map +1 -1
  80. package/graphql/schema/cms/helpers/index.d.ts +1 -0
  81. package/graphql/schema/cms/helpers/index.js +1 -0
  82. package/graphql/schema/cms/helpers/index.js.map +1 -1
  83. package/graphql/schema/cms/helpers/transformWhereToNested.d.ts +17 -0
  84. package/graphql/schema/cms/helpers/transformWhereToNested.js +54 -0
  85. package/graphql/schema/cms/helpers/transformWhereToNested.js.map +1 -0
  86. package/graphql/schema/cms/helpers.d.ts +1 -0
  87. package/graphql/schema/cms/helpers.js +1 -0
  88. package/graphql/schema/cms/helpers.js.map +1 -1
  89. package/graphql/schema/cms/listEntriesResolver.js +6 -2
  90. package/graphql/schema/cms/listEntriesResolver.js.map +1 -1
  91. package/graphql/schema/contentModels.js +21 -3
  92. package/graphql/schema/contentModels.js.map +1 -1
  93. package/graphql/schema/createManageSDL.js +4 -2
  94. package/graphql/schema/createManageSDL.js.map +1 -1
  95. package/graphqlFields/index.js +1 -2
  96. package/graphqlFields/index.js.map +1 -1
  97. package/package.json +22 -22
  98. package/plugins/CmsModelPlugin.js +19 -4
  99. package/plugins/CmsModelPlugin.js.map +1 -1
  100. package/types/fields/objectField.d.ts +2 -0
  101. package/types/fields/objectField.js.map +1 -1
  102. package/types/model.d.ts +32 -3
  103. package/types/model.js.map +1 -1
  104. package/types/modelField.d.ts +19 -3
  105. package/types/modelField.js.map +1 -1
  106. package/types/types.d.ts +12 -9
  107. package/types/types.js.map +1 -1
  108. package/utils/createModelField.js +4 -2
  109. package/utils/createModelField.js.map +1 -1
  110. package/crud/contentEntry/entryDataFactories/state.d.ts +0 -10
  111. package/crud/contentEntry/entryDataFactories/state.js +0 -16
  112. package/crud/contentEntry/entryDataFactories/state.js.map +0 -1
  113. package/features/modelBuilder/fields/UiFieldType.d.ts +0 -18
  114. package/features/modelBuilder/fields/UiFieldType.js +0 -25
  115. package/features/modelBuilder/fields/UiFieldType.js.map +0 -1
  116. package/graphqlFields/ui.d.ts +0 -2
  117. package/graphqlFields/ui.js +0 -32
  118. package/graphqlFields/ui.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"names":["WebinyError","lodashCamelCase","camelCase","upperFirst","pluralize","Plugin","createFieldStorageId","validateStorageId","createApiName","name","createPluralApiName","CmsModelPlugin","type","constructor","contentModel","options","buildModel","input","isPrivate","singularApiName","pluralApiName","modelPlugin","group","description","fields","isPlugin","icon","layout","modelId","titleFieldId","noValidate","model","buildFields","validateLayout","inputFields","length","storageIdList","fieldIdList","fieldId","trim","field","match","includes","id","storageId","e","from","data","settings","childFields","push","total","row","count","filter","cell","createModelPlugin","createPrivateModelPlugin","authorization"],"sources":["CmsModelPlugin.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport lodashCamelCase from \"lodash/camelCase.js\";\nimport camelCase from \"lodash/camelCase.js\";\nimport upperFirst from \"lodash/upperFirst.js\";\nimport pluralize from \"pluralize\";\nimport { Plugin } from \"@webiny/plugins\";\nimport type {\n CmsModel as CmsModelBase,\n CmsModelField as CmsModelFieldBase,\n CmsModelFieldSettings as BaseCmsModelFieldSettings\n} from \"~/types/index.js\";\nimport { createFieldStorageId } from \"~/crud/contentModel/createFieldStorageId.js\";\nimport { validateStorageId } from \"~/crud/contentModel/validateStorageId.js\";\n\nconst createApiName = (name: string) => {\n return upperFirst(camelCase(name));\n};\n\nconst createPluralApiName = (name: string) => {\n return pluralize(createApiName(name));\n};\n\ninterface CmsModelFieldSettings extends Omit<BaseCmsModelFieldSettings, \"fields\"> {\n /**\n * Object field has child fields.\n */\n fields?: CmsModelFieldInput[];\n}\n\ninterface CmsModelFieldInput extends Omit<CmsModelFieldBase, \"storageId\" | \"settings\"> {\n /**\n * If defined, it must be camelCased string.\n * This is for backwards compatibility - before fields had storageId.\n *\n * This should only be populated in old model fields.\n * New ones must have this empty.\n */\n storageId?: string;\n /**\n * We must have a possibility to have a nested field defined without the storageId.\n */\n settings?: CmsModelFieldSettings;\n}\n\nexport interface CmsApiModel\n extends Omit<\n CmsModelPluginModel,\n \"isPrivate\" | \"fields\" | \"singularApiName\" | \"pluralApiName\" | \"isPlugin\"\n > {\n isPrivate?: never;\n noValidate?: boolean;\n singularApiName?: string;\n pluralApiName?: string;\n fields: CmsModelFieldInput[];\n}\n\nexport interface CmsApiModelFull extends Omit<CmsApiModel, \"fields\"> {\n fields: CmsModelFieldBase[];\n}\n\ninterface CmsPrivateModel\n extends Omit<\n CmsModelPluginModel,\n | \"isPrivate\"\n | \"singularApiName\"\n | \"pluralApiName\"\n | \"fields\"\n | \"isPlugin\"\n | \"layout\"\n | \"icon\"\n | \"titleFieldId\"\n | \"description\"\n > {\n noValidate?: boolean;\n titleFieldId?: string;\n singularApiName?: never;\n pluralApiName?: never;\n isPrivate: true;\n fields: CmsModelFieldInput[];\n}\n\nexport interface CmsPrivateModelFull\n extends Omit<CmsPrivateModel, \"fields\" | \"createdBy\" | \"createdOn\" | \"savedOn\"> {\n fields: CmsModelFieldBase[];\n}\n\nexport type CmsModelInput = CmsApiModel | CmsPrivateModel | CmsApiModelFull | CmsPrivateModelFull;\n\nexport interface CmsModelPluginModel extends Omit<CmsModelBase, \"tenant\"> {\n tenant?: string;\n}\n\ninterface CmsModelPluginOptions {\n validateLayout?: boolean;\n}\n\nexport class CmsModelPlugin extends Plugin {\n public static override readonly type: string = \"cms-content-model\";\n public readonly contentModel: CmsModelPluginModel;\n\n private readonly options: CmsModelPluginOptions;\n\n constructor(contentModel: CmsModelInput, options?: CmsModelPluginOptions) {\n super();\n this.options = options || {};\n this.contentModel = this.buildModel(contentModel);\n }\n\n private buildModel(input: CmsModelInput): CmsModelPluginModel {\n const isPrivate = input.isPrivate ?? false;\n\n const singularApiName = input.singularApiName\n ? createApiName(input.singularApiName)\n : createApiName(input.name);\n\n const pluralApiName = input.pluralApiName\n ? createApiName(input.pluralApiName)\n : createPluralApiName(input.name);\n\n const modelPlugin: CmsModelPluginModel = {\n group: input.group ?? \"ungrouped\",\n description: \"\",\n fields: [],\n isPlugin: true,\n isPrivate,\n icon: null,\n layout: [],\n modelId: input.modelId,\n name: input.name,\n pluralApiName,\n singularApiName,\n titleFieldId: \"id\"\n };\n\n if (input.noValidate) {\n /**\n * We can safely ignore this error, because we are sure noValidate is not a model field.\n */\n delete input[\"noValidate\"];\n\n return {\n ...modelPlugin,\n ...input,\n // Since `noValidate` is set, we trust the input, and cast to `CmsModelFieldBase`.\n fields: input.fields as CmsModelFieldBase[],\n pluralApiName,\n singularApiName\n };\n }\n\n const model: CmsModelPluginModel = {\n ...modelPlugin,\n ...input,\n pluralApiName,\n singularApiName,\n fields: this.buildFields(input, input.fields)\n };\n this.validateLayout(model);\n return model;\n }\n\n private buildFields(\n model: CmsModelInput,\n inputFields: CmsModelFieldInput[]\n ): CmsModelFieldBase[] {\n if (inputFields.length === 0) {\n throw new WebinyError(\n `Missing fields for the defined model \"${model.modelId}\".`,\n \"MISSING_FIELDS\",\n {\n model\n }\n );\n }\n const fields: CmsModelFieldBase[] = [];\n const storageIdList: string[] = [];\n const fieldIdList: string[] = [];\n for (const input of inputFields) {\n /**\n * Field must contain an fieldId. It is required in the graphql, but lets check it just in case\n */\n if (!(input.fieldId || \"\").trim()) {\n throw new WebinyError(\n `Field's \"storageId\" is not defined for the content model \"${model.modelId}\".`,\n \"FIELD_ID_ERROR\",\n {\n model,\n field: input\n }\n );\n }\n const fieldId = lodashCamelCase(input.fieldId);\n /**\n * FieldID must be in correct pattern.\n */\n if (fieldId.match(/^[0-9]/) !== null) {\n throw new WebinyError(\n `Field's \"fieldId\" does not match correct pattern in the content model \"${model.modelId}\" - cannot start with a number.`,\n \"FIELD_FIELD_ID_ERROR\",\n {\n model,\n field: input\n }\n );\n }\n /**\n * FieldID also must be camelCased.\n */\n if (fieldId !== input.fieldId) {\n throw new WebinyError(\n `Field's \"fieldId\" must be a camel cased string in the content model \"${model.modelId}\".`,\n \"FIELD_FIELD_ID_ERROR\",\n {\n model,\n field: input\n }\n );\n }\n /**\n * ... and fieldId must be unique.\n */\n if (fieldIdList.includes(fieldId)) {\n throw new WebinyError(\n `Field's \"fieldId\" (id: ${input.id}) is not unique in the content model \"${model.modelId}\".`,\n \"FIELD_ID_NOT_UNIQUE_ERROR\",\n {\n model,\n field: input\n }\n );\n }\n\n let storageId = input.storageId;\n if (storageId) {\n try {\n validateStorageId(storageId);\n } catch (e) {\n throw WebinyError.from(e, {\n data: { model, storageId, field: input }\n });\n }\n } else {\n storageId = createFieldStorageId(input);\n }\n\n /**\n * Fields storageId must be unique.\n */\n if (storageIdList.includes(storageId)) {\n throw new WebinyError(\n `Field's \"storageId\" is not unique in the content model \"${model.modelId}\".`,\n \"STORAGE_ID_ERROR\",\n {\n model,\n field: input\n }\n );\n }\n\n /**\n * We can safely ignore error because we are going through the fields and making sure each has storageId.\n */\n // @ts-expect-error\n let settings: BaseCmsModelFieldSettings = input.settings;\n\n const childFields = settings?.fields || [];\n if (input.type === \"object\" && childFields.length > 0) {\n settings = {\n ...(settings || {}),\n fields: this.buildFields(model, childFields)\n };\n }\n\n const field: CmsModelFieldBase = {\n ...input,\n settings,\n storageId\n };\n /**\n * Add all relevant data to arrays.\n */\n fields.push(field);\n storageIdList.push(field.storageId);\n fieldIdList.push(field.fieldId);\n }\n return fields;\n }\n\n private validateLayout(model: CmsModelPluginModel): void {\n /**\n * Only skip validation if option.validateLayout was set as false, explicitly.\n */\n if (this.options.validateLayout === false) {\n return;\n }\n for (const field of model.fields) {\n let total = 0;\n for (const row of model.layout) {\n const count = row.filter(cell => cell === field.id).length;\n total = total + count;\n }\n if (total === 1) {\n continue;\n } else if (total > 1) {\n throw new WebinyError(\n `Field \"${field.id}\" is in more than one layout cell.`,\n \"DUPLICATE_FIELD_IN_LAYOUT\",\n {\n model,\n field\n }\n );\n }\n throw new WebinyError(\n `Missing field \"${field.id}\" in layout.`,\n \"MISSING_FIELD_IN_LAYOUT\",\n {\n model,\n field\n }\n );\n }\n }\n}\n\n/**\n * IMPORTANT! This function should NOT be used outside the `api-headless-cms` package!\n * @internal\n */\nexport const createModelPlugin = (\n model: CmsModelInput,\n options?: CmsModelPluginOptions\n): CmsModelPlugin => {\n return new CmsModelPlugin(model, options);\n};\n\n/**\n * IMPORTANT! This function should NOT be used outside the `api-headless-cms` package!\n * @internal\n */\nexport const createPrivateModelPlugin = (\n input: Omit<CmsPrivateModelFull, \"group\" | \"isPrivate\">\n): CmsModelPlugin => {\n return createModelPlugin(\n {\n authorization: false,\n noValidate: true,\n isPrivate: true,\n group: \"private\",\n ...input\n },\n {\n validateLayout: false\n }\n );\n};\n"],"mappings":"AAAA,OAAOA,WAAW,MAAM,eAAe;AACvC,OAAOC,eAAe,MAAM,qBAAqB;AACjD,OAAOC,SAAS,MAAM,qBAAqB;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,KAAK,GAAG,CAAC,EAAE;QAClB,MAAM,IAAInD,WAAW,CACjB,UAAUwC,KAAK,CAACG,EAAE,oCAAoC,EACtD,2BAA2B,EAC3B;UACIZ,KAAK;UACLS;QACJ,CACJ,CAAC;MACL;MACA,MAAM,IAAIxC,WAAW,CACjB,kBAAkBwC,KAAK,CAACG,EAAE,cAAc,EACxC,yBAAyB,EACzB;QACIZ,KAAK;QACLS;MACJ,CACJ,CAAC;IACL;EACJ;AACJ;;AAEA;AACA;AACA;AACA;AACA,OAAO,MAAMgB,iBAAiB,GAAGA,CAC7BzB,KAAoB,EACpBhB,OAA+B,KACd;EACjB,OAAO,IAAIJ,cAAc,CAACoB,KAAK,EAAEhB,OAAO,CAAC;AAC7C,CAAC;;AAED;AACA;AACA;AACA;AACA,OAAO,MAAM0C,wBAAwB,GACjCxC,KAAuD,IACtC;EACjB,OAAOuC,iBAAiB,CACpB;IACIE,aAAa,EAAE,KAAK;IACpB5B,UAAU,EAAE,IAAI;IAChBZ,SAAS,EAAE,IAAI;IACfI,KAAK,EAAE,SAAS;IAChB,GAAGL;EACP,CAAC,EACD;IACIgB,cAAc,EAAE;EACpB,CACJ,CAAC;AACL,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["WebinyError","lodashCamelCase","camelCase","upperFirst","pluralize","Plugin","createFieldStorageId","validateStorageId","createApiName","name","createPluralApiName","CmsModelPlugin","type","constructor","contentModel","options","buildModel","input","isPrivate","singularApiName","pluralApiName","modelPlugin","group","description","fields","isPlugin","icon","layout","modelId","titleFieldId","noValidate","model","buildFields","validateLayout","inputFields","length","storageIdList","fieldIdList","fieldId","trim","field","match","includes","id","storageId","e","from","data","settings","childFields","push","countFieldInLayout","total","row","cell","Array","isArray","tabs","tab","createModelPlugin","createPrivateModelPlugin","authorization"],"sources":["CmsModelPlugin.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport lodashCamelCase from \"lodash/camelCase.js\";\nimport camelCase from \"lodash/camelCase.js\";\nimport upperFirst from \"lodash/upperFirst.js\";\nimport pluralize from \"pluralize\";\nimport { Plugin } from \"@webiny/plugins\";\nimport type {\n CmsModel as CmsModelBase,\n CmsModelField as CmsModelFieldBase,\n CmsModelFieldSettings as BaseCmsModelFieldSettings\n} from \"~/types/index.js\";\nimport { createFieldStorageId } from \"~/crud/contentModel/createFieldStorageId.js\";\nimport { validateStorageId } from \"~/crud/contentModel/validateStorageId.js\";\n\nconst createApiName = (name: string) => {\n return upperFirst(camelCase(name));\n};\n\nconst createPluralApiName = (name: string) => {\n return pluralize(createApiName(name));\n};\n\ninterface CmsModelFieldSettings extends Omit<BaseCmsModelFieldSettings, \"fields\"> {\n /**\n * Object field has child fields.\n */\n fields?: CmsModelFieldInput[];\n}\n\ninterface CmsModelFieldInput extends Omit<CmsModelFieldBase, \"storageId\" | \"settings\"> {\n /**\n * If defined, it must be camelCased string.\n * This is for backwards compatibility - before fields had storageId.\n *\n * This should only be populated in old model fields.\n * New ones must have this empty.\n */\n storageId?: string;\n /**\n * We must have a possibility to have a nested field defined without the storageId.\n */\n settings?: CmsModelFieldSettings;\n}\n\nexport interface CmsApiModel\n extends Omit<\n CmsModelPluginModel,\n \"isPrivate\" | \"fields\" | \"singularApiName\" | \"pluralApiName\" | \"isPlugin\"\n > {\n isPrivate?: never;\n noValidate?: boolean;\n singularApiName?: string;\n pluralApiName?: string;\n fields: CmsModelFieldInput[];\n}\n\nexport interface CmsApiModelFull extends Omit<CmsApiModel, \"fields\"> {\n fields: CmsModelFieldBase[];\n}\n\ninterface CmsPrivateModel\n extends Omit<\n CmsModelPluginModel,\n | \"isPrivate\"\n | \"singularApiName\"\n | \"pluralApiName\"\n | \"fields\"\n | \"isPlugin\"\n | \"layout\"\n | \"icon\"\n | \"titleFieldId\"\n | \"description\"\n > {\n noValidate?: boolean;\n titleFieldId?: string;\n singularApiName?: never;\n pluralApiName?: never;\n isPrivate: true;\n fields: CmsModelFieldInput[];\n}\n\nexport interface CmsPrivateModelFull\n extends Omit<CmsPrivateModel, \"fields\" | \"createdBy\" | \"createdOn\" | \"savedOn\"> {\n fields: CmsModelFieldBase[];\n}\n\nexport type CmsModelInput = CmsApiModel | CmsPrivateModel | CmsApiModelFull | CmsPrivateModelFull;\n\nexport interface CmsModelPluginModel extends Omit<CmsModelBase, \"tenant\"> {\n tenant?: string;\n}\n\ninterface CmsModelPluginOptions {\n validateLayout?: boolean;\n}\n\nexport class CmsModelPlugin extends Plugin {\n public static override readonly type: string = \"cms-content-model\";\n public readonly contentModel: CmsModelPluginModel;\n\n private readonly options: CmsModelPluginOptions;\n\n constructor(contentModel: CmsModelInput, options?: CmsModelPluginOptions) {\n super();\n this.options = options || {};\n this.contentModel = this.buildModel(contentModel);\n }\n\n private buildModel(input: CmsModelInput): CmsModelPluginModel {\n const isPrivate = input.isPrivate ?? false;\n\n const singularApiName = input.singularApiName\n ? createApiName(input.singularApiName)\n : createApiName(input.name);\n\n const pluralApiName = input.pluralApiName\n ? createApiName(input.pluralApiName)\n : createPluralApiName(input.name);\n\n const modelPlugin: CmsModelPluginModel = {\n group: input.group ?? \"ungrouped\",\n description: \"\",\n fields: [],\n isPlugin: true,\n isPrivate,\n icon: null,\n layout: [],\n modelId: input.modelId,\n name: input.name,\n pluralApiName,\n singularApiName,\n titleFieldId: \"id\"\n };\n\n if (input.noValidate) {\n /**\n * We can safely ignore this error, because we are sure noValidate is not a model field.\n */\n delete input[\"noValidate\"];\n\n return {\n ...modelPlugin,\n ...input,\n // Since `noValidate` is set, we trust the input, and cast to `CmsModelFieldBase`.\n fields: input.fields as CmsModelFieldBase[],\n pluralApiName,\n singularApiName\n };\n }\n\n const model: CmsModelPluginModel = {\n ...modelPlugin,\n ...input,\n pluralApiName,\n singularApiName,\n fields: this.buildFields(input, input.fields)\n };\n this.validateLayout(model);\n return model;\n }\n\n private buildFields(\n model: CmsModelInput,\n inputFields: CmsModelFieldInput[]\n ): CmsModelFieldBase[] {\n if (inputFields.length === 0) {\n throw new WebinyError(\n `Missing fields for the defined model \"${model.modelId}\".`,\n \"MISSING_FIELDS\",\n {\n model\n }\n );\n }\n const fields: CmsModelFieldBase[] = [];\n const storageIdList: string[] = [];\n const fieldIdList: string[] = [];\n for (const input of inputFields) {\n /**\n * Field must contain an fieldId. It is required in the graphql, but lets check it just in case\n */\n if (!(input.fieldId || \"\").trim()) {\n throw new WebinyError(\n `Field's \"storageId\" is not defined for the content model \"${model.modelId}\".`,\n \"FIELD_ID_ERROR\",\n {\n model,\n field: input\n }\n );\n }\n const fieldId = lodashCamelCase(input.fieldId);\n /**\n * FieldID must be in correct pattern.\n */\n if (fieldId.match(/^[0-9]/) !== null) {\n throw new WebinyError(\n `Field's \"fieldId\" does not match correct pattern in the content model \"${model.modelId}\" - cannot start with a number.`,\n \"FIELD_FIELD_ID_ERROR\",\n {\n model,\n field: input\n }\n );\n }\n /**\n * FieldID also must be camelCased.\n */\n if (fieldId !== input.fieldId) {\n throw new WebinyError(\n `Field's \"fieldId\" must be a camel cased string in the content model \"${model.modelId}\".`,\n \"FIELD_FIELD_ID_ERROR\",\n {\n model,\n field: input\n }\n );\n }\n /**\n * ... and fieldId must be unique.\n */\n if (fieldIdList.includes(fieldId)) {\n throw new WebinyError(\n `Field's \"fieldId\" (id: ${input.id}) is not unique in the content model \"${model.modelId}\".`,\n \"FIELD_ID_NOT_UNIQUE_ERROR\",\n {\n model,\n field: input\n }\n );\n }\n\n let storageId = input.storageId;\n if (storageId) {\n try {\n validateStorageId(storageId);\n } catch (e) {\n throw WebinyError.from(e, {\n data: { model, storageId, field: input }\n });\n }\n } else {\n storageId = createFieldStorageId(input);\n }\n\n /**\n * Fields storageId must be unique.\n */\n if (storageIdList.includes(storageId)) {\n throw new WebinyError(\n `Field's \"storageId\" is not unique in the content model \"${model.modelId}\".`,\n \"STORAGE_ID_ERROR\",\n {\n model,\n field: input\n }\n );\n }\n\n /**\n * We can safely ignore error because we are going through the fields and making sure each has storageId.\n */\n // @ts-expect-error\n let settings: BaseCmsModelFieldSettings = input.settings;\n\n const childFields = settings?.fields || [];\n if (input.type === \"object\" && childFields.length > 0) {\n settings = {\n ...(settings || {}),\n fields: this.buildFields(model, childFields)\n };\n }\n\n const field: CmsModelFieldBase = {\n ...input,\n settings,\n storageId\n };\n /**\n * Add all relevant data to arrays.\n */\n fields.push(field);\n storageIdList.push(field.storageId);\n fieldIdList.push(field.fieldId);\n }\n return fields;\n }\n\n private validateLayout(model: CmsModelPluginModel): void {\n /**\n * Only skip validation if option.validateLayout was set as false, explicitly.\n */\n if (this.options.validateLayout === false) {\n return;\n }\n\n const countFieldInLayout = (fieldId: string, layout: any[][]): number => {\n let total = 0;\n for (const row of layout) {\n for (const cell of row) {\n if (typeof cell === \"string\") {\n if (cell === fieldId) {\n total++;\n }\n } else if (cell && typeof cell === \"object\" && Array.isArray(cell.tabs)) {\n for (const tab of cell.tabs) {\n if (Array.isArray(tab.layout)) {\n total += countFieldInLayout(fieldId, tab.layout);\n }\n }\n }\n }\n }\n return total;\n };\n\n for (const field of model.fields) {\n const total = countFieldInLayout(field.id, model.layout);\n if (total === 1) {\n continue;\n } else if (total > 1) {\n throw new WebinyError(\n `Field \"${field.id}\" is in more than one layout cell.`,\n \"DUPLICATE_FIELD_IN_LAYOUT\",\n {\n model,\n field\n }\n );\n }\n throw new WebinyError(\n `Missing field \"${field.id}\" in layout.`,\n \"MISSING_FIELD_IN_LAYOUT\",\n {\n model,\n field\n }\n );\n }\n }\n}\n\n/**\n * IMPORTANT! This function should NOT be used outside the `api-headless-cms` package!\n * @internal\n */\nexport const createModelPlugin = (\n model: CmsModelInput,\n options?: CmsModelPluginOptions\n): CmsModelPlugin => {\n return new CmsModelPlugin(model, options);\n};\n\n/**\n * IMPORTANT! This function should NOT be used outside the `api-headless-cms` package!\n * @internal\n */\nexport const createPrivateModelPlugin = (\n input: Omit<CmsPrivateModelFull, \"group\" | \"isPrivate\">\n): CmsModelPlugin => {\n return createModelPlugin(\n {\n authorization: false,\n noValidate: true,\n isPrivate: true,\n group: \"private\",\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pB;IACIE,aAAa,EAAE,KAAK;IACpB/B,UAAU,EAAE,IAAI;IAChBZ,SAAS,EAAE,IAAI;IACfI,KAAK,EAAE,SAAS;IAChB,GAAGL;EACP,CAAC,EACD;IACIgB,cAAc,EAAE;EACpB,CACJ,CAAC;AACL,CAAC","ignoreList":[]}
@@ -1,4 +1,5 @@
1
1
  import type { CmsModelField } from "../modelField.js";
2
+ import type { CmsModelLayout } from "../../types/index.js";
2
3
  /**
3
4
  * A definition for object field to show possible type of the field in settings.
4
5
  */
@@ -8,6 +9,7 @@ export interface CmsModelObjectField extends CmsModelField {
8
9
  */
9
10
  settings: {
10
11
  fields: CmsModelField[];
12
+ layout?: CmsModelLayout;
11
13
  parents?: string[];
12
14
  };
13
15
  }
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["objectField.ts"],"sourcesContent":["import type { CmsModelField } from \"../modelField.js\";\n\n/**\n * A definition for object field to show possible type of the field in settings.\n */\nexport interface CmsModelObjectField extends CmsModelField {\n /**\n * Settings object for the field. Contains `templates` property.\n */\n settings: {\n fields: CmsModelField[];\n parents?: string[];\n };\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["objectField.ts"],"sourcesContent":["import type { CmsModelField } from \"../modelField.js\";\nimport type { CmsModelLayout } from \"~/types/index.js\";\n\n/**\n * A definition for object field to show possible type of the field in settings.\n */\nexport interface CmsModelObjectField extends CmsModelField {\n /**\n * Settings object for the field. Contains `templates` property.\n */\n settings: {\n fields: CmsModelField[];\n layout?: CmsModelLayout;\n parents?: string[];\n };\n}\n"],"mappings":"","ignoreList":[]}
package/types/model.d.ts CHANGED
@@ -1,6 +1,35 @@
1
1
  import type { CmsIdentity } from "./identity.js";
2
- import type { CmsModelField, CmsModelFieldInput } from "./modelField.js";
2
+ import type { CmsModelField, CmsModelFieldInput, FieldRule } from "./modelField.js";
3
3
  import type { CmsIcon } from "../types/types.js";
4
+ export interface CmsTabLayoutTab {
5
+ id: string;
6
+ label: string;
7
+ icon?: CmsIcon | null;
8
+ layout: CmsModelLayout;
9
+ rules?: FieldRule[];
10
+ }
11
+ export interface CmsTabLayoutDescriptor {
12
+ type: "tabs";
13
+ label: string;
14
+ description?: string | null;
15
+ help?: string | null;
16
+ tabs: CmsTabLayoutTab[];
17
+ rules?: FieldRule[];
18
+ }
19
+ export interface CmsSeparatorLayoutDescriptor {
20
+ type: "separator";
21
+ label: string;
22
+ description: string | null | undefined;
23
+ rules?: FieldRule[];
24
+ }
25
+ export interface CmsAlertLayoutDescriptor {
26
+ type: "alert";
27
+ label: string;
28
+ alertType: "info" | "success" | "warning" | "danger";
29
+ rules?: FieldRule[];
30
+ }
31
+ export type CmsModelLayoutCell = string | CmsTabLayoutDescriptor | CmsSeparatorLayoutDescriptor | CmsAlertLayoutDescriptor;
32
+ export type CmsModelLayout = CmsModelLayoutCell[][];
4
33
  /**
5
34
  * Base CMS Model. Should not be exported and used outside of this package.
6
35
  *
@@ -76,7 +105,7 @@ export interface CmsModel {
76
105
  * ]
77
106
  * ```
78
107
  */
79
- layout: string[][];
108
+ layout: CmsModelLayout;
80
109
  /**
81
110
  * Models can be tagged to give them contextual meaning.
82
111
  */
@@ -161,7 +190,7 @@ export interface CmsModelCreateInput {
161
190
  * ]
162
191
  * ```
163
192
  */
164
- layout?: string[][];
193
+ layout?: CmsModelLayout;
165
194
  /**
166
195
  * Models can be tagged to give them contextual meaning.
167
196
  */
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["model.ts"],"sourcesContent":["import type { CmsIdentity } from \"./identity.js\";\nimport type { CmsModelField, CmsModelFieldInput } from \"./modelField.js\";\nimport type { CmsIcon } from \"~/types/types.js\";\n\n/**\n * Base CMS Model. Should not be exported and used outside of this package.\n *\n * @category Database model\n * @category CmsModel\n */\nexport interface CmsModel {\n /**\n * Name of the content model.\n */\n name: string;\n /**\n * Unique ID for the content model. Created from name if not defined by user.\n */\n modelId: string;\n /**\n * Name of the content model in singular form to be used in the API.\n * example:\n * - Article\n * - Fruit\n * - Vegetable\n * - Car\n */\n singularApiName: string;\n /**\n * Name of the content model in plural form to be used in the API.\n * example:\n * - Articles\n * - Fruits\n * - Vegetables\n * - Cars\n */\n pluralApiName: string;\n /**\n * Model tenant.\n */\n tenant: string;\n /**\n * Model group slug.\n */\n group: string;\n /**\n * Icon for the content model.\n */\n icon: CmsIcon | null;\n /**\n * Description for the content model.\n */\n description: string | null;\n /**\n * Date created\n */\n createdOn?: string;\n /**\n * Date saved. Changes on both save and create.\n */\n savedOn?: string;\n /**\n * CreatedBy object wrapper. Contains id, name and type of the user.\n */\n createdBy?: CmsIdentity;\n /**\n * List of fields defining entry values.\n */\n fields: CmsModelField[];\n /**\n * Admin UI field layout\n *\n * ```ts\n * layout: [\n * [field1id, field2id],\n * [field3id]\n * ]\n * ```\n */\n layout: string[][];\n /**\n * Models can be tagged to give them contextual meaning.\n */\n tags?: string[];\n /**\n * The field that is used as an entry title.\n * If not specified by the user, the system tries to assign the first available `text` field.\n */\n titleFieldId: string;\n /**\n * The field that is used as an entry description.\n * If not set by the user, the system will try to assign the first available `long-text` field.\n */\n descriptionFieldId?: string | null;\n /**\n * The field that is used as an entry image.\n * If not set by the user, the system will try to assign a `file` field which has `imagesOnly` enabled.\n */\n imageFieldId?: string | null;\n\n /**\n * Is model private?\n * This is meant to be used for some internal models - will not be visible in the schema.\n * Only available for the plugin constructed models.\n */\n isPrivate?: boolean;\n\n /**\n * Does this model require authorization to be performed?\n * Only available for models created via plugins.\n */\n authorization?: boolean | CmsModelAuthorization;\n\n /**\n * Is this model created via plugin?\n */\n isPlugin?: boolean;\n}\n\nexport interface CmsModelAuthorization {\n permissions: boolean;\n\n [key: string]: any;\n}\n\n/**\n * A GraphQL `params.data` parameter received when creating content model.\n *\n * @category GraphQL params\n * @category CmsModel\n */\nexport interface CmsModelCreateInput {\n /**\n * Name of the content model.\n */\n name: string;\n /**\n * Singular name of the content model to be used in the API.\n */\n singularApiName: string;\n /**\n * Plural name of the content model to be used in the API.\n */\n pluralApiName: string;\n /**\n * Unique ID of the content model. Created from name if not sent by the user. Cannot be changed.\n */\n modelId?: string;\n /**\n * Description of the content model.\n */\n description?: string | null;\n /**\n * Group where to put the content model in.\n */\n group: string;\n /**\n * A list of content model fields to define the entry values.\n */\n fields?: CmsModelFieldInput[];\n /**\n * Admin UI field layout\n *\n * ```ts\n * layout: [\n * [field1id, field2id],\n * [field3id]\n * ]\n * ```\n */\n layout?: string[][];\n /**\n * Models can be tagged to give them contextual meaning.\n */\n tags?: string[];\n /**\n * Fields fieldId which are picked to represent the CMS entry.\n */\n titleFieldId?: string | null;\n descriptionFieldId?: string | null;\n imageFieldId?: string | null;\n icon?: CmsIcon | null;\n}\n\n/**\n * A GraphQL `params.data` parameter received when creating content model from existing model.\n *\n * @category GraphQL params\n * @category CmsModel\n */\nexport interface CmsModelCreateFromInput extends CmsModelCreateInput {}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["model.ts"],"sourcesContent":["import type { CmsIdentity } from \"./identity.js\";\nimport type { CmsModelField, CmsModelFieldInput, FieldRule } from \"./modelField.js\";\nimport type { CmsIcon } from \"~/types/types.js\";\n\nexport interface CmsTabLayoutTab {\n id: string;\n label: string;\n icon?: CmsIcon | null;\n layout: CmsModelLayout;\n rules?: FieldRule[];\n}\n\nexport interface CmsTabLayoutDescriptor {\n type: \"tabs\";\n label: string;\n description?: string | null;\n help?: string | null;\n tabs: CmsTabLayoutTab[];\n rules?: FieldRule[];\n}\n\nexport interface CmsSeparatorLayoutDescriptor {\n type: \"separator\";\n label: string;\n description: string | null | undefined;\n rules?: FieldRule[];\n}\n\nexport interface CmsAlertLayoutDescriptor {\n type: \"alert\";\n label: string;\n alertType: \"info\" | \"success\" | \"warning\" | \"danger\";\n rules?: FieldRule[];\n}\n\nexport type CmsModelLayoutCell =\n | string\n | CmsTabLayoutDescriptor\n | CmsSeparatorLayoutDescriptor\n | CmsAlertLayoutDescriptor;\nexport type CmsModelLayout = CmsModelLayoutCell[][];\n\n/**\n * Base CMS Model. Should not be exported and used outside of this package.\n *\n * @category Database model\n * @category CmsModel\n */\nexport interface CmsModel {\n /**\n * Name of the content model.\n */\n name: string;\n /**\n * Unique ID for the content model. Created from name if not defined by user.\n */\n modelId: string;\n /**\n * Name of the content model in singular form to be used in the API.\n * example:\n * - Article\n * - Fruit\n * - Vegetable\n * - Car\n */\n singularApiName: string;\n /**\n * Name of the content model in plural form to be used in the API.\n * example:\n * - Articles\n * - Fruits\n * - Vegetables\n * - Cars\n */\n pluralApiName: string;\n /**\n * Model tenant.\n */\n tenant: string;\n /**\n * Model group slug.\n */\n group: string;\n /**\n * Icon for the content model.\n */\n icon: CmsIcon | null;\n /**\n * Description for the content model.\n */\n description: string | null;\n /**\n * Date created\n */\n createdOn?: string;\n /**\n * Date saved. Changes on both save and create.\n */\n savedOn?: string;\n /**\n * CreatedBy object wrapper. Contains id, name and type of the user.\n */\n createdBy?: CmsIdentity;\n /**\n * List of fields defining entry values.\n */\n fields: CmsModelField[];\n /**\n * Admin UI field layout\n *\n * ```ts\n * layout: [\n * [field1id, field2id],\n * [field3id]\n * ]\n * ```\n */\n layout: CmsModelLayout;\n /**\n * Models can be tagged to give them contextual meaning.\n */\n tags?: string[];\n /**\n * The field that is used as an entry title.\n * If not specified by the user, the system tries to assign the first available `text` field.\n */\n titleFieldId: string;\n /**\n * The field that is used as an entry description.\n * If not set by the user, the system will try to assign the first available `long-text` field.\n */\n descriptionFieldId?: string | null;\n /**\n * The field that is used as an entry image.\n * If not set by the user, the system will try to assign a `file` field which has `imagesOnly` enabled.\n */\n imageFieldId?: string | null;\n\n /**\n * Is model private?\n * This is meant to be used for some internal models - will not be visible in the schema.\n * Only available for the plugin constructed models.\n */\n isPrivate?: boolean;\n\n /**\n * Does this model require authorization to be performed?\n * Only available for models created via plugins.\n */\n authorization?: boolean | CmsModelAuthorization;\n\n /**\n * Is this model created via plugin?\n */\n isPlugin?: boolean;\n}\n\nexport interface CmsModelAuthorization {\n permissions: boolean;\n\n [key: string]: any;\n}\n\n/**\n * A GraphQL `params.data` parameter received when creating content model.\n *\n * @category GraphQL params\n * @category CmsModel\n */\nexport interface CmsModelCreateInput {\n /**\n * Name of the content model.\n */\n name: string;\n /**\n * Singular name of the content model to be used in the API.\n */\n singularApiName: string;\n /**\n * Plural name of the content model to be used in the API.\n */\n pluralApiName: string;\n /**\n * Unique ID of the content model. Created from name if not sent by the user. Cannot be changed.\n */\n modelId?: string;\n /**\n * Description of the content model.\n */\n description?: string | null;\n /**\n * Group where to put the content model in.\n */\n group: string;\n /**\n * A list of content model fields to define the entry values.\n */\n fields?: CmsModelFieldInput[];\n /**\n * Admin UI field layout\n *\n * ```ts\n * layout: [\n * [field1id, field2id],\n * [field3id]\n * ]\n * ```\n */\n layout?: CmsModelLayout;\n /**\n * Models can be tagged to give them contextual meaning.\n */\n tags?: string[];\n /**\n * Fields fieldId which are picked to represent the CMS entry.\n */\n titleFieldId?: string | null;\n descriptionFieldId?: string | null;\n imageFieldId?: string | null;\n icon?: CmsIcon | null;\n}\n\n/**\n * A GraphQL `params.data` parameter received when creating content model from existing model.\n *\n * @category GraphQL params\n * @category CmsModel\n */\nexport interface CmsModelCreateFromInput extends CmsModelCreateInput {}\n"],"mappings":"","ignoreList":[]}
@@ -1,6 +1,14 @@
1
- import type { CmsModel } from "./model.js";
1
+ import type { CmsModel, CmsModelLayout } from "./model.js";
2
2
  import type { GenericRecord } from "@webiny/api/types.js";
3
3
  import type { CmsDynamicZoneTemplate } from "../types/fields/dynamicZoneField.js";
4
+ export type FieldRuleAction = "hide" | "disable" | string;
5
+ export interface FieldRule {
6
+ type: "accessControl" | "entryValue";
7
+ target: string;
8
+ operator: string;
9
+ value: string | number | boolean | null;
10
+ action: FieldRuleAction;
11
+ }
4
12
  export type CmsModelFieldType = "boolean" | "datetime" | "file" | "long-text" | "number" | "json" | "object" | "ref" | "rich-text" | "text" | "dynamicZone" | string;
5
13
  export type ICmsModelFieldStorageId = `${string}@${string}` | string;
6
14
  /**
@@ -99,6 +107,10 @@ export interface CmsModelField {
99
107
  * @default {}
100
108
  */
101
109
  settings?: CmsModelFieldSettings;
110
+ /**
111
+ * Rules that control field visibility and editability (access control and entry value conditions).
112
+ */
113
+ rules?: FieldRule[];
102
114
  }
103
115
  /**
104
116
  * A definition for content model field received from the user.
@@ -173,6 +185,10 @@ export interface CmsModelFieldInput {
173
185
  settings?: {
174
186
  [key: string]: any;
175
187
  };
188
+ /**
189
+ * Rules that control field visibility and editability (access control and entry value conditions).
190
+ */
191
+ rules?: FieldRule[];
176
192
  }
177
193
  /**
178
194
  * A GraphQL `params.data` parameter received when updating content model.
@@ -215,7 +231,7 @@ export interface CmsModelUpdateInput {
215
231
  * ]
216
232
  * ```
217
233
  */
218
- layout: string[][];
234
+ layout: CmsModelLayout;
219
235
  /**
220
236
  * Tags for the content model.
221
237
  */
@@ -266,7 +282,7 @@ export interface CmsModelFieldSettings {
266
282
  /**
267
283
  * Object field has child fields - so it needs to have a layout.
268
284
  */
269
- layout?: string[][];
285
+ layout?: CmsModelLayout;
270
286
  /**
271
287
  * Ref field.
272
288
  */
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["modelField.ts"],"sourcesContent":["import type { CmsModel } from \"./model.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\nimport type { CmsDynamicZoneTemplate } from \"~/types/fields/dynamicZoneField.js\";\n\nexport type CmsModelFieldType =\n | \"boolean\"\n | \"datetime\"\n | \"file\"\n | \"long-text\"\n | \"number\"\n | \"json\"\n | \"object\"\n | \"ref\"\n | \"rich-text\"\n | \"text\"\n | \"dynamicZone\"\n | string;\n\nexport type ICmsModelFieldStorageId = `${string}@${string}` | string;\n/**\n * A definition for content model field. This type exists on the app side as well.\n *\n * @category ModelField\n * @category Database model\n */\nexport interface CmsModelField {\n /**\n * A generated unique ID for the model field.\n * MUST be absolute unique throughout the models.\n * Must be in form of a-zA-Z0-9.\n *\n * We generate a unique id value when you're building a model via UI,\n * but when user is creating a model via a plugin it is up to them to be careful about this.\n */\n id: string;\n /**\n * A type of the field.\n * We are defining our built-in fields, so people know which are available by the default.\n */\n type: CmsModelFieldType;\n /**\n * A unique storage ID for storing actual values.\n * Must in form of a-zA-Z0-9@a-zA-Z0-9\n *\n * This is an auto-generated value: uses `id` and `type`\n *\n * This is used as path for the entry value.\n */\n storageId: ICmsModelFieldStorageId;\n /**\n * Field identifier for the model field that will be available to the outside world.\n * `storageId` is used as path (or column) to store the data.\n *\n * Must in form of a-zA-Z0-9.\n *\n * This value MUST be unique in the CmsModel.\n */\n fieldId: string;\n /**\n * A label for the field.\n */\n label: string;\n /**\n * Field description right below the label.\n */\n description?: string | null;\n /**\n * Note displayed below the input.\n */\n note?: string | null;\n /**\n * Text in the tooltip next to the input label.\n */\n help?: string | null;\n /**\n * Placeholder text to be displayed in the field\n */\n placeholder?: string | null;\n /**\n * Are predefined values enabled? And list of them\n */\n predefinedValues?: CmsModelFieldPredefinedValues;\n /**\n * Field renderer. Blank if determined automatically.\n */\n renderer?: CmsModelFieldRenderer | null;\n /**\n * List of validations for the field\n *\n * @default []\n */\n validation: CmsModelFieldValidation[];\n /**\n * List of validations for the list of values, when a field is set to accept a list of values.\n * These validations will be applied to the entire list, and `validation` (see above) will be applied\n * to each individual value in the list.\n *\n * @default []\n */\n listValidation: CmsModelFieldValidation[];\n /**\n * Is this a multiple values field?\n *\n */\n list?: boolean;\n /**\n * Fields can be tagged to give them contextual meaning.\n */\n tags?: string[];\n /**\n * Any user defined settings.\n *\n * @default {}\n */\n settings?: CmsModelFieldSettings;\n}\n\n/**\n * A definition for content model field received from the user.\n *\n * Input type for `CmsModelField`.\n * @see CmsModelField\n *\n * @category GraphQL params\n * @category ModelField\n */\nexport interface CmsModelFieldInput {\n /**\n * Generated ID.\n */\n id: string;\n /**\n * Type of the field. A plugin for the field must be defined.\n * @see CmsModelFieldToGraphQLPlugin\n */\n type: string;\n /**\n * Field outside world identifier for the field. Must be unique in the model.\n */\n fieldId: string;\n /**\n * Label for the field.\n */\n label: string;\n /**\n * Field description right below the label.\n */\n description?: string | null;\n /**\n * Note displayed below the input.\n */\n note?: string | null;\n /**\n * Text in the tooltip next to the input label.\n */\n help?: string | null;\n /**\n * Placeholder text to be displayed in the field\n */\n placeholder?: string | null;\n /**\n * Fields can be tagged to give them contextual meaning.\n */\n tags?: string[];\n /**\n * Are multiple values allowed?\n */\n list?: boolean;\n /**\n * Predefined values options for the field. Check the reference for more information.\n */\n predefinedValues?: CmsModelFieldPredefinedValues;\n /**\n * Renderer options for the field. Check the reference for more information.\n */\n renderer?: CmsModelFieldRenderer | null;\n /**\n * List of validations for the field.\n */\n validation: CmsModelFieldValidation[];\n /**\n * @see CmsModelField.listValidation\n */\n listValidation: CmsModelFieldValidation[];\n /**\n * User defined settings.\n */\n settings?: {\n [key: string]: any;\n };\n}\n\n/**\n * A GraphQL `params.data` parameter received when updating content model.\n *\n * @category GraphQL params\n * @category CmsModel\n */\nexport interface CmsModelUpdateInput {\n /**\n * A new content model name.\n */\n name?: string;\n /**\n * A new singular name of the content model to be used in the API.\n */\n singularApiName?: string;\n /**\n * A new plural name of the content model to be used in the API.\n */\n pluralApiName?: string;\n /**\n * A group we want to move the model to.\n */\n group?: string;\n /**\n * A new description of the content model.\n */\n description?: string | null;\n /**\n * A list of content model fields to define the entry values.\n */\n fields: CmsModelFieldInput[];\n /**\n * Admin UI field layout\n *\n * ```ts\n * layout: [\n * [field1id, field2id],\n * [field3id]\n * ]\n * ```\n */\n layout: string[][];\n /**\n * Tags for the content model.\n */\n tags?: string[];\n /**\n * Fields fieldId which are picked to represent the CMS entry.\n */\n titleFieldId?: string | null;\n descriptionFieldId?: string | null;\n imageFieldId?: string | null;\n}\n\n/**\n * Object containing content model field renderer options.\n *\n * @category CmsModelField\n */\ninterface CmsModelFieldRenderer {\n /**\n * Name of the field renderer. Must have one in field renderer plugins.\n * Can be blank to let automatically determine the renderer.\n */\n name: string;\n /**\n * Renderer settings allow you to configure field renderer on a field level.\n */\n settings?: GenericRecord<string> | null;\n}\n\n/**\n * A definition for content model field settings.\n *\n * @category ModelField\n * @category Database model\n */\nexport interface CmsModelFieldSettings {\n /**\n * Predefined values (text, number)\n * The default value for the field in case it is not predefined values field.\n */\n defaultValue?: string | boolean | number | null | undefined;\n /**\n * Object field has child fields.\n */\n fields?: CmsModelField[];\n /**\n * Is the file field images only one?\n */\n imagesOnly?: boolean;\n /**\n * Object field has child fields - so it needs to have a layout.\n */\n layout?: string[][];\n /**\n * Ref field.\n */\n models?: Pick<CmsModel, \"modelId\">[];\n /**\n * Date field.\n */\n type?: string;\n /**\n * Disable full text search explicitly on this field.\n */\n disableFullTextSearch?: boolean;\n /**\n * Dynamic zone field templates.\n */\n templates?: CmsDynamicZoneTemplate[];\n /**\n * There are a lot of other settings that are possible to add, so we keep the type opened.\n */\n [key: string]: any;\n}\n\n/**\n * Definition for content model field validator.\n *\n * @category ModelField\n * @category FieldValidation\n */\nexport interface CmsModelFieldValidation {\n name: string;\n message: string;\n settings?: {\n value?: string | number;\n values?: string[];\n preset?: string;\n [key: string]: any;\n };\n}\n\n/**\n * Object containing content model field predefined options and values.\n *\n * @category CmsModelField\n */\nexport interface CmsModelFieldPredefinedValues {\n /**\n * Are predefined field values enabled?\n */\n enabled: boolean;\n /**\n * Predefined values array.\n */\n values: CmsModelFieldPredefinedValuesValue[];\n}\n\ninterface CmsModelFieldPredefinedValuesValue {\n value: string;\n label: string;\n /**\n * Default selected predefined value.\n */\n selected?: boolean;\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["modelField.ts"],"sourcesContent":["import type { CmsModel, CmsModelLayout } from \"./model.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\nimport type { CmsDynamicZoneTemplate } from \"~/types/fields/dynamicZoneField.js\";\n\nexport type FieldRuleAction = \"hide\" | \"disable\" | string;\n\nexport interface FieldRule {\n type: \"accessControl\" | \"entryValue\";\n target: string;\n operator: string;\n value: string | number | boolean | null;\n action: FieldRuleAction;\n}\n\nexport type CmsModelFieldType =\n | \"boolean\"\n | \"datetime\"\n | \"file\"\n | \"long-text\"\n | \"number\"\n | \"json\"\n | \"object\"\n | \"ref\"\n | \"rich-text\"\n | \"text\"\n | \"dynamicZone\"\n | string;\n\nexport type ICmsModelFieldStorageId = `${string}@${string}` | string;\n/**\n * A definition for content model field. This type exists on the app side as well.\n *\n * @category ModelField\n * @category Database model\n */\nexport interface CmsModelField {\n /**\n * A generated unique ID for the model field.\n * MUST be absolute unique throughout the models.\n * Must be in form of a-zA-Z0-9.\n *\n * We generate a unique id value when you're building a model via UI,\n * but when user is creating a model via a plugin it is up to them to be careful about this.\n */\n id: string;\n /**\n * A type of the field.\n * We are defining our built-in fields, so people know which are available by the default.\n */\n type: CmsModelFieldType;\n /**\n * A unique storage ID for storing actual values.\n * Must in form of a-zA-Z0-9@a-zA-Z0-9\n *\n * This is an auto-generated value: uses `id` and `type`\n *\n * This is used as path for the entry value.\n */\n storageId: ICmsModelFieldStorageId;\n /**\n * Field identifier for the model field that will be available to the outside world.\n * `storageId` is used as path (or column) to store the data.\n *\n * Must in form of a-zA-Z0-9.\n *\n * This value MUST be unique in the CmsModel.\n */\n fieldId: string;\n /**\n * A label for the field.\n */\n label: string;\n /**\n * Field description right below the label.\n */\n description?: string | null;\n /**\n * Note displayed below the input.\n */\n note?: string | null;\n /**\n * Text in the tooltip next to the input label.\n */\n help?: string | null;\n /**\n * Placeholder text to be displayed in the field\n */\n placeholder?: string | null;\n /**\n * Are predefined values enabled? And list of them\n */\n predefinedValues?: CmsModelFieldPredefinedValues;\n /**\n * Field renderer. Blank if determined automatically.\n */\n renderer?: CmsModelFieldRenderer | null;\n /**\n * List of validations for the field\n *\n * @default []\n */\n validation: CmsModelFieldValidation[];\n /**\n * List of validations for the list of values, when a field is set to accept a list of values.\n * These validations will be applied to the entire list, and `validation` (see above) will be applied\n * to each individual value in the list.\n *\n * @default []\n */\n listValidation: CmsModelFieldValidation[];\n /**\n * Is this a multiple values field?\n *\n */\n list?: boolean;\n /**\n * Fields can be tagged to give them contextual meaning.\n */\n tags?: string[];\n /**\n * Any user defined settings.\n *\n * @default {}\n */\n settings?: CmsModelFieldSettings;\n /**\n * Rules that control field visibility and editability (access control and entry value conditions).\n */\n rules?: FieldRule[];\n}\n\n/**\n * A definition for content model field received from the user.\n *\n * Input type for `CmsModelField`.\n * @see CmsModelField\n *\n * @category GraphQL params\n * @category ModelField\n */\nexport interface CmsModelFieldInput {\n /**\n * Generated ID.\n */\n id: string;\n /**\n * Type of the field. A plugin for the field must be defined.\n * @see CmsModelFieldToGraphQLPlugin\n */\n type: string;\n /**\n * Field outside world identifier for the field. Must be unique in the model.\n */\n fieldId: string;\n /**\n * Label for the field.\n */\n label: string;\n /**\n * Field description right below the label.\n */\n description?: string | null;\n /**\n * Note displayed below the input.\n */\n note?: string | null;\n /**\n * Text in the tooltip next to the input label.\n */\n help?: string | null;\n /**\n * Placeholder text to be displayed in the field\n */\n placeholder?: string | null;\n /**\n * Fields can be tagged to give them contextual meaning.\n */\n tags?: string[];\n /**\n * Are multiple values allowed?\n */\n list?: boolean;\n /**\n * Predefined values options for the field. Check the reference for more information.\n */\n predefinedValues?: CmsModelFieldPredefinedValues;\n /**\n * Renderer options for the field. Check the reference for more information.\n */\n renderer?: CmsModelFieldRenderer | null;\n /**\n * List of validations for the field.\n */\n validation: CmsModelFieldValidation[];\n /**\n * @see CmsModelField.listValidation\n */\n listValidation: CmsModelFieldValidation[];\n /**\n * User defined settings.\n */\n settings?: {\n [key: string]: any;\n };\n /**\n * Rules that control field visibility and editability (access control and entry value conditions).\n */\n rules?: FieldRule[];\n}\n\n/**\n * A GraphQL `params.data` parameter received when updating content model.\n *\n * @category GraphQL params\n * @category CmsModel\n */\nexport interface CmsModelUpdateInput {\n /**\n * A new content model name.\n */\n name?: string;\n /**\n * A new singular name of the content model to be used in the API.\n */\n singularApiName?: string;\n /**\n * A new plural name of the content model to be used in the API.\n */\n pluralApiName?: string;\n /**\n * A group we want to move the model to.\n */\n group?: string;\n /**\n * A new description of the content model.\n */\n description?: string | null;\n /**\n * A list of content model fields to define the entry values.\n */\n fields: CmsModelFieldInput[];\n /**\n * Admin UI field layout\n *\n * ```ts\n * layout: [\n * [field1id, field2id],\n * [field3id]\n * ]\n * ```\n */\n layout: CmsModelLayout;\n /**\n * Tags for the content model.\n */\n tags?: string[];\n /**\n * Fields fieldId which are picked to represent the CMS entry.\n */\n titleFieldId?: string | null;\n descriptionFieldId?: string | null;\n imageFieldId?: string | null;\n}\n\n/**\n * Object containing content model field renderer options.\n *\n * @category CmsModelField\n */\ninterface CmsModelFieldRenderer {\n /**\n * Name of the field renderer. Must have one in field renderer plugins.\n * Can be blank to let automatically determine the renderer.\n */\n name: string;\n /**\n * Renderer settings allow you to configure field renderer on a field level.\n */\n settings?: GenericRecord<string> | null;\n}\n\n/**\n * A definition for content model field settings.\n *\n * @category ModelField\n * @category Database model\n */\nexport interface CmsModelFieldSettings {\n /**\n * Predefined values (text, number)\n * The default value for the field in case it is not predefined values field.\n */\n defaultValue?: string | boolean | number | null | undefined;\n /**\n * Object field has child fields.\n */\n fields?: CmsModelField[];\n /**\n * Is the file field images only one?\n */\n imagesOnly?: boolean;\n /**\n * Object field has child fields - so it needs to have a layout.\n */\n layout?: CmsModelLayout;\n /**\n * Ref field.\n */\n models?: Pick<CmsModel, \"modelId\">[];\n /**\n * Date field.\n */\n type?: string;\n /**\n * Disable full text search explicitly on this field.\n */\n disableFullTextSearch?: boolean;\n /**\n * Dynamic zone field templates.\n */\n templates?: CmsDynamicZoneTemplate[];\n /**\n * There are a lot of other settings that are possible to add, so we keep the type opened.\n */\n [key: string]: any;\n}\n\n/**\n * Definition for content model field validator.\n *\n * @category ModelField\n * @category FieldValidation\n */\nexport interface CmsModelFieldValidation {\n name: string;\n message: string;\n settings?: {\n value?: string | number;\n values?: string[];\n preset?: string;\n [key: string]: any;\n };\n}\n\n/**\n * Object containing content model field predefined options and values.\n *\n * @category CmsModelField\n */\nexport interface CmsModelFieldPredefinedValues {\n /**\n * Are predefined field values enabled?\n */\n enabled: boolean;\n /**\n * Predefined values array.\n */\n values: CmsModelFieldPredefinedValuesValue[];\n}\n\ninterface CmsModelFieldPredefinedValuesValue {\n value: string;\n label: string;\n /**\n * Default selected predefined value.\n */\n selected?: boolean;\n}\n"],"mappings":"","ignoreList":[]}
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":[]}
@@ -19,7 +19,8 @@ export const createModelField = params => {
19
19
  },
20
20
  help = null,
21
21
  placeholder = null,
22
- renderer = null
22
+ renderer = null,
23
+ rules = []
23
24
  } = params;
24
25
 
25
26
  // TODO: ideally, initialFieldId should also be passed through `camelCase` but currently this would break `wbyAco_location` field.
@@ -39,7 +40,8 @@ export const createModelField = params => {
39
40
  predefinedValues,
40
41
  help,
41
42
  placeholder,
42
- renderer
43
+ renderer,
44
+ rules
43
45
  };
44
46
  };
45
47
 
@@ -1 +1 @@
1
- {"version":3,"names":["camelCase","createModelField","params","id","label","fieldId","initialFieldId","storageId","type","tags","settings","listValidation","validation","list","predefinedValues","values","enabled","help","placeholder","renderer"],"sources":["createModelField.ts"],"sourcesContent":["import camelCase from \"lodash/camelCase.js\";\nimport type { CmsModelField, CmsModelFieldValidation } from \"~/types/index.js\";\n\nexport interface CreateModelFieldParams\n extends Omit<CmsModelField, \"id\" | \"storageId\" | \"fieldId\" | \"validation\" | \"listValidation\"> {\n id?: string;\n fieldId?: string;\n storageId?: string;\n validation?: CmsModelFieldValidation[];\n listValidation?: CmsModelFieldValidation[];\n}\n\nexport const createModelField = (params: CreateModelFieldParams): CmsModelField => {\n // We are not just spreading `params` because we want to ensure\n // a default value is set for every property of the model field.\n const {\n id,\n label,\n fieldId: initialFieldId,\n storageId,\n type,\n tags = [],\n settings = {},\n listValidation = [],\n validation = [],\n list = false,\n predefinedValues = {\n values: [],\n enabled: false\n },\n help = null,\n placeholder = null,\n renderer = null\n } = params;\n\n // TODO: ideally, initialFieldId should also be passed through `camelCase` but currently this would break `wbyAco_location` field.\n // TODO: Once this legacy field is removed, we can enable camelCase on the initialFieldId.\n const fieldId = initialFieldId ? initialFieldId : camelCase(label);\n\n return {\n id: id ?? fieldId,\n storageId: storageId ?? `${type}@${id ?? fieldId}`,\n fieldId,\n label,\n type,\n settings,\n tags,\n listValidation,\n validation,\n list,\n predefinedValues,\n help,\n placeholder,\n renderer\n };\n};\n"],"mappings":"AAAA,OAAOA,SAAS,MAAM,qBAAqB;AAY3C,OAAO,MAAMC,gBAAgB,GAAIC,MAA8B,IAAoB;EAC/E;EACA;EACA,MAAM;IACFC,EAAE;IACFC,KAAK;IACLC,OAAO,EAAEC,cAAc;IACvBC,SAAS;IACTC,IAAI;IACJC,IAAI,GAAG,EAAE;IACTC,QAAQ,GAAG,CAAC,CAAC;IACbC,cAAc,GAAG,EAAE;IACnBC,UAAU,GAAG,EAAE;IACfC,IAAI,GAAG,KAAK;IACZC,gBAAgB,GAAG;MACfC,MAAM,EAAE,EAAE;MACVC,OAAO,EAAE;IACb,CAAC;IACDC,IAAI,GAAG,IAAI;IACXC,WAAW,GAAG,IAAI;IAClBC,QAAQ,GAAG;EACf,CAAC,GAAGjB,MAAM;;EAEV;EACA;EACA,MAAMG,OAAO,GAAGC,cAAc,GAAGA,cAAc,GAAGN,SAAS,CAACI,KAAK,CAAC;EAElE,OAAO;IACHD,EAAE,EAAEA,EAAE,IAAIE,OAAO;IACjBE,SAAS,EAAEA,SAAS,IAAI,GAAGC,IAAI,IAAIL,EAAE,IAAIE,OAAO,EAAE;IAClDA,OAAO;IACPD,KAAK;IACLI,IAAI;IACJE,QAAQ;IACRD,IAAI;IACJE,cAAc;IACdC,UAAU;IACVC,IAAI;IACJC,gBAAgB;IAChBG,IAAI;IACJC,WAAW;IACXC;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["camelCase","createModelField","params","id","label","fieldId","initialFieldId","storageId","type","tags","settings","listValidation","validation","list","predefinedValues","values","enabled","help","placeholder","renderer","rules"],"sources":["createModelField.ts"],"sourcesContent":["import camelCase from \"lodash/camelCase.js\";\nimport type { CmsModelField, CmsModelFieldValidation } from \"~/types/index.js\";\n\nexport interface CreateModelFieldParams\n extends Omit<CmsModelField, \"id\" | \"storageId\" | \"fieldId\" | \"validation\" | \"listValidation\"> {\n id?: string;\n fieldId?: string;\n storageId?: string;\n validation?: CmsModelFieldValidation[];\n listValidation?: CmsModelFieldValidation[];\n}\n\nexport const createModelField = (params: CreateModelFieldParams): CmsModelField => {\n // We are not just spreading `params` because we want to ensure\n // a default value is set for every property of the model field.\n const {\n id,\n label,\n fieldId: initialFieldId,\n storageId,\n type,\n tags = [],\n settings = {},\n listValidation = [],\n validation = [],\n list = false,\n predefinedValues = {\n values: [],\n enabled: false\n },\n help = null,\n placeholder = null,\n renderer = null,\n rules = []\n } = params;\n\n // TODO: ideally, initialFieldId should also be passed through `camelCase` but currently this would break `wbyAco_location` field.\n // TODO: Once this legacy field is removed, we can enable camelCase on the initialFieldId.\n const fieldId = initialFieldId ? initialFieldId : camelCase(label);\n\n return {\n id: id ?? fieldId,\n storageId: storageId ?? `${type}@${id ?? fieldId}`,\n fieldId,\n label,\n type,\n settings,\n tags,\n listValidation,\n validation,\n list,\n predefinedValues,\n help,\n placeholder,\n renderer,\n rules\n };\n};\n"],"mappings":"AAAA,OAAOA,SAAS,MAAM,qBAAqB;AAY3C,OAAO,MAAMC,gBAAgB,GAAIC,MAA8B,IAAoB;EAC/E;EACA;EACA,MAAM;IACFC,EAAE;IACFC,KAAK;IACLC,OAAO,EAAEC,cAAc;IACvBC,SAAS;IACTC,IAAI;IACJC,IAAI,GAAG,EAAE;IACTC,QAAQ,GAAG,CAAC,CAAC;IACbC,cAAc,GAAG,EAAE;IACnBC,UAAU,GAAG,EAAE;IACfC,IAAI,GAAG,KAAK;IACZC,gBAAgB,GAAG;MACfC,MAAM,EAAE,EAAE;MACVC,OAAO,EAAE;IACb,CAAC;IACDC,IAAI,GAAG,IAAI;IACXC,WAAW,GAAG,IAAI;IAClBC,QAAQ,GAAG,IAAI;IACfC,KAAK,GAAG;EACZ,CAAC,GAAGlB,MAAM;;EAEV;EACA;EACA,MAAMG,OAAO,GAAGC,cAAc,GAAGA,cAAc,GAAGN,SAAS,CAACI,KAAK,CAAC;EAElE,OAAO;IACHD,EAAE,EAAEA,EAAE,IAAIE,OAAO;IACjBE,SAAS,EAAEA,SAAS,IAAI,GAAGC,IAAI,IAAIL,EAAE,IAAIE,OAAO,EAAE;IAClDA,OAAO;IACPD,KAAK;IACLI,IAAI;IACJE,QAAQ;IACRD,IAAI;IACJE,cAAc;IACdC,UAAU;IACVC,IAAI;IACJC,gBAAgB;IAChBG,IAAI;IACJC,WAAW;IACXC,QAAQ;IACRC;EACJ,CAAC;AACL,CAAC","ignoreList":[]}