@webiny/api-headless-cms-ddb 6.6.0-alpha.11 → 6.6.0-alpha.13

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 (101) hide show
  1. package/operations/entry/DdbCreateEntry.d.ts +3 -1
  2. package/operations/entry/DdbCreateEntry.js +17 -10
  3. package/operations/entry/DdbCreateEntry.js.map +1 -1
  4. package/operations/entry/DdbCreateEntryRevisionFrom.d.ts +3 -1
  5. package/operations/entry/DdbCreateEntryRevisionFrom.js +22 -12
  6. package/operations/entry/DdbCreateEntryRevisionFrom.js.map +1 -1
  7. package/operations/entry/DdbDeleteEntry.d.ts +3 -3
  8. package/operations/entry/DdbDeleteEntry.js +7 -7
  9. package/operations/entry/DdbDeleteEntry.js.map +1 -1
  10. package/operations/entry/DdbDeleteEntryRevision.d.ts +3 -1
  11. package/operations/entry/DdbDeleteEntryRevision.js +23 -13
  12. package/operations/entry/DdbDeleteEntryRevision.js.map +1 -1
  13. package/operations/entry/DdbDeleteMultipleEntries.d.ts +3 -1
  14. package/operations/entry/DdbDeleteMultipleEntries.js +13 -6
  15. package/operations/entry/DdbDeleteMultipleEntries.js.map +1 -1
  16. package/operations/entry/DdbGetEntriesByIds.d.ts +3 -1
  17. package/operations/entry/DdbGetEntriesByIds.js +10 -3
  18. package/operations/entry/DdbGetEntriesByIds.js.map +1 -1
  19. package/operations/entry/DdbGetEntry.d.ts +3 -1
  20. package/operations/entry/DdbGetEntry.js +6 -2
  21. package/operations/entry/DdbGetEntry.js.map +1 -1
  22. package/operations/entry/DdbGetLatestEntriesByIds.d.ts +3 -1
  23. package/operations/entry/DdbGetLatestEntriesByIds.js +10 -3
  24. package/operations/entry/DdbGetLatestEntriesByIds.js.map +1 -1
  25. package/operations/entry/DdbGetLatestRevisionByEntryId.d.ts +3 -1
  26. package/operations/entry/DdbGetLatestRevisionByEntryId.js +10 -3
  27. package/operations/entry/DdbGetLatestRevisionByEntryId.js.map +1 -1
  28. package/operations/entry/DdbGetPreviousRevision.d.ts +3 -1
  29. package/operations/entry/DdbGetPreviousRevision.js +7 -3
  30. package/operations/entry/DdbGetPreviousRevision.js.map +1 -1
  31. package/operations/entry/DdbGetPublishedEntriesByIds.d.ts +3 -1
  32. package/operations/entry/DdbGetPublishedEntriesByIds.js +10 -3
  33. package/operations/entry/DdbGetPublishedEntriesByIds.js.map +1 -1
  34. package/operations/entry/DdbGetPublishedRevisionByEntryId.d.ts +3 -1
  35. package/operations/entry/DdbGetPublishedRevisionByEntryId.js +10 -3
  36. package/operations/entry/DdbGetPublishedRevisionByEntryId.js.map +1 -1
  37. package/operations/entry/DdbGetRevisionById.d.ts +3 -1
  38. package/operations/entry/DdbGetRevisionById.js +10 -3
  39. package/operations/entry/DdbGetRevisionById.js.map +1 -1
  40. package/operations/entry/DdbGetRevisions.d.ts +3 -1
  41. package/operations/entry/DdbGetRevisions.js +10 -3
  42. package/operations/entry/DdbGetRevisions.js.map +1 -1
  43. package/operations/entry/DdbGetUniqueFieldValues.d.ts +3 -1
  44. package/operations/entry/DdbGetUniqueFieldValues.js +6 -2
  45. package/operations/entry/DdbGetUniqueFieldValues.js.map +1 -1
  46. package/operations/entry/DdbListEntries.d.ts +3 -1
  47. package/operations/entry/DdbListEntries.js +10 -3
  48. package/operations/entry/DdbListEntries.js.map +1 -1
  49. package/operations/entry/DdbMoveEntry.d.ts +3 -3
  50. package/operations/entry/DdbMoveEntry.js +7 -7
  51. package/operations/entry/DdbMoveEntry.js.map +1 -1
  52. package/operations/entry/DdbMoveToBin.d.ts +3 -1
  53. package/operations/entry/DdbMoveToBin.js +8 -4
  54. package/operations/entry/DdbMoveToBin.js.map +1 -1
  55. package/operations/entry/DdbPublishEntry.d.ts +3 -1
  56. package/operations/entry/DdbPublishEntry.js +54 -32
  57. package/operations/entry/DdbPublishEntry.js.map +1 -1
  58. package/operations/entry/DdbRestoreFromBin.d.ts +3 -1
  59. package/operations/entry/DdbRestoreFromBin.js +8 -4
  60. package/operations/entry/DdbRestoreFromBin.js.map +1 -1
  61. package/operations/entry/DdbUnpublishEntry.d.ts +3 -1
  62. package/operations/entry/DdbUnpublishEntry.js +32 -19
  63. package/operations/entry/DdbUnpublishEntry.js.map +1 -1
  64. package/operations/entry/DdbUpdateEntry.d.ts +3 -1
  65. package/operations/entry/DdbUpdateEntry.js +25 -15
  66. package/operations/entry/DdbUpdateEntry.js.map +1 -1
  67. package/operations/entry/keys.d.ts +15 -6
  68. package/operations/entry/keys.js +30 -12
  69. package/operations/entry/keys.js.map +1 -1
  70. package/operations/group/DdbCreateGroup.d.ts +3 -1
  71. package/operations/group/DdbCreateGroup.js +14 -4
  72. package/operations/group/DdbCreateGroup.js.map +1 -1
  73. package/operations/group/DdbDeleteGroup.d.ts +3 -1
  74. package/operations/group/DdbDeleteGroup.js +10 -3
  75. package/operations/group/DdbDeleteGroup.js.map +1 -1
  76. package/operations/group/DdbGetGroup.d.ts +3 -1
  77. package/operations/group/DdbGetGroup.js +10 -3
  78. package/operations/group/DdbGetGroup.js.map +1 -1
  79. package/operations/group/DdbListGroups.d.ts +3 -1
  80. package/operations/group/DdbListGroups.js +9 -3
  81. package/operations/group/DdbListGroups.js.map +1 -1
  82. package/operations/group/DdbUpdateGroup.d.ts +3 -1
  83. package/operations/group/DdbUpdateGroup.js +14 -4
  84. package/operations/group/DdbUpdateGroup.js.map +1 -1
  85. package/operations/model/DdbCreateModel.d.ts +3 -1
  86. package/operations/model/DdbCreateModel.js +14 -4
  87. package/operations/model/DdbCreateModel.js.map +1 -1
  88. package/operations/model/DdbDeleteModel.d.ts +3 -1
  89. package/operations/model/DdbDeleteModel.js +10 -3
  90. package/operations/model/DdbDeleteModel.js.map +1 -1
  91. package/operations/model/DdbGetModel.d.ts +3 -1
  92. package/operations/model/DdbGetModel.js +10 -3
  93. package/operations/model/DdbGetModel.js.map +1 -1
  94. package/operations/model/DdbListModels.d.ts +4 -2
  95. package/operations/model/DdbListModels.js +10 -5
  96. package/operations/model/DdbListModels.js.map +1 -1
  97. package/operations/model/DdbUpdateModel.d.ts +3 -1
  98. package/operations/model/DdbUpdateModel.js +14 -4
  99. package/operations/model/DdbUpdateModel.js.map +1 -1
  100. package/package.json +14 -14
  101. package/types.js.map +1 -1
@@ -1,16 +1,22 @@
1
1
  import { GetRevisionsStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/GetRevisionsStorageOperation.js";
2
+ import { ScopeTenant } from "@webiny/api-core/features/tenancy/ScopeTenant/index.js";
2
3
  import { CmsDdbDataLoaders } from "../../abstractions/CmsDdbDataLoaders.js";
3
4
  import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
4
5
  import { convertFromStorageEntry } from "./storageEntryUtils.js";
5
6
  class DdbGetRevisionsImpl {
6
- constructor(dataLoaders, storageModelProvider){
7
+ constructor(dataLoaders, storageModelProvider, scopeTenant){
7
8
  this.dataLoaders = dataLoaders;
8
9
  this.storageModelProvider = storageModelProvider;
10
+ this.scopeTenant = scopeTenant;
9
11
  }
10
12
  async execute(initialModel, params) {
13
+ const tenant = this.scopeTenant.getId();
11
14
  const model = this.storageModelProvider.getModel(initialModel);
12
15
  const items = await this.dataLoaders.getAllEntryRevisions({
13
- model,
16
+ model: {
17
+ tenant,
18
+ modelId: model.modelId
19
+ },
14
20
  ids: [
15
21
  params.id
16
22
  ]
@@ -25,7 +31,8 @@ const DdbGetRevisions = GetRevisionsStorageOperation.createImplementation({
25
31
  implementation: DdbGetRevisionsImpl,
26
32
  dependencies: [
27
33
  CmsDdbDataLoaders,
28
- CmsStorageModelProvider
34
+ CmsStorageModelProvider,
35
+ ScopeTenant
29
36
  ]
30
37
  });
31
38
  export { DdbGetRevisions };
@@ -1 +1 @@
1
- {"version":3,"file":"operations/entry/DdbGetRevisions.js","sources":["../../../src/operations/entry/DdbGetRevisions.ts"],"sourcesContent":["import type {\n CmsModel,\n CmsEntryValues,\n CmsEntryStorageOperationsGetRevisionsParams\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { GetRevisionsStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/entry/GetRevisionsStorageOperation.js\";\nimport { CmsDdbDataLoaders } from \"~/abstractions/CmsDdbDataLoaders.js\";\nimport { CmsStorageModelProvider } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport { convertFromStorageEntry } from \"./storageEntryUtils.js\";\n\nclass DdbGetRevisionsImpl implements GetRevisionsStorageOperation.Interface {\n constructor(\n private dataLoaders: CmsDdbDataLoaders.Interface,\n private storageModelProvider: CmsStorageModelProvider.Interface\n ) {}\n\n async execute<T extends CmsEntryValues = CmsEntryValues>(\n initialModel: CmsModel,\n params: CmsEntryStorageOperationsGetRevisionsParams\n ) {\n const model = this.storageModelProvider.getModel<T>(initialModel);\n\n const items = await this.dataLoaders.getAllEntryRevisions<T>({\n model,\n ids: [params.id]\n });\n\n return items.map(item => {\n return convertFromStorageEntry<T>({\n storageEntry: item,\n model\n });\n });\n }\n}\n\nexport const DdbGetRevisions = GetRevisionsStorageOperation.createImplementation({\n implementation: DdbGetRevisionsImpl,\n dependencies: [CmsDdbDataLoaders, CmsStorageModelProvider]\n});\n"],"names":["DdbGetRevisionsImpl","dataLoaders","storageModelProvider","initialModel","params","model","items","item","convertFromStorageEntry","DdbGetRevisions","GetRevisionsStorageOperation","CmsDdbDataLoaders","CmsStorageModelProvider"],"mappings":";;;;AAUA,MAAMA;IACF,YACYC,WAAwC,EACxCC,oBAAuD,CACjE;aAFUD,WAAW,GAAXA;aACAC,oBAAoB,GAApBA;IACT;IAEH,MAAM,QACFC,YAAsB,EACtBC,MAAmD,EACrD;QACE,MAAMC,QAAQ,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAAIF;QAEpD,MAAMG,QAAQ,MAAM,IAAI,CAAC,WAAW,CAAC,oBAAoB,CAAI;YACzDD;YACA,KAAK;gBAACD,OAAO,EAAE;aAAC;QACpB;QAEA,OAAOE,MAAM,GAAG,CAACC,CAAAA,OACNC,wBAA2B;gBAC9B,cAAcD;gBACdF;YACJ;IAER;AACJ;AAEO,MAAMI,kBAAkBC,6BAA6B,oBAAoB,CAAC;IAC7E,gBAAgBV;IAChB,cAAc;QAACW;QAAmBC;KAAwB;AAC9D"}
1
+ {"version":3,"file":"operations/entry/DdbGetRevisions.js","sources":["../../../src/operations/entry/DdbGetRevisions.ts"],"sourcesContent":["import type {\n CmsModel,\n CmsEntryValues,\n CmsEntryStorageOperationsGetRevisionsParams\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { GetRevisionsStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/entry/GetRevisionsStorageOperation.js\";\nimport { ScopeTenant } from \"@webiny/api-core/features/tenancy/ScopeTenant/index.js\";\nimport { CmsDdbDataLoaders } from \"~/abstractions/CmsDdbDataLoaders.js\";\nimport { CmsStorageModelProvider } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport { convertFromStorageEntry } from \"./storageEntryUtils.js\";\n\nclass DdbGetRevisionsImpl implements GetRevisionsStorageOperation.Interface {\n constructor(\n private dataLoaders: CmsDdbDataLoaders.Interface,\n private storageModelProvider: CmsStorageModelProvider.Interface,\n private scopeTenant: ScopeTenant.Interface\n ) {}\n\n async execute<T extends CmsEntryValues = CmsEntryValues>(\n initialModel: CmsModel,\n params: CmsEntryStorageOperationsGetRevisionsParams\n ) {\n const tenant = this.scopeTenant.getId();\n const model = this.storageModelProvider.getModel<T>(initialModel);\n\n const items = await this.dataLoaders.getAllEntryRevisions<T>({\n model: { tenant, modelId: model.modelId },\n ids: [params.id]\n });\n\n return items.map(item => {\n return convertFromStorageEntry<T>({\n storageEntry: item,\n model\n });\n });\n }\n}\n\nexport const DdbGetRevisions = GetRevisionsStorageOperation.createImplementation({\n implementation: DdbGetRevisionsImpl,\n dependencies: [CmsDdbDataLoaders, CmsStorageModelProvider, ScopeTenant]\n});\n"],"names":["DdbGetRevisionsImpl","dataLoaders","storageModelProvider","scopeTenant","initialModel","params","tenant","model","items","item","convertFromStorageEntry","DdbGetRevisions","GetRevisionsStorageOperation","CmsDdbDataLoaders","CmsStorageModelProvider","ScopeTenant"],"mappings":";;;;;AAWA,MAAMA;IACF,YACYC,WAAwC,EACxCC,oBAAuD,EACvDC,WAAkC,CAC5C;aAHUF,WAAW,GAAXA;aACAC,oBAAoB,GAApBA;aACAC,WAAW,GAAXA;IACT;IAEH,MAAM,QACFC,YAAsB,EACtBC,MAAmD,EACrD;QACE,MAAMC,SAAS,IAAI,CAAC,WAAW,CAAC,KAAK;QACrC,MAAMC,QAAQ,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAAIH;QAEpD,MAAMI,QAAQ,MAAM,IAAI,CAAC,WAAW,CAAC,oBAAoB,CAAI;YACzD,OAAO;gBAAEF;gBAAQ,SAASC,MAAM,OAAO;YAAC;YACxC,KAAK;gBAACF,OAAO,EAAE;aAAC;QACpB;QAEA,OAAOG,MAAM,GAAG,CAACC,CAAAA,OACNC,wBAA2B;gBAC9B,cAAcD;gBACdF;YACJ;IAER;AACJ;AAEO,MAAMI,kBAAkBC,6BAA6B,oBAAoB,CAAC;IAC7E,gBAAgBZ;IAChB,cAAc;QAACa;QAAmBC;QAAyBC;KAAY;AAC3E"}
@@ -1,9 +1,11 @@
1
1
  import type { CmsModel, CmsEntryStorageOperationsGetUniqueFieldValuesParams } from "@webiny/api-headless-cms/types/index.js";
2
2
  import { GetUniqueFieldValuesStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/GetUniqueFieldValuesStorageOperation.js";
3
3
  import { ListEntriesStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/ListEntriesStorageOperation.js";
4
+ import { ScopeTenant } from "@webiny/api-core/features/tenancy/ScopeTenant/index.js";
4
5
  declare class DdbGetUniqueFieldValuesImpl implements GetUniqueFieldValuesStorageOperation.Interface {
5
6
  private listEntries;
6
- constructor(listEntries: ListEntriesStorageOperation.Interface);
7
+ private scopeTenant;
8
+ constructor(listEntries: ListEntriesStorageOperation.Interface, scopeTenant: ScopeTenant.Interface);
7
9
  execute(model: CmsModel, params: CmsEntryStorageOperationsGetUniqueFieldValuesParams): Promise<import("@webiny/api-headless-cms/types/types").CmsEntryUniqueValue[]>;
8
10
  }
9
11
  export declare const DdbGetUniqueFieldValues: typeof DdbGetUniqueFieldValuesImpl & {
@@ -1,13 +1,16 @@
1
1
  import error from "@webiny/error";
2
2
  import { GetUniqueFieldValuesStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/GetUniqueFieldValuesStorageOperation.js";
3
3
  import { ListEntriesStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/ListEntriesStorageOperation.js";
4
+ import { ScopeTenant } from "@webiny/api-core/features/tenancy/ScopeTenant/index.js";
4
5
  import { aggregateUniqueFieldValues } from "@webiny/api-headless-cms-storage";
5
6
  const MAX_LIST_LIMIT = 1000000;
6
7
  class DdbGetUniqueFieldValuesImpl {
7
- constructor(listEntries){
8
+ constructor(listEntries, scopeTenant){
8
9
  this.listEntries = listEntries;
10
+ this.scopeTenant = scopeTenant;
9
11
  }
10
12
  async execute(model, params) {
13
+ this.scopeTenant.getId();
11
14
  const { where, fieldId } = params;
12
15
  const field = model.fields.find((f)=>f.fieldId === fieldId);
13
16
  if (!field) throw new error('Could not find field with given "fieldId" value.', "FIELD_NOT_FOUND", {
@@ -23,7 +26,8 @@ class DdbGetUniqueFieldValuesImpl {
23
26
  const DdbGetUniqueFieldValues = GetUniqueFieldValuesStorageOperation.createImplementation({
24
27
  implementation: DdbGetUniqueFieldValuesImpl,
25
28
  dependencies: [
26
- ListEntriesStorageOperation
29
+ ListEntriesStorageOperation,
30
+ ScopeTenant
27
31
  ]
28
32
  });
29
33
  export { DdbGetUniqueFieldValues };
@@ -1 +1 @@
1
- {"version":3,"file":"operations/entry/DdbGetUniqueFieldValues.js","sources":["../../../src/operations/entry/DdbGetUniqueFieldValues.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type {\n CmsModel,\n CmsEntryStorageOperationsGetUniqueFieldValuesParams\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { GetUniqueFieldValuesStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/entry/GetUniqueFieldValuesStorageOperation.js\";\nimport { ListEntriesStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/entry/ListEntriesStorageOperation.js\";\nimport { aggregateUniqueFieldValues } from \"@webiny/api-headless-cms-storage\";\n\nconst MAX_LIST_LIMIT = 1000000;\n\nclass DdbGetUniqueFieldValuesImpl implements GetUniqueFieldValuesStorageOperation.Interface {\n constructor(private listEntries: ListEntriesStorageOperation.Interface) {}\n\n async execute(model: CmsModel, params: CmsEntryStorageOperationsGetUniqueFieldValuesParams) {\n const { where, fieldId } = params;\n\n const field = model.fields.find(f => f.fieldId === fieldId);\n if (!field) {\n throw new WebinyError(\n `Could not find field with given \"fieldId\" value.`,\n \"FIELD_NOT_FOUND\",\n { fieldId }\n );\n }\n\n const { items } = await this.listEntries.execute(model, {\n where,\n limit: MAX_LIST_LIMIT\n });\n\n return aggregateUniqueFieldValues(items, field.fieldId);\n }\n}\n\nexport const DdbGetUniqueFieldValues = GetUniqueFieldValuesStorageOperation.createImplementation({\n implementation: DdbGetUniqueFieldValuesImpl,\n dependencies: [ListEntriesStorageOperation]\n});\n"],"names":["MAX_LIST_LIMIT","DdbGetUniqueFieldValuesImpl","listEntries","model","params","where","fieldId","field","f","WebinyError","items","aggregateUniqueFieldValues","DdbGetUniqueFieldValues","GetUniqueFieldValuesStorageOperation","ListEntriesStorageOperation"],"mappings":";;;;AASA,MAAMA,iBAAiB;AAEvB,MAAMC;IACF,YAAoBC,WAAkD,CAAE;aAApDA,WAAW,GAAXA;IAAqD;IAEzE,MAAM,QAAQC,KAAe,EAAEC,MAA2D,EAAE;QACxF,MAAM,EAAEC,KAAK,EAAEC,OAAO,EAAE,GAAGF;QAE3B,MAAMG,QAAQJ,MAAM,MAAM,CAAC,IAAI,CAACK,CAAAA,IAAKA,EAAE,OAAO,KAAKF;QACnD,IAAI,CAACC,OACD,MAAM,IAAIE,MACN,oDACA,mBACA;YAAEH;QAAQ;QAIlB,MAAM,EAAEI,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAACP,OAAO;YACpDE;YACA,OAAOL;QACX;QAEA,OAAOW,2BAA2BD,OAAOH,MAAM,OAAO;IAC1D;AACJ;AAEO,MAAMK,0BAA0BC,qCAAqC,oBAAoB,CAAC;IAC7F,gBAAgBZ;IAChB,cAAc;QAACa;KAA4B;AAC/C"}
1
+ {"version":3,"file":"operations/entry/DdbGetUniqueFieldValues.js","sources":["../../../src/operations/entry/DdbGetUniqueFieldValues.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type {\n CmsModel,\n CmsEntryStorageOperationsGetUniqueFieldValuesParams\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { GetUniqueFieldValuesStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/entry/GetUniqueFieldValuesStorageOperation.js\";\nimport { ListEntriesStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/entry/ListEntriesStorageOperation.js\";\nimport { ScopeTenant } from \"@webiny/api-core/features/tenancy/ScopeTenant/index.js\";\nimport { aggregateUniqueFieldValues } from \"@webiny/api-headless-cms-storage\";\n\nconst MAX_LIST_LIMIT = 1000000;\n\nclass DdbGetUniqueFieldValuesImpl implements GetUniqueFieldValuesStorageOperation.Interface {\n constructor(\n private listEntries: ListEntriesStorageOperation.Interface,\n private scopeTenant: ScopeTenant.Interface\n ) {}\n\n async execute(model: CmsModel, params: CmsEntryStorageOperationsGetUniqueFieldValuesParams) {\n this.scopeTenant.getId();\n const { where, fieldId } = params;\n\n const field = model.fields.find(f => f.fieldId === fieldId);\n if (!field) {\n throw new WebinyError(\n `Could not find field with given \"fieldId\" value.`,\n \"FIELD_NOT_FOUND\",\n { fieldId }\n );\n }\n\n const { items } = await this.listEntries.execute(model, {\n where,\n limit: MAX_LIST_LIMIT\n });\n\n return aggregateUniqueFieldValues(items, field.fieldId);\n }\n}\n\nexport const DdbGetUniqueFieldValues = GetUniqueFieldValuesStorageOperation.createImplementation({\n implementation: DdbGetUniqueFieldValuesImpl,\n dependencies: [ListEntriesStorageOperation, ScopeTenant]\n});\n"],"names":["MAX_LIST_LIMIT","DdbGetUniqueFieldValuesImpl","listEntries","scopeTenant","model","params","where","fieldId","field","f","WebinyError","items","aggregateUniqueFieldValues","DdbGetUniqueFieldValues","GetUniqueFieldValuesStorageOperation","ListEntriesStorageOperation","ScopeTenant"],"mappings":";;;;;AAUA,MAAMA,iBAAiB;AAEvB,MAAMC;IACF,YACYC,WAAkD,EAClDC,WAAkC,CAC5C;aAFUD,WAAW,GAAXA;aACAC,WAAW,GAAXA;IACT;IAEH,MAAM,QAAQC,KAAe,EAAEC,MAA2D,EAAE;QACxF,IAAI,CAAC,WAAW,CAAC,KAAK;QACtB,MAAM,EAAEC,KAAK,EAAEC,OAAO,EAAE,GAAGF;QAE3B,MAAMG,QAAQJ,MAAM,MAAM,CAAC,IAAI,CAACK,CAAAA,IAAKA,EAAE,OAAO,KAAKF;QACnD,IAAI,CAACC,OACD,MAAM,IAAIE,MACN,oDACA,mBACA;YAAEH;QAAQ;QAIlB,MAAM,EAAEI,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAACP,OAAO;YACpDE;YACA,OAAON;QACX;QAEA,OAAOY,2BAA2BD,OAAOH,MAAM,OAAO;IAC1D;AACJ;AAEO,MAAMK,0BAA0BC,qCAAqC,oBAAoB,CAAC;IAC7F,gBAAgBb;IAChB,cAAc;QAACc;QAA6BC;KAAY;AAC5D"}
@@ -1,5 +1,6 @@
1
1
  import type { CmsEntry, CmsEntryStorageOperationsListParams, CmsEntryValues, CmsModel } from "@webiny/api-headless-cms/types/index.js";
2
2
  import { ListEntriesStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/ListEntriesStorageOperation.js";
3
+ import { ScopeTenant } from "@webiny/api-core/features/tenancy/ScopeTenant/index.js";
3
4
  import { CmsDdbEntryEntity } from "../../abstractions/CmsDdbEntryEntity.js";
4
5
  import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
5
6
  import { StorageTransformRegistry } from "@webiny/api-headless-cms/exports/api/cms/storage.js";
@@ -16,7 +17,8 @@ declare class DdbListEntriesImpl implements ListEntriesStorageOperation.Interfac
16
17
  private sortingRegistry;
17
18
  private valueFilterRegistry;
18
19
  private entrySystemFields;
19
- constructor(entity: CmsDdbEntryEntity.Interface, storageModelProvider: CmsStorageModelProvider.Interface, storageTransformRegistry: StorageTransformRegistry.Interface, pathRegistry: FieldFilterPathRegistry.Interface, transformRegistry: FieldFilterValueTransformRegistry.Interface, filterCreateRegistry: FieldFilterCreateRegistry.Interface, sortingRegistry: FieldSortingRegistry.Interface, valueFilterRegistry: ValueFilterRegistry.Interface, entrySystemFields: CmsEntrySystemField.Interface[]);
20
+ private scopeTenant;
21
+ constructor(entity: CmsDdbEntryEntity.Interface, storageModelProvider: CmsStorageModelProvider.Interface, storageTransformRegistry: StorageTransformRegistry.Interface, pathRegistry: FieldFilterPathRegistry.Interface, transformRegistry: FieldFilterValueTransformRegistry.Interface, filterCreateRegistry: FieldFilterCreateRegistry.Interface, sortingRegistry: FieldSortingRegistry.Interface, valueFilterRegistry: ValueFilterRegistry.Interface, entrySystemFields: CmsEntrySystemField.Interface[], scopeTenant: ScopeTenant.Interface);
20
22
  execute<T extends CmsEntryValues = CmsEntryValues>(initialModel: CmsModel, params: CmsEntryStorageOperationsListParams): Promise<{
21
23
  hasMoreItems: boolean;
22
24
  totalCount: number;
@@ -1,5 +1,6 @@
1
1
  import error from "@webiny/error";
2
2
  import { ListEntriesStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/ListEntriesStorageOperation.js";
3
+ import { ScopeTenant } from "@webiny/api-core/features/tenancy/ScopeTenant/index.js";
3
4
  import { CmsDdbEntryEntity } from "../../abstractions/CmsDdbEntryEntity.js";
4
5
  import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
5
6
  import { StorageTransformRegistry } from "@webiny/api-headless-cms/exports/api/cms/storage.js";
@@ -11,7 +12,7 @@ import { FieldFilterCreateRegistry, FieldFilterPathRegistry, FieldFilterValueTra
11
12
  import { convertFromStorageEntry } from "./storageEntryUtils.js";
12
13
  const MAX_LIST_LIMIT = 1000000;
13
14
  class DdbListEntriesImpl {
14
- constructor(entity, storageModelProvider, storageTransformRegistry, pathRegistry, transformRegistry, filterCreateRegistry, sortingRegistry, valueFilterRegistry, entrySystemFields){
15
+ constructor(entity, storageModelProvider, storageTransformRegistry, pathRegistry, transformRegistry, filterCreateRegistry, sortingRegistry, valueFilterRegistry, entrySystemFields, scopeTenant){
15
16
  this.entity = entity;
16
17
  this.storageModelProvider = storageModelProvider;
17
18
  this.storageTransformRegistry = storageTransformRegistry;
@@ -21,13 +22,18 @@ class DdbListEntriesImpl {
21
22
  this.sortingRegistry = sortingRegistry;
22
23
  this.valueFilterRegistry = valueFilterRegistry;
23
24
  this.entrySystemFields = entrySystemFields;
25
+ this.scopeTenant = scopeTenant;
24
26
  }
25
27
  async execute(initialModel, params) {
28
+ const tenant = this.scopeTenant.getId();
26
29
  const model = this.storageModelProvider.getModel(initialModel);
27
30
  const { limit: initialLimit = 10, where: initialWhere, after, sort: sortBy, fields, search } = params;
28
31
  const limit = initialLimit <= 0 || initialLimit >= MAX_LIST_LIMIT ? MAX_LIST_LIMIT : initialLimit;
29
32
  const type = initialWhere.published ? "P" : "L";
30
- const partitionKey = createGSIPartitionKey(model, type);
33
+ const partitionKey = createGSIPartitionKey({
34
+ tenant,
35
+ modelId: model.modelId
36
+ }, type);
31
37
  const options = {
32
38
  index: "GSI1",
33
39
  gte: " "
@@ -125,7 +131,8 @@ const DdbListEntries = ListEntriesStorageOperation.createImplementation({
125
131
  {
126
132
  multiple: true
127
133
  }
128
- ]
134
+ ],
135
+ ScopeTenant
129
136
  ]
130
137
  });
131
138
  export { DdbListEntries };
@@ -1 +1 @@
1
- {"version":3,"file":"operations/entry/DdbListEntries.js","sources":["../../../src/operations/entry/DdbListEntries.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type {\n CmsEntry,\n CmsEntryListWhere,\n CmsEntryStorageOperationsListParams,\n CmsEntryValues,\n CmsModel\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { ListEntriesStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/entry/ListEntriesStorageOperation.js\";\nimport { CmsDdbEntryEntity } from \"~/abstractions/CmsDdbEntryEntity.js\";\nimport { CmsStorageModelProvider } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport { StorageTransformRegistry } from \"@webiny/api-headless-cms/exports/api/cms/storage.js\";\nimport { CmsEntrySystemField } from \"@webiny/api-headless-cms/features/contentEntry/EntrySystemField/index.js\";\nimport { createGSIPartitionKey } from \"~/operations/entry/keys.js\";\nimport { decodeCursor, encodeCursor } from \"@webiny/utils\";\nimport { ValueFilterRegistry } from \"@webiny/db-utils\";\nimport {\n createFields,\n filter,\n sort,\n createStorageTransformCallable,\n FieldFilterPathRegistry,\n FieldFilterValueTransformRegistry,\n FieldFilterCreateRegistry,\n FieldSortingRegistry\n} from \"@webiny/api-headless-cms-storage\";\nimport { convertFromStorageEntry } from \"./storageEntryUtils.js\";\n\nconst MAX_LIST_LIMIT = 1000000;\n\nclass DdbListEntriesImpl implements ListEntriesStorageOperation.Interface {\n constructor(\n private entity: CmsDdbEntryEntity.Interface,\n private storageModelProvider: CmsStorageModelProvider.Interface,\n private storageTransformRegistry: StorageTransformRegistry.Interface,\n private pathRegistry: FieldFilterPathRegistry.Interface,\n private transformRegistry: FieldFilterValueTransformRegistry.Interface,\n private filterCreateRegistry: FieldFilterCreateRegistry.Interface,\n private sortingRegistry: FieldSortingRegistry.Interface,\n private valueFilterRegistry: ValueFilterRegistry.Interface,\n private entrySystemFields: CmsEntrySystemField.Interface[]\n ) {}\n\n async execute<T extends CmsEntryValues = CmsEntryValues>(\n initialModel: CmsModel,\n params: CmsEntryStorageOperationsListParams\n ) {\n const model = this.storageModelProvider.getModel(initialModel);\n\n const {\n limit: initialLimit = 10,\n where: initialWhere,\n after,\n sort: sortBy,\n fields,\n search\n } = params;\n const limit =\n initialLimit <= 0 || initialLimit >= MAX_LIST_LIMIT ? MAX_LIST_LIMIT : initialLimit;\n\n const type = initialWhere.published ? \"P\" : \"L\";\n\n const partitionKey = createGSIPartitionKey(model, type);\n const options = {\n index: \"GSI1\",\n gte: \" \"\n };\n\n let storageEntries: Awaited<ReturnType<typeof this.entity.queryAll>> = [];\n try {\n storageEntries = await this.entity.queryAll({\n partitionKey,\n options\n });\n } catch (ex) {\n throw new WebinyError(ex.message, \"QUERY_ENTRIES_ERROR\", {\n error: ex,\n partitionKey,\n options\n });\n }\n if (storageEntries.length === 0) {\n return {\n hasMoreItems: false,\n totalCount: 0,\n cursor: null,\n items: []\n };\n }\n const where: Partial<CmsEntryListWhere> = {\n ...initialWhere\n };\n delete where[\"published\"];\n delete where[\"latest\"];\n /**\n * We need an object containing field, transformers and paths.\n * Just build it here and pass on into other methods that require it to avoid mapping multiple times.\n */\n const pathRegistry = this.pathRegistry;\n const transformRegistry = this.transformRegistry;\n const filterCreateRegistry = this.filterCreateRegistry;\n const sortingRegistry = this.sortingRegistry;\n\n const modelFields = createFields({\n pathRegistry,\n transformRegistry,\n fields: model.fields,\n systemFields: this.entrySystemFields.map(systemField => systemField.field)\n });\n\n const fromStorage = createStorageTransformCallable(this.storageTransformRegistry, model);\n /**\n * Let's transform records from storage ones to regular ones, so we do not need to do it later.\n *\n * This is always being done, but at least its in parallel.\n */\n const records = await Promise.all(\n storageEntries.map(async storageEntry => {\n const entry = convertFromStorageEntry({\n storageEntry: storageEntry.data,\n model\n });\n\n for (const field of model.fields) {\n entry.values[field.fieldId] = await fromStorage(\n field,\n entry.values[field.fieldId]\n );\n }\n\n return entry as CmsEntry<T>;\n })\n );\n /* Resolve the registry once. */\n const valueFilterRegistry = this.valueFilterRegistry;\n\n /**\n * Filter the read items via the code.\n * It will build the filters out of the where input and transform the values it is using.\n */\n const filteredItems = filter<T>({\n items: records,\n where,\n filterCreateRegistry,\n transformRegistry,\n fields: modelFields,\n fullTextSearch: {\n term: search,\n fields: fields || []\n },\n valueFilterRegistry\n });\n\n const totalCount = filteredItems.length;\n\n /**\n * Sorting is also done via the code.\n * It takes the sort input and sorts by it via the lodash sortBy method.\n */\n const sortedItems = sort<T>({\n model,\n items: filteredItems,\n sort: sortBy,\n fields: modelFields,\n sortingRegistry\n });\n\n const start = parseInt((decodeCursor(after) as string) || \"0\") || 0;\n const hasMoreItems = totalCount > start + limit;\n const end = limit > totalCount + start + limit ? undefined : start + limit;\n const slicedItems = sortedItems.slice(start, end);\n /**\n * Although we do not need a cursor here, we will use it as such to keep it standardized.\n * Number is simply encoded.\n */\n const cursor = encodeCursor(`${start + limit}`);\n return {\n hasMoreItems,\n totalCount,\n cursor,\n items: slicedItems\n };\n }\n}\n\nexport const DdbListEntries = ListEntriesStorageOperation.createImplementation({\n implementation: DdbListEntriesImpl,\n dependencies: [\n CmsDdbEntryEntity,\n CmsStorageModelProvider,\n StorageTransformRegistry,\n FieldFilterPathRegistry,\n FieldFilterValueTransformRegistry,\n FieldFilterCreateRegistry,\n FieldSortingRegistry,\n ValueFilterRegistry,\n [CmsEntrySystemField, { multiple: true }]\n ]\n});\n"],"names":["MAX_LIST_LIMIT","DdbListEntriesImpl","entity","storageModelProvider","storageTransformRegistry","pathRegistry","transformRegistry","filterCreateRegistry","sortingRegistry","valueFilterRegistry","entrySystemFields","initialModel","params","model","initialLimit","initialWhere","after","sortBy","fields","search","limit","type","partitionKey","createGSIPartitionKey","options","storageEntries","ex","WebinyError","where","modelFields","createFields","systemField","fromStorage","createStorageTransformCallable","records","Promise","storageEntry","entry","convertFromStorageEntry","field","filteredItems","filter","totalCount","sortedItems","sort","start","parseInt","decodeCursor","hasMoreItems","end","undefined","slicedItems","cursor","encodeCursor","DdbListEntries","ListEntriesStorageOperation","CmsDdbEntryEntity","CmsStorageModelProvider","StorageTransformRegistry","FieldFilterPathRegistry","FieldFilterValueTransformRegistry","FieldFilterCreateRegistry","FieldSortingRegistry","ValueFilterRegistry","CmsEntrySystemField"],"mappings":";;;;;;;;;;;AA4BA,MAAMA,iBAAiB;AAEvB,MAAMC;IACF,YACYC,MAAmC,EACnCC,oBAAuD,EACvDC,wBAA4D,EAC5DC,YAA+C,EAC/CC,iBAA8D,EAC9DC,oBAAyD,EACzDC,eAA+C,EAC/CC,mBAAkD,EAClDC,iBAAkD,CAC5D;aATUR,MAAM,GAANA;aACAC,oBAAoB,GAApBA;aACAC,wBAAwB,GAAxBA;aACAC,YAAY,GAAZA;aACAC,iBAAiB,GAAjBA;aACAC,oBAAoB,GAApBA;aACAC,eAAe,GAAfA;aACAC,mBAAmB,GAAnBA;aACAC,iBAAiB,GAAjBA;IACT;IAEH,MAAM,QACFC,YAAsB,EACtBC,MAA2C,EAC7C;QACE,MAAMC,QAAQ,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAACF;QAEjD,MAAM,EACF,OAAOG,eAAe,EAAE,EACxB,OAAOC,YAAY,EACnBC,KAAK,EACL,MAAMC,MAAM,EACZC,MAAM,EACNC,MAAM,EACT,GAAGP;QACJ,MAAMQ,QACFN,gBAAgB,KAAKA,gBAAgBd,iBAAiBA,iBAAiBc;QAE3E,MAAMO,OAAON,aAAa,SAAS,GAAG,MAAM;QAE5C,MAAMO,eAAeC,sBAAsBV,OAAOQ;QAClD,MAAMG,UAAU;YACZ,OAAO;YACP,KAAK;QACT;QAEA,IAAIC,iBAAmE,EAAE;QACzE,IAAI;YACAA,iBAAiB,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;gBACxCH;gBACAE;YACJ;QACJ,EAAE,OAAOE,IAAI;YACT,MAAM,IAAIC,MAAYD,GAAG,OAAO,EA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AO2B;YACP,MAAMvB;YACN,QAAQY;YACRrB;QACJ;QAEA,MAAMqC,QAAQC,SAAUC,aAAa/B,UAAqB,QAAQ;QAClE,MAAMgC,eAAeN,aAAaG,QAAQzB;QAC1C,MAAM6B,MAAM7B,QAAQsB,aAAaG,QAAQzB,QAAQ8B,SAAYL,QAAQzB;QACrE,MAAM+B,cAAcR,YAAY,KAAK,CAACE,OAAOI;QAK7C,MAAMG,SAASC,aAAa,GAAGR,QAAQzB,OAAO;QAC9C,OAAO;YACH4B;YACAN;YACAU;YACA,OAAOD;QACX;IACJ;AACJ;AAEO,MAAMG,iBAAiBC,4BAA4B,oBAAoB,CAAC;IAC3E,gBAAgBtD;IAChB,cAAc;QACVuD;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACA;YAACC;YAAqB;gBAAE,UAAU;YAAK;SAAE;KAC5C;AACL"}
1
+ {"version":3,"file":"operations/entry/DdbListEntries.js","sources":["../../../src/operations/entry/DdbListEntries.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type {\n CmsEntry,\n CmsEntryListWhere,\n CmsEntryStorageOperationsListParams,\n CmsEntryValues,\n CmsModel\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { ListEntriesStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/entry/ListEntriesStorageOperation.js\";\nimport { ScopeTenant } from \"@webiny/api-core/features/tenancy/ScopeTenant/index.js\";\nimport { CmsDdbEntryEntity } from \"~/abstractions/CmsDdbEntryEntity.js\";\nimport { CmsStorageModelProvider } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport { StorageTransformRegistry } from \"@webiny/api-headless-cms/exports/api/cms/storage.js\";\nimport { CmsEntrySystemField } from \"@webiny/api-headless-cms/features/contentEntry/EntrySystemField/index.js\";\nimport { createGSIPartitionKey } from \"~/operations/entry/keys.js\";\nimport { decodeCursor, encodeCursor } from \"@webiny/utils\";\nimport { ValueFilterRegistry } from \"@webiny/db-utils\";\nimport {\n createFields,\n filter,\n sort,\n createStorageTransformCallable,\n FieldFilterPathRegistry,\n FieldFilterValueTransformRegistry,\n FieldFilterCreateRegistry,\n FieldSortingRegistry\n} from \"@webiny/api-headless-cms-storage\";\nimport { convertFromStorageEntry } from \"./storageEntryUtils.js\";\n\nconst MAX_LIST_LIMIT = 1000000;\n\nclass DdbListEntriesImpl implements ListEntriesStorageOperation.Interface {\n constructor(\n private entity: CmsDdbEntryEntity.Interface,\n private storageModelProvider: CmsStorageModelProvider.Interface,\n private storageTransformRegistry: StorageTransformRegistry.Interface,\n private pathRegistry: FieldFilterPathRegistry.Interface,\n private transformRegistry: FieldFilterValueTransformRegistry.Interface,\n private filterCreateRegistry: FieldFilterCreateRegistry.Interface,\n private sortingRegistry: FieldSortingRegistry.Interface,\n private valueFilterRegistry: ValueFilterRegistry.Interface,\n private entrySystemFields: CmsEntrySystemField.Interface[],\n private scopeTenant: ScopeTenant.Interface\n ) {}\n\n async execute<T extends CmsEntryValues = CmsEntryValues>(\n initialModel: CmsModel,\n params: CmsEntryStorageOperationsListParams\n ) {\n const tenant = this.scopeTenant.getId();\n const model = this.storageModelProvider.getModel(initialModel);\n\n const {\n limit: initialLimit = 10,\n where: initialWhere,\n after,\n sort: sortBy,\n fields,\n search\n } = params;\n const limit =\n initialLimit <= 0 || initialLimit >= MAX_LIST_LIMIT ? MAX_LIST_LIMIT : initialLimit;\n\n const type = initialWhere.published ? \"P\" : \"L\";\n\n const partitionKey = createGSIPartitionKey({ tenant, modelId: model.modelId }, type);\n const options = {\n index: \"GSI1\",\n gte: \" \"\n };\n\n let storageEntries: Awaited<ReturnType<typeof this.entity.queryAll>> = [];\n try {\n storageEntries = await this.entity.queryAll({\n partitionKey,\n options\n });\n } catch (ex) {\n throw new WebinyError(ex.message, \"QUERY_ENTRIES_ERROR\", {\n error: ex,\n partitionKey,\n options\n });\n }\n if (storageEntries.length === 0) {\n return {\n hasMoreItems: false,\n totalCount: 0,\n cursor: null,\n items: []\n };\n }\n const where: Partial<CmsEntryListWhere> = {\n ...initialWhere\n };\n delete where[\"published\"];\n delete where[\"latest\"];\n /**\n * We need an object containing field, transformers and paths.\n * Just build it here and pass on into other methods that require it to avoid mapping multiple times.\n */\n const pathRegistry = this.pathRegistry;\n const transformRegistry = this.transformRegistry;\n const filterCreateRegistry = this.filterCreateRegistry;\n const sortingRegistry = this.sortingRegistry;\n\n const modelFields = createFields({\n pathRegistry,\n transformRegistry,\n fields: model.fields,\n systemFields: this.entrySystemFields.map(systemField => systemField.field)\n });\n\n const fromStorage = createStorageTransformCallable(this.storageTransformRegistry, model);\n /**\n * Let's transform records from storage ones to regular ones, so we do not need to do it later.\n *\n * This is always being done, but at least its in parallel.\n */\n const records = await Promise.all(\n storageEntries.map(async storageEntry => {\n const entry = convertFromStorageEntry({\n storageEntry: storageEntry.data,\n model\n });\n\n for (const field of model.fields) {\n entry.values[field.fieldId] = await fromStorage(\n field,\n entry.values[field.fieldId]\n );\n }\n\n return entry as CmsEntry<T>;\n })\n );\n /* Resolve the registry once. */\n const valueFilterRegistry = this.valueFilterRegistry;\n\n /**\n * Filter the read items via the code.\n * It will build the filters out of the where input and transform the values it is using.\n */\n const filteredItems = filter<T>({\n items: records,\n where,\n filterCreateRegistry,\n transformRegistry,\n fields: modelFields,\n fullTextSearch: {\n term: search,\n fields: fields || []\n },\n valueFilterRegistry\n });\n\n const totalCount = filteredItems.length;\n\n /**\n * Sorting is also done via the code.\n * It takes the sort input and sorts by it via the lodash sortBy method.\n */\n const sortedItems = sort<T>({\n model,\n items: filteredItems,\n sort: sortBy,\n fields: modelFields,\n sortingRegistry\n });\n\n const start = parseInt((decodeCursor(after) as string) || \"0\") || 0;\n const hasMoreItems = totalCount > start + limit;\n const end = limit > totalCount + start + limit ? undefined : start + limit;\n const slicedItems = sortedItems.slice(start, end);\n /**\n * Although we do not need a cursor here, we will use it as such to keep it standardized.\n * Number is simply encoded.\n */\n const cursor = encodeCursor(`${start + limit}`);\n return {\n hasMoreItems,\n totalCount,\n cursor,\n items: slicedItems\n };\n }\n}\n\nexport const DdbListEntries = ListEntriesStorageOperation.createImplementation({\n implementation: DdbListEntriesImpl,\n dependencies: [\n CmsDdbEntryEntity,\n CmsStorageModelProvider,\n StorageTransformRegistry,\n FieldFilterPathRegistry,\n FieldFilterValueTransformRegistry,\n FieldFilterCreateRegistry,\n FieldSortingRegistry,\n ValueFilterRegistry,\n [CmsEntrySystemField, { multiple: true }],\n ScopeTenant\n ]\n});\n"],"names":["MAX_LIST_LIMIT","DdbListEntriesImpl","entity","storageModelProvider","storageTransformRegistry","pathRegistry","transformRegistry","filterCreateRegistry","sortingRegistry","valueFilterRegistry","entrySystemFields","scopeTenant","initialModel","params","tenant","model","initialLimit","initialWhere","after","sortBy","fields","search","limit","type","partitionKey","createGSIPartitionKey","options","storageEntries","ex","WebinyError","where","modelFields","createFields","systemField","fromStorage","createStorageTransformCallable","records","Promise","storageEntry","entry","convertFromStorageEntry","field","filteredItems","filter","totalCount","sortedItems","sort","start","parseInt","decodeCursor","hasMoreItems","end","undefined","slicedItems","cursor","encodeCursor","DdbListEntries","ListEntriesStorageOperation","CmsDdbEntryEntity","CmsStorageModelProvider","StorageTransformRegistry","FieldFilterPathRegistry","FieldFilterValueTransformRegistry","FieldFilterCreateRegistry","FieldSortingRegistry","ValueFilterRegistry","CmsEntrySystemField","ScopeTenant"],"mappings":";;;;;;;;;;;;AA6BA,MAAMA,iBAAiB;AAEvB,MAAMC;IACF,YACYC,MAAmC,EACnCC,oBAAuD,EACvDC,wBAA4D,EAC5DC,YAA+C,EAC/CC,iBAA8D,EAC9DC,oBAAyD,EACzDC,eAA+C,EAC/CC,mBAAkD,EAClDC,iBAAkD,EAClDC,WAAkC,CAC5C;aAVUT,MAAM,GAANA;aACAC,oBAAoB,GAApBA;aACAC,wBAAwB,GAAxBA;aACAC,YAAY,GAAZA;aACAC,iBAAiB,GAAjBA;aACAC,oBAAoB,GAApBA;aACAC,eAAe,GAAfA;aACAC,mBAAmB,GA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AC;QACAC;QACA;YAACC;YAAqB;gBAAE,UAAU;YAAK;SAAE;QACzCC;KACH;AACL"}
@@ -1,13 +1,13 @@
1
1
  import type { CmsModel } from "@webiny/api-headless-cms/types/index.js";
2
2
  import { MoveEntryStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/MoveEntryStorageOperation.js";
3
+ import { ScopeTenant } from "@webiny/api-core/features/tenancy/ScopeTenant/index.js";
3
4
  import { CmsDdbEntryEntity } from "../../abstractions/CmsDdbEntryEntity.js";
4
5
  import { CmsDdbDataLoaders } from "../../abstractions/CmsDdbDataLoaders.js";
5
- import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
6
6
  declare class DdbMoveEntryImpl implements MoveEntryStorageOperation.Interface {
7
7
  private entity;
8
8
  private dataLoaders;
9
- private storageModelProvider;
10
- constructor(entity: CmsDdbEntryEntity.Interface, dataLoaders: CmsDdbDataLoaders.Interface, storageModelProvider: CmsStorageModelProvider.Interface);
9
+ private scopeTenant;
10
+ constructor(entity: CmsDdbEntryEntity.Interface, dataLoaders: CmsDdbDataLoaders.Interface, scopeTenant: ScopeTenant.Interface);
11
11
  execute(initialModel: CmsModel, id: string, folderId: string): Promise<void>;
12
12
  }
13
13
  export declare const DdbMoveEntry: typeof DdbMoveEntryImpl & {
@@ -1,20 +1,20 @@
1
1
  import error from "@webiny/error";
2
2
  import { MoveEntryStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/MoveEntryStorageOperation.js";
3
+ import { ScopeTenant } from "@webiny/api-core/features/tenancy/ScopeTenant/index.js";
3
4
  import { CmsDdbEntryEntity } from "../../abstractions/CmsDdbEntryEntity.js";
4
5
  import { CmsDdbDataLoaders } from "../../abstractions/CmsDdbDataLoaders.js";
5
- import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
6
6
  import { createPartitionKey } from "./keys.js";
7
7
  class DdbMoveEntryImpl {
8
- constructor(entity, dataLoaders, storageModelProvider){
8
+ constructor(entity, dataLoaders, scopeTenant){
9
9
  this.entity = entity;
10
10
  this.dataLoaders = dataLoaders;
11
- this.storageModelProvider = storageModelProvider;
11
+ this.scopeTenant = scopeTenant;
12
12
  }
13
13
  async execute(initialModel, id, folderId) {
14
- const model = this.storageModelProvider.getModel(initialModel);
14
+ const tenant = this.scopeTenant.getId();
15
15
  const partitionKey = createPartitionKey({
16
16
  id,
17
- tenant: model.tenant
17
+ tenant
18
18
  });
19
19
  const records = await this.entity.queryAll({
20
20
  partitionKey,
@@ -37,7 +37,7 @@ class DdbMoveEntryImpl {
37
37
  try {
38
38
  await entityBatch.execute();
39
39
  this.dataLoaders.clearAll({
40
- tenant: model.tenant
40
+ tenant
41
41
  });
42
42
  } catch (ex) {
43
43
  throw error.from(ex, {
@@ -55,7 +55,7 @@ const DdbMoveEntry = MoveEntryStorageOperation.createImplementation({
55
55
  dependencies: [
56
56
  CmsDdbEntryEntity,
57
57
  CmsDdbDataLoaders,
58
- CmsStorageModelProvider
58
+ ScopeTenant
59
59
  ]
60
60
  });
61
61
  export { DdbMoveEntry };
@@ -1 +1 @@
1
- {"version":3,"file":"operations/entry/DdbMoveEntry.js","sources":["../../../src/operations/entry/DdbMoveEntry.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\nimport { MoveEntryStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/entry/MoveEntryStorageOperation.js\";\nimport { CmsDdbEntryEntity } from \"~/abstractions/CmsDdbEntryEntity.js\";\nimport { CmsDdbDataLoaders } from \"~/abstractions/CmsDdbDataLoaders.js\";\nimport { CmsStorageModelProvider } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport { createPartitionKey } from \"~/operations/entry/keys.js\";\n\nclass DdbMoveEntryImpl implements MoveEntryStorageOperation.Interface {\n constructor(\n private entity: CmsDdbEntryEntity.Interface,\n private dataLoaders: CmsDdbDataLoaders.Interface,\n private storageModelProvider: CmsStorageModelProvider.Interface\n ) {}\n\n async execute(initialModel: CmsModel, id: string, folderId: string) {\n /**\n * We need to:\n * - load all the revisions of the entry, including published and latest\n * - update all the revisions (published and latest ) of the entry with new folderId\n */\n const model = this.storageModelProvider.getModel(initialModel);\n /**\n * First we need to load all the revisions and published / latest entry.\n */\n const partitionKey = createPartitionKey({\n id,\n tenant: model.tenant\n });\n const records = await this.entity.queryAll({\n partitionKey,\n options: {\n gte: \" \"\n }\n });\n /**\n * Then create the batch writes for the DynamoDB, with the updated folderId.\n */\n const entityBatch = this.entity.createEntityWriter({\n put: records.map(item => {\n return {\n ...item,\n data: {\n ...item.data,\n location: {\n ...item.data.location,\n folderId\n }\n }\n };\n })\n });\n\n /**\n * And finally write it...\n */\n try {\n await entityBatch.execute();\n\n this.dataLoaders.clearAll({\n tenant: model.tenant\n });\n } catch (ex) {\n throw WebinyError.from(ex, {\n message: \"Could not move records to a new folder.\",\n data: {\n id,\n folderId\n }\n });\n }\n }\n}\n\nexport const DdbMoveEntry = MoveEntryStorageOperation.createImplementation({\n implementation: DdbMoveEntryImpl,\n dependencies: [CmsDdbEntryEntity, CmsDdbDataLoaders, CmsStorageModelProvider]\n});\n"],"names":["DdbMoveEntryImpl","entity","dataLoaders","storageModelProvider","initialModel","id","folderId","model","partitionKey","createPartitionKey","records","entityBatch","item","ex","WebinyError","DdbMoveEntry","MoveEntryStorageOperation","CmsDdbEntryEntity","CmsDdbDataLoaders","CmsStorageModelProvider"],"mappings":";;;;;;AAQA,MAAMA;IACF,YACYC,MAAmC,EACnCC,WAAwC,EACxCC,oBAAuD,CACjE;aAHUF,MAAM,GAANA;aACAC,WAAW,GAAXA;aACAC,oBAAoB,GAApBA;IACT;IAEH,MAAM,QAAQC,YAAsB,EAAEC,EAAU,EAAEC,QAAgB,EAAE;QAMhE,MAAMC,QAAQ,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAACH;QAIjD,MAAMI,eAAeC,mBAAmB;YACpCJ;YACA,QAAQE,MAAM,MAAM;QACxB;QACA,MAAMG,UAAU,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;YACvCF;YACA,SAAS;gBACL,KAAK;YACT;QACJ;QAIA,MAAMG,cAAc,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC;YAC/C,KAAKD,QAAQ,GAAG,CAACE,CAAAA,OACN;oBACH,GAAGA,IAAI;oBACP,MAAM;wBACF,GAAGA,KAAK,IAAI;wBACZ,UAAU;4BACN,GAAGA,KAAK,IAAI,CAAC,QAAQ;4BACrBN;wBACJ;oBACJ;gBACJ;QAER;QAKA,IAAI;YACA,MAAMK,YAAY,OAAO;YAEzB,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC;gBACtB,QAAQJ,MAAM,MAAM;YACxB;QACJ,EAAE,OAAOM,IAAI;YACT,MAAMC,MAAAA,IAAgB,CAACD,IAAI;gBACvB,SAAS;gBACT,MAAM;oBACFR;oBACAC;gBACJ;YACJ;QACJ;IACJ;AACJ;AAEO,MAAMS,eAAeC,0BAA0B,oBAAoB,CAAC;IACvE,gBAAgBhB;IAChB,cAAc;QAACiB;QAAmBC;QAAmBC;KAAwB;AACjF"}
1
+ {"version":3,"file":"operations/entry/DdbMoveEntry.js","sources":["../../../src/operations/entry/DdbMoveEntry.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\nimport { MoveEntryStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/entry/MoveEntryStorageOperation.js\";\nimport { ScopeTenant } from \"@webiny/api-core/features/tenancy/ScopeTenant/index.js\";\nimport { CmsDdbEntryEntity } from \"~/abstractions/CmsDdbEntryEntity.js\";\nimport { CmsDdbDataLoaders } from \"~/abstractions/CmsDdbDataLoaders.js\";\nimport { createPartitionKey } from \"~/operations/entry/keys.js\";\n\nclass DdbMoveEntryImpl implements MoveEntryStorageOperation.Interface {\n constructor(\n private entity: CmsDdbEntryEntity.Interface,\n private dataLoaders: CmsDdbDataLoaders.Interface,\n private scopeTenant: ScopeTenant.Interface\n ) {}\n\n async execute(initialModel: CmsModel, id: string, folderId: string) {\n /**\n * We need to:\n * - load all the revisions of the entry, including published and latest\n * - update all the revisions (published and latest ) of the entry with new folderId\n */\n const tenant = this.scopeTenant.getId();\n /**\n * First we need to load all the revisions and published / latest entry.\n */\n const partitionKey = createPartitionKey({\n id,\n tenant\n });\n const records = await this.entity.queryAll({\n partitionKey,\n options: {\n gte: \" \"\n }\n });\n /**\n * Then create the batch writes for the DynamoDB, with the updated folderId.\n */\n const entityBatch = this.entity.createEntityWriter({\n put: records.map(item => {\n return {\n ...item,\n data: {\n ...item.data,\n location: {\n ...item.data.location,\n folderId\n }\n }\n };\n })\n });\n\n /**\n * And finally write it...\n */\n try {\n await entityBatch.execute();\n\n this.dataLoaders.clearAll({ tenant });\n } catch (ex) {\n throw WebinyError.from(ex, {\n message: \"Could not move records to a new folder.\",\n data: {\n id,\n folderId\n }\n });\n }\n }\n}\n\nexport const DdbMoveEntry = MoveEntryStorageOperation.createImplementation({\n implementation: DdbMoveEntryImpl,\n dependencies: [CmsDdbEntryEntity, CmsDdbDataLoaders, ScopeTenant]\n});\n"],"names":["DdbMoveEntryImpl","entity","dataLoaders","scopeTenant","initialModel","id","folderId","tenant","partitionKey","createPartitionKey","records","entityBatch","item","ex","WebinyError","DdbMoveEntry","MoveEntryStorageOperation","CmsDdbEntryEntity","CmsDdbDataLoaders","ScopeTenant"],"mappings":";;;;;;AAQA,MAAMA;IACF,YACYC,MAAmC,EACnCC,WAAwC,EACxCC,WAAkC,CAC5C;aAHUF,MAAM,GAANA;aACAC,WAAW,GAAXA;aACAC,WAAW,GAAXA;IACT;IAEH,MAAM,QAAQC,YAAsB,EAAEC,EAAU,EAAEC,QAAgB,EAAE;QAMhE,MAAMC,SAAS,IAAI,CAAC,WAAW,CAAC,KAAK;QAIrC,MAAMC,eAAeC,mBAAmB;YACpCJ;YACAE;QACJ;QACA,MAAMG,UAAU,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;YACvCF;YACA,SAAS;gBACL,KAAK;YACT;QACJ;QAIA,MAAMG,cAAc,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC;YAC/C,KAAKD,QAAQ,GAAG,CAACE,CAAAA,OACN;oBACH,GAAGA,IAAI;oBACP,MAAM;wBACF,GAAGA,KAAK,IAAI;wBACZ,UAAU;4BACN,GAAGA,KAAK,IAAI,CAAC,QAAQ;4BACrBN;wBACJ;oBACJ;gBACJ;QAER;QAKA,IAAI;YACA,MAAMK,YAAY,OAAO;YAEzB,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC;gBAAEJ;YAAO;QACvC,EAAE,OAAOM,IAAI;YACT,MAAMC,MAAAA,IAAgB,CAACD,IAAI;gBACvB,SAAS;gBACT,MAAM;oBACFR;oBACAC;gBACJ;YACJ;QACJ;IACJ;AACJ;AAEO,MAAMS,eAAeC,0BAA0B,oBAAoB,CAAC;IACvE,gBAAgBhB;IAChB,cAAc;QAACiB;QAAmBC;QAAmBC;KAAY;AACrE"}
@@ -1,5 +1,6 @@
1
1
  import type { CmsModel, CmsEntryStorageOperationsMoveToBinParams } from "@webiny/api-headless-cms/types/index.js";
2
2
  import { MoveToBinStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/MoveToBinStorageOperation.js";
3
+ import { ScopeTenant } from "@webiny/api-core/features/tenancy/ScopeTenant/index.js";
3
4
  import { CmsDdbEntryEntity } from "../../abstractions/CmsDdbEntryEntity.js";
4
5
  import { CmsDdbDataLoaders } from "../../abstractions/CmsDdbDataLoaders.js";
5
6
  import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
@@ -7,7 +8,8 @@ declare class DdbMoveToBinImpl implements MoveToBinStorageOperation.Interface {
7
8
  private entity;
8
9
  private dataLoaders;
9
10
  private storageModelProvider;
10
- constructor(entity: CmsDdbEntryEntity.Interface, dataLoaders: CmsDdbDataLoaders.Interface, storageModelProvider: CmsStorageModelProvider.Interface);
11
+ private scopeTenant;
12
+ constructor(entity: CmsDdbEntryEntity.Interface, dataLoaders: CmsDdbDataLoaders.Interface, storageModelProvider: CmsStorageModelProvider.Interface, scopeTenant: ScopeTenant.Interface);
11
13
  execute(initialModel: CmsModel, params: CmsEntryStorageOperationsMoveToBinParams): Promise<void>;
12
14
  }
13
15
  export declare const DdbMoveToBin: typeof DdbMoveToBinImpl & {
@@ -1,5 +1,6 @@
1
1
  import error from "@webiny/error";
2
2
  import { MoveToBinStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/MoveToBinStorageOperation.js";
3
+ import { ScopeTenant } from "@webiny/api-core/features/tenancy/ScopeTenant/index.js";
3
4
  import { CmsDdbEntryEntity } from "../../abstractions/CmsDdbEntryEntity.js";
4
5
  import { CmsDdbDataLoaders } from "../../abstractions/CmsDdbDataLoaders.js";
5
6
  import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
@@ -7,20 +8,22 @@ import { createPartitionKey } from "./keys.js";
7
8
  import { isDeletedEntryMetaField, pickEntryMetaFields } from "@webiny/api-headless-cms/constants.js";
8
9
  import { convertToStorageEntry } from "./storageEntryUtils.js";
9
10
  class DdbMoveToBinImpl {
10
- constructor(entity, dataLoaders, storageModelProvider){
11
+ constructor(entity, dataLoaders, storageModelProvider, scopeTenant){
11
12
  this.entity = entity;
12
13
  this.dataLoaders = dataLoaders;
13
14
  this.storageModelProvider = storageModelProvider;
15
+ this.scopeTenant = scopeTenant;
14
16
  }
15
17
  async execute(initialModel, params) {
16
18
  const { entry, storageEntry: initialStorageEntry } = params;
19
+ const tenant = this.scopeTenant.getId();
17
20
  const model = this.storageModelProvider.getModel(initialModel);
18
21
  let records = [];
19
22
  try {
20
23
  records = await this.entity.queryAll({
21
24
  partitionKey: createPartitionKey({
22
25
  id: entry.id,
23
- tenant: model.tenant
26
+ tenant
24
27
  }),
25
28
  options: {
26
29
  gte: " "
@@ -53,7 +56,7 @@ class DdbMoveToBinImpl {
53
56
  try {
54
57
  await entityBatch.execute();
55
58
  this.dataLoaders.clearAll({
56
- tenant: entry.tenant
59
+ tenant
57
60
  });
58
61
  } catch (ex) {
59
62
  throw new error(ex.message || "Could not move the entry to the bin.", ex.code || "MOVE_ENTRY_TO_BIN_ERROR", {
@@ -69,7 +72,8 @@ const DdbMoveToBin = MoveToBinStorageOperation.createImplementation({
69
72
  dependencies: [
70
73
  CmsDdbEntryEntity,
71
74
  CmsDdbDataLoaders,
72
- CmsStorageModelProvider
75
+ CmsStorageModelProvider,
76
+ ScopeTenant
73
77
  ]
74
78
  });
75
79
  export { DdbMoveToBin };
@@ -1 +1 @@
1
- {"version":3,"file":"operations/entry/DdbMoveToBin.js","sources":["../../../src/operations/entry/DdbMoveToBin.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type {\n CmsModel,\n CmsEntryStorageOperationsMoveToBinParams\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { MoveToBinStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/entry/MoveToBinStorageOperation.js\";\nimport { CmsDdbEntryEntity } from \"~/abstractions/CmsDdbEntryEntity.js\";\nimport { CmsDdbDataLoaders } from \"~/abstractions/CmsDdbDataLoaders.js\";\nimport { CmsStorageModelProvider } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport { createPartitionKey } from \"~/operations/entry/keys.js\";\nimport {\n isDeletedEntryMetaField,\n pickEntryMetaFields\n} from \"@webiny/api-headless-cms/constants.js\";\nimport { convertToStorageEntry } from \"./storageEntryUtils.js\";\n\nclass DdbMoveToBinImpl implements MoveToBinStorageOperation.Interface {\n constructor(\n private entity: CmsDdbEntryEntity.Interface,\n private dataLoaders: CmsDdbDataLoaders.Interface,\n private storageModelProvider: CmsStorageModelProvider.Interface\n ) {}\n\n async execute(\n initialModel: CmsModel,\n params: CmsEntryStorageOperationsMoveToBinParams\n ): Promise<void> {\n const { entry, storageEntry: initialStorageEntry } = params;\n const model = this.storageModelProvider.getModel(initialModel);\n\n /**\n * First we need to load all the revisions and published / latest entries.\n */\n\n let records: Awaited<ReturnType<typeof this.entity.queryAll>> = [];\n try {\n records = await this.entity.queryAll({\n partitionKey: createPartitionKey({\n id: entry.id,\n tenant: model.tenant\n }),\n options: {\n gte: \" \"\n }\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not load all records.\",\n ex.code || \"LOAD_ALL_RECORDS_ERROR\",\n {\n error: ex,\n id: entry.id\n }\n );\n }\n if (records.length === 0) {\n return;\n }\n\n const storageEntry = convertToStorageEntry({\n model,\n storageEntry: initialStorageEntry\n });\n\n /**\n * Let's pick the `deleted` meta fields from the storage entry.\n */\n const updatedDeletedMetaFields = pickEntryMetaFields(storageEntry, isDeletedEntryMetaField);\n\n /**\n * Then create the batch writes for the DynamoDB, with the updated data.\n */\n const entityBatch = this.entity.createEntityWriter({\n put: records.map(record => {\n return {\n ...record,\n data: {\n ...record.data,\n ...updatedDeletedMetaFields,\n wbyDeleted: storageEntry.wbyDeleted,\n location: storageEntry.location,\n binOriginalFolderId: storageEntry.binOriginalFolderId\n }\n };\n })\n });\n /**\n * And finally write it...\n */\n try {\n await entityBatch.execute();\n this.dataLoaders.clearAll({\n tenant: entry.tenant\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not move the entry to the bin.\",\n ex.code || \"MOVE_ENTRY_TO_BIN_ERROR\",\n {\n error: ex,\n entry,\n storageEntry\n }\n );\n }\n }\n}\n\nexport const DdbMoveToBin = MoveToBinStorageOperation.createImplementation({\n implementation: DdbMoveToBinImpl,\n dependencies: [CmsDdbEntryEntity, CmsDdbDataLoaders, CmsStorageModelProvider]\n});\n"],"names":["DdbMoveToBinImpl","entity","dataLoaders","storageModelProvider","initialModel","params","entry","initialStorageEntry","model","records","createPartitionKey","ex","WebinyError","storageEntry","convertToStorageEntry","updatedDeletedMetaFields","pickEntryMetaFields","isDeletedEntryMetaField","entityBatch","record","DdbMoveToBin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AW,CAAC,QAAQ,CAAC;gBACtB,QAAQZ,MAAM,MAAM;YACxB;QACJ,EAAE,OAAOK,IAAI;YACT,MAAM,IAAIC,MACND,GAAG,OAAO,IAAI,wCACdA,GAAG,IAAI,IAAI,2BACX;gBACI,OAAOA;gBACPL;gBACAO;YACJ;QAER;IACJ;AACJ;AAEO,MAAMO,eAAeC,0BAA0B,oBAAoB,CAAC;IACvE,gBAAgBrB;IAChB,cAAc;QAACsB;QAAmBC;QAAmBC;KAAwB;AACjF"}
1
+ {"version":3,"file":"operations/entry/DdbMoveToBin.js","sources":["../../../src/operations/entry/DdbMoveToBin.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type {\n CmsModel,\n CmsEntryStorageOperationsMoveToBinParams\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { MoveToBinStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/entry/MoveToBinStorageOperation.js\";\nimport { ScopeTenant } from \"@webiny/api-core/features/tenancy/ScopeTenant/index.js\";\nimport { CmsDdbEntryEntity } from \"~/abstractions/CmsDdbEntryEntity.js\";\nimport { CmsDdbDataLoaders } from \"~/abstractions/CmsDdbDataLoaders.js\";\nimport { CmsStorageModelProvider } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport { createPartitionKey } from \"~/operations/entry/keys.js\";\nimport {\n isDeletedEntryMetaField,\n pickEntryMetaFields\n} from \"@webiny/api-headless-cms/constants.js\";\nimport { convertToStorageEntry } from \"./storageEntryUtils.js\";\n\nclass DdbMoveToBinImpl implements MoveToBinStorageOperation.Interface {\n constructor(\n private entity: CmsDdbEntryEntity.Interface,\n private dataLoaders: CmsDdbDataLoaders.Interface,\n private storageModelProvider: CmsStorageModelProvider.Interface,\n private scopeTenant: ScopeTenant.Interface\n ) {}\n\n async execute(\n initialModel: CmsModel,\n params: CmsEntryStorageOperationsMoveToBinParams\n ): Promise<void> {\n const { entry, storageEntry: initialStorageEntry } = params;\n const tenant = this.scopeTenant.getId();\n const model = this.storageModelProvider.getModel(initialModel);\n\n /**\n * First we need to load all the revisions and published / latest entries.\n */\n\n let records: Awaited<ReturnType<typeof this.entity.queryAll>> = [];\n try {\n records = await this.entity.queryAll({\n partitionKey: createPartitionKey({\n id: entry.id,\n tenant\n }),\n options: {\n gte: \" \"\n }\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not load all records.\",\n ex.code || \"LOAD_ALL_RECORDS_ERROR\",\n {\n error: ex,\n id: entry.id\n }\n );\n }\n if (records.length === 0) {\n return;\n }\n\n const storageEntry = convertToStorageEntry({\n model,\n storageEntry: initialStorageEntry\n });\n\n /**\n * Let's pick the `deleted` meta fields from the storage entry.\n */\n const updatedDeletedMetaFields = pickEntryMetaFields(storageEntry, isDeletedEntryMetaField);\n\n /**\n * Then create the batch writes for the DynamoDB, with the updated data.\n */\n const entityBatch = this.entity.createEntityWriter({\n put: records.map(record => {\n return {\n ...record,\n data: {\n ...record.data,\n ...updatedDeletedMetaFields,\n wbyDeleted: storageEntry.wbyDeleted,\n location: storageEntry.location,\n binOriginalFolderId: storageEntry.binOriginalFolderId\n }\n };\n })\n });\n /**\n * And finally write it...\n */\n try {\n await entityBatch.execute();\n this.dataLoaders.clearAll({ tenant });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not move the entry to the bin.\",\n ex.code || \"MOVE_ENTRY_TO_BIN_ERROR\",\n {\n error: ex,\n entry,\n storageEntry\n }\n );\n }\n }\n}\n\nexport const DdbMoveToBin = MoveToBinStorageOperation.createImplementation({\n implementation: DdbMoveToBinImpl,\n dependencies: [CmsDdbEntryEntity, CmsDdbDataLoaders, CmsStorageModelProvider, ScopeTenant]\n});\n"],"names":["DdbMoveToBinImpl","entity","dataLoaders","storageModelProvider","scopeTenant","initialModel","params","entry","initialStorageEntry","tenant","model","records","createPartitionKey","ex","WebinyError","storageEntry","convertToStorageEntry","updatedDeletedMetaFields","pickEntryMetaFields","isDeletedEntryMetaField","entityBatch","record","DdbMoveToBin","Mo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BACJ;QAER;QAIA,IAAI;YACA,MAAMK,YAAY,OAAO;YACzB,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC;gBAAEX;YAAO;QACvC,EAAE,OAAOI,IAAI;YACT,MAAM,IAAIC,MACND,GAAG,OAAO,IAAI,wCACdA,GAAG,IAAI,IAAI,2BACX;gBACI,OAAOA;gBACPN;gBACAQ;YACJ;QAER;IACJ;AACJ;AAEO,MAAMO,eAAeC,0BAA0B,oBAAoB,CAAC;IACvE,gBAAgBvB;IAChB,cAAc;QAACwB;QAAmBC;QAAmBC;QAAyBC;KAAY;AAC9F"}
@@ -1,5 +1,6 @@
1
1
  import type { CmsModel, CmsEntryValues, CmsEntryStorageOperationsPublishParams } from "@webiny/api-headless-cms/types/index.js";
2
2
  import { PublishEntryStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/PublishEntryStorageOperation.js";
3
+ import { ScopeTenant } from "@webiny/api-core/features/tenancy/ScopeTenant/index.js";
3
4
  import { CmsDdbEntryEntity } from "../../abstractions/CmsDdbEntryEntity.js";
4
5
  import { CmsDdbDataLoaders } from "../../abstractions/CmsDdbDataLoaders.js";
5
6
  import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
@@ -7,7 +8,8 @@ declare class DdbPublishEntryImpl implements PublishEntryStorageOperation.Interf
7
8
  private entity;
8
9
  private dataLoaders;
9
10
  private storageModelProvider;
10
- constructor(entity: CmsDdbEntryEntity.Interface, dataLoaders: CmsDdbDataLoaders.Interface, storageModelProvider: CmsStorageModelProvider.Interface);
11
+ private scopeTenant;
12
+ constructor(entity: CmsDdbEntryEntity.Interface, dataLoaders: CmsDdbDataLoaders.Interface, storageModelProvider: CmsStorageModelProvider.Interface, scopeTenant: ScopeTenant.Interface);
11
13
  private getLatestRevisionByEntryId;
12
14
  private getPublishedRevisionByEntryId;
13
15
  execute<T extends CmsEntryValues = CmsEntryValues>(initialModel: CmsModel, params: CmsEntryStorageOperationsPublishParams<T>): Promise<import("@webiny/api-headless-cms/types/types.js").CmsStorageEntry<T>>;