@webiny/api-headless-cms-ddb 0.0.0-mt-2 → 0.0.0-unstable.1145e7667f

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 (138) hide show
  1. package/definitions/entry.d.ts +2 -1
  2. package/definitions/entry.js +9 -12
  3. package/definitions/entry.js.map +1 -0
  4. package/definitions/group.d.ts +2 -1
  5. package/definitions/group.js +3 -12
  6. package/definitions/group.js.map +1 -0
  7. package/definitions/model.d.ts +2 -1
  8. package/definitions/model.js +25 -12
  9. package/definitions/model.js.map +1 -0
  10. package/definitions/settings.d.ts +2 -1
  11. package/definitions/settings.js +3 -12
  12. package/definitions/settings.js.map +1 -0
  13. package/definitions/system.d.ts +2 -1
  14. package/definitions/system.js +3 -12
  15. package/definitions/system.js.map +1 -0
  16. package/definitions/table.d.ts +2 -1
  17. package/definitions/table.js +0 -3
  18. package/definitions/table.js.map +1 -0
  19. package/dynamoDb/index.d.ts +1 -1
  20. package/dynamoDb/index.js +6 -17
  21. package/dynamoDb/index.js.map +1 -0
  22. package/dynamoDb/path/plainObject.d.ts +2 -3
  23. package/dynamoDb/path/plainObject.js +25 -25
  24. package/dynamoDb/path/plainObject.js.map +1 -0
  25. package/dynamoDb/storage/date.d.ts +3 -3
  26. package/dynamoDb/storage/date.js +80 -54
  27. package/dynamoDb/storage/date.js.map +1 -0
  28. package/dynamoDb/storage/longText.d.ts +7 -4
  29. package/dynamoDb/storage/longText.js +72 -64
  30. package/dynamoDb/storage/longText.js.map +1 -0
  31. package/dynamoDb/storage/richText.d.ts +2 -8
  32. package/dynamoDb/storage/richText.js +62 -77
  33. package/dynamoDb/storage/richText.js.map +1 -0
  34. package/dynamoDb/transformValue/datetime.d.ts +4 -2
  35. package/dynamoDb/transformValue/datetime.js +28 -30
  36. package/dynamoDb/transformValue/datetime.js.map +1 -0
  37. package/index.d.ts +1 -0
  38. package/index.js +48 -41
  39. package/index.js.map +1 -0
  40. package/operations/entry/dataLoaders.d.ts +12 -8
  41. package/operations/entry/dataLoaders.js +27 -52
  42. package/operations/entry/dataLoaders.js.map +1 -0
  43. package/operations/entry/filtering/createExpressions.d.ts +26 -0
  44. package/operations/entry/filtering/createExpressions.js +176 -0
  45. package/operations/entry/filtering/createExpressions.js.map +1 -0
  46. package/operations/entry/filtering/createFields.d.ts +14 -0
  47. package/operations/entry/filtering/createFields.js +105 -0
  48. package/operations/entry/filtering/createFields.js.map +1 -0
  49. package/operations/entry/filtering/extractSort.d.ts +17 -0
  50. package/operations/entry/filtering/extractSort.js +67 -0
  51. package/operations/entry/filtering/extractSort.js.map +1 -0
  52. package/operations/entry/filtering/filter.d.ts +15 -0
  53. package/operations/entry/filtering/filter.js +143 -0
  54. package/operations/entry/filtering/filter.js.map +1 -0
  55. package/operations/entry/filtering/fullTextSearch.d.ts +14 -0
  56. package/operations/entry/filtering/fullTextSearch.js +48 -0
  57. package/operations/entry/filtering/fullTextSearch.js.map +1 -0
  58. package/operations/entry/filtering/getValue.d.ts +5 -0
  59. package/operations/entry/filtering/getValue.js +63 -0
  60. package/operations/entry/filtering/getValue.js.map +1 -0
  61. package/operations/entry/filtering/index.d.ts +2 -0
  62. package/operations/entry/filtering/index.js +19 -0
  63. package/operations/entry/filtering/index.js.map +1 -0
  64. package/operations/entry/filtering/mapPlugins.d.ts +8 -0
  65. package/operations/entry/filtering/mapPlugins.js +31 -0
  66. package/operations/entry/filtering/mapPlugins.js.map +1 -0
  67. package/operations/entry/filtering/plugins/defaultFilterCreate.d.ts +2 -0
  68. package/operations/entry/filtering/plugins/defaultFilterCreate.js +41 -0
  69. package/operations/entry/filtering/plugins/defaultFilterCreate.js.map +1 -0
  70. package/operations/entry/filtering/plugins/index.d.ts +1 -0
  71. package/operations/entry/filtering/plugins/index.js +13 -0
  72. package/operations/entry/filtering/plugins/index.js.map +1 -0
  73. package/operations/entry/filtering/plugins/objectFilterCreate.d.ts +2 -0
  74. package/operations/entry/filtering/plugins/objectFilterCreate.js +86 -0
  75. package/operations/entry/filtering/plugins/objectFilterCreate.js.map +1 -0
  76. package/operations/entry/filtering/plugins/refFilterCreate.d.ts +2 -0
  77. package/operations/entry/filtering/plugins/refFilterCreate.js +71 -0
  78. package/operations/entry/filtering/plugins/refFilterCreate.js.map +1 -0
  79. package/operations/entry/filtering/sort.d.ts +12 -0
  80. package/operations/entry/filtering/sort.js +69 -0
  81. package/operations/entry/filtering/sort.js.map +1 -0
  82. package/operations/entry/filtering/systemFields.d.ts +4 -0
  83. package/operations/entry/filtering/systemFields.js +70 -0
  84. package/operations/entry/filtering/systemFields.js.map +1 -0
  85. package/operations/entry/filtering/transform.d.ts +6 -0
  86. package/operations/entry/filtering/transform.js +16 -0
  87. package/operations/entry/filtering/transform.js.map +1 -0
  88. package/operations/entry/filtering/types.d.ts +40 -0
  89. package/operations/entry/filtering/types.js +5 -0
  90. package/operations/entry/filtering/types.js.map +1 -0
  91. package/operations/entry/filtering/values.d.ts +2 -0
  92. package/operations/entry/filtering/values.js +22 -0
  93. package/operations/entry/filtering/values.js.map +1 -0
  94. package/operations/entry/filtering/where.d.ts +5 -0
  95. package/operations/entry/filtering/where.js +32 -0
  96. package/operations/entry/filtering/where.js.map +1 -0
  97. package/operations/entry/index.d.ts +2 -2
  98. package/operations/entry/index.js +323 -330
  99. package/operations/entry/index.js.map +1 -0
  100. package/operations/entry/keys.js +7 -14
  101. package/operations/entry/keys.js.map +1 -0
  102. package/operations/entry/systemFields.js +24 -2
  103. package/operations/entry/systemFields.js.map +1 -0
  104. package/operations/group/index.d.ts +3 -2
  105. package/operations/group/index.js +9 -45
  106. package/operations/group/index.js.map +1 -0
  107. package/operations/model/index.d.ts +3 -2
  108. package/operations/model/index.js +13 -37
  109. package/operations/model/index.js.map +1 -0
  110. package/operations/settings/index.d.ts +3 -2
  111. package/operations/settings/index.js +7 -37
  112. package/operations/settings/index.js.map +1 -0
  113. package/operations/system/index.d.ts +3 -2
  114. package/operations/system/index.js +5 -28
  115. package/operations/system/index.js.map +1 -0
  116. package/package.json +22 -23
  117. package/plugins/CmsEntryFieldFilterPathPlugin.d.ts +22 -0
  118. package/plugins/CmsEntryFieldFilterPathPlugin.js +41 -0
  119. package/plugins/CmsEntryFieldFilterPathPlugin.js.map +1 -0
  120. package/plugins/CmsEntryFieldFilterPlugin.d.ts +43 -0
  121. package/plugins/CmsEntryFieldFilterPlugin.js +24 -0
  122. package/plugins/CmsEntryFieldFilterPlugin.js.map +1 -0
  123. package/plugins/CmsEntryFieldSortingPlugin.d.ts +42 -0
  124. package/plugins/CmsEntryFieldSortingPlugin.js +28 -0
  125. package/plugins/CmsEntryFieldSortingPlugin.js.map +1 -0
  126. package/plugins/CmsFieldFilterValueTransformPlugin.d.ts +11 -0
  127. package/plugins/CmsFieldFilterValueTransformPlugin.js +24 -0
  128. package/plugins/CmsFieldFilterValueTransformPlugin.js.map +1 -0
  129. package/plugins/index.d.ts +4 -0
  130. package/plugins/index.js +49 -0
  131. package/plugins/index.js.map +1 -0
  132. package/types.d.ts +2 -33
  133. package/types.js +0 -1
  134. package/types.js.map +1 -0
  135. package/dynamoDb/path/ref.d.ts +0 -3
  136. package/dynamoDb/path/ref.js +0 -27
  137. package/operations/entry/utils.d.ts +0 -31
  138. package/operations/entry/utils.js +0 -406
package/index.js CHANGED
@@ -1,49 +1,49 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
7
+ var _exportNames = {
8
+ createStorageOperations: true
9
+ };
8
10
  exports.createStorageOperations = void 0;
9
-
10
11
  var _filters = _interopRequireDefault(require("@webiny/db-dynamodb/plugins/filters"));
11
-
12
12
  var _dynamoDb = _interopRequireDefault(require("./dynamoDb"));
13
-
14
13
  var _types = require("./types");
15
-
16
14
  var _table = require("./definitions/table");
17
-
18
15
  var _settings = require("./definitions/settings");
19
-
20
16
  var _system = require("./definitions/system");
21
-
22
17
  var _group = require("./definitions/group");
23
-
24
18
  var _model = require("./definitions/model");
25
-
26
19
  var _entry = require("./definitions/entry");
27
-
28
20
  var _plugins = require("@webiny/plugins");
29
-
30
21
  var _system2 = require("./operations/system");
31
-
32
22
  var _settings2 = require("./operations/settings");
33
-
34
23
  var _group2 = require("./operations/group");
35
-
36
24
  var _model2 = require("./operations/model");
37
-
38
25
  var _entry2 = require("./operations/entry");
39
-
26
+ var _plugins2 = require("./operations/entry/filtering/plugins");
27
+ var _plugins3 = require("./plugins");
28
+ Object.keys(_plugins3).forEach(function (key) {
29
+ if (key === "default" || key === "__esModule") return;
30
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
31
+ if (key in exports && exports[key] === _plugins3[key]) return;
32
+ Object.defineProperty(exports, key, {
33
+ enumerable: true,
34
+ get: function () {
35
+ return _plugins3[key];
36
+ }
37
+ });
38
+ });
39
+ var _ValueFilterPlugin = require("@webiny/db-dynamodb/plugins/definitions/ValueFilterPlugin");
40
+ var _apiHeadlessCms = require("@webiny/api-headless-cms");
40
41
  const createStorageOperations = params => {
41
42
  const {
42
- attributes = {},
43
+ attributes,
43
44
  table,
44
45
  documentClient,
45
- plugins: customPlugins,
46
- modelFieldToGraphQLPlugins
46
+ plugins: userPlugins
47
47
  } = params;
48
48
  const tableInstance = (0, _table.createTable)({
49
49
  table,
@@ -53,53 +53,61 @@ const createStorageOperations = params => {
53
53
  settings: (0, _settings.createSettingsEntity)({
54
54
  entityName: _types.ENTITIES.SETTINGS,
55
55
  table: tableInstance,
56
- attributes: attributes[_types.ENTITIES.SETTINGS]
56
+ attributes: attributes ? attributes[_types.ENTITIES.SETTINGS] : {}
57
57
  }),
58
58
  system: (0, _system.createSystemEntity)({
59
59
  entityName: _types.ENTITIES.SYSTEM,
60
60
  table: tableInstance,
61
- attributes: attributes[_types.ENTITIES.SYSTEM]
61
+ attributes: attributes ? attributes[_types.ENTITIES.SYSTEM] : {}
62
62
  }),
63
63
  groups: (0, _group.createGroupEntity)({
64
64
  entityName: _types.ENTITIES.GROUPS,
65
65
  table: tableInstance,
66
- attributes: attributes[_types.ENTITIES.GROUPS]
66
+ attributes: attributes ? attributes[_types.ENTITIES.GROUPS] : {}
67
67
  }),
68
68
  models: (0, _model.createModelEntity)({
69
69
  entityName: _types.ENTITIES.MODELS,
70
70
  table: tableInstance,
71
- attributes: attributes[_types.ENTITIES.MODELS]
71
+ attributes: attributes ? attributes[_types.ENTITIES.MODELS] : {}
72
72
  }),
73
73
  entries: (0, _entry.createEntryEntity)({
74
74
  entityName: _types.ENTITIES.ENTRIES,
75
75
  table: tableInstance,
76
- attributes: attributes[_types.ENTITIES.ENTRIES]
76
+ attributes: attributes ? attributes[_types.ENTITIES.ENTRIES] : {}
77
77
  })
78
78
  };
79
79
  const plugins = new _plugins.PluginsContainer([
80
80
  /**
81
- * User defined custom plugins.
81
+ * DynamoDB filter plugins for the where conditions.
82
82
  */
83
- ...(customPlugins || []),
83
+ (0, _filters.default)(),
84
84
  /**
85
- * Plugins of type CmsModelFieldToGraphQLPlugin.
85
+ * Field plugins for DynamoDB.
86
86
  */
87
- modelFieldToGraphQLPlugins,
87
+ (0, _dynamoDb.default)(),
88
88
  /**
89
- * DynamoDB filter plugins for the where conditions.
89
+ * Filter create plugins.
90
90
  */
91
- (0, _filters.default)(),
91
+ (0, _plugins2.createFilterCreatePlugins)(),
92
92
  /**
93
- * Field plugins for DynamoDB.
93
+ * User defined custom plugins.
94
94
  */
95
- (0, _dynamoDb.default)()]);
95
+ ...(userPlugins || [])]);
96
96
  return {
97
- plugins: [
98
- /**
99
- * Field plugins for DynamoDB.
100
- * We must pass them to the base application.
101
- */
102
- (0, _dynamoDb.default)()],
97
+ name: "dynamodb",
98
+ beforeInit: async context => {
99
+ const types = ["cms-model-field-to-graphql", _plugins3.CmsEntryFieldFilterPathPlugin.type, _plugins3.CmsFieldFilterValueTransformPlugin.type, _plugins3.CmsEntryFieldFilterPlugin.type, _plugins3.CmsEntryFieldSortingPlugin.type, _ValueFilterPlugin.ValueFilterPlugin.type, _apiHeadlessCms.StorageOperationsCmsModelPlugin.type];
100
+ /**
101
+ * Collect all required plugins from parent context.
102
+ */
103
+ for (const type of types) {
104
+ plugins.mergeByType(context.plugins, type);
105
+ }
106
+ /**
107
+ * Pass the plugins to the parent context.
108
+ */
109
+ context.plugins.register([(0, _dynamoDb.default)()]);
110
+ },
103
111
  getEntities: () => entities,
104
112
  getTable: () => tableInstance,
105
113
  system: (0, _system2.createSystemStorageOperations)({
@@ -121,5 +129,4 @@ const createStorageOperations = params => {
121
129
  })
122
130
  };
123
131
  };
124
-
125
132
  exports.createStorageOperations = createStorageOperations;
package/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createStorageOperations","params","attributes","table","documentClient","plugins","userPlugins","tableInstance","createTable","entities","settings","createSettingsEntity","entityName","ENTITIES","SETTINGS","system","createSystemEntity","SYSTEM","groups","createGroupEntity","GROUPS","models","createModelEntity","MODELS","entries","createEntryEntity","ENTRIES","PluginsContainer","dynamoDbValueFilters","dynamoDbPlugins","createFilterCreatePlugins","name","beforeInit","context","types","CmsEntryFieldFilterPathPlugin","type","CmsFieldFilterValueTransformPlugin","CmsEntryFieldFilterPlugin","CmsEntryFieldSortingPlugin","ValueFilterPlugin","StorageOperationsCmsModelPlugin","mergeByType","register","getEntities","getTable","createSystemStorageOperations","entity","createSettingsStorageOperations","createGroupsStorageOperations","createModelsStorageOperations","createEntriesStorageOperations"],"sources":["index.ts"],"sourcesContent":["import dynamoDbValueFilters from \"@webiny/db-dynamodb/plugins/filters\";\nimport dynamoDbPlugins from \"./dynamoDb\";\nimport { ENTITIES, StorageOperationsFactory } from \"~/types\";\nimport { createTable } from \"~/definitions/table\";\nimport { createSettingsEntity } from \"~/definitions/settings\";\nimport { createSystemEntity } from \"~/definitions/system\";\nimport { createGroupEntity } from \"~/definitions/group\";\nimport { createModelEntity } from \"~/definitions/model\";\nimport { createEntryEntity } from \"~/definitions/entry\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { createSystemStorageOperations } from \"~/operations/system\";\nimport { createSettingsStorageOperations } from \"~/operations/settings\";\nimport { createGroupsStorageOperations } from \"~/operations/group\";\nimport { createModelsStorageOperations } from \"~/operations/model\";\nimport { createEntriesStorageOperations } from \"./operations/entry\";\n\nimport { createFilterCreatePlugins } from \"~/operations/entry/filtering/plugins\";\nimport {\n CmsEntryFieldFilterPathPlugin,\n CmsEntryFieldFilterPlugin,\n CmsEntryFieldSortingPlugin,\n CmsFieldFilterValueTransformPlugin\n} from \"~/plugins\";\nimport { ValueFilterPlugin } from \"@webiny/db-dynamodb/plugins/definitions/ValueFilterPlugin\";\nimport { StorageOperationsCmsModelPlugin } from \"@webiny/api-headless-cms\";\n\nexport * from \"./plugins\";\n\nexport const createStorageOperations: StorageOperationsFactory = params => {\n const { attributes, table, documentClient, plugins: userPlugins } = params;\n\n const tableInstance = createTable({\n table,\n documentClient\n });\n\n const entities = {\n settings: createSettingsEntity({\n entityName: ENTITIES.SETTINGS,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.SETTINGS] : {}\n }),\n system: createSystemEntity({\n entityName: ENTITIES.SYSTEM,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.SYSTEM] : {}\n }),\n groups: createGroupEntity({\n entityName: ENTITIES.GROUPS,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.GROUPS] : {}\n }),\n models: createModelEntity({\n entityName: ENTITIES.MODELS,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.MODELS] : {}\n }),\n entries: createEntryEntity({\n entityName: ENTITIES.ENTRIES,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.ENTRIES] : {}\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 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 ];\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 getEntities: () => entities,\n getTable: () => tableInstance,\n system: createSystemStorageOperations({\n entity: entities.system\n }),\n settings: createSettingsStorageOperations({\n entity: entities.settings\n }),\n groups: createGroupsStorageOperations({\n entity: entities.groups,\n plugins\n }),\n models: createModelsStorageOperations({\n entity: entities.models\n }),\n entries: createEntriesStorageOperations({\n entity: entities.entries,\n plugins\n })\n };\n};\n"],"mappings":";;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AASA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AAHA;AACA;AAIO,MAAMA,uBAAiD,GAAGC,MAAM,IAAI;EACvE,MAAM;IAAEC,UAAU;IAAEC,KAAK;IAAEC,cAAc;IAAEC,OAAO,EAAEC;EAAY,CAAC,GAAGL,MAAM;EAE1E,MAAMM,aAAa,GAAG,IAAAC,kBAAW,EAAC;IAC9BL,KAAK;IACLC;EACJ,CAAC,CAAC;EAEF,MAAMK,QAAQ,GAAG;IACbC,QAAQ,EAAE,IAAAC,8BAAoB,EAAC;MAC3BC,UAAU,EAAEC,eAAQ,CAACC,QAAQ;MAC7BX,KAAK,EAAEI,aAAa;MACpBL,UAAU,EAAEA,UAAU,GAAGA,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IAAI;MACzB,MAAMC,KAAe,GAAG,CACpB,4BAA4B,EAC5BC,uCAA6B,CAACC,IAAI,EAClCC,4CAAkC,CAACD,IAAI,EACvCE,mCAAyB,CAACF,IAAI,EAC9BG,oCAA0B,CAACH,IAAI,EAC/BI,oCAAiB,CAACJ,IAAI,EACtBK,+CAA+B,CAACL,IAAI,CACvC;MACD;AACZ;AACA;MACY,KAAK,MAAMA,IAAI,IAAIF,KAAK,EAAE;QACtB7B,OAAO,CAACqC,WAAW,CAACT,OAAO,CAAC5B,OAAO,EAAE+B,IAAI,CAAC;MAC9C;MACA;AACZ;AACA;MACYH,OAAO,CAAC5B,OAAO,CAACsC,QAAQ,CAAC,CAAC,IAAAd,iBAAe,GAAE,CAAC,CAAC;IACjD,CAAC;IACDe,WAAW,EAAE,MAAMnC,QAAQ;IAC3BoC,QAAQ,EAAE,MAAMtC,aAAa;IAC7BQ,MAAM,EAAE,IAAA+B,sCAA6B,EAAC;MAClCC,MAAM,EAAEtC,QAAQ,CAACM;IACrB,CAAC,CAAC;IACFL,QAAQ,EAAE,IAAAsC,0CAA+B,EAAC;MACtCD,MAAM,EAAEtC,QAAQ,CAACC;IACrB,CAAC,CAAC;IACFQ,MAAM,EAAE,IAAA+B,qCAA6B,EAAC;MAClCF,MAAM,EAAEtC,QAAQ,CAACS,MAAM;MACvBb;IACJ,CAAC,CAAC;IACFgB,MAAM,EAAE,IAAA6B,qCAA6B,EAAC;MAClCH,MAAM,EAAEtC,QAAQ,CAACY;IACrB,CAAC,CAAC;IACFG,OAAO,EAAE,IAAA2B,sCAA8B,EAAC;MACpCJ,MAAM,EAAEtC,QAAQ,CAACe,OAAO;MACxBnB;IACJ,CAAC;EACL,CAAC;AACL,CAAC;AAAC"}
@@ -1,4 +1,4 @@
1
- import { CmsEntry, CmsModel } from "@webiny/api-headless-cms/types";
1
+ import { CmsStorageEntry, CmsModel } from "@webiny/api-headless-cms/types";
2
2
  import { Entity } from "dynamodb-toolbox";
3
3
  export interface GetAllEntryRevisionsParams {
4
4
  ids: readonly string[];
@@ -18,19 +18,23 @@ export interface GetLatestRevisionByEntryIdParams {
18
18
  }
19
19
  interface ClearLoaderParams {
20
20
  model: CmsModel;
21
- entry?: CmsEntry;
21
+ entry?: CmsStorageEntry;
22
22
  }
23
- export interface Params {
23
+ interface DataLoadersHandlerParams {
24
24
  entity: Entity<any>;
25
25
  }
26
26
  export declare class DataLoadersHandler {
27
27
  private readonly loaders;
28
28
  private readonly entity;
29
- constructor(params: any);
30
- getAllEntryRevisions(params: GetAllEntryRevisionsParams): Promise<CmsEntry[]>;
31
- getRevisionById(params: GetRevisionByIdParams): Promise<CmsEntry[]>;
32
- getPublishedRevisionByEntryId(params: GetPublishedRevisionByEntryIdParams): Promise<CmsEntry[]>;
33
- getLatestRevisionByEntryId(params: GetLatestRevisionByEntryIdParams): Promise<CmsEntry[]>;
29
+ constructor(params: DataLoadersHandlerParams);
30
+ getAllEntryRevisions(params: GetAllEntryRevisionsParams): Promise<CmsStorageEntry[]>;
31
+ getRevisionById(params: GetRevisionByIdParams): Promise<CmsStorageEntry[]>;
32
+ getPublishedRevisionByEntryId(params: GetPublishedRevisionByEntryIdParams): Promise<CmsStorageEntry[]>;
33
+ getLatestRevisionByEntryId(params: GetLatestRevisionByEntryIdParams): Promise<CmsStorageEntry[]>;
34
+ /**
35
+ * TODO @ts-refactor
36
+ * Maybe pass on the generics to DataLoader definition?
37
+ */
34
38
  private getLoader;
35
39
  private loadMany;
36
40
  clearAll(params: Omit<ClearLoaderParams, "entry">): void;
@@ -1,32 +1,19 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.DataLoadersHandler = void 0;
9
-
8
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
10
9
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
12
10
  var _dataloader = _interopRequireDefault(require("dataloader"));
13
-
14
11
  var _error = _interopRequireDefault(require("@webiny/error"));
15
-
16
12
  var _query = require("@webiny/db-dynamodb/utils/query");
17
-
18
13
  var _keys = require("./keys");
19
-
20
14
  var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
21
-
22
15
  var _utils = require("@webiny/utils");
23
-
24
16
  var _batchRead = require("@webiny/db-dynamodb/utils/batchRead");
25
-
26
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
27
-
28
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
29
-
30
17
  const getAllEntryRevisions = params => {
31
18
  const {
32
19
  entity,
@@ -37,8 +24,7 @@ const getAllEntryRevisions = params => {
37
24
  locale
38
25
  } = model;
39
26
  return new _dataloader.default(async ids => {
40
- const results = [];
41
-
27
+ const results = {};
42
28
  for (const id of ids) {
43
29
  const queryAllParams = {
44
30
  entity,
@@ -52,14 +38,13 @@ const getAllEntryRevisions = params => {
52
38
  }
53
39
  };
54
40
  const items = await (0, _query.queryAll)(queryAllParams);
55
- const entries = (0, _cleanup.cleanupItems)(entity, items);
56
- results.push(entries);
41
+ results[id] = (0, _cleanup.cleanupItems)(entity, items);
57
42
  }
58
-
59
- return results;
43
+ return ids.map(id => {
44
+ return results[id] || [];
45
+ });
60
46
  });
61
47
  };
62
-
63
48
  const getRevisionById = params => {
64
49
  const {
65
50
  entity,
@@ -79,20 +64,24 @@ const getRevisionById = params => {
79
64
  const {
80
65
  version
81
66
  } = (0, _utils.parseIdentifier)(id);
67
+ if (version === null) {
68
+ return collection;
69
+ }
82
70
  const sortKey = (0, _keys.createRevisionSortKey)({
83
71
  version
84
72
  });
85
73
  const keys = `${partitionKey}__${sortKey}`;
86
-
87
74
  if (collection[keys]) {
88
75
  return collection;
89
76
  }
90
-
91
77
  collection[keys] = entity.getBatch({
92
78
  PK: partitionKey,
93
79
  SK: sortKey
94
80
  });
95
81
  return collection;
82
+ /**
83
+ * We cast as any because there is no return type defined.
84
+ */
96
85
  }, {});
97
86
  const records = await (0, _batchRead.batchReadAll)({
98
87
  table: entity.table,
@@ -106,7 +95,6 @@ const getRevisionById = params => {
106
95
  });
107
96
  });
108
97
  };
109
-
110
98
  const getPublishedRevisionByEntryId = params => {
111
99
  const {
112
100
  entity,
@@ -124,16 +112,17 @@ const getPublishedRevisionByEntryId = params => {
124
112
  locale,
125
113
  id
126
114
  });
127
-
128
115
  if (collection[partitionKey]) {
129
116
  return collection;
130
117
  }
131
-
132
118
  collection[partitionKey] = entity.getBatch({
133
119
  PK: partitionKey,
134
120
  SK: publishedKey
135
121
  });
136
122
  return collection;
123
+ /**
124
+ * We cast as any because there is no return type defined.
125
+ */
137
126
  }, {});
138
127
  const records = await (0, _batchRead.batchReadAll)({
139
128
  table: entity.table,
@@ -150,7 +139,6 @@ const getPublishedRevisionByEntryId = params => {
150
139
  });
151
140
  });
152
141
  };
153
-
154
142
  const getLatestRevisionByEntryId = params => {
155
143
  const {
156
144
  entity,
@@ -168,16 +156,17 @@ const getLatestRevisionByEntryId = params => {
168
156
  locale,
169
157
  id
170
158
  });
171
-
172
159
  if (collection[partitionKey]) {
173
160
  return collection;
174
161
  }
175
-
176
162
  collection[partitionKey] = entity.getBatch({
177
163
  PK: partitionKey,
178
164
  SK: latestKey
179
165
  });
180
166
  return collection;
167
+ /**
168
+ * We cast as any because there is no return type defined.
169
+ */
181
170
  }, {});
182
171
  const records = await (0, _batchRead.batchReadAll)({
183
172
  table: entity.table,
@@ -194,7 +183,6 @@ const getLatestRevisionByEntryId = params => {
194
183
  });
195
184
  });
196
185
  };
197
-
198
186
  const dataLoaders = {
199
187
  getAllEntryRevisions,
200
188
  getRevisionById,
@@ -202,37 +190,35 @@ const dataLoaders = {
202
190
  getLatestRevisionByEntryId
203
191
  };
204
192
  const loaderNames = Object.keys(dataLoaders);
205
-
206
193
  class DataLoadersHandler {
207
194
  constructor(params) {
208
195
  (0, _defineProperty2.default)(this, "loaders", new Map());
209
196
  (0, _defineProperty2.default)(this, "entity", void 0);
210
197
  this.entity = params.entity;
211
198
  }
212
-
213
199
  async getAllEntryRevisions(params) {
214
200
  return await this.loadMany("getAllEntryRevisions", params, params.ids);
215
201
  }
216
-
217
202
  async getRevisionById(params) {
218
203
  return await this.loadMany("getRevisionById", params, params.ids);
219
204
  }
220
-
221
205
  async getPublishedRevisionByEntryId(params) {
222
206
  return await this.loadMany("getPublishedRevisionByEntryId", params, params.ids);
223
207
  }
224
-
225
208
  async getLatestRevisionByEntryId(params) {
226
209
  return await this.loadMany("getLatestRevisionByEntryId", params, params.ids);
227
210
  }
228
211
 
212
+ /**
213
+ * TODO @ts-refactor
214
+ * Maybe pass on the generics to DataLoader definition?
215
+ */
229
216
  getLoader(name, params) {
230
217
  if (!dataLoaders[name]) {
231
218
  throw new _error.default("Unknown data loader.", "UNKNOWN_DATA_LOADER", {
232
219
  name
233
220
  });
234
221
  }
235
-
236
222
  const {
237
223
  model
238
224
  } = params;
@@ -241,63 +227,52 @@ class DataLoadersHandler {
241
227
  locale
242
228
  } = model;
243
229
  const loaderKey = `${name}-${tenant}-${locale}-${model.modelId}`;
244
-
245
230
  if (!this.loaders.has(loaderKey)) {
246
- this.loaders.set(loaderKey, dataLoaders[name](_objectSpread(_objectSpread({}, params), {}, {
231
+ this.loaders.set(loaderKey, dataLoaders[name]((0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
247
232
  entity: this.entity
248
233
  })));
249
234
  }
250
-
251
235
  return this.loaders.get(loaderKey);
252
236
  }
253
-
254
237
  async loadMany(loader, params, ids) {
255
238
  let results;
256
-
257
239
  try {
258
240
  results = await this.getLoader(loader, params).loadMany(ids);
259
-
260
241
  if (Array.isArray(results) === true) {
261
242
  return results.reduce((acc, res) => {
262
243
  if (Array.isArray(res) === false) {
263
244
  if (res && res.message) {
264
- throw new _error.default(res.message, res.code, _objectSpread(_objectSpread({}, res), {}, {
245
+ throw new _error.default(res.message, res.code, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, res), {}, {
265
246
  data: JSON.stringify(res.data || {})
266
247
  }));
267
248
  }
268
-
269
- throw new _error.default("Result from the data loader must be an array of arrays which contain requested items.", "DATA_LOADER_RESULTS_ERROR", _objectSpread(_objectSpread({}, params), {}, {
249
+ throw new _error.default("Result from the data loader must be an array of arrays which contain requested items.", "DATA_LOADER_RESULTS_ERROR", (0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
270
250
  loader
271
251
  }));
272
252
  }
273
-
274
253
  acc.push(...res);
275
254
  return acc;
276
255
  }, []);
277
256
  }
278
257
  } catch (ex) {
279
- throw new _error.default(ex.message || "Data loader error.", ex.code || "DATA_LOADER_ERROR", _objectSpread(_objectSpread({
258
+ throw new _error.default(ex.message || "Data loader error.", ex.code || "DATA_LOADER_ERROR", (0, _objectSpread2.default)((0, _objectSpread2.default)({
280
259
  error: ex
281
260
  }, params), {}, {
282
261
  loader,
283
262
  ids
284
263
  }));
285
264
  }
286
-
287
265
  throw new _error.default(`Data loader did not return array of items or empty array.`, "INVALID_DATA_LOADER_RESULT", {
288
266
  loader,
289
267
  ids,
290
268
  results
291
269
  });
292
270
  }
293
-
294
271
  clearAll(params) {
295
272
  for (const name of loaderNames) {
296
273
  const loader = this.getLoader(name, params);
297
274
  loader.clearAll();
298
275
  }
299
276
  }
300
-
301
277
  }
302
-
303
278
  exports.DataLoadersHandler = DataLoadersHandler;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getAllEntryRevisions","params","entity","model","tenant","locale","DataLoader","ids","results","id","queryAllParams","partitionKey","createPartitionKey","options","beginsWith","items","queryAll","cleanupItems","map","getRevisionById","queries","reduce","collection","version","parseIdentifier","sortKey","createRevisionSortKey","keys","getBatch","PK","SK","records","batchReadAll","table","Object","values","filter","item","getPublishedRevisionByEntryId","publishedKey","createPublishedSortKey","entryId","getLatestRevisionByEntryId","latestKey","createLatestSortKey","dataLoaders","loaderNames","DataLoadersHandler","constructor","Map","loadMany","getLoader","name","WebinyError","loaderKey","modelId","loaders","has","set","get","loader","Array","isArray","acc","res","message","code","data","JSON","stringify","push","ex","error","clearAll"],"sources":["dataLoaders.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport { CmsStorageEntry, CmsModel } from \"@webiny/api-headless-cms/types\";\nimport WebinyError from \"@webiny/error\";\nimport { Entity } from \"dynamodb-toolbox\";\nimport { queryAll, QueryAllParams } from \"@webiny/db-dynamodb/utils/query\";\nimport {\n createLatestSortKey,\n createPartitionKey,\n createPublishedSortKey,\n createRevisionSortKey\n} from \"./keys\";\nimport { cleanupItems } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport { batchReadAll } from \"@webiny/db-dynamodb/utils/batchRead\";\n\nconst getAllEntryRevisions = (params: LoaderParams) => {\n const { entity, model } = params;\n const { tenant, locale } = model;\n return new DataLoader<string, CmsStorageEntry[]>(async (ids: readonly string[]) => {\n const results: Record<string, CmsStorageEntry[]> = {};\n for (const id of ids) {\n const queryAllParams: QueryAllParams = {\n entity,\n partitionKey: createPartitionKey({\n tenant,\n locale,\n id\n }),\n options: {\n beginsWith: \"REV#\"\n }\n };\n const items = await queryAll<CmsStorageEntry>(queryAllParams);\n results[id] = cleanupItems(entity, items);\n }\n\n return ids.map(id => {\n return results[id] || [];\n });\n });\n};\n\nconst getRevisionById = (params: LoaderParams) => {\n const { entity, model } = params;\n const { locale, tenant } = model;\n\n return new DataLoader<string, CmsStorageEntry[]>(async (ids: readonly string[]) => {\n const queries = ids.reduce((collection, id) => {\n const partitionKey = createPartitionKey({\n tenant,\n locale,\n id\n });\n const { version } = parseIdentifier(id);\n if (version === null) {\n return collection;\n }\n const sortKey = createRevisionSortKey({\n version\n });\n const keys = `${partitionKey}__${sortKey}`;\n if (collection[keys]) {\n return collection;\n }\n\n collection[keys] = entity.getBatch({\n PK: partitionKey,\n SK: sortKey\n });\n\n return collection;\n /**\n * We cast as any because there is no return type defined.\n */\n }, {} as Record<string, any>);\n\n const records = await batchReadAll<CmsStorageEntry>({\n table: entity.table,\n items: Object.values(queries)\n });\n const items = cleanupItems(entity, records);\n\n return ids.map(id => {\n return items.filter(item => {\n return id === item.id;\n });\n });\n });\n};\n\nconst getPublishedRevisionByEntryId = (params: LoaderParams) => {\n const { entity, model } = params;\n const { locale, tenant } = model;\n\n const publishedKey = createPublishedSortKey();\n\n return new DataLoader<string, CmsStorageEntry[]>(async (ids: readonly string[]) => {\n const queries = ids.reduce((collection, id) => {\n const partitionKey = createPartitionKey({\n tenant,\n locale,\n id\n });\n if (collection[partitionKey]) {\n return collection;\n }\n collection[partitionKey] = entity.getBatch({\n PK: partitionKey,\n SK: publishedKey\n });\n return collection;\n /**\n * We cast as any because there is no return type defined.\n */\n }, {} as Record<string, any>);\n\n const records = await batchReadAll<CmsStorageEntry>({\n table: entity.table,\n items: Object.values(queries)\n });\n const items = cleanupItems(entity, records);\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\nconst getLatestRevisionByEntryId = (params: LoaderParams) => {\n const { entity, model } = params;\n const { locale, tenant } = model;\n\n const latestKey = createLatestSortKey();\n\n return new DataLoader<string, CmsStorageEntry[]>(async (ids: readonly string[]) => {\n const queries = ids.reduce((collection, id) => {\n const partitionKey = createPartitionKey({\n tenant,\n locale,\n id\n });\n if (collection[partitionKey]) {\n return collection;\n }\n collection[partitionKey] = entity.getBatch({\n PK: partitionKey,\n SK: latestKey\n });\n return collection;\n /**\n * We cast as any because there is no return type defined.\n */\n }, {} as Record<string, any>);\n\n const records = await batchReadAll<CmsStorageEntry>({\n table: entity.table,\n items: Object.values(queries)\n });\n const items = cleanupItems(entity, records);\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\nconst dataLoaders: Record<Loaders, any> = {\n getAllEntryRevisions,\n getRevisionById,\n getPublishedRevisionByEntryId,\n getLatestRevisionByEntryId\n};\n\nexport interface GetAllEntryRevisionsParams {\n ids: readonly string[];\n model: CmsModel;\n}\n\nexport interface GetRevisionByIdParams {\n ids: readonly string[];\n model: CmsModel;\n}\n\nexport interface GetPublishedRevisionByEntryIdParams {\n ids: readonly string[];\n model: CmsModel;\n}\n\nexport interface GetLatestRevisionByEntryIdParams {\n ids: readonly string[];\n model: CmsModel;\n}\n\ninterface LoaderParams {\n entity: Entity<any>;\n model: CmsModel;\n}\n\ninterface GetLoaderParams {\n model: CmsModel;\n}\n\ninterface ClearLoaderParams {\n model: CmsModel;\n entry?: CmsStorageEntry;\n}\n\ntype Loaders =\n | \"getAllEntryRevisions\"\n | \"getRevisionById\"\n | \"getPublishedRevisionByEntryId\"\n | \"getLatestRevisionByEntryId\";\n\nconst loaderNames = Object.keys(dataLoaders) as Loaders[];\n\ninterface DataLoadersHandlerParams {\n entity: Entity<any>;\n}\nexport class DataLoadersHandler {\n private readonly loaders: Map<string, DataLoader<any, any>> = new Map();\n private readonly entity: Entity<any>;\n\n public constructor(params: DataLoadersHandlerParams) {\n this.entity = params.entity;\n }\n\n public async getAllEntryRevisions(\n params: GetAllEntryRevisionsParams\n ): Promise<CmsStorageEntry[]> {\n return await this.loadMany(\"getAllEntryRevisions\", params, params.ids);\n }\n\n public async getRevisionById(params: GetRevisionByIdParams): Promise<CmsStorageEntry[]> {\n return await this.loadMany(\"getRevisionById\", params, params.ids);\n }\n\n public async getPublishedRevisionByEntryId(\n params: GetPublishedRevisionByEntryIdParams\n ): Promise<CmsStorageEntry[]> {\n return await this.loadMany(\"getPublishedRevisionByEntryId\", params, params.ids);\n }\n\n public async getLatestRevisionByEntryId(\n params: GetLatestRevisionByEntryIdParams\n ): Promise<CmsStorageEntry[]> {\n return await this.loadMany(\"getLatestRevisionByEntryId\", params, params.ids);\n }\n\n /**\n * TODO @ts-refactor\n * Maybe pass on the generics to DataLoader definition?\n */\n private getLoader(name: Loaders, params: GetLoaderParams): DataLoader<any, any> {\n if (!dataLoaders[name]) {\n throw new WebinyError(\"Unknown data loader.\", \"UNKNOWN_DATA_LOADER\", {\n name\n });\n }\n const { model } = params;\n const { tenant, locale } = model;\n const loaderKey = `${name}-${tenant}-${locale}-${model.modelId}`;\n if (!this.loaders.has(loaderKey)) {\n this.loaders.set(\n loaderKey,\n dataLoaders[name]({\n ...params,\n entity: this.entity\n })\n );\n }\n return this.loaders.get(loaderKey) as DataLoader<any, any>;\n }\n\n private async loadMany(\n loader: Loaders,\n params: GetLoaderParams,\n ids: readonly string[]\n ): Promise<CmsStorageEntry[]> {\n let results;\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: Omit<ClearLoaderParams, \"entry\">): void {\n for (const name of loaderNames) {\n const loader = this.getLoader(name, params);\n loader.clearAll();\n }\n }\n}\n"],"mappings":";;;;;;;;;AAAA;AAEA;AAEA;AACA;AAMA;AACA;AACA;AAEA,MAAMA,oBAAoB,GAAIC,MAAoB,IAAK;EACnD,MAAM;IAAEC,MAAM;IAAEC;EAAM,CAAC,GAAGF,MAAM;EAChC,MAAM;IAAEG,MAAM;IAAEC;EAAO,CAAC,GAAGF,KAAK;EAChC,OAAO,IAAIG,mBAAU,CAA4B,MAAOC,GAAsB,IAAK;IAC/E,MAAMC,OAA0C,GAAG,CAAC,CAAC;IACrD,KAAK,MAAMC,EAAE,IAAIF,GAAG,EAAE;MAClB,MAAMG,cAA8B,GAAG;QACnCR,MAAM;QACNS,YAAY,EAAE,IAAAC,wBAAkB,EAAC;UAC7BR,MAAM;UACNC,MAAM;UACNI;QACJ,CAAC,CAAC;QACFI,OAAO,EAAE;UACLC,UAAU,EAAE;QAChB;MACJ,CAAC;MACD,MAAMC,KAAK,GAAG,MAAM,IAAAC,eAAQ,EAAkBN,cAAc,CAAC;MAC7DF,OAAO,CAACC,EAAE,CAAC,GAAG,IAAAQ,qBAAY,EAACf,MAAM,EAAEa,KAAK,CAAC;IAC7C;IAEA,OAAOR,GAAG,CAACW,GAAG,CAACT,EAAE,IAAI;MACjB,OAAOD,OAAO,CAACC,EAAE,CAAC,IAAI,EAAE;IAC5B,CAAC,CAAC;EACN,CAAC,CAAC;AACN,CAAC;AAED,MAAMU,eAAe,GAAIlB,MAAoB,IAAK;EAC9C,MAAM;IAAEC,MAAM;IAAEC;EAAM,CAAC,GAAGF,MAAM;EAChC,MAAM;IAAEI,MAAM;IAAED;EAAO,CAAC,GAAGD,KAAK;EAEhC,OAAO,IAAIG,mBAAU,CAA4B,MAAOC,GAAsB,IAAK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Q,EAAE,EAAE;MACT,MAAM,IAAIlB,cAAW,CACjBkB,EAAE,CAACN,OAAO,IAAI,oBAAoB,EAClCM,EAAE,CAACL,IAAI,IAAI,mBAAmB;QAE1BM,KAAK,EAAED;MAAE,GACNtE,MAAM;QACT2D,MAAM;QACNrD;MAAG,GAEV;IACL;IACA,MAAM,IAAI8C,cAAW,CAChB,2DAA0D,EAC3D,4BAA4B,EAC5B;MACIO,MAAM;MACNrD,GAAG;MACHC;IACJ,CAAC,CACJ;EACL;EAEOiE,QAAQ,CAACxE,MAAwC,EAAQ;IAC5D,KAAK,MAAMmD,IAAI,IAAIN,WAAW,EAAE;MAC5B,MAAMc,MAAM,GAAG,IAAI,CAACT,SAAS,CAACC,IAAI,EAAEnD,MAAM,CAAC;MAC3C2D,MAAM,CAACa,QAAQ,EAAE;IACrB;EACJ;AACJ;AAAC"}
@@ -0,0 +1,26 @@
1
+ import { CmsEntryListWhere } from "@webiny/api-headless-cms/types";
2
+ import { ValueFilterPlugin } from "@webiny/db-dynamodb/plugins/definitions/ValueFilterPlugin";
3
+ import { PluginsContainer } from "@webiny/plugins";
4
+ import { Field } from "./types";
5
+ interface Params {
6
+ plugins: PluginsContainer;
7
+ where: Partial<CmsEntryListWhere>;
8
+ fields: Record<string, Field>;
9
+ }
10
+ export declare type ExpressionCondition = "AND" | "OR";
11
+ export interface Expression {
12
+ expressions: Expression[];
13
+ filters: Filter[];
14
+ condition: ExpressionCondition;
15
+ }
16
+ export interface Filter {
17
+ field: Field;
18
+ path: string;
19
+ fieldPathId: string;
20
+ plugin: ValueFilterPlugin;
21
+ negate: boolean;
22
+ compareValue: any;
23
+ transformValue: <I = any, O = any>(value: I) => O;
24
+ }
25
+ export declare const createExpressions: (params: Params) => Expression;
26
+ export {};