@webiny/api-headless-cms 5.32.0 → 5.33.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 (108) hide show
  1. package/crud/contentEntry/entryDataValidation.js +1 -0
  2. package/crud/contentEntry/entryDataValidation.js.map +1 -1
  3. package/crud/contentEntry/markLockedFields.js +2 -2
  4. package/crud/contentEntry/markLockedFields.js.map +1 -1
  5. package/crud/contentEntry.crud.js +170 -60
  6. package/crud/contentEntry.crud.js.map +1 -1
  7. package/crud/contentModel/beforeCreate.js +11 -4
  8. package/crud/contentModel/beforeCreate.js.map +1 -1
  9. package/crud/contentModel/beforeDelete.js +6 -1
  10. package/crud/contentModel/beforeDelete.js.map +1 -1
  11. package/crud/contentModel/beforeUpdate.js +18 -4
  12. package/crud/contentModel/beforeUpdate.js.map +1 -1
  13. package/crud/contentModel/createFieldStorageId.d.ts +2 -0
  14. package/crud/contentModel/createFieldStorageId.js +16 -0
  15. package/crud/contentModel/createFieldStorageId.js.map +1 -0
  16. package/crud/contentModel/fieldIdValidation.d.ts +1 -0
  17. package/crud/contentModel/fieldIdValidation.js +25 -0
  18. package/crud/contentModel/fieldIdValidation.js.map +1 -0
  19. package/crud/contentModel/models.js +9 -8
  20. package/crud/contentModel/models.js.map +1 -1
  21. package/crud/contentModel/systemFields.d.ts +1 -0
  22. package/crud/contentModel/systemFields.js +8 -0
  23. package/crud/contentModel/systemFields.js.map +1 -0
  24. package/crud/contentModel/validateLayout.d.ts +1 -1
  25. package/crud/contentModel/validateLayout.js +1 -2
  26. package/crud/contentModel/validateLayout.js.map +1 -1
  27. package/crud/contentModel/validateModel.d.ts +9 -0
  28. package/crud/contentModel/validateModel.js +32 -0
  29. package/crud/contentModel/validateModel.js.map +1 -0
  30. package/crud/contentModel/validateModelFields.d.ts +3 -2
  31. package/crud/contentModel/validateModelFields.js +200 -38
  32. package/crud/contentModel/validateModelFields.js.map +1 -1
  33. package/crud/contentModel.crud.js +59 -5
  34. package/crud/contentModel.crud.js.map +1 -1
  35. package/crud/contentModelGroup/beforeCreate.js +3 -3
  36. package/crud/contentModelGroup/beforeCreate.js.map +1 -1
  37. package/fieldConverters/CmsModelDefaultFieldConverterPlugin.d.ts +7 -0
  38. package/fieldConverters/CmsModelDefaultFieldConverterPlugin.js +66 -0
  39. package/fieldConverters/CmsModelDefaultFieldConverterPlugin.js.map +1 -0
  40. package/fieldConverters/CmsModelObjectFieldConverterPlugin.d.ts +11 -0
  41. package/fieldConverters/CmsModelObjectFieldConverterPlugin.js +306 -0
  42. package/fieldConverters/CmsModelObjectFieldConverterPlugin.js.map +1 -0
  43. package/fieldConverters/index.d.ts +3 -0
  44. package/fieldConverters/index.js +16 -0
  45. package/fieldConverters/index.js.map +1 -0
  46. package/graphql/index.d.ts +1 -1
  47. package/graphql/schema/contentModels.js +6 -0
  48. package/graphql/schema/contentModels.js.map +1 -1
  49. package/graphql/schema/createFieldResolvers.js +13 -1
  50. package/graphql/schema/createFieldResolvers.js.map +1 -1
  51. package/graphql/schema/createReadSDL.js +3 -2
  52. package/graphql/schema/createReadSDL.js.map +1 -1
  53. package/graphql/schema/schemaPlugins.js +7 -1
  54. package/graphql/schema/schemaPlugins.js.map +1 -1
  55. package/graphqlFields/datetime.js +6 -1
  56. package/graphqlFields/datetime.js.map +1 -1
  57. package/graphqlFields/helpers.js +1 -1
  58. package/graphqlFields/helpers.js.map +1 -1
  59. package/graphqlFields/object.js +1 -1
  60. package/graphqlFields/object.js.map +1 -1
  61. package/index.d.ts +2 -2
  62. package/index.js +3 -1
  63. package/index.js.map +1 -1
  64. package/package.json +24 -24
  65. package/plugins/CmsGroupPlugin.d.ts +1 -1
  66. package/plugins/CmsGroupPlugin.js.map +1 -1
  67. package/plugins/CmsModelFieldConverterPlugin.d.ts +14 -0
  68. package/plugins/CmsModelFieldConverterPlugin.js +17 -0
  69. package/plugins/CmsModelFieldConverterPlugin.js.map +1 -0
  70. package/plugins/CmsModelPlugin.d.ts +32 -4
  71. package/plugins/CmsModelPlugin.js +160 -1
  72. package/plugins/CmsModelPlugin.js.map +1 -1
  73. package/plugins/index.d.ts +1 -0
  74. package/plugins/index.js +13 -0
  75. package/plugins/index.js.map +1 -1
  76. package/types.d.ts +143 -81
  77. package/types.js +24 -0
  78. package/types.js.map +1 -1
  79. package/upgrades/5.33.0/index.d.ts +3 -0
  80. package/upgrades/5.33.0/index.js +186 -0
  81. package/upgrades/5.33.0/index.js.map +1 -0
  82. package/upgrades/index.d.ts +1 -1
  83. package/upgrades/index.js +3 -1
  84. package/upgrades/index.js.map +1 -1
  85. package/utils/converters/Converter.d.ts +27 -0
  86. package/utils/converters/Converter.js +71 -0
  87. package/utils/converters/Converter.js.map +1 -0
  88. package/utils/converters/ConverterCollection.d.ts +24 -0
  89. package/utils/converters/ConverterCollection.js +115 -0
  90. package/utils/converters/ConverterCollection.js.map +1 -0
  91. package/utils/converters/valueKeyStorageConverter.d.ts +18 -0
  92. package/utils/converters/valueKeyStorageConverter.js +152 -0
  93. package/utils/converters/valueKeyStorageConverter.js.map +1 -0
  94. package/utils/filterModelFields.d.ts +16 -0
  95. package/utils/filterModelFields.js +81 -0
  96. package/utils/filterModelFields.js.map +1 -0
  97. package/utils/getEntryTitle.js +6 -5
  98. package/utils/getEntryTitle.js.map +1 -1
  99. package/utils/ownership.js +4 -2
  100. package/utils/ownership.js.map +1 -1
  101. package/utils/renderGetFilterFields.js +3 -3
  102. package/utils/renderGetFilterFields.js.map +1 -1
  103. package/utils/renderListFilterFields.js +6 -5
  104. package/utils/renderListFilterFields.js.map +1 -1
  105. package/utils/renderSortEnum.js +4 -4
  106. package/utils/renderSortEnum.js.map +1 -1
  107. package/validators/unique.js +1 -0
  108. package/validators/unique.js.map +1 -1
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.Converter = void 0;
9
+
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+
12
+ var _error = _interopRequireDefault(require("@webiny/error"));
13
+
14
+ class Converter {
15
+ constructor(config) {
16
+ (0, _defineProperty2.default)(this, "type", void 0);
17
+ (0, _defineProperty2.default)(this, "plugin", void 0);
18
+ (0, _defineProperty2.default)(this, "converters", undefined);
19
+ this.type = config.type;
20
+ this.plugin = config.plugin;
21
+ }
22
+
23
+ setConverterCollection(converters) {
24
+ if (this.converters) {
25
+ throw new _error.default(`Cannot attach converters collection more than once to Converter with type "${this.type}".`, "CONVERTER_COLLECTION_ERROR", {
26
+ type: this.type
27
+ });
28
+ }
29
+
30
+ this.converters = converters;
31
+ }
32
+
33
+ getConverterCollection() {
34
+ if (!this.converters) {
35
+ throw new _error.default(`There is no ConverterCollection defined in the converter with type "${this.type}".`);
36
+ }
37
+
38
+ return this.converters;
39
+ }
40
+
41
+ getType() {
42
+ return this.type;
43
+ }
44
+
45
+ convertToStorage(params) {
46
+ const {
47
+ field,
48
+ value
49
+ } = params;
50
+ return this.plugin.convertToStorage({
51
+ field,
52
+ value,
53
+ converterCollection: this.getConverterCollection()
54
+ });
55
+ }
56
+
57
+ convertFromStorage(params) {
58
+ const {
59
+ field,
60
+ value
61
+ } = params;
62
+ return this.plugin.convertFromStorage({
63
+ field,
64
+ value,
65
+ converterCollection: this.getConverterCollection()
66
+ });
67
+ }
68
+
69
+ }
70
+
71
+ exports.Converter = Converter;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Converter","constructor","config","undefined","type","plugin","setConverterCollection","converters","WebinyError","getConverterCollection","getType","convertToStorage","params","field","value","converterCollection","convertFromStorage"],"sources":["Converter.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsEntryValues, CmsModelField } from \"~/types\";\nimport { CmsModelFieldConverterPlugin } from \"~/plugins\";\nimport { ConverterCollection } from \"./ConverterCollection\";\n\nexport interface CmsModelFieldWithParent extends CmsModelField {\n parent?: CmsModelFieldWithParent | null;\n}\n\ninterface ConverterConvertParams {\n field: CmsModelFieldWithParent;\n value: any;\n parent?: CmsModelFieldWithParent | null;\n}\nexport interface ConverterConfig {\n type: string;\n plugin: CmsModelFieldConverterPlugin;\n}\nexport class Converter {\n private readonly type: string;\n private readonly plugin: CmsModelFieldConverterPlugin;\n\n private converters: ConverterCollection | undefined = undefined;\n\n public constructor(config: ConverterConfig) {\n this.type = config.type;\n this.plugin = config.plugin;\n }\n\n public setConverterCollection(converters: ConverterCollection): void {\n if (this.converters) {\n throw new WebinyError(\n `Cannot attach converters collection more than once to Converter with type \"${this.type}\".`,\n \"CONVERTER_COLLECTION_ERROR\",\n {\n type: this.type\n }\n );\n }\n this.converters = converters;\n }\n\n public getConverterCollection(): ConverterCollection {\n if (!this.converters) {\n throw new WebinyError(\n `There is no ConverterCollection defined in the converter with type \"${this.type}\".`\n );\n }\n return this.converters;\n }\n\n public getType(): string {\n return this.type;\n }\n\n public convertToStorage(params: ConverterConvertParams): CmsEntryValues {\n const { field, value } = params;\n\n return this.plugin.convertToStorage({\n field,\n value,\n converterCollection: this.getConverterCollection()\n });\n }\n\n public convertFromStorage(params: ConverterConvertParams): CmsEntryValues {\n const { field, value } = params;\n\n return this.plugin.convertFromStorage({\n field,\n value,\n converterCollection: this.getConverterCollection()\n });\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA;;AAkBO,MAAMA,SAAN,CAAgB;EAMZC,WAAW,CAACC,MAAD,EAA0B;IAAA;IAAA;IAAA,kDAFUC,SAEV;IACxC,KAAKC,IAAL,GAAYF,MAAM,CAACE,IAAnB;IACA,KAAKC,MAAL,GAAcH,MAAM,CAACG,MAArB;EACH;;EAEMC,sBAAsB,CAACC,UAAD,EAAwC;IACjE,IAAI,KAAKA,UAAT,EAAqB;MACjB,MAAM,IAAIC,cAAJ,CACD,8EAA6E,KAAKJ,IAAK,IADtF,EAEF,4BAFE,EAGF;QACIA,IAAI,EAAE,KAAKA;MADf,CAHE,CAAN;IAOH;;IACD,KAAKG,UAAL,GAAkBA,UAAlB;EACH;;EAEME,sBAAsB,GAAwB;IACjD,IAAI,CAAC,KAAKF,UAAV,EAAsB;MAClB,MAAM,IAAIC,cAAJ,CACD,uEAAsE,KAAKJ,IAAK,IAD/E,CAAN;IAGH;;IACD,OAAO,KAAKG,UAAZ;EACH;;EAEMG,OAAO,GAAW;IACrB,OAAO,KAAKN,IAAZ;EACH;;EAEMO,gBAAgB,CAACC,MAAD,EAAiD;IACpE,MAAM;MAAEC,KAAF;MAASC;IAAT,IAAmBF,MAAzB;IAEA,OAAO,KAAKP,MAAL,CAAYM,gBAAZ,CAA6B;MAChCE,KADgC;MAEhCC,KAFgC;MAGhCC,mBAAmB,EAAE,KAAKN,sBAAL;IAHW,CAA7B,CAAP;EAKH;;EAEMO,kBAAkB,CAACJ,MAAD,EAAiD;IACtE,MAAM;MAAEC,KAAF;MAASC;IAAT,IAAmBF,MAAzB;IAEA,OAAO,KAAKP,MAAL,CAAYW,kBAAZ,CAA+B;MAClCH,KADkC;MAElCC,KAFkC;MAGlCC,mBAAmB,EAAE,KAAKN,sBAAL;IAHa,CAA/B,CAAP;EAKH;;AAvDkB"}
@@ -0,0 +1,24 @@
1
+ import { Converter } from "./Converter";
2
+ import { CmsEntryValues, CmsModelField } from "../../types";
3
+ import { PluginsContainer } from "@webiny/plugins";
4
+ export interface CmsModelFieldsWithParent extends CmsModelField {
5
+ parent?: CmsModelField | null;
6
+ }
7
+ export interface CmsModelConverterCallable {
8
+ (params: ConverterCollectionConvertParams): CmsEntryValues;
9
+ }
10
+ export interface ConverterCollectionConvertParams {
11
+ fields: CmsModelFieldsWithParent[];
12
+ values?: CmsEntryValues;
13
+ }
14
+ export interface ConverterCollectionParams {
15
+ plugins: PluginsContainer;
16
+ }
17
+ export declare class ConverterCollection {
18
+ private readonly converters;
19
+ constructor(params: ConverterCollectionParams);
20
+ addConverter(converter: Converter): void;
21
+ getConverter(type: string): Converter;
22
+ convertToStorage(params: ConverterCollectionConvertParams): CmsEntryValues | undefined;
23
+ convertFromStorage(params: ConverterCollectionConvertParams): CmsEntryValues | undefined;
24
+ }
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.ConverterCollection = void 0;
9
+
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+
12
+ var _error = _interopRequireDefault(require("@webiny/error"));
13
+
14
+ var _Converter = require("./Converter");
15
+
16
+ var _plugins = require("../../plugins");
17
+
18
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); 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 = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
21
+
22
+ class ConverterCollection {
23
+ constructor(params) {
24
+ (0, _defineProperty2.default)(this, "converters", new Map());
25
+ const {
26
+ plugins
27
+ } = params;
28
+ const fieldGraphQLPlugins = plugins.byType("cms-model-field-to-graphql");
29
+ const fieldConverterPlugins = plugins.byType(_plugins.CmsModelFieldConverterPlugin.type);
30
+ const defaultFieldConverterPlugin = fieldConverterPlugins.find(pl => pl.getFieldType() === "*");
31
+
32
+ if (defaultFieldConverterPlugin === undefined) {
33
+ throw new _error.default(`Missing default field converter plugin.`, "DEFAULT_FIELD_CONVERTER_ERROR");
34
+ }
35
+
36
+ for (const fieldGraphQLPlugin of fieldGraphQLPlugins) {
37
+ const plugin = fieldConverterPlugins.find(pl => pl.getFieldType() === fieldGraphQLPlugin.fieldType);
38
+ const converter = new _Converter.Converter({
39
+ type: fieldGraphQLPlugin.fieldType,
40
+ plugin: plugin || defaultFieldConverterPlugin
41
+ });
42
+ this.addConverter(converter);
43
+ }
44
+ }
45
+
46
+ addConverter(converter) {
47
+ converter.setConverterCollection(this);
48
+ this.converters.set(converter.getType(), converter);
49
+ }
50
+
51
+ getConverter(type) {
52
+ const converter = this.converters.get(type);
53
+
54
+ if (converter === undefined) {
55
+ throw new _error.default(`Missing converter for field type "${type}".`, "CONVERTER_ERROR", {
56
+ type
57
+ });
58
+ }
59
+
60
+ return converter;
61
+ }
62
+
63
+ convertToStorage(params) {
64
+ const {
65
+ fields,
66
+ values: inputValues
67
+ } = params;
68
+
69
+ if (inputValues === undefined) {
70
+ return undefined;
71
+ }
72
+
73
+ return fields.reduce((output, field) => {
74
+ const converter = this.getConverter(field.type);
75
+
76
+ if (inputValues === null || inputValues.hasOwnProperty(field.fieldId) === false) {
77
+ return output;
78
+ }
79
+
80
+ const values = converter.convertToStorage({
81
+ field,
82
+ value: inputValues[field.fieldId]
83
+ });
84
+ return _objectSpread(_objectSpread({}, output), values);
85
+ }, {});
86
+ }
87
+
88
+ convertFromStorage(params) {
89
+ const {
90
+ fields,
91
+ values: inputValues
92
+ } = params;
93
+
94
+ if (inputValues === undefined) {
95
+ return undefined;
96
+ }
97
+
98
+ return fields.reduce((output, field) => {
99
+ const converter = this.getConverter(field.type);
100
+
101
+ if (inputValues === null || inputValues.hasOwnProperty(field.storageId) === false) {
102
+ return output;
103
+ }
104
+
105
+ const values = converter.convertFromStorage({
106
+ field,
107
+ value: inputValues[field.storageId]
108
+ });
109
+ return _objectSpread(_objectSpread({}, output), values);
110
+ }, {});
111
+ }
112
+
113
+ }
114
+
115
+ exports.ConverterCollection = ConverterCollection;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ConverterCollection","constructor","params","Map","plugins","fieldGraphQLPlugins","byType","fieldConverterPlugins","CmsModelFieldConverterPlugin","type","defaultFieldConverterPlugin","find","pl","getFieldType","undefined","WebinyError","fieldGraphQLPlugin","plugin","fieldType","converter","Converter","addConverter","setConverterCollection","converters","set","getType","getConverter","get","convertToStorage","fields","values","inputValues","reduce","output","field","hasOwnProperty","fieldId","value","convertFromStorage","storageId"],"sources":["ConverterCollection.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { Converter } from \"./Converter\";\nimport { CmsEntryValues, CmsModelField, CmsModelFieldToGraphQLPlugin } from \"~/types\";\nimport { CmsModelFieldConverterPlugin } from \"~/plugins\";\nimport { PluginsContainer } from \"@webiny/plugins\";\n\nexport interface CmsModelFieldsWithParent extends CmsModelField {\n parent?: CmsModelField | null;\n}\n\nexport interface CmsModelConverterCallable {\n (params: ConverterCollectionConvertParams): CmsEntryValues;\n}\n\nexport interface ConverterCollectionConvertParams {\n fields: CmsModelFieldsWithParent[];\n values?: CmsEntryValues;\n}\n\nexport interface ConverterCollectionParams {\n plugins: PluginsContainer;\n}\n\nexport class ConverterCollection {\n private readonly converters: Map<string, Converter> = new Map();\n\n public constructor(params: ConverterCollectionParams) {\n const { plugins } = params;\n const fieldGraphQLPlugins = plugins.byType<CmsModelFieldToGraphQLPlugin>(\n \"cms-model-field-to-graphql\"\n );\n const fieldConverterPlugins = plugins.byType<CmsModelFieldConverterPlugin>(\n CmsModelFieldConverterPlugin.type\n );\n const defaultFieldConverterPlugin = fieldConverterPlugins.find(\n pl => pl.getFieldType() === \"*\"\n );\n if (defaultFieldConverterPlugin === undefined) {\n throw new WebinyError(\n `Missing default field converter plugin.`,\n \"DEFAULT_FIELD_CONVERTER_ERROR\"\n );\n }\n for (const fieldGraphQLPlugin of fieldGraphQLPlugins) {\n const plugin = fieldConverterPlugins.find(\n pl => pl.getFieldType() === fieldGraphQLPlugin.fieldType\n );\n const converter = new Converter({\n type: fieldGraphQLPlugin.fieldType,\n plugin: plugin || defaultFieldConverterPlugin\n });\n\n this.addConverter(converter);\n }\n }\n\n public addConverter(converter: Converter): void {\n converter.setConverterCollection(this);\n this.converters.set(converter.getType(), converter);\n }\n\n public getConverter(type: string): Converter {\n const converter = this.converters.get(type);\n if (converter === undefined) {\n throw new WebinyError(\n `Missing converter for field type \"${type}\".`,\n \"CONVERTER_ERROR\",\n {\n type\n }\n );\n }\n return converter;\n }\n\n public convertToStorage(params: ConverterCollectionConvertParams): CmsEntryValues | undefined {\n const { fields, values: inputValues } = params;\n if (inputValues === undefined) {\n return undefined;\n }\n\n return fields.reduce<CmsEntryValues>((output, field) => {\n const converter = this.getConverter(field.type);\n if (inputValues === null || inputValues.hasOwnProperty(field.fieldId) === false) {\n return output;\n }\n const values = converter.convertToStorage({\n field,\n value: inputValues[field.fieldId]\n });\n\n return {\n ...output,\n ...values\n };\n }, {});\n }\n\n public convertFromStorage(\n params: ConverterCollectionConvertParams\n ): CmsEntryValues | undefined {\n const { fields, values: inputValues } = params;\n if (inputValues === undefined) {\n return undefined;\n }\n\n return fields.reduce((output, field) => {\n const converter = this.getConverter(field.type);\n if (inputValues === null || inputValues.hasOwnProperty(field.storageId) === false) {\n return output;\n }\n const values = converter.convertFromStorage({\n field,\n value: inputValues[field.storageId]\n });\n\n return {\n ...output,\n ...values\n };\n }, {});\n }\n}\n"],"mappings":"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"}
@@ -0,0 +1,18 @@
1
+ import { PluginsContainer } from "@webiny/plugins";
2
+ import { CmsModelConverterCallable } from "./ConverterCollection";
3
+ import { CmsModel, StorageOperationsCmsModel } from "../../types";
4
+ interface Params {
5
+ /**
6
+ * We need a model to determine if the conversion feature is enabled.
7
+ */
8
+ model: CmsModel;
9
+ plugins: PluginsContainer;
10
+ }
11
+ export declare const createValueKeyToStorageConverter: (params: Params) => CmsModelConverterCallable;
12
+ export declare const createValueKeyFromStorageConverter: (params: Params) => CmsModelConverterCallable;
13
+ interface AttachConvertersParams {
14
+ plugins: PluginsContainer;
15
+ model: CmsModel;
16
+ }
17
+ export declare const attachCmsModelFieldConverters: (params: AttachConvertersParams) => StorageOperationsCmsModel;
18
+ export {};
@@ -0,0 +1,152 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.createValueKeyToStorageConverter = exports.createValueKeyFromStorageConverter = exports.attachCmsModelFieldConverters = void 0;
9
+
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+
12
+ var _ConverterCollection = require("./ConverterCollection");
13
+
14
+ var _semver = _interopRequireDefault(require("semver"));
15
+
16
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
17
+
18
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
19
+
20
+ const featureVersion = _semver.default.coerce("5.33.0");
21
+
22
+ const isBetaOrNext = model => {
23
+ if (!model.webinyVersion) {
24
+ return false;
25
+ }
26
+
27
+ return model.webinyVersion.match(/next|beta/) !== null;
28
+ };
29
+
30
+ const isFeatureEnabled = model => {
31
+ /**
32
+ * In case of disabled webinyVersion value, we disable this feature.
33
+ * This is only for testing...
34
+ */
35
+ if (model.webinyVersion === "disable") {
36
+ return false;
37
+ }
38
+ /**
39
+ * If is a test environment, always have this turned on.
40
+ */
41
+
42
+
43
+ if (process.env.NODE_ENV === "test" || isBetaOrNext(model) === true) {
44
+ return true;
45
+ }
46
+ /**
47
+ * Possibility that the version is not defined, this means it is a quite old system where models did not change.
48
+ */
49
+
50
+
51
+ if (!model.webinyVersion) {
52
+ return false;
53
+ }
54
+ /**
55
+ * In case feature version value is greater than the model version, feature is not enabled as it is an older model with no storageId.
56
+ *
57
+ * TODO change if necessary after the update to the system
58
+ */
59
+
60
+
61
+ const modelVersion = _semver.default.coerce(model.webinyVersion);
62
+
63
+ if (!modelVersion) {
64
+ console.log(`Warning: Model "${model.modelId}" does not have valid Webiny version set.`);
65
+ return true;
66
+ } else if (_semver.default.compare(modelVersion, featureVersion) === -1) {
67
+ return false;
68
+ }
69
+
70
+ return true;
71
+ };
72
+
73
+ const createValueKeyToStorageConverter = params => {
74
+ const {
75
+ plugins,
76
+ model
77
+ } = params;
78
+
79
+ if (isFeatureEnabled(model) === false) {
80
+ return ({
81
+ values
82
+ }) => {
83
+ return values || {};
84
+ };
85
+ }
86
+
87
+ const converters = new _ConverterCollection.ConverterCollection({
88
+ plugins
89
+ });
90
+ return ({
91
+ fields,
92
+ values
93
+ }) => {
94
+ const result = converters.convertToStorage({
95
+ fields: fields || model.fields,
96
+ values
97
+ });
98
+ return result || {};
99
+ };
100
+ };
101
+
102
+ exports.createValueKeyToStorageConverter = createValueKeyToStorageConverter;
103
+
104
+ const createValueKeyFromStorageConverter = params => {
105
+ const {
106
+ plugins,
107
+ model
108
+ } = params;
109
+
110
+ if (isFeatureEnabled(model) === false) {
111
+ return ({
112
+ values
113
+ }) => {
114
+ return values || {};
115
+ };
116
+ }
117
+
118
+ const converters = new _ConverterCollection.ConverterCollection({
119
+ plugins
120
+ });
121
+ return ({
122
+ fields,
123
+ values
124
+ }) => {
125
+ const result = converters.convertFromStorage({
126
+ fields: fields || model.fields,
127
+ values
128
+ });
129
+ return result || {};
130
+ };
131
+ };
132
+
133
+ exports.createValueKeyFromStorageConverter = createValueKeyFromStorageConverter;
134
+
135
+ const attachCmsModelFieldConverters = params => {
136
+ const {
137
+ model,
138
+ plugins
139
+ } = params;
140
+ return _objectSpread(_objectSpread({}, model), {}, {
141
+ convertValueKeyToStorage: createValueKeyToStorageConverter({
142
+ model,
143
+ plugins
144
+ }),
145
+ convertValueKeyFromStorage: createValueKeyFromStorageConverter({
146
+ model,
147
+ plugins
148
+ })
149
+ });
150
+ };
151
+
152
+ exports.attachCmsModelFieldConverters = attachCmsModelFieldConverters;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["featureVersion","semver","coerce","isBetaOrNext","model","webinyVersion","match","isFeatureEnabled","process","env","NODE_ENV","modelVersion","console","log","modelId","compare","createValueKeyToStorageConverter","params","plugins","values","converters","ConverterCollection","fields","result","convertToStorage","createValueKeyFromStorageConverter","convertFromStorage","attachCmsModelFieldConverters","convertValueKeyToStorage","convertValueKeyFromStorage"],"sources":["valueKeyStorageConverter.ts"],"sourcesContent":["import { PluginsContainer } from \"@webiny/plugins\";\nimport {\n CmsModelConverterCallable,\n ConverterCollection,\n ConverterCollectionConvertParams as BaseConverterCollectionConvertParams\n} from \"~/utils/converters/ConverterCollection\";\nimport { CmsModel, StorageOperationsCmsModel } from \"~/types\";\nimport semver, { SemVer } from \"semver\";\n\nconst featureVersion = semver.coerce(\"5.33.0\") as SemVer;\n\nconst isBetaOrNext = (model: CmsModel): boolean => {\n if (!model.webinyVersion) {\n return false;\n }\n return model.webinyVersion.match(/next|beta/) !== null;\n};\n\nconst isFeatureEnabled = (model: CmsModel): boolean => {\n /**\n * In case of disabled webinyVersion value, we disable this feature.\n * This is only for testing...\n */\n if (model.webinyVersion === \"disable\") {\n return false;\n }\n /**\n * If is a test environment, always have this turned on.\n */\n if (process.env.NODE_ENV === \"test\" || isBetaOrNext(model) === true) {\n return true;\n }\n /**\n * Possibility that the version is not defined, this means it is a quite old system where models did not change.\n */\n if (!model.webinyVersion) {\n return false;\n }\n /**\n * In case feature version value is greater than the model version, feature is not enabled as it is an older model with no storageId.\n *\n * TODO change if necessary after the update to the system\n */\n const modelVersion = semver.coerce(model.webinyVersion);\n if (!modelVersion) {\n console.log(`Warning: Model \"${model.modelId}\" does not have valid Webiny version set.`);\n return true;\n } else if (semver.compare(modelVersion, featureVersion) === -1) {\n return false;\n }\n return true;\n};\n\ninterface Params {\n /**\n * We need a model to determine if the conversion feature is enabled.\n */\n model: CmsModel;\n plugins: PluginsContainer;\n}\n\n/**\n * In the first call of the converter we do not need the fields property as it will be taken directly from the model.\n */\ninterface ConverterCollectionConvertParams\n extends Omit<BaseConverterCollectionConvertParams, \"fields\"> {\n fields?: BaseConverterCollectionConvertParams[\"fields\"];\n}\n\nexport const createValueKeyToStorageConverter = (params: Params): CmsModelConverterCallable => {\n const { plugins, model } = params;\n\n if (isFeatureEnabled(model) === false) {\n return ({ values }: ConverterCollectionConvertParams) => {\n return values || {};\n };\n }\n\n const converters = new ConverterCollection({\n plugins\n });\n\n return ({ fields, values }: ConverterCollectionConvertParams) => {\n const result = converters.convertToStorage({\n fields: fields || model.fields,\n values\n });\n return result || {};\n };\n};\n\nexport const createValueKeyFromStorageConverter = (params: Params): CmsModelConverterCallable => {\n const { plugins, model } = params;\n\n if (isFeatureEnabled(model) === false) {\n return ({ values }: ConverterCollectionConvertParams) => {\n return values || {};\n };\n }\n\n const converters = new ConverterCollection({\n plugins\n });\n\n return ({ fields, values }: ConverterCollectionConvertParams) => {\n const result = converters.convertFromStorage({\n fields: fields || model.fields,\n values\n });\n return result || {};\n };\n};\n\ninterface AttachConvertersParams {\n plugins: PluginsContainer;\n model: CmsModel;\n}\nexport const attachCmsModelFieldConverters = (\n params: AttachConvertersParams\n): StorageOperationsCmsModel => {\n const { model, plugins } = params;\n return {\n ...model,\n convertValueKeyToStorage: createValueKeyToStorageConverter({\n model,\n plugins\n }),\n convertValueKeyFromStorage: createValueKeyFromStorageConverter({\n model,\n plugins\n })\n };\n};\n"],"mappings":"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"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * We are leaving this file because isDeleted might come back later
3
+ */
4
+ import { ApiEndpoint, CmsModel } from "../types";
5
+ /**
6
+ * Filters deleted fields from all given models.
7
+ */
8
+ interface FilterModelsDeletedFieldsCallableParams {
9
+ models: CmsModel[];
10
+ type: ApiEndpoint;
11
+ }
12
+ interface FilterModelsDeletedFieldsCallable {
13
+ (params: FilterModelsDeletedFieldsCallableParams): CmsModel[];
14
+ }
15
+ export declare const filterModelsDeletedFields: FilterModelsDeletedFieldsCallable;
16
+ export {};
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.filterModelsDeletedFields = void 0;
9
+
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+
12
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
13
+
14
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
15
+
16
+ /**
17
+ * We are leaving this file because isDeleted might come back later
18
+ */
19
+ // @ts-nocheck
20
+
21
+ /**
22
+ * Filters deleted fields from the list of fields.
23
+ *
24
+ * Used to recursively delete fields - object field.
25
+ */
26
+ const filterDeletedFields = params => {
27
+ return params.fields.reduce((output, field) => {
28
+ var _field$settings;
29
+
30
+ if (!!field.isDeleted) {
31
+ return output;
32
+ } else if ((_field$settings = field.settings) !== null && _field$settings !== void 0 && _field$settings.fields) {
33
+ const fields = filterDeletedFields({
34
+ fields: field.settings.fields
35
+ });
36
+ output.push(_objectSpread(_objectSpread({}, field), {}, {
37
+ settings: _objectSpread(_objectSpread({}, field.settings), {}, {
38
+ fields
39
+ })
40
+ }));
41
+ return output;
42
+ }
43
+
44
+ output.push(field);
45
+ return output;
46
+ }, []);
47
+ };
48
+ /**
49
+ * Filters deleted fields from given model.
50
+ */
51
+
52
+
53
+ const filterModelDeletedFields = ({
54
+ model
55
+ }) => {
56
+ const fields = filterDeletedFields(model);
57
+ return _objectSpread(_objectSpread({}, model), {}, {
58
+ fields
59
+ });
60
+ };
61
+ /**
62
+ * Filters deleted fields from all given models.
63
+ */
64
+
65
+
66
+ const filterModelsDeletedFields = ({
67
+ models,
68
+ type
69
+ }) => {
70
+ if (type === "manage") {
71
+ return models;
72
+ }
73
+
74
+ return models.map(model => {
75
+ return filterModelDeletedFields({
76
+ model
77
+ });
78
+ });
79
+ };
80
+
81
+ exports.filterModelsDeletedFields = filterModelsDeletedFields;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["filterDeletedFields","params","fields","reduce","output","field","isDeleted","settings","push","filterModelDeletedFields","model","filterModelsDeletedFields","models","type","map"],"sources":["filterModelFields.ts"],"sourcesContent":["/**\n * We are leaving this file because isDeleted might come back later\n */\n// @ts-nocheck\nimport { ApiEndpoint, CmsModel, CmsModelField } from \"~/types\";\n\n/**\n * Filters deleted fields from the list of fields.\n *\n * Used to recursively delete fields - object field.\n */\ninterface FilterModelFieldsCallableParams {\n fields: CmsModelField[];\n}\ninterface FilterModelFieldsCallable {\n (params: FilterModelFieldsCallableParams): CmsModelField[];\n}\n\nconst filterDeletedFields: FilterModelFieldsCallable = params => {\n return params.fields.reduce<CmsModelField[]>((output, field) => {\n if (!!field.isDeleted) {\n return output;\n } else if (field.settings?.fields) {\n const fields = filterDeletedFields({\n fields: field.settings.fields\n });\n\n output.push({\n ...field,\n settings: {\n ...field.settings,\n fields\n }\n });\n return output;\n }\n\n output.push(field);\n\n return output;\n }, []);\n};\n\n/**\n * Filters deleted fields from given model.\n */\ninterface FilterModelDeletedFieldsCallableParams {\n model: CmsModel;\n}\ninterface FilterModelDeletedFieldsCallable {\n (params: FilterModelDeletedFieldsCallableParams): CmsModel;\n}\nconst filterModelDeletedFields: FilterModelDeletedFieldsCallable = ({ model }) => {\n const fields = filterDeletedFields(model);\n return {\n ...model,\n fields\n };\n};\n\n/**\n * Filters deleted fields from all given models.\n */\ninterface FilterModelsDeletedFieldsCallableParams {\n models: CmsModel[];\n type: ApiEndpoint;\n}\ninterface FilterModelsDeletedFieldsCallable {\n (params: FilterModelsDeletedFieldsCallableParams): CmsModel[];\n}\nexport const filterModelsDeletedFields: FilterModelsDeletedFieldsCallable = ({ models, type }) => {\n if (type === \"manage\") {\n return models;\n }\n return models.map(model => {\n return filterModelDeletedFields({\n model\n });\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AAQA,MAAMA,mBAA8C,GAAGC,MAAM,IAAI;EAC7D,OAAOA,MAAM,CAACC,MAAP,CAAcC,MAAd,CAAsC,CAACC,MAAD,EAASC,KAAT,KAAmB;IAAA;;IAC5D,IAAI,CAAC,CAACA,KAAK,CAACC,SAAZ,EAAuB;MACnB,OAAOF,MAAP;IACH,CAFD,MAEO,uBAAIC,KAAK,CAACE,QAAV,4CAAI,gBAAgBL,MAApB,EAA4B;MAC/B,MAAMA,MAAM,GAAGF,mBAAmB,CAAC;QAC/BE,MAAM,EAAEG,KAAK,CAACE,QAAN,CAAeL;MADQ,CAAD,CAAlC;MAIAE,MAAM,CAACI,IAAP,iCACOH,KADP;QAEIE,QAAQ,kCACDF,KAAK,CAACE,QADL;UAEJL;QAFI;MAFZ;MAOA,OAAOE,MAAP;IACH;;IAEDA,MAAM,CAACI,IAAP,CAAYH,KAAZ;IAEA,OAAOD,MAAP;EACH,CArBM,EAqBJ,EArBI,CAAP;AAsBH,CAvBD;AAyBA;AACA;AACA;;;AAOA,MAAMK,wBAA0D,GAAG,CAAC;EAAEC;AAAF,CAAD,KAAe;EAC9E,MAAMR,MAAM,GAAGF,mBAAmB,CAACU,KAAD,CAAlC;EACA,uCACOA,KADP;IAEIR;EAFJ;AAIH,CAND;AAQA;AACA;AACA;;;AAQO,MAAMS,yBAA4D,GAAG,CAAC;EAAEC,MAAF;EAAUC;AAAV,CAAD,KAAsB;EAC9F,IAAIA,IAAI,KAAK,QAAb,EAAuB;IACnB,OAAOD,MAAP;EACH;;EACD,OAAOA,MAAM,CAACE,GAAP,CAAWJ,KAAK,IAAI;IACvB,OAAOD,wBAAwB,CAAC;MAC5BC;IAD4B,CAAD,CAA/B;EAGH,CAJM,CAAP;AAKH,CATM"}
@@ -10,16 +10,17 @@ function getEntryTitle(model, entry) {
10
10
  return entry.id;
11
11
  }
12
12
 
13
- const titleValue = entry.values[model.titleFieldId];
13
+ const field = model.fields.find(f => f.fieldId === model.titleFieldId);
14
14
 
15
- if (!titleValue) {
15
+ if (!field) {
16
16
  return entry.id;
17
17
  }
18
18
 
19
- const field = model.fields.find(f => f.fieldId === model.titleFieldId);
19
+ const titleFieldId = field.fieldId;
20
+ const titleValue = entry.values[titleFieldId];
20
21
 
21
- if (!field) {
22
- return titleValue;
22
+ if (!titleValue) {
23
+ return entry.id;
23
24
  }
24
25
 
25
26
  const {
@@ -1 +1 @@
1
- {"version":3,"names":["getEntryTitle","model","entry","titleFieldId","id","titleValue","values","field","fields","find","f","fieldId","enabled","predefinedValues","Array","isArray","value","label"],"sources":["getEntryTitle.ts"],"sourcesContent":["import { CmsEntry, CmsModel } from \"~/types\";\n\nexport function getEntryTitle(model: CmsModel, entry: CmsEntry): string {\n if (!model.titleFieldId) {\n return entry.id;\n }\n const titleValue = entry.values[model.titleFieldId];\n if (!titleValue) {\n return entry.id;\n }\n const field = model.fields.find(f => f.fieldId === model.titleFieldId);\n if (!field) {\n return titleValue;\n }\n const { enabled = false, values } = field.predefinedValues || {};\n if (!enabled || !values || Array.isArray(values) === false) {\n return titleValue;\n }\n for (const value of values) {\n // needs to be loose because titleValue can be a number and value can be a string - but it must match\n if (value.value == titleValue) {\n return value.label;\n }\n }\n return titleValue;\n}\n"],"mappings":";;;;;;;AAEO,SAASA,aAAT,CAAuBC,KAAvB,EAAwCC,KAAxC,EAAiE;EACpE,IAAI,CAACD,KAAK,CAACE,YAAX,EAAyB;IACrB,OAAOD,KAAK,CAACE,EAAb;EACH;;EACD,MAAMC,UAAU,GAAGH,KAAK,CAACI,MAAN,CAAaL,KAAK,CAACE,YAAnB,CAAnB;;EACA,IAAI,CAACE,UAAL,EAAiB;IACb,OAAOH,KAAK,CAACE,EAAb;EACH;;EACD,MAAMG,KAAK,GAAGN,KAAK,CAACO,MAAN,CAAaC,IAAb,CAAkBC,CAAC,IAAIA,CAAC,CAACC,OAAF,KAAcV,KAAK,CAACE,YAA3C,CAAd;;EACA,IAAI,CAACI,KAAL,EAAY;IACR,OAAOF,UAAP;EACH;;EACD,MAAM;IAAEO,OAAO,GAAG,KAAZ;IAAmBN;EAAnB,IAA8BC,KAAK,CAACM,gBAAN,IAA0B,EAA9D;;EACA,IAAI,CAACD,OAAD,IAAY,CAACN,MAAb,IAAuBQ,KAAK,CAACC,OAAN,CAAcT,MAAd,MAA0B,KAArD,EAA4D;IACxD,OAAOD,UAAP;EACH;;EACD,KAAK,MAAMW,KAAX,IAAoBV,MAApB,EAA4B;IACxB;IACA,IAAIU,KAAK,CAACA,KAAN,IAAeX,UAAnB,EAA+B;MAC3B,OAAOW,KAAK,CAACC,KAAb;IACH;EACJ;;EACD,OAAOZ,UAAP;AACH"}
1
+ {"version":3,"names":["getEntryTitle","model","entry","titleFieldId","id","field","fields","find","f","fieldId","titleValue","values","enabled","predefinedValues","Array","isArray","value","label"],"sources":["getEntryTitle.ts"],"sourcesContent":["import { CmsEntry, CmsModel } from \"~/types\";\n\nexport function getEntryTitle(model: CmsModel, entry: CmsEntry): string {\n if (!model.titleFieldId) {\n return entry.id;\n }\n const field = model.fields.find(f => f.fieldId === model.titleFieldId);\n if (!field) {\n return entry.id;\n }\n const titleFieldId = field.fieldId;\n const titleValue = entry.values[titleFieldId];\n if (!titleValue) {\n return entry.id;\n }\n\n const { enabled = false, values } = field.predefinedValues || {};\n if (!enabled || !values || Array.isArray(values) === false) {\n return titleValue;\n }\n for (const value of values) {\n // needs to be loose because titleValue can be a number and value can be a string - but it must match\n if (value.value == titleValue) {\n return value.label;\n }\n }\n return titleValue;\n}\n"],"mappings":";;;;;;;AAEO,SAASA,aAAT,CAAuBC,KAAvB,EAAwCC,KAAxC,EAAiE;EACpE,IAAI,CAACD,KAAK,CAACE,YAAX,EAAyB;IACrB,OAAOD,KAAK,CAACE,EAAb;EACH;;EACD,MAAMC,KAAK,GAAGJ,KAAK,CAACK,MAAN,CAAaC,IAAb,CAAkBC,CAAC,IAAIA,CAAC,CAACC,OAAF,KAAcR,KAAK,CAACE,YAA3C,CAAd;;EACA,IAAI,CAACE,KAAL,EAAY;IACR,OAAOH,KAAK,CAACE,EAAb;EACH;;EACD,MAAMD,YAAY,GAAGE,KAAK,CAACI,OAA3B;EACA,MAAMC,UAAU,GAAGR,KAAK,CAACS,MAAN,CAAaR,YAAb,CAAnB;;EACA,IAAI,CAACO,UAAL,EAAiB;IACb,OAAOR,KAAK,CAACE,EAAb;EACH;;EAED,MAAM;IAAEQ,OAAO,GAAG,KAAZ;IAAmBD;EAAnB,IAA8BN,KAAK,CAACQ,gBAAN,IAA0B,EAA9D;;EACA,IAAI,CAACD,OAAD,IAAY,CAACD,MAAb,IAAuBG,KAAK,CAACC,OAAN,CAAcJ,MAAd,MAA0B,KAArD,EAA4D;IACxD,OAAOD,UAAP;EACH;;EACD,KAAK,MAAMM,KAAX,IAAoBL,MAApB,EAA4B;IACxB;IACA,IAAIK,KAAK,CAACA,KAAN,IAAeN,UAAnB,EAA+B;MAC3B,OAAOM,KAAK,CAACC,KAAb;IACH;EACJ;;EACD,OAAOP,UAAP;AACH"}
@@ -8,13 +8,15 @@ exports.validateOwnership = exports.checkOwnership = void 0;
8
8
  var _apiSecurity = require("@webiny/api-security");
9
9
 
10
10
  const checkOwnership = (context, permission, record) => {
11
+ var _record$ownedBy, _record$createdBy;
12
+
11
13
  if (!permission.own) {
12
14
  return;
13
15
  }
14
16
 
15
17
  const identity = context.security.getIdentity();
16
- const owner = identity && record["ownedBy"] && record["ownedBy"].id === identity.id;
17
- const creator = identity && record["createdBy"] && record["createdBy"].id === identity.id;
18
+ const owner = identity && ((_record$ownedBy = record.ownedBy) === null || _record$ownedBy === void 0 ? void 0 : _record$ownedBy.id) === identity.id;
19
+ const creator = identity && ((_record$createdBy = record.createdBy) === null || _record$createdBy === void 0 ? void 0 : _record$createdBy.id) === identity.id;
18
20
 
19
21
  if (!owner && !creator) {
20
22
  throw new _apiSecurity.NotAuthorizedError({
@@ -1 +1 @@
1
- {"version":3,"names":["checkOwnership","context","permission","record","own","identity","security","getIdentity","owner","id","creator","NotAuthorizedError","data","reason","validateOwnership"],"sources":["ownership.ts"],"sourcesContent":["import { BaseCmsSecurityPermission, CmsContext, CreatedBy } from \"~/types\";\nimport { NotAuthorizedError } from \"@webiny/api-security\";\n\ninterface OwnableRecord {\n createdBy?: CreatedBy;\n ownedBy?: CreatedBy;\n}\n\nexport const checkOwnership = (\n context: CmsContext,\n permission: BaseCmsSecurityPermission,\n record: OwnableRecord\n): void => {\n if (!permission.own) {\n return;\n }\n\n const identity = context.security.getIdentity();\n const owner = identity && record[\"ownedBy\"] && record[\"ownedBy\"].id === identity.id;\n const creator = identity && record[\"createdBy\"] && record[\"createdBy\"].id === identity.id;\n\n if (!owner && !creator) {\n throw new NotAuthorizedError({\n data: {\n reason: `You are not the owner of the record.`\n }\n });\n }\n};\n\nexport const validateOwnership = (\n context: CmsContext,\n permission: BaseCmsSecurityPermission,\n record: OwnableRecord\n): boolean => {\n try {\n checkOwnership(context, permission, record);\n return true;\n } catch {\n return false;\n }\n};\n"],"mappings":";;;;;;;AACA;;AAOO,MAAMA,cAAc,GAAG,CAC1BC,OAD0B,EAE1BC,UAF0B,EAG1BC,MAH0B,KAInB;EACP,IAAI,CAACD,UAAU,CAACE,GAAhB,EAAqB;IACjB;EACH;;EAED,MAAMC,QAAQ,GAAGJ,OAAO,CAACK,QAAR,CAAiBC,WAAjB,EAAjB;EACA,MAAMC,KAAK,GAAGH,QAAQ,IAAIF,MAAM,CAAC,SAAD,CAAlB,IAAiCA,MAAM,CAAC,SAAD,CAAN,CAAkBM,EAAlB,KAAyBJ,QAAQ,CAACI,EAAjF;EACA,MAAMC,OAAO,GAAGL,QAAQ,IAAIF,MAAM,CAAC,WAAD,CAAlB,IAAmCA,MAAM,CAAC,WAAD,CAAN,CAAoBM,EAApB,KAA2BJ,QAAQ,CAACI,EAAvF;;EAEA,IAAI,CAACD,KAAD,IAAU,CAACE,OAAf,EAAwB;IACpB,MAAM,IAAIC,+BAAJ,CAAuB;MACzBC,IAAI,EAAE;QACFC,MAAM,EAAG;MADP;IADmB,CAAvB,CAAN;EAKH;AACJ,CApBM;;;;AAsBA,MAAMC,iBAAiB,GAAG,CAC7Bb,OAD6B,EAE7BC,UAF6B,EAG7BC,MAH6B,KAInB;EACV,IAAI;IACAH,cAAc,CAACC,OAAD,EAAUC,UAAV,EAAsBC,MAAtB,CAAd;IACA,OAAO,IAAP;EACH,CAHD,CAGE,MAAM;IACJ,OAAO,KAAP;EACH;AACJ,CAXM"}
1
+ {"version":3,"names":["checkOwnership","context","permission","record","own","identity","security","getIdentity","owner","ownedBy","id","creator","createdBy","NotAuthorizedError","data","reason","validateOwnership"],"sources":["ownership.ts"],"sourcesContent":["import { BaseCmsSecurityPermission, CmsContext, CreatedBy } from \"~/types\";\nimport { NotAuthorizedError } from \"@webiny/api-security\";\n\ninterface OwnableRecord {\n createdBy?: CreatedBy;\n ownedBy?: CreatedBy;\n}\n\nexport const checkOwnership = (\n context: CmsContext,\n permission: BaseCmsSecurityPermission,\n record: OwnableRecord\n): void => {\n if (!permission.own) {\n return;\n }\n\n const identity = context.security.getIdentity();\n const owner = identity && record.ownedBy?.id === identity.id;\n const creator = identity && record.createdBy?.id === identity.id;\n\n if (!owner && !creator) {\n throw new NotAuthorizedError({\n data: {\n reason: `You are not the owner of the record.`\n }\n });\n }\n};\n\nexport const validateOwnership = (\n context: CmsContext,\n permission: BaseCmsSecurityPermission,\n record: OwnableRecord\n): boolean => {\n try {\n checkOwnership(context, permission, record);\n return true;\n } catch {\n return false;\n }\n};\n"],"mappings":";;;;;;;AACA;;AAOO,MAAMA,cAAc,GAAG,CAC1BC,OAD0B,EAE1BC,UAF0B,EAG1BC,MAH0B,KAInB;EAAA;;EACP,IAAI,CAACD,UAAU,CAACE,GAAhB,EAAqB;IACjB;EACH;;EAED,MAAMC,QAAQ,GAAGJ,OAAO,CAACK,QAAR,CAAiBC,WAAjB,EAAjB;EACA,MAAMC,KAAK,GAAGH,QAAQ,IAAI,oBAAAF,MAAM,CAACM,OAAP,oEAAgBC,EAAhB,MAAuBL,QAAQ,CAACK,EAA1D;EACA,MAAMC,OAAO,GAAGN,QAAQ,IAAI,sBAAAF,MAAM,CAACS,SAAP,wEAAkBF,EAAlB,MAAyBL,QAAQ,CAACK,EAA9D;;EAEA,IAAI,CAACF,KAAD,IAAU,CAACG,OAAf,EAAwB;IACpB,MAAM,IAAIE,+BAAJ,CAAuB;MACzBC,IAAI,EAAE;QACFC,MAAM,EAAG;MADP;IADmB,CAAvB,CAAN;EAKH;AACJ,CApBM;;;;AAsBA,MAAMC,iBAAiB,GAAG,CAC7Bf,OAD6B,EAE7BC,UAF6B,EAG7BC,MAH6B,KAInB;EACV,IAAI;IACAH,cAAc,CAACC,OAAD,EAAUC,UAAV,EAAsBC,MAAtB,CAAd;IACA,OAAO,IAAP;EACH,CAHD,CAGE,MAAM;IACJ,OAAO,KAAP;EACH;AACJ,CAXM"}
@@ -17,7 +17,7 @@ const renderGetFilterFields = ({
17
17
  model,
18
18
  fieldTypePlugins
19
19
  }) => {
20
- const fieldIds = model.fields.filter(field => {
20
+ const fieldIdList = model.fields.filter(field => {
21
21
  // Every time a client updates content model's fields, we check the type of each field. If a field plugin
22
22
  // for a particular "field.type" doesn't exist on the backend yet, we throw an error. But still, we also
23
23
  // want to be careful when accessing the field plugin here too. It is still possible to have a content model
@@ -31,8 +31,8 @@ const renderGetFilterFields = ({
31
31
  }).map(f => f.fieldId);
32
32
  const filters = ["id: ID", "entryId: String"];
33
33
 
34
- for (const id of fieldIds) {
35
- const field = model.fields.find(item => item.fieldId === id);
34
+ for (const fieldId of fieldIdList) {
35
+ const field = model.fields.find(item => item.fieldId === fieldId);
36
36
 
37
37
  if (!field) {
38
38
  continue;
@@ -1 +1 @@
1
- {"version":3,"names":["getCreateFilters","plugins","fieldType","read","createGetFilters","renderGetFilterFields","model","fieldTypePlugins","fieldIds","fields","filter","field","type","isSearchable","map","f","fieldId","filters","id","find","item","push","Boolean","join"],"sources":["renderGetFilterFields.ts"],"sourcesContent":["import { CmsFieldTypePlugins, CmsModel, CmsModelFieldToGraphQLPlugin } from \"~/types\";\n\ninterface RenderGetFilterFieldsParams {\n model: CmsModel;\n fieldTypePlugins: CmsFieldTypePlugins;\n}\ninterface RenderGetFilterFields {\n (params: RenderGetFilterFieldsParams): string;\n}\n\nconst getCreateFilters = (\n plugins: CmsFieldTypePlugins,\n fieldType: string\n): CmsModelFieldToGraphQLPlugin[\"read\"][\"createGetFilters\"] | null => {\n if (!plugins[fieldType] || !plugins[fieldType].read.createGetFilters) {\n return null;\n }\n return plugins[fieldType].read.createGetFilters;\n};\n\nexport const renderGetFilterFields: RenderGetFilterFields = ({ model, fieldTypePlugins }) => {\n const fieldIds = model.fields\n .filter(field => {\n // Every time a client updates content model's fields, we check the type of each field. If a field plugin\n // for a particular \"field.type\" doesn't exist on the backend yet, we throw an error. But still, we also\n // want to be careful when accessing the field plugin here too. It is still possible to have a content model\n // that contains a field, for which we don't have a plugin registered on the backend. For example, user\n // could've just removed the plugin from the backend.\n if (!fieldTypePlugins[field.type]) {\n return false;\n }\n return fieldTypePlugins[field.type].isSearchable;\n })\n .map(f => f.fieldId);\n\n const filters: string[] = [\"id: ID\", \"entryId: String\"];\n\n for (const id of fieldIds) {\n const field = model.fields.find(item => item.fieldId === id);\n if (!field) {\n continue;\n }\n const createGetFilters = getCreateFilters(fieldTypePlugins, field.type);\n if (typeof createGetFilters !== \"function\") {\n continue;\n }\n filters.push(createGetFilters({ model, field }));\n }\n\n return filters.filter(Boolean).join(\"\\n\");\n};\n"],"mappings":";;;;;;;AAUA,MAAMA,gBAAgB,GAAG,CACrBC,OADqB,EAErBC,SAFqB,KAG6C;EAClE,IAAI,CAACD,OAAO,CAACC,SAAD,CAAR,IAAuB,CAACD,OAAO,CAACC,SAAD,CAAP,CAAmBC,IAAnB,CAAwBC,gBAApD,EAAsE;IAClE,OAAO,IAAP;EACH;;EACD,OAAOH,OAAO,CAACC,SAAD,CAAP,CAAmBC,IAAnB,CAAwBC,gBAA/B;AACH,CARD;;AAUO,MAAMC,qBAA4C,GAAG,CAAC;EAAEC,KAAF;EAASC;AAAT,CAAD,KAAiC;EACzF,MAAMC,QAAQ,GAAGF,KAAK,CAACG,MAAN,CACZC,MADY,CACLC,KAAK,IAAI;IACb;IACA;IACA;IACA;IACA;IACA,IAAI,CAACJ,gBAAgB,CAACI,KAAK,CAACC,IAAP,CAArB,EAAmC;MAC/B,OAAO,KAAP;IACH;;IACD,OAAOL,gBAAgB,CAACI,KAAK,CAACC,IAAP,CAAhB,CAA6BC,YAApC;EACH,CAXY,EAYZC,GAZY,CAYRC,CAAC,IAAIA,CAAC,CAACC,OAZC,CAAjB;EAcA,MAAMC,OAAiB,GAAG,CAAC,QAAD,EAAW,iBAAX,CAA1B;;EAEA,KAAK,MAAMC,EAAX,IAAiBV,QAAjB,EAA2B;IACvB,MAAMG,KAAK,GAAGL,KAAK,CAACG,MAAN,CAAaU,IAAb,CAAkBC,IAAI,IAAIA,IAAI,CAACJ,OAAL,KAAiBE,EAA3C,CAAd;;IACA,IAAI,CAACP,KAAL,EAAY;MACR;IACH;;IACD,MAAMP,gBAAgB,GAAGJ,gBAAgB,CAACO,gBAAD,EAAmBI,KAAK,CAACC,IAAzB,CAAzC;;IACA,IAAI,OAAOR,gBAAP,KAA4B,UAAhC,EAA4C;MACxC;IACH;;IACDa,OAAO,CAACI,IAAR,CAAajB,gBAAgB,CAAC;MAAEE,KAAF;MAASK;IAAT,CAAD,CAA7B;EACH;;EAED,OAAOM,OAAO,CAACP,MAAR,CAAeY,OAAf,EAAwBC,IAAxB,CAA6B,IAA7B,CAAP;AACH,CA9BM"}
1
+ {"version":3,"names":["getCreateFilters","plugins","fieldType","read","createGetFilters","renderGetFilterFields","model","fieldTypePlugins","fieldIdList","fields","filter","field","type","isSearchable","map","f","fieldId","filters","find","item","push","Boolean","join"],"sources":["renderGetFilterFields.ts"],"sourcesContent":["import { CmsFieldTypePlugins, CmsModel, CmsModelFieldToGraphQLPlugin } from \"~/types\";\n\ninterface RenderGetFilterFieldsParams {\n model: CmsModel;\n fieldTypePlugins: CmsFieldTypePlugins;\n}\ninterface RenderGetFilterFields {\n (params: RenderGetFilterFieldsParams): string;\n}\n\nconst getCreateFilters = (\n plugins: CmsFieldTypePlugins,\n fieldType: string\n): CmsModelFieldToGraphQLPlugin[\"read\"][\"createGetFilters\"] | null => {\n if (!plugins[fieldType] || !plugins[fieldType].read.createGetFilters) {\n return null;\n }\n return plugins[fieldType].read.createGetFilters;\n};\n\nexport const renderGetFilterFields: RenderGetFilterFields = ({ model, fieldTypePlugins }) => {\n const fieldIdList = model.fields\n .filter(field => {\n // Every time a client updates content model's fields, we check the type of each field. If a field plugin\n // for a particular \"field.type\" doesn't exist on the backend yet, we throw an error. But still, we also\n // want to be careful when accessing the field plugin here too. It is still possible to have a content model\n // that contains a field, for which we don't have a plugin registered on the backend. For example, user\n // could've just removed the plugin from the backend.\n if (!fieldTypePlugins[field.type]) {\n return false;\n }\n return fieldTypePlugins[field.type].isSearchable;\n })\n .map(f => f.fieldId);\n\n const filters: string[] = [\"id: ID\", \"entryId: String\"];\n\n for (const fieldId of fieldIdList) {\n const field = model.fields.find(item => item.fieldId === fieldId);\n if (!field) {\n continue;\n }\n const createGetFilters = getCreateFilters(fieldTypePlugins, field.type);\n if (typeof createGetFilters !== \"function\") {\n continue;\n }\n filters.push(createGetFilters({ model, field }));\n }\n\n return filters.filter(Boolean).join(\"\\n\");\n};\n"],"mappings":";;;;;;;AAUA,MAAMA,gBAAgB,GAAG,CACrBC,OADqB,EAErBC,SAFqB,KAG6C;EAClE,IAAI,CAACD,OAAO,CAACC,SAAD,CAAR,IAAuB,CAACD,OAAO,CAACC,SAAD,CAAP,CAAmBC,IAAnB,CAAwBC,gBAApD,EAAsE;IAClE,OAAO,IAAP;EACH;;EACD,OAAOH,OAAO,CAACC,SAAD,CAAP,CAAmBC,IAAnB,CAAwBC,gBAA/B;AACH,CARD;;AAUO,MAAMC,qBAA4C,GAAG,CAAC;EAAEC,KAAF;EAASC;AAAT,CAAD,KAAiC;EACzF,MAAMC,WAAW,GAAGF,KAAK,CAACG,MAAN,CACfC,MADe,CACRC,KAAK,IAAI;IACb;IACA;IACA;IACA;IACA;IACA,IAAI,CAACJ,gBAAgB,CAACI,KAAK,CAACC,IAAP,CAArB,EAAmC;MAC/B,OAAO,KAAP;IACH;;IACD,OAAOL,gBAAgB,CAACI,KAAK,CAACC,IAAP,CAAhB,CAA6BC,YAApC;EACH,CAXe,EAYfC,GAZe,CAYXC,CAAC,IAAIA,CAAC,CAACC,OAZI,CAApB;EAcA,MAAMC,OAAiB,GAAG,CAAC,QAAD,EAAW,iBAAX,CAA1B;;EAEA,KAAK,MAAMD,OAAX,IAAsBR,WAAtB,EAAmC;IAC/B,MAAMG,KAAK,GAAGL,KAAK,CAACG,MAAN,CAAaS,IAAb,CAAkBC,IAAI,IAAIA,IAAI,CAACH,OAAL,KAAiBA,OAA3C,CAAd;;IACA,IAAI,CAACL,KAAL,EAAY;MACR;IACH;;IACD,MAAMP,gBAAgB,GAAGJ,gBAAgB,CAACO,gBAAD,EAAmBI,KAAK,CAACC,IAAzB,CAAzC;;IACA,IAAI,OAAOR,gBAAP,KAA4B,UAAhC,EAA4C;MACxC;IACH;;IACDa,OAAO,CAACG,IAAR,CAAahB,gBAAgB,CAAC;MAAEE,KAAF;MAASK;IAAT,CAAD,CAA7B;EACH;;EAED,OAAOM,OAAO,CAACP,MAAR,CAAeW,OAAf,EAAwBC,IAAxB,CAA6B,IAA7B,CAAP;AACH,CA9BM"}