@webiny/api-headless-cms-ddb 0.0.0-mt-3 → 0.0.0-unstable.3386f66516

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 (133) hide show
  1. package/definitions/entry.d.ts +2 -1
  2. package/definitions/entry.js +6 -7
  3. package/definitions/entry.js.map +1 -0
  4. package/definitions/group.d.ts +2 -1
  5. package/definitions/group.js +3 -7
  6. package/definitions/group.js.map +1 -0
  7. package/definitions/model.d.ts +2 -1
  8. package/definitions/model.js +8 -7
  9. package/definitions/model.js.map +1 -0
  10. package/definitions/settings.d.ts +2 -1
  11. package/definitions/settings.js +3 -7
  12. package/definitions/settings.js.map +1 -0
  13. package/definitions/system.d.ts +2 -1
  14. package/definitions/system.js +3 -7
  15. package/definitions/system.js.map +1 -0
  16. package/definitions/table.d.ts +2 -1
  17. package/definitions/table.js.map +1 -0
  18. package/dynamoDb/index.d.ts +1 -1
  19. package/dynamoDb/index.js +6 -10
  20. package/dynamoDb/index.js.map +1 -0
  21. package/dynamoDb/path/plainObject.d.ts +2 -3
  22. package/dynamoDb/path/plainObject.js +29 -22
  23. package/dynamoDb/path/plainObject.js.map +1 -0
  24. package/dynamoDb/storage/date.d.ts +3 -3
  25. package/dynamoDb/storage/date.js +90 -46
  26. package/dynamoDb/storage/date.js.map +1 -0
  27. package/dynamoDb/storage/longText.d.ts +7 -4
  28. package/dynamoDb/storage/longText.js +79 -54
  29. package/dynamoDb/storage/longText.js.map +1 -0
  30. package/dynamoDb/storage/richText.d.ts +2 -8
  31. package/dynamoDb/storage/richText.js +70 -67
  32. package/dynamoDb/storage/richText.js.map +1 -0
  33. package/dynamoDb/transformValue/datetime.d.ts +4 -2
  34. package/dynamoDb/transformValue/datetime.js +31 -26
  35. package/dynamoDb/transformValue/datetime.js.map +1 -0
  36. package/index.d.ts +1 -0
  37. package/index.js +54 -23
  38. package/index.js.map +1 -0
  39. package/operations/entry/dataLoaders.d.ts +12 -8
  40. package/operations/entry/dataLoaders.js +31 -13
  41. package/operations/entry/dataLoaders.js.map +1 -0
  42. package/operations/entry/filtering/createExpressions.d.ts +26 -0
  43. package/operations/entry/filtering/createExpressions.js +213 -0
  44. package/operations/entry/filtering/createExpressions.js.map +1 -0
  45. package/operations/entry/filtering/createFields.d.ts +14 -0
  46. package/operations/entry/filtering/createFields.js +123 -0
  47. package/operations/entry/filtering/createFields.js.map +1 -0
  48. package/operations/entry/filtering/extractSort.d.ts +17 -0
  49. package/operations/entry/filtering/extractSort.js +77 -0
  50. package/operations/entry/filtering/extractSort.js.map +1 -0
  51. package/operations/entry/filtering/filter.d.ts +15 -0
  52. package/operations/entry/filtering/filter.js +178 -0
  53. package/operations/entry/filtering/filter.js.map +1 -0
  54. package/operations/entry/filtering/fullTextSearch.d.ts +14 -0
  55. package/operations/entry/filtering/fullTextSearch.js +60 -0
  56. package/operations/entry/filtering/fullTextSearch.js.map +1 -0
  57. package/operations/entry/filtering/getValue.d.ts +5 -0
  58. package/operations/entry/filtering/getValue.js +81 -0
  59. package/operations/entry/filtering/getValue.js.map +1 -0
  60. package/operations/entry/filtering/index.d.ts +2 -0
  61. package/operations/entry/filtering/index.js +21 -0
  62. package/operations/entry/filtering/index.js.map +1 -0
  63. package/operations/entry/filtering/mapPlugins.d.ts +8 -0
  64. package/operations/entry/filtering/mapPlugins.js +39 -0
  65. package/operations/entry/filtering/mapPlugins.js.map +1 -0
  66. package/operations/entry/filtering/plugins/defaultFilterCreate.d.ts +2 -0
  67. package/operations/entry/filtering/plugins/defaultFilterCreate.js +48 -0
  68. package/operations/entry/filtering/plugins/defaultFilterCreate.js.map +1 -0
  69. package/operations/entry/filtering/plugins/index.d.ts +1 -0
  70. package/operations/entry/filtering/plugins/index.js +18 -0
  71. package/operations/entry/filtering/plugins/index.js.map +1 -0
  72. package/operations/entry/filtering/plugins/objectFilterCreate.d.ts +2 -0
  73. package/operations/entry/filtering/plugins/objectFilterCreate.js +107 -0
  74. package/operations/entry/filtering/plugins/objectFilterCreate.js.map +1 -0
  75. package/operations/entry/filtering/plugins/refFilterCreate.d.ts +2 -0
  76. package/operations/entry/filtering/plugins/refFilterCreate.js +89 -0
  77. package/operations/entry/filtering/plugins/refFilterCreate.js.map +1 -0
  78. package/operations/entry/filtering/sort.d.ts +12 -0
  79. package/operations/entry/filtering/sort.js +84 -0
  80. package/operations/entry/filtering/sort.js.map +1 -0
  81. package/operations/entry/filtering/systemFields.d.ts +4 -0
  82. package/operations/entry/filtering/systemFields.js +72 -0
  83. package/operations/entry/filtering/systemFields.js.map +1 -0
  84. package/operations/entry/filtering/transform.d.ts +6 -0
  85. package/operations/entry/filtering/transform.js +19 -0
  86. package/operations/entry/filtering/transform.js.map +1 -0
  87. package/operations/entry/filtering/types.d.ts +40 -0
  88. package/operations/entry/filtering/types.js +5 -0
  89. package/operations/entry/filtering/types.js.map +1 -0
  90. package/operations/entry/filtering/values.d.ts +2 -0
  91. package/operations/entry/filtering/values.js +28 -0
  92. package/operations/entry/filtering/values.js.map +1 -0
  93. package/operations/entry/filtering/where.d.ts +5 -0
  94. package/operations/entry/filtering/where.js +38 -0
  95. package/operations/entry/filtering/where.js.map +1 -0
  96. package/operations/entry/index.d.ts +2 -2
  97. package/operations/entry/index.js +278 -227
  98. package/operations/entry/index.js.map +1 -0
  99. package/operations/entry/keys.js +11 -0
  100. package/operations/entry/keys.js.map +1 -0
  101. package/operations/entry/systemFields.js +24 -0
  102. package/operations/entry/systemFields.js.map +1 -0
  103. package/operations/group/index.d.ts +3 -2
  104. package/operations/group/index.js +7 -13
  105. package/operations/group/index.js.map +1 -0
  106. package/operations/model/index.d.ts +3 -2
  107. package/operations/model/index.js +15 -14
  108. package/operations/model/index.js.map +1 -0
  109. package/operations/settings/index.d.ts +3 -2
  110. package/operations/settings/index.js +7 -13
  111. package/operations/settings/index.js.map +1 -0
  112. package/operations/system/index.d.ts +3 -2
  113. package/operations/system/index.js +5 -11
  114. package/operations/system/index.js.map +1 -0
  115. package/package.json +22 -23
  116. package/plugins/CmsEntryFieldFilterPathPlugin.d.ts +22 -0
  117. package/plugins/CmsEntryFieldFilterPathPlugin.js +55 -0
  118. package/plugins/CmsEntryFieldFilterPathPlugin.js.map +1 -0
  119. package/plugins/CmsEntryFieldFilterPlugin.d.ts +43 -0
  120. package/plugins/CmsEntryFieldFilterPlugin.js +31 -0
  121. package/plugins/CmsEntryFieldFilterPlugin.js.map +1 -0
  122. package/plugins/CmsEntryFieldSortingPlugin.d.ts +42 -0
  123. package/plugins/CmsEntryFieldSortingPlugin.js +38 -0
  124. package/plugins/CmsEntryFieldSortingPlugin.js.map +1 -0
  125. package/plugins/index.d.ts +3 -0
  126. package/plugins/index.js +44 -0
  127. package/plugins/index.js.map +1 -0
  128. package/types.d.ts +2 -33
  129. package/types.js.map +1 -0
  130. package/dynamoDb/path/ref.d.ts +0 -3
  131. package/dynamoDb/path/ref.js +0 -27
  132. package/operations/entry/utils.d.ts +0 -31
  133. package/operations/entry/utils.js +0 -406
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.createSystemStorageOperations = void 0;
9
9
 
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
11
 
12
12
  var _error = _interopRequireDefault(require("@webiny/error"));
13
13
 
@@ -15,10 +15,6 @@ var _get = require("@webiny/db-dynamodb/utils/get");
15
15
 
16
16
  var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
17
17
 
18
- 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; }
19
-
20
- 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; }
21
-
22
18
  const createPartitionKey = ({
23
19
  tenant
24
20
  }) => {
@@ -47,7 +43,7 @@ const createSystemStorageOperations = params => {
47
43
  const keys = createKeys(system);
48
44
 
49
45
  try {
50
- await entity.put(_objectSpread(_objectSpread({}, system), keys));
46
+ await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, system), keys));
51
47
  return system;
52
48
  } catch (ex) {
53
49
  throw new _error.default(ex.message || "Could not create system.", ex.code || "CREATE_SYSTEM_ERROR", {
@@ -60,19 +56,17 @@ const createSystemStorageOperations = params => {
60
56
 
61
57
  const update = async params => {
62
58
  const {
63
- system,
64
- original
59
+ system
65
60
  } = params;
66
61
  const keys = createKeys(system);
67
62
 
68
63
  try {
69
- await entity.put(_objectSpread(_objectSpread({}, system), keys));
64
+ await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, system), keys));
70
65
  return system;
71
66
  } catch (ex) {
72
67
  throw new _error.default(ex.message || "Could not update system.", ex.code || "UPDATE_SYSTEM_ERROR", {
73
68
  error: ex,
74
69
  system,
75
- original,
76
70
  keys
77
71
  });
78
72
  }
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createPartitionKey","tenant","toLowerCase","createSortKey","createKeys","params","PK","SK","createSystemStorageOperations","entity","create","system","keys","put","ex","WebinyError","message","code","error","update","get","getRecord","cleanupItem"],"sources":["index.ts"],"sourcesContent":["import {\n CmsSystem,\n CmsSystemStorageOperations,\n CmsSystemStorageOperationsCreateParams,\n CmsSystemStorageOperationsGetParams,\n CmsSystemStorageOperationsUpdateParams\n} from \"@webiny/api-headless-cms/types\";\nimport { Entity } from \"dynamodb-toolbox\";\nimport WebinyError from \"@webiny/error\";\nimport { get as getRecord } from \"@webiny/db-dynamodb/utils/get\";\nimport { cleanupItem } from \"@webiny/db-dynamodb/utils/cleanup\";\n\ninterface CreateSystemStorageOperationsParams {\n entity: Entity<any>;\n}\n\ninterface PartitionKeyParams {\n tenant: string;\n}\nconst createPartitionKey = ({ tenant }: PartitionKeyParams): string => {\n return `T#${tenant.toLowerCase()}#SYSTEM`;\n};\nconst createSortKey = (): string => {\n return \"CMS\";\n};\n\ninterface Keys {\n PK: string;\n SK: string;\n}\nconst createKeys = (params: PartitionKeyParams): Keys => {\n return {\n PK: createPartitionKey(params),\n SK: createSortKey()\n };\n};\n\nexport const createSystemStorageOperations = (\n params: CreateSystemStorageOperationsParams\n): CmsSystemStorageOperations => {\n const { entity } = params;\n\n const create = async ({ system }: CmsSystemStorageOperationsCreateParams) => {\n const keys = createKeys(system);\n try {\n await entity.put({\n ...system,\n ...keys\n });\n return system;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create system.\",\n ex.code || \"CREATE_SYSTEM_ERROR\",\n {\n error: ex,\n system,\n keys\n }\n );\n }\n };\n\n const update = async (params: CmsSystemStorageOperationsUpdateParams) => {\n const { system } = params;\n\n const keys = createKeys(system);\n\n try {\n await entity.put({\n ...system,\n ...keys\n });\n return system;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update system.\",\n ex.code || \"UPDATE_SYSTEM_ERROR\",\n {\n error: ex,\n system,\n keys\n }\n );\n }\n };\n\n const get = async (params: CmsSystemStorageOperationsGetParams) => {\n const keys = createKeys(params);\n\n try {\n const system = await getRecord<CmsSystem>({\n entity,\n keys\n });\n return cleanupItem(entity, system);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get system.\",\n ex.code || \"GET_SYSTEM_ERROR\",\n {\n error: ex,\n keys\n }\n );\n }\n };\n\n return {\n create,\n update,\n get\n };\n};\n"],"mappings":";;;;;;;;;;;AAQA;;AACA;;AACA;;AASA,MAAMA,kBAAkB,GAAG,CAAC;EAAEC;AAAF,CAAD,KAA4C;EACnE,OAAQ,KAAIA,MAAM,CAACC,WAAP,EAAqB,SAAjC;AACH,CAFD;;AAGA,MAAMC,aAAa,GAAG,MAAc;EAChC,OAAO,KAAP;AACH,CAFD;;AAQA,MAAMC,UAAU,GAAIC,MAAD,IAAsC;EACrD,OAAO;IACHC,EAAE,EAAEN,kBAAkB,CAACK,MAAD,CADnB;IAEHE,EAAE,EAAEJ,aAAa;EAFd,CAAP;AAIH,CALD;;AAOO,MAAMK,6BAA6B,GACtCH,MADyC,IAEZ;EAC7B,MAAM;IAAEI;EAAF,IAAaJ,MAAnB;;EAEA,MAAMK,MAAM,GAAG,OAAO;IAAEC;EAAF,CAAP,KAA8D;IACzE,MAAMC,IAAI,GAAGR,UAAU,CAACO,MAAD,CAAvB;;IACA,IAAI;MACA,MAAMF,MAAM,CAACI,GAAP,6DACCF,MADD,GAECC,IAFD,EAAN;MAIA,OAAOD,MAAP;IACH,CAND,CAME,OAAOG,EAAP,EAAW;MACT,MAAM,IAAIC,cAAJ,CACFD,EAAE,CAACE,OAAH,IAAc,0BADZ,EAEFF,EAAE,CAACG,IAAH,IAAW,qBAFT,EAGF;QACIC,KAAK,EAAEJ,EADX;QAEIH,MAFJ;QAGIC;MAHJ,CAHE,CAAN;IASH;EACJ,CAnBD;;EAqBA,MAAMO,MAAM,GAAG,MAAOd,MAAP,IAA0D;IACrE,MAAM;MAAEM;IAAF,IAAaN,MAAnB;IAEA,MAAMO,IAAI,GAAGR,UAAU,CAACO,MAAD,CAAvB;;IAEA,IAAI;MACA,MAAMF,MAAM,CAACI,GAAP,6DACCF,MADD,GAECC,IAFD,EAAN;MAIA,OAAOD,MAAP;IACH,CAND,CAME,OAAOG,EAAP,EAAW;MACT,MAAM,IAAIC,cAAJ,CACFD,EAAE,CAACE,OAAH,IAAc,0BADZ,EAEFF,EAAE,CAACG,IAAH,IAAW,qBAFT,EAGF;QACIC,KAAK,EAAEJ,EADX;QAEIH,MAFJ;QAGIC;MAHJ,CAHE,CAAN;IASH;EACJ,CAtBD;;EAwBA,MAAMQ,GAAG,GAAG,MAAOf,MAAP,IAAuD;IAC/D,MAAMO,IAAI,GAAGR,UAAU,CAACC,MAAD,CAAvB;;IAEA,IAAI;MACA,MAAMM,MAAM,GAAG,MAAM,IAAAU,QAAA,EAAqB;QACtCZ,MADsC;QAEtCG;MAFsC,CAArB,CAArB;MAIA,OAAO,IAAAU,oBAAA,EAAYb,MAAZ,EAAoBE,MAApB,CAAP;IACH,CAND,CAME,OAAOG,EAAP,EAAW;MACT,MAAM,IAAIC,cAAJ,CACFD,EAAE,CAACE,OAAH,IAAc,uBADZ,EAEFF,EAAE,CAACG,IAAH,IAAW,kBAFT,EAGF;QACIC,KAAK,EAAEJ,EADX;QAEIF;MAFJ,CAHE,CAAN;IAQH;EACJ,CAnBD;;EAqBA,OAAO;IACHF,MADG;IAEHS,MAFG;IAGHC;EAHG,CAAP;AAKH,CA5EM"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-headless-cms-ddb",
3
- "version": "0.0.0-mt-3",
3
+ "version": "0.0.0-unstable.3386f66516",
4
4
  "main": "index.js",
5
5
  "keywords": [
6
6
  "@webiny/api-headless-cms",
@@ -21,33 +21,32 @@
21
21
  ],
22
22
  "license": "MIT",
23
23
  "dependencies": {
24
- "@babel/runtime": "7.15.4",
25
- "@webiny/api-headless-cms": "0.0.0-mt-3",
26
- "@webiny/db-dynamodb": "0.0.0-mt-3",
27
- "@webiny/error": "0.0.0-mt-3",
28
- "@webiny/handler-db": "0.0.0-mt-3",
29
- "@webiny/utils": "0.0.0-mt-3",
30
- "aws-sdk": "2.1026.0",
31
- "dataloader": "2.0.0",
32
- "dot-prop": "5.3.0",
33
- "dynamodb-toolbox": "0.3.4",
24
+ "@babel/runtime": "7.19.0",
25
+ "@webiny/api-headless-cms": "0.0.0-unstable.3386f66516",
26
+ "@webiny/db-dynamodb": "0.0.0-unstable.3386f66516",
27
+ "@webiny/error": "0.0.0-unstable.3386f66516",
28
+ "@webiny/handler-db": "0.0.0-unstable.3386f66516",
29
+ "@webiny/utils": "0.0.0-unstable.3386f66516",
30
+ "aws-sdk": "2.1230.0",
31
+ "dataloader": "2.1.0",
32
+ "dot-prop": "6.0.1",
33
+ "dynamodb-toolbox": "0.3.5",
34
34
  "jsonpack": "1.1.5",
35
- "lodash.sortby": "4.7.0"
35
+ "lodash": "4.17.21"
36
36
  },
37
37
  "devDependencies": {
38
- "@babel/cli": "^7.5.5",
39
- "@babel/core": "^7.5.5",
40
- "@babel/preset-env": "^7.5.5",
41
- "@babel/preset-flow": "^7.0.0",
38
+ "@babel/cli": "^7.19.3",
39
+ "@babel/core": "^7.19.3",
40
+ "@babel/preset-env": "^7.19.4",
42
41
  "@types/jsonpack": "^1.1.0",
43
- "@webiny/cli": "^0.0.0-mt-3",
44
- "@webiny/plugins": "^0.0.0-mt-3",
45
- "@webiny/project-utils": "^0.0.0-mt-3",
46
- "jest": "^26.6.3",
42
+ "@webiny/cli": "^0.0.0-unstable.3386f66516",
43
+ "@webiny/plugins": "^0.0.0-unstable.3386f66516",
44
+ "@webiny/project-utils": "^0.0.0-unstable.3386f66516",
45
+ "jest": "^28.1.0",
47
46
  "jest-dynalite": "^3.2.0",
48
- "jest-environment-node": "^26.6.2",
47
+ "jest-environment-node": "^27.2.4",
49
48
  "ttypescript": "^1.5.12",
50
- "typescript": "^4.1.3"
49
+ "typescript": "4.7.4"
51
50
  },
52
51
  "publishConfig": {
53
52
  "access": "public",
@@ -57,5 +56,5 @@
57
56
  "build": "yarn webiny run build",
58
57
  "watch": "yarn webiny run watch"
59
58
  },
60
- "gitHead": "ebea815be2be99404591cba465cc1fe88355bd48"
59
+ "gitHead": "3386f66516b16fe54e2508243b91dfff1a0156f9"
61
60
  }
@@ -0,0 +1,22 @@
1
+ import { Plugin } from "@webiny/plugins/Plugin";
2
+ import { CmsModelField } from "@webiny/api-headless-cms/types";
3
+ export interface CreatePathCallableParams {
4
+ field: Partial<CmsModelField> & Pick<CmsModelField, "fieldId" | "storageId" | "id">;
5
+ index?: number;
6
+ }
7
+ export interface CreatePathCallable {
8
+ (params: CreatePathCallableParams): string;
9
+ }
10
+ export interface CmsEntryFieldFilterPathPluginParams {
11
+ fieldType: string;
12
+ fieldId?: string[];
13
+ path: string | CreatePathCallable;
14
+ }
15
+ export declare class CmsEntryFieldFilterPathPlugin extends Plugin {
16
+ static readonly type: string;
17
+ private readonly config;
18
+ get fieldType(): string;
19
+ constructor(config: CmsEntryFieldFilterPathPluginParams);
20
+ canUse(field: Pick<CmsModelField, "fieldId" | "type">): boolean;
21
+ createPath(params: CreatePathCallableParams): string;
22
+ }
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.CmsEntryFieldFilterPathPlugin = void 0;
9
+
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+
12
+ var _error = _interopRequireDefault(require("@webiny/error"));
13
+
14
+ var _Plugin = require("@webiny/plugins/Plugin");
15
+
16
+ class CmsEntryFieldFilterPathPlugin extends _Plugin.Plugin {
17
+ get fieldType() {
18
+ return this.config.fieldType;
19
+ }
20
+
21
+ constructor(config) {
22
+ super();
23
+ (0, _defineProperty2.default)(this, "config", void 0);
24
+ this.config = config;
25
+ this.name = `${this.constructor.type}-${this.config.fieldType}`;
26
+ }
27
+
28
+ canUse(field) {
29
+ if (field.type !== this.config.fieldType) {
30
+ return false;
31
+ }
32
+
33
+ const fieldId = this.config.fieldId;
34
+
35
+ if (!fieldId || Array.isArray(fieldId) === false || fieldId.length === 0) {
36
+ return true;
37
+ }
38
+
39
+ return fieldId.includes(field.fieldId);
40
+ }
41
+
42
+ createPath(params) {
43
+ if (typeof this.config.path === "function") {
44
+ return this.config.path(params);
45
+ } else if (typeof this.config.path === "string") {
46
+ return this.config.path;
47
+ }
48
+
49
+ throw new _error.default(`Missing path in "${this.name}" plugin.`);
50
+ }
51
+
52
+ }
53
+
54
+ exports.CmsEntryFieldFilterPathPlugin = CmsEntryFieldFilterPathPlugin;
55
+ (0, _defineProperty2.default)(CmsEntryFieldFilterPathPlugin, "type", "cms-field-filter-path");
@@ -0,0 +1 @@
1
+ {"version":3,"names":["CmsEntryFieldFilterPathPlugin","Plugin","fieldType","config","constructor","name","type","canUse","field","fieldId","Array","isArray","length","includes","createPath","params","path","WebinyError"],"sources":["CmsEntryFieldFilterPathPlugin.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { Plugin } from \"@webiny/plugins/Plugin\";\nimport { CmsModelField } from \"@webiny/api-headless-cms/types\";\n\nexport interface CreatePathCallableParams {\n field: Partial<CmsModelField> & Pick<CmsModelField, \"fieldId\" | \"storageId\" | \"id\">;\n index?: number;\n}\nexport interface CreatePathCallable {\n (params: CreatePathCallableParams): string;\n}\nexport interface CmsEntryFieldFilterPathPluginParams {\n fieldType: string;\n fieldId?: string[];\n path: string | CreatePathCallable;\n}\nexport class CmsEntryFieldFilterPathPlugin extends Plugin {\n public static override readonly type: string = \"cms-field-filter-path\";\n\n private readonly config: CmsEntryFieldFilterPathPluginParams;\n\n public get fieldType(): string {\n return this.config.fieldType;\n }\n\n public constructor(config: CmsEntryFieldFilterPathPluginParams) {\n super();\n\n this.config = config;\n\n this.name = `${(this.constructor as any).type}-${this.config.fieldType}`;\n }\n\n public canUse(field: Pick<CmsModelField, \"fieldId\" | \"type\">): boolean {\n if (field.type !== this.config.fieldType) {\n return false;\n }\n const fieldId = this.config.fieldId;\n if (!fieldId || Array.isArray(fieldId) === false || fieldId.length === 0) {\n return true;\n }\n return fieldId.includes(field.fieldId);\n }\n\n public createPath(params: CreatePathCallableParams): string {\n if (typeof this.config.path === \"function\") {\n return this.config.path(params);\n } else if (typeof this.config.path === \"string\") {\n return this.config.path;\n }\n throw new WebinyError(`Missing path in \"${this.name}\" plugin.`);\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AAeO,MAAMA,6BAAN,SAA4CC,cAA5C,CAAmD;EAKlC,IAATC,SAAS,GAAW;IAC3B,OAAO,KAAKC,MAAL,CAAYD,SAAnB;EACH;;EAEME,WAAW,CAACD,MAAD,EAA8C;IAC5D;IAD4D;IAG5D,KAAKA,MAAL,GAAcA,MAAd;IAEA,KAAKE,IAAL,GAAa,GAAG,KAAKD,WAAN,CAA0BE,IAAK,IAAG,KAAKH,MAAL,CAAYD,SAAU,EAAvE;EACH;;EAEMK,MAAM,CAACC,KAAD,EAA0D;IACnE,IAAIA,KAAK,CAACF,IAAN,KAAe,KAAKH,MAAL,CAAYD,SAA/B,EAA0C;MACtC,OAAO,KAAP;IACH;;IACD,MAAMO,OAAO,GAAG,KAAKN,MAAL,CAAYM,OAA5B;;IACA,IAAI,CAACA,OAAD,IAAYC,KAAK,CAACC,OAAN,CAAcF,OAAd,MAA2B,KAAvC,IAAgDA,OAAO,CAACG,MAAR,KAAmB,CAAvE,EAA0E;MACtE,OAAO,IAAP;IACH;;IACD,OAAOH,OAAO,CAACI,QAAR,CAAiBL,KAAK,CAACC,OAAvB,CAAP;EACH;;EAEMK,UAAU,CAACC,MAAD,EAA2C;IACxD,IAAI,OAAO,KAAKZ,MAAL,CAAYa,IAAnB,KAA4B,UAAhC,EAA4C;MACxC,OAAO,KAAKb,MAAL,CAAYa,IAAZ,CAAiBD,MAAjB,CAAP;IACH,CAFD,MAEO,IAAI,OAAO,KAAKZ,MAAL,CAAYa,IAAnB,KAA4B,QAAhC,EAA0C;MAC7C,OAAO,KAAKb,MAAL,CAAYa,IAAnB;IACH;;IACD,MAAM,IAAIC,cAAJ,CAAiB,oBAAmB,KAAKZ,IAAK,WAA9C,CAAN;EACH;;AAnCqD;;;8BAA7CL,6B,UACsC,uB"}
@@ -0,0 +1,43 @@
1
+ import { Plugin } from "@webiny/plugins";
2
+ import { ValueFilterPlugin } from "@webiny/db-dynamodb/plugins/definitions/ValueFilterPlugin";
3
+ import { Field } from "../operations/entry/filtering/types";
4
+ import { CmsFieldFilterValueTransformPlugin } from "../types";
5
+ /**
6
+ * This plugin is used to create the filter.
7
+ * Internally we have default one + the one for the reference field - because it is actually an object when filtering.
8
+ */
9
+ interface CmsEntryFieldFilterPluginParams {
10
+ fieldType: string;
11
+ create: (params: CmsEntryFieldFilterPluginCreateParams) => null | CmsEntryFieldFilterPluginCreateResponse | CmsEntryFieldFilterPluginCreateResponse[];
12
+ }
13
+ interface CmsEntryFieldFilterPluginCreateParams {
14
+ key: string;
15
+ value: any;
16
+ field: Field;
17
+ fields: Record<string, Field>;
18
+ operation: string;
19
+ valueFilterPlugins: Record<string, ValueFilterPlugin>;
20
+ transformValuePlugins: Record<string, CmsFieldFilterValueTransformPlugin>;
21
+ getFilterCreatePlugin: (type: string) => CmsEntryFieldFilterPlugin;
22
+ negate: boolean;
23
+ compareValue: any;
24
+ transformValue: <I = any, O = any>(value: I) => O;
25
+ }
26
+ export interface CmsEntryFieldFilterPluginCreateResponse {
27
+ field: Field;
28
+ path: string;
29
+ fieldPathId: string;
30
+ plugin: ValueFilterPlugin;
31
+ negate: boolean;
32
+ compareValue: any;
33
+ transformValue: <I = any, O = any>(value: I) => O;
34
+ }
35
+ export declare class CmsEntryFieldFilterPlugin extends Plugin {
36
+ static readonly type: string;
37
+ static readonly ALL: string;
38
+ private readonly config;
39
+ readonly fieldType: string;
40
+ constructor(config: CmsEntryFieldFilterPluginParams);
41
+ create(params: CmsEntryFieldFilterPluginCreateParams): CmsEntryFieldFilterPluginCreateResponse | CmsEntryFieldFilterPluginCreateResponse[] | null;
42
+ }
43
+ export {};
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.CmsEntryFieldFilterPlugin = void 0;
9
+
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+
12
+ var _plugins = require("@webiny/plugins");
13
+
14
+ class CmsEntryFieldFilterPlugin extends _plugins.Plugin {
15
+ constructor(config) {
16
+ super();
17
+ (0, _defineProperty2.default)(this, "config", void 0);
18
+ (0, _defineProperty2.default)(this, "fieldType", void 0);
19
+ this.config = config;
20
+ this.fieldType = this.config.fieldType;
21
+ }
22
+
23
+ create(params) {
24
+ return this.config.create(params);
25
+ }
26
+
27
+ }
28
+
29
+ exports.CmsEntryFieldFilterPlugin = CmsEntryFieldFilterPlugin;
30
+ (0, _defineProperty2.default)(CmsEntryFieldFilterPlugin, "type", "cms.dynamodb.entry.field.filter");
31
+ (0, _defineProperty2.default)(CmsEntryFieldFilterPlugin, "ALL", "*");
@@ -0,0 +1 @@
1
+ {"version":3,"names":["CmsEntryFieldFilterPlugin","Plugin","constructor","config","fieldType","create","params"],"sources":["CmsEntryFieldFilterPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { ValueFilterPlugin } from \"@webiny/db-dynamodb/plugins/definitions/ValueFilterPlugin\";\nimport { Field } from \"~/operations/entry/filtering/types\";\nimport { CmsFieldFilterValueTransformPlugin } from \"~/types\";\n\n/**\n * This plugin is used to create the filter.\n * Internally we have default one + the one for the reference field - because it is actually an object when filtering.\n */\n\ninterface CmsEntryFieldFilterPluginParams {\n fieldType: string;\n create: (\n params: CmsEntryFieldFilterPluginCreateParams\n ) => null | CmsEntryFieldFilterPluginCreateResponse | CmsEntryFieldFilterPluginCreateResponse[];\n}\n\ninterface CmsEntryFieldFilterPluginCreateParams {\n key: string;\n value: any;\n field: Field;\n fields: Record<string, Field>;\n operation: string;\n valueFilterPlugins: Record<string, ValueFilterPlugin>;\n transformValuePlugins: Record<string, CmsFieldFilterValueTransformPlugin>;\n getFilterCreatePlugin: (type: string) => CmsEntryFieldFilterPlugin;\n negate: boolean;\n compareValue: any;\n transformValue: <I = any, O = any>(value: I) => O;\n}\n\nexport interface CmsEntryFieldFilterPluginCreateResponse {\n field: Field;\n path: string;\n fieldPathId: string;\n plugin: ValueFilterPlugin;\n negate: boolean;\n compareValue: any;\n transformValue: <I = any, O = any>(value: I) => O;\n}\n\nexport class CmsEntryFieldFilterPlugin extends Plugin {\n public static override readonly type: string = \"cms.dynamodb.entry.field.filter\";\n public static readonly ALL: string = \"*\";\n\n private readonly config: CmsEntryFieldFilterPluginParams;\n\n public readonly fieldType: string;\n\n public constructor(config: CmsEntryFieldFilterPluginParams) {\n super();\n this.config = config;\n this.fieldType = this.config.fieldType;\n }\n\n public create(params: CmsEntryFieldFilterPluginCreateParams) {\n return this.config.create(params);\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA;;AAyCO,MAAMA,yBAAN,SAAwCC,eAAxC,CAA+C;EAQ3CC,WAAW,CAACC,MAAD,EAA0C;IACxD;IADwD;IAAA;IAExD,KAAKA,MAAL,GAAcA,MAAd;IACA,KAAKC,SAAL,GAAiB,KAAKD,MAAL,CAAYC,SAA7B;EACH;;EAEMC,MAAM,CAACC,MAAD,EAAgD;IACzD,OAAO,KAAKH,MAAL,CAAYE,MAAZ,CAAmBC,MAAnB,CAAP;EACH;;AAhBiD;;;8BAAzCN,yB,UACsC,iC;8BADtCA,yB,SAE4B,G"}
@@ -0,0 +1,42 @@
1
+ import { Plugin } from "@webiny/plugins";
2
+ import { Field } from "../operations/entry/filtering/types";
3
+ import { CmsModel } from "@webiny/api-headless-cms/types";
4
+ interface CmsEntryFieldSortingPluginCanUseParams {
5
+ model: CmsModel;
6
+ field?: Field;
7
+ fieldId: string;
8
+ order: "ASC" | "DESC";
9
+ /**
10
+ * Combination of fieldId and sortBy
11
+ *
12
+ * example: id_ASC or createdBy_DESC
13
+ */
14
+ sortBy: string;
15
+ }
16
+ interface CmsEntryFieldSortingPluginCreateSortParams {
17
+ model: CmsModel;
18
+ fieldId: string;
19
+ order: "ASC" | "DESC";
20
+ sortBy: string;
21
+ fields: Record<string, Field>;
22
+ field?: Field;
23
+ }
24
+ interface CmsEntryFieldSortingPluginCreateSortResult {
25
+ valuePath: string;
26
+ reverse: boolean;
27
+ fieldId: string;
28
+ field: Field;
29
+ }
30
+ interface CmsEntryFieldSortingPluginConfig {
31
+ createSort: (params: CmsEntryFieldSortingPluginCreateSortParams) => CmsEntryFieldSortingPluginCreateSortResult;
32
+ canUse: (params: CmsEntryFieldSortingPluginCanUseParams) => boolean;
33
+ }
34
+ export declare class CmsEntryFieldSortingPlugin extends Plugin {
35
+ static readonly type: string;
36
+ private readonly config;
37
+ constructor(config: CmsEntryFieldSortingPluginConfig);
38
+ canUse(params: CmsEntryFieldSortingPluginCanUseParams): boolean;
39
+ createSort(params: CmsEntryFieldSortingPluginCreateSortParams): CmsEntryFieldSortingPluginCreateSortResult;
40
+ }
41
+ export declare const createCmsEntryFieldSortingPlugin: (config: CmsEntryFieldSortingPluginConfig) => CmsEntryFieldSortingPlugin;
42
+ export {};
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.createCmsEntryFieldSortingPlugin = exports.CmsEntryFieldSortingPlugin = void 0;
9
+
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+
12
+ var _plugins = require("@webiny/plugins");
13
+
14
+ class CmsEntryFieldSortingPlugin extends _plugins.Plugin {
15
+ constructor(config) {
16
+ super();
17
+ (0, _defineProperty2.default)(this, "config", void 0);
18
+ this.config = config;
19
+ }
20
+
21
+ canUse(params) {
22
+ return this.config.canUse(params);
23
+ }
24
+
25
+ createSort(params) {
26
+ return this.config.createSort(params);
27
+ }
28
+
29
+ }
30
+
31
+ exports.CmsEntryFieldSortingPlugin = CmsEntryFieldSortingPlugin;
32
+ (0, _defineProperty2.default)(CmsEntryFieldSortingPlugin, "type", "cms.entry.field.sorting");
33
+
34
+ const createCmsEntryFieldSortingPlugin = config => {
35
+ return new CmsEntryFieldSortingPlugin(config);
36
+ };
37
+
38
+ exports.createCmsEntryFieldSortingPlugin = createCmsEntryFieldSortingPlugin;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["CmsEntryFieldSortingPlugin","Plugin","constructor","config","canUse","params","createSort","createCmsEntryFieldSortingPlugin"],"sources":["CmsEntryFieldSortingPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { Field } from \"~/operations/entry/filtering/types\";\nimport { CmsModel } from \"@webiny/api-headless-cms/types\";\n\ninterface CmsEntryFieldSortingPluginCanUseParams {\n model: CmsModel;\n field?: Field;\n fieldId: string;\n order: \"ASC\" | \"DESC\";\n /**\n * Combination of fieldId and sortBy\n *\n * example: id_ASC or createdBy_DESC\n */\n sortBy: string;\n}\n\ninterface CmsEntryFieldSortingPluginCreateSortParams {\n model: CmsModel;\n fieldId: string;\n order: \"ASC\" | \"DESC\";\n sortBy: string;\n fields: Record<string, Field>;\n field?: Field;\n}\n\ninterface CmsEntryFieldSortingPluginCreateSortResult {\n valuePath: string;\n reverse: boolean;\n fieldId: string;\n field: Field;\n}\n\ninterface CmsEntryFieldSortingPluginConfig {\n createSort: (\n params: CmsEntryFieldSortingPluginCreateSortParams\n ) => CmsEntryFieldSortingPluginCreateSortResult;\n canUse: (params: CmsEntryFieldSortingPluginCanUseParams) => boolean;\n}\n\nexport class CmsEntryFieldSortingPlugin extends Plugin {\n public static override readonly type: string = \"cms.entry.field.sorting\";\n private readonly config: CmsEntryFieldSortingPluginConfig;\n\n public constructor(config: CmsEntryFieldSortingPluginConfig) {\n super();\n this.config = config;\n }\n\n public canUse(params: CmsEntryFieldSortingPluginCanUseParams): boolean {\n return this.config.canUse(params);\n }\n\n public createSort(\n params: CmsEntryFieldSortingPluginCreateSortParams\n ): CmsEntryFieldSortingPluginCreateSortResult {\n return this.config.createSort(params);\n }\n}\n\nexport const createCmsEntryFieldSortingPlugin = (config: CmsEntryFieldSortingPluginConfig) => {\n return new CmsEntryFieldSortingPlugin(config);\n};\n"],"mappings":";;;;;;;;;;;AAAA;;AAwCO,MAAMA,0BAAN,SAAyCC,eAAzC,CAAgD;EAI5CC,WAAW,CAACC,MAAD,EAA2C;IACzD;IADyD;IAEzD,KAAKA,MAAL,GAAcA,MAAd;EACH;;EAEMC,MAAM,CAACC,MAAD,EAA0D;IACnE,OAAO,KAAKF,MAAL,CAAYC,MAAZ,CAAmBC,MAAnB,CAAP;EACH;;EAEMC,UAAU,CACbD,MADa,EAE6B;IAC1C,OAAO,KAAKF,MAAL,CAAYG,UAAZ,CAAuBD,MAAvB,CAAP;EACH;;AAjBkD;;;8BAA1CL,0B,UACsC,yB;;AAmB5C,MAAMO,gCAAgC,GAAIJ,MAAD,IAA8C;EAC1F,OAAO,IAAIH,0BAAJ,CAA+BG,MAA/B,CAAP;AACH,CAFM"}
@@ -0,0 +1,3 @@
1
+ export * from "./CmsEntryFieldFilterPathPlugin";
2
+ export * from "./CmsEntryFieldSortingPlugin";
3
+ export * from "./CmsEntryFieldFilterPlugin";
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ var _CmsEntryFieldFilterPathPlugin = require("./CmsEntryFieldFilterPathPlugin");
8
+
9
+ Object.keys(_CmsEntryFieldFilterPathPlugin).forEach(function (key) {
10
+ if (key === "default" || key === "__esModule") return;
11
+ if (key in exports && exports[key] === _CmsEntryFieldFilterPathPlugin[key]) return;
12
+ Object.defineProperty(exports, key, {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _CmsEntryFieldFilterPathPlugin[key];
16
+ }
17
+ });
18
+ });
19
+
20
+ var _CmsEntryFieldSortingPlugin = require("./CmsEntryFieldSortingPlugin");
21
+
22
+ Object.keys(_CmsEntryFieldSortingPlugin).forEach(function (key) {
23
+ if (key === "default" || key === "__esModule") return;
24
+ if (key in exports && exports[key] === _CmsEntryFieldSortingPlugin[key]) return;
25
+ Object.defineProperty(exports, key, {
26
+ enumerable: true,
27
+ get: function () {
28
+ return _CmsEntryFieldSortingPlugin[key];
29
+ }
30
+ });
31
+ });
32
+
33
+ var _CmsEntryFieldFilterPlugin = require("./CmsEntryFieldFilterPlugin");
34
+
35
+ Object.keys(_CmsEntryFieldFilterPlugin).forEach(function (key) {
36
+ if (key === "default" || key === "__esModule") return;
37
+ if (key in exports && exports[key] === _CmsEntryFieldFilterPlugin[key]) return;
38
+ Object.defineProperty(exports, key, {
39
+ enumerable: true,
40
+ get: function () {
41
+ return _CmsEntryFieldFilterPlugin[key];
42
+ }
43
+ });
44
+ });
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./CmsEntryFieldFilterPathPlugin\";\nexport * from \"./CmsEntryFieldSortingPlugin\";\nexport * from \"./CmsEntryFieldFilterPlugin\";\n"],"mappings":";;;;;;AAAA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
package/types.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Plugin } from "@webiny/plugins/types";
2
- import { CmsModelField, CmsModelFieldToGraphQLPlugin, HeadlessCmsStorageOperations as BaseHeadlessCmsStorageOperations } from "@webiny/api-headless-cms/types";
2
+ import { CmsModelField, HeadlessCmsStorageOperations as BaseHeadlessCmsStorageOperations } from "@webiny/api-headless-cms/types";
3
3
  import { DynamoDBTypes, TableConstructor } from "dynamodb-toolbox/dist/classes/Table";
4
4
  import { EntityAttributeConfig, EntityCompositeAttributes } from "dynamodb-toolbox/dist/classes/Entity";
5
5
  import { DocumentClient } from "aws-sdk/clients/dynamodb";
@@ -8,7 +8,7 @@ interface CmsFieldFilterValueTransformParams {
8
8
  /**
9
9
  * A field which value we are transforming.
10
10
  */
11
- field: CmsModelField;
11
+ field: Partial<CmsModelField> & Pick<CmsModelField, "id" | "storageId" | "fieldId" | "settings">;
12
12
  value: any;
13
13
  }
14
14
  export interface CmsFieldFilterValueTransformPlugin extends Plugin {
@@ -25,36 +25,6 @@ export interface CmsFieldFilterValueTransformPlugin extends Plugin {
25
25
  */
26
26
  transform: (params: CmsFieldFilterValueTransformParams) => any;
27
27
  }
28
- interface CmsFieldFilterPathParams {
29
- /**
30
- * A field for which we are creating the value path.
31
- */
32
- field: CmsModelField;
33
- /**
34
- * If value is an array we will need index position.
35
- * It is up to the developer to add.
36
- */
37
- index?: number | string;
38
- }
39
- export interface CmsFieldFilterPathPlugin extends Plugin {
40
- /**
41
- * A plugin type.
42
- */
43
- type: "cms-field-filter-path";
44
- /**
45
- * A field type this plugin is for.
46
- */
47
- fieldType: string;
48
- /**
49
- * A field id this plugin is for.
50
- * It is meant for targeting only specific fields in a certain type.
51
- */
52
- fieldId?: string[];
53
- /**
54
- * Get a path for given field.
55
- */
56
- createPath: (params: CmsFieldFilterPathParams) => string;
57
- }
58
28
  export declare type AttributeDefinition = DynamoDBTypes | EntityAttributeConfig | EntityCompositeAttributes;
59
29
  export declare type Attributes = Record<string, AttributeDefinition>;
60
30
  export declare enum ENTITIES {
@@ -70,7 +40,6 @@ export interface TableModifier {
70
40
  export interface StorageOperationsFactoryParams {
71
41
  documentClient: DocumentClient;
72
42
  table?: TableModifier;
73
- modelFieldToGraphQLPlugins: CmsModelFieldToGraphQLPlugin[];
74
43
  attributes?: Record<ENTITIES, Attributes>;
75
44
  plugins?: Plugin[] | Plugin[][];
76
45
  }
package/types.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ENTITIES"],"sources":["types.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins/types\";\nimport {\n CmsModelField,\n HeadlessCmsStorageOperations as BaseHeadlessCmsStorageOperations\n} from \"@webiny/api-headless-cms/types\";\nimport { DynamoDBTypes, TableConstructor } from \"dynamodb-toolbox/dist/classes/Table\";\nimport {\n EntityAttributeConfig,\n EntityCompositeAttributes\n} from \"dynamodb-toolbox/dist/classes/Entity\";\nimport { DocumentClient } from \"aws-sdk/clients/dynamodb\";\nimport { Entity, Table } from \"dynamodb-toolbox\";\n\ninterface CmsFieldFilterValueTransformParams {\n /**\n * A field which value we are transforming.\n */\n field: Partial<CmsModelField> &\n Pick<CmsModelField, \"id\" | \"storageId\" | \"fieldId\" | \"settings\">;\n value: any;\n}\n\nexport interface CmsFieldFilterValueTransformPlugin extends Plugin {\n /**\n * A plugin type.\n */\n type: \"cms-field-filter-value-transform\";\n /**\n * A field type this plugin is for.\n */\n fieldType: string;\n /**\n * Transform method which expect field definition and value to transform.\n */\n transform: (params: CmsFieldFilterValueTransformParams) => any;\n}\n\nexport type AttributeDefinition = DynamoDBTypes | EntityAttributeConfig | EntityCompositeAttributes;\n\nexport type Attributes = Record<string, AttributeDefinition>;\n\nexport enum ENTITIES {\n SYSTEM = \"CmsSystem\",\n SETTINGS = \"CmsSettings\",\n GROUPS = \"CmsGroups\",\n MODELS = \"CmsModels\",\n ENTRIES = \"CmsEntries\"\n}\n\nexport interface TableModifier {\n (table: TableConstructor): TableConstructor;\n}\n\nexport interface StorageOperationsFactoryParams {\n documentClient: DocumentClient;\n table?: TableModifier;\n attributes?: Record<ENTITIES, Attributes>;\n plugins?: Plugin[] | Plugin[][];\n}\n\nexport interface HeadlessCmsStorageOperations extends BaseHeadlessCmsStorageOperations {\n getTable: () => Table;\n getEntities: () => Record<\"system\" | \"settings\" | \"groups\" | \"models\" | \"entries\", Entity<any>>;\n}\n\nexport interface StorageOperationsFactory {\n (params: StorageOperationsFactoryParams): HeadlessCmsStorageOperations;\n}\n"],"mappings":";;;;;;IAyCYA,Q;;;WAAAA,Q;EAAAA,Q;EAAAA,Q;EAAAA,Q;EAAAA,Q;EAAAA,Q;GAAAA,Q,wBAAAA,Q"}
@@ -1,3 +0,0 @@
1
- import { CmsFieldFilterPathPlugin } from "../../types";
2
- declare const _default: () => CmsFieldFilterPathPlugin;
3
- export default _default;
@@ -1,27 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _default = () => ({
9
- type: "cms-field-filter-path",
10
- name: "cms-field-filter-path-ref",
11
- fieldType: "ref",
12
- createPath: ({
13
- field,
14
- index
15
- }) => {
16
- const paths = [field.fieldId];
17
-
18
- if (index !== undefined) {
19
- paths.push(String(index));
20
- }
21
-
22
- paths.push("entryId");
23
- return paths.join(".");
24
- }
25
- });
26
-
27
- exports.default = _default;
@@ -1,31 +0,0 @@
1
- import { CmsEntry, CmsEntryListWhere, CmsModel, CmsModelField } from "@webiny/api-headless-cms/types";
2
- import { PluginsContainer } from "@webiny/plugins";
3
- interface ModelField {
4
- def: CmsModelField;
5
- valueTransformer: (value: any) => any;
6
- valuePath: string;
7
- isSystemField?: boolean;
8
- }
9
- declare type ModelFieldRecords = Record<string, ModelField>;
10
- export interface FilterItemFromStorage {
11
- (field: CmsModelField, value: any): Promise<any>;
12
- }
13
- interface FilterItemsParams {
14
- items: CmsEntry[];
15
- where: CmsEntryListWhere;
16
- plugins: PluginsContainer;
17
- fields: ModelFieldRecords;
18
- fromStorage: FilterItemFromStorage;
19
- }
20
- export declare const filterItems: (params: FilterItemsParams) => Promise<CmsEntry[]>;
21
- interface SortEntryItemsArgs {
22
- items: CmsEntry[];
23
- sort: string[];
24
- fields: ModelFieldRecords;
25
- }
26
- export declare const sortEntryItems: (params: SortEntryItemsArgs) => CmsEntry[];
27
- export declare const buildModelFields: ({ plugins, model }: {
28
- plugins: PluginsContainer;
29
- model: CmsModel;
30
- }) => Record<string, ModelField>;
31
- export {};