@webiny/api-headless-cms 5.18.3 → 5.19.0-beta.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 (30) hide show
  1. package/content/plugins/crud/contentEntry/afterDelete.d.ts +7 -0
  2. package/content/plugins/crud/contentEntry/afterDelete.js +41 -0
  3. package/content/plugins/crud/contentEntry/markLockedFields.d.ts +7 -3
  4. package/content/plugins/crud/contentEntry/markLockedFields.js +41 -7
  5. package/content/plugins/crud/contentEntry/referenceFieldsMapping.d.ts +12 -0
  6. package/content/plugins/crud/contentEntry/referenceFieldsMapping.js +251 -0
  7. package/content/plugins/crud/contentEntry.crud.d.ts +0 -4
  8. package/content/plugins/crud/contentEntry.crud.js +127 -51
  9. package/content/plugins/crud/contentModel/beforeCreate.js +1 -1
  10. package/content/plugins/crud/index.js +6 -4
  11. package/content/plugins/graphqlFields/ref.js +70 -34
  12. package/content/plugins/modelManager/DefaultCmsModelManager.js +7 -1
  13. package/content/plugins/schema/contentEntries.js +39 -28
  14. package/content/plugins/schema/createManageResolvers.js +6 -2
  15. package/content/plugins/schema/createManageSDL.js +2 -0
  16. package/content/plugins/schema/resolvers/manage/resolveDelete.js +7 -1
  17. package/content/plugins/schema/resolvers/manage/resolveRepublish.d.ts +2 -0
  18. package/content/plugins/schema/resolvers/manage/resolveRepublish.js +21 -0
  19. package/content/plugins/utils/renderSortEnum.js +12 -12
  20. package/content/plugins/validators/patternPlugins/index.js +5 -1
  21. package/content/plugins/validators/patternPlugins/lowerCaseSpace.d.ts +3 -0
  22. package/content/plugins/validators/patternPlugins/lowerCaseSpace.js +17 -0
  23. package/content/plugins/validators/patternPlugins/upperCaseSpace.d.ts +3 -0
  24. package/content/plugins/validators/patternPlugins/upperCaseSpace.js +17 -0
  25. package/index.d.ts +1 -1
  26. package/package.json +24 -23
  27. package/plugins/crud/index.js +20 -2
  28. package/plugins/crud/system.crud.js +25 -7
  29. package/types.d.ts +25 -36
  30. package/types.js +0 -6
@@ -46,7 +46,7 @@ const plugin = context => {
46
46
 
47
47
  input CmsModelEntryInput {
48
48
  modelId: ID!
49
- entryId: ID!
49
+ id: ID!
50
50
  }
51
51
 
52
52
  extend type Query {
@@ -101,7 +101,7 @@ const plugin = context => {
101
101
  async getContentEntry(_, args, context) {
102
102
  const {
103
103
  modelId,
104
- entryId
104
+ id
105
105
  } = args.entry;
106
106
  const models = await context.cms.listModels();
107
107
  const model = models.find(m => m.modelId === modelId);
@@ -114,7 +114,7 @@ const plugin = context => {
114
114
  });
115
115
  }
116
116
 
117
- const [entry] = await context.cms.getEntriesByIds(model, [entryId]);
117
+ const [entry] = await context.cms.getEntriesByIds(model, [id]);
118
118
  return new _handlerGraphql.Response({
119
119
  id: entry.id,
120
120
  model: {
@@ -128,33 +128,44 @@ const plugin = context => {
128
128
 
129
129
  async getContentEntries(_, args, context) {
130
130
  const models = await context.cms.listModels();
131
- const entriesByModel = args.entries.map((ref, index) => {
132
- return {
133
- entryId: ref.entryId,
134
- modelId: ref.modelId,
135
- index
136
- };
131
+ const modelsMap = models.reduce((collection, model) => {
132
+ collection[model.modelId] = model;
133
+ return collection;
134
+ }, {});
135
+ const entriesByModel = args.entries.reduce((collection, ref) => {
136
+ if (!collection[ref.modelId]) {
137
+ collection[ref.modelId] = [];
138
+ } else if (collection[ref.modelId].includes(ref.id) === true) {
139
+ return collection;
140
+ }
141
+
142
+ collection[ref.modelId].push(ref.id);
143
+ return collection;
144
+ }, {});
145
+ const getters = Object.keys(entriesByModel).map(async modelId => {
146
+ return context.cms.getEntriesByIds(modelsMap[modelId], entriesByModel[modelId]);
137
147
  });
138
- const getters = entriesByModel.map(async ({
139
- modelId,
140
- entryId
141
- }) => {
142
- // Get model manager, to get access to CRUD methods
143
- const model = models.find(m => m.modelId === modelId);
144
- const entries = await context.cms.getEntriesByIds(model, [entryId]);
145
- return entries.map(entry => ({
146
- id: entry.id,
147
- model: {
148
- modelId: model.modelId,
149
- name: model.name
150
- },
151
- status: entry.status,
152
- title: (0, _getEntryTitle.getEntryTitle)(model, entry)
148
+
149
+ if (getters.length === 0) {
150
+ return new _handlerGraphql.Response([]);
151
+ }
152
+
153
+ const results = await Promise.all(getters);
154
+ const entries = results.reduce((collection, items) => {
155
+ return collection.concat(items.map(item => {
156
+ const model = modelsMap[item.modelId];
157
+ return {
158
+ id: item.id,
159
+ model: {
160
+ modelId: model.modelId,
161
+ name: model.name
162
+ },
163
+ status: item.status,
164
+ title: (0, _getEntryTitle.getEntryTitle)(model, item)
165
+ };
153
166
  }));
154
- });
155
- return new _handlerGraphql.Response(await Promise.all(getters).then(results => {
156
- return results.reduce((result, item) => result.concat(item), []);
157
- }));
167
+ }, []);
168
+ return new _handlerGraphql.Response(entries);
158
169
  }
159
170
 
160
171
  }
@@ -31,6 +31,8 @@ var _resolveDelete = require("./resolvers/manage/resolveDelete");
31
31
 
32
32
  var _resolvePublish = require("./resolvers/manage/resolvePublish");
33
33
 
34
+ var _resolveRepublish = require("./resolvers/manage/resolveRepublish");
35
+
34
36
  var _resolveUnpublish = require("./resolvers/manage/resolveUnpublish");
35
37
 
36
38
  var _resolveCreateFrom = require("./resolvers/manage/resolveCreateFrom");
@@ -88,6 +90,9 @@ const createManageResolvers = ({
88
90
  [`publish${typeName}`]: (0, _resolvePublish.resolvePublish)({
89
91
  model
90
92
  }),
93
+ [`republish${typeName}`]: (0, _resolveRepublish.resolveRepublish)({
94
+ model
95
+ }),
91
96
  [`unpublish${typeName}`]: (0, _resolveUnpublish.resolveUnpublish)({
92
97
  model
93
98
  }),
@@ -123,8 +128,7 @@ const createManageResolvers = ({
123
128
  },
124
129
 
125
130
  async revisions(entry, _, context) {
126
- const entryId = entry.id.split("#")[0];
127
- const revisions = await context.cms.getEntryRevisions(model, entryId);
131
+ const revisions = await context.cms.getEntryRevisions(model, entry.entryId);
128
132
  return revisions.sort((a, b) => b.version - a.version);
129
133
  }
130
134
 
@@ -139,6 +139,8 @@ const createManageSDL = ({
139
139
  delete${typeName}(revision: ID!): CmsDeleteResponse
140
140
 
141
141
  publish${typeName}(revision: ID!): ${mTypeName}Response
142
+
143
+ republish${typeName}(revision: ID!): ${mTypeName}Response
142
144
 
143
145
  unpublish${typeName}(revision: ID!): ${mTypeName}Response
144
146
 
@@ -7,6 +7,8 @@ exports.resolveDelete = void 0;
7
7
 
8
8
  var _responses = require("@webiny/handler-graphql/responses");
9
9
 
10
+ var _utils = require("@webiny/utils");
11
+
10
12
  const resolveDelete = ({
11
13
  model
12
14
  }) => async (_, {
@@ -15,7 +17,11 @@ const resolveDelete = ({
15
17
  cms
16
18
  }) => {
17
19
  try {
18
- if (revision.includes("#")) {
20
+ const {
21
+ version
22
+ } = (0, _utils.parseIdentifier)(revision);
23
+
24
+ if (version) {
19
25
  await cms.deleteEntryRevision(model, revision);
20
26
  } else {
21
27
  await cms.deleteEntry(model, revision);
@@ -0,0 +1,2 @@
1
+ import { CmsEntryResolverFactory as ResolverFactory } from "../../../../../types";
2
+ export declare const resolveRepublish: ResolverFactory;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.resolveRepublish = void 0;
7
+
8
+ var _responses = require("@webiny/handler-graphql/responses");
9
+
10
+ const resolveRepublish = ({
11
+ model
12
+ }) => async (_, args, context) => {
13
+ try {
14
+ const entry = await context.cms.republishEntry(model, args.revision);
15
+ return new _responses.Response(entry);
16
+ } catch (e) {
17
+ return new _responses.ErrorResponse(e);
18
+ }
19
+ };
20
+
21
+ exports.resolveRepublish = resolveRepublish;
@@ -14,18 +14,18 @@ const renderSortEnum = ({
14
14
  fieldTypePlugins
15
15
  }) => {
16
16
  const sorters = [`id_ASC`, `id_DESC`, "savedOn_ASC", "savedOn_DESC", "createdOn_ASC", "createdOn_DESC"];
17
- const fieldIds = model.fields.filter(f => {
18
- // Every time a client updates content model's fields, we check the type of each field. If a field plugin
19
- // for a particular "field.type" doesn't exist on the backend yet, we throw an error. But still, we also
20
- // want to be careful when accessing the field plugin here too. It is still possible to have a content model
21
- // that contains a field, for which we don't have a plugin registered on the backend. For example, user
22
- // could've just removed the plugin from the backend.
23
- return (0, _get.default)(fieldTypePlugins, `${f.type}.isSortable`);
24
- }).map(f => f.fieldId);
25
- fieldIds.forEach(fieldId => {
26
- sorters.push(`${fieldId}_ASC`);
27
- sorters.push(`${fieldId}_DESC`);
28
- });
17
+
18
+ for (const field of model.fields) {
19
+ const isSortable = (0, _get.default)(fieldTypePlugins, `${field.type}.isSortable`);
20
+
21
+ if (!isSortable) {
22
+ continue;
23
+ }
24
+
25
+ sorters.push(`${field.fieldId}_ASC`);
26
+ sorters.push(`${field.fieldId}_DESC`);
27
+ }
28
+
29
29
  return sorters.join("\n");
30
30
  };
31
31
 
@@ -15,5 +15,9 @@ var _lowerCase = _interopRequireDefault(require("./lowerCase"));
15
15
 
16
16
  var _upperCase = _interopRequireDefault(require("./upperCase"));
17
17
 
18
- var _default = [_email.default, _url.default, _lowerCase.default, _upperCase.default];
18
+ var _lowerCaseSpace = _interopRequireDefault(require("./lowerCaseSpace"));
19
+
20
+ var _upperCaseSpace = _interopRequireDefault(require("./upperCaseSpace"));
21
+
22
+ var _default = [_email.default, _url.default, _lowerCase.default, _upperCase.default, _lowerCaseSpace.default, _upperCaseSpace.default];
19
23
  exports.default = _default;
@@ -0,0 +1,3 @@
1
+ import { CmsModelFieldPatternValidatorPlugin } from "../../../../types";
2
+ declare const plugin: CmsModelFieldPatternValidatorPlugin;
3
+ export default plugin;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ const plugin = {
8
+ type: "cms-model-field-validator-pattern",
9
+ name: "cms-model-field-validator-pattern-lower-case-space",
10
+ pattern: {
11
+ name: "lowerCaseSpace",
12
+ regex: `^([a-z\\s]+)$`,
13
+ flags: ""
14
+ }
15
+ };
16
+ var _default = plugin;
17
+ exports.default = _default;
@@ -0,0 +1,3 @@
1
+ import { CmsModelFieldPatternValidatorPlugin } from "../../../../types";
2
+ declare const plugin: CmsModelFieldPatternValidatorPlugin;
3
+ export default plugin;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ const plugin = {
8
+ type: "cms-model-field-validator-pattern",
9
+ name: "cms-model-field-validator-pattern-upper-case-space",
10
+ pattern: {
11
+ name: "upperCaseSpace",
12
+ regex: `^([A-Z\\s]+)$`,
13
+ flags: ""
14
+ }
15
+ };
16
+ var _default = plugin;
17
+ exports.default = _default;
package/index.d.ts CHANGED
@@ -6,7 +6,7 @@ export declare type AdminContextParams = CreateAdminCrudsParams;
6
6
  export declare const createAdminHeadlessCmsContext: (params: AdminContextParams) => (import("@webiny/handler/plugins/ContextPlugin").ContextPlugin<import("./types").CmsContext> | import("@webiny/api-upgrade").UpgradePlugin<import("./types").CmsContext>[])[];
7
7
  export declare const createAdminHeadlessCmsGraphQL: () => import("@webiny/handler-graphql/types").GraphQLSchemaPlugin<import("@webiny/handler/types").ContextInterface>;
8
8
  export declare type ContentContextParams = CreateContentCrudsParams;
9
- export declare const createContentHeadlessCmsContext: (params: ContentContextParams) => (import("./types").ModelManagerPlugin | import("@webiny/handler/plugins/ContextPlugin").ContextPlugin<import("./types").CmsContext> | import("./types").CmsModelFieldToGraphQLPlugin[] | StorageTransformPlugin<any, any> | (import("./types").CmsModelFieldValidatorPlugin | import("./types").CmsModelFieldPatternValidatorPlugin[])[])[];
9
+ export declare const createContentHeadlessCmsContext: (params: ContentContextParams) => (import("./types").ModelManagerPlugin | import("./types").CmsModelFieldToGraphQLPlugin[] | StorageTransformPlugin<any, any> | import("@webiny/handler/plugins/ContextPlugin").ContextPlugin<import("./types").CmsContext> | (import("./types").CmsModelFieldValidatorPlugin | import("./types").CmsModelFieldPatternValidatorPlugin[])[])[];
10
10
  export declare type ContentGraphQLParams = CreateGraphQLHandlerOptions;
11
11
  export declare const createContentHeadlessCmsGraphQL: (params?: ContentGraphQLParams) => import("@webiny/plugins/types").PluginCollection;
12
12
  export { StorageTransformPlugin };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-headless-cms",
3
- "version": "5.18.3",
3
+ "version": "5.19.0-beta.3",
4
4
  "main": "index.js",
5
5
  "keywords": [
6
6
  "cms:base"
@@ -21,26 +21,27 @@
21
21
  "@babel/runtime": "7.16.3",
22
22
  "@commodo/fields": "1.1.2-beta.20",
23
23
  "@graphql-tools/schema": "7.1.5",
24
- "@webiny/api-file-manager": "5.18.3",
25
- "@webiny/api-i18n": "5.18.3",
26
- "@webiny/api-i18n-content": "5.18.3",
27
- "@webiny/api-i18n-ddb": "5.18.3",
28
- "@webiny/api-security": "5.18.3",
29
- "@webiny/api-tenancy": "5.18.3",
30
- "@webiny/api-upgrade": "5.18.3",
31
- "@webiny/error": "5.18.3",
32
- "@webiny/handler": "5.18.3",
33
- "@webiny/handler-aws": "5.18.3",
34
- "@webiny/handler-db": "5.18.3",
35
- "@webiny/handler-graphql": "5.18.3",
36
- "@webiny/handler-http": "5.18.3",
37
- "@webiny/plugins": "5.18.3",
38
- "@webiny/pubsub": "5.18.3",
39
- "@webiny/utils": "5.18.3",
40
- "@webiny/validation": "5.18.3",
24
+ "@webiny/api-file-manager": "5.19.0-beta.3",
25
+ "@webiny/api-i18n": "5.19.0-beta.3",
26
+ "@webiny/api-i18n-content": "5.19.0-beta.3",
27
+ "@webiny/api-i18n-ddb": "5.19.0-beta.3",
28
+ "@webiny/api-security": "5.19.0-beta.3",
29
+ "@webiny/api-tenancy": "5.19.0-beta.3",
30
+ "@webiny/api-upgrade": "5.19.0-beta.3",
31
+ "@webiny/error": "5.19.0-beta.3",
32
+ "@webiny/handler": "5.19.0-beta.3",
33
+ "@webiny/handler-aws": "5.19.0-beta.3",
34
+ "@webiny/handler-db": "5.19.0-beta.3",
35
+ "@webiny/handler-graphql": "5.19.0-beta.3",
36
+ "@webiny/handler-http": "5.19.0-beta.3",
37
+ "@webiny/plugins": "5.19.0-beta.3",
38
+ "@webiny/pubsub": "5.19.0-beta.3",
39
+ "@webiny/utils": "5.19.0-beta.3",
40
+ "@webiny/validation": "5.19.0-beta.3",
41
41
  "boolean": "3.1.4",
42
42
  "commodo-fields-object": "1.0.6",
43
43
  "dataloader": "2.0.0",
44
+ "dot-prop": "6.0.1",
44
45
  "lodash": "4.17.21",
45
46
  "p-map": "4.0.0",
46
47
  "p-reduce": "2.1.0",
@@ -53,10 +54,10 @@
53
54
  "@babel/core": "^7.5.5",
54
55
  "@babel/preset-env": "^7.5.5",
55
56
  "@babel/preset-flow": "^7.0.0",
56
- "@webiny/api-security-so-ddb": "^5.18.3",
57
- "@webiny/api-tenancy-so-ddb": "^5.18.3",
58
- "@webiny/cli": "^5.18.3",
59
- "@webiny/project-utils": "^5.18.3",
57
+ "@webiny/api-security-so-ddb": "^5.19.0-beta.3",
58
+ "@webiny/api-tenancy-so-ddb": "^5.19.0-beta.3",
59
+ "@webiny/cli": "^5.19.0-beta.3",
60
+ "@webiny/project-utils": "^5.19.0-beta.3",
60
61
  "apollo-graphql": "^0.4.1",
61
62
  "get-yarn-workspaces": "^1.0.2",
62
63
  "graphql": "^14.6.0",
@@ -76,5 +77,5 @@
76
77
  "build": "yarn webiny run build",
77
78
  "watch": "yarn webiny run watch"
78
79
  },
79
- "gitHead": "3ccdb07d10c57086a63eb42ba7484e17bc388297"
80
+ "gitHead": "a1cca819f83172183b907de16fd5746d07d13ad0"
80
81
  }
@@ -17,10 +17,16 @@ var _ContextPlugin = require("@webiny/handler/plugins/ContextPlugin");
17
17
 
18
18
  var _contentModelGroup = require("../../content/plugins/crud/contentModelGroup.crud");
19
19
 
20
+ var _contentModel = require("../../content/plugins/crud/contentModel.crud");
21
+
22
+ var _contentEntry = require("../../content/plugins/crud/contentEntry.crud");
23
+
20
24
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
21
25
 
22
26
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
23
27
 
28
+ const debug = process.env.DEBUG === "true";
29
+
24
30
  const createAdminCruds = params => {
25
31
  const {
26
32
  storageOperations
@@ -31,7 +37,7 @@ const createAdminCruds = params => {
31
37
  * It is to make sure that we load setup context before the CRUD init in our internal code.
32
38
  */
33
39
  if (!context.cms) {
34
- console.log(`Missing initial "cms" on the context. Make sure that you set it up before creating Admin CRUDs.`);
40
+ debug && console.log(`Missing initial "cms" on the context. Make sure that you set it up before creating Admin CRUDs.`);
35
41
  return;
36
42
  }
37
43
 
@@ -51,7 +57,9 @@ const createAdminCruds = params => {
51
57
  context.plugins.register(storageOperations.plugins);
52
58
  }
53
59
 
54
- context.cms = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, context.cms), (0, _system.createSystemCrud)({
60
+ context.cms = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, context.cms), {}, {
61
+ storageOperations
62
+ }, (0, _system.createSystemCrud)({
55
63
  context,
56
64
  getTenant,
57
65
  getIdentity,
@@ -67,6 +75,16 @@ const createAdminCruds = params => {
67
75
  getLocale,
68
76
  getIdentity,
69
77
  storageOperations
78
+ })), (0, _contentModel.createModelsCrud)({
79
+ context,
80
+ getTenant,
81
+ getLocale,
82
+ getIdentity,
83
+ storageOperations
84
+ })), (0, _contentEntry.createContentEntryCrud)({
85
+ context,
86
+ getIdentity,
87
+ storageOperations
70
88
  }));
71
89
 
72
90
  if (!storageOperations.init) {
@@ -161,17 +161,35 @@ const createSystemCrud = params => {
161
161
  }
162
162
 
163
163
  const upgradePlugins = context.plugins.byType("api-upgrade").filter(pl => pl.app === "headless-cms");
164
- const plugin = (0, _apiUpgrade.getApplicablePlugin)({
165
- deployedVersion: context.WEBINY_VERSION,
166
- installedAppVersion: await this.getVersion(),
167
- upgradePlugins,
168
- upgradeToVersion: version
169
- });
170
- await plugin.apply(context);
164
+ const installedAppVersion = await this.getSystemVersion();
165
+ let plugin;
166
+
167
+ try {
168
+ plugin = (0, _apiUpgrade.getApplicablePlugin)({
169
+ deployedVersion: context.WEBINY_VERSION,
170
+ installedAppVersion,
171
+ upgradePlugins,
172
+ upgradeToVersion: version
173
+ });
174
+ } catch (ex) {
175
+ /**
176
+ * We just let the error disappear if is UPGRADE_NOT_AVAILABLE code
177
+ * and rethrow if is not.
178
+ * This is because we want upgrade to pass if there is no plugin available.
179
+ */
180
+ if (ex.code !== _apiUpgrade.ErrorCode.UPGRADE_NOT_AVAILABLE) {
181
+ throw ex;
182
+ }
183
+ }
184
+
185
+ if (plugin) {
186
+ await plugin.apply(context);
187
+ }
171
188
  /**
172
189
  * Store new app version.
173
190
  */
174
191
 
192
+
175
193
  await setVersion(version);
176
194
  return true;
177
195
  }
package/types.d.ts CHANGED
@@ -10,7 +10,7 @@ import { DbContext } from "@webiny/handler-db/types";
10
10
  import { FileManagerContext } from "@webiny/api-file-manager/types";
11
11
  import { UpgradePlugin } from "@webiny/api-upgrade/types";
12
12
  import { Topic } from "@webiny/pubsub/types";
13
- interface BaseCmsValuesObject {
13
+ export interface HeadlessCms extends CmsSettingsContext, CmsSystemContext, CmsGroupContext, CmsModelContext, CmsEntryContext {
14
14
  /**
15
15
  * API type
16
16
  */
@@ -35,8 +35,9 @@ interface BaseCmsValuesObject {
35
35
  * Means this request is a PREVIEW API
36
36
  */
37
37
  PREVIEW: boolean;
38
- }
39
- export interface HeadlessCms extends BaseCmsValuesObject, CmsCrudContextObject {
38
+ /**
39
+ * The storage operations loaded for current context.
40
+ */
40
41
  storageOperations: HeadlessCmsStorageOperations;
41
42
  }
42
43
  /**
@@ -162,11 +163,11 @@ export interface CmsModelDateTimeField extends CmsModelField {
162
163
  * @category ModelField
163
164
  * @category FieldValidation
164
165
  */
165
- export interface CmsModelFieldValidatorValidateParams {
166
+ export interface CmsModelFieldValidatorValidateParams<T = any> {
166
167
  /**
167
168
  * A value to be validated.
168
169
  */
169
- value: any;
170
+ value: T;
170
171
  /**
171
172
  * Options from the CmsModelField validations.
172
173
  *
@@ -1254,6 +1255,16 @@ export interface CmsModelContext {
1254
1255
  * @category CmsEntry
1255
1256
  */
1256
1257
  declare type CmsEntryStatus = "published" | "unpublished" | "reviewRequested" | "changesRequested" | "draft";
1258
+ export interface CmsEntryListWhereRef {
1259
+ id?: string;
1260
+ id_in?: string[];
1261
+ id_not?: string;
1262
+ id_not_in?: string[];
1263
+ entryId?: string;
1264
+ entryId_not?: string;
1265
+ entryId_in?: string[];
1266
+ entryId_not_in?: string[];
1267
+ }
1257
1268
  /**
1258
1269
  * Entry listing where params.
1259
1270
  *
@@ -1316,7 +1327,10 @@ export interface CmsEntryListWhere {
1316
1327
  * @internal
1317
1328
  */
1318
1329
  latest?: boolean;
1319
- [key: string]: any;
1330
+ /**
1331
+ * Can be reference field or, actually, anything else.
1332
+ */
1333
+ [key: string]: any | CmsEntryListWhereRef;
1320
1334
  }
1321
1335
  /**
1322
1336
  * Entry listing sort.
@@ -1511,6 +1525,11 @@ export interface CmsEntryContext {
1511
1525
  * Update existing entry.
1512
1526
  */
1513
1527
  updateEntry: (model: CmsModel, id: string, data?: Record<string, any>) => Promise<CmsEntry>;
1528
+ /**
1529
+ * Method that republishes entry with given identifier.
1530
+ * @internal
1531
+ */
1532
+ republishEntry: (model: CmsModel, id: string) => Promise<CmsEntry>;
1514
1533
  /**
1515
1534
  * Delete only a certain revision of the entry.
1516
1535
  */
@@ -1563,14 +1582,6 @@ export interface CmsEntryContext {
1563
1582
  onBeforeEntryGet: Topic<BeforeEntryGetTopicParams>;
1564
1583
  onBeforeEntryList: Topic<BeforeEntryListTopicParams>;
1565
1584
  }
1566
- /**
1567
- * A cms part of the context that has all the CRUD operations.
1568
- *
1569
- * @category Context
1570
- */
1571
- interface CmsCrudContextObject extends CmsSettingsContext, CmsSystemContext, CmsGroupContext, CmsModelContext, CmsEntryContext {
1572
- storageOperations: HeadlessCmsStorageOperations;
1573
- }
1574
1585
  /**
1575
1586
  * Parameters for CmsEntryResolverFactory.
1576
1587
  *
@@ -1936,51 +1947,30 @@ export interface CmsEntryStorageOperationsRequestReviewParams<T extends CmsStora
1936
1947
  */
1937
1948
  originalStorageEntry: T;
1938
1949
  }
1939
- export interface CmsEntryStorageOperationsGetAllRevisionsParams {
1940
- ids: readonly string[];
1941
- tenant: string;
1942
- locale: string;
1943
- }
1944
1950
  export interface CmsEntryStorageOperationsGetByIdsParams {
1945
1951
  ids: readonly string[];
1946
- tenant: string;
1947
- locale: string;
1948
1952
  }
1949
1953
  export interface CmsEntryStorageOperationsGetLatestByIdsParams {
1950
1954
  ids: readonly string[];
1951
- tenant: string;
1952
- locale: string;
1953
1955
  }
1954
1956
  export interface CmsEntryStorageOperationsGetPublishedByIdsParams {
1955
1957
  ids: readonly string[];
1956
- tenant: string;
1957
- locale: string;
1958
1958
  }
1959
1959
  export interface CmsEntryStorageOperationsGetRevisionsParams {
1960
1960
  id: string;
1961
- tenant: string;
1962
- locale: string;
1963
1961
  }
1964
1962
  export interface CmsEntryStorageOperationsGetRevisionParams {
1965
1963
  id: string;
1966
- tenant: string;
1967
- locale: string;
1968
1964
  }
1969
1965
  export interface CmsEntryStorageOperationsGetPublishedRevisionParams {
1970
1966
  id: string;
1971
- tenant: string;
1972
- locale: string;
1973
1967
  }
1974
1968
  export interface CmsEntryStorageOperationsGetLatestRevisionParams {
1975
1969
  id: string;
1976
- tenant: string;
1977
- locale: string;
1978
1970
  }
1979
1971
  export interface CmsEntryStorageOperationsGetPreviousRevisionParams {
1980
1972
  entryId: string;
1981
1973
  version: number;
1982
- tenant: string;
1983
- locale: string;
1984
1974
  }
1985
1975
  export interface CmsEntryStorageOperationsListResponse<T extends CmsStorageEntry = CmsStorageEntry> {
1986
1976
  /**
@@ -2029,7 +2019,6 @@ export interface CmsEntryStorageOperations<T extends CmsStorageEntry = CmsStorag
2029
2019
  /**
2030
2020
  * Get all revisions of all of the given IDs.
2031
2021
  */
2032
- getAllRevisionsByIds: (model: CmsModel, params: CmsEntryStorageOperationsGetAllRevisionsParams) => Promise<T[]>;
2033
2022
  /**
2034
2023
  * Get the entry by the given revision id.
2035
2024
  */
package/types.js CHANGED
@@ -291,12 +291,6 @@ exports.CONTENT_ENTRY_STATUS = void 0;
291
291
  * @category CmsEntry
292
292
  */
293
293
 
294
- /**
295
- * A cms part of the context that has all the CRUD operations.
296
- *
297
- * @category Context
298
- */
299
-
300
294
  /**
301
295
  * Parameters for CmsEntryResolverFactory.
302
296
  *