@webiny/api-aco 5.39.0-beta.1 → 5.39.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/apps/AcoApp.js +6 -19
  2. package/apps/AcoApp.js.map +1 -1
  3. package/apps/AcoApps.js +4 -7
  4. package/apps/AcoApps.js.map +1 -1
  5. package/createAcoContext.js +13 -11
  6. package/createAcoContext.js.map +1 -1
  7. package/createAcoGraphQL.js +1 -0
  8. package/createAcoGraphQL.js.map +1 -1
  9. package/createAcoModels.js +1 -17
  10. package/createAcoModels.js.map +1 -1
  11. package/createAcoStorageOperations.d.ts +0 -1
  12. package/createAcoStorageOperations.js +6 -6
  13. package/createAcoStorageOperations.js.map +1 -1
  14. package/filter/filter.gql.js +4 -1
  15. package/filter/filter.gql.js.map +1 -1
  16. package/filter/filter.model.d.ts +1 -3
  17. package/filter/filter.model.js +4 -6
  18. package/filter/filter.model.js.map +1 -1
  19. package/filter/filter.so.js +29 -27
  20. package/filter/filter.so.js.map +1 -1
  21. package/filter/filter.types.d.ts +1 -1
  22. package/filter/filter.types.js.map +1 -1
  23. package/folder/folder.crud.js +6 -9
  24. package/folder/folder.crud.js.map +1 -1
  25. package/folder/folder.gql.js +4 -1
  26. package/folder/folder.gql.js.map +1 -1
  27. package/folder/folder.model.d.ts +1 -3
  28. package/folder/folder.model.js +4 -6
  29. package/folder/folder.model.js.map +1 -1
  30. package/folder/folder.so.js +31 -19
  31. package/folder/folder.so.js.map +1 -1
  32. package/folder/folder.types.d.ts +5 -2
  33. package/folder/folder.types.js.map +1 -1
  34. package/index.d.ts +1 -1
  35. package/index.js +1 -2
  36. package/index.js.map +1 -1
  37. package/package.json +25 -26
  38. package/plugins/AcoAppModifierPlugin.js +1 -4
  39. package/plugins/AcoAppModifierPlugin.js.map +1 -1
  40. package/plugins/AcoAppRegisterPlugin.js +1 -4
  41. package/plugins/AcoAppRegisterPlugin.js.map +1 -1
  42. package/record/graphql/createAppResolvers.js +5 -7
  43. package/record/graphql/createAppResolvers.js.map +1 -1
  44. package/record/graphql/createAppSchema.js +7 -4
  45. package/record/graphql/createAppSchema.js.map +1 -1
  46. package/record/record.model.d.ts +1 -3
  47. package/record/record.model.js +4 -6
  48. package/record/record.model.js.map +1 -1
  49. package/record/record.so.js +32 -22
  50. package/record/record.so.js.map +1 -1
  51. package/record/record.types.d.ts +2 -2
  52. package/record/record.types.js.map +1 -1
  53. package/types.d.ts +4 -1
  54. package/types.js.map +1 -1
  55. package/utils/FolderLevelPermissions.js +15 -23
  56. package/utils/FolderLevelPermissions.js.map +1 -1
  57. package/utils/decorators/CmsEntriesCrudDecorators.js +17 -71
  58. package/utils/decorators/CmsEntriesCrudDecorators.js.map +1 -1
  59. package/utils/decorators/createFolderType.d.ts +2 -0
  60. package/utils/decorators/createFolderType.js +18 -0
  61. package/utils/decorators/createFolderType.js.map +1 -0
  62. package/utils/decorators/filterEntriesByFolderFactory.d.ts +6 -0
  63. package/utils/decorators/filterEntriesByFolderFactory.js +37 -0
  64. package/utils/decorators/filterEntriesByFolderFactory.js.map +1 -0
  65. package/utils/decorators/isPageModel.d.ts +5 -0
  66. package/utils/decorators/isPageModel.js +20 -0
  67. package/utils/decorators/isPageModel.js.map +1 -0
  68. package/utils/decorators/where.d.ts +2 -1
  69. package/utils/decorators/where.js +30 -15
  70. package/utils/decorators/where.js.map +1 -1
  71. package/utils/modelFactory.d.ts +1 -3
  72. package/utils/modelFactory.js +4 -9
  73. package/utils/modelFactory.js.map +1 -1
  74. package/utils/pickEntryFieldValues.d.ts +3 -0
  75. package/utils/pickEntryFieldValues.js +31 -0
  76. package/utils/pickEntryFieldValues.js.map +1 -0
  77. package/utils/resolve.d.ts +1 -1
  78. package/fields/index.d.ts +0 -2
  79. package/fields/index.js +0 -14
  80. package/fields/index.js.map +0 -1
  81. package/fields/location.d.ts +0 -2
  82. package/fields/location.js +0 -46
  83. package/fields/location.js.map +0 -1
  84. package/utils/fieldResolver.d.ts +0 -16
  85. package/utils/fieldResolver.js +0 -46
  86. package/utils/fieldResolver.js.map +0 -1
  87. package/utils/getFieldValues.d.ts +0 -7
  88. package/utils/getFieldValues.js +0 -24
  89. package/utils/getFieldValues.js.map +0 -1
@@ -1,88 +1,41 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
6
  exports.CmsEntriesCrudDecorators = void 0;
8
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
9
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
- var _handlerGraphql = require("@webiny/handler-graphql");
11
7
  var _where = require("./where");
12
8
  var _constants = require("./constants");
13
- /**
14
- * Keep this until we figure out how to fetch the folders.
15
- */
16
- const isPageModel = model => {
17
- if (model.modelId === "pbPage") {
18
- return true;
19
- } else if (model.modelId === "acoSearchRecord-pbpage") {
20
- return true;
21
- }
22
- return false;
23
- };
24
- const createFolderType = model => {
25
- if (model.modelId === "fmFile") {
26
- return "FmFile";
27
- } else if (isPageModel(model)) {
28
- return "PbPage";
29
- }
30
- return `cms:${model.modelId}`;
31
- };
32
- const filterEntriesByFolderFactory = (context, permissions) => {
33
- return async (model, entries) => {
34
- const [folders] = await context.aco.folder.listAll({
35
- where: {
36
- type: createFolderType(model)
37
- }
38
- });
39
- const results = await Promise.all(entries.map(async entry => {
40
- var _entry$location;
41
- const folderId = (_entry$location = entry.location) === null || _entry$location === void 0 ? void 0 : _entry$location.folderId;
42
- if (!folderId || folderId === _constants.ROOT_FOLDER) {
43
- return entry;
44
- }
45
- const folder = folders.find(folder => folder.id === folderId);
46
- if (!folder) {
47
- throw new _handlerGraphql.NotFoundError(`Folder "${folderId}" not found.`);
48
- }
49
- const result = await permissions.canAccessFolderContent({
50
- folder,
51
- rwd: "r"
52
- });
53
- return result ? entry : null;
54
- }));
55
- return results.filter(entry => !!entry);
56
- };
57
- };
9
+ var _filterEntriesByFolderFactory = require("./filterEntriesByFolderFactory");
10
+ var _createFolderType = require("./createFolderType");
58
11
  class CmsEntriesCrudDecorators {
59
12
  constructor({
60
13
  context
61
14
  }) {
62
- (0, _defineProperty2.default)(this, "context", void 0);
63
15
  this.context = context;
64
16
  }
65
17
  decorate() {
66
18
  const context = this.context;
67
19
  const folderLevelPermissions = context.aco.folderLevelPermissions;
68
- const filterEntriesByFolder = filterEntriesByFolderFactory(context, folderLevelPermissions);
20
+ const filterEntriesByFolder = (0, _filterEntriesByFolderFactory.filterEntriesByFolderFactory)(context, folderLevelPermissions);
69
21
  const originalCmsListEntries = context.cms.listEntries.bind(context.cms);
70
22
  context.cms.listEntries = async (model, params) => {
71
- const folderType = createFolderType(model);
23
+ const folderType = (0, _createFolderType.createFolderType)(model);
72
24
  const folders = await folderLevelPermissions.listAllFoldersWithPermissions(folderType);
73
25
  const where = (0, _where.createWhere)({
26
+ model,
74
27
  where: params.where,
75
28
  folders
76
29
  });
77
- return originalCmsListEntries(model, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
30
+ return originalCmsListEntries(model, {
31
+ ...params,
78
32
  where
79
- }));
33
+ });
80
34
  };
81
35
  const originalCmsGetEntry = context.cms.getEntry.bind(context.cms);
82
36
  context.cms.getEntry = async (model, params) => {
83
- var _entry$location2;
84
37
  const entry = await originalCmsGetEntry(model, params);
85
- const folderId = entry === null || entry === void 0 || (_entry$location2 = entry.location) === null || _entry$location2 === void 0 ? void 0 : _entry$location2.folderId;
38
+ const folderId = entry?.location?.folderId;
86
39
  if (!folderId || folderId === _constants.ROOT_FOLDER) {
87
40
  return entry;
88
41
  }
@@ -95,9 +48,8 @@ class CmsEntriesCrudDecorators {
95
48
  };
96
49
  const originalCmsGetEntryById = context.cms.getEntryById.bind(context.cms);
97
50
  context.cms.getEntryById = async (model, params) => {
98
- var _entry$location3;
99
51
  const entry = await originalCmsGetEntryById(model, params);
100
- const folderId = entry === null || entry === void 0 || (_entry$location3 = entry.location) === null || _entry$location3 === void 0 ? void 0 : _entry$location3.folderId;
52
+ const folderId = entry?.location?.folderId;
101
53
  if (!folderId || folderId === _constants.ROOT_FOLDER) {
102
54
  return entry;
103
55
  }
@@ -120,8 +72,7 @@ class CmsEntriesCrudDecorators {
120
72
  };
121
73
  const originalCmsCreateEntry = context.cms.createEntry.bind(context.cms);
122
74
  context.cms.createEntry = async (model, params, options) => {
123
- var _params$wbyAco_locati, _params$location;
124
- const folderId = ((_params$wbyAco_locati = params.wbyAco_location) === null || _params$wbyAco_locati === void 0 ? void 0 : _params$wbyAco_locati.folderId) || ((_params$location = params.location) === null || _params$location === void 0 ? void 0 : _params$location.folderId);
75
+ const folderId = params.wbyAco_location?.folderId || params.location?.folderId;
125
76
  if (!folderId || folderId === _constants.ROOT_FOLDER) {
126
77
  return originalCmsCreateEntry(model, params, options);
127
78
  }
@@ -134,11 +85,10 @@ class CmsEntriesCrudDecorators {
134
85
  };
135
86
  const originalCmsCreateFromEntry = context.cms.createEntryRevisionFrom.bind(context.cms);
136
87
  context.cms.createEntryRevisionFrom = async (model, id, input, options) => {
137
- var _entry$location4;
138
88
  const entry = await context.cms.storageOperations.entries.getRevisionById(model, {
139
89
  id
140
90
  });
141
- const folderId = entry === null || entry === void 0 || (_entry$location4 = entry.location) === null || _entry$location4 === void 0 ? void 0 : _entry$location4.folderId;
91
+ const folderId = entry?.location?.folderId;
142
92
  if (!folderId || folderId === _constants.ROOT_FOLDER) {
143
93
  return originalCmsCreateFromEntry(model, id, input, options);
144
94
  }
@@ -151,11 +101,10 @@ class CmsEntriesCrudDecorators {
151
101
  };
152
102
  const originalCmsUpdateEntry = context.cms.updateEntry.bind(context.cms);
153
103
  context.cms.updateEntry = async (model, id, input, meta, options) => {
154
- var _entry$location5;
155
104
  const entry = await context.cms.storageOperations.entries.getRevisionById(model, {
156
105
  id
157
106
  });
158
- const folderId = entry === null || entry === void 0 || (_entry$location5 = entry.location) === null || _entry$location5 === void 0 ? void 0 : _entry$location5.folderId;
107
+ const folderId = entry?.location?.folderId;
159
108
  if (!folderId || folderId === _constants.ROOT_FOLDER) {
160
109
  return originalCmsUpdateEntry(model, id, input, meta, options);
161
110
  }
@@ -168,11 +117,10 @@ class CmsEntriesCrudDecorators {
168
117
  };
169
118
  const originalCmsDeleteEntry = context.cms.deleteEntry.bind(context.cms);
170
119
  context.cms.deleteEntry = async (model, id, options) => {
171
- var _entry$location6;
172
- const entry = await context.cms.storageOperations.entries.getRevisionById(model, {
120
+ const entry = await context.cms.storageOperations.entries.getLatestRevisionByEntryId(model, {
173
121
  id
174
122
  });
175
- const folderId = entry === null || entry === void 0 || (_entry$location6 = entry.location) === null || _entry$location6 === void 0 ? void 0 : _entry$location6.folderId;
123
+ const folderId = entry?.location?.folderId;
176
124
  if (!folderId || folderId === _constants.ROOT_FOLDER) {
177
125
  return originalCmsDeleteEntry(model, id, options);
178
126
  }
@@ -185,11 +133,10 @@ class CmsEntriesCrudDecorators {
185
133
  };
186
134
  const originalCmsDeleteEntryRevision = context.cms.deleteEntryRevision.bind(context.cms);
187
135
  context.cms.deleteEntryRevision = async (model, id) => {
188
- var _entry$location7;
189
136
  const entry = await context.cms.storageOperations.entries.getRevisionById(model, {
190
137
  id
191
138
  });
192
- const folderId = entry === null || entry === void 0 || (_entry$location7 = entry.location) === null || _entry$location7 === void 0 ? void 0 : _entry$location7.folderId;
139
+ const folderId = entry?.location?.folderId;
193
140
  if (!folderId || folderId === _constants.ROOT_FOLDER) {
194
141
  return originalCmsDeleteEntryRevision(model, id);
195
142
  }
@@ -202,14 +149,13 @@ class CmsEntriesCrudDecorators {
202
149
  };
203
150
  const originalCmsMoveEntry = context.cms.moveEntry.bind(context.cms);
204
151
  context.cms.moveEntry = async (model, id, targetFolderId) => {
205
- var _entry$location8;
206
152
  /**
207
153
  * First we need to check if user has access to the entries existing folder.
208
154
  */
209
155
  const entry = await context.cms.storageOperations.entries.getRevisionById(model, {
210
156
  id
211
157
  });
212
- const folderId = (entry === null || entry === void 0 || (_entry$location8 = entry.location) === null || _entry$location8 === void 0 ? void 0 : _entry$location8.folderId) || _constants.ROOT_FOLDER;
158
+ const folderId = entry?.location?.folderId || _constants.ROOT_FOLDER;
213
159
  /**
214
160
  * If the entry is in the same folder we are trying to move it to, just continue.
215
161
  */
@@ -1 +1 @@
1
- {"version":3,"names":["_handlerGraphql","require","_where","_constants","isPageModel","model","modelId","createFolderType","filterEntriesByFolderFactory","context","permissions","entries","folders","aco","folder","listAll","where","type","results","Promise","all","map","entry","_entry$location","folderId","location","ROOT_FOLDER","find","id","NotFoundError","result","canAccessFolderContent","rwd","filter","CmsEntriesCrudDecorators","constructor","_defineProperty2","default","decorate","folderLevelPermissions","filterEntriesByFolder","originalCmsListEntries","cms","listEntries","bind","params","folderType","listAllFoldersWithPermissions","createWhere","_objectSpread2","originalCmsGetEntry","getEntry","_entry$location2","get","ensureCanAccessFolderContent","originalCmsGetEntryById","getEntryById","_entry$location3","originalGetLatestEntriesByIds","getLatestEntriesByIds","ids","originalGetPublishedEntriesByIds","getPublishedEntriesByIds","originalCmsCreateEntry","createEntry","options","_params$wbyAco_locati","_params$location","wbyAco_location","originalCmsCreateFromEntry","createEntryRevisionFrom","input","_entry$location4","storageOperations","getRevisionById","originalCmsUpdateEntry","updateEntry","meta","_entry$location5","originalCmsDeleteEntry","deleteEntry","_entry$location6","originalCmsDeleteEntryRevision","deleteEntryRevision","_entry$location7","originalCmsMoveEntry","moveEntry","targetFolderId","_entry$location8","exports"],"sources":["CmsEntriesCrudDecorators.ts"],"sourcesContent":["import { AcoContext } from \"~/types\";\nimport { CmsEntry, CmsModel } from \"@webiny/api-headless-cms/types\";\nimport { NotFoundError } from \"@webiny/handler-graphql\";\nimport { FolderLevelPermissions } from \"~/utils/FolderLevelPermissions\";\nimport { createWhere } from \"./where\";\nimport { ROOT_FOLDER } from \"./constants\";\n\ntype Context = Pick<AcoContext, \"aco\" | \"cms\">;\n/**\n * Keep this until we figure out how to fetch the folders.\n */\nconst isPageModel = (model: CmsModel): boolean => {\n if (model.modelId === \"pbPage\") {\n return true;\n } else if (model.modelId === \"acoSearchRecord-pbpage\") {\n return true;\n }\n return false;\n};\n\nconst createFolderType = (model: CmsModel): \"FmFile\" | \"PbPage\" | `cms:${string}` => {\n if (model.modelId === \"fmFile\") {\n return \"FmFile\";\n } else if (isPageModel(model)) {\n return \"PbPage\";\n }\n return `cms:${model.modelId}`;\n};\n\nconst filterEntriesByFolderFactory = (context: Context, permissions: FolderLevelPermissions) => {\n return async (model: CmsModel, entries: CmsEntry[]) => {\n const [folders] = await context.aco.folder.listAll({\n where: {\n type: createFolderType(model)\n }\n });\n\n const results = await Promise.all(\n entries.map(async entry => {\n const folderId = entry.location?.folderId;\n if (!folderId || folderId === ROOT_FOLDER) {\n return entry;\n }\n\n const folder = folders.find(folder => folder.id === folderId);\n if (!folder) {\n throw new NotFoundError(`Folder \"${folderId}\" not found.`);\n }\n const result = await permissions.canAccessFolderContent({\n folder,\n rwd: \"r\"\n });\n return result ? entry : null;\n })\n );\n\n return results.filter((entry): entry is CmsEntry => !!entry);\n };\n};\n\ninterface EntryManagerCrudDecoratorsParams {\n context: Context;\n}\n\nexport class CmsEntriesCrudDecorators {\n private readonly context: Context;\n\n public constructor({ context }: EntryManagerCrudDecoratorsParams) {\n this.context = context;\n }\n\n public decorate() {\n const context = this.context;\n const folderLevelPermissions = context.aco.folderLevelPermissions;\n\n const filterEntriesByFolder = filterEntriesByFolderFactory(context, folderLevelPermissions);\n\n const originalCmsListEntries = context.cms.listEntries.bind(context.cms);\n context.cms.listEntries = async (model, params) => {\n const folderType = createFolderType(model);\n const folders = await folderLevelPermissions.listAllFoldersWithPermissions(folderType);\n\n const where = createWhere({\n where: params.where,\n folders\n });\n return originalCmsListEntries(model, {\n ...params,\n where\n });\n };\n\n const originalCmsGetEntry = context.cms.getEntry.bind(context.cms);\n context.cms.getEntry = async (model, params) => {\n const entry = await originalCmsGetEntry(model, params);\n\n const folderId = entry?.location?.folderId;\n if (!folderId || folderId === ROOT_FOLDER) {\n return entry;\n }\n\n const folder = await context.aco.folder.get(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n folder,\n rwd: \"r\"\n });\n\n return entry;\n };\n\n const originalCmsGetEntryById = context.cms.getEntryById.bind(context.cms);\n context.cms.getEntryById = async (model, params) => {\n const entry = await originalCmsGetEntryById(model, params);\n\n const folderId = entry?.location?.folderId;\n if (!folderId || folderId === ROOT_FOLDER) {\n return entry;\n }\n const folder = await context.aco.folder.get(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n folder,\n rwd: \"r\"\n });\n return entry;\n };\n\n const originalGetLatestEntriesByIds = context.cms.getLatestEntriesByIds.bind(context.cms);\n context.cms.getLatestEntriesByIds = async (model, ids) => {\n const entries = await originalGetLatestEntriesByIds(model, ids);\n\n return filterEntriesByFolder(model, entries);\n };\n\n const originalGetPublishedEntriesByIds = context.cms.getPublishedEntriesByIds.bind(\n context.cms\n );\n context.cms.getPublishedEntriesByIds = async (model, ids) => {\n const entries = await originalGetPublishedEntriesByIds(model, ids);\n return filterEntriesByFolder(model, entries);\n };\n\n const originalCmsCreateEntry = context.cms.createEntry.bind(context.cms);\n context.cms.createEntry = async (model, params, options) => {\n const folderId = params.wbyAco_location?.folderId || params.location?.folderId;\n\n if (!folderId || folderId === ROOT_FOLDER) {\n return originalCmsCreateEntry(model, params, options);\n }\n\n const folder = await context.aco.folder.get(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n folder,\n rwd: \"w\"\n });\n\n return originalCmsCreateEntry(model, params, options);\n };\n\n const originalCmsCreateFromEntry = context.cms.createEntryRevisionFrom.bind(context.cms);\n context.cms.createEntryRevisionFrom = async (model, id, input, options) => {\n const entry = await context.cms.storageOperations.entries.getRevisionById(model, {\n id\n });\n\n const folderId = entry?.location?.folderId;\n if (!folderId || folderId === ROOT_FOLDER) {\n return originalCmsCreateFromEntry(model, id, input, options);\n }\n\n const folder = await context.aco.folder.get(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n folder,\n rwd: \"w\"\n });\n\n return originalCmsCreateFromEntry(model, id, input, options);\n };\n\n const originalCmsUpdateEntry = context.cms.updateEntry.bind(context.cms);\n context.cms.updateEntry = async (model, id, input, meta, options) => {\n const entry = await context.cms.storageOperations.entries.getRevisionById(model, {\n id\n });\n\n const folderId = entry?.location?.folderId;\n if (!folderId || folderId === ROOT_FOLDER) {\n return originalCmsUpdateEntry(model, id, input, meta, options);\n }\n\n const folder = await context.aco.folder.get(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n folder,\n rwd: \"w\"\n });\n\n return originalCmsUpdateEntry(model, id, input, meta, options);\n };\n\n const originalCmsDeleteEntry = context.cms.deleteEntry.bind(context.cms);\n context.cms.deleteEntry = async (model, id, options) => {\n const entry = await context.cms.storageOperations.entries.getRevisionById(model, {\n id\n });\n\n const folderId = entry?.location?.folderId;\n if (!folderId || folderId === ROOT_FOLDER) {\n return originalCmsDeleteEntry(model, id, options);\n }\n\n const folder = await context.aco.folder.get(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n folder,\n rwd: \"d\"\n });\n\n return originalCmsDeleteEntry(model, id, options);\n };\n\n const originalCmsDeleteEntryRevision = context.cms.deleteEntryRevision.bind(context.cms);\n context.cms.deleteEntryRevision = async (model, id) => {\n const entry = await context.cms.storageOperations.entries.getRevisionById(model, {\n id\n });\n\n const folderId = entry?.location?.folderId;\n if (!folderId || folderId === ROOT_FOLDER) {\n return originalCmsDeleteEntryRevision(model, id);\n }\n\n const folder = await context.aco.folder.get(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n folder,\n rwd: \"d\"\n });\n\n return originalCmsDeleteEntryRevision(model, id);\n };\n\n const originalCmsMoveEntry = context.cms.moveEntry.bind(context.cms);\n context.cms.moveEntry = async (model, id, targetFolderId) => {\n /**\n * First we need to check if user has access to the entries existing folder.\n */\n const entry = await context.cms.storageOperations.entries.getRevisionById(model, {\n id\n });\n const folderId = entry?.location?.folderId || ROOT_FOLDER;\n /**\n * If the entry is in the same folder we are trying to move it to, just continue.\n */\n if (folderId === targetFolderId) {\n return originalCmsMoveEntry(model, id, targetFolderId);\n } else if (folderId !== ROOT_FOLDER) {\n /**\n * If entry current folder is not a root, check for access\n */\n const folder = await context.aco.folder.get(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n folder,\n rwd: \"w\"\n });\n }\n /**\n * If target folder is not a ROOT_FOLDER, check for access.\n */\n if (targetFolderId !== ROOT_FOLDER) {\n const folder = await context.aco.folder.get(targetFolderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n folder,\n rwd: \"w\"\n });\n }\n\n return originalCmsMoveEntry(model, id, targetFolderId);\n };\n }\n}\n"],"mappings":";;;;;;;;;AAEA,IAAAA,eAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AAGA;AACA;AACA;AACA,MAAMG,WAAW,GAAIC,KAAe,IAAc;EAC9C,IAAIA,KAAK,CAACC,OAAO,KAAK,QAAQ,EAAE;IAC5B,OAAO,IAAI;EACf,CAAC,MAAM,IAAID,KAAK,CAACC,OAAO,KAAK,wBAAwB,EAAE;IACnD,OAAO,IAAI;EACf;EACA,OAAO,KAAK;AAChB,CAAC;AAED,MAAMC,gBAAgB,GAAIF,KAAe,IAA4C;EACjF,IAAIA,KAAK,CAACC,OAAO,KAAK,QAAQ,EAAE;IAC5B,OAAO,QAAQ;EACnB,CAAC,MAAM,IAAIF,WAAW,CAACC,KAAK,CAAC,EAAE;IAC3B,OAAO,QAAQ;EACnB;EACA,OAAQ,OAAMA,KAAK,CAACC,OAAQ,EAAC;AACjC,CAAC;AAED,MAAME,4BAA4B,GAAGA,CAACC,OAAgB,EAAEC,WAAmC,KAAK;EAC5F,OAAO,OAAOL,KAAe,EAAEM,OAAmB,KAAK;IACnD,MAAM,CAACC,OAAO,C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AE;QACT,CAAC,CAAC;MACN;MAEA,OAAOqD,oBAAoB,CAAChF,KAAK,EAAEuB,EAAE,EAAE2D,cAAc,CAAC;IAC1D,CAAC;EACL;AACJ;AAACE,OAAA,CAAAvD,wBAAA,GAAAA,wBAAA"}
1
+ {"version":3,"names":["_where","require","_constants","_filterEntriesByFolderFactory","_createFolderType","CmsEntriesCrudDecorators","constructor","context","decorate","folderLevelPermissions","aco","filterEntriesByFolder","filterEntriesByFolderFactory","originalCmsListEntries","cms","listEntries","bind","model","params","folderType","createFolderType","folders","listAllFoldersWithPermissions","where","createWhere","originalCmsGetEntry","getEntry","entry","folderId","location","ROOT_FOLDER","folder","get","ensureCanAccessFolderContent","rwd","originalCmsGetEntryById","getEntryById","originalGetLatestEntriesByIds","getLatestEntriesByIds","ids","entries","originalGetPublishedEntriesByIds","getPublishedEntriesByIds","originalCmsCreateEntry","createEntry","options","wbyAco_location","originalCmsCreateFromEntry","createEntryRevisionFrom","id","input","storageOperations","getRevisionById","originalCmsUpdateEntry","updateEntry","meta","originalCmsDeleteEntry","deleteEntry","getLatestRevisionByEntryId","originalCmsDeleteEntryRevision","deleteEntryRevision","originalCmsMoveEntry","moveEntry","targetFolderId","exports"],"sources":["CmsEntriesCrudDecorators.ts"],"sourcesContent":["import { AcoContext } from \"~/types\";\nimport { createWhere } from \"./where\";\nimport { ROOT_FOLDER } from \"./constants\";\nimport { filterEntriesByFolderFactory } from \"./filterEntriesByFolderFactory\";\nimport { createFolderType } from \"./createFolderType\";\n\ntype Context = Pick<AcoContext, \"aco\" | \"cms\">;\n\ninterface EntryManagerCrudDecoratorsParams {\n context: Context;\n}\n\nexport class CmsEntriesCrudDecorators {\n private readonly context: Context;\n\n public constructor({ context }: EntryManagerCrudDecoratorsParams) {\n this.context = context;\n }\n\n public decorate() {\n const context = this.context;\n const folderLevelPermissions = context.aco.folderLevelPermissions;\n\n const filterEntriesByFolder = filterEntriesByFolderFactory(context, folderLevelPermissions);\n\n const originalCmsListEntries = context.cms.listEntries.bind(context.cms);\n context.cms.listEntries = async (model, params) => {\n const folderType = createFolderType(model);\n const folders = await folderLevelPermissions.listAllFoldersWithPermissions(folderType);\n\n const where = createWhere({\n model,\n where: params.where,\n folders\n });\n return originalCmsListEntries(model, {\n ...params,\n where\n });\n };\n\n const originalCmsGetEntry = context.cms.getEntry.bind(context.cms);\n context.cms.getEntry = async (model, params) => {\n const entry = await originalCmsGetEntry(model, params);\n\n const folderId = entry?.location?.folderId;\n if (!folderId || folderId === ROOT_FOLDER) {\n return entry;\n }\n\n const folder = await context.aco.folder.get(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n folder,\n rwd: \"r\"\n });\n\n return entry;\n };\n\n const originalCmsGetEntryById = context.cms.getEntryById.bind(context.cms);\n context.cms.getEntryById = async (model, params) => {\n const entry = await originalCmsGetEntryById(model, params);\n\n const folderId = entry?.location?.folderId;\n if (!folderId || folderId === ROOT_FOLDER) {\n return entry;\n }\n const folder = await context.aco.folder.get(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n folder,\n rwd: \"r\"\n });\n return entry;\n };\n\n const originalGetLatestEntriesByIds = context.cms.getLatestEntriesByIds.bind(context.cms);\n context.cms.getLatestEntriesByIds = async (model, ids) => {\n const entries = await originalGetLatestEntriesByIds(model, ids);\n\n return filterEntriesByFolder(model, entries);\n };\n\n const originalGetPublishedEntriesByIds = context.cms.getPublishedEntriesByIds.bind(\n context.cms\n );\n context.cms.getPublishedEntriesByIds = async (model, ids) => {\n const entries = await originalGetPublishedEntriesByIds(model, ids);\n return filterEntriesByFolder(model, entries);\n };\n\n const originalCmsCreateEntry = context.cms.createEntry.bind(context.cms);\n context.cms.createEntry = async (model, params, options) => {\n const folderId = params.wbyAco_location?.folderId || params.location?.folderId;\n\n if (!folderId || folderId === ROOT_FOLDER) {\n return originalCmsCreateEntry(model, params, options);\n }\n\n const folder = await context.aco.folder.get(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n folder,\n rwd: \"w\"\n });\n\n return originalCmsCreateEntry(model, params, options);\n };\n\n const originalCmsCreateFromEntry = context.cms.createEntryRevisionFrom.bind(context.cms);\n context.cms.createEntryRevisionFrom = async (model, id, input, options) => {\n const entry = await context.cms.storageOperations.entries.getRevisionById(model, {\n id\n });\n\n const folderId = entry?.location?.folderId;\n if (!folderId || folderId === ROOT_FOLDER) {\n return originalCmsCreateFromEntry(model, id, input, options);\n }\n\n const folder = await context.aco.folder.get(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n folder,\n rwd: \"w\"\n });\n\n return originalCmsCreateFromEntry(model, id, input, options);\n };\n\n const originalCmsUpdateEntry = context.cms.updateEntry.bind(context.cms);\n context.cms.updateEntry = async (model, id, input, meta, options) => {\n const entry = await context.cms.storageOperations.entries.getRevisionById(model, {\n id\n });\n\n const folderId = entry?.location?.folderId;\n if (!folderId || folderId === ROOT_FOLDER) {\n return originalCmsUpdateEntry(model, id, input, meta, options);\n }\n\n const folder = await context.aco.folder.get(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n folder,\n rwd: \"w\"\n });\n\n return originalCmsUpdateEntry(model, id, input, meta, options);\n };\n\n const originalCmsDeleteEntry = context.cms.deleteEntry.bind(context.cms);\n context.cms.deleteEntry = async (model, id, options) => {\n const entry = await context.cms.storageOperations.entries.getLatestRevisionByEntryId(\n model,\n {\n id\n }\n );\n\n const folderId = entry?.location?.folderId;\n if (!folderId || folderId === ROOT_FOLDER) {\n return originalCmsDeleteEntry(model, id, options);\n }\n\n const folder = await context.aco.folder.get(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n folder,\n rwd: \"d\"\n });\n\n return originalCmsDeleteEntry(model, id, options);\n };\n\n const originalCmsDeleteEntryRevision = context.cms.deleteEntryRevision.bind(context.cms);\n context.cms.deleteEntryRevision = async (model, id) => {\n const entry = await context.cms.storageOperations.entries.getRevisionById(model, {\n id\n });\n\n const folderId = entry?.location?.folderId;\n if (!folderId || folderId === ROOT_FOLDER) {\n return originalCmsDeleteEntryRevision(model, id);\n }\n\n const folder = await context.aco.folder.get(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n folder,\n rwd: \"d\"\n });\n\n return originalCmsDeleteEntryRevision(model, id);\n };\n\n const originalCmsMoveEntry = context.cms.moveEntry.bind(context.cms);\n context.cms.moveEntry = async (model, id, targetFolderId) => {\n /**\n * First we need to check if user has access to the entries existing folder.\n */\n const entry = await context.cms.storageOperations.entries.getRevisionById(model, {\n id\n });\n\n const folderId = entry?.location?.folderId || ROOT_FOLDER;\n /**\n * If the entry is in the same folder we are trying to move it to, just continue.\n */\n if (folderId === targetFolderId) {\n return originalCmsMoveEntry(model, id, targetFolderId);\n } else if (folderId !== ROOT_FOLDER) {\n /**\n * If entry current folder is not a root, check for access\n */\n const folder = await context.aco.folder.get(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n folder,\n rwd: \"w\"\n });\n }\n /**\n * If target folder is not a ROOT_FOLDER, check for access.\n */\n if (targetFolderId !== ROOT_FOLDER) {\n const folder = await context.aco.folder.get(targetFolderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n folder,\n rwd: \"w\"\n });\n }\n\n return originalCmsMoveEntry(model, id, targetFolderId);\n };\n }\n}\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,6BAAA,GAAAF,OAAA;AACA,IAAAG,iBAAA,GAAAH,OAAA;AAQO,MAAMI,wBAAwB,CAAC;EAG3BC,WAAWA,CAAC;IAAEC;EAA0C,CAAC,EAAE;IAC9D,IAAI,CAACA,OAAO,GAAGA,OAAO;EAC1B;EAEOC,QAAQA,CAAA,EAAG;IACd,MAAMD,OAAO,GAAG,IAAI,CAACA,OAAO;IAC5B,MAAME,sBAAsB,GAAGF,OAAO,CAACG,GAAG,CAACD,sBAAsB;IAEjE,MAAME,qBAAqB,GAAG,IAAAC,0DAA4B,EAACL,OAAO,EAAEE,s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C,MAAM,GAAG,MAAMxB,OAAO,CAACG,GAAG,CAACqB,MAAM,CAACC,GAAG,CAAC+B,cAAc,CAAC;QAC3D,MAAMtD,sBAAsB,CAACwB,4BAA4B,CAAC;UACtDF,MAAM;UACNG,GAAG,EAAE;QACT,CAAC,CAAC;MACN;MAEA,OAAO2B,oBAAoB,CAAC5C,KAAK,EAAEgC,EAAE,EAAEc,cAAc,CAAC;IAC1D,CAAC;EACL;AACJ;AAACC,OAAA,CAAA3D,wBAAA,GAAAA,wBAAA"}
@@ -0,0 +1,2 @@
1
+ import { CmsModel } from "@webiny/api-headless-cms/types";
2
+ export declare const createFolderType: (model: CmsModel) => "FmFile" | "PbPage" | `cms:${string}`;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createFolderType = void 0;
7
+ var _isPageModel = require("./isPageModel");
8
+ const createFolderType = model => {
9
+ if (model.modelId === "fmFile") {
10
+ return "FmFile";
11
+ } else if ((0, _isPageModel.isPageModel)(model)) {
12
+ return "PbPage";
13
+ }
14
+ return `cms:${model.modelId}`;
15
+ };
16
+ exports.createFolderType = createFolderType;
17
+
18
+ //# sourceMappingURL=createFolderType.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_isPageModel","require","createFolderType","model","modelId","isPageModel","exports"],"sources":["createFolderType.ts"],"sourcesContent":["import { CmsModel } from \"@webiny/api-headless-cms/types\";\nimport { isPageModel } from \"./isPageModel\";\n\nexport const createFolderType = (model: CmsModel): \"FmFile\" | \"PbPage\" | `cms:${string}` => {\n if (model.modelId === \"fmFile\") {\n return \"FmFile\";\n } else if (isPageModel(model)) {\n return \"PbPage\";\n }\n return `cms:${model.modelId}`;\n};\n"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AAEO,MAAMC,gBAAgB,GAAIC,KAAe,IAA4C;EACxF,IAAIA,KAAK,CAACC,OAAO,KAAK,QAAQ,EAAE;IAC5B,OAAO,QAAQ;EACnB,CAAC,MAAM,IAAI,IAAAC,wBAAW,EAACF,KAAK,CAAC,EAAE;IAC3B,OAAO,QAAQ;EACnB;EACA,OAAQ,OAAMA,KAAK,CAACC,OAAQ,EAAC;AACjC,CAAC;AAACE,OAAA,CAAAJ,gBAAA,GAAAA,gBAAA"}
@@ -0,0 +1,6 @@
1
+ import { AcoContext } from "../../types";
2
+ import { CmsEntry, CmsModel } from "@webiny/api-headless-cms/types";
3
+ import { FolderLevelPermissions } from "../FolderLevelPermissions";
4
+ declare type Context = Pick<AcoContext, "aco" | "cms">;
5
+ export declare const filterEntriesByFolderFactory: (context: Context, permissions: FolderLevelPermissions) => (model: CmsModel, entries: CmsEntry[]) => Promise<CmsEntry<import("@webiny/api-headless-cms/types").CmsEntryValues>[]>;
6
+ export {};
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.filterEntriesByFolderFactory = void 0;
7
+ var _handlerGraphql = require("@webiny/handler-graphql");
8
+ var _constants = require("./constants");
9
+ var _createFolderType = require("./createFolderType");
10
+ const filterEntriesByFolderFactory = (context, permissions) => {
11
+ return async (model, entries) => {
12
+ const [folders] = await context.aco.folder.listAll({
13
+ where: {
14
+ type: (0, _createFolderType.createFolderType)(model)
15
+ }
16
+ });
17
+ const results = await Promise.all(entries.map(async entry => {
18
+ const folderId = entry.location?.folderId;
19
+ if (!folderId || folderId === _constants.ROOT_FOLDER) {
20
+ return entry;
21
+ }
22
+ const folder = folders.find(folder => folder.id === folderId);
23
+ if (!folder) {
24
+ throw new _handlerGraphql.NotFoundError(`Folder "${folderId}" not found.`);
25
+ }
26
+ const result = await permissions.canAccessFolderContent({
27
+ folder,
28
+ rwd: "r"
29
+ });
30
+ return result ? entry : null;
31
+ }));
32
+ return results.filter(entry => !!entry);
33
+ };
34
+ };
35
+ exports.filterEntriesByFolderFactory = filterEntriesByFolderFactory;
36
+
37
+ //# sourceMappingURL=filterEntriesByFolderFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_handlerGraphql","require","_constants","_createFolderType","filterEntriesByFolderFactory","context","permissions","model","entries","folders","aco","folder","listAll","where","type","createFolderType","results","Promise","all","map","entry","folderId","location","ROOT_FOLDER","find","id","NotFoundError","result","canAccessFolderContent","rwd","filter","exports"],"sources":["filterEntriesByFolderFactory.ts"],"sourcesContent":["import { AcoContext } from \"~/types\";\nimport { CmsEntry, CmsModel } from \"@webiny/api-headless-cms/types\";\nimport { NotFoundError } from \"@webiny/handler-graphql\";\nimport { FolderLevelPermissions } from \"~/utils/FolderLevelPermissions\";\nimport { ROOT_FOLDER } from \"./constants\";\n\ntype Context = Pick<AcoContext, \"aco\" | \"cms\">;\n\nimport { createFolderType } from \"./createFolderType\";\n\nexport const filterEntriesByFolderFactory = (\n context: Context,\n permissions: FolderLevelPermissions\n) => {\n return async (model: CmsModel, entries: CmsEntry[]) => {\n const [folders] = await context.aco.folder.listAll({\n where: {\n type: createFolderType(model)\n }\n });\n\n const results = await Promise.all(\n entries.map(async entry => {\n const folderId = entry.location?.folderId;\n if (!folderId || folderId === ROOT_FOLDER) {\n return entry;\n }\n\n const folder = folders.find(folder => folder.id === folderId);\n if (!folder) {\n throw new NotFoundError(`Folder \"${folderId}\" not found.`);\n }\n const result = await permissions.canAccessFolderContent({\n folder,\n rwd: \"r\"\n });\n return result ? entry : null;\n })\n );\n\n return results.filter((entry): entry is CmsEntry => !!entry);\n };\n};\n"],"mappings":";;;;;;AAEA,IAAAA,eAAA,GAAAC,OAAA;AAEA,IAAAC,UAAA,GAAAD,OAAA;AAIA,IAAAE,iBAAA,GAAAF,OAAA;AAEO,MAAMG,4BAA4B,GAAGA,CACxCC,OAAgB,EAChBC,WAAmC,KAClC;EACD,OAAO,OAAOC,KAAe,EAAEC,OAAmB,KAAK;IACnD,MAAM,CAACC,OAAO,CAAC,GAAG,MAAMJ,OAAO,CAACK,GAAG,CAACC,MAAM,CAACC,OAAO,CAAC;MAC/CC,KAAK,EAAE;QACHC,IAAI,EAAE,IAAAC,kCAAgB,EAACR,KAAK;MAChC;IACJ,CAAC,CAAC;IAEF,MAAMS,OAAO,GAAG,MAAMC,OAAO,CAACC,GAAG,CAC7BV,OAAO,CAACW,GAAG,CAAC,MAAMC,KAAK,IAAI;MACvB,MAAMC,QAAQ,GAAGD,KAAK,CAACE,QAAQ,EAAED,QAAQ;MACzC,IAAI,CAACA,QAAQ,IAAIA,QAAQ,KAAKE,sBAAW,EAAE;QACvC,OAAOH,KAAK;MAChB;MAEA,MAAMT,MAAM,GAAGF,OAAO,CAACe,IAAI,CAACb,MAAM,IAAIA,MAAM,CAACc,EAAE,KAAKJ,QAAQ,CAAC;MAC7D,IAAI,CAACV,MAAM,EAAE;QACT,MAAM,IAAIe,6BAAa,CAAE,WAAUL,QAAS,cAAa,CAAC;MAC9D;MACA,MAAMM,MAAM,GAAG,MAAMrB,WAAW,CAACsB,sBAAsB,CAAC;QACpDjB,MAAM;QACNkB,GAAG,EAAE;MACT,CAAC,CAAC;MACF,OAAOF,MAAM,GAAGP,KAAK,GAAG,IAAI;IAChC,CAAC,CACL,CAAC;IAED,OAAOJ,OAAO,CAACc,MAAM,CAAEV,KAAK,IAAwB,CAAC,CAACA,KAAK,CAAC;EAChE,CAAC;AACL,CAAC;AAACW,OAAA,CAAA3B,4BAAA,GAAAA,4BAAA"}
@@ -0,0 +1,5 @@
1
+ import { CmsModel } from "@webiny/api-headless-cms/types";
2
+ /**
3
+ * Keep this until we figure out how to fetch the folders.
4
+ */
5
+ export declare const isPageModel: (model: CmsModel) => boolean;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isPageModel = void 0;
7
+ /**
8
+ * Keep this until we figure out how to fetch the folders.
9
+ */
10
+ const isPageModel = model => {
11
+ if (model.modelId === "pbPage") {
12
+ return true;
13
+ } else if (model.modelId === "acoSearchRecord-pbpage") {
14
+ return true;
15
+ }
16
+ return false;
17
+ };
18
+ exports.isPageModel = isPageModel;
19
+
20
+ //# sourceMappingURL=isPageModel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["isPageModel","model","modelId","exports"],"sources":["isPageModel.ts"],"sourcesContent":["import { CmsModel } from \"@webiny/api-headless-cms/types\";\n\n/**\n * Keep this until we figure out how to fetch the folders.\n */\nexport const isPageModel = (model: CmsModel): boolean => {\n if (model.modelId === \"pbPage\") {\n return true;\n } else if (model.modelId === \"acoSearchRecord-pbpage\") {\n return true;\n }\n return false;\n};\n"],"mappings":";;;;;;AAEA;AACA;AACA;AACO,MAAMA,WAAW,GAAIC,KAAe,IAAc;EACrD,IAAIA,KAAK,CAACC,OAAO,KAAK,QAAQ,EAAE;IAC5B,OAAO,IAAI;EACf,CAAC,MAAM,IAAID,KAAK,CAACC,OAAO,KAAK,wBAAwB,EAAE;IACnD,OAAO,IAAI;EACf;EACA,OAAO,KAAK;AAChB,CAAC;AAACC,OAAA,CAAAH,WAAA,GAAAA,WAAA"}
@@ -1,6 +1,7 @@
1
- import { CmsEntryListWhere } from "@webiny/api-headless-cms/types";
1
+ import { CmsEntryListWhere, CmsModel } from "@webiny/api-headless-cms/types";
2
2
  import { Folder } from "../../folder/folder.types";
3
3
  interface Params {
4
+ model: CmsModel;
4
5
  where: CmsEntryListWhere | undefined;
5
6
  folders: Folder[];
6
7
  }
@@ -1,12 +1,11 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
6
  exports.createWhere = void 0;
8
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
9
7
  var _constants = require("./constants");
8
+ var _isPageModel = require("./isPageModel");
10
9
  /**
11
10
  * There are multiple cases that we need to handle:
12
11
  * * existing location with no AND conditional
@@ -15,30 +14,46 @@ var _constants = require("./constants");
15
14
  */
16
15
  const createWhere = params => {
17
16
  const {
17
+ model,
18
18
  where,
19
19
  folders
20
20
  } = params;
21
- if (!where) {
22
- return undefined;
23
- }
21
+
22
+ // Once we migrate PB to HCMS, we can remove this check and always use `wbAco_location`.
23
+ const locationFieldName = (0, _isPageModel.isPageModel)(model) ? "location" : "wbyAco_location";
24
24
  const whereLocation = {
25
- wbyAco_location: {
25
+ [locationFieldName]: {
26
26
  // At the moment, all users can access entries in the root folder.
27
27
  // Root folder level permissions cannot be set yet.
28
28
  folderId_in: [_constants.ROOT_FOLDER, ...folders.map(folder => folder.id)]
29
29
  }
30
30
  };
31
+ if (!where) {
32
+ // If no `where` condition is present, that means we're performing a query
33
+ // across all folders. Still, with FLP enabled, we need to filter out
34
+ // folders to which the user does not have access.
35
+ return whereLocation;
36
+ }
31
37
  const whereAnd = where.AND;
32
- if (where.wbyAco_location && !whereAnd) {
33
- return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, where), {}, {
34
- AND: [(0, _objectSpread2.default)({}, whereLocation)]
35
- });
36
- } else if (where.wbyAco_location && whereAnd) {
37
- return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, where), {}, {
38
- AND: [(0, _objectSpread2.default)({}, whereLocation), ...whereAnd]
39
- });
38
+ if (where[locationFieldName] && !whereAnd) {
39
+ return {
40
+ ...where,
41
+ AND: [{
42
+ ...whereLocation
43
+ }]
44
+ };
45
+ } else if (where[locationFieldName] && whereAnd) {
46
+ return {
47
+ ...where,
48
+ AND: [{
49
+ ...whereLocation
50
+ }, ...whereAnd]
51
+ };
40
52
  }
41
- return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, where), whereLocation);
53
+ return {
54
+ ...where,
55
+ ...whereLocation
56
+ };
42
57
  };
43
58
  exports.createWhere = createWhere;
44
59
 
@@ -1 +1 @@
1
- {"version":3,"names":["_constants","require","createWhere","params","where","folders","undefined","whereLocation","wbyAco_location","folderId_in","ROOT_FOLDER","map","folder","id","whereAnd","AND","_objectSpread2","default","exports"],"sources":["where.ts"],"sourcesContent":["import { CmsEntryListWhere } from \"@webiny/api-headless-cms/types\";\nimport { Folder } from \"~/folder/folder.types\";\nimport { ROOT_FOLDER } from \"./constants\";\n\ninterface Params {\n where: CmsEntryListWhere | undefined;\n folders: Folder[];\n}\n\n/**\n * There are multiple cases that we need to handle:\n * * existing location with no AND conditional\n * * existing location with AND conditional\n * * no existing location with no AND conditional + with AND conditional\n */\nexport const createWhere = (params: Params): CmsEntryListWhere | undefined => {\n const { where, folders } = params;\n if (!where) {\n return undefined;\n }\n const whereLocation = {\n wbyAco_location: {\n // At the moment, all users can access entries in the root folder.\n // Root folder level permissions cannot be set yet.\n folderId_in: [ROOT_FOLDER, ...folders.map(folder => folder.id)]\n }\n };\n const whereAnd = where.AND;\n if (where.wbyAco_location && !whereAnd) {\n return {\n ...where,\n AND: [\n {\n ...whereLocation\n }\n ]\n };\n } else if (where.wbyAco_location && whereAnd) {\n return {\n ...where,\n AND: [\n {\n ...whereLocation\n },\n ...whereAnd\n ]\n };\n }\n return {\n ...where,\n ...whereLocation\n };\n};\n"],"mappings":";;;;;;;;AAEA,IAAAA,UAAA,GAAAC,OAAA;AAOA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,WAAW,GAAIC,MAAc,IAAoC;EAC1E,MAAM;IAAEC,KAAK;IAAEC;EAAQ,CAAC,GAAGF,MAAM;EACjC,IAAI,CAACC,KAAK,EAAE;IACR,OAAOE,SAAS;EACpB;EACA,MAAMC,aAAa,GAAG;IAClBC,eAAe,EAAE;MACb;MACA;MACAC,WAAW,EAAE,CAACC,sBAAW,EAAE,GAAGL,OAAO,CAACM,GAAG,CAACC,MAAM,IAAIA,MAAM,CAACC,EAAE,CAAC;IAClE;EACJ,CAAC;EACD,MAAMC,QAAQ,GAAGV,KAAK,CAACW,GAAG;EAC1B,IAAIX,KAAK,CAACI,eAAe,IAAI,CAACM,QAAQ,EAAE;IACpC,WAAAE,cAAA,CAAAC,OAAA,MAAAD,cAAA,CAAAC,OAAA,MACOb,KAAK;MACRW,GAAG,EAAE,KAAAC,cAAA,CAAAC,OAAA,MAEMV,aAAa;IAEvB;EAET,CAAC,MAAM,IAAIH,KAAK,CAACI,eAAe,IAAIM,QAAQ,EAAE;IAC1C,WAAAE,cAAA,CAAAC,OAAA,MAAAD,cAAA,CAAAC,OAAA,MACOb,KAAK;MACRW,GAAG,EAAE,KAAAC,cAAA,CAAAC,OAAA,MAEMV,aAAa,GAEpB,GAAGO,QAAQ;IACd;EAET;EACA,WAAAE,cAAA,CAAAC,OAAA,MAAAD,cAAA,CAAAC,OAAA,MACOb,KAAK,GACLG,aAAa;AAExB,CAAC;AAACW,OAAA,CAAAhB,WAAA,GAAAA,WAAA"}
1
+ {"version":3,"names":["_constants","require","_isPageModel","createWhere","params","model","where","folders","locationFieldName","isPageModel","whereLocation","folderId_in","ROOT_FOLDER","map","folder","id","whereAnd","AND","exports"],"sources":["where.ts"],"sourcesContent":["import { CmsEntryListWhere, CmsModel } from \"@webiny/api-headless-cms/types\";\nimport { Folder } from \"~/folder/folder.types\";\nimport { ROOT_FOLDER } from \"./constants\";\nimport { isPageModel } from \"~/utils/decorators/isPageModel\";\n\ninterface Params {\n model: CmsModel;\n where: CmsEntryListWhere | undefined;\n folders: Folder[];\n}\n\n/**\n * There are multiple cases that we need to handle:\n * * existing location with no AND conditional\n * * existing location with AND conditional\n * * no existing location with no AND conditional + with AND conditional\n */\nexport const createWhere = (params: Params): CmsEntryListWhere | undefined => {\n const { model, where, folders } = params;\n\n // Once we migrate PB to HCMS, we can remove this check and always use `wbAco_location`.\n const locationFieldName = isPageModel(model) ? \"location\" : \"wbyAco_location\";\n\n const whereLocation = {\n [locationFieldName]: {\n // At the moment, all users can access entries in the root folder.\n // Root folder level permissions cannot be set yet.\n folderId_in: [ROOT_FOLDER, ...folders.map(folder => folder.id)]\n }\n };\n\n if (!where) {\n // If no `where` condition is present, that means we're performing a query\n // across all folders. Still, with FLP enabled, we need to filter out\n // folders to which the user does not have access.\n return whereLocation;\n }\n\n const whereAnd = where.AND;\n if (where[locationFieldName] && !whereAnd) {\n return {\n ...where,\n AND: [\n {\n ...whereLocation\n }\n ]\n };\n } else if (where[locationFieldName] && whereAnd) {\n return {\n ...where,\n AND: [\n {\n ...whereLocation\n },\n ...whereAnd\n ]\n };\n }\n\n return {\n ...where,\n ...whereLocation\n };\n};\n"],"mappings":";;;;;;AAEA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAQA;AACA;AACA;AACA;AACA;AACA;AACO,MAAME,WAAW,GAAIC,MAAc,IAAoC;EAC1E,MAAM;IAAEC,KAAK;IAAEC,KAAK;IAAEC;EAAQ,CAAC,GAAGH,MAAM;;EAExC;EACA,MAAMI,iBAAiB,GAAG,IAAAC,wBAAW,EAACJ,KAAK,CAAC,GAAG,UAAU,GAAG,iBAAiB;EAE7E,MAAMK,aAAa,GAAG;IAClB,CAACF,iBAAiB,GAAG;MACjB;MACA;MACAG,WAAW,EAAE,CAACC,sBAAW,EAAE,GAAGL,OAAO,CAACM,GAAG,CAACC,MAAM,IAAIA,MAAM,CAACC,EAAE,CAAC;IAClE;EACJ,CAAC;EAED,IAAI,CAACT,KAAK,EAAE;IACR;IACA;IACA;IACA,OAAOI,aAAa;EACxB;EAEA,MAAMM,QAAQ,GAAGV,KAAK,CAACW,GAAG;EAC1B,IAAIX,KAAK,CAACE,iBAAiB,CAAC,IAAI,CAACQ,QAAQ,EAAE;IACvC,OAAO;MACH,GAAGV,KAAK;MACRW,GAAG,EAAE,CACD;QACI,GAAGP;MACP,CAAC;IAET,CAAC;EACL,CAAC,MAAM,IAAIJ,KAAK,CAACE,iBAAiB,CAAC,IAAIQ,QAAQ,EAAE;IAC7C,OAAO;MACH,GAAGV,KAAK;MACRW,GAAG,EAAE,CACD;QACI,GAAGP;MACP,CAAC,EACD,GAAGM,QAAQ;IAEnB,CAAC;EACL;EAEA,OAAO;IACH,GAAGV,KAAK;IACR,GAAGI;EACP,CAAC;AACL,CAAC;AAACQ,OAAA,CAAAf,WAAA,GAAAA,WAAA"}
@@ -1,7 +1,5 @@
1
1
  import { CmsModelPlugin, CmsPrivateModelFull } from "@webiny/api-headless-cms";
2
- import { CmsGroup } from "@webiny/api-headless-cms/types";
3
2
  interface Params {
4
- group: Pick<CmsGroup, "id" | "name">;
5
3
  /**
6
4
  * Locale and tenant do not need to be defined.
7
5
  * In that case model is not bound to any locale or tenant.
@@ -9,7 +7,7 @@ interface Params {
9
7
  */
10
8
  locale?: string;
11
9
  tenant?: string;
12
- modelDefinition: Omit<CmsPrivateModelFull, "noValidate" | "group">;
10
+ modelDefinition: CmsPrivateModelFull;
13
11
  }
14
12
  export declare const modelFactory: (params: Params) => CmsModelPlugin;
15
13
  export {};
@@ -1,26 +1,21 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
6
  exports.modelFactory = void 0;
8
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
9
7
  var _apiHeadlessCms = require("@webiny/api-headless-cms");
10
8
  const modelFactory = params => {
11
9
  const {
12
- group,
13
10
  locale,
14
11
  tenant,
15
12
  modelDefinition
16
13
  } = params;
17
- return (0, _apiHeadlessCms.createCmsModel)((0, _objectSpread2.default)((0, _objectSpread2.default)({
18
- group,
14
+ return (0, _apiHeadlessCms.createCmsModel)({
19
15
  locale,
20
- tenant
21
- }, modelDefinition), {}, {
22
- noValidate: true
23
- }));
16
+ tenant,
17
+ ...modelDefinition
18
+ });
24
19
  };
25
20
  exports.modelFactory = modelFactory;
26
21
 
@@ -1 +1 @@
1
- {"version":3,"names":["_apiHeadlessCms","require","modelFactory","params","group","locale","tenant","modelDefinition","createCmsModel","_objectSpread2","default","noValidate","exports"],"sources":["modelFactory.ts"],"sourcesContent":["import { CmsModelPlugin, CmsPrivateModelFull, createCmsModel } from \"@webiny/api-headless-cms\";\nimport { CmsGroup } from \"@webiny/api-headless-cms/types\";\n\ninterface Params {\n group: Pick<CmsGroup, \"id\" | \"name\">;\n /**\n * Locale and tenant do not need to be defined.\n * In that case model is not bound to any locale or tenant.\n * You can bind it to locale, tenant, both or none.\n */\n locale?: string;\n tenant?: string;\n modelDefinition: Omit<CmsPrivateModelFull, \"noValidate\" | \"group\">;\n}\n\nexport const modelFactory = (params: Params): CmsModelPlugin => {\n const { group, locale, tenant, modelDefinition } = params;\n\n return createCmsModel({\n group,\n locale,\n tenant,\n ...modelDefinition,\n noValidate: true\n });\n};\n"],"mappings":";;;;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AAeO,MAAMC,YAAY,GAAIC,MAAc,IAAqB;EAC5D,MAAM;IAAEC,KAAK;IAAEC,MAAM;IAAEC,MAAM;IAAEC;EAAgB,CAAC,GAAGJ,MAAM;EAEzD,OAAO,IAAAK,8BAAc,MAAAC,cAAA,CAAAC,OAAA,MAAAD,cAAA,CAAAC,OAAA;IACjBN,KAAK;IACLC,MAAM;IACNC;EAAM,GACHC,eAAe;IAClBI,UAAU,EAAE;EAAI,EACnB,CAAC;AACN,CAAC;AAACC,OAAA,CAAAV,YAAA,GAAAA,YAAA"}
1
+ {"version":3,"names":["_apiHeadlessCms","require","modelFactory","params","locale","tenant","modelDefinition","createCmsModel","exports"],"sources":["modelFactory.ts"],"sourcesContent":["import { CmsModelPlugin, CmsPrivateModelFull, createCmsModel } from \"@webiny/api-headless-cms\";\n\ninterface Params {\n /**\n * Locale and tenant do not need to be defined.\n * In that case model is not bound to any locale or tenant.\n * You can bind it to locale, tenant, both or none.\n */\n locale?: string;\n tenant?: string;\n modelDefinition: CmsPrivateModelFull;\n}\n\nexport const modelFactory = (params: Params): CmsModelPlugin => {\n const { locale, tenant, modelDefinition } = params;\n\n return createCmsModel({\n locale,\n tenant,\n ...modelDefinition\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AAaO,MAAMC,YAAY,GAAIC,MAAc,IAAqB;EAC5D,MAAM;IAAEC,MAAM;IAAEC,MAAM;IAAEC;EAAgB,CAAC,GAAGH,MAAM;EAElD,OAAO,IAAAI,8BAAc,EAAC;IAClBH,MAAM;IACNC,MAAM;IACN,GAAGC;EACP,CAAC,CAAC;AACN,CAAC;AAACE,OAAA,CAAAN,YAAA,GAAAA,YAAA"}
@@ -0,0 +1,3 @@
1
+ import { CmsEntry } from "@webiny/api-headless-cms/types";
2
+ export declare const baseFields: string[];
3
+ export declare function pickEntryFieldValues<T>(entry: CmsEntry): T;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.baseFields = void 0;
7
+ exports.pickEntryFieldValues = pickEntryFieldValues;
8
+ const baseFields = [
9
+ // Entry ID is mapped to "id" (we don't use revisions with ACO entities).
10
+ "id", "createdOn", "modifiedOn", "savedOn", "createdBy", "modifiedBy", "savedBy"];
11
+ exports.baseFields = baseFields;
12
+ const pickBaseEntryFieldValues = entry => {
13
+ const pickedValues = {};
14
+ for (const fieldName of baseFields) {
15
+ const [srcFieldName, targetFieldName = srcFieldName] = fieldName.split(":");
16
+ if (srcFieldName in entry) {
17
+ Object.assign(pickedValues, {
18
+ [targetFieldName]: entry[srcFieldName]
19
+ });
20
+ }
21
+ }
22
+ return pickedValues;
23
+ };
24
+ function pickEntryFieldValues(entry) {
25
+ return {
26
+ ...pickBaseEntryFieldValues(entry),
27
+ ...entry.values
28
+ };
29
+ }
30
+
31
+ //# sourceMappingURL=pickEntryFieldValues.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["baseFields","exports","pickBaseEntryFieldValues","entry","pickedValues","fieldName","srcFieldName","targetFieldName","split","Object","assign","pickEntryFieldValues","values"],"sources":["pickEntryFieldValues.ts"],"sourcesContent":["import { CmsEntry } from \"@webiny/api-headless-cms/types\";\n\nexport const baseFields = [\n // Entry ID is mapped to \"id\" (we don't use revisions with ACO entities).\n \"id\",\n\n \"createdOn\",\n \"modifiedOn\",\n \"savedOn\",\n \"createdBy\",\n \"modifiedBy\",\n \"savedBy\"\n];\n\nconst pickBaseEntryFieldValues = (entry: CmsEntry) => {\n const pickedValues: Partial<CmsEntry> = {};\n for (const fieldName of baseFields) {\n const [srcFieldName, targetFieldName = srcFieldName] = fieldName.split(\":\");\n if (srcFieldName in entry) {\n Object.assign(pickedValues, {\n [targetFieldName]: entry[srcFieldName as keyof CmsEntry]\n });\n }\n }\n\n return pickedValues;\n};\n\nexport function pickEntryFieldValues<T>(entry: CmsEntry): T {\n return {\n ...pickBaseEntryFieldValues(entry),\n ...entry.values\n } as T;\n}\n"],"mappings":";;;;;;;AAEO,MAAMA,UAAU,GAAG;AACtB;AACA,IAAI,EAEJ,WAAW,EACX,YAAY,EACZ,SAAS,EACT,WAAW,EACX,YAAY,EACZ,SAAS,CACZ;AAACC,OAAA,CAAAD,UAAA,GAAAA,UAAA;AAEF,MAAME,wBAAwB,GAAIC,KAAe,IAAK;EAClD,MAAMC,YAA+B,GAAG,CAAC,CAAC;EAC1C,KAAK,MAAMC,SAAS,IAAIL,UAAU,EAAE;IAChC,MAAM,CAACM,YAAY,EAAEC,eAAe,GAAGD,YAAY,CAAC,GAAGD,SAAS,CAACG,KAAK,CAAC,GAAG,CAAC;IAC3E,IAAIF,YAAY,IAAIH,KAAK,EAAE;MACvBM,MAAM,CAACC,MAAM,CAACN,YAAY,EAAE;QACxB,CAACG,eAAe,GAAGJ,KAAK,CAACG,YAAY;MACzC,CAAC,CAAC;IACN;EACJ;EAEA,OAAOF,YAAY;AACvB,CAAC;AAEM,SAASO,oBAAoBA,CAAIR,KAAe,EAAK;EACxD,OAAO;IACH,GAAGD,wBAAwB,CAACC,KAAK,CAAC;IAClC,GAAGA,KAAK,CAACS;EACb,CAAC;AACL"}
@@ -1,3 +1,3 @@
1
1
  import { ErrorResponse, ListResponse, Response } from "@webiny/handler-graphql";
2
- export declare const resolve: (fn: () => Promise<any>) => Promise<Response<any> | ErrorResponse>;
2
+ export declare const resolve: (fn: () => Promise<any>) => Promise<ErrorResponse | Response<any>>;
3
3
  export declare const resolveList: (fn: () => Promise<any>) => Promise<ErrorResponse | ListResponse<unknown, any>>;
package/fields/index.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import { CmsModelFieldToGraphQLPlugin } from "@webiny/api-headless-cms/types";
2
- export declare const createFields: () => CmsModelFieldToGraphQLPlugin[];
package/fields/index.js DELETED
@@ -1,14 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createFields = void 0;
7
- const createFields = () => {
8
- return [
9
- // createLocationField()
10
- ];
11
- };
12
- exports.createFields = createFields;
13
-
14
- //# sourceMappingURL=index.js.map