@webiny/api-headless-cms-ddb 5.15.0-beta.0

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 (81) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +25 -0
  3. package/configurations.d.ts +18 -0
  4. package/configurations.js +24 -0
  5. package/configurations.js.map +1 -0
  6. package/definitions/entry.d.ts +6 -0
  7. package/definitions/entry.js +86 -0
  8. package/definitions/entry.js.map +1 -0
  9. package/definitions/table.d.ts +14 -0
  10. package/definitions/table.js +30 -0
  11. package/definitions/table.js.map +1 -0
  12. package/dynamoDb/index.d.ts +2 -0
  13. package/dynamoDb/index.js +23 -0
  14. package/dynamoDb/index.js.map +1 -0
  15. package/dynamoDb/path/plainObject.d.ts +3 -0
  16. package/dynamoDb/path/plainObject.js +34 -0
  17. package/dynamoDb/path/plainObject.js.map +1 -0
  18. package/dynamoDb/path/ref.d.ts +3 -0
  19. package/dynamoDb/path/ref.js +28 -0
  20. package/dynamoDb/path/ref.js.map +1 -0
  21. package/dynamoDb/storage/date.d.ts +3 -0
  22. package/dynamoDb/storage/date.js +69 -0
  23. package/dynamoDb/storage/date.js.map +1 -0
  24. package/dynamoDb/storage/richText.d.ts +8 -0
  25. package/dynamoDb/storage/richText.js +108 -0
  26. package/dynamoDb/storage/richText.js.map +1 -0
  27. package/dynamoDb/transformValue/datetime.d.ts +3 -0
  28. package/dynamoDb/transformValue/datetime.js +48 -0
  29. package/dynamoDb/transformValue/datetime.js.map +1 -0
  30. package/index.d.ts +6 -0
  31. package/index.js +30 -0
  32. package/index.js.map +1 -0
  33. package/operations/entry/CmsContentEntryDynamo.d.ts +86 -0
  34. package/operations/entry/CmsContentEntryDynamo.js +972 -0
  35. package/operations/entry/CmsContentEntryDynamo.js.map +1 -0
  36. package/operations/entry/dataLoaders.d.ts +23 -0
  37. package/operations/entry/dataLoaders.js +283 -0
  38. package/operations/entry/dataLoaders.js.map +1 -0
  39. package/operations/entry/index.d.ts +4 -0
  40. package/operations/entry/index.js +25 -0
  41. package/operations/entry/index.js.map +1 -0
  42. package/operations/entry/systemFields.d.ts +2 -0
  43. package/operations/entry/systemFields.js +51 -0
  44. package/operations/entry/systemFields.js.map +1 -0
  45. package/operations/entry/utils.d.ts +26 -0
  46. package/operations/entry/utils.js +362 -0
  47. package/operations/entry/utils.js.map +1 -0
  48. package/operations/helpers.d.ts +5 -0
  49. package/operations/helpers.js +96 -0
  50. package/operations/helpers.js.map +1 -0
  51. package/operations/model/CmsContentModelDynamo.d.ts +18 -0
  52. package/operations/model/CmsContentModelDynamo.js +234 -0
  53. package/operations/model/CmsContentModelDynamo.js.map +1 -0
  54. package/operations/model/index.d.ts +3 -0
  55. package/operations/model/index.js +26 -0
  56. package/operations/model/index.js.map +1 -0
  57. package/operations/modelGroup/CmsContentModelGroupDynamo.d.ts +42 -0
  58. package/operations/modelGroup/CmsContentModelGroupDynamo.js +230 -0
  59. package/operations/modelGroup/CmsContentModelGroupDynamo.js.map +1 -0
  60. package/operations/modelGroup/index.d.ts +3 -0
  61. package/operations/modelGroup/index.js +26 -0
  62. package/operations/modelGroup/index.js.map +1 -0
  63. package/operations/settings/CmsSettingsDynamo.d.ts +16 -0
  64. package/operations/settings/CmsSettingsDynamo.js +145 -0
  65. package/operations/settings/CmsSettingsDynamo.js.map +1 -0
  66. package/operations/settings/index.d.ts +3 -0
  67. package/operations/settings/index.js +25 -0
  68. package/operations/settings/index.js.map +1 -0
  69. package/operations/system/CmsSystemDynamo.d.ts +16 -0
  70. package/operations/system/CmsSystemDynamo.js +126 -0
  71. package/operations/system/CmsSystemDynamo.js.map +1 -0
  72. package/operations/system/index.d.ts +3 -0
  73. package/operations/system/index.js +25 -0
  74. package/operations/system/index.js.map +1 -0
  75. package/package.json +61 -0
  76. package/types.d.ts +54 -0
  77. package/types.js +6 -0
  78. package/types.js.map +1 -0
  79. package/utils.d.ts +5 -0
  80. package/utils.js +62 -0
  81. package/utils.js.map +1 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Webiny
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,25 @@
1
+ # @webiny/api-headless-cms-ddb
2
+
3
+ [![](https://img.shields.io/npm/dw/@webiny/api-headless-cms-ddb.svg)](https://www.npmjs.com/package/@webiny/api-headless-cms-ddb)
4
+ [![](https://img.shields.io/npm/v/@webiny/api-headless-cms-ddb.svg)](https://www.npmjs.com/package/@webiny/api-headless-cms-ddb)
5
+ [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
6
+ [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
7
+
8
+ ## Install
9
+
10
+ ```
11
+ npm install --save @webiny/api-headless-cms-ddb
12
+ ```
13
+
14
+ Or if you prefer yarn:
15
+
16
+ ```
17
+ yarn add @webiny/api-headless-cms-ddb
18
+ ```
19
+
20
+ ## Testing
21
+ To run the tests only for this package you must filter it with keywords.
22
+ ### Command
23
+ ````
24
+ yarn test packages/api-headless-cms --keyword=cms:ddb --keyword=cms:base
25
+ ````
@@ -0,0 +1,18 @@
1
+ interface DatabaseConfigKeyFields {
2
+ name: string;
3
+ }
4
+ interface DatabaseConfigKeys {
5
+ primary: boolean;
6
+ unique: boolean;
7
+ name: string;
8
+ fields: DatabaseConfigKeyFields[];
9
+ }
10
+ export interface CmsDatabaseConfig {
11
+ table: string;
12
+ keys: DatabaseConfigKeys[];
13
+ }
14
+ interface Configurations {
15
+ db: () => CmsDatabaseConfig;
16
+ }
17
+ declare const configurations: Configurations;
18
+ export default configurations;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ const configurations = {
8
+ db: () => ({
9
+ table: process.env.DB_TABLE_HEADLESS_CMS,
10
+ keys: [{
11
+ primary: true,
12
+ unique: true,
13
+ name: "primary",
14
+ fields: [{
15
+ name: "PK"
16
+ }, {
17
+ name: "SK"
18
+ }]
19
+ }]
20
+ })
21
+ };
22
+ var _default = configurations;
23
+ exports.default = _default;
24
+ //# sourceMappingURL=configurations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/configurations.ts"],"names":["configurations","db","table","process","env","DB_TABLE_HEADLESS_CMS","keys","primary","unique","name","fields"],"mappings":";;;;;;AAoBA,MAAMA,cAA8B,GAAG;AACnCC,EAAAA,EAAE,EAAE,OAAO;AACPC,IAAAA,KAAK,EAAEC,OAAO,CAACC,GAAR,CAAYC,qBADZ;AAEPC,IAAAA,IAAI,EAAE,CACF;AACIC,MAAAA,OAAO,EAAE,IADb;AAEIC,MAAAA,MAAM,EAAE,IAFZ;AAGIC,MAAAA,IAAI,EAAE,SAHV;AAIIC,MAAAA,MAAM,EAAE,CAAC;AAAED,QAAAA,IAAI,EAAE;AAAR,OAAD,EAAiB;AAAEA,QAAAA,IAAI,EAAE;AAAR,OAAjB;AAJZ,KADE;AAFC,GAAP;AAD+B,CAAvC;eAceT,c","sourcesContent":["interface DatabaseConfigKeyFields {\n name: string;\n}\n\ninterface DatabaseConfigKeys {\n primary: boolean;\n unique: boolean;\n name: string;\n fields: DatabaseConfigKeyFields[];\n}\n\nexport interface CmsDatabaseConfig {\n table: string;\n keys: DatabaseConfigKeys[];\n}\n\ninterface Configurations {\n db: () => CmsDatabaseConfig;\n}\n\nconst configurations: Configurations = {\n db: () => ({\n table: process.env.DB_TABLE_HEADLESS_CMS,\n keys: [\n {\n primary: true,\n unique: true,\n name: \"primary\",\n fields: [{ name: \"PK\" }, { name: \"SK\" }]\n }\n ]\n })\n};\n\nexport default configurations;\n"],"file":"configurations.js"}
@@ -0,0 +1,6 @@
1
+ import { Table, Entity } from "dynamodb-toolbox";
2
+ interface Params {
3
+ table: Table;
4
+ }
5
+ export declare const createEntryEntity: ({ table }: Params) => Entity<{}>;
6
+ export {};
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createEntryEntity = void 0;
7
+
8
+ var _dynamodbToolbox = require("dynamodb-toolbox");
9
+
10
+ const entityName = "ContentEntry";
11
+
12
+ const createEntryEntity = ({
13
+ table
14
+ }) => {
15
+ return new _dynamodbToolbox.Entity({
16
+ name: entityName,
17
+ table,
18
+ attributes: {
19
+ PK: {
20
+ type: "string",
21
+ partitionKey: true
22
+ },
23
+ SK: {
24
+ type: "string",
25
+ sortKey: true
26
+ },
27
+ GSI1_PK: {
28
+ type: "string"
29
+ },
30
+ GSI1_SK: {
31
+ type: "string"
32
+ },
33
+ TYPE: {
34
+ type: "string"
35
+ },
36
+ webinyVersion: {
37
+ type: "string"
38
+ },
39
+ tenant: {
40
+ type: "string"
41
+ },
42
+ entryId: {
43
+ type: "string"
44
+ },
45
+ id: {
46
+ type: "string"
47
+ },
48
+ createdBy: {
49
+ type: "map"
50
+ },
51
+ ownedBy: {
52
+ type: "map"
53
+ },
54
+ createdOn: {
55
+ type: "string"
56
+ },
57
+ savedOn: {
58
+ type: "string"
59
+ },
60
+ modelId: {
61
+ type: "string"
62
+ },
63
+ locale: {
64
+ type: "string"
65
+ },
66
+ publishedOn: {
67
+ type: "string"
68
+ },
69
+ version: {
70
+ type: "number"
71
+ },
72
+ locked: {
73
+ type: "boolean"
74
+ },
75
+ status: {
76
+ type: "string"
77
+ },
78
+ values: {
79
+ type: "map"
80
+ }
81
+ }
82
+ });
83
+ };
84
+
85
+ exports.createEntryEntity = createEntryEntity;
86
+ //# sourceMappingURL=entry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/definitions/entry.ts"],"names":["entityName","createEntryEntity","table","Entity","name","attributes","PK","type","partitionKey","SK","sortKey","GSI1_PK","GSI1_SK","TYPE","webinyVersion","tenant","entryId","id","createdBy","ownedBy","createdOn","savedOn","modelId","locale","publishedOn","version","locked","status","values"],"mappings":";;;;;;;AAAA;;AAMA,MAAMA,UAAU,GAAG,cAAnB;;AAEO,MAAMC,iBAAiB,GAAG,CAAC;AAAEC,EAAAA;AAAF,CAAD,KAAuB;AACpD,SAAO,IAAIC,uBAAJ,CAAW;AACdC,IAAAA,IAAI,EAAEJ,UADQ;AAEdE,IAAAA,KAFc;AAGdG,IAAAA,UAAU,EAAE;AACRC,MAAAA,EAAE,EAAE;AACAC,QAAAA,IAAI,EAAE,QADN;AAEAC,QAAAA,YAAY,EAAE;AAFd,OADI;AAKRC,MAAAA,EAAE,EAAE;AACAF,QAAAA,IAAI,EAAE,QADN;AAEAG,QAAAA,OAAO,EAAE;AAFT,OALI;AASRC,MAAAA,OAAO,EAAE;AACLJ,QAAAA,IAAI,EAAE;AADD,OATD;AAYRK,MAAAA,OAAO,EAAE;AACLL,QAAAA,IAAI,EAAE;AADD,OAZD;AAeRM,MAAAA,IAAI,EAAE;AACFN,QAAAA,IAAI,EAAE;AADJ,OAfE;AAkBRO,MAAAA,aAAa,EAAE;AACXP,QAAAA,IAAI,EAAE;AADK,OAlBP;AAqBRQ,MAAAA,MAAM,EAAE;AACJR,QAAAA,IAAI,EAAE;AADF,OArBA;AAwBRS,MAAAA,OAAO,EAAE;AACLT,QAAAA,IAAI,EAAE;AADD,OAxBD;AA2BRU,MAAAA,EAAE,EAAE;AACAV,QAAAA,IAAI,EAAE;AADN,OA3BI;AA8BRW,MAAAA,SAAS,EAAE;AACPX,QAAAA,IAAI,EAAE;AADC,OA9BH;AAiCRY,MAAAA,OAAO,EAAE;AACLZ,QAAAA,IAAI,EAAE;AADD,OAjCD;AAoCRa,MAAAA,SAAS,EAAE;AACPb,QAAAA,IAAI,EAAE;AADC,OApCH;AAuCRc,MAAAA,OAAO,EAAE;AACLd,QAAAA,IAAI,EAAE;AADD,OAvCD;AA0CRe,MAAAA,OAAO,EAAE;AACLf,QAAAA,IAAI,EAAE;AADD,OA1CD;AA6CRgB,MAAAA,MAAM,EAAE;AACJhB,QAAAA,IAAI,EAAE;AADF,OA7CA;AAgDRiB,MAAAA,WAAW,EAAE;AACTjB,QAAAA,IAAI,EAAE;AADG,OAhDL;AAmDRkB,MAAAA,OAAO,EAAE;AACLlB,QAAAA,IAAI,EAAE;AADD,OAnDD;AAsDRmB,MAAAA,MAAM,EAAE;AACJnB,QAAAA,IAAI,EAAE;AADF,OAtDA;AAyDRoB,MAAAA,MAAM,EAAE;AACJpB,QAAAA,IAAI,EAAE;AADF,OAzDA;AA4DRqB,MAAAA,MAAM,EAAE;AACJrB,QAAAA,IAAI,EAAE;AADF;AA5DA;AAHE,GAAX,CAAP;AAoEH,CArEM","sourcesContent":["import { Table, Entity } from \"dynamodb-toolbox\";\n\ninterface Params {\n table: Table;\n}\n\nconst entityName = \"ContentEntry\";\n\nexport const createEntryEntity = ({ table }: Params) => {\n return new Entity({\n name: entityName,\n table,\n attributes: {\n PK: {\n type: \"string\",\n partitionKey: true\n },\n SK: {\n type: \"string\",\n sortKey: true\n },\n GSI1_PK: {\n type: \"string\"\n },\n GSI1_SK: {\n type: \"string\"\n },\n TYPE: {\n type: \"string\"\n },\n webinyVersion: {\n type: \"string\"\n },\n tenant: {\n type: \"string\"\n },\n entryId: {\n type: \"string\"\n },\n id: {\n type: \"string\"\n },\n createdBy: {\n type: \"map\"\n },\n ownedBy: {\n type: \"map\"\n },\n createdOn: {\n type: \"string\"\n },\n savedOn: {\n type: \"string\"\n },\n modelId: {\n type: \"string\"\n },\n locale: {\n type: \"string\"\n },\n publishedOn: {\n type: \"string\"\n },\n version: {\n type: \"number\"\n },\n locked: {\n type: \"boolean\"\n },\n status: {\n type: \"string\"\n },\n values: {\n type: \"map\"\n }\n }\n });\n};\n"],"file":"entry.js"}
@@ -0,0 +1,14 @@
1
+ import { CmsContext } from "@webiny/api-headless-cms/types";
2
+ import { Table } from "dynamodb-toolbox";
3
+ interface IndexParams {
4
+ partitionKey: string;
5
+ sortKey: string;
6
+ }
7
+ interface Params {
8
+ context: CmsContext;
9
+ indexes: {
10
+ [key: string]: IndexParams;
11
+ };
12
+ }
13
+ export declare const createTable: ({ context, indexes }: Params) => Table;
14
+ export {};
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.createTable = void 0;
9
+
10
+ var _dynamodbToolbox = require("dynamodb-toolbox");
11
+
12
+ var _configurations = _interopRequireDefault(require("../configurations"));
13
+
14
+ var _helpers = require("../operations/helpers");
15
+
16
+ const createTable = ({
17
+ context,
18
+ indexes
19
+ }) => {
20
+ return new _dynamodbToolbox.Table({
21
+ name: _configurations.default.db().table || (0, _helpers.getTable)(context),
22
+ partitionKey: "PK",
23
+ sortKey: "SK",
24
+ DocumentClient: (0, _helpers.getDocumentClient)(context),
25
+ indexes
26
+ });
27
+ };
28
+
29
+ exports.createTable = createTable;
30
+ //# sourceMappingURL=table.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/definitions/table.ts"],"names":["createTable","context","indexes","Table","name","configurations","db","table","partitionKey","sortKey","DocumentClient"],"mappings":";;;;;;;;;AACA;;AACA;;AACA;;AAcO,MAAMA,WAAW,GAAG,CAAC;AAAEC,EAAAA,OAAF;AAAWC,EAAAA;AAAX,CAAD,KAAkC;AACzD,SAAO,IAAIC,sBAAJ,CAAU;AACbC,IAAAA,IAAI,EAAEC,wBAAeC,EAAf,GAAoBC,KAApB,IAA6B,uBAASN,OAAT,CADtB;AAEbO,IAAAA,YAAY,EAAE,IAFD;AAGbC,IAAAA,OAAO,EAAE,IAHI;AAIbC,IAAAA,cAAc,EAAE,gCAAkBT,OAAlB,CAJH;AAKbC,IAAAA;AALa,GAAV,CAAP;AAOH,CARM","sourcesContent":["import { CmsContext } from \"@webiny/api-headless-cms/types\";\nimport { Table } from \"dynamodb-toolbox\";\nimport configurations from \"~/configurations\";\nimport { getDocumentClient, getTable } from \"~/operations/helpers\";\n\ninterface IndexParams {\n partitionKey: string;\n sortKey: string;\n}\n\ninterface Params {\n context: CmsContext;\n indexes: {\n [key: string]: IndexParams;\n };\n}\n\nexport const createTable = ({ context, indexes }: Params) => {\n return new Table({\n name: configurations.db().table || getTable(context),\n partitionKey: \"PK\",\n sortKey: \"SK\",\n DocumentClient: getDocumentClient(context),\n indexes\n });\n};\n"],"file":"table.js"}
@@ -0,0 +1,2 @@
1
+ declare const _default: () => (import("../types").CmsFieldFilterPathPlugin | import("@webiny/api-headless-cms/types").CmsModelFieldToStoragePlugin<import("./storage/richText").OriginalValue, import("./storage/richText").StorageValue> | import("@webiny/api-headless-cms/types").CmsModelFieldToStoragePlugin<string | Date, string> | import("../types").CmsFieldFilterValueTransformPlugin<string | number | Date, number>)[];
2
+ export default _default;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+
10
+ var _richText = _interopRequireDefault(require("./storage/richText"));
11
+
12
+ var _date = _interopRequireDefault(require("./storage/date"));
13
+
14
+ var _plainObject = _interopRequireDefault(require("./path/plainObject"));
15
+
16
+ var _ref = _interopRequireDefault(require("./path/ref"));
17
+
18
+ var _datetime = _interopRequireDefault(require("./transformValue/datetime"));
19
+
20
+ var _default = () => [(0, _richText.default)(), (0, _date.default)(), (0, _plainObject.default)(), (0, _ref.default)(), (0, _datetime.default)()];
21
+
22
+ exports.default = _default;
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/dynamoDb/index.ts"],"names":[],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;eAEe,MAAM,CACjB,wBADiB,EAEjB,oBAFiB,EAGjB,2BAHiB,EAIjB,mBAJiB,EAKjB,wBALiB,C","sourcesContent":["import richTextStorage from \"./storage/richText\";\nimport dateStorage from \"./storage/date\";\nimport plainObjectPath from \"./path/plainObject\";\nimport refPath from \"./path/ref\";\nimport datetimeTransformValue from \"./transformValue/datetime\";\n\nexport default () => [\n richTextStorage(),\n dateStorage(),\n plainObjectPath(),\n refPath(),\n datetimeTransformValue()\n];\n"],"file":"index.js"}
@@ -0,0 +1,3 @@
1
+ import { CmsFieldFilterPathPlugin } from "../../types";
2
+ declare const _default: () => CmsFieldFilterPathPlugin;
3
+ export default _default;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+
10
+ var _error = _interopRequireDefault(require("@webiny/error"));
11
+
12
+ var _default = () => ({
13
+ type: "cms-field-filter-path",
14
+ name: "cms-field-filter-path-plain-object",
15
+ fieldType: "plainObject",
16
+ createPath: ({
17
+ field
18
+ }) => {
19
+ const {
20
+ path
21
+ } = field.settings || {};
22
+
23
+ if (!path) {
24
+ throw new _error.default("Missing path settings value.", "FIELD_SETTINGS_ERROR", {
25
+ field
26
+ });
27
+ }
28
+
29
+ return path;
30
+ }
31
+ });
32
+
33
+ exports.default = _default;
34
+ //# sourceMappingURL=plainObject.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/dynamoDb/path/plainObject.ts"],"names":["type","name","fieldType","createPath","field","path","settings","WebinyError"],"mappings":";;;;;;;;;AACA;;eAEe,OAAiC;AAC5CA,EAAAA,IAAI,EAAE,uBADsC;AAE5CC,EAAAA,IAAI,EAAE,oCAFsC;AAG5CC,EAAAA,SAAS,EAAE,aAHiC;AAI5CC,EAAAA,UAAU,EAAE,CAAC;AAAEC,IAAAA;AAAF,GAAD,KAAe;AACvB,UAAM;AAAEC,MAAAA;AAAF,QAAWD,KAAK,CAACE,QAAN,IAAkB,EAAnC;;AACA,QAAI,CAACD,IAAL,EAAW;AACP,YAAM,IAAIE,cAAJ,CAAgB,8BAAhB,EAAgD,sBAAhD,EAAwE;AAC1EH,QAAAA;AAD0E,OAAxE,CAAN;AAGH;;AACD,WAAOC,IAAP;AACH;AAZ2C,CAAjC,C","sourcesContent":["import { CmsFieldFilterPathPlugin } from \"../../types\";\nimport WebinyError from \"@webiny/error\";\n\nexport default (): CmsFieldFilterPathPlugin => ({\n type: \"cms-field-filter-path\",\n name: \"cms-field-filter-path-plain-object\",\n fieldType: \"plainObject\",\n createPath: ({ field }) => {\n const { path } = field.settings || {};\n if (!path) {\n throw new WebinyError(\"Missing path settings value.\", \"FIELD_SETTINGS_ERROR\", {\n field\n });\n }\n return path;\n }\n});\n"],"file":"plainObject.js"}
@@ -0,0 +1,3 @@
1
+ import { CmsFieldFilterPathPlugin } from "../../types";
2
+ declare const _default: () => CmsFieldFilterPathPlugin;
3
+ export default _default;
@@ -0,0 +1,28 @@
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;
28
+ //# sourceMappingURL=ref.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/dynamoDb/path/ref.ts"],"names":["type","name","fieldType","createPath","field","index","paths","fieldId","undefined","push","String","join"],"mappings":";;;;;;;eAEe,OAAiC;AAC5CA,EAAAA,IAAI,EAAE,uBADsC;AAE5CC,EAAAA,IAAI,EAAE,2BAFsC;AAG5CC,EAAAA,SAAS,EAAE,KAHiC;AAI5CC,EAAAA,UAAU,EAAE,CAAC;AAAEC,IAAAA,KAAF;AAASC,IAAAA;AAAT,GAAD,KAAsB;AAC9B,UAAMC,KAAe,GAAG,CAACF,KAAK,CAACG,OAAP,CAAxB;;AACA,QAAIF,KAAK,KAAKG,SAAd,EAAyB;AACrBF,MAAAA,KAAK,CAACG,IAAN,CAAWC,MAAM,CAACL,KAAD,CAAjB;AACH;;AACDC,IAAAA,KAAK,CAACG,IAAN,CAAW,SAAX;AACA,WAAOH,KAAK,CAACK,IAAN,CAAW,GAAX,CAAP;AACH;AAX2C,CAAjC,C","sourcesContent":["import { CmsFieldFilterPathPlugin } from \"~/types\";\n\nexport default (): CmsFieldFilterPathPlugin => ({\n type: \"cms-field-filter-path\",\n name: \"cms-field-filter-path-ref\",\n fieldType: \"ref\",\n createPath: ({ field, index }) => {\n const paths: string[] = [field.fieldId];\n if (index !== undefined) {\n paths.push(String(index));\n }\n paths.push(\"entryId\");\n return paths.join(\".\");\n }\n});\n"],"file":"ref.js"}
@@ -0,0 +1,3 @@
1
+ import { CmsModelFieldToStoragePlugin } from "@webiny/api-headless-cms/types";
2
+ declare const _default: () => CmsModelFieldToStoragePlugin<Date | string, string>;
3
+ export default _default;
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+
10
+ var _error = _interopRequireDefault(require("@webiny/error"));
11
+
12
+ const excludeTypes = ["time", "dateTimeWithTimezone"];
13
+
14
+ var _default = () => ({
15
+ type: "cms-model-field-to-storage",
16
+ name: "cms-model-field-to-storage-datetime",
17
+ fieldType: "datetime",
18
+
19
+ async fromStorage({
20
+ field,
21
+ value
22
+ }) {
23
+ const {
24
+ type
25
+ } = field.settings;
26
+
27
+ if (!value || !type || excludeTypes.includes(type)) {
28
+ return value;
29
+ }
30
+
31
+ try {
32
+ return new Date(value);
33
+ } catch {
34
+ return value;
35
+ }
36
+ },
37
+
38
+ async toStorage({
39
+ value,
40
+ field
41
+ }) {
42
+ const {
43
+ type
44
+ } = field.settings;
45
+
46
+ if (!value || !type || excludeTypes.includes(type)) {
47
+ if (value && value.toISOString) {
48
+ return value.toISOString();
49
+ }
50
+
51
+ return value;
52
+ }
53
+
54
+ if (value.toISOString) {
55
+ return value.toISOString();
56
+ } else if (typeof value === "string") {
57
+ return value;
58
+ }
59
+
60
+ throw new _error.default("Error converting value to a storage type.", "TO_STORAGE_ERROR", {
61
+ value,
62
+ fieldId: field.fieldId
63
+ });
64
+ }
65
+
66
+ });
67
+
68
+ exports.default = _default;
69
+ //# sourceMappingURL=date.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/dynamoDb/storage/date.ts"],"names":["excludeTypes","type","name","fieldType","fromStorage","field","value","settings","includes","Date","toStorage","toISOString","WebinyError","fieldId"],"mappings":";;;;;;;;;AAAA;;AAMA,MAAMA,YAAY,GAAG,CAAC,MAAD,EAAS,sBAAT,CAArB;;eAEe,OAA4D;AACvEC,EAAAA,IAAI,EAAE,4BADiE;AAEvEC,EAAAA,IAAI,EAAE,qCAFiE;AAGvEC,EAAAA,SAAS,EAAE,UAH4D;;AAIvE,QAAMC,WAAN,CAAkB;AAAEC,IAAAA,KAAF;AAASC,IAAAA;AAAT,GAAlB,EAAoC;AAChC,UAAM;AAAEL,MAAAA;AAAF,QAAYI,KAAD,CAAwCE,QAAzD;;AACA,QAAI,CAACD,KAAD,IAAU,CAACL,IAAX,IAAmBD,YAAY,CAACQ,QAAb,CAAsBP,IAAtB,CAAvB,EAAoD;AAChD,aAAOK,KAAP;AACH;;AACD,QAAI;AACA,aAAO,IAAIG,IAAJ,CAASH,KAAT,CAAP;AACH,KAFD,CAEE,MAAM;AACJ,aAAOA,KAAP;AACH;AACJ,GAdsE;;AAevE,QAAMI,SAAN,CAAgB;AAAEJ,IAAAA,KAAF;AAASD,IAAAA;AAAT,GAAhB,EAAkC;AAC9B,UAAM;AAAEJ,MAAAA;AAAF,QAAYI,KAAD,CAAwCE,QAAzD;;AACA,QAAI,CAACD,KAAD,IAAU,CAACL,IAAX,IAAmBD,YAAY,CAACQ,QAAb,CAAsBP,IAAtB,CAAvB,EAAoD;AAChD,UAAIK,KAAK,IAAKA,KAAD,CAAgBK,WAA7B,EAA0C;AACtC,eAAQL,KAAD,CAAgBK,WAAhB,EAAP;AACH;;AACD,aAAOL,KAAP;AACH;;AACD,QAAKA,KAAD,CAAeK,WAAnB,EAAgC;AAC5B,aAAQL,KAAD,CAAgBK,WAAhB,EAAP;AACH,KAFD,MAEO,IAAI,OAAOL,KAAP,KAAiB,QAArB,EAA+B;AAClC,aAAOA,KAAP;AACH;;AACD,UAAM,IAAIM,cAAJ,CAAgB,2CAAhB,EAA6D,kBAA7D,EAAiF;AACnFN,MAAAA,KADmF;AAEnFO,MAAAA,OAAO,EAAER,KAAK,CAACQ;AAFoE,KAAjF,CAAN;AAIH;;AAhCsE,CAA5D,C","sourcesContent":["import WebinyError from \"@webiny/error\";\nimport {\n CmsContentModelDateTimeField,\n CmsModelFieldToStoragePlugin\n} from \"@webiny/api-headless-cms/types\";\n\nconst excludeTypes = [\"time\", \"dateTimeWithTimezone\"];\n\nexport default (): CmsModelFieldToStoragePlugin<Date | string, string> => ({\n type: \"cms-model-field-to-storage\",\n name: \"cms-model-field-to-storage-datetime\",\n fieldType: \"datetime\",\n async fromStorage({ field, value }) {\n const { type } = (field as CmsContentModelDateTimeField).settings;\n if (!value || !type || excludeTypes.includes(type)) {\n return value;\n }\n try {\n return new Date(value);\n } catch {\n return value;\n }\n },\n async toStorage({ value, field }) {\n const { type } = (field as CmsContentModelDateTimeField).settings;\n if (!value || !type || excludeTypes.includes(type)) {\n if (value && (value as Date).toISOString) {\n return (value as Date).toISOString();\n }\n return value as string;\n }\n if ((value as any).toISOString) {\n return (value as Date).toISOString();\n } else if (typeof value === \"string\") {\n return value as string;\n }\n throw new WebinyError(\"Error converting value to a storage type.\", \"TO_STORAGE_ERROR\", {\n value,\n fieldId: field.fieldId\n });\n }\n});\n"],"file":"date.js"}
@@ -0,0 +1,8 @@
1
+ import { CmsModelFieldToStoragePlugin } from "@webiny/api-headless-cms/types";
2
+ export declare type OriginalValue = Record<string, any> | any[];
3
+ export interface StorageValue {
4
+ compression: string;
5
+ value: any;
6
+ }
7
+ declare const _default: () => CmsModelFieldToStoragePlugin<OriginalValue, StorageValue>;
8
+ export default _default;