@webiny/api-headless-cms-ddb 0.0.0-unstable.b14eaecf38 → 0.0.0-unstable.b6d7105cee

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 (165) hide show
  1. package/README.md +6 -20
  2. package/definitions/entry.d.ts +4 -5
  3. package/definitions/entry.js +10 -93
  4. package/definitions/entry.js.map +1 -1
  5. package/definitions/group.d.ts +4 -5
  6. package/definitions/group.js +10 -64
  7. package/definitions/group.js.map +1 -1
  8. package/definitions/model.d.ts +4 -5
  9. package/definitions/model.js +10 -108
  10. package/definitions/model.js.map +1 -1
  11. package/definitions/table.d.ts +4 -6
  12. package/definitions/table.js +7 -26
  13. package/definitions/table.js.map +1 -1
  14. package/definitions/types.d.ts +65 -0
  15. package/definitions/types.js +0 -0
  16. package/dynamoDb/index.d.ts +1 -1
  17. package/dynamoDb/index.js +8 -12
  18. package/dynamoDb/index.js.map +1 -1
  19. package/index.d.ts +2 -3
  20. package/index.js +87 -128
  21. package/index.js.map +1 -1
  22. package/operations/entry/dataLoader/DataLoaderCache.d.ts +16 -0
  23. package/operations/entry/dataLoader/DataLoaderCache.js +27 -0
  24. package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -0
  25. package/operations/entry/dataLoader/constants.d.ts +1 -0
  26. package/operations/entry/dataLoader/constants.js +5 -0
  27. package/operations/entry/dataLoader/constants.js.map +1 -0
  28. package/operations/entry/dataLoader/createBatchScheduleFn.d.ts +8 -0
  29. package/operations/entry/dataLoader/createBatchScheduleFn.js +10 -0
  30. package/operations/entry/dataLoader/createBatchScheduleFn.js.map +1 -0
  31. package/operations/entry/dataLoader/getAllEntryRevisions.d.ts +4 -0
  32. package/operations/entry/dataLoader/getAllEntryRevisions.js +24 -0
  33. package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -0
  34. package/operations/entry/dataLoader/getLatestRevisionByEntryId.d.ts +4 -0
  35. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +40 -0
  36. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -0
  37. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.d.ts +4 -0
  38. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +40 -0
  39. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -0
  40. package/operations/entry/dataLoader/getRevisionById.d.ts +4 -0
  41. package/operations/entry/dataLoader/getRevisionById.js +42 -0
  42. package/operations/entry/dataLoader/getRevisionById.js.map +1 -0
  43. package/operations/entry/dataLoader/index.d.ts +8 -0
  44. package/operations/entry/dataLoader/index.js +18 -0
  45. package/operations/entry/dataLoader/index.js.map +1 -0
  46. package/operations/entry/dataLoader/types.d.ts +6 -0
  47. package/operations/entry/dataLoader/types.js +0 -0
  48. package/operations/entry/dataLoaders.d.ts +14 -30
  49. package/operations/entry/dataLoaders.js +84 -272
  50. package/operations/entry/dataLoaders.js.map +1 -1
  51. package/operations/entry/index.d.ts +5 -4
  52. package/operations/entry/index.js +899 -807
  53. package/operations/entry/index.js.map +1 -1
  54. package/operations/entry/keys.d.ts +46 -2
  55. package/operations/entry/keys.js +54 -49
  56. package/operations/entry/keys.js.map +1 -1
  57. package/operations/group/index.d.ts +4 -5
  58. package/operations/group/index.js +117 -158
  59. package/operations/group/index.js.map +1 -1
  60. package/operations/model/index.d.ts +3 -3
  61. package/operations/model/index.js +103 -134
  62. package/operations/model/index.js.map +1 -1
  63. package/package.json +32 -33
  64. package/plugins/index.d.ts +2 -4
  65. package/plugins/index.js +1 -49
  66. package/types.d.ts +25 -41
  67. package/types.js +8 -14
  68. package/types.js.map +1 -1
  69. package/definitions/settings.d.ts +0 -9
  70. package/definitions/settings.js +0 -53
  71. package/definitions/settings.js.map +0 -1
  72. package/definitions/system.d.ts +0 -9
  73. package/definitions/system.js +0 -41
  74. package/definitions/system.js.map +0 -1
  75. package/dynamoDb/path/plainObject.d.ts +0 -2
  76. package/dynamoDb/path/plainObject.js +0 -33
  77. package/dynamoDb/path/plainObject.js.map +0 -1
  78. package/dynamoDb/storage/date.d.ts +0 -3
  79. package/dynamoDb/storage/date.js +0 -91
  80. package/dynamoDb/storage/date.js.map +0 -1
  81. package/dynamoDb/storage/longText.d.ts +0 -10
  82. package/dynamoDb/storage/longText.js +0 -91
  83. package/dynamoDb/storage/longText.js.map +0 -1
  84. package/dynamoDb/storage/richText.d.ts +0 -2
  85. package/dynamoDb/storage/richText.js +0 -95
  86. package/dynamoDb/storage/richText.js.map +0 -1
  87. package/dynamoDb/transformValue/datetime.d.ts +0 -5
  88. package/dynamoDb/transformValue/datetime.js +0 -45
  89. package/dynamoDb/transformValue/datetime.js.map +0 -1
  90. package/operations/entry/filtering/createExpressions.d.ts +0 -26
  91. package/operations/entry/filtering/createExpressions.js +0 -176
  92. package/operations/entry/filtering/createExpressions.js.map +0 -1
  93. package/operations/entry/filtering/createFields.d.ts +0 -14
  94. package/operations/entry/filtering/createFields.js +0 -105
  95. package/operations/entry/filtering/createFields.js.map +0 -1
  96. package/operations/entry/filtering/extractSort.d.ts +0 -17
  97. package/operations/entry/filtering/extractSort.js +0 -67
  98. package/operations/entry/filtering/extractSort.js.map +0 -1
  99. package/operations/entry/filtering/filter.d.ts +0 -15
  100. package/operations/entry/filtering/filter.js +0 -143
  101. package/operations/entry/filtering/filter.js.map +0 -1
  102. package/operations/entry/filtering/fullTextSearch.d.ts +0 -14
  103. package/operations/entry/filtering/fullTextSearch.js +0 -48
  104. package/operations/entry/filtering/fullTextSearch.js.map +0 -1
  105. package/operations/entry/filtering/getValue.d.ts +0 -5
  106. package/operations/entry/filtering/getValue.js +0 -63
  107. package/operations/entry/filtering/getValue.js.map +0 -1
  108. package/operations/entry/filtering/index.d.ts +0 -2
  109. package/operations/entry/filtering/index.js +0 -19
  110. package/operations/entry/filtering/index.js.map +0 -1
  111. package/operations/entry/filtering/mapPlugins.d.ts +0 -8
  112. package/operations/entry/filtering/mapPlugins.js +0 -31
  113. package/operations/entry/filtering/mapPlugins.js.map +0 -1
  114. package/operations/entry/filtering/plugins/defaultFilterCreate.d.ts +0 -2
  115. package/operations/entry/filtering/plugins/defaultFilterCreate.js +0 -41
  116. package/operations/entry/filtering/plugins/defaultFilterCreate.js.map +0 -1
  117. package/operations/entry/filtering/plugins/index.d.ts +0 -1
  118. package/operations/entry/filtering/plugins/index.js +0 -13
  119. package/operations/entry/filtering/plugins/index.js.map +0 -1
  120. package/operations/entry/filtering/plugins/objectFilterCreate.d.ts +0 -2
  121. package/operations/entry/filtering/plugins/objectFilterCreate.js +0 -86
  122. package/operations/entry/filtering/plugins/objectFilterCreate.js.map +0 -1
  123. package/operations/entry/filtering/plugins/refFilterCreate.d.ts +0 -2
  124. package/operations/entry/filtering/plugins/refFilterCreate.js +0 -71
  125. package/operations/entry/filtering/plugins/refFilterCreate.js.map +0 -1
  126. package/operations/entry/filtering/sort.d.ts +0 -12
  127. package/operations/entry/filtering/sort.js +0 -69
  128. package/operations/entry/filtering/sort.js.map +0 -1
  129. package/operations/entry/filtering/systemFields.d.ts +0 -4
  130. package/operations/entry/filtering/systemFields.js +0 -70
  131. package/operations/entry/filtering/systemFields.js.map +0 -1
  132. package/operations/entry/filtering/transform.d.ts +0 -6
  133. package/operations/entry/filtering/transform.js +0 -16
  134. package/operations/entry/filtering/transform.js.map +0 -1
  135. package/operations/entry/filtering/types.d.ts +0 -40
  136. package/operations/entry/filtering/types.js +0 -5
  137. package/operations/entry/filtering/types.js.map +0 -1
  138. package/operations/entry/filtering/values.d.ts +0 -2
  139. package/operations/entry/filtering/values.js +0 -22
  140. package/operations/entry/filtering/values.js.map +0 -1
  141. package/operations/entry/filtering/where.d.ts +0 -5
  142. package/operations/entry/filtering/where.js +0 -32
  143. package/operations/entry/filtering/where.js.map +0 -1
  144. package/operations/entry/systemFields.d.ts +0 -2
  145. package/operations/entry/systemFields.js +0 -72
  146. package/operations/entry/systemFields.js.map +0 -1
  147. package/operations/settings/index.d.ts +0 -7
  148. package/operations/settings/index.js +0 -111
  149. package/operations/settings/index.js.map +0 -1
  150. package/operations/system/index.d.ts +0 -7
  151. package/operations/system/index.js +0 -82
  152. package/operations/system/index.js.map +0 -1
  153. package/plugins/CmsEntryFieldFilterPathPlugin.d.ts +0 -22
  154. package/plugins/CmsEntryFieldFilterPathPlugin.js +0 -41
  155. package/plugins/CmsEntryFieldFilterPathPlugin.js.map +0 -1
  156. package/plugins/CmsEntryFieldFilterPlugin.d.ts +0 -43
  157. package/plugins/CmsEntryFieldFilterPlugin.js +0 -24
  158. package/plugins/CmsEntryFieldFilterPlugin.js.map +0 -1
  159. package/plugins/CmsEntryFieldSortingPlugin.d.ts +0 -42
  160. package/plugins/CmsEntryFieldSortingPlugin.js +0 -28
  161. package/plugins/CmsEntryFieldSortingPlugin.js.map +0 -1
  162. package/plugins/CmsFieldFilterValueTransformPlugin.d.ts +0 -11
  163. package/plugins/CmsFieldFilterValueTransformPlugin.js +0 -24
  164. package/plugins/CmsFieldFilterValueTransformPlugin.js.map +0 -1
  165. package/plugins/index.js.map +0 -1
@@ -1,71 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.createRefFilterCreate = void 0;
8
- var _error = _interopRequireDefault(require("@webiny/error"));
9
- var _CmsEntryFieldFilterPlugin = require("../../../../plugins/CmsEntryFieldFilterPlugin");
10
- var _where = require("../where");
11
- var _transform = require("../transform");
12
- const createRefFilterCreate = () => {
13
- return new _CmsEntryFieldFilterPlugin.CmsEntryFieldFilterPlugin({
14
- fieldType: "ref",
15
- create: params => {
16
- const {
17
- value,
18
- valueFilterPlugins,
19
- transformValuePlugins,
20
- field
21
- } = params;
22
- const propertyFilters = Object.keys(value);
23
- if (propertyFilters.length === 0) {
24
- return null;
25
- }
26
- const filters = [];
27
- for (const propertyFilter of propertyFilters) {
28
- const whereParams = (0, _where.extractWhereParams)(propertyFilter);
29
- if (!whereParams) {
30
- continue;
31
- }
32
- const {
33
- fieldId: propertyId,
34
- operation: propertyOperation,
35
- negate
36
- } = whereParams;
37
- const transformValuePlugin = transformValuePlugins[field.type];
38
- const transformValueCallable = value => {
39
- if (!transformValuePlugin) {
40
- return value;
41
- }
42
- return transformValuePlugin.transform({
43
- field,
44
- value
45
- });
46
- };
47
- const filterPlugin = valueFilterPlugins[propertyOperation];
48
- if (!filterPlugin) {
49
- throw new _error.default(`Missing operation filter for "${propertyOperation}".`, "MISSING_OPERATION_FILTER");
50
- }
51
- const paths = [field.createPath({
52
- field
53
- }), propertyId];
54
- filters.push({
55
- field,
56
- path: paths.join("."),
57
- fieldPathId: [...field.parents.map(f => f.fieldId), field.fieldId].join("."),
58
- plugin: filterPlugin,
59
- negate,
60
- compareValue: (0, _transform.transformValue)({
61
- value: value[propertyFilter],
62
- transform: transformValueCallable
63
- }),
64
- transformValue: transformValueCallable
65
- });
66
- }
67
- return filters;
68
- }
69
- });
70
- };
71
- exports.createRefFilterCreate = createRefFilterCreate;
@@ -1 +0,0 @@
1
- {"version":3,"names":["createRefFilterCreate","CmsEntryFieldFilterPlugin","fieldType","create","params","value","valueFilterPlugins","transformValuePlugins","field","propertyFilters","Object","keys","length","filters","propertyFilter","whereParams","extractWhereParams","fieldId","propertyId","operation","propertyOperation","negate","transformValuePlugin","type","transformValueCallable","transform","filterPlugin","WebinyError","paths","createPath","push","path","join","fieldPathId","parents","map","f","plugin","compareValue","transformValue"],"sources":["refFilterCreate.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport {\n CmsEntryFieldFilterPlugin,\n CmsEntryFieldFilterPluginCreateResponse\n} from \"~/plugins/CmsEntryFieldFilterPlugin\";\nimport { extractWhereParams } from \"~/operations/entry/filtering/where\";\nimport { transformValue } from \"~/operations/entry/filtering/transform\";\n\nexport const createRefFilterCreate = () => {\n return new CmsEntryFieldFilterPlugin({\n fieldType: \"ref\",\n create: params => {\n const { value, valueFilterPlugins, transformValuePlugins, field } = params;\n const propertyFilters = Object.keys(value);\n if (propertyFilters.length === 0) {\n return null;\n }\n\n const filters: CmsEntryFieldFilterPluginCreateResponse[] = [];\n\n for (const propertyFilter of propertyFilters) {\n const whereParams = extractWhereParams(propertyFilter);\n if (!whereParams) {\n continue;\n }\n const { fieldId: propertyId, operation: propertyOperation, negate } = whereParams;\n\n const transformValuePlugin = transformValuePlugins[field.type];\n\n const transformValueCallable = (value: any) => {\n if (!transformValuePlugin) {\n return value;\n }\n return transformValuePlugin.transform({\n field,\n value\n });\n };\n\n const filterPlugin = valueFilterPlugins[propertyOperation];\n if (!filterPlugin) {\n throw new WebinyError(\n `Missing operation filter for \"${propertyOperation}\".`,\n \"MISSING_OPERATION_FILTER\"\n );\n }\n\n const paths = [\n field.createPath({\n field\n }),\n propertyId\n ];\n\n filters.push({\n field,\n path: paths.join(\".\"),\n fieldPathId: [...field.parents.map(f => f.fieldId), field.fieldId].join(\".\"),\n plugin: filterPlugin,\n negate,\n compareValue: transformValue({\n value: value[propertyFilter],\n transform: transformValueCallable\n }),\n transformValue: transformValueCallable\n });\n }\n\n return filters;\n }\n });\n};\n"],"mappings":";;;;;;;AAAA;AACA;AAIA;AACA;AAEO,MAAMA,qBAAqB,GAAG,MAAM;EACvC,OAAO,IAAIC,oDAAyB,CAAC;IACjCC,SAAS,EAAE,KAAK;IAChBC,MAAM,EAAEC,MAAM,IAAI;MACd,MAAM;QAAEC,KAAK;QAAEC,kBAAkB;QAAEC,qBAAqB;QAAEC;MAAM,CAAC,GAAGJ,MAAM;MAC1E,MAAMK,eAAe,GAAGC,MAAM,CAACC,IAAI,CAACN,KAAK,CAAC;MAC1C,IAAII,eAAe,CAACG,MAAM,KAAK,CAAC,EAAE;QAC9B,OAAO,IAAI;MACf;MAEA,MAAMC,OAAkD,GAAG,EAAE;MAE7D,KAAK,MAAMC,cAAc,IAAIL,eAAe,EAAE;QAC1C,MAAMM,WAAW,GAAG,IAAAC,yBAAkB,EAACF,cAAc,CAAC;QACtD,IAAI,CAAC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sModel } from "@webiny/api-headless-cms/types";
2
- import { Field } from "./types";
3
- import { PluginsContainer } from "@webiny/plugins";
4
- interface Params {
5
- model: CmsModel;
6
- items: CmsEntry[];
7
- sort?: string[];
8
- fields: Record<string, Field>;
9
- plugins: PluginsContainer;
10
- }
11
- export declare const sort: (params: Params) => CmsEntry[];
12
- export {};
@@ -1,69 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.sort = void 0;
8
- var _error = _interopRequireDefault(require("@webiny/error"));
9
- var _dotProp = _interopRequireDefault(require("dot-prop"));
10
- var _sortBy = _interopRequireDefault(require("lodash/sortBy"));
11
- var _extractSort = require("./extractSort");
12
- const sort = params => {
13
- const {
14
- model,
15
- items,
16
- sort = [],
17
- fields,
18
- plugins
19
- } = params;
20
- if (items.length <= 1) {
21
- return items;
22
- } else if (sort.length === 0) {
23
- sort.push("savedOn_DESC");
24
- } else if (sort.length > 1) {
25
- throw new _error.default("Sorting is limited to a single field.", "SORT_MULTIPLE_FIELDS_ERROR", {
26
- sort: sort
27
- });
28
- }
29
- const [firstSort] = sort;
30
- if (!firstSort) {
31
- throw new _error.default("Empty sort array item.", "SORT_EMPTY_ERROR", {
32
- sort
33
- });
34
- }
35
- const {
36
- fieldId,
37
- field,
38
- valuePath,
39
- reverse
40
- } = (0, _extractSort.extractSort)({
41
- model,
42
- sortBy: firstSort,
43
- fields,
44
- plugins
45
- });
46
- const itemsToSort = items.map(item => {
47
- return {
48
- id: item.id,
49
- value: field.transform(_dotProp.default.get(item, valuePath))
50
- };
51
- });
52
- const sortedItems = (0, _sortBy.default)(itemsToSort, "value");
53
- const newItems = sortedItems.map(s => {
54
- const item = items.find(i => i.id === s.id);
55
- if (item) {
56
- return item;
57
- }
58
- throw new _error.default("Could not find item by given id after the sorting.", "SORTING_ITEMS_ERROR", {
59
- id: s.id,
60
- sortingBy: fieldId,
61
- reverse
62
- });
63
- });
64
- if (!reverse) {
65
- return newItems;
66
- }
67
- return newItems.reverse();
68
- };
69
- exports.sort = sort;
@@ -1 +0,0 @@
1
- {"version":3,"names":["sort","params","model","items","fields","plugins","length","push","WebinyError","firstSort","fieldId","field","valuePath","reverse","extractSort","sortBy","itemsToSort","map","item","id","value","transform","dotProp","get","sortedItems","lodashSortBy","newItems","s","find","i","sortingBy"],"sources":["sort.ts"],"sourcesContent":["import { CmsEntry, CmsModel } from \"@webiny/api-headless-cms/types\";\nimport WebinyError from \"@webiny/error\";\nimport dotProp from \"dot-prop\";\nimport lodashSortBy from \"lodash/sortBy\";\nimport { extractSort } from \"./extractSort\";\nimport { Field } from \"./types\";\nimport { PluginsContainer } from \"@webiny/plugins\";\n\ninterface Params {\n model: CmsModel;\n items: CmsEntry[];\n sort?: string[];\n fields: Record<string, Field>;\n plugins: PluginsContainer;\n}\n\ninterface SortedItem {\n id: string;\n value: any;\n}\n\nexport const sort = (params: Params): CmsEntry[] => {\n const { model, items, sort = [], fields, plugins } = params;\n if (items.length <= 1) {\n return items;\n } else if (sort.length === 0) {\n sort.push(\"savedOn_DESC\");\n } else if (sort.length > 1) {\n throw new WebinyError(\n \"Sorting is limited to a single field.\",\n \"SORT_MULTIPLE_FIELDS_ERROR\",\n {\n sort: sort\n }\n );\n }\n const [firstSort] = sort;\n if (!firstSort) {\n throw new WebinyError(\"Empty sort array item.\", \"SORT_EMPTY_ERROR\", {\n sort\n });\n }\n\n const { fieldId, field, valuePath, reverse } = extractSort({\n model,\n sortBy: firstSort,\n fields,\n plugins\n });\n\n const itemsToSort = items.map(item => {\n return {\n id: item.id,\n value: field.transform(dotProp.get(item, valuePath))\n };\n });\n const sortedItems: SortedItem[] = lodashSortBy(itemsToSort, \"value\");\n const newItems = sortedItems.map(s => {\n const item = items.find(i => i.id === s.id);\n if (item) {\n return item;\n }\n throw new WebinyError(\n \"Could not find item by given id after the sorting.\",\n \"SORTING_ITEMS_ERROR\",\n {\n id: s.id,\n sortingBy: fieldId,\n reverse\n }\n );\n });\n if (!reverse) {\n return newItems;\n }\n return newItems.reverse();\n};\n"],"mappings":";;;;;;;AACA;AACA;AACA;AACA;AAiBO,MAAMA,IAAI,GAAIC,MAAc,IAAiB;EAChD,MAAM;IAAEC,KAAK;IAAEC,KAAK;IAAEH,IAAI,GAAG,EAAE;IAAEI,MAAM;IAAEC;EAAQ,CAAC,GAAGJ,MAAM;EAC3D,IAAIE,KAAK,CAACG,MAAM,IAAI,CAAC,EAAE;IACnB,OAAOH,KAAK;EAChB,CAAC,MAAM,IAAIH,IAAI,CAACM,MAAM,KAAK,CAAC,EAAE;IAC1BN,IAAI,CAACO,IAAI,CAAC,cAAc,CAAC;EAC7B,CAAC,MAAM,IAAIP,IAAI,CAACM,MAAM,GAAG,CAAC,EAAE;IACxB,MAAM,IAAIE,cAAW,CACjB,uCAAuC,EACvC,4BAA4B,EAC5B;MACIR,IAAI,EAAEA;IACV,CAAC,CACJ;EACL;EACA,MAAM,CAACS,SAAS,CAAC,GAAGT,IAAI;EACxB,IAAI,CAACS,SAAS,EAAE;IACZ,MAAM,IAAID,cAAW,CAAC,wBAAwB,EAAE,kBAAkB,EAAE;MAChER;IACJ,CAAC,CAAC;EACN;EAEA,MAAM;IAAEU,OAAO;IAAEC,KAAK;IAAEC,SAAS;IAAEC;EAAQ,CAAC,GAAG,IAAAC,wBAAW,EAAC;IACvDZ,KAAK;IACLa,MAAM,EAAEN,SAAS;IACjBL,MAAM;IACNC;EACJ,CAAC,CAAC;EAEF,MAAMW,WAAW,GAAGb,KAAK,CAACc,GAAG,CAACC,IAAI,IAAI;IAClC,OAAO;MACHC,EAAE,EAAED,IAAI,CAACC,EAAE;MACXC,KAAK,EAAET,KAAK,CAACU,SAAS,CAACC,gBAAO,CAACC,GAAG,CAACL,IAAI,EAAEN,SAAS,CAAC;IACvD,CAAC;EACL,CAAC,CAAC;EACF,MAAMY,WAAyB,GAAG,IAAAC,eAAY,EAACT,WAAW,EAAE,OAAO,CAAC;EACpE,MAAMU,QAAQ,GAAGF,WAAW,CAACP,GAAG,CAACU,CAAC,IAAI;IAClC,MAAMT,IAAI,GAAGf,KAAK,CAACyB,IAAI,CAACC,CAAC,IAAIA,CAAC,CAACV,EAAE,KAAKQ,CAAC,CAACR,EAAE,CAAC;IAC3C,IAAID,IAAI,EAAE;MACN,OAAOA,IAAI;IACf;IACA,MAAM,IAAIV,cAAW,CACjB,oDAAoD,EACpD,qBAAqB,EACrB;MACIW,EAAE,EAAEQ,CAAC,CAACR,EAAE;MACRW,SAAS,EAAEpB,OAAO;MAClBG;IACJ,CAAC,CACJ;EACL,CAAC,CAAC;EACF,IAAI,CAACA,OAAO,EAAE;IACV,OAAOa,QAAQ;EACnB;EACA,OAAOA,QAAQ,CAACb,OAAO,EAAE;AAC7B,CAAC;AAAC"}
@@ -1,4 +0,0 @@
1
- import { CmsModelField } from "@webiny/api-headless-cms/types";
2
- declare type Field = Pick<CmsModelField, "id" | "type" | "storageId" | "fieldId" | "settings" | "label">;
3
- export declare const createSystemFields: () => Field[];
4
- export {};
@@ -1,70 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createSystemFields = void 0;
7
- const createSystemFields = () => {
8
- return [{
9
- id: "id",
10
- type: "text",
11
- storageId: "id",
12
- fieldId: "id",
13
- label: "ID"
14
- }, {
15
- id: "entryId",
16
- type: "text",
17
- storageId: "entryId",
18
- fieldId: "entryId",
19
- label: "Entry ID"
20
- }, {
21
- id: "createdOn",
22
- type: "datetime",
23
- storageId: "createdOn",
24
- fieldId: "createdOn",
25
- label: "Created On"
26
- }, {
27
- id: "savedOn",
28
- type: "datetime",
29
- storageId: "savedOn",
30
- fieldId: "savedOn",
31
- label: "Saved On"
32
- }, {
33
- id: "createdBy",
34
- type: "plainObject",
35
- storageId: "createdBy",
36
- fieldId: "createdBy",
37
- label: "Created By",
38
- settings: {
39
- path: "createdBy.id"
40
- }
41
- }, {
42
- id: "meta",
43
- type: "plainObject",
44
- storageId: "meta",
45
- fieldId: "meta",
46
- label: "Meta"
47
- }, {
48
- id: "ownedBy",
49
- type: "plainObject",
50
- storageId: "ownedBy",
51
- fieldId: "ownedBy",
52
- label: "Owned By",
53
- settings: {
54
- path: "ownedBy.id"
55
- }
56
- }, {
57
- id: "version",
58
- type: "number",
59
- storageId: "version",
60
- fieldId: "version",
61
- label: "Version"
62
- }, {
63
- id: "status",
64
- type: "text",
65
- storageId: "status",
66
- fieldId: "status",
67
- label: "Status"
68
- }];
69
- };
70
- exports.createSystemFields = createSystemFields;
@@ -1 +0,0 @@
1
- {"version":3,"names":["createSystemFields","id","type","storageId","fieldId","label","settings","path"],"sources":["systemFields.ts"],"sourcesContent":["import { CmsModelField } from \"@webiny/api-headless-cms/types\";\n\ntype Field = Pick<CmsModelField, \"id\" | \"type\" | \"storageId\" | \"fieldId\" | \"settings\" | \"label\">;\n\nexport const createSystemFields = (): Field[] => {\n return [\n {\n id: \"id\",\n type: \"text\",\n storageId: \"id\",\n fieldId: \"id\",\n label: \"ID\"\n },\n {\n id: \"entryId\",\n type: \"text\",\n storageId: \"entryId\",\n fieldId: \"entryId\",\n label: \"Entry ID\"\n },\n {\n id: \"createdOn\",\n type: \"datetime\",\n storageId: \"createdOn\",\n fieldId: \"createdOn\",\n label: \"Created On\"\n },\n {\n id: \"savedOn\",\n type: \"datetime\",\n storageId: \"savedOn\",\n fieldId: \"savedOn\",\n label: \"Saved On\"\n },\n {\n id: \"createdBy\",\n type: \"plainObject\",\n storageId: \"createdBy\",\n fieldId: \"createdBy\",\n label: \"Created By\",\n settings: {\n path: \"createdBy.id\"\n }\n },\n {\n id: \"meta\",\n type: \"plainObject\",\n storageId: \"meta\",\n fieldId: \"meta\",\n label: \"Meta\"\n },\n {\n id: \"ownedBy\",\n type: \"plainObject\",\n storageId: \"ownedBy\",\n fieldId: \"ownedBy\",\n label: \"Owned By\",\n settings: {\n path: \"ownedBy.id\"\n }\n },\n {\n id: \"version\",\n type: \"number\",\n storageId: \"version\",\n fieldId: \"version\",\n label: \"Version\"\n },\n {\n id: \"status\",\n type: \"text\",\n storageId: \"status\",\n fieldId: \"status\",\n label: \"Status\"\n }\n ];\n};\n"],"mappings":";;;;;;AAIO,MAAMA,kBAAkB,GAAG,MAAe;EAC7C,OAAO,CACH;IACIC,EAAE,EAAE,IAAI;IACRC,IAAI,EAAE,MAAM;IACZC,SAAS,EAAE,IAAI;IACfC,OAAO,EAAE,IAAI;IACbC,KAAK,EAAE;EACX,CAAC,EACD;IACIJ,EAAE,EAAE,SAAS;IACbC,IAAI,EAAE,MAAM;IACZC,SAAS,EAAE,SAAS;IACpBC,OAAO,EAAE,SAAS;IAClBC,KAAK,EAAE;EACX,CAAC,EACD;IACIJ,EAAE,EAAE,WAAW;IACfC,IAAI,EAAE,UAAU;IAChBC,SAAS,EAAE,WAAW;IACtBC,OAAO,EAAE,WAAW;IACpBC,KAAK,EAAE;EACX,CAAC,EACD;IACIJ,EAAE,EAAE,SAAS;IACbC,IAAI,EAAE,UAAU;IAChBC,SAAS,EAAE,SAAS;IACpBC,OAAO,EAAE,SAAS;IAClBC,KAAK,EAAE;EACX,CAAC,EACD;IACIJ,EAAE,EAAE,WAAW;IACfC,IAAI,EAAE,aAAa;IACnBC,SAAS,EAAE,WAAW;IACtBC,OAAO,EAAE,WAAW;IACpBC,KAAK,EAAE,YAAY;IACnBC,QAAQ,EAAE;MACNC,IAAI,EAAE;IACV;EACJ,CAAC,EACD;IACIN,EAAE,EAAE,MAAM;IACVC,IAAI,EAAE,aAAa;IACnBC,SAAS,EAAE,MAAM;IACjBC,OAAO,EAAE,MAAM;IACfC,KAAK,EAAE;EACX,CAAC,EACD;IACIJ,EAAE,EAAE,SAAS;IACbC,IAAI,EAAE,aAAa;IACnBC,SAAS,EAAE,SAAS;IACpBC,OAAO,EAAE,SAAS;IAClBC,KAAK,EAAE,UAAU;IACjBC,QAAQ,EAAE;MACNC,IAAI,EAAE;IACV;EACJ,CAAC,EACD;IACIN,EAAE,EAAE,SAAS;IACbC,IAAI,EAAE,QAAQ;IACdC,SAAS,EAAE,SAAS;IACpBC,OAAO,EAAE,SAAS;IAClBC,KAAK,EAAE;EACX,CAAC,EACD;IACIJ,EAAE,EAAE,QAAQ;IACZC,IAAI,EAAE,MAAM;IACZC,SAAS,EAAE,QAAQ;IACnBC,OAAO,EAAE,QAAQ;IACjBC,KAAK,EAAE;EACX,CAAC,CACJ;AACL,CAAC;AAAC"}
@@ -1,6 +0,0 @@
1
- import { Field } from "./types";
2
- interface Params extends Pick<Field, "transform"> {
3
- value: any;
4
- }
5
- export declare const transformValue: ({ value, transform }: Params) => any;
6
- export {};
@@ -1,16 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.transformValue = void 0;
7
- const transformValue = ({
8
- value,
9
- transform
10
- }) => {
11
- if (Array.isArray(value)) {
12
- return value.map(v => transform(v));
13
- }
14
- return transform(value);
15
- };
16
- exports.transformValue = transformValue;
@@ -1 +0,0 @@
1
- {"version":3,"names":["transformValue","value","transform","Array","isArray","map","v"],"sources":["transform.ts"],"sourcesContent":["import { Field } from \"./types\";\n\ninterface Params extends Pick<Field, \"transform\"> {\n value: any;\n}\nexport const transformValue = ({ value, transform }: Params): any => {\n if (Array.isArray(value)) {\n return value.map(v => transform(v));\n }\n return transform(value);\n};\n"],"mappings":";;;;;;AAKO,MAAMA,cAAc,GAAG,CAAC;EAAEC,KAAK;EAAEC;AAAkB,CAAC,KAAU;EACjE,IAAIC,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,EAAE;IACtB,OAAOA,KAAK,CAACI,GAAG,CAACC,CAAC,IAAIJ,SAAS,CAACI,CAAC,CAAC,CAAC;EACvC;EACA,OAAOJ,SAAS,CAACD,KAAK,CAAC;AAC3B,CAAC;AAAC"}
@@ -1,40 +0,0 @@
1
- import { CmsModelField } from "@webiny/api-headless-cms/types";
2
- import { CreatePathCallable } from "../../../plugins";
3
- interface FieldValueTransform {
4
- (value: any): any;
5
- }
6
- export interface FieldParent {
7
- fieldId: string;
8
- multipleValues?: boolean;
9
- }
10
- export interface Field extends Partial<Omit<CmsModelField, "id" | "type" | "storageId" | "fieldId">>, Pick<CmsModelField, "id" | "type" | "storageId" | "fieldId"> {
11
- /**
12
- * A list od fieldId of all parents of the current field.
13
- *
14
- * This is used to check if we need to iterate through an array of parent values.
15
- */
16
- parents: FieldParent[];
17
- /**
18
- * The method which creates a path for the filtering.
19
- *
20
- * Always exists. In most cases it will return some fixed value.
21
- * When having a CmsEntryFieldFilterPathPlugin then it is executed to create a path.
22
- */
23
- createPath: CreatePathCallable;
24
- /**
25
- * In most cases, return value of this method is what ever is the input.
26
- *
27
- * In some cases there might be a CmsFieldFilterValueTransformPlugin, which transforms value to a comparable one.
28
- * For example, time in format 15:45:58 is not comparable, so we transform it into the seconds and then compare.
29
- */
30
- transform: FieldValueTransform;
31
- /**
32
- * Is the field a system field?
33
- * System fields are built into the code and cannot be changed.
34
- */
35
- system: boolean;
36
- }
37
- export interface FilterItemFromStorage {
38
- <T = any>(field: Partial<CmsModelField> & Pick<CmsModelField, "fieldId" | "storageId" | "id" | "settings" | "type">, value: any): Promise<T>;
39
- }
40
- export {};
@@ -1,5 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import { CmsModelField } from \"@webiny/api-headless-cms/types\";\nimport { CreatePathCallable } from \"~/plugins\";\n\ninterface FieldValueTransform {\n (value: any): any;\n}\n\nexport interface FieldParent {\n fieldId: string;\n multipleValues?: boolean;\n}\n\nexport interface Field\n extends Partial<Omit<CmsModelField, \"id\" | \"type\" | \"storageId\" | \"fieldId\">>,\n Pick<CmsModelField, \"id\" | \"type\" | \"storageId\" | \"fieldId\"> {\n /**\n * A list od fieldId of all parents of the current field.\n *\n * This is used to check if we need to iterate through an array of parent values.\n */\n parents: FieldParent[];\n /**\n * The method which creates a path for the filtering.\n *\n * Always exists. In most cases it will return some fixed value.\n * When having a CmsEntryFieldFilterPathPlugin then it is executed to create a path.\n */\n createPath: CreatePathCallable;\n /**\n * In most cases, return value of this method is what ever is the input.\n *\n * In some cases there might be a CmsFieldFilterValueTransformPlugin, which transforms value to a comparable one.\n * For example, time in format 15:45:58 is not comparable, so we transform it into the seconds and then compare.\n */\n transform: FieldValueTransform;\n /**\n * Is the field a system field?\n * System fields are built into the code and cannot be changed.\n */\n system: boolean;\n}\n\nexport interface FilterItemFromStorage {\n <T = any>(\n field: Partial<CmsModelField> &\n Pick<CmsModelField, \"fieldId\" | \"storageId\" | \"id\" | \"settings\" | \"type\">,\n value: any\n ): Promise<T>;\n}\n"],"mappings":""}
@@ -1,2 +0,0 @@
1
- import { CmsEntryListWhere } from "@webiny/api-headless-cms/types";
2
- export declare const getWhereValues: (value: unknown, condition: "AND" | "OR") => CmsEntryListWhere[];
@@ -1,22 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.getWhereValues = void 0;
8
- var _error = _interopRequireDefault(require("@webiny/error"));
9
- const getWhereValues = (value, condition) => {
10
- const values = value;
11
- if (!Array.isArray(values)) {
12
- throw new _error.default(`Trying to run filtering with "${condition}", but the value sent is not an array.`, `MALFORMED_${condition}_CONDITION`, {
13
- value
14
- });
15
- } else if (values.length === 0) {
16
- throw new _error.default(`Trying to run filtering with "${condition}", but the value sent is empty array.`, `MALFORMED_${condition}_CONDITION`, {
17
- value
18
- });
19
- }
20
- return values;
21
- };
22
- exports.getWhereValues = getWhereValues;
@@ -1 +0,0 @@
1
- {"version":3,"names":["getWhereValues","value","condition","values","Array","isArray","WebinyError","length"],"sources":["values.ts"],"sourcesContent":["import { CmsEntryListWhere } from \"@webiny/api-headless-cms/types\";\nimport WebinyError from \"@webiny/error\";\n\nexport const getWhereValues = (value: unknown, condition: \"AND\" | \"OR\") => {\n const values = value as CmsEntryListWhere[] | undefined;\n if (!Array.isArray(values)) {\n throw new WebinyError(\n `Trying to run filtering with \"${condition}\", but the value sent is not an array.`,\n `MALFORMED_${condition}_CONDITION`,\n {\n value\n }\n );\n } else if (values.length === 0) {\n throw new WebinyError(\n `Trying to run filtering with \"${condition}\", but the value sent is empty array.`,\n `MALFORMED_${condition}_CONDITION`,\n {\n value\n }\n );\n }\n return values;\n};\n"],"mappings":";;;;;;;AACA;AAEO,MAAMA,cAAc,GAAG,CAACC,KAAc,EAAEC,SAAuB,KAAK;EACvE,MAAMC,MAAM,GAAGF,KAAwC;EACvD,IAAI,CAACG,KAAK,CAACC,OAAO,CAACF,MAAM,CAAC,EAAE;IACxB,MAAM,IAAIG,cAAW,CAChB,iCAAgCJ,SAAU,wCAAuC,EACjF,aAAYA,SAAU,YAAW,EAClC;MACID;IACJ,CAAC,CACJ;EACL,CAAC,MAAM,IAAIE,MAAM,CAACI,MAAM,KAAK,CAAC,EAAE;IAC5B,MAAM,IAAID,cAAW,CAChB,iCAAgCJ,SAAU,uCAAsC,EAChF,aAAYA,SAAU,YAAW,EAClC;MACID;IACJ,CAAC,CACJ;EACL;EACA,OAAOE,MAAM;AACjB,CAAC;AAAC"}
@@ -1,5 +0,0 @@
1
- export declare const extractWhereParams: (key: string) => {
2
- fieldId: string;
3
- operation: string;
4
- negate: boolean;
5
- } | null;
@@ -1,32 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.extractWhereParams = void 0;
7
- const extractWhereParams = key => {
8
- const result = key.split("_");
9
- const fieldId = result.shift();
10
- if (!fieldId) {
11
- return null;
12
- }
13
- const rawOp = result.length === 0 ? "eq" : result.join("_");
14
- /**
15
- * When rawOp is not, it means it is equal negated so just return that.
16
- */
17
- if (rawOp === "not") {
18
- return {
19
- fieldId,
20
- operation: "eq",
21
- negate: true
22
- };
23
- }
24
- const negate = rawOp.match("not_") !== null;
25
- const operation = rawOp.replace("not_", "");
26
- return {
27
- fieldId,
28
- operation,
29
- negate
30
- };
31
- };
32
- exports.extractWhereParams = extractWhereParams;
@@ -1 +0,0 @@
1
- {"version":3,"names":["extractWhereParams","key","result","split","fieldId","shift","rawOp","length","join","operation","negate","match","replace"],"sources":["where.ts"],"sourcesContent":["export const extractWhereParams = (key: string) => {\n const result = key.split(\"_\");\n const fieldId = result.shift();\n if (!fieldId) {\n return null;\n }\n const rawOp = result.length === 0 ? \"eq\" : result.join(\"_\");\n /**\n * When rawOp is not, it means it is equal negated so just return that.\n */\n if (rawOp === \"not\") {\n return {\n fieldId,\n operation: \"eq\",\n negate: true\n };\n }\n const negate = rawOp.match(\"not_\") !== null;\n const operation = rawOp.replace(\"not_\", \"\");\n return {\n fieldId,\n operation,\n negate\n };\n};\n"],"mappings":";;;;;;AAAO,MAAMA,kBAAkB,GAAIC,GAAW,IAAK;EAC/C,MAAMC,MAAM,GAAGD,GAAG,CAACE,KAAK,CAAC,GAAG,CAAC;EAC7B,MAAMC,OAAO,GAAGF,MAAM,CAACG,KAAK,EAAE;EAC9B,IAAI,CAACD,OAAO,EAAE;IACV,OAAO,IAAI;EACf;EACA,MAAME,KAAK,GAAGJ,MAAM,CAACK,MAAM,KAAK,CAAC,GAAG,IAAI,GAAGL,MAAM,CAACM,IAAI,CAAC,GAAG,CAAC;EAC3D;AACJ;AACA;EACI,IAAIF,KAAK,KAAK,KAAK,EAAE;IACjB,OAAO;MACHF,OAAO;MACPK,SAAS,EAAE,IAAI;MACfC,MAAM,EAAE;IACZ,CAAC;EACL;EACA,MAAMA,MAAM,GAAGJ,KAAK,CAACK,KAAK,CAAC,MAAM,CAAC,KAAK,IAAI;EAC3C,MAAMF,SAAS,GAAGH,KAAK,CAACM,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;EAC3C,OAAO;IACHR,OAAO;IACPK,SAAS;IACTC;EACJ,CAAC;AACL,CAAC;AAAC"}
@@ -1,2 +0,0 @@
1
- import { CmsModelField } from "@webiny/api-headless-cms/types";
2
- export declare const systemFields: Record<string, CmsModelField>;
@@ -1,72 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.systemFields = void 0;
7
- const createSystemField = field => {
8
- return field;
9
- };
10
- const systemFields = {
11
- id: createSystemField({
12
- id: "id",
13
- type: "text",
14
- storageId: "id",
15
- fieldId: "id"
16
- }),
17
- entryId: createSystemField({
18
- id: "entryId",
19
- type: "text",
20
- storageId: "entryId",
21
- fieldId: "entryId"
22
- }),
23
- createdOn: createSystemField({
24
- id: "createdOn",
25
- type: "datetime",
26
- storageId: "createdOn",
27
- fieldId: "createdOn"
28
- }),
29
- savedOn: createSystemField({
30
- id: "savedOn",
31
- type: "datetime",
32
- storageId: "savedOn",
33
- fieldId: "savedOn"
34
- }),
35
- createdBy: createSystemField({
36
- id: "createdBy",
37
- type: "plainObject",
38
- storageId: "createdBy",
39
- fieldId: "createdBy",
40
- settings: {
41
- path: "createdBy.id"
42
- }
43
- }),
44
- meta: createSystemField({
45
- id: "meta",
46
- type: "plainObject",
47
- storageId: "meta",
48
- fieldId: "meta"
49
- }),
50
- ownedBy: createSystemField({
51
- id: "ownedBy",
52
- type: "plainObject",
53
- storageId: "ownedBy",
54
- fieldId: "ownedBy",
55
- settings: {
56
- path: "ownedBy.id"
57
- }
58
- }),
59
- version: createSystemField({
60
- id: "version",
61
- type: "number",
62
- storageId: "version",
63
- fieldId: "version"
64
- }),
65
- status: createSystemField({
66
- id: "status",
67
- type: "string",
68
- storageId: "status",
69
- fieldId: "status"
70
- })
71
- };
72
- exports.systemFields = systemFields;
@@ -1 +0,0 @@
1
- {"version":3,"names":["createSystemField","field","systemFields","id","type","storageId","fieldId","entryId","createdOn","savedOn","createdBy","settings","path","meta","ownedBy","version","status"],"sources":["systemFields.ts"],"sourcesContent":["import { CmsModelField } from \"@webiny/api-headless-cms/types\";\n\ntype CmsModelFieldInput = Partial<CmsModelField> &\n Pick<CmsModelField, \"id\" | \"type\" | \"storageId\" | \"fieldId\">;\nconst createSystemField = (field: CmsModelFieldInput): CmsModelField => {\n return field as CmsModelField;\n};\n\nexport const systemFields: Record<string, CmsModelField> = {\n id: createSystemField({\n id: \"id\",\n type: \"text\",\n storageId: \"id\",\n fieldId: \"id\"\n }),\n entryId: createSystemField({\n id: \"entryId\",\n type: \"text\",\n storageId: \"entryId\",\n fieldId: \"entryId\"\n }),\n createdOn: createSystemField({\n id: \"createdOn\",\n type: \"datetime\",\n storageId: \"createdOn\",\n fieldId: \"createdOn\"\n }),\n savedOn: createSystemField({\n id: \"savedOn\",\n type: \"datetime\",\n storageId: \"savedOn\",\n fieldId: \"savedOn\"\n }),\n createdBy: createSystemField({\n id: \"createdBy\",\n type: \"plainObject\",\n storageId: \"createdBy\",\n fieldId: \"createdBy\",\n settings: {\n path: \"createdBy.id\"\n }\n }),\n meta: createSystemField({\n id: \"meta\",\n type: \"plainObject\",\n storageId: \"meta\",\n fieldId: \"meta\"\n }),\n ownedBy: createSystemField({\n id: \"ownedBy\",\n type: \"plainObject\",\n storageId: \"ownedBy\",\n fieldId: \"ownedBy\",\n settings: {\n path: \"ownedBy.id\"\n }\n }),\n version: createSystemField({\n id: \"version\",\n type: \"number\",\n storageId: \"version\",\n fieldId: \"version\"\n }),\n status: createSystemField({\n id: \"status\",\n type: \"string\",\n storageId: \"status\",\n fieldId: \"status\"\n })\n};\n"],"mappings":";;;;;;AAIA,MAAMA,iBAAiB,GAAIC,KAAyB,IAAoB;EACpE,OAAOA,KAAK;AAChB,CAAC;AAEM,MAAMC,YAA2C,GAAG;EACvDC,EAAE,EAAEH,iBAAiB,CAAC;IAClBG,EAAE,EAAE,IAAI;IACRC,IAAI,EAAE,MAAM;IACZC,SAAS,EAAE,IAAI;IACfC,OAAO,EAAE;EACb,CAAC,CAAC;EACFC,OAAO,EAAEP,iBAAiB,CAAC;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C"}
@@ -1,7 +0,0 @@
1
- import { CmsSettingsStorageOperations } from "@webiny/api-headless-cms/types";
2
- import { Entity } from "dynamodb-toolbox";
3
- interface CreateSettingsStorageOperationsParams {
4
- entity: Entity<any>;
5
- }
6
- export declare const createSettingsStorageOperations: (params: CreateSettingsStorageOperationsParams) => CmsSettingsStorageOperations;
7
- export {};
@@ -1,111 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.createSettingsStorageOperations = void 0;
8
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
9
- var _get = require("@webiny/db-dynamodb/utils/get");
10
- var _error = _interopRequireDefault(require("@webiny/error"));
11
- var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
12
- const convertToDbData = settings => {
13
- return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, settings), {}, {
14
- contentModelLastChange: settings.contentModelLastChange.toISOString()
15
- });
16
- };
17
- const convertFromDbData = settings => {
18
- if (!settings) {
19
- return null;
20
- }
21
- let contentModelLastChange;
22
- try {
23
- contentModelLastChange = new Date(settings.contentModelLastChange);
24
- } catch {
25
- contentModelLastChange = new Date();
26
- }
27
- return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, settings), {}, {
28
- contentModelLastChange
29
- });
30
- };
31
- const createPartitionKey = ({
32
- tenant,
33
- locale
34
- }) => {
35
- return `T#${tenant}#L#${locale}#CMS#SETTINGS`;
36
- };
37
- const createSortKey = () => {
38
- return "settings";
39
- };
40
- const createKeys = params => {
41
- return {
42
- PK: createPartitionKey(params),
43
- SK: createSortKey()
44
- };
45
- };
46
- const createSettingsStorageOperations = params => {
47
- const {
48
- entity
49
- } = params;
50
- const create = async params => {
51
- const {
52
- settings
53
- } = params;
54
- const keys = createKeys(settings);
55
- const dbSettings = convertToDbData(settings);
56
- try {
57
- await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, dbSettings), keys));
58
- return settings;
59
- } catch (ex) {
60
- throw new _error.default(ex.message || "Could not create settings.", ex.code || "CREATE_SETTINGS_ERROR", {
61
- error: ex,
62
- settings,
63
- dbSettings,
64
- keys
65
- });
66
- }
67
- };
68
- const update = async params => {
69
- const {
70
- settings
71
- } = params;
72
- const keys = createKeys(settings);
73
- const dbSettings = convertToDbData(settings);
74
- try {
75
- await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, dbSettings), keys));
76
- return settings;
77
- } catch (ex) {
78
- throw new _error.default(ex.message || "Could not update settings.", ex.code || "UPDATE_SETTINGS_ERROR", {
79
- error: ex,
80
- settings,
81
- dbSettings,
82
- keys
83
- });
84
- }
85
- };
86
- const get = async params => {
87
- const keys = createKeys(params);
88
- try {
89
- const record = await (0, _get.get)({
90
- entity,
91
- keys
92
- });
93
- if (!record) {
94
- return null;
95
- }
96
- const settings = (0, _cleanup.cleanupItem)(entity, record);
97
- return convertFromDbData(settings);
98
- } catch (ex) {
99
- throw new _error.default(ex.message || "Could not get settings.", ex.code || "GET_SETTINGS_ERROR", {
100
- error: ex,
101
- keys
102
- });
103
- }
104
- };
105
- return {
106
- create,
107
- get,
108
- update
109
- };
110
- };
111
- exports.createSettingsStorageOperations = createSettingsStorageOperations;
@@ -1 +0,0 @@
1
- {"version":3,"names":["convertToDbData","settings","contentModelLastChange","toISOString","convertFromDbData","Date","createPartitionKey","tenant","locale","createSortKey","createKeys","params","PK","SK","createSettingsStorageOperations","entity","create","keys","dbSettings","put","ex","WebinyError","message","code","error","update","get","record","getRecord","cleanupItem"],"sources":["index.ts"],"sourcesContent":["import {\n CmsSettings,\n CmsSettingsStorageOperations,\n CmsSettingsStorageOperationsCreateParams,\n CmsSettingsStorageOperationsGetParams,\n CmsSettingsStorageOperationsUpdateParams\n} from \"@webiny/api-headless-cms/types\";\nimport { Entity } from \"dynamodb-toolbox\";\nimport { get as getRecord } from \"@webiny/db-dynamodb/utils/get\";\nimport WebinyError from \"@webiny/error\";\nimport { cleanupItem } from \"@webiny/db-dynamodb/utils/cleanup\";\n\ninterface CmsSettingsDb extends Omit<CmsSettings, \"contentModelLastChange\"> {\n contentModelLastChange: string;\n}\n\nconst convertToDbData = (settings: CmsSettings): CmsSettingsDb => {\n return {\n ...settings,\n contentModelLastChange: settings.contentModelLastChange.toISOString()\n };\n};\n\nconst convertFromDbData = (settings?: CmsSettingsDb): CmsSettings | null => {\n if (!settings) {\n return null;\n }\n let contentModelLastChange;\n try {\n contentModelLastChange = new Date(settings.contentModelLastChange);\n } catch {\n contentModelLastChange = new Date();\n }\n return {\n ...settings,\n contentModelLastChange\n };\n};\n\ninterface PartitionKeyParams {\n tenant: string;\n locale: string;\n}\n\nconst createPartitionKey = ({ tenant, locale }: PartitionKeyParams): string => {\n return `T#${tenant}#L#${locale}#CMS#SETTINGS`;\n};\n\nconst createSortKey = (): string => {\n return \"settings\";\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\ninterface CreateSettingsStorageOperationsParams {\n entity: Entity<any>;\n}\n\nexport const createSettingsStorageOperations = (\n params: CreateSettingsStorageOperationsParams\n): CmsSettingsStorageOperations => {\n const { entity } = params;\n\n const create = async (params: CmsSettingsStorageOperationsCreateParams) => {\n const { settings } = params;\n const keys = createKeys(settings);\n\n const dbSettings: CmsSettingsDb = convertToDbData(settings);\n\n try {\n await entity.put({\n ...dbSettings,\n ...keys\n });\n return settings;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create settings.\",\n ex.code || \"CREATE_SETTINGS_ERROR\",\n {\n error: ex,\n settings,\n dbSettings,\n keys\n }\n );\n }\n };\n\n const update = async (params: CmsSettingsStorageOperationsUpdateParams) => {\n const { settings } = params;\n\n const keys = createKeys(settings);\n\n const dbSettings: CmsSettingsDb = convertToDbData(settings);\n\n try {\n await entity.put({\n ...dbSettings,\n ...keys\n });\n return settings;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update settings.\",\n ex.code || \"UPDATE_SETTINGS_ERROR\",\n {\n error: ex,\n settings,\n dbSettings,\n keys\n }\n );\n }\n };\n\n const get = async (params: CmsSettingsStorageOperationsGetParams) => {\n const keys = createKeys(params);\n try {\n const record = await getRecord<CmsSettingsDb>({\n entity,\n keys\n });\n if (!record) {\n return null;\n }\n const settings = cleanupItem(entity, record) as CmsSettingsDb;\n return convertFromDbData(settings);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get settings.\",\n ex.code || \"GET_SETTINGS_ERROR\",\n {\n error: ex,\n keys\n }\n );\n }\n };\n\n return {\n create,\n get,\n update\n };\n};\n"],"mappings":";;;;;;;;AAQA;AACA;AACA;AAMA,MAAMA,eAAe,GAAIC,QAAqB,IAAoB;EAC9D,mEACOA,QAAQ;IACXC,sBAAsB,EAAED,QAAQ,CAACC,sBAAsB,CAACC,WAAW;EAAE;AAE7E,CAAC;AAED,MAAMC,iBAAiB,GAAIH,QAAwB,IAAyB;EACxE,IAAI,CAACA,QAAQ,EAAE;IACX,OAAO,IAAI;EACf;EACA,IAAIC,sBAAsB;EAC1B,IAAI;IACAA,sBAAsB,GAAG,IAAIG,IAAI,CAACJ,QAAQ,CAACC,sBAAsB,CAAC;EACtE,CAAC,CAAC,MAAM;IACJA,sBAAsB,GAAG,IAAIG,IAAI,EAAE;EACvC;EACA,mEACOJ,QAAQ;IACXC;EAAsB;AAE9B,CAAC;AAOD,MAAMI,kBAAkB,GAAG,CAAC;EAAEC,MAAM;EAAEC;AAA2B,CAAC,KAAa;EAC3E,OAAQ,KAAID,MAAO,MAAKC,MAAO,eAAc;AACjD,CAAC;AAED,MAAMC,aAAa,GAAG,MAAc;EAChC,OAAO,UAAU;AACrB,CAAC;AAMD,MAAMC,UAAU,GAAIC,MAA0B,IAAW;EACrD,OAAO;IACHC,EAAE,EAAEN,kBAAkB,CAACK,MAAM,CAAC;IAC9B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