@webiny/api-headless-cms-ddb 0.0.0-mt-2 → 0.0.0-unstable.1e66d121db

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 (70) 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 +3 -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 +2 -3
  25. package/dynamoDb/storage/date.js +80 -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 +72 -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.js +21 -20
  37. package/index.js.map +1 -0
  38. package/operations/entry/dataLoaders.d.ts +12 -8
  39. package/operations/entry/dataLoaders.js +31 -13
  40. package/operations/entry/dataLoaders.js.map +1 -0
  41. package/operations/entry/index.d.ts +2 -2
  42. package/operations/entry/index.js +253 -219
  43. package/operations/entry/index.js.map +1 -0
  44. package/operations/entry/keys.js +11 -0
  45. package/operations/entry/keys.js.map +1 -0
  46. package/operations/entry/systemFields.js +24 -0
  47. package/operations/entry/systemFields.js.map +1 -0
  48. package/operations/entry/utils.d.ts +10 -5
  49. package/operations/entry/utils.js +370 -96
  50. package/operations/entry/utils.js.map +1 -0
  51. package/operations/group/index.d.ts +3 -2
  52. package/operations/group/index.js +7 -13
  53. package/operations/group/index.js.map +1 -0
  54. package/operations/model/index.d.ts +3 -2
  55. package/operations/model/index.js +15 -14
  56. package/operations/model/index.js.map +1 -0
  57. package/operations/settings/index.d.ts +3 -2
  58. package/operations/settings/index.js +7 -13
  59. package/operations/settings/index.js.map +1 -0
  60. package/operations/system/index.d.ts +3 -2
  61. package/operations/system/index.js +5 -11
  62. package/operations/system/index.js.map +1 -0
  63. package/package.json +23 -23
  64. package/plugins/CmsEntryFieldFilterPathPlugin.d.ts +22 -0
  65. package/plugins/CmsEntryFieldFilterPathPlugin.js +55 -0
  66. package/plugins/CmsEntryFieldFilterPathPlugin.js.map +1 -0
  67. package/types.d.ts +1 -32
  68. package/types.js.map +1 -0
  69. package/dynamoDb/path/ref.d.ts +0 -3
  70. package/dynamoDb/path/ref.js +0 -27
@@ -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: CmsModelField;\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: CmsModelField): 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,EAAgC;IACzC,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"}
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";
@@ -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: CmsModelField;\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":";;;;;;IAwCYA,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;