@webiny/api-headless-cms 0.0.0-unstable.9e825fd5fb → 0.0.0-unstable.aa00eecd97

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 (135) hide show
  1. package/context.js +4 -3
  2. package/context.js.map +1 -1
  3. package/crud/contentEntry/referenceFieldsMapping.js +34 -5
  4. package/crud/contentEntry/referenceFieldsMapping.js.map +1 -1
  5. package/crud/contentEntry.crud.d.ts +4 -4
  6. package/crud/contentEntry.crud.js +207 -106
  7. package/crud/contentEntry.crud.js.map +1 -1
  8. package/crud/contentModel/beforeDelete.d.ts +1 -1
  9. package/crud/contentModel/beforeDelete.js +1 -5
  10. package/crud/contentModel/beforeDelete.js.map +1 -1
  11. package/crud/contentModel/validation.d.ts +48 -16
  12. package/crud/contentModel/validation.js +2 -2
  13. package/crud/contentModel/validation.js.map +1 -1
  14. package/crud/contentModelGroup.crud.js +1 -7
  15. package/crud/contentModelGroup.crud.js.map +1 -1
  16. package/graphql/checkEndpointAccess.d.ts +2 -0
  17. package/graphql/checkEndpointAccess.js +18 -0
  18. package/graphql/checkEndpointAccess.js.map +1 -0
  19. package/graphql/createRequestBody.d.ts +2 -0
  20. package/graphql/createRequestBody.js +14 -0
  21. package/graphql/createRequestBody.js.map +1 -0
  22. package/graphql/formatErrorPayload.d.ts +1 -0
  23. package/graphql/formatErrorPayload.js +25 -0
  24. package/graphql/formatErrorPayload.js.map +1 -0
  25. package/graphql/generateSchema.js.map +1 -1
  26. package/graphql/getSchema.d.ts +17 -0
  27. package/graphql/getSchema.js +102 -0
  28. package/graphql/getSchema.js.map +1 -0
  29. package/graphql/graphQLHandlerFactory.js +5 -190
  30. package/graphql/graphQLHandlerFactory.js.map +1 -1
  31. package/graphql/handleRequest.d.ts +11 -0
  32. package/graphql/handleRequest.js +81 -0
  33. package/graphql/handleRequest.js.map +1 -0
  34. package/graphql/schema/baseSchema.js +15 -0
  35. package/graphql/schema/baseSchema.js.map +1 -1
  36. package/graphql/schema/createFieldResolvers.d.ts +1 -1
  37. package/graphql/schema/createFieldResolvers.js +6 -12
  38. package/graphql/schema/createFieldResolvers.js.map +1 -1
  39. package/graphql/schema/createFieldTypePluginRecords.d.ts +3 -0
  40. package/graphql/schema/createFieldTypePluginRecords.js +13 -0
  41. package/graphql/schema/createFieldTypePluginRecords.js.map +1 -0
  42. package/graphql/schema/createManageResolvers.js +4 -0
  43. package/graphql/schema/createManageResolvers.js.map +1 -1
  44. package/graphql/schema/createManageSDL.js +34 -26
  45. package/graphql/schema/createManageSDL.js.map +1 -1
  46. package/graphql/schema/createReadSDL.js +22 -19
  47. package/graphql/schema/createReadSDL.js.map +1 -1
  48. package/graphql/schema/resolvers/manage/resolveDelete.d.ts +2 -1
  49. package/graphql/schema/resolvers/manage/resolveDelete.js +13 -3
  50. package/graphql/schema/resolvers/manage/resolveDelete.js.map +1 -1
  51. package/graphql/schema/resolvers/manage/resolveDeleteMultiple.d.ts +7 -0
  52. package/graphql/schema/resolvers/manage/resolveDeleteMultiple.js +20 -0
  53. package/graphql/schema/resolvers/manage/resolveDeleteMultiple.js.map +1 -0
  54. package/graphql/schema/resolvers/manage/resolveGetUniqueFieldValues.d.ts +4 -0
  55. package/graphql/schema/resolvers/manage/resolveGetUniqueFieldValues.js +18 -0
  56. package/graphql/schema/resolvers/manage/resolveGetUniqueFieldValues.js.map +1 -0
  57. package/graphql/schema/schemaPlugins.js +2 -11
  58. package/graphql/schema/schemaPlugins.js.map +1 -1
  59. package/graphqlFields/dynamicZone/dynamicZoneField.d.ts +1 -1
  60. package/graphqlFields/dynamicZone/dynamicZoneField.js +44 -17
  61. package/graphqlFields/dynamicZone/dynamicZoneField.js.map +1 -1
  62. package/graphqlFields/object.js.map +1 -1
  63. package/graphqlFields/ref.js +7 -7
  64. package/graphqlFields/ref.js.map +1 -1
  65. package/index.d.ts +1 -1
  66. package/index.js +13 -9
  67. package/index.js.map +1 -1
  68. package/package.json +35 -35
  69. package/plugins/CmsModelPlugin.d.ts +3 -1
  70. package/plugins/CmsModelPlugin.js +5 -5
  71. package/plugins/CmsModelPlugin.js.map +1 -1
  72. package/plugins/StorageOperationsCmsModelPlugin.d.ts +23 -0
  73. package/plugins/StorageOperationsCmsModelPlugin.js +42 -0
  74. package/plugins/StorageOperationsCmsModelPlugin.js.map +1 -0
  75. package/plugins/index.d.ts +1 -0
  76. package/plugins/index.js +11 -0
  77. package/plugins/index.js.map +1 -1
  78. package/types.d.ts +122 -71
  79. package/types.js +11 -0
  80. package/types.js.map +1 -1
  81. package/utils/converters/valueKeyStorageConverter.d.ts +1 -5
  82. package/utils/converters/valueKeyStorageConverter.js +24 -25
  83. package/utils/converters/valueKeyStorageConverter.js.map +1 -1
  84. package/utils/createTypeFromFields.js +1 -2
  85. package/utils/createTypeFromFields.js.map +1 -1
  86. package/utils/createTypeName.d.ts +0 -2
  87. package/utils/createTypeName.js +2 -10
  88. package/utils/createTypeName.js.map +1 -1
  89. package/utils/getBaseFieldType.d.ts +1 -3
  90. package/utils/getBaseFieldType.js.map +1 -1
  91. package/utils/getEntryDescription.d.ts +1 -1
  92. package/utils/getEntryDescription.js.map +1 -1
  93. package/utils/getEntryImage.d.ts +1 -1
  94. package/utils/getEntryImage.js.map +1 -1
  95. package/utils/getEntryTitle.d.ts +1 -1
  96. package/utils/getEntryTitle.js.map +1 -1
  97. package/utils/renderFields.d.ts +2 -1
  98. package/utils/renderFields.js +2 -1
  99. package/utils/renderFields.js.map +1 -1
  100. package/utils/renderGetFilterFields.d.ts +2 -2
  101. package/utils/renderGetFilterFields.js +7 -20
  102. package/utils/renderGetFilterFields.js.map +1 -1
  103. package/utils/renderInputFields.d.ts +2 -1
  104. package/utils/renderInputFields.js +14 -6
  105. package/utils/renderInputFields.js.map +1 -1
  106. package/utils/renderListFilterFields.d.ts +2 -1
  107. package/utils/renderListFilterFields.js +9 -20
  108. package/utils/renderListFilterFields.js.map +1 -1
  109. package/utils/renderSortEnum.d.ts +2 -1
  110. package/utils/renderSortEnum.js +2 -1
  111. package/utils/renderSortEnum.js.map +1 -1
  112. package/crud/contentModel/createFieldModels.d.ts +0 -2
  113. package/crud/contentModel/createFieldModels.js +0 -26
  114. package/crud/contentModel/createFieldModels.js.map +0 -1
  115. package/crud/contentModel/fieldIdValidation.d.ts +0 -1
  116. package/crud/contentModel/fieldIdValidation.js +0 -25
  117. package/crud/contentModel/fieldIdValidation.js.map +0 -1
  118. package/crud/contentModel/idValidation.d.ts +0 -1
  119. package/crud/contentModel/idValidation.js +0 -22
  120. package/crud/contentModel/idValidation.js.map +0 -1
  121. package/crud/contentModel/models.d.ts +0 -4
  122. package/crud/contentModel/models.js +0 -192
  123. package/crud/contentModel/models.js.map +0 -1
  124. package/crud/contentModel/systemFields.d.ts +0 -1
  125. package/crud/contentModel/systemFields.js +0 -8
  126. package/crud/contentModel/systemFields.js.map +0 -1
  127. package/upgrades/5.33.0/index.d.ts +0 -3
  128. package/upgrades/5.33.0/index.js +0 -182
  129. package/upgrades/5.33.0/index.js.map +0 -1
  130. package/upgrades/index.d.ts +0 -1
  131. package/upgrades/index.js +0 -12
  132. package/upgrades/index.js.map +0 -1
  133. package/utils/pluralizedTypeName.d.ts +0 -1
  134. package/utils/pluralizedTypeName.js +0 -26
  135. package/utils/pluralizedTypeName.js.map +0 -1
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.StorageOperationsCmsModelPlugin = void 0;
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
+ var _plugins = require("@webiny/plugins");
10
+ /**
11
+ * This plugin should be initialized only once and hence the name.
12
+ */
13
+ class StorageOperationsCmsModelPlugin extends _plugins.Plugin {
14
+ constructor(cb) {
15
+ super();
16
+ (0, _defineProperty2.default)(this, "name", "cms.storageOperations.model");
17
+ (0, _defineProperty2.default)(this, "models", {});
18
+ (0, _defineProperty2.default)(this, "cb", void 0);
19
+ this.cb = cb;
20
+ }
21
+ getModel(input) {
22
+ const cacheKey = this.createCacheKey(input);
23
+ if (this.models[cacheKey]) {
24
+ return this.models[cacheKey];
25
+ }
26
+ const model = this.cb(input);
27
+ this.models[cacheKey] = model;
28
+ return model;
29
+ }
30
+
31
+ /**
32
+ * We can cache the converters by having a cache key that is a combination of model ID and savedOn.
33
+ * The models created via the code will not have savedOn, so they will be unknown - and that is ok as they cannot change in the middle of the call.
34
+ *
35
+ * The models created via the CRUD operations might get changed in the middle of the call, so we need to re-create the SO model.
36
+ */
37
+ createCacheKey(model) {
38
+ return [model.tenant, model.locale, model.modelId, model.savedOn || "unknown"].join("#");
39
+ }
40
+ }
41
+ exports.StorageOperationsCmsModelPlugin = StorageOperationsCmsModelPlugin;
42
+ (0, _defineProperty2.default)(StorageOperationsCmsModelPlugin, "type", "cms.storageOperations.model");
@@ -0,0 +1 @@
1
+ {"version":3,"names":["StorageOperationsCmsModelPlugin","Plugin","constructor","cb","getModel","input","cacheKey","createCacheKey","models","model","tenant","locale","modelId","savedOn","join"],"sources":["StorageOperationsCmsModelPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { CmsModel, StorageOperationsCmsModel } from \"~/types\";\n\nexport interface StorageOperationsCmsModelPluginCallable {\n (model: CmsModel): StorageOperationsCmsModel;\n}\n\n/**\n * This plugin should be initialized only once and hence the name.\n */\nexport class StorageOperationsCmsModelPlugin extends Plugin {\n public static override readonly type: string = \"cms.storageOperations.model\";\n public override name = \"cms.storageOperations.model\";\n\n private readonly models: Record<string, StorageOperationsCmsModel> = {};\n private readonly cb: StorageOperationsCmsModelPluginCallable;\n\n public constructor(cb: StorageOperationsCmsModelPluginCallable) {\n super();\n this.cb = cb;\n }\n\n public getModel(input: CmsModel) {\n const cacheKey = this.createCacheKey(input);\n if (this.models[cacheKey]) {\n return this.models[cacheKey];\n }\n const model = this.cb(input);\n\n this.models[cacheKey] = model;\n\n return model;\n }\n\n /**\n * We can cache the converters by having a cache key that is a combination of model ID and savedOn.\n * The models created via the code will not have savedOn, so they will be unknown - and that is ok as they cannot change in the middle of the call.\n *\n * The models created via the CRUD operations might get changed in the middle of the call, so we need to re-create the SO model.\n */\n private createCacheKey(model: CmsModel): string {\n return [model.tenant, model.locale, model.modelId, model.savedOn || \"unknown\"].join(\"#\");\n }\n}\n"],"mappings":";;;;;;;;AAAA;AAOA;AACA;AACA;AACO,MAAMA,+BAA+B,SAASC,eAAM,CAAC;EAOjDC,WAAW,CAACC,EAA2C,EAAE;IAC5D,KAAK,EAAE;IAAC,4CANW,6BAA6B;IAAA,8CAEiB,CAAC,CAAC;IAAA;IAKnE,IAAI,CAACA,EAAE,GAAGA,EAAE;EAChB;EAEOC,QAAQ,CAACC,KAAe,EAAE;IAC7B,MAAMC,QAAQ,GAAG,IAAI,CAACC,cAAc,CAACF,KAAK,CAAC;IAC3C,IAAI,IAAI,CAACG,MAAM,CAACF,QAAQ,CAAC,EAAE;MACvB,OAAO,IAAI,CAACE,MAAM,CAACF,QAAQ,CAAC;IAChC;IACA,MAAMG,KAAK,GAAG,IAAI,CAACN,EAAE,CAACE,KAAK,CAAC;IAE5B,IAAI,CAACG,MAAM,CAACF,QAAQ,CAAC,GAAGG,KAAK;IAE7B,OAAOA,KAAK;EAChB;;EAEA;AACJ;AACA;AACA;AACA;AACA;EACYF,cAAc,CAACE,KAAe,EAAU;IAC5C,OAAO,CAACA,KAAK,CAACC,MAAM,EAAED,KAAK,CAACE,MAAM,EAAEF,KAAK,CAACG,OAAO,EAAEH,KAAK,CAACI,OAAO,IAAI,SAAS,CAAC,CAACC,IAAI,CAAC,GAAG,CAAC;EAC5F;AACJ;AAAC;AAAA,8BAjCYd,+BAA+B,UACO,6BAA6B"}
@@ -5,3 +5,4 @@ export * from "./CmsParametersPlugin";
5
5
  export * from "./CmsModelFieldConverterPlugin";
6
6
  export * from "./CmsGraphQLSchemaPlugin";
7
7
  export * from "./CmsGraphQLSchemaSorterPlugin";
8
+ export * from "./StorageOperationsCmsModelPlugin";
package/plugins/index.js CHANGED
@@ -79,4 +79,15 @@ Object.keys(_CmsGraphQLSchemaSorterPlugin).forEach(function (key) {
79
79
  return _CmsGraphQLSchemaSorterPlugin[key];
80
80
  }
81
81
  });
82
+ });
83
+ var _StorageOperationsCmsModelPlugin = require("./StorageOperationsCmsModelPlugin");
84
+ Object.keys(_StorageOperationsCmsModelPlugin).forEach(function (key) {
85
+ if (key === "default" || key === "__esModule") return;
86
+ if (key in exports && exports[key] === _StorageOperationsCmsModelPlugin[key]) return;
87
+ Object.defineProperty(exports, key, {
88
+ enumerable: true,
89
+ get: function () {
90
+ return _StorageOperationsCmsModelPlugin[key];
91
+ }
92
+ });
82
93
  });
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./CmsGroupPlugin\";\nexport * from \"./CmsModelPlugin\";\nexport * from \"./StorageTransformPlugin\";\nexport * from \"./CmsParametersPlugin\";\nexport * from \"./CmsModelFieldConverterPlugin\";\nexport * from \"./CmsGraphQLSchemaPlugin\";\nexport * from \"./CmsGraphQLSchemaSorterPlugin\";\n"],"mappings":";;;;;AAAA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./CmsGroupPlugin\";\nexport * from \"./CmsModelPlugin\";\nexport * from \"./StorageTransformPlugin\";\nexport * from \"./CmsParametersPlugin\";\nexport * from \"./CmsModelFieldConverterPlugin\";\nexport * from \"./CmsGraphQLSchemaPlugin\";\nexport * from \"./CmsGraphQLSchemaSorterPlugin\";\nexport * from \"./StorageOperationsCmsModelPlugin\";\n"],"mappings":";;;;;AAAA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
package/types.d.ts CHANGED
@@ -118,6 +118,7 @@ export interface CmsModelFieldSettings {
118
118
  */
119
119
  [key: string]: any;
120
120
  }
121
+ export declare type CmsModelFieldType = "boolean" | "datetime" | "file" | "long-text" | "number" | "object" | "ref" | "rich-text" | "text" | "dynamicZone" | string;
121
122
  /**
122
123
  * A definition for content model field. This type exists on the app side as well.
123
124
  *
@@ -138,7 +139,7 @@ export interface CmsModelField {
138
139
  * A type of the field.
139
140
  * We are defining our built-in fields, so people know which are available by the default.
140
141
  */
141
- type: "boolean" | "datetime" | "file" | "long-text" | "number" | "object" | "ref" | "rich-text" | "text" | "dynamicZone" | string;
142
+ type: CmsModelFieldType;
142
143
  /**
143
144
  * A unique storage ID for storing actual values.
144
145
  * Must in form of a-zA-Z0-9@a-zA-Z0-9
@@ -513,6 +514,7 @@ interface CmsModelFieldToGraphQLCreateResolverParams<TField> {
513
514
  graphQLType: string;
514
515
  field: TField;
515
516
  createFieldResolvers: any;
517
+ fieldTypePlugins: CmsFieldTypePlugins;
516
518
  }
517
519
  export interface CmsModelFieldToGraphQLCreateResolver<TField = CmsModelField> {
518
520
  (params: CmsModelFieldToGraphQLCreateResolverParams<TField>): GraphQLFieldResolver | {
@@ -578,24 +580,6 @@ export interface CmsModelFieldToGraphQLPlugin<TField extends CmsModelField = Cms
578
580
  * ```
579
581
  */
580
582
  isSortable: boolean;
581
- /**
582
- * Optional method which creates the storageId.
583
- * Primary use is for the datetime field, but if users has some specific fields, they can customize the storageId to their needs.
584
- *
585
- * ```ts
586
- * createStorageId: ({field}) => {
587
- * if (field.settings.type === "time) {
588
- * return `${field.type}_time@${field.id}`
589
- * }
590
- * // use default method
591
- * return undefined;
592
- * }
593
- * ```
594
- */
595
- createStorageId?: (params: {
596
- model: CmsModel;
597
- field: TField;
598
- }) => string | null | undefined;
599
583
  /**
600
584
  * Read API methods.
601
585
  */
@@ -612,7 +596,6 @@ export interface CmsModelFieldToGraphQLPlugin<TField extends CmsModelField = Cms
612
596
  * ```
613
597
  */
614
598
  createGetFilters?(params: {
615
- model: CmsModel;
616
599
  field: TField;
617
600
  }): string;
618
601
  /**
@@ -632,7 +615,7 @@ export interface CmsModelFieldToGraphQLPlugin<TField extends CmsModelField = Cms
632
615
  * ```
633
616
  */
634
617
  createListFilters?(params: {
635
- model: CmsModel;
618
+ model: Pick<CmsModel, "singularApiName">;
636
619
  field: TField;
637
620
  plugins: CmsFieldTypePlugins;
638
621
  }): string;
@@ -713,7 +696,7 @@ export interface CmsModelFieldToGraphQLPlugin<TField extends CmsModelField = Cms
713
696
  * ```
714
697
  */
715
698
  createListFilters?: (params: {
716
- model: CmsModel;
699
+ model: Pick<CmsModel, "singularApiName">;
717
700
  field: TField;
718
701
  plugins: CmsFieldTypePlugins;
719
702
  }) => string;
@@ -1880,12 +1863,12 @@ export interface CmsEntryMeta {
1880
1863
  export interface OnEntryBeforeCreateTopicParams {
1881
1864
  input: CreateCmsEntryInput;
1882
1865
  entry: CmsEntry;
1883
- model: StorageOperationsCmsModel;
1866
+ model: CmsModel;
1884
1867
  }
1885
1868
  export interface OnEntryAfterCreateTopicParams {
1886
1869
  input: CreateCmsEntryInput;
1887
1870
  entry: CmsEntry;
1888
- model: StorageOperationsCmsModel;
1871
+ model: CmsModel;
1889
1872
  storageEntry: CmsEntry;
1890
1873
  }
1891
1874
  export interface OnEntryCreateErrorTopicParams {
@@ -1901,13 +1884,13 @@ export interface OnEntryRevisionBeforeCreateTopicParams {
1901
1884
  input: CreateFromCmsEntryInput;
1902
1885
  entry: CmsEntry;
1903
1886
  original: CmsEntry;
1904
- model: StorageOperationsCmsModel;
1887
+ model: CmsModel;
1905
1888
  }
1906
1889
  export interface OnEntryRevisionAfterCreateTopicParams {
1907
1890
  input: CreateFromCmsEntryInput;
1908
1891
  entry: CmsEntry;
1909
1892
  original: CmsEntry;
1910
- model: StorageOperationsCmsModel;
1893
+ model: CmsModel;
1911
1894
  storageEntry: CmsEntry;
1912
1895
  }
1913
1896
  export interface OnEntryCreateRevisionErrorTopicParams {
@@ -1924,13 +1907,13 @@ export interface OnEntryBeforeUpdateTopicParams {
1924
1907
  input: UpdateCmsEntryInput;
1925
1908
  original: CmsEntry;
1926
1909
  entry: CmsEntry;
1927
- model: StorageOperationsCmsModel;
1910
+ model: CmsModel;
1928
1911
  }
1929
1912
  export interface OnEntryAfterUpdateTopicParams {
1930
1913
  input: UpdateCmsEntryInput;
1931
1914
  original: CmsEntry;
1932
1915
  entry: CmsEntry;
1933
- model: StorageOperationsCmsModel;
1916
+ model: CmsModel;
1934
1917
  storageEntry: CmsEntry;
1935
1918
  }
1936
1919
  export interface OnEntryUpdateErrorTopicParams {
@@ -1944,45 +1927,45 @@ export interface OnEntryUpdateErrorTopicParams {
1944
1927
  */
1945
1928
  export interface OnEntryBeforePublishTopicParams {
1946
1929
  entry: CmsEntry;
1947
- model: StorageOperationsCmsModel;
1930
+ model: CmsModel;
1948
1931
  }
1949
1932
  export interface OnEntryAfterPublishTopicParams {
1950
1933
  entry: CmsEntry;
1951
- model: StorageOperationsCmsModel;
1934
+ model: CmsModel;
1952
1935
  storageEntry: CmsEntry;
1953
1936
  }
1954
1937
  export interface OnEntryPublishErrorTopicParams {
1955
1938
  error: Error;
1956
1939
  entry: CmsEntry;
1957
- model: StorageOperationsCmsModel;
1940
+ model: CmsModel;
1958
1941
  }
1959
1942
  /**
1960
1943
  * Republish
1961
1944
  */
1962
1945
  export interface OnEntryBeforeRepublishTopicParams {
1963
1946
  entry: CmsEntry;
1964
- model: StorageOperationsCmsModel;
1947
+ model: CmsModel;
1965
1948
  }
1966
1949
  export interface OnEntryAfterRepublishTopicParams {
1967
1950
  entry: CmsEntry;
1968
- model: StorageOperationsCmsModel;
1951
+ model: CmsModel;
1969
1952
  storageEntry: CmsEntry;
1970
1953
  }
1971
1954
  export interface OnEntryRepublishErrorTopicParams {
1972
1955
  error: Error;
1973
1956
  entry: CmsEntry;
1974
- model: StorageOperationsCmsModel;
1957
+ model: CmsModel;
1975
1958
  }
1976
1959
  /**
1977
1960
  * Unpublish
1978
1961
  */
1979
1962
  export interface OnEntryBeforeUnpublishTopicParams {
1980
1963
  entry: CmsEntry;
1981
- model: StorageOperationsCmsModel;
1964
+ model: CmsModel;
1982
1965
  }
1983
1966
  export interface OnEntryAfterUnpublishTopicParams {
1984
1967
  entry: CmsEntry;
1985
- model: StorageOperationsCmsModel;
1968
+ model: CmsModel;
1986
1969
  storageEntry: CmsEntry;
1987
1970
  }
1988
1971
  export interface OnEntryUnpublishErrorTopicParams {
@@ -1992,37 +1975,53 @@ export interface OnEntryUnpublishErrorTopicParams {
1992
1975
  }
1993
1976
  export interface OnEntryBeforeDeleteTopicParams {
1994
1977
  entry: CmsEntry;
1995
- model: StorageOperationsCmsModel;
1978
+ model: CmsModel;
1996
1979
  }
1997
1980
  export interface OnEntryAfterDeleteTopicParams {
1998
1981
  entry: CmsEntry;
1999
- model: StorageOperationsCmsModel;
1982
+ model: CmsModel;
2000
1983
  }
2001
1984
  export interface OnEntryDeleteErrorTopicParams {
2002
1985
  error: Error;
2003
1986
  entry: CmsEntry;
2004
- model: StorageOperationsCmsModel;
1987
+ model: CmsModel;
2005
1988
  }
2006
1989
  export interface OnEntryRevisionBeforeDeleteTopicParams {
2007
1990
  entry: CmsEntry;
2008
- model: StorageOperationsCmsModel;
1991
+ model: CmsModel;
2009
1992
  }
2010
1993
  export interface OnEntryRevisionAfterDeleteTopicParams {
2011
1994
  entry: CmsEntry;
2012
- model: StorageOperationsCmsModel;
1995
+ model: CmsModel;
2013
1996
  }
2014
1997
  export interface OnEntryRevisionDeleteErrorTopicParams {
2015
1998
  error: Error;
2016
1999
  entry: CmsEntry;
2017
- model: StorageOperationsCmsModel;
2000
+ model: CmsModel;
2001
+ }
2002
+ export interface OnEntryBeforeDeleteMultipleTopicParams {
2003
+ model: CmsModel;
2004
+ entries: CmsEntry[];
2005
+ ids: string[];
2006
+ }
2007
+ export interface OnEntryAfterDeleteMultipleTopicParams {
2008
+ model: CmsModel;
2009
+ entries: CmsEntry[];
2010
+ ids: string[];
2011
+ }
2012
+ export interface OnEntryDeleteMultipleErrorTopicParams {
2013
+ model: CmsModel;
2014
+ entries: CmsEntry[];
2015
+ ids: string[];
2016
+ error: Error;
2018
2017
  }
2019
2018
  export interface OnEntryBeforeGetTopicParams {
2020
- model: StorageOperationsCmsModel;
2019
+ model: CmsModel;
2021
2020
  where: CmsEntryListWhere;
2022
2021
  }
2023
2022
  export interface EntryBeforeListTopicParams {
2024
2023
  where: CmsEntryListWhere;
2025
- model: StorageOperationsCmsModel;
2024
+ model: CmsModel;
2026
2025
  }
2027
2026
  /**
2028
2027
  * @category Context
@@ -2046,6 +2045,34 @@ export interface CreateFromCmsEntryInput {
2046
2045
  export interface UpdateCmsEntryInput {
2047
2046
  [key: string]: any;
2048
2047
  }
2048
+ /**
2049
+ * @category Context
2050
+ * @category CmsEntry
2051
+ */
2052
+ export interface GetUniqueFieldValuesParams {
2053
+ where: CmsEntryListWhere;
2054
+ fieldId: string;
2055
+ }
2056
+ /**
2057
+ * @category CmsEntry
2058
+ */
2059
+ export interface CmsDeleteEntryOptions {
2060
+ /**
2061
+ * Runs the delete commands even if the entry is not found in the DynamoDB.
2062
+ * This is to force clean the entry records that might have been left behind a failed delete.
2063
+ */
2064
+ force?: boolean;
2065
+ }
2066
+ /**
2067
+ * @category Context
2068
+ * @category CmsEntry
2069
+ */
2070
+ export interface DeleteMultipleEntriesParams {
2071
+ entries: string[];
2072
+ }
2073
+ export declare type DeleteMultipleEntriesResponse = {
2074
+ id: string;
2075
+ }[];
2049
2076
  /**
2050
2077
  * Cms Entry CRUD methods in the context.
2051
2078
  *
@@ -2056,7 +2083,7 @@ export interface CmsEntryContext {
2056
2083
  /**
2057
2084
  * Get a single content entry for a model.
2058
2085
  */
2059
- getEntry: (model: CmsModel, params: CmsEntryGetParams) => Promise<CmsEntry | null>;
2086
+ getEntry: (model: CmsModel, params: CmsEntryGetParams) => Promise<CmsEntry>;
2060
2087
  /**
2061
2088
  * Get a list of entries for a model by a given ID (revision).
2062
2089
  */
@@ -2068,15 +2095,15 @@ export interface CmsEntryContext {
2068
2095
  /**
2069
2096
  * List entries for a model. Internal method used by get, listLatest and listPublished.
2070
2097
  */
2071
- listEntries: (model: CmsModel, params: CmsEntryListParams) => Promise<[CmsEntry[], CmsEntryMeta]>;
2098
+ listEntries: <T = CmsEntryValues>(model: CmsModel, params: CmsEntryListParams) => Promise<[CmsEntry<T>[], CmsEntryMeta]>;
2072
2099
  /**
2073
2100
  * Lists the latest entries. Used for manage API.
2074
2101
  */
2075
- listLatestEntries: (model: CmsModel, params?: CmsEntryListParams) => Promise<[CmsEntry[], CmsEntryMeta]>;
2102
+ listLatestEntries: <T = CmsEntryValues>(model: CmsModel, params?: CmsEntryListParams) => Promise<[CmsEntry<T>[], CmsEntryMeta]>;
2076
2103
  /**
2077
2104
  * List published entries. Used for read API.
2078
2105
  */
2079
- listPublishedEntries: (model: CmsModel, params?: CmsEntryListParams) => Promise<[CmsEntry[], CmsEntryMeta]>;
2106
+ listPublishedEntries: <T = CmsEntryValues>(model: CmsModel, params?: CmsEntryListParams) => Promise<[CmsEntry<T>[], CmsEntryMeta]>;
2080
2107
  /**
2081
2108
  * List published entries by IDs.
2082
2109
  */
@@ -2109,7 +2136,11 @@ export interface CmsEntryContext {
2109
2136
  /**
2110
2137
  * Delete entry with all its revisions.
2111
2138
  */
2112
- deleteEntry: (model: CmsModel, id: string) => Promise<void>;
2139
+ deleteEntry: (model: CmsModel, id: string, options?: CmsDeleteEntryOptions) => Promise<void>;
2140
+ /**
2141
+ * Delete multiple entries
2142
+ */
2143
+ deleteMultipleEntries: (model: CmsModel, params: DeleteMultipleEntriesParams) => Promise<DeleteMultipleEntriesResponse>;
2113
2144
  /**
2114
2145
  * Publish entry.
2115
2146
  */
@@ -2123,7 +2154,13 @@ export interface CmsEntryContext {
2123
2154
  */
2124
2155
  getEntryRevisions: (model: CmsModel, id: string) => Promise<CmsEntry[]>;
2125
2156
  /**
2126
- * Lifecyle events - deprecated.
2157
+ * List all unique values for a given field.
2158
+ *
2159
+ * @internal
2160
+ */
2161
+ getUniqueFieldValues: (model: CmsModel, params: GetUniqueFieldValuesParams) => Promise<string[]>;
2162
+ /**
2163
+ * Lifecycle events - deprecated.
2127
2164
  */
2128
2165
  /**
2129
2166
  * @deprecated
@@ -2469,11 +2506,11 @@ export interface CmsEntryStorageOperationsDeleteRevisionParams<T extends CmsStor
2469
2506
  latestStorageEntry: T | null;
2470
2507
  }
2471
2508
  export interface CmsEntryStorageOperationsDeleteParams {
2472
- /**
2473
- * Entry that is going to be deleted.
2474
- */
2475
2509
  entry: CmsEntry;
2476
2510
  }
2511
+ export interface CmsEntryStorageOperationsDeleteEntriesParams {
2512
+ entries: string[];
2513
+ }
2477
2514
  export interface CmsEntryStorageOperationsPublishParams<T extends CmsStorageEntry = CmsStorageEntry> {
2478
2515
  /**
2479
2516
  * The modified entry that is going to be saved as published.
@@ -2495,6 +2532,10 @@ export interface CmsEntryStorageOperationsUnpublishParams<T extends CmsStorageEn
2495
2532
  */
2496
2533
  storageEntry: T;
2497
2534
  }
2535
+ export interface CmsEntryStorageOperationsGetUniqueFieldValuesParams {
2536
+ where: CmsEntryListWhere;
2537
+ fieldId: string;
2538
+ }
2498
2539
  export interface CmsEntryStorageOperationsGetByIdsParams {
2499
2540
  ids: readonly string[];
2500
2541
  }
@@ -2551,71 +2592,81 @@ export interface CmsEntryStorageOperations<T extends CmsStorageEntry = CmsStorag
2551
2592
  /**
2552
2593
  * Get all the entries of the ids.
2553
2594
  */
2554
- getByIds: (model: StorageOperationsCmsModel, params: CmsEntryStorageOperationsGetByIdsParams) => Promise<T[]>;
2595
+ getByIds: (model: CmsModel, params: CmsEntryStorageOperationsGetByIdsParams) => Promise<T[]>;
2555
2596
  /**
2556
2597
  * Get all the published entries of the ids.
2557
2598
  */
2558
- getPublishedByIds: (model: StorageOperationsCmsModel, params: CmsEntryStorageOperationsGetPublishedByIdsParams) => Promise<T[]>;
2599
+ getPublishedByIds: (model: CmsModel, params: CmsEntryStorageOperationsGetPublishedByIdsParams) => Promise<T[]>;
2559
2600
  /**
2560
2601
  * Get all the latest entries of the ids.
2561
2602
  */
2562
- getLatestByIds: (model: StorageOperationsCmsModel, params: CmsEntryStorageOperationsGetLatestByIdsParams) => Promise<T[]>;
2603
+ getLatestByIds: (model: CmsModel, params: CmsEntryStorageOperationsGetLatestByIdsParams) => Promise<T[]>;
2563
2604
  /**
2564
2605
  * Get all revisions of the given entry id.
2565
2606
  */
2566
- getRevisions: (model: StorageOperationsCmsModel, params: CmsEntryStorageOperationsGetRevisionsParams) => Promise<T[]>;
2607
+ getRevisions: (model: CmsModel, params: CmsEntryStorageOperationsGetRevisionsParams) => Promise<T[]>;
2567
2608
  /**
2568
2609
  * Get the entry by the given revision id.
2569
2610
  */
2570
- getRevisionById: (model: StorageOperationsCmsModel, params: CmsEntryStorageOperationsGetRevisionParams) => Promise<T | null>;
2611
+ getRevisionById: (model: CmsModel, params: CmsEntryStorageOperationsGetRevisionParams) => Promise<T | null>;
2571
2612
  /**
2572
2613
  * Get the published entry by given entryId.
2573
2614
  */
2574
- getPublishedRevisionByEntryId: (model: StorageOperationsCmsModel, params: CmsEntryStorageOperationsGetPublishedRevisionParams) => Promise<T | null>;
2615
+ getPublishedRevisionByEntryId: (model: CmsModel, params: CmsEntryStorageOperationsGetPublishedRevisionParams) => Promise<T | null>;
2575
2616
  /**
2576
2617
  * Get the latest entry by given entryId.
2577
2618
  */
2578
- getLatestRevisionByEntryId: (model: StorageOperationsCmsModel, params: CmsEntryStorageOperationsGetLatestRevisionParams) => Promise<T | null>;
2619
+ getLatestRevisionByEntryId: (model: CmsModel, params: CmsEntryStorageOperationsGetLatestRevisionParams) => Promise<T | null>;
2579
2620
  /**
2580
2621
  * Get the revision of the entry before given one.
2581
2622
  */
2582
- getPreviousRevision: (model: StorageOperationsCmsModel, params: CmsEntryStorageOperationsGetPreviousRevisionParams) => Promise<T | null>;
2623
+ getPreviousRevision: (model: CmsModel, params: CmsEntryStorageOperationsGetPreviousRevisionParams) => Promise<T | null>;
2583
2624
  /**
2584
2625
  * Gets entry by given params.
2585
2626
  */
2586
- get: (model: StorageOperationsCmsModel, params: CmsEntryStorageOperationsGetParams) => Promise<T | null>;
2627
+ get: (model: CmsModel, params: CmsEntryStorageOperationsGetParams) => Promise<T | null>;
2587
2628
  /**
2588
2629
  * List all entries. Filterable via params.
2589
2630
  */
2590
- list: (model: StorageOperationsCmsModel, params: CmsEntryStorageOperationsListParams) => Promise<CmsEntryStorageOperationsListResponse<T>>;
2631
+ list: (model: CmsModel, params: CmsEntryStorageOperationsListParams) => Promise<CmsEntryStorageOperationsListResponse<T>>;
2591
2632
  /**
2592
2633
  * Create a new entry.
2593
2634
  */
2594
- create: (model: StorageOperationsCmsModel, params: CmsEntryStorageOperationsCreateParams<T>) => Promise<T>;
2635
+ create: (model: CmsModel, params: CmsEntryStorageOperationsCreateParams<T>) => Promise<T>;
2595
2636
  /**
2596
2637
  * Create a new entry from existing one.
2597
2638
  */
2598
- createRevisionFrom: (model: StorageOperationsCmsModel, params: CmsEntryStorageOperationsCreateRevisionFromParams<T>) => Promise<T>;
2639
+ createRevisionFrom: (model: CmsModel, params: CmsEntryStorageOperationsCreateRevisionFromParams<T>) => Promise<T>;
2599
2640
  /**
2600
2641
  * Update existing entry.
2601
2642
  */
2602
- update: (model: StorageOperationsCmsModel, params: CmsEntryStorageOperationsUpdateParams<T>) => Promise<T>;
2643
+ update: (model: CmsModel, params: CmsEntryStorageOperationsUpdateParams<T>) => Promise<T>;
2603
2644
  /**
2604
2645
  * Delete the entry revision.
2605
2646
  */
2606
- deleteRevision: (model: StorageOperationsCmsModel, params: CmsEntryStorageOperationsDeleteRevisionParams<T>) => Promise<void>;
2647
+ deleteRevision: (model: CmsModel, params: CmsEntryStorageOperationsDeleteRevisionParams<T>) => Promise<void>;
2607
2648
  /**
2608
2649
  * Delete the entry.
2609
2650
  */
2610
- delete: (model: StorageOperationsCmsModel, params: CmsEntryStorageOperationsDeleteParams) => Promise<void>;
2651
+ delete: (model: CmsModel, params: CmsEntryStorageOperationsDeleteParams) => Promise<void>;
2652
+ /**
2653
+ * Delete multiple entries, with a limit on how much can be deleted in one call.
2654
+ */
2655
+ deleteMultipleEntries: (model: CmsModel, params: CmsEntryStorageOperationsDeleteEntriesParams) => Promise<void>;
2611
2656
  /**
2612
2657
  * Publish the entry.
2613
2658
  */
2614
- publish: (model: StorageOperationsCmsModel, params: CmsEntryStorageOperationsPublishParams<T>) => Promise<T>;
2659
+ publish: (model: CmsModel, params: CmsEntryStorageOperationsPublishParams<T>) => Promise<T>;
2615
2660
  /**
2616
2661
  * Unpublish the entry.
2617
2662
  */
2618
- unpublish: (model: StorageOperationsCmsModel, params: CmsEntryStorageOperationsUnpublishParams<T>) => Promise<T>;
2663
+ unpublish: (model: CmsModel, params: CmsEntryStorageOperationsUnpublishParams<T>) => Promise<T>;
2664
+ /**
2665
+ * Method to list all the unique values for the given field id.
2666
+ * Simplest use case would be to aggregate tags for some content.
2667
+ * @internal
2668
+ */
2669
+ getUniqueFieldValues: (model: CmsModel, params: CmsEntryStorageOperationsGetUniqueFieldValuesParams) => Promise<string[]>;
2619
2670
  }
2620
2671
  export declare enum CONTENT_ENTRY_STATUS {
2621
2672
  DRAFT = "draft",
@@ -2687,7 +2738,7 @@ export interface HeadlessCmsStorageOperations<C = CmsContext> {
2687
2738
  /**
2688
2739
  * Either attach something from the storage operations or run something in it.
2689
2740
  */
2690
- beforeInit?: (context: C) => Promise<void>;
2741
+ beforeInit: (context: C) => Promise<void>;
2691
2742
  init?: (context: C) => Promise<void>;
2692
2743
  }
2693
2744
  export {};
package/types.js CHANGED
@@ -334,6 +334,17 @@ exports.CONTENT_ENTRY_STATUS = void 0;
334
334
  * @category Context
335
335
  * @category CmsEntry
336
336
  */
337
+ /**
338
+ * @category Context
339
+ * @category CmsEntry
340
+ */
341
+ /**
342
+ * @category CmsEntry
343
+ */
344
+ /**
345
+ * @category Context
346
+ * @category CmsEntry
347
+ */
337
348
  /**
338
349
  * Cms Entry CRUD methods in the context.
339
350
  *