@webiny/api-headless-cms-ddb 0.0.0-unstable.e622468070 → 0.0.0-unstable.e6f0dc8ca7

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 (69) hide show
  1. package/definitions/entry.js.map +1 -1
  2. package/definitions/model.js.map +1 -1
  3. package/definitions/types.d.ts +7 -5
  4. package/definitions/types.js.map +1 -1
  5. package/dynamoDb/index.d.ts +1 -1
  6. package/dynamoDb/index.js +1 -3
  7. package/dynamoDb/index.js.map +1 -1
  8. package/index.d.ts +1 -2
  9. package/index.js +36 -31
  10. package/index.js.map +1 -1
  11. package/operations/entry/dataLoader/DataLoaderCache.d.ts +1 -0
  12. package/operations/entry/dataLoader/DataLoaderCache.js +2 -5
  13. package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -1
  14. package/operations/entry/dataLoader/getAllEntryRevisions.js +5 -2
  15. package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -1
  16. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +5 -1
  17. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -1
  18. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +5 -1
  19. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -1
  20. package/operations/entry/dataLoader/getRevisionById.js +5 -1
  21. package/operations/entry/dataLoader/getRevisionById.js.map +1 -1
  22. package/operations/entry/dataLoader/types.d.ts +1 -0
  23. package/operations/entry/dataLoader/types.js.map +1 -1
  24. package/operations/entry/dataLoaders.js +3 -1
  25. package/operations/entry/dataLoaders.js.map +1 -1
  26. package/operations/entry/filtering/createExpressions.d.ts +6 -5
  27. package/operations/entry/filtering/createExpressions.js +5 -8
  28. package/operations/entry/filtering/createExpressions.js.map +1 -1
  29. package/operations/entry/filtering/createFields.js +3 -3
  30. package/operations/entry/filtering/createFields.js.map +1 -1
  31. package/operations/entry/filtering/filter.d.ts +5 -4
  32. package/operations/entry/filtering/filter.js +11 -8
  33. package/operations/entry/filtering/filter.js.map +1 -1
  34. package/operations/entry/filtering/fullTextSearch.d.ts +2 -2
  35. package/operations/entry/filtering/fullTextSearch.js +4 -4
  36. package/operations/entry/filtering/fullTextSearch.js.map +1 -1
  37. package/operations/entry/filtering/plugins/defaultFilterCreate.js +4 -4
  38. package/operations/entry/filtering/plugins/defaultFilterCreate.js.map +1 -1
  39. package/operations/entry/filtering/plugins/objectFilterCreate.js +2 -2
  40. package/operations/entry/filtering/plugins/objectFilterCreate.js.map +1 -1
  41. package/operations/entry/filtering/plugins/refFilterCreate.js +4 -4
  42. package/operations/entry/filtering/plugins/refFilterCreate.js.map +1 -1
  43. package/operations/entry/filtering/plugins/searchableJsonFilterCreate.js +7 -2
  44. package/operations/entry/filtering/plugins/searchableJsonFilterCreate.js.map +1 -1
  45. package/operations/entry/filtering/sort.js +2 -2
  46. package/operations/entry/filtering/sort.js.map +1 -1
  47. package/operations/entry/filtering/systemFields.js +15 -0
  48. package/operations/entry/filtering/systemFields.js.map +1 -1
  49. package/operations/entry/filtering/types.d.ts +2 -2
  50. package/operations/entry/filtering/types.js.map +1 -1
  51. package/operations/entry/index.d.ts +2 -0
  52. package/operations/entry/index.js +15 -14
  53. package/operations/entry/index.js.map +1 -1
  54. package/operations/group/index.d.ts +2 -3
  55. package/operations/group/index.js +6 -9
  56. package/operations/group/index.js.map +1 -1
  57. package/operations/model/index.js +0 -1
  58. package/operations/model/index.js.map +1 -1
  59. package/package.json +23 -17
  60. package/plugins/CmsEntryFieldFilterPlugin.d.ts +3 -3
  61. package/plugins/CmsEntryFieldFilterPlugin.js.map +1 -1
  62. package/types.d.ts +5 -3
  63. package/types.js.map +1 -1
  64. package/dynamoDb/storage/longText.d.ts +0 -10
  65. package/dynamoDb/storage/longText.js +0 -86
  66. package/dynamoDb/storage/longText.js.map +0 -1
  67. package/dynamoDb/storage/richText.d.ts +0 -2
  68. package/dynamoDb/storage/richText.js +0 -52
  69. package/dynamoDb/storage/richText.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"names":["createStandardEntity","createEntryEntity","params","table","entityName","name"],"sources":["entry.ts"],"sourcesContent":["import { createStandardEntity, type ITable } from \"@webiny/db-dynamodb\";\nimport type { IEntryEntity, IEntryEntityAttirbutesData } from \"./types.js\";\n\ninterface Params {\n table: ITable;\n entityName: string;\n}\n\nexport const createEntryEntity = (params: Params): IEntryEntity => {\n const { table, entityName } = params;\n return createStandardEntity<IEntryEntityAttirbutesData>({\n name: entityName,\n table: table.table\n });\n};\n"],"mappings":"AAAA,SAASA,oBAAoB,QAAqB,qBAAqB;AAQvE,OAAO,MAAMC,iBAAiB,GAAIC,MAAc,IAAmB;EAC/D,MAAM;IAAEC,KAAK;IAAEC;EAAW,CAAC,GAAGF,MAAM;EACpC,OAAOF,oBAAoB,CAA6B;IACpDK,IAAI,EAAED,UAAU;IAChBD,KAAK,EAAEA,KAAK,CAACA;EACjB,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["createStandardEntity","createEntryEntity","params","table","entityName","name"],"sources":["entry.ts"],"sourcesContent":["import { createStandardEntity, type ITable } from \"@webiny/db-dynamodb\";\nimport type { IEntryEntity, IEntryEntityAttributesData } from \"./types.js\";\n\ninterface Params {\n table: ITable;\n entityName: string;\n}\n\nexport const createEntryEntity = (params: Params): IEntryEntity => {\n const { table, entityName } = params;\n return createStandardEntity<IEntryEntityAttributesData>({\n name: entityName,\n table: table.table\n });\n};\n"],"mappings":"AAAA,SAASA,oBAAoB,QAAqB,qBAAqB;AAQvE,OAAO,MAAMC,iBAAiB,GAAIC,MAAc,IAAmB;EAC/D,MAAM;IAAEC,KAAK;IAAEC;EAAW,CAAC,GAAGF,MAAM;EACpC,OAAOF,oBAAoB,CAA6B;IACpDK,IAAI,EAAED,UAAU;IAChBD,KAAK,EAAEA,KAAK,CAACA;EACjB,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["createStandardEntity","createModelEntity","params","table","entityName","name"],"sources":["model.ts"],"sourcesContent":["import { createStandardEntity, type ITable } from \"@webiny/db-dynamodb\";\nimport type { IModelEntity } from \"./types.js\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\n\ninterface Params {\n table: ITable;\n entityName: string;\n}\n\nexport const createModelEntity = (params: Params): IModelEntity => {\n const { table, entityName } = params;\n return createStandardEntity<CmsModel>({\n table: table.table,\n name: entityName\n });\n};\n"],"mappings":"AAAA,SAASA,oBAAoB,QAAqB,qBAAqB;AASvE,OAAO,MAAMC,iBAAiB,GAAIC,MAAc,IAAmB;EAC/D,MAAM;IAAEC,KAAK;IAAEC;EAAW,CAAC,GAAGF,MAAM;EACpC,OAAOF,oBAAoB,CAAW;IAClCG,KAAK,EAAEA,KAAK,CAACA,KAAK;IAClBE,IAAI,EAAED;EACV,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["createStandardEntity","createModelEntity","params","table","entityName","name"],"sources":["model.ts"],"sourcesContent":["import { createStandardEntity, type ITable } from \"@webiny/db-dynamodb\";\nimport type { IModelEntity } from \"./types.js\";\nimport type { StorageCmsModel } from \"@webiny/api-headless-cms/types/index.js\";\n\ninterface Params {\n table: ITable;\n entityName: string;\n}\n\nexport const createModelEntity = (params: Params): IModelEntity => {\n const { table, entityName } = params;\n return createStandardEntity<StorageCmsModel>({\n table: table.table,\n name: entityName\n });\n};\n"],"mappings":"AAAA,SAASA,oBAAoB,QAAqB,qBAAqB;AASvE,OAAO,MAAMC,iBAAiB,GAAIC,MAAc,IAAmB;EAC/D,MAAM;IAAEC,KAAK;IAAEC;EAAW,CAAC,GAAGF,MAAM;EACpC,OAAOF,oBAAoB,CAAkB;IACzCG,KAAK,EAAEA,KAAK,CAACA,KAAK;IAClBE,IAAI,EAAED;EACV,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
@@ -1,7 +1,7 @@
1
1
  import type { IEntity, IStandardEntityAttributes } from "@webiny/db-dynamodb";
2
2
  import type { GenericRecord } from "@webiny/api/types.js";
3
- import type { CmsEntryStatus, CmsGroup, CmsIdentity, CmsModel, ICmsEntryLocation, IEntryState } from "@webiny/api-headless-cms/types/index.js";
4
- export interface IEntryEntityAttirbutesData {
3
+ import type { CmsEntryStatus, CmsGroup, CmsIdentity, ICmsEntryLive, ICmsEntryLocation, ICmsEntrySystem, StorageCmsModel } from "@webiny/api-headless-cms/types/index.js";
4
+ export interface IEntryEntityAttributesData {
5
5
  id: string;
6
6
  entryId: string;
7
7
  modelId: string;
@@ -51,9 +51,11 @@ export interface IEntryEntityAttirbutesData {
51
51
  binOriginalFolderId?: string;
52
52
  values: GenericRecord;
53
53
  meta?: GenericRecord;
54
- state?: IEntryState;
54
+ system?: ICmsEntrySystem;
55
+ live: ICmsEntryLive | null;
56
+ revisionDescription: string | undefined;
55
57
  }
56
- export type IEntryEntityAttributes = IStandardEntityAttributes<IEntryEntityAttirbutesData>;
57
- export type IModelEntity = IEntity<IStandardEntityAttributes<CmsModel>>;
58
+ export type IEntryEntityAttributes = IStandardEntityAttributes<IEntryEntityAttributesData>;
59
+ export type IModelEntity = IEntity<IStandardEntityAttributes<StorageCmsModel>>;
58
60
  export type IGroupEntity = IEntity<IStandardEntityAttributes<CmsGroup>>;
59
61
  export type IEntryEntity = IEntity<IEntryEntityAttributes>;
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { IEntity, IStandardEntityAttributes } from \"@webiny/db-dynamodb\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\nimport type {\n CmsEntryStatus,\n CmsGroup,\n CmsIdentity,\n CmsModel,\n ICmsEntryLocation,\n IEntryState\n} from \"@webiny/api-headless-cms/types/index.js\";\n\nexport interface IEntryEntityAttirbutesData {\n id: string;\n entryId: string;\n modelId: string;\n\n tenant: string;\n /**\n * Revision-level meta fields. 👇\n */\n revisionCreatedOn: string;\n revisionModifiedOn: string | null;\n revisionSavedOn: string;\n revisionDeletedOn: string | null;\n revisionRestoredOn: string | null;\n revisionFirstPublishedOn: string | null;\n revisionLastPublishedOn: string | null;\n revisionCreatedBy: CmsIdentity;\n revisionModifiedBy: CmsIdentity | null;\n revisionSavedBy: CmsIdentity;\n revisionDeletedBy: CmsIdentity | null;\n revisionRestoredBy: CmsIdentity | null;\n revisionFirstPublishedBy: CmsIdentity | null;\n revisionLastPublishedBy: CmsIdentity | null;\n\n /**\n * Entry-level meta fields. 👇\n */\n createdOn: string;\n modifiedOn: string | null;\n savedOn: string;\n deletedOn: string | null;\n restoredOn: string | null;\n firstPublishedOn: string | null;\n lastPublishedOn: string | null;\n createdBy: CmsIdentity;\n modifiedBy: CmsIdentity | null;\n savedBy: CmsIdentity;\n deletedBy: CmsIdentity | null;\n restoredBy: CmsIdentity | null;\n firstPublishedBy: CmsIdentity | null;\n lastPublishedBy: CmsIdentity | null;\n\n /**\n * The rest. 👇\n */\n version: number;\n locked: boolean;\n status: CmsEntryStatus;\n location?: ICmsEntryLocation;\n wbyDeleted?: boolean | null;\n binOriginalFolderId?: string;\n values: GenericRecord;\n meta?: GenericRecord;\n state?: IEntryState;\n}\n\nexport type IEntryEntityAttributes = IStandardEntityAttributes<IEntryEntityAttirbutesData>;\n\nexport type IModelEntity = IEntity<IStandardEntityAttributes<CmsModel>>;\nexport type IGroupEntity = IEntity<IStandardEntityAttributes<CmsGroup>>;\nexport type IEntryEntity = IEntity<IEntryEntityAttributes>;\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { IEntity, IStandardEntityAttributes } from \"@webiny/db-dynamodb\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\nimport type {\n CmsEntryStatus,\n CmsGroup,\n CmsIdentity,\n ICmsEntryLive,\n ICmsEntryLocation,\n ICmsEntrySystem,\n StorageCmsModel\n} from \"@webiny/api-headless-cms/types/index.js\";\n\nexport interface IEntryEntityAttributesData {\n id: string;\n entryId: string;\n modelId: string;\n\n tenant: string;\n /**\n * Revision-level meta fields. 👇\n */\n revisionCreatedOn: string;\n revisionModifiedOn: string | null;\n revisionSavedOn: string;\n revisionDeletedOn: string | null;\n revisionRestoredOn: string | null;\n revisionFirstPublishedOn: string | null;\n revisionLastPublishedOn: string | null;\n revisionCreatedBy: CmsIdentity;\n revisionModifiedBy: CmsIdentity | null;\n revisionSavedBy: CmsIdentity;\n revisionDeletedBy: CmsIdentity | null;\n revisionRestoredBy: CmsIdentity | null;\n revisionFirstPublishedBy: CmsIdentity | null;\n revisionLastPublishedBy: CmsIdentity | null;\n\n /**\n * Entry-level meta fields. 👇\n */\n createdOn: string;\n modifiedOn: string | null;\n savedOn: string;\n deletedOn: string | null;\n restoredOn: string | null;\n firstPublishedOn: string | null;\n lastPublishedOn: string | null;\n createdBy: CmsIdentity;\n modifiedBy: CmsIdentity | null;\n savedBy: CmsIdentity;\n deletedBy: CmsIdentity | null;\n restoredBy: CmsIdentity | null;\n firstPublishedBy: CmsIdentity | null;\n lastPublishedBy: CmsIdentity | null;\n\n /**\n * The rest. 👇\n */\n version: number;\n locked: boolean;\n status: CmsEntryStatus;\n location?: ICmsEntryLocation;\n wbyDeleted?: boolean | null;\n binOriginalFolderId?: string;\n values: GenericRecord;\n meta?: GenericRecord;\n system?: ICmsEntrySystem;\n live: ICmsEntryLive | null;\n revisionDescription: string | undefined;\n}\n\nexport type IEntryEntityAttributes = IStandardEntityAttributes<IEntryEntityAttributesData>;\n\nexport type IModelEntity = IEntity<IStandardEntityAttributes<StorageCmsModel>>;\nexport type IGroupEntity = IEntity<IStandardEntityAttributes<CmsGroup>>;\nexport type IEntryEntity = IEntity<IEntryEntityAttributes>;\n"],"mappings":"","ignoreList":[]}
@@ -1,2 +1,2 @@
1
- declare const _default: () => (import("@webiny/api-headless-cms/index.js").StorageTransformPlugin<any, any, import("@webiny/api-headless-cms/types/modelField.js").CmsModelField> | import("../index.js").CmsEntryFieldFilterPathPlugin | import("../types.js").CmsFieldFilterValueTransformPlugin)[];
1
+ declare const _default: () => (import("../index.js").CmsEntryFieldFilterPathPlugin | import("../types.js").CmsFieldFilterValueTransformPlugin)[];
2
2
  export default _default;
package/dynamoDb/index.js CHANGED
@@ -1,8 +1,6 @@
1
- import { createRichTextStorageTransformPlugin } from "./storage/richText.js";
2
- import { createLongTextStorageTransformPlugin } from "./storage/longText.js";
3
1
  import { createPlainObjectPathPlugin } from "./path/plainObject.js";
4
2
  import { createDatetimeTransformValuePlugin } from "./transformValue/datetime.js";
5
3
  import { createLocationFolderIdPathPlugin } from "./path/locationFolderId.js";
6
- export default () => [createRichTextStorageTransformPlugin(), createLongTextStorageTransformPlugin(), createPlainObjectPathPlugin(), createLocationFolderIdPathPlugin(), createDatetimeTransformValuePlugin()];
4
+ export default () => [createPlainObjectPathPlugin(), createLocationFolderIdPathPlugin(), createDatetimeTransformValuePlugin()];
7
5
 
8
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createRichTextStorageTransformPlugin","createLongTextStorageTransformPlugin","createPlainObjectPathPlugin","createDatetimeTransformValuePlugin","createLocationFolderIdPathPlugin"],"sources":["index.ts"],"sourcesContent":["import { createRichTextStorageTransformPlugin } from \"./storage/richText.js\";\nimport { createLongTextStorageTransformPlugin } from \"./storage/longText.js\";\nimport { createPlainObjectPathPlugin } from \"./path/plainObject.js\";\nimport { createDatetimeTransformValuePlugin } from \"./transformValue/datetime.js\";\nimport { createLocationFolderIdPathPlugin } from \"~/dynamoDb/path/locationFolderId.js\";\n\nexport default () => [\n createRichTextStorageTransformPlugin(),\n createLongTextStorageTransformPlugin(),\n createPlainObjectPathPlugin(),\n createLocationFolderIdPathPlugin(),\n createDatetimeTransformValuePlugin()\n];\n"],"mappings":"AAAA,SAASA,oCAAoC;AAC7C,SAASC,oCAAoC;AAC7C,SAASC,2BAA2B;AACpC,SAASC,kCAAkC;AAC3C,SAASC,gCAAgC;AAEzC,eAAe,MAAM,CACjBJ,oCAAoC,CAAC,CAAC,EACtCC,oCAAoC,CAAC,CAAC,EACtCC,2BAA2B,CAAC,CAAC,EAC7BE,gCAAgC,CAAC,CAAC,EAClCD,kCAAkC,CAAC,CAAC,CACvC","ignoreList":[]}
1
+ {"version":3,"names":["createPlainObjectPathPlugin","createDatetimeTransformValuePlugin","createLocationFolderIdPathPlugin"],"sources":["index.ts"],"sourcesContent":["import { createPlainObjectPathPlugin } from \"./path/plainObject.js\";\nimport { createDatetimeTransformValuePlugin } from \"./transformValue/datetime.js\";\nimport { createLocationFolderIdPathPlugin } from \"~/dynamoDb/path/locationFolderId.js\";\n\nexport default () => [\n createPlainObjectPathPlugin(),\n createLocationFolderIdPathPlugin(),\n createDatetimeTransformValuePlugin()\n];\n"],"mappings":"AAAA,SAASA,2BAA2B;AACpC,SAASC,kCAAkC;AAC3C,SAASC,gCAAgC;AAEzC,eAAe,MAAM,CACjBF,2BAA2B,CAAC,CAAC,EAC7BE,gCAAgC,CAAC,CAAC,EAClCD,kCAAkC,CAAC,CAAC,CACvC","ignoreList":[]}
package/index.d.ts CHANGED
@@ -1,3 +1,2 @@
1
- import type { StorageOperationsFactory } from "./types.js";
2
1
  export * from "./plugins/index.js";
3
- export declare const createStorageOperations: StorageOperationsFactory;
2
+ export declare const registerDynamoDbStorageOperations: () => import("@webiny/handler").RegisterExtensionPlugin<import("@webiny/handler/types.js").Context>[];
package/index.js CHANGED
@@ -1,25 +1,24 @@
1
- import dynamoDbValueFilters from "@webiny/db-dynamodb/plugins/filters/index.js";
1
+ import { registerExtension as registerDynamoDbExtension } from "@webiny/db-dynamodb";
2
2
  import dynamoDbPlugins from "./dynamoDb/index.js";
3
3
  import { ENTITIES } from "./types.js";
4
4
  import { createGroupEntity } from "./definitions/group.js";
5
5
  import { createModelEntity } from "./definitions/model.js";
6
6
  import { createEntryEntity } from "./definitions/entry.js";
7
- import { PluginsContainer } from "@webiny/plugins";
8
7
  import { createGroupsStorageOperations } from "./operations/group/index.js";
9
8
  import { createModelsStorageOperations } from "./operations/model/index.js";
10
9
  import { createEntriesStorageOperations } from "./operations/entry/index.js";
11
10
  import { createFilterCreatePlugins } from "./operations/entry/filtering/plugins/index.js";
12
- import { CmsEntryFieldFilterPathPlugin, CmsEntryFieldFilterPlugin, CmsEntryFieldSortingPlugin, CmsFieldFilterValueTransformPlugin } from "./plugins/index.js";
13
- import { ValueFilterPlugin } from "@webiny/db-dynamodb/plugins/definitions/ValueFilterPlugin.js";
14
- import { StorageOperationsCmsModelPlugin, StorageTransformPlugin } from "@webiny/api-headless-cms";
15
- import { CompressorPlugin } from "@webiny/api";
16
11
  import { createTable } from "./definitions/table.js";
12
+ import { createRegisterExtensionPlugin } from "@webiny/handler";
13
+ import { createFeature } from "@webiny/feature/api/index.js";
14
+ import { StorageOperationsFactory as StorageOperationsFactoryAbstraction } from "@webiny/api-headless-cms/exports/api/cms/storage.js";
17
15
  export * from "./plugins/index.js";
18
- export const createStorageOperations = params => {
16
+ const createDynamoDbStorageOperations = params => {
19
17
  const {
20
18
  table,
21
19
  documentClient,
22
- plugins: userPlugins
20
+ plugins,
21
+ container
23
22
  } = params;
24
23
  const tableInstance = createTable({
25
24
  name: table,
@@ -39,11 +38,7 @@ export const createStorageOperations = params => {
39
38
  table: tableInstance
40
39
  })
41
40
  };
42
- const plugins = new PluginsContainer([
43
- /**
44
- * DynamoDB filter plugins for the where conditions.
45
- */
46
- dynamoDbValueFilters(),
41
+ plugins.register([
47
42
  /**
48
43
  * Field plugins for DynamoDB.
49
44
  */
@@ -51,36 +46,22 @@ export const createStorageOperations = params => {
51
46
  /**
52
47
  * Filter create plugins.
53
48
  */
54
- createFilterCreatePlugins(),
55
- /**
56
- * User defined custom plugins.
57
- */
58
- ...(userPlugins || [])]);
49
+ createFilterCreatePlugins()]);
59
50
  const entries = createEntriesStorageOperations({
60
51
  entity: entities.entries,
52
+ container,
61
53
  plugins
62
54
  });
63
55
  return {
64
56
  name: "dynamodb",
65
- beforeInit: async context => {
66
- const types = ["cms-model-field-to-graphql", CmsEntryFieldFilterPathPlugin.type, CmsFieldFilterValueTransformPlugin.type, CmsEntryFieldFilterPlugin.type, CmsEntryFieldSortingPlugin.type, ValueFilterPlugin.type, StorageOperationsCmsModelPlugin.type, StorageTransformPlugin.type, CompressorPlugin.type];
67
- /**
68
- * Collect all required plugins from parent context.
69
- */
70
- for (const type of types) {
71
- plugins.mergeByType(context.plugins, type);
72
- }
73
- /**
74
- * Pass the plugins to the parent context.
75
- */
76
- context.plugins.register([dynamoDbPlugins()]);
57
+ beforeInit: async () => {
77
58
  entries.dataLoaders.clearAll();
78
59
  },
79
60
  getEntities: () => entities,
80
61
  getTable: () => tableInstance,
81
62
  groups: createGroupsStorageOperations({
82
63
  entity: entities.groups,
83
- plugins
64
+ container
84
65
  }),
85
66
  models: createModelsStorageOperations({
86
67
  entity: entities.models
@@ -88,5 +69,29 @@ export const createStorageOperations = params => {
88
69
  entries
89
70
  };
90
71
  };
72
+ class DynamoDbStorageOperationsFactoryImpl {
73
+ async create(context) {
74
+ return createDynamoDbStorageOperations({
75
+ documentClient: context.db.driver.getClient(),
76
+ plugins: context.plugins,
77
+ container: context.container
78
+ });
79
+ }
80
+ }
81
+ const DynamoDbStorageOperationsFactory = StorageOperationsFactoryAbstraction.createImplementation({
82
+ implementation: DynamoDbStorageOperationsFactoryImpl,
83
+ dependencies: []
84
+ });
85
+ const storageOperationsFeature = createFeature({
86
+ name: "cms.storageOperations.openSearch",
87
+ register: container => {
88
+ container.register(DynamoDbStorageOperationsFactory).inSingletonScope();
89
+ }
90
+ });
91
+ export const registerDynamoDbStorageOperations = () => {
92
+ return [registerDynamoDbExtension(), createRegisterExtensionPlugin(context => {
93
+ return storageOperationsFeature.register(context.container);
94
+ })];
95
+ };
91
96
 
92
97
  //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["dynamoDbValueFilters","dynamoDbPlugins","ENTITIES","createGroupEntity","createModelEntity","createEntryEntity","PluginsContainer","createGroupsStorageOperations","createModelsStorageOperations","createEntriesStorageOperations","createFilterCreatePlugins","CmsEntryFieldFilterPathPlugin","CmsEntryFieldFilterPlugin","CmsEntryFieldSortingPlugin","CmsFieldFilterValueTransformPlugin","ValueFilterPlugin","StorageOperationsCmsModelPlugin","StorageTransformPlugin","CompressorPlugin","createTable","createStorageOperations","params","table","documentClient","plugins","userPlugins","tableInstance","name","entities","groups","entityName","GROUPS","models","MODELS","entries","ENTRIES","entity","beforeInit","context","types","type","mergeByType","register","dataLoaders","clearAll","getEntities","getTable"],"sources":["index.ts"],"sourcesContent":["import dynamoDbValueFilters from \"@webiny/db-dynamodb/plugins/filters/index.js\";\nimport dynamoDbPlugins from \"./dynamoDb/index.js\";\nimport type { StorageOperationsFactory } from \"~/types.js\";\nimport { ENTITIES } from \"~/types.js\";\nimport { createGroupEntity } from \"~/definitions/group.js\";\nimport { createModelEntity } from \"~/definitions/model.js\";\nimport { createEntryEntity } from \"~/definitions/entry.js\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { createGroupsStorageOperations } from \"~/operations/group/index.js\";\nimport { createModelsStorageOperations } from \"~/operations/model/index.js\";\nimport { createEntriesStorageOperations } from \"./operations/entry/index.js\";\n\nimport { createFilterCreatePlugins } from \"~/operations/entry/filtering/plugins/index.js\";\nimport {\n CmsEntryFieldFilterPathPlugin,\n CmsEntryFieldFilterPlugin,\n CmsEntryFieldSortingPlugin,\n CmsFieldFilterValueTransformPlugin\n} from \"~/plugins/index.js\";\nimport { ValueFilterPlugin } from \"@webiny/db-dynamodb/plugins/definitions/ValueFilterPlugin.js\";\nimport { StorageOperationsCmsModelPlugin, StorageTransformPlugin } from \"@webiny/api-headless-cms\";\nimport { CompressorPlugin } from \"@webiny/api\";\nimport { createTable } from \"~/definitions/table.js\";\n\nexport * from \"./plugins/index.js\";\n\nexport const createStorageOperations: StorageOperationsFactory = params => {\n const { table, documentClient, plugins: userPlugins } = params;\n\n const tableInstance = createTable({\n name: table,\n documentClient\n });\n\n const entities = {\n groups: createGroupEntity({\n entityName: ENTITIES.GROUPS,\n table: tableInstance\n }),\n models: createModelEntity({\n entityName: ENTITIES.MODELS,\n table: tableInstance\n }),\n entries: createEntryEntity({\n entityName: ENTITIES.ENTRIES,\n table: tableInstance\n })\n };\n\n const plugins = new PluginsContainer([\n /**\n * DynamoDB filter plugins for the where conditions.\n */\n dynamoDbValueFilters(),\n /**\n * Field plugins for DynamoDB.\n */\n dynamoDbPlugins(),\n /**\n * Filter create plugins.\n */\n createFilterCreatePlugins(),\n /**\n * User defined custom plugins.\n */\n ...(userPlugins || [])\n ]);\n\n const entries = createEntriesStorageOperations({\n entity: entities.entries,\n plugins\n });\n\n return {\n name: \"dynamodb\",\n beforeInit: async context => {\n const types: string[] = [\n \"cms-model-field-to-graphql\",\n CmsEntryFieldFilterPathPlugin.type,\n CmsFieldFilterValueTransformPlugin.type,\n CmsEntryFieldFilterPlugin.type,\n CmsEntryFieldSortingPlugin.type,\n ValueFilterPlugin.type,\n StorageOperationsCmsModelPlugin.type,\n StorageTransformPlugin.type,\n CompressorPlugin.type\n ];\n /**\n * Collect all required plugins from parent context.\n */\n for (const type of types) {\n plugins.mergeByType(context.plugins, type);\n }\n /**\n * Pass the plugins to the parent context.\n */\n context.plugins.register([dynamoDbPlugins()]);\n\n entries.dataLoaders.clearAll();\n },\n getEntities: () => entities,\n getTable: () => tableInstance,\n groups: createGroupsStorageOperations({\n entity: entities.groups,\n plugins\n }),\n models: createModelsStorageOperations({\n entity: entities.models\n }),\n entries\n };\n};\n"],"mappings":"AAAA,OAAOA,oBAAoB,MAAM,8CAA8C;AAC/E,OAAOC,eAAe;AAEtB,SAASC,QAAQ;AACjB,SAASC,iBAAiB;AAC1B,SAASC,iBAAiB;AAC1B,SAASC,iBAAiB;AAC1B,SAASC,gBAAgB,QAAQ,iBAAiB;AAClD,SAASC,6BAA6B;AACtC,SAASC,6BAA6B;AACtC,SAASC,8BAA8B;AAEvC,SAASC,yBAAyB;AAClC,SACIC,6BAA6B,EAC7BC,yBAAyB,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AAG,CACpB,4BAA4B,EAC5B5B,6BAA6B,CAAC6B,IAAI,EAClC1B,kCAAkC,CAAC0B,IAAI,EACvC5B,yBAAyB,CAAC4B,IAAI,EAC9B3B,0BAA0B,CAAC2B,IAAI,EAC/BzB,iBAAiB,CAACyB,IAAI,EACtBxB,+BAA+B,CAACwB,IAAI,EACpCvB,sBAAsB,CAACuB,IAAI,EAC3BtB,gBAAgB,CAACsB,IAAI,CACxB;MACD;AACZ;AACA;MACY,KAAK,MAAMA,IAAI,IAAID,KAAK,EAAE;QACtBf,OAAO,CAACiB,WAAW,CAACH,OAAO,CAACd,OAAO,EAAEgB,IAAI,CAAC;MAC9C;MACA;AACZ;AACA;MACYF,OAAO,CAACd,OAAO,CAACkB,QAAQ,CAAC,CAACzC,eAAe,CAAC,CAAC,CAAC,CAAC;MAE7CiC,OAAO,CAACS,WAAW,CAACC,QAAQ,CAAC,CAAC;IAClC,CAAC;IACDC,WAAW,EAAEA,CAAA,KAAMjB,QAAQ;IAC3BkB,QAAQ,EAAEA,CAAA,KAAMpB,aAAa;IAC7BG,MAAM,EAAEtB,6BAA6B,CAAC;MAClC6B,MAAM,EAAER,QAAQ,CAACC,MAAM;MACvBL;IACJ,CAAC,CAAC;IACFQ,MAAM,EAAExB,6BAA6B,CAAC;MAClC4B,MAAM,EAAER,QAAQ,CAACI;IACrB,CAAC,CAAC;IACFE;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["registerExtension","registerDynamoDbExtension","dynamoDbPlugins","ENTITIES","createGroupEntity","createModelEntity","createEntryEntity","createGroupsStorageOperations","createModelsStorageOperations","createEntriesStorageOperations","createFilterCreatePlugins","createTable","createRegisterExtensionPlugin","createFeature","StorageOperationsFactory","StorageOperationsFactoryAbstraction","createDynamoDbStorageOperations","params","table","documentClient","plugins","container","tableInstance","name","entities","groups","entityName","GROUPS","models","MODELS","entries","ENTRIES","register","entity","beforeInit","dataLoaders","clearAll","getEntities","getTable","DynamoDbStorageOperationsFactoryImpl","create","context","db","driver","getClient","DynamoDbStorageOperationsFactory","createImplementation","implementation","dependencies","storageOperationsFeature","inSingletonScope","registerDynamoDbStorageOperations"],"sources":["index.ts"],"sourcesContent":["import { registerExtension as registerDynamoDbExtension } from \"@webiny/db-dynamodb\";\nimport dynamoDbPlugins from \"./dynamoDb/index.js\";\nimport type { CmsContext, StorageOperationsFactory } from \"~/types.js\";\nimport { ENTITIES } from \"~/types.js\";\nimport { createGroupEntity } from \"~/definitions/group.js\";\nimport { createModelEntity } from \"~/definitions/model.js\";\nimport { createEntryEntity } from \"~/definitions/entry.js\";\nimport { createGroupsStorageOperations } from \"~/operations/group/index.js\";\nimport { createModelsStorageOperations } from \"~/operations/model/index.js\";\nimport { createEntriesStorageOperations } from \"./operations/entry/index.js\";\nimport { createFilterCreatePlugins } from \"~/operations/entry/filtering/plugins/index.js\";\nimport { createTable } from \"~/definitions/table.js\";\nimport { createRegisterExtensionPlugin } from \"@webiny/handler\";\nimport { createFeature } from \"@webiny/feature/api/index.js\";\nimport { StorageOperationsFactory as StorageOperationsFactoryAbstraction } from \"@webiny/api-headless-cms/exports/api/cms/storage.js\";\nimport type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\n\nexport * from \"./plugins/index.js\";\n\nconst createDynamoDbStorageOperations: StorageOperationsFactory = params => {\n const { table, documentClient, plugins, container } = params;\n\n const tableInstance = createTable({\n name: table,\n documentClient\n });\n\n const entities = {\n groups: createGroupEntity({\n entityName: ENTITIES.GROUPS,\n table: tableInstance\n }),\n models: createModelEntity({\n entityName: ENTITIES.MODELS,\n table: tableInstance\n }),\n entries: createEntryEntity({\n entityName: ENTITIES.ENTRIES,\n table: tableInstance\n })\n };\n\n plugins.register([\n /**\n * Field plugins for DynamoDB.\n */\n dynamoDbPlugins(),\n /**\n * Filter create plugins.\n */\n createFilterCreatePlugins()\n ]);\n\n const entries = createEntriesStorageOperations({\n entity: entities.entries,\n container,\n plugins\n });\n\n return {\n name: \"dynamodb\",\n beforeInit: async () => {\n entries.dataLoaders.clearAll();\n },\n getEntities: () => entities,\n getTable: () => tableInstance,\n groups: createGroupsStorageOperations({\n entity: entities.groups,\n container\n }),\n models: createModelsStorageOperations({\n entity: entities.models\n }),\n entries\n };\n};\n\nclass DynamoDbStorageOperationsFactoryImpl\n implements StorageOperationsFactoryAbstraction.Interface\n{\n public async create(context: CmsContext) {\n return createDynamoDbStorageOperations({\n documentClient: context.db.driver.getClient() as DynamoDBDocument,\n plugins: context.plugins,\n container: context.container\n });\n }\n}\n\nconst DynamoDbStorageOperationsFactory = StorageOperationsFactoryAbstraction.createImplementation({\n implementation: DynamoDbStorageOperationsFactoryImpl,\n dependencies: []\n});\n\nconst storageOperationsFeature = createFeature({\n name: \"cms.storageOperations.openSearch\",\n register: container => {\n container.register(DynamoDbStorageOperationsFactory).inSingletonScope();\n }\n});\n\nexport const registerDynamoDbStorageOperations = () => {\n return [\n registerDynamoDbExtension(),\n createRegisterExtensionPlugin(context => {\n return storageOperationsFeature.register(context.container);\n })\n ];\n};\n"],"mappings":"AAAA,SAASA,iBAAiB,IAAIC,yBAAyB,QAAQ,qBAAqB;AACpF,OAAOC,eAAe;AAEtB,SAASC,QAAQ;AACjB,SAASC,iBAAiB;AAC1B,SAASC,iBAAiB;AAC1B,SAASC,iBAAiB;AAC1B,SAASC,6BAA6B;AACtC,SAASC,6BAA6B;AACtC,SAASC,8BAA8B;AACvC,SAASC,yBAAyB;AAClC,SAASC,WAAW;AACpB,SAASC,6BAA6B,QAAQ,iBAAiB;AAC/D,SAASC,aAAa,QAAQ,8BAA8B;AAC5D,SAASC,wBAAwB,IAAIC,mCAAmC,QAAQ,qDAAqD;AAGrI;AAEA,MAAMC,+BAAyD,GAAGC,MAAM,IAAI;EACxE,MAAM;IAAEC,KAAK;IAAEC,cAAc;IAAEC,OAAO;IAAEC;EAAU,CAAC,GAAGJ,MAAM;EAE5D,MAAMK,aAAa,GAAGX,WAAW,CAAC;IAC9BY,IAAI,E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O,CAACC,EAAE,CAACC,MAAM,CAACC,SAAS,CAAC,CAAqB;MACjExB,OAAO,EAAEqB,OAAO,CAACrB,OAAO;MACxBC,SAAS,EAAEoB,OAAO,CAACpB;IACvB,CAAC,CAAC;EACN;AACJ;AAEA,MAAMwB,gCAAgC,GAAG9B,mCAAmC,CAAC+B,oBAAoB,CAAC;EAC9FC,cAAc,EAAER,oCAAoC;EACpDS,YAAY,EAAE;AAClB,CAAC,CAAC;AAEF,MAAMC,wBAAwB,GAAGpC,aAAa,CAAC;EAC3CU,IAAI,EAAE,kCAAkC;EACxCS,QAAQ,EAAEX,SAAS,IAAI;IACnBA,SAAS,CAACW,QAAQ,CAACa,gCAAgC,CAAC,CAACK,gBAAgB,CAAC,CAAC;EAC3E;AACJ,CAAC,CAAC;AAEF,OAAO,MAAMC,iCAAiC,GAAGA,CAAA,KAAM;EACnD,OAAO,CACHlD,yBAAyB,CAAC,CAAC,EAC3BW,6BAA6B,CAAC6B,OAAO,IAAI;IACrC,OAAOQ,wBAAwB,CAACjB,QAAQ,CAACS,OAAO,CAACpB,SAAS,CAAC;EAC/D,CAAC,CAAC,CACL;AACL,CAAC","ignoreList":[]}
@@ -2,6 +2,7 @@ import type DataLoader from "dataloader";
2
2
  export interface CacheKeyParams {
3
3
  name: string;
4
4
  tenant: string;
5
+ modelId: string;
5
6
  }
6
7
  export interface ClearAllParams {
7
8
  tenant: string;
@@ -15,10 +15,7 @@ export class DataLoaderCache {
15
15
  }
16
16
  return;
17
17
  }
18
- const key = this.createKey({
19
- ...params,
20
- name: ""
21
- });
18
+ const key = `${params.tenant}_`;
22
19
  for (const current in this.cache) {
23
20
  if (current.startsWith(key) === false) {
24
21
  continue;
@@ -27,7 +24,7 @@ export class DataLoaderCache {
27
24
  }
28
25
  }
29
26
  createKey(params) {
30
- return `${params.tenant}_${params.name}`;
27
+ return `${params.tenant}_${params.modelId}_${params.name}`;
31
28
  }
32
29
  }
33
30
 
@@ -1 +1 @@
1
- {"version":3,"names":["DataLoaderCache","cache","getDataLoader","params","key","createKey","setDataLoader","dataLoader","clearAll","current","name","startsWith","tenant"],"sources":["DataLoaderCache.ts"],"sourcesContent":["import type DataLoader from \"dataloader\";\n\nexport interface CacheKeyParams {\n name: string;\n tenant: string;\n}\n\nexport interface ClearAllParams {\n tenant: string;\n}\n\nexport class DataLoaderCache {\n private readonly cache: Record<string, DataLoader<any, any>> = {};\n\n public getDataLoader<I = any, R = any>(params: CacheKeyParams): DataLoader<I, R> | null {\n const key = this.createKey(params);\n\n return this.cache[key] || null;\n }\n\n public setDataLoader(params: CacheKeyParams, dataLoader: DataLoader<any, any>): void {\n const key = this.createKey(params);\n this.cache[key] = dataLoader;\n }\n\n public clearAll(params?: ClearAllParams): void {\n if (!params) {\n for (const current in this.cache) {\n this.cache[current].clearAll();\n }\n return;\n }\n const key = this.createKey({\n ...params,\n name: \"\"\n });\n for (const current in this.cache) {\n if (current.startsWith(key) === false) {\n continue;\n }\n this.cache[current].clearAll();\n }\n }\n\n private createKey(params: CacheKeyParams): string {\n return `${params.tenant}_${params.name}`;\n }\n}\n"],"mappings":"AAWA,OAAO,MAAMA,eAAe,CAAC;EACRC,KAAK,GAAyC,CAAC,CAAC;EAE1DC,aAAaA,CAAmBC,MAAsB,EAA2B;IACpF,MAAMC,GAAG,GAAG,IAAI,CAACC,SAAS,CAACF,MAAM,CAAC;IAElC,OAAO,IAAI,CAACF,KAAK,CAACG,GAAG,CAAC,IAAI,IAAI;EAClC;EAEOE,aAAaA,CAACH,MAAsB,EAAEI,UAAgC,EAAQ;IACjF,MAAMH,GAAG,GAAG,IAAI,CAACC,SAAS,CAACF,MAAM,CAAC;IAClC,IAAI,CAACF,KAAK,CAACG,GAAG,CAAC,GAAGG,UAAU;EAChC;EAEOC,QAAQA,CAACL,MAAuB,EAAQ;IAC3C,IAAI,CAACA,MAAM,EAAE;MACT,KAAK,MAAMM,OAAO,IAAI,IAAI,CAACR,KAAK,EAAE;QAC9B,IAAI,CAACA,KAAK,CAACQ,OAAO,CAAC,CAACD,QAAQ,CAAC,CAAC;MAClC;MACA;IACJ;IACA,MAAMJ,GAAG,GAAG,IAAI,CAACC,SAAS,CAAC;MACvB,GAAGF,MAAM;MACTO,IAAI,EAAE;IACV,CAAC,CAAC;IACF,KAAK,MAAMD,OAAO,IAAI,IAAI,CAACR,KAAK,EAAE;MAC9B,IAAIQ,OAAO,CAACE,UAAU,CAACP,GAAG,CAAC,KAAK,KAAK,EAAE;QACnC;MACJ;MACA,IAAI,CAACH,KAAK,CAACQ,OAAO,CAAC,CAACD,QAAQ,CAAC,CAAC;IAClC;EACJ;EAEQH,SAASA,CAACF,MAAsB,EAAU;IAC9C,OAAO,GAAGA,MAAM,CAACS,MAAM,IAAIT,MAAM,CAACO,IAAI,EAAE;EAC5C;AACJ","ignoreList":[]}
1
+ {"version":3,"names":["DataLoaderCache","cache","getDataLoader","params","key","createKey","setDataLoader","dataLoader","clearAll","current","tenant","startsWith","modelId","name"],"sources":["DataLoaderCache.ts"],"sourcesContent":["import type DataLoader from \"dataloader\";\n\nexport interface CacheKeyParams {\n name: string;\n tenant: string;\n modelId: string;\n}\n\nexport interface ClearAllParams {\n tenant: string;\n}\n\nexport class DataLoaderCache {\n private readonly cache: Record<string, DataLoader<any, any>> = {};\n\n public getDataLoader<I = any, R = any>(params: CacheKeyParams): DataLoader<I, R> | null {\n const key = this.createKey(params);\n\n return this.cache[key] || null;\n }\n\n public setDataLoader(params: CacheKeyParams, dataLoader: DataLoader<any, any>): void {\n const key = this.createKey(params);\n this.cache[key] = dataLoader;\n }\n\n public clearAll(params?: ClearAllParams): void {\n if (!params) {\n for (const current in this.cache) {\n this.cache[current].clearAll();\n }\n return;\n }\n const key = `${params.tenant}_`;\n for (const current in this.cache) {\n if (current.startsWith(key) === false) {\n continue;\n }\n this.cache[current].clearAll();\n }\n }\n\n private createKey(params: CacheKeyParams): string {\n return `${params.tenant}_${params.modelId}_${params.name}`;\n }\n}\n"],"mappings":"AAYA,OAAO,MAAMA,eAAe,CAAC;EACRC,KAAK,GAAyC,CAAC,CAAC;EAE1DC,aAAaA,CAAmBC,MAAsB,EAA2B;IACpF,MAAMC,GAAG,GAAG,IAAI,CAACC,SAAS,CAACF,MAAM,CAAC;IAElC,OAAO,IAAI,CAACF,KAAK,CAACG,GAAG,CAAC,IAAI,IAAI;EAClC;EAEOE,aAAaA,CAACH,MAAsB,EAAEI,UAAgC,EAAQ;IACjF,MAAMH,GAAG,GAAG,IAAI,CAACC,SAAS,CAACF,MAAM,CAAC;IAClC,IAAI,CAACF,KAAK,CAACG,GAAG,CAAC,GAAGG,UAAU;EAChC;EAEOC,QAAQA,CAACL,MAAuB,EAAQ;IAC3C,IAAI,CAACA,MAAM,EAAE;MACT,KAAK,MAAMM,OAAO,IAAI,IAAI,CAACR,KAAK,EAAE;QAC9B,IAAI,CAACA,KAAK,CAACQ,OAAO,CAAC,CAACD,QAAQ,CAAC,CAAC;MAClC;MACA;IACJ;IACA,MAAMJ,GAAG,GAAG,GAAGD,MAAM,CAACO,MAAM,GAAG;IAC/B,KAAK,MAAMD,OAAO,IAAI,IAAI,CAACR,KAAK,EAAE;MAC9B,IAAIQ,OAAO,CAACE,UAAU,CAACP,GAAG,CAAC,KAAK,KAAK,EAAE;QACnC;MACJ;MACA,IAAI,CAACH,KAAK,CAACQ,OAAO,CAAC,CAACD,QAAQ,CAAC,CAAC;IAClC;EACJ;EAEQH,SAASA,CAACF,MAAsB,EAAU;IAC9C,OAAO,GAAGA,MAAM,CAACO,MAAM,IAAIP,MAAM,CAACS,OAAO,IAAIT,MAAM,CAACU,IAAI,EAAE;EAC9D;AACJ","ignoreList":[]}
@@ -4,7 +4,8 @@ import { createBatchScheduleFn } from "./createBatchScheduleFn.js";
4
4
  export const createGetAllEntryRevisions = params => {
5
5
  const {
6
6
  entity,
7
- tenant
7
+ tenant,
8
+ modelId
8
9
  } = params;
9
10
  return new DataLoader(async ids => {
10
11
  const results = {};
@@ -22,7 +23,9 @@ export const createGetAllEntryRevisions = params => {
22
23
  });
23
24
  }
24
25
  return ids.map(id => {
25
- return results[id] || [];
26
+ return (results[id] || []).filter(item => {
27
+ return item.modelId === modelId;
28
+ });
26
29
  });
27
30
  }, {
28
31
  batchScheduleFn: createBatchScheduleFn()
@@ -1 +1 @@
1
- {"version":3,"names":["DataLoader","createPartitionKey","createBatchScheduleFn","createGetAllEntryRevisions","params","entity","tenant","ids","results","id","queryAllClean","partitionKey","options","beginsWith","map","result","data","batchScheduleFn"],"sources":["getAllEntryRevisions.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport type { CmsStorageEntry } from \"@webiny/api-headless-cms/types/index.js\";\nimport { createPartitionKey } from \"~/operations/entry/keys.js\";\nimport type { IDataLoaderParams } from \"./types.js\";\nimport { createBatchScheduleFn } from \"./createBatchScheduleFn.js\";\n\nexport const createGetAllEntryRevisions = (params: IDataLoaderParams) => {\n const { entity, tenant } = params;\n return new DataLoader<string, CmsStorageEntry[]>(\n async ids => {\n const results: Record<string, CmsStorageEntry[]> = {};\n\n for (const id of ids) {\n results[id] = (\n await entity.queryAllClean({\n partitionKey: createPartitionKey({\n tenant,\n id\n }),\n options: {\n beginsWith: \"REV#\"\n }\n })\n ).map(result => {\n return result.data;\n });\n }\n\n return ids.map(id => {\n return results[id] || [];\n });\n },\n {\n batchScheduleFn: createBatchScheduleFn()\n }\n );\n};\n"],"mappings":"AAAA,OAAOA,UAAU,MAAM,YAAY;AAEnC,SAASC,kBAAkB;AAE3B,SAASC,qBAAqB;AAE9B,OAAO,MAAMC,0BAA0B,GAAIC,MAAyB,IAAK;EACrE,MAAM;IAAEC,MAAM;IAAEC;EAAO,CAAC,GAAGF,MAAM;EACjC,OAAO,IAAIJ,UAAU,CACjB,MAAMO,GAAG,IAAI;IACT,MAAMC,OAA0C,GAAG,CAAC,CAAC;IAErD,KAAK,MAAMC,EAAE,IAAIF,GAAG,EAAE;MAClBC,OAAO,CAACC,EAAE,CAAC,GAAG,CACV,MAAMJ,MAAM,CAACK,aAAa,CAAC;QACvBC,YAAY,EAAEV,kBAAkB,CAAC;UAC7BK,MAAM;UACNG;QACJ,CAAC,CAAC;QACFG,OAAO,EAAE;UACLC,UAAU,EAAE;QAChB;MACJ,CAAC,CAAC,EACJC,GAAG,CAACC,MAAM,IAAI;QACZ,OAAOA,MAAM,CAACC,IAAI;MACtB,CAAC,CAAC;IACN;IAEA,OAAOT,GAAG,CAACO,GAAG,CAACL,EAAE,IAAI;MACjB,OAAOD,OAAO,CAACC,EAAE,CAAC,IAAI,EAAE;IAC5B,CAAC,CAAC;EACN,CAAC,EACD;IACIQ,eAAe,EAAEf,qBAAqB,CAAC;EAC3C,CACJ,CAAC;AACL,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["DataLoader","createPartitionKey","createBatchScheduleFn","createGetAllEntryRevisions","params","entity","tenant","modelId","ids","results","id","queryAllClean","partitionKey","options","beginsWith","map","result","data","filter","item","batchScheduleFn"],"sources":["getAllEntryRevisions.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport type { CmsStorageEntry } from \"@webiny/api-headless-cms/types/index.js\";\nimport { createPartitionKey } from \"~/operations/entry/keys.js\";\nimport type { IDataLoaderParams } from \"./types.js\";\nimport { createBatchScheduleFn } from \"./createBatchScheduleFn.js\";\n\nexport const createGetAllEntryRevisions = (params: IDataLoaderParams) => {\n const { entity, tenant, modelId } = params;\n return new DataLoader<string, CmsStorageEntry[]>(\n async ids => {\n const results: Record<string, CmsStorageEntry[]> = {};\n\n for (const id of ids) {\n results[id] = (\n await entity.queryAllClean({\n partitionKey: createPartitionKey({\n tenant,\n id\n }),\n options: {\n beginsWith: \"REV#\"\n }\n })\n ).map(result => {\n return result.data;\n });\n }\n\n return ids.map(id => {\n return (results[id] || []).filter(item => {\n return item.modelId === modelId;\n });\n });\n },\n {\n batchScheduleFn: createBatchScheduleFn()\n }\n );\n};\n"],"mappings":"AAAA,OAAOA,UAAU,MAAM,YAAY;AAEnC,SAASC,kBAAkB;AAE3B,SAASC,qBAAqB;AAE9B,OAAO,MAAMC,0BAA0B,GAAIC,MAAyB,IAAK;EACrE,MAAM;IAAEC,MAAM;IAAEC,MAAM;IAAEC;EAAQ,CAAC,GAAGH,MAAM;EAC1C,OAAO,IAAIJ,UAAU,CACjB,MAAMQ,GAAG,IAAI;IACT,MAAMC,OAA0C,GAAG,CAAC,CAAC;IAErD,KAAK,MAAMC,EAAE,IAAIF,GAAG,EAAE;MAClBC,OAAO,CAACC,EAAE,CAAC,GAAG,CACV,MAAML,MAAM,CAACM,aAAa,CAAC;QACvBC,YAAY,EAAEX,kBAAkB,CAAC;UAC7BK,MAAM;UACNI;QACJ,CAAC,CAAC;QACFG,OAAO,EAAE;UACLC,UAAU,EAAE;QAChB;MACJ,CAAC,CAAC,EACJC,GAAG,CAACC,MAAM,IAAI;QACZ,OAAOA,MAAM,CAACC,IAAI;MACtB,CAAC,CAAC;IACN;IAEA,OAAOT,GAAG,CAACO,GAAG,CAACL,EAAE,IAAI;MACjB,OAAO,CAACD,OAAO,CAACC,EAAE,CAAC,IAAI,EAAE,EAAEQ,MAAM,CAACC,IAAI,IAAI;QACtC,OAAOA,IAAI,CAACZ,OAAO,KAAKA,OAAO;MACnC,CAAC,CAAC;IACN,CAAC,CAAC;EACN,CAAC,EACD;IACIa,eAAe,EAAElB,qBAAqB,CAAC;EAC3C,CACJ,CAAC;AACL,CAAC","ignoreList":[]}
@@ -6,7 +6,8 @@ import { parseIdentifier } from "@webiny/utils";
6
6
  export const createGetLatestRevisionByEntryId = params => {
7
7
  const {
8
8
  entity,
9
- tenant
9
+ tenant,
10
+ modelId
10
11
  } = params;
11
12
  const latestKey = createLatestSortKey();
12
13
  return new DataLoader(async ids => {
@@ -35,6 +36,9 @@ export const createGetLatestRevisionByEntryId = params => {
35
36
  id: entryId
36
37
  } = parseIdentifier(id);
37
38
  return items.filter(item => {
39
+ if (item.modelId !== modelId) {
40
+ return false;
41
+ }
38
42
  return entryId === item.entryId;
39
43
  });
40
44
  });
@@ -1 +1 @@
1
- {"version":3,"names":["DataLoader","cleanupItems","createBatchScheduleFn","createLatestSortKey","createPartitionKey","parseIdentifier","createGetLatestRevisionByEntryId","params","entity","tenant","latestKey","ids","reader","createEntityReader","keys","Set","id","partitionKey","has","add","get","PK","SK","records","execute","items","map","item","data","entryId","filter","batchScheduleFn"],"sources":["getLatestRevisionByEntryId.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport { cleanupItems } from \"@webiny/db-dynamodb/utils/cleanup.js\";\nimport type { CmsStorageEntry } from \"@webiny/api-headless-cms/types/index.js\";\nimport { createBatchScheduleFn } from \"./createBatchScheduleFn.js\";\nimport { createLatestSortKey, createPartitionKey } from \"~/operations/entry/keys.js\";\nimport type { IDataLoaderParams } from \"./types.js\";\nimport { parseIdentifier } from \"@webiny/utils\";\n\nexport const createGetLatestRevisionByEntryId = (params: IDataLoaderParams) => {\n const { entity, tenant } = params;\n\n const latestKey = createLatestSortKey();\n\n return new DataLoader<string, CmsStorageEntry[]>(\n async ids => {\n const reader = entity.createEntityReader();\n\n const keys = new Set<string>();\n\n for (const id of ids) {\n const partitionKey = createPartitionKey({\n tenant,\n id\n });\n if (keys.has(partitionKey)) {\n continue;\n }\n keys.add(partitionKey);\n\n reader.get({\n PK: partitionKey,\n SK: latestKey\n });\n }\n\n const records = await reader.execute();\n const items = cleanupItems(entity.entity, records).map(item => {\n return item.data;\n });\n\n return ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return items.filter(item => {\n return entryId === item.entryId;\n });\n });\n },\n {\n batchScheduleFn: createBatchScheduleFn()\n }\n );\n};\n"],"mappings":"AAAA,OAAOA,UAAU,MAAM,YAAY;AACnC,SAASC,YAAY,QAAQ,sCAAsC;AAEnE,SAASC,qBAAqB;AAC9B,SAASC,mBAAmB,EAAEC,kBAAkB;AAEhD,SAASC,eAAe,QAAQ,eAAe;AAE/C,OAAO,MAAMC,gCAAgC,GAAIC,MAAyB,IAAK;EAC3E,MAAM;IAAEC,MAAM;IAAEC;EAAO,CAAC,GAAGF,MAAM;EAEjC,MAAMG,SAAS,GAAGP,mBAAmB,CAAC,CAAC;EAEvC,OAAO,IAAIH,UAAU,CACjB,MAAMW,GAAG,IAAI;IACT,MAAMC,MAAM,GAAGJ,MAAM,CAACK,kBAAkB,CAAC,CAAC;IAE1C,MAAMC,IAAI,GAAG,IAAIC,GAAG,CAAS,CAAC;IAE9B,KAAK,MAAMC,EAAE,IAAIL,GAAG,EAAE;MAClB,MAAMM,YAAY,GAAGb,kBAAkB,CAAC;QACpCK,MAAM;QACNO;MACJ,CAAC,CAAC;MACF,IAAIF,IAAI,CAACI,GAAG,CAACD,YAAY,CAAC,EAAE;QACxB;MACJ;MACAH,IAAI,CAACK,GAAG,CAACF,YAAY,CAAC;MAEtBL,MAAM,CAACQ,GAAG,CAAC;QACPC,EAAE,EAAEJ,YAAY;QAChBK,EAAE,EAAEZ;MACR,CAAC,CAAC;IACN;IAEA,MAAMa,OAAO,GAAG,MAAMX,MAAM,CAACY,OAAO,CAAC,CAAC;IACtC,MAAMC,KAAK,GAAGxB,YAAY,CAACO,MAAM,CAACA,MAAM,EAAEe,OAAO,CAAC,CAACG,GAAG,CAACC,IAAI,IAAI;MAC3D,OAAOA,IAAI,CAACC,IAAI;IACpB,CAAC,CAAC;IAEF,OAAOjB,GAAG,CAACe,GAAG,CAACV,EAAE,IAAI;MACjB,MAAM;QAAEA,EAAE,EAAEa;MAAQ,CAAC,GAAGxB,eAAe,CAACW,EAAE,CAAC;MAC3C,OAAOS,KAAK,CAACK,MAAM,CAACH,IAAI,IAAI;QACxB,OAAOE,OAAO,KAAKF,IAAI,CAACE,OAAO;MACnC,CAAC,CAAC;IACN,CAAC,CAAC;EACN,CAAC,EACD;IACIE,eAAe,EAAE7B,qBAAqB,CAAC;EAC3C,CACJ,CAAC;AACL,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["DataLoader","cleanupItems","createBatchScheduleFn","createLatestSortKey","createPartitionKey","parseIdentifier","createGetLatestRevisionByEntryId","params","entity","tenant","modelId","latestKey","ids","reader","createEntityReader","keys","Set","id","partitionKey","has","add","get","PK","SK","records","execute","items","map","item","data","entryId","filter","batchScheduleFn"],"sources":["getLatestRevisionByEntryId.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport { cleanupItems } from \"@webiny/db-dynamodb/utils/cleanup.js\";\nimport type { CmsStorageEntry } from \"@webiny/api-headless-cms/types/index.js\";\nimport { createBatchScheduleFn } from \"./createBatchScheduleFn.js\";\nimport { createLatestSortKey, createPartitionKey } from \"~/operations/entry/keys.js\";\nimport type { IDataLoaderParams } from \"./types.js\";\nimport { parseIdentifier } from \"@webiny/utils\";\n\nexport const createGetLatestRevisionByEntryId = (params: IDataLoaderParams) => {\n const { entity, tenant, modelId } = params;\n\n const latestKey = createLatestSortKey();\n\n return new DataLoader<string, CmsStorageEntry[]>(\n async ids => {\n const reader = entity.createEntityReader();\n\n const keys = new Set<string>();\n\n for (const id of ids) {\n const partitionKey = createPartitionKey({\n tenant,\n id\n });\n if (keys.has(partitionKey)) {\n continue;\n }\n keys.add(partitionKey);\n\n reader.get({\n PK: partitionKey,\n SK: latestKey\n });\n }\n\n const records = await reader.execute();\n const items = cleanupItems(entity.entity, records).map(item => {\n return item.data;\n });\n\n return ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return items.filter(item => {\n if (item.modelId !== modelId) {\n return false;\n }\n return entryId === item.entryId;\n });\n });\n },\n {\n batchScheduleFn: createBatchScheduleFn()\n }\n );\n};\n"],"mappings":"AAAA,OAAOA,UAAU,MAAM,YAAY;AACnC,SAASC,YAAY,QAAQ,sCAAsC;AAEnE,SAASC,qBAAqB;AAC9B,SAASC,mBAAmB,EAAEC,kBAAkB;AAEhD,SAASC,eAAe,QAAQ,eAAe;AAE/C,OAAO,MAAMC,gCAAgC,GAAIC,MAAyB,IAAK;EAC3E,MAAM;IAAEC,MAAM;IAAEC,MAAM;IAAEC;EAAQ,CAAC,GAAGH,MAAM;EAE1C,MAAM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Fn.js";
6
6
  export const createGetPublishedRevisionByEntryId = params => {
7
7
  const {
8
8
  entity,
9
- tenant
9
+ tenant,
10
+ modelId
10
11
  } = params;
11
12
  const publishedKey = createPublishedSortKey();
12
13
  return new DataLoader(async ids => {
@@ -35,6 +36,9 @@ export const createGetPublishedRevisionByEntryId = params => {
35
36
  id: entryId
36
37
  } = parseIdentifier(id);
37
38
  return items.filter(item => {
39
+ if (item.modelId !== modelId) {
40
+ return false;
41
+ }
38
42
  return entryId === item.entryId;
39
43
  });
40
44
  });
@@ -1 +1 @@
1
- {"version":3,"names":["DataLoader","cleanupItems","createPartitionKey","createPublishedSortKey","parseIdentifier","createBatchScheduleFn","createGetPublishedRevisionByEntryId","params","entity","tenant","publishedKey","ids","reader","createEntityReader","keys","Set","id","partitionKey","has","add","get","PK","SK","records","execute","items","map","item","data","entryId","filter","batchScheduleFn"],"sources":["getPublishedRevisionByEntryId.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport { cleanupItems } from \"@webiny/db-dynamodb/utils/cleanup.js\";\nimport type { CmsStorageEntry } from \"@webiny/api-headless-cms/types/index.js\";\nimport { createPartitionKey, createPublishedSortKey } from \"~/operations/entry/keys.js\";\nimport type { IDataLoaderParams } from \"./types.js\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport { createBatchScheduleFn } from \"./createBatchScheduleFn.js\";\n\nexport const createGetPublishedRevisionByEntryId = (params: IDataLoaderParams) => {\n const { entity, tenant } = params;\n\n const publishedKey = createPublishedSortKey();\n return new DataLoader<string, CmsStorageEntry[]>(\n async ids => {\n const reader = entity.createEntityReader();\n\n const keys = new Set<string>();\n\n for (const id of ids) {\n const partitionKey = createPartitionKey({\n tenant,\n id\n });\n if (keys.has(partitionKey)) {\n continue;\n }\n keys.add(partitionKey);\n reader.get({\n PK: partitionKey,\n SK: publishedKey\n });\n }\n\n const records = await reader.execute();\n const items = cleanupItems(entity.entity, records).map(item => {\n return item.data;\n });\n\n return ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return items.filter(item => {\n return entryId === item.entryId;\n });\n });\n },\n {\n batchScheduleFn: createBatchScheduleFn()\n }\n );\n};\n"],"mappings":"AAAA,OAAOA,UAAU,MAAM,YAAY;AACnC,SAASC,YAAY,QAAQ,sCAAsC;AAEnE,SAASC,kBAAkB,EAAEC,sBAAsB;AAEnD,SAASC,eAAe,QAAQ,eAAe;AAC/C,SAASC,qBAAqB;AAE9B,OAAO,MAAMC,mCAAmC,GAAIC,MAAyB,IAAK;EAC9E,MAAM;IAAEC,MAAM;IAAEC;EAAO,CAAC,GAAGF,MAAM;EAEjC,MAAMG,YAAY,GAAGP,sBAAsB,CAAC,CAAC;EAC7C,OAAO,IAAIH,UAAU,CACjB,MAAMW,GAAG,IAAI;IACT,MAAMC,MAAM,GAAGJ,MAAM,CAACK,kBAAkB,CAAC,CAAC;IAE1C,MAAMC,IAAI,GAAG,IAAIC,GAAG,CAAS,CAAC;IAE9B,KAAK,MAAMC,EAAE,IAAIL,GAAG,EAAE;MAClB,MAAMM,YAAY,GAAGf,kBAAkB,CAAC;QACpCO,MAAM;QACNO;MACJ,CAAC,CAAC;MACF,IAAIF,IAAI,CAACI,GAAG,CAACD,YAAY,CAAC,EAAE;QACxB;MACJ;MACAH,IAAI,CAACK,GAAG,CAACF,YAAY,CAAC;MACtBL,MAAM,CAACQ,GAAG,CAAC;QACPC,EAAE,EAAEJ,YAAY;QAChBK,EAAE,EAAEZ;MACR,CAAC,CAAC;IACN;IAEA,MAAMa,OAAO,GAAG,MAAMX,MAAM,CAACY,OAAO,CAAC,CAAC;IACtC,MAAMC,KAAK,GAAGxB,YAAY,CAACO,MAAM,CAACA,MAAM,EAAEe,OAAO,CAAC,CAACG,GAAG,CAACC,IAAI,IAAI;MAC3D,OAAOA,IAAI,CAACC,IAAI;IACpB,CAAC,CAAC;IAEF,OAAOjB,GAAG,CAACe,GAAG,CAACV,EAAE,IAAI;MACjB,MAAM;QAAEA,EAAE,EAAEa;MAAQ,CAAC,GAAGzB,eAAe,CAACY,EAAE,CAAC;MAC3C,OAAOS,KAAK,CAACK,MAAM,CAACH,IAAI,IAAI;QACxB,OAAOE,OAAO,KAAKF,IAAI,CAACE,OAAO;MACnC,CAAC,CAAC;IACN,CAAC,CAAC;EACN,CAAC,EACD;IACIE,eAAe,EAAE1B,qBAAqB,CAAC;EAC3C,CACJ,CAAC;AACL,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["DataLoader","cleanupItems","createPartitionKey","createPublishedSortKey","parseIdentifier","createBatchScheduleFn","createGetPublishedRevisionByEntryId","params","entity","tenant","modelId","publishedKey","ids","reader","createEntityReader","keys","Set","id","partitionKey","has","add","get","PK","SK","records","execute","items","map","item","data","entryId","filter","batchScheduleFn"],"sources":["getPublishedRevisionByEntryId.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport { cleanupItems } from \"@webiny/db-dynamodb/utils/cleanup.js\";\nimport type { CmsStorageEntry } from \"@webiny/api-headless-cms/types/index.js\";\nimport { createPartitionKey, createPublishedSortKey } from \"~/operations/entry/keys.js\";\nimport type { IDataLoaderParams } from \"./types.js\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport { createBatchScheduleFn } from \"./createBatchScheduleFn.js\";\n\nexport const createGetPublishedRevisionByEntryId = (params: IDataLoaderParams) => {\n const { entity, tenant, modelId } = params;\n\n const publishedKey = createPublishedSortKey();\n return new DataLoader<string, CmsStorageEntry[]>(\n async ids => {\n const reader = entity.createEntityReader();\n\n const keys = new Set<string>();\n\n for (const id of ids) {\n const partitionKey = createPartitionKey({\n tenant,\n id\n });\n if (keys.has(partitionKey)) {\n continue;\n }\n keys.add(partitionKey);\n reader.get({\n PK: partitionKey,\n SK: publishedKey\n });\n }\n\n const records = await reader.execute();\n const items = cleanupItems(entity.entity, records).map(item => {\n return item.data;\n });\n\n return ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return items.filter(item => {\n if (item.modelId !== modelId) {\n return false;\n }\n return entryId === item.entryId;\n });\n });\n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C3C,OAAOS,KAAK,CAACK,MAAM,CAACH,IAAI,IAAI;QACxB,IAAIA,IAAI,CAAClB,OAAO,KAAKA,OAAO,EAAE;UAC1B,OAAO,KAAK;QAChB;QACA,OAAOoB,OAAO,KAAKF,IAAI,CAACE,OAAO;MACnC,CAAC,CAAC;IACN,CAAC,CAAC;EACN,CAAC,EACD;IACIE,eAAe,EAAE3B,qBAAqB,CAAC;EAC3C,CACJ,CAAC;AACL,CAAC","ignoreList":[]}
@@ -6,7 +6,8 @@ import { createBatchScheduleFn } from "./createBatchScheduleFn.js";
6
6
  export const createGetRevisionById = params => {
7
7
  const {
8
8
  entity,
9
- tenant
9
+ tenant,
10
+ modelId
10
11
  } = params;
11
12
  return new DataLoader(async ids => {
12
13
  const reader = entity.createEntityReader();
@@ -41,6 +42,9 @@ export const createGetRevisionById = params => {
41
42
  });
42
43
  return ids.map(id => {
43
44
  return items.filter(item => {
45
+ if (item.modelId !== modelId) {
46
+ return false;
47
+ }
44
48
  return id === item.id;
45
49
  });
46
50
  });
@@ -1 +1 @@
1
- {"version":3,"names":["DataLoader","cleanupItems","createPartitionKey","createRevisionSortKey","parseIdentifier","createBatchScheduleFn","createGetRevisionById","params","entity","tenant","ids","reader","createEntityReader","keys","Set","id","partitionKey","version","sortKey","key","has","add","get","PK","SK","records","execute","items","map","item","data","filter","batchScheduleFn"],"sources":["getRevisionById.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport type { CmsStorageEntry } from \"@webiny/api-headless-cms/types/index.js\";\nimport { cleanupItems } from \"@webiny/db-dynamodb/utils/cleanup.js\";\nimport { createPartitionKey, createRevisionSortKey } from \"~/operations/entry/keys.js\";\nimport type { IDataLoaderParams } from \"./types.js\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport { createBatchScheduleFn } from \"./createBatchScheduleFn.js\";\n\nexport const createGetRevisionById = (params: IDataLoaderParams) => {\n const { entity, tenant } = params;\n\n return new DataLoader<string, CmsStorageEntry[]>(\n async ids => {\n const reader = entity.createEntityReader();\n\n const keys = new Set<string>();\n\n for (const id of ids) {\n const partitionKey = createPartitionKey({\n tenant,\n id\n });\n const { version } = parseIdentifier(id);\n if (version === null) {\n continue;\n }\n const sortKey = createRevisionSortKey({\n version\n });\n const key = `${partitionKey}__${sortKey}`;\n if (keys.has(key)) {\n continue;\n }\n keys.add(key);\n\n reader.get({\n PK: partitionKey,\n SK: sortKey\n });\n }\n\n const records = await reader.execute();\n const items = cleanupItems(entity.entity, records).map(item => {\n return item.data;\n });\n\n return ids.map(id => {\n return items.filter(item => {\n return id === item.id;\n });\n });\n },\n {\n batchScheduleFn: createBatchScheduleFn()\n }\n );\n};\n"],"mappings":"AAAA,OAAOA,UAAU,MAAM,YAAY;AAEnC,SAASC,YAAY,QAAQ,sCAAsC;AACnE,SAASC,kBAAkB,EAAEC,qBAAqB;AAElD,SAASC,eAAe,QAAQ,eAAe;AAC/C,SAASC,qBAAqB;AAE9B,OAAO,MAAMC,qBAAqB,GAAIC,MAAyB,IAAK;EAChE,MAAM;IAAEC,MAAM;IAAEC;EAAO,CAAC,GAAGF,MAAM;EAEjC,OAAO,IAAIP,UAAU,CACjB,MAAMU,GAAG,IAAI;IACT,MAAMC,MAAM,GAAGH,MAAM,CAACI,kBAAkB,CAAC,CAAC;IAE1C,MAAMC,IAAI,GAAG,IAAIC,GAAG,CAAS,CAAC;IAE9B,KAAK,MAAMC,EAAE,IAAIL,GAAG,EAAE;MAClB,MAAMM,YAAY,GAAGd,kBAAkB,CAAC;QACpCO,MAAM;QACNM;MACJ,CAAC,CAAC;MACF,MAAM;QAAEE;MAAQ,CAAC,GAAGb,eAAe,CAACW,EAAE,CAAC;MACvC,IAAIE,OAAO,KAAK,IAAI,EAAE;QAClB;MACJ;MACA,MAAMC,OAAO,GAAGf,qBAAqB,CAAC;QAClCc;MACJ,CAAC,CAAC;MACF,MAAME,GAAG,GAAG,GAAGH,YAAY,KAAKE,OAAO,EAAE;MACzC,IAAIL,IAAI,CAACO,GAAG,CAACD,GAAG,CAAC,EAAE;QACf;MACJ;MACAN,IAAI,CAACQ,GAAG,CAACF,GAAG,CAAC;MAEbR,MAAM,CAACW,GAAG,CAAC;QACPC,EAAE,EAAEP,YAAY;QAChBQ,EAAE,EAAEN;MACR,CAAC,CAAC;IACN;IAEA,MAAMO,OAAO,GAAG,MAAMd,MAAM,CAACe,OAAO,CAAC,CAAC;IACtC,MAAMC,KAAK,GAAG1B,YAAY,CAACO,MAAM,CAACA,MAAM,EAAEiB,OAAO,CAAC,CAACG,GAAG,CAACC,IAAI,IAAI;MAC3D,OAAOA,IAAI,CAACC,IAAI;IACpB,CAAC,CAAC;IAEF,OAAOpB,GAAG,CAACkB,GAAG,CAACb,EAAE,IAAI;MACjB,OAAOY,KAAK,CAACI,MAAM,CAACF,IAAI,IAAI;QACxB,OAAOd,EAAE,KAAKc,IAAI,CAACd,EAAE;MACzB,CAAC,CAAC;IACN,CAAC,CAAC;EACN,CAAC,EACD;IACIiB,eAAe,EAAE3B,qBAAqB,CAAC;EAC3C,CACJ,CAAC;AACL,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["DataLoader","cleanupItems","createPartitionKey","createRevisionSortKey","parseIdentifier","createBatchScheduleFn","createGetRevisionById","params","entity","tenant","modelId","ids","reader","createEntityReader","keys","Set","id","partitionKey","version","sortKey","key","has","add","get","PK","SK","records","execute","items","map","item","data","filter","batchScheduleFn"],"sources":["getRevisionById.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport type { CmsStorageEntry } from \"@webiny/api-headless-cms/types/index.js\";\nimport { cleanupItems } from \"@webiny/db-dynamodb/utils/cleanup.js\";\nimport { createPartitionKey, createRevisionSortKey } from \"~/operations/entry/keys.js\";\nimport type { IDataLoaderParams } from \"./types.js\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport { createBatchScheduleFn } from \"./createBatchScheduleFn.js\";\n\nexport const createGetRevisionById = (params: IDataLoaderParams) => {\n const { entity, tenant, modelId } = params;\n\n return new DataLoader<string, CmsStorageEntry[]>(\n async ids => {\n const reader = entity.createEntityReader();\n\n const keys = new Set<string>();\n\n for (const id of ids) {\n const partitionKey = createPartitionKey({\n tenant,\n id\n });\n const { version } = parseIdentifier(id);\n if (version === null) {\n continue;\n }\n const sortKey = createRevisionSortKey({\n version\n });\n const key = `${partitionKey}__${sortKey}`;\n if (keys.has(key)) {\n continue;\n }\n keys.add(key);\n\n reader.get({\n PK: partitionKey,\n SK: sortKey\n });\n }\n\n const records = await reader.execute();\n const items = cleanupItems(entity.entity, records).map(item => {\n return item.data;\n });\n\n return ids.map(id => {\n return items.filter(item => {\n if (item.modelId !== modelId) {\n return false;\n }\n return id === item.id;\n });\n });\n },\n {\n batchScheduleFn: createBatchScheduleFn()\n }\n );\n};\n"],"mappings":"AAAA,OAAOA,UAAU,MAAM,YAAY;AAEnC,SAASC,YAAY,QAAQ,sCAAsC;AACnE,SAASC,kBAAkB,EAAEC,qBAAqB;AAElD,SAASC,eAAe,QAAQ,eAAe;AAC/C,SAASC,qBAAqB;AAE9B,OAAO,MAAMC,qBAAqB,GAAIC,MAAyB,IAAK;EAChE,MAAM;IAAEC,MAAM;IAAEC,MAAM;IAAEC;EAAQ,CAAC,GAAGH,MAAM;EAE1C,OAAO,IAAIP,UAAU,CACjB,MAAMW,GAAG,IAAI;IACT,MAAMC,MAAM,GAAGJ,MAAM,CAACK,kBAAkB,CAAC,CAAC;IAE1C,MAAMC,IAAI,GAAG,IAAIC,GAAG,CAAS,CAAC;IAE9B,KAAK,MAAMC,EAAE,IAAIL,GAAG,EAAE;MAClB,MAAMM,YAAY,GAAGf,kBAAkB,CAAC;QACpCO,MAAM;QACNO;MACJ,CAAC,CAAC;MACF,MAAM;QAAEE;MAAQ,CAAC,GAAGd,eAAe,CAACY,EAAE,CAAC;MACvC,IAAIE,OAAO,KAAK,IAAI,EAAE;QAClB;MACJ;MACA,MAAMC,OAAO,GAAGhB,qBAAqB,CAAC;QAClCe;MACJ,CAAC,CAAC;MACF,MAAME,GAAG,GAAG,GAAGH,YAAY,KAAKE,OAAO,EAAE;MACzC,IAAIL,IAAI,CAACO,GAAG,CAACD,GAAG,CAAC,EAAE;QACf;MACJ;MACAN,IAAI,CAACQ,GAAG,CAACF,GAAG,CAAC;MAEbR,MAAM,CAACW,GAAG,CAAC;QACPC,EAAE,EAAEP,YAAY;QAChBQ,EAAE,EAAEN;MACR,CAAC,CAAC;IACN;IAEA,MAAMO,OAAO,GAAG,MAAMd,MAAM,CAACe,OAAO,CAAC,CAAC;IACtC,MAAMC,KAAK,GAAG3B,YAAY,CAACO,MAAM,CAACA,MAAM,EAAEkB,OAAO,CAAC,CAACG,GAAG,CAACC,IAAI,IAAI;MAC3D,OAAOA,IAAI,CAACC,IAAI;IACpB,CAAC,CAAC;IAEF,OAAOpB,GAAG,CAACkB,GAAG,CAACb,EAAE,IAAI;MACjB,OAAOY,KAAK,CAACI,MAAM,CAACF,IAAI,IAAI;QACxB,IAAIA,IAAI,CAACpB,OAAO,KAAKA,OAAO,EAAE;UAC1B,OAAO,KAAK;QAChB;QACA,OAAOM,EAAE,KAAKc,IAAI,CAACd,EAAE;MACzB,CAAC,CAAC;IACN,CAAC,CAAC;EACN,CAAC,EACD;IACIiB,eAAe,EAAE5B,qBAAqB,CAAC;EAC3C,CACJ,CAAC;AACL,CAAC","ignoreList":[]}
@@ -2,4 +2,5 @@ import type { IEntryEntity } from "../../../definitions/types.js";
2
2
  export interface IDataLoaderParams {
3
3
  entity: IEntryEntity;
4
4
  tenant: string;
5
+ modelId: string;
5
6
  }
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { IEntryEntity } from \"~/definitions/types.js\";\n\nexport interface IDataLoaderParams {\n entity: IEntryEntity;\n tenant: string;\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { IEntryEntity } from \"~/definitions/types.js\";\n\nexport interface IDataLoaderParams {\n entity: IEntryEntity;\n tenant: string;\n modelId: string;\n}\n"],"mappings":"","ignoreList":[]}
@@ -48,6 +48,7 @@ export class DataLoadersHandler {
48
48
  } = params;
49
49
  const cacheParams = {
50
50
  tenant: model.tenant,
51
+ modelId: model.modelId,
51
52
  name
52
53
  };
53
54
  let loader = this.cache.getDataLoader(cacheParams);
@@ -57,7 +58,8 @@ export class DataLoadersHandler {
57
58
  const factory = getDataLoaderFactory(name);
58
59
  loader = factory({
59
60
  entity: this.entity,
60
- tenant: model.tenant
61
+ tenant: model.tenant,
62
+ modelId: model.modelId
61
63
  });
62
64
  this.cache.setDataLoader(cacheParams, loader);
63
65
  return loader;
@@ -1 +1 @@
1
- {"version":3,"names":["WebinyError","DataLoaderCache","getDataLoaderFactory","parseIdentifier","DataLoadersHandler","cache","constructor","params","entity","getAllEntryRevisions","ids","map","id","entryId","loadMany","getRevisionById","getPublishedRevisionByEntryId","getLatestRevisionByEntryId","getLoader","name","model","cacheParams","tenant","loader","getDataLoader","factory","setDataLoader","results","Array","isArray","reduce","acc","res","message","code","data","JSON","stringify","push","ex","error","clearAll"],"sources":["dataLoaders.ts"],"sourcesContent":["import type DataLoader from \"dataloader\";\nimport WebinyError from \"@webiny/error\";\nimport type {\n CmsEntryValues,\n CmsModel,\n CmsStorageEntry\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport type { CacheKeyParams } from \"~/operations/entry/dataLoader/DataLoaderCache.js\";\nimport { DataLoaderCache } from \"~/operations/entry/dataLoader/DataLoaderCache.js\";\nimport type { DataLoaders } from \"~/operations/entry/dataLoader/index.js\";\nimport { getDataLoaderFactory } from \"~/operations/entry/dataLoader/index.js\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport type {\n DataLoadersHandlerInterfaceClearAllParams,\n IDataLoadersHandler,\n IEntryEntity\n} from \"~/types.js\";\n\ninterface DataLoaderParams {\n model: Pick<CmsModel, \"tenant\" | \"modelId\">;\n ids: readonly string[];\n}\n\ninterface GetLoaderParams {\n model: Pick<CmsModel, \"tenant\" | \"modelId\">;\n}\n\ninterface IDataLoadersHandlerParams {\n entity: IEntryEntity;\n}\n\nexport class DataLoadersHandler implements IDataLoadersHandler {\n private readonly entity;\n private readonly cache = new DataLoaderCache();\n\n public constructor(params: IDataLoadersHandlerParams) {\n this.entity = params.entity;\n }\n\n public async getAllEntryRevisions<T extends CmsEntryValues = CmsEntryValues>(\n params: DataLoaderParams\n ): Promise<CmsStorageEntry<T>[]> {\n const ids = params.ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return entryId;\n });\n return await this.loadMany<T>(\"getAllEntryRevisions\", params, ids);\n }\n\n public async getRevisionById<T extends CmsEntryValues = CmsEntryValues>(\n params: DataLoaderParams\n ): Promise<CmsStorageEntry<T>[]> {\n return await this.loadMany<T>(\"getRevisionById\", params, params.ids);\n }\n\n public async getPublishedRevisionByEntryId<T extends CmsEntryValues = CmsEntryValues>(\n params: DataLoaderParams\n ): Promise<CmsStorageEntry<T>[]> {\n const ids = params.ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return entryId;\n });\n return await this.loadMany<T>(\"getPublishedRevisionByEntryId\", params, ids);\n }\n\n public async getLatestRevisionByEntryId<T extends CmsEntryValues = CmsEntryValues>(\n params: DataLoaderParams\n ): Promise<CmsStorageEntry<T>[]> {\n const ids = params.ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return entryId;\n });\n return await this.loadMany<T>(\"getLatestRevisionByEntryId\", params, ids);\n }\n\n /**\n * TODO @ts-refactor\n * Maybe pass on the generics to DataLoader definition?\n */\n private getLoader(name: DataLoaders, params: GetLoaderParams): DataLoader<any, any> {\n const { model } = params;\n const cacheParams: CacheKeyParams = {\n tenant: model.tenant,\n name\n };\n let loader = this.cache.getDataLoader(cacheParams);\n if (loader) {\n return loader;\n }\n const factory = getDataLoaderFactory(name);\n loader = factory({\n entity: this.entity,\n tenant: model.tenant\n });\n this.cache.setDataLoader(cacheParams, loader);\n return loader;\n }\n\n private async loadMany<T extends CmsEntryValues = CmsEntryValues>(\n loader: DataLoaders,\n params: GetLoaderParams,\n ids: readonly string[]\n ): Promise<CmsStorageEntry<T>[]> {\n let results: any[] = [];\n try {\n results = await this.getLoader(loader, params).loadMany(ids);\n if (Array.isArray(results) === true) {\n return results.reduce((acc, res) => {\n if (Array.isArray(res) === false) {\n if (res && res.message) {\n throw new WebinyError(res.message, res.code, {\n ...res,\n data: JSON.stringify(res.data || {})\n });\n }\n throw new WebinyError(\n \"Result from the data loader must be an array of arrays which contain requested items.\",\n \"DATA_LOADER_RESULTS_ERROR\",\n {\n ...params,\n loader\n }\n );\n }\n acc.push(...res);\n return acc;\n }, []);\n }\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Data loader error.\",\n ex.code || \"DATA_LOADER_ERROR\",\n {\n error: ex,\n ...params,\n loader,\n ids\n }\n );\n }\n throw new WebinyError(\n `Data loader did not return array of items or empty array.`,\n \"INVALID_DATA_LOADER_RESULT\",\n {\n loader,\n ids,\n results\n }\n );\n }\n\n public clearAll(params?: DataLoadersHandlerInterfaceClearAllParams): void {\n this.cache.clearAll(params?.model);\n }\n}\n"],"mappings":"AACA,OAAOA,WAAW,MAAM,eAAe;AAOvC,SAASC,eAAe;AAExB,SAASC,oBAAoB;AAC7B,SAASC,eAAe,QAAQ,eAAe;AAoB/C,OAAO,MAAMC,kBAAkB,CAAgC;EAE1CC,KAAK,GAAG,IAAIJ,eAAe,CAAC,CAAC;EAEvCK,WAAWA,CAACC,MAAiC,EAAE;IAClD,IAAI,CAACC,MAAM,GAAGD,MAAM,CAACC,MAAM;EAC/B;EAEA,MAAaC,oBAAoBA,CAC7BF,MAAwB,EACK;IAC7B,MAAMG,GAAG,GAAGH,MAAM,CAACG,GAAG,CAACC,GAAG,CAACC,EAAE,IAAI;MAC7B,MAAM;QAAEA,EAAE,EAAEC;MAAQ,CAAC,GAAGV,eAAe,CAACS,EAAE,CAAC;MAC3C,OAAOC,OAAO;IAClB,CAAC,CAAC;IACF,OAAO,MAAM,IAAI,CAACC,QAAQ,CA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,IAAI,mBAAmB,EAC9B;QACIM,KAAK,EAAED,EAAE;QACT,GAAGhC,MAAM;QACTgB,MAAM;QACNb;MACJ,CACJ,CAAC;IACL;IACA,MAAM,IAAIV,WAAW,CACjB,2DAA2D,EAC3D,4BAA4B,EAC5B;MACIuB,MAAM;MACNb,GAAG;MACHiB;IACJ,CACJ,CAAC;EACL;EAEOc,QAAQA,CAAClC,MAAkD,EAAQ;IACtE,IAAI,CAACF,KAAK,CAACoC,QAAQ,CAAClC,MAAM,EAAEa,KAAK,CAAC;EACtC;AACJ","ignoreList":[]}
1
+ {"version":3,"names":["WebinyError","DataLoaderCache","getDataLoaderFactory","parseIdentifier","DataLoadersHandler","cache","constructor","params","entity","getAllEntryRevisions","ids","map","id","entryId","loadMany","getRevisionById","getPublishedRevisionByEntryId","getLatestRevisionByEntryId","getLoader","name","model","cacheParams","tenant","modelId","loader","getDataLoader","factory","setDataLoader","results","Array","isArray","reduce","acc","res","message","code","data","JSON","stringify","push","ex","error","clearAll"],"sources":["dataLoaders.ts"],"sourcesContent":["import type DataLoader from \"dataloader\";\nimport WebinyError from \"@webiny/error\";\nimport type {\n CmsEntryValues,\n CmsModel,\n CmsStorageEntry\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport type { CacheKeyParams } from \"~/operations/entry/dataLoader/DataLoaderCache.js\";\nimport { DataLoaderCache } from \"~/operations/entry/dataLoader/DataLoaderCache.js\";\nimport type { DataLoaders } from \"~/operations/entry/dataLoader/index.js\";\nimport { getDataLoaderFactory } from \"~/operations/entry/dataLoader/index.js\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport type {\n DataLoadersHandlerInterfaceClearAllParams,\n IDataLoadersHandler,\n IEntryEntity\n} from \"~/types.js\";\n\ninterface DataLoaderParams {\n model: Pick<CmsModel, \"tenant\" | \"modelId\">;\n ids: readonly string[];\n}\n\ninterface GetLoaderParams {\n model: Pick<CmsModel, \"tenant\" | \"modelId\">;\n}\n\ninterface IDataLoadersHandlerParams {\n entity: IEntryEntity;\n}\n\nexport class DataLoadersHandler implements IDataLoadersHandler {\n private readonly entity;\n private readonly cache = new DataLoaderCache();\n\n public constructor(params: IDataLoadersHandlerParams) {\n this.entity = params.entity;\n }\n\n public async getAllEntryRevisions<T extends CmsEntryValues = CmsEntryValues>(\n params: DataLoaderParams\n ): Promise<CmsStorageEntry<T>[]> {\n const ids = params.ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return entryId;\n });\n return await this.loadMany<T>(\"getAllEntryRevisions\", params, ids);\n }\n\n public async getRevisionById<T extends CmsEntryValues = CmsEntryValues>(\n params: DataLoaderParams\n ): Promise<CmsStorageEntry<T>[]> {\n return await this.loadMany<T>(\"getRevisionById\", params, params.ids);\n }\n\n public async getPublishedRevisionByEntryId<T extends CmsEntryValues = CmsEntryValues>(\n params: DataLoaderParams\n ): Promise<CmsStorageEntry<T>[]> {\n const ids = params.ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return entryId;\n });\n return await this.loadMany<T>(\"getPublishedRevisionByEntryId\", params, ids);\n }\n\n public async getLatestRevisionByEntryId<T extends CmsEntryValues = CmsEntryValues>(\n params: DataLoaderParams\n ): Promise<CmsStorageEntry<T>[]> {\n const ids = params.ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return entryId;\n });\n return await this.loadMany<T>(\"getLatestRevisionByEntryId\", params, ids);\n }\n\n /**\n * TODO @ts-refactor\n * Maybe pass on the generics to DataLoader definition?\n */\n private getLoader(name: DataLoaders, params: GetLoaderParams): DataLoader<any, any> {\n const { model } = params;\n const cacheParams: CacheKeyParams = {\n tenant: model.tenant,\n modelId: model.modelId,\n name\n };\n let loader = this.cache.getDataLoader(cacheParams);\n if (loader) {\n return loader;\n }\n const factory = getDataLoaderFactory(name);\n loader = factory({\n entity: this.entity,\n tenant: model.tenant,\n modelId: model.modelId\n });\n this.cache.setDataLoader(cacheParams, loader);\n return loader;\n }\n\n private async loadMany<T extends CmsEntryValues = CmsEntryValues>(\n loader: DataLoaders,\n params: GetLoaderParams,\n ids: readonly string[]\n ): Promise<CmsStorageEntry<T>[]> {\n let results: any[] = [];\n try {\n results = await this.getLoader(loader, params).loadMany(ids);\n if (Array.isArray(results) === true) {\n return results.reduce((acc, res) => {\n if (Array.isArray(res) === false) {\n if (res && res.message) {\n throw new WebinyError(res.message, res.code, {\n ...res,\n data: JSON.stringify(res.data || {})\n });\n }\n throw new WebinyError(\n \"Result from the data loader must be an array of arrays which contain requested items.\",\n \"DATA_LOADER_RESULTS_ERROR\",\n {\n ...params,\n loader\n }\n );\n }\n acc.push(...res);\n return acc;\n }, []);\n }\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Data loader error.\",\n ex.code || \"DATA_LOADER_ERROR\",\n {\n error: ex,\n ...params,\n loader,\n ids\n }\n );\n }\n throw new WebinyError(\n `Data loader did not return array of items or empty array.`,\n \"INVALID_DATA_LOADER_RESULT\",\n {\n loader,\n ids,\n results\n }\n );\n }\n\n public clearAll(params?: DataLoadersHandlerInterfaceClearAllParams): void {\n this.cache.clearAll(params?.model);\n }\n}\n"],"mappings":"AACA,OAAOA,WAAW,MAAM,eAAe;AAOvC,SAASC,eAAe;AAExB,SAASC,oBAAoB;AAC7B,SAASC,eAAe,QAAQ,eAAe;AAoB/C,OAAO,MAAMC,kBAAkB,CAAgC;EAE1CC,KAAK,GAAG,IAAIJ,eAAe,CAAC,CAAC;EAEvCK,WAAWA,CAACC,MAAiC,EAAE;IAClD,IAAI,CAACC,MAAM,GAAGD,MAAM,CAACC,MAAM;EAC/B;EAEA,MAAaC,oBAAoBA,CAC7BF,MAAwB,EACK;IAC7B,MAAMG,GAAG,GAAGH,MAAM,CAACG,GAAG,CAACC,GAAG,CAACC,EAAE,IAAI;MAC7B,MAAM;QAAEA,EAAE,EAAEC;MAAQ,CAAC,GAAGV,eAAe,CAACS,EAAE,CAAC;MAC3C,OAAOC,OAAO;IAClB,CAAC,CAAC;IACF,OAAO,MAAM,IAAI,CAACC,QAAQ,CAAI,sBAAs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AAW,CACjBwC,EAAE,CAACN,OAAO,IAAI,oBAAoB,EAClCM,EAAE,CAACL,IAAI,IAAI,mBAAmB,EAC9B;QACIM,KAAK,EAAED,EAAE;QACT,GAAGjC,MAAM;QACTiB,MAAM;QACNd;MACJ,CACJ,CAAC;IACL;IACA,MAAM,IAAIV,WAAW,CACjB,2DAA2D,EAC3D,4BAA4B,EAC5B;MACIwB,MAAM;MACNd,GAAG;MACHkB;IACJ,CACJ,CAAC;EACL;EAEOc,QAAQA,CAACnC,MAAkD,EAAQ;IACtE,IAAI,CAACF,KAAK,CAACqC,QAAQ,CAACnC,MAAM,EAAEa,KAAK,CAAC;EACtC;AACJ","ignoreList":[]}
@@ -1,9 +1,10 @@
1
- import type { CmsEntryListWhere } from "@webiny/api-headless-cms/types/index.js";
2
- import { ValueFilterPlugin } from "@webiny/db-dynamodb/plugins/definitions/ValueFilterPlugin.js";
1
+ import type { CmsContext, CmsEntryListWhere } from "@webiny/api-headless-cms/types/index.js";
3
2
  import type { PluginsContainer } from "@webiny/plugins";
4
3
  import type { Field } from "./types.js";
5
- interface Params {
4
+ import { ValueFilter } from "@webiny/db-dynamodb/feature/ValueFilter/index.js";
5
+ interface ICreateExpressionsParams {
6
6
  plugins: PluginsContainer;
7
+ container: CmsContext["container"];
7
8
  where: Partial<CmsEntryListWhere>;
8
9
  fields: Record<string, Field>;
9
10
  }
@@ -17,10 +18,10 @@ export interface Filter {
17
18
  field: Field;
18
19
  path: string;
19
20
  fieldPathId: string;
20
- plugin: ValueFilterPlugin;
21
+ filter: ValueFilter.Interface;
21
22
  negate: boolean;
22
23
  compareValue: any;
23
24
  transformValue: <I = any, O = any>(value: I) => O;
24
25
  }
25
- export declare const createExpressions: (params: Params) => Expression;
26
+ export declare const createExpressions: (params: ICreateExpressionsParams) => Expression;
26
27
  export {};