@webiny/api-headless-cms 0.0.0-unstable.496cf268ac → 0.0.0-unstable.606fc9c866
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.
- package/context.js +47 -43
- package/context.js.map +1 -1
- package/crud/contentEntry/referenceFieldsMapping.js +34 -5
- package/crud/contentEntry/referenceFieldsMapping.js.map +1 -1
- package/crud/contentEntry.crud.d.ts +6 -4
- package/crud/contentEntry.crud.js +896 -821
- package/crud/contentEntry.crud.js.map +1 -1
- package/crud/contentModel/beforeCreate.js +38 -79
- package/crud/contentModel/beforeCreate.js.map +1 -1
- package/crud/contentModel/beforeDelete.d.ts +1 -1
- package/crud/contentModel/beforeDelete.js +1 -5
- package/crud/contentModel/beforeDelete.js.map +1 -1
- package/crud/contentModel/beforeUpdate.js +30 -6
- package/crud/contentModel/beforeUpdate.js.map +1 -1
- package/crud/contentModel/validate/endingAllowed.d.ts +6 -0
- package/crud/contentModel/validate/endingAllowed.js +26 -0
- package/crud/contentModel/validate/endingAllowed.js.map +1 -0
- package/crud/contentModel/validate/isModelEndingAllowed.d.ts +6 -0
- package/crud/contentModel/validate/isModelEndingAllowed.js +24 -0
- package/crud/contentModel/validate/isModelEndingAllowed.js.map +1 -0
- package/crud/contentModel/validate/modelId.d.ts +11 -0
- package/crud/contentModel/validate/modelId.js +36 -0
- package/crud/contentModel/validate/modelId.js.map +1 -0
- package/crud/contentModel/validate/pluralApiName.d.ts +7 -0
- package/crud/contentModel/validate/pluralApiName.js +24 -0
- package/crud/contentModel/validate/pluralApiName.js.map +1 -0
- package/crud/contentModel/validate/singularApiName.d.ts +7 -0
- package/crud/contentModel/validate/singularApiName.js +24 -0
- package/crud/contentModel/validate/singularApiName.js.map +1 -0
- package/crud/contentModel/validateModelFields.js +6 -7
- package/crud/contentModel/validateModelFields.js.map +1 -1
- package/crud/contentModel/validation.d.ts +127 -95
- package/crud/contentModel/validation.js +4 -4
- package/crud/contentModel/validation.js.map +1 -1
- package/crud/contentModel.crud.js +334 -296
- package/crud/contentModel.crud.js.map +1 -1
- package/crud/contentModelGroup/validation.d.ts +4 -4
- package/crud/contentModelGroup.crud.js +170 -142
- package/crud/contentModelGroup.crud.js.map +1 -1
- package/crud/settings.crud.d.ts +1 -1
- package/crud/settings.crud.js +5 -10
- package/crud/settings.crud.js.map +1 -1
- package/graphql/checkEndpointAccess.d.ts +2 -0
- package/graphql/checkEndpointAccess.js +18 -0
- package/graphql/checkEndpointAccess.js.map +1 -0
- package/graphql/createExecutableSchema.d.ts +2 -3
- package/graphql/createExecutableSchema.js.map +1 -1
- package/graphql/createRequestBody.d.ts +2 -0
- package/graphql/createRequestBody.js +14 -0
- package/graphql/createRequestBody.js.map +1 -0
- package/graphql/formatErrorPayload.d.ts +1 -0
- package/graphql/formatErrorPayload.js +25 -0
- package/graphql/formatErrorPayload.js.map +1 -0
- package/graphql/generateSchema.js.map +1 -1
- package/graphql/getSchema.d.ts +17 -0
- package/graphql/getSchema.js +102 -0
- package/graphql/getSchema.js.map +1 -0
- package/graphql/graphQLHandlerFactory.js +6 -150
- package/graphql/graphQLHandlerFactory.js.map +1 -1
- package/graphql/handleRequest.d.ts +11 -0
- package/graphql/handleRequest.js +81 -0
- package/graphql/handleRequest.js.map +1 -0
- package/graphql/index.d.ts +1 -1
- package/graphql/schema/contentModelGroups.js +6 -6
- package/graphql/schema/contentModelGroups.js.map +1 -1
- package/graphql/schema/contentModels.js +3 -3
- package/graphql/schema/contentModels.js.map +1 -1
- package/graphql/schema/createFieldResolvers.js +2 -1
- package/graphql/schema/createFieldResolvers.js.map +1 -1
- package/graphql/schema/createManageResolvers.js +6 -0
- package/graphql/schema/createManageResolvers.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveGetUniqueFieldValues.d.ts +4 -0
- package/graphql/schema/resolvers/manage/resolveGetUniqueFieldValues.js +18 -0
- package/graphql/schema/resolvers/manage/resolveGetUniqueFieldValues.js.map +1 -0
- package/graphqlFields/dynamicZone/dynamicZoneField.d.ts +1 -1
- package/graphqlFields/dynamicZone/dynamicZoneField.js +44 -17
- package/graphqlFields/dynamicZone/dynamicZoneField.js.map +1 -1
- package/graphqlFields/object.js +14 -1
- package/graphqlFields/object.js.map +1 -1
- package/graphqlFields/ref.js +7 -7
- package/graphqlFields/ref.js.map +1 -1
- package/index.d.ts +3 -1
- package/index.js +24 -0
- package/index.js.map +1 -1
- package/package.json +22 -22
- package/plugins/CmsModelPlugin.d.ts +15 -7
- package/plugins/CmsModelPlugin.js +21 -6
- package/plugins/CmsModelPlugin.js.map +1 -1
- package/plugins/StorageOperationsCmsModelPlugin.d.ts +23 -0
- package/plugins/StorageOperationsCmsModelPlugin.js +42 -0
- package/plugins/StorageOperationsCmsModelPlugin.js.map +1 -0
- package/plugins/index.d.ts +1 -0
- package/plugins/index.js +11 -0
- package/plugins/index.js.map +1 -1
- package/types.d.ts +72 -48
- package/types.js +4 -0
- package/types.js.map +1 -1
- package/utils/converters/valueKeyStorageConverter.d.ts +1 -5
- package/utils/converters/valueKeyStorageConverter.js +19 -17
- package/utils/converters/valueKeyStorageConverter.js.map +1 -1
- package/utils/createTypeFromFields.js +1 -2
- package/utils/createTypeFromFields.js.map +1 -1
- package/utils/createTypeName.d.ts +0 -2
- package/utils/createTypeName.js +2 -10
- package/utils/createTypeName.js.map +1 -1
- package/utils/incrementEntryIdVersion.d.ts +5 -0
- package/utils/incrementEntryIdVersion.js +29 -0
- package/utils/incrementEntryIdVersion.js.map +1 -0
- package/crud/contentModel/createFieldModels.d.ts +0 -2
- package/crud/contentModel/createFieldModels.js +0 -26
- package/crud/contentModel/createFieldModels.js.map +0 -1
- package/crud/contentModel/fieldIdValidation.d.ts +0 -1
- package/crud/contentModel/fieldIdValidation.js +0 -25
- package/crud/contentModel/fieldIdValidation.js.map +0 -1
- package/crud/contentModel/idValidation.d.ts +0 -1
- package/crud/contentModel/idValidation.js +0 -22
- package/crud/contentModel/idValidation.js.map +0 -1
- package/crud/contentModel/models.d.ts +0 -4
- package/crud/contentModel/models.js +0 -192
- package/crud/contentModel/models.js.map +0 -1
- package/crud/contentModel/systemFields.d.ts +0 -1
- package/crud/contentModel/systemFields.js +0 -8
- package/crud/contentModel/systemFields.js.map +0 -1
- package/upgrades/5.33.0/index.d.ts +0 -3
- package/upgrades/5.33.0/index.js +0 -182
- package/upgrades/5.33.0/index.js.map +0 -1
- package/upgrades/index.d.ts +0 -1
- package/upgrades/index.js +0 -12
- package/upgrades/index.js.map +0 -1
- package/utils/pluralizedTypeName.d.ts +0 -1
- package/utils/pluralizedTypeName.js +0 -26
- package/utils/pluralizedTypeName.js.map +0 -1
- package/utils/removeNullValues.d.ts +0 -1
- package/utils/removeNullValues.js +0 -17
- package/utils/removeNullValues.js.map +0 -1
- package/utils/removeUndefinedValues.d.ts +0 -1
- package/utils/removeUndefinedValues.js +0 -17
- package/utils/removeUndefinedValues.js.map +0 -1
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.incrementEntryIdVersion = void 0;
|
|
8
|
+
var _utils = require("@webiny/utils");
|
|
9
|
+
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
10
|
+
const incrementEntryIdVersion = id => {
|
|
11
|
+
const {
|
|
12
|
+
id: entryId,
|
|
13
|
+
version
|
|
14
|
+
} = (0, _utils.parseIdentifier)(id);
|
|
15
|
+
if (!version) {
|
|
16
|
+
throw new _error.default("Cannot increase version on the ID without the version part.", "WRONG_ID", {
|
|
17
|
+
id
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
entryId,
|
|
22
|
+
version: version + 1,
|
|
23
|
+
id: (0, _utils.createIdentifier)({
|
|
24
|
+
id: entryId,
|
|
25
|
+
version: version + 1
|
|
26
|
+
})
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
exports.incrementEntryIdVersion = incrementEntryIdVersion;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["incrementEntryIdVersion","id","entryId","version","parseIdentifier","WebinyError","createIdentifier"],"sources":["incrementEntryIdVersion.ts"],"sourcesContent":["import { createIdentifier, parseIdentifier } from \"@webiny/utils\";\nimport WebinyError from \"@webiny/error\";\n\nexport const incrementEntryIdVersion = (id: string) => {\n const { id: entryId, version } = parseIdentifier(id);\n if (!version) {\n throw new WebinyError(\n \"Cannot increase version on the ID without the version part.\",\n \"WRONG_ID\",\n {\n id\n }\n );\n }\n return {\n entryId,\n version: version + 1,\n id: createIdentifier({\n id: entryId,\n version: version + 1\n })\n };\n};\n"],"mappings":";;;;;;;AAAA;AACA;AAEO,MAAMA,uBAAuB,GAAIC,EAAU,IAAK;EACnD,MAAM;IAAEA,EAAE,EAAEC,OAAO;IAAEC;EAAQ,CAAC,GAAG,IAAAC,sBAAe,EAACH,EAAE,CAAC;EACpD,IAAI,CAACE,OAAO,EAAE;IACV,MAAM,IAAIE,cAAW,CACjB,6DAA6D,EAC7D,UAAU,EACV;MACIJ;IACJ,CAAC,CACJ;EACL;EACA,OAAO;IACHC,OAAO;IACPC,OAAO,EAAEA,OAAO,GAAG,CAAC;IACpBF,EAAE,EAAE,IAAAK,uBAAgB,EAAC;MACjBL,EAAE,EAAEC,OAAO;MACXC,OAAO,EAAEA,OAAO,GAAG;IACvB,CAAC;EACL,CAAC;AACL,CAAC;AAAC"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createFieldModels = void 0;
|
|
7
|
-
|
|
8
|
-
var _models = require("./models");
|
|
9
|
-
|
|
10
|
-
const createFieldModels = async input => {
|
|
11
|
-
if (!input || input.length === 0) {
|
|
12
|
-
return [];
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const fields = [];
|
|
16
|
-
|
|
17
|
-
for (const field of input) {
|
|
18
|
-
const fieldData = new _models.ContentModelFieldModel().populate(field);
|
|
19
|
-
await fieldData.validate();
|
|
20
|
-
fields.push(await fieldData.toJSON());
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return fields;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
exports.createFieldModels = createFieldModels;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["createFieldModels","input","length","fields","field","fieldData","ContentModelFieldModel","populate","validate","push","toJSON"],"sources":["createFieldModels.ts"],"sourcesContent":["import { CmsModelField, CmsModelFieldInput } from \"~/types\";\nimport { ContentModelFieldModel } from \"./models\";\n\nexport const createFieldModels = async (input?: CmsModelFieldInput[]): Promise<CmsModelField[]> => {\n if (!input || input.length === 0) {\n return [];\n }\n const fields: CmsModelField[] = [];\n for (const field of input) {\n const fieldData = new ContentModelFieldModel().populate(field);\n await fieldData.validate();\n fields.push(await fieldData.toJSON());\n }\n return fields;\n};\n"],"mappings":";;;;;;;AACA;;AAEO,MAAMA,iBAAiB,GAAG,MAAOC,KAAP,IAAkE;EAC/F,IAAI,CAACA,KAAD,IAAUA,KAAK,CAACC,MAAN,KAAiB,CAA/B,EAAkC;IAC9B,OAAO,EAAP;EACH;;EACD,MAAMC,MAAuB,GAAG,EAAhC;;EACA,KAAK,MAAMC,KAAX,IAAoBH,KAApB,EAA2B;IACvB,MAAMI,SAAS,GAAG,IAAIC,8BAAJ,GAA6BC,QAA7B,CAAsCH,KAAtC,CAAlB;IACA,MAAMC,SAAS,CAACG,QAAV,EAAN;IACAL,MAAM,CAACM,IAAP,CAAY,MAAMJ,SAAS,CAACK,MAAV,EAAlB;EACH;;EACD,OAAOP,MAAP;AACH,CAXM"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const validateFieldId: (input: string) => Promise<void>;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.validateFieldId = void 0;
|
|
7
|
-
|
|
8
|
-
var _validation = require("@webiny/validation");
|
|
9
|
-
|
|
10
|
-
var _systemFields = require("./systemFields");
|
|
11
|
-
|
|
12
|
-
const validateFieldId = async input => {
|
|
13
|
-
await _validation.validation.validate(input, "required,maxLength:100");
|
|
14
|
-
const value = String(input || "").trim();
|
|
15
|
-
|
|
16
|
-
if (!value.charAt(0).match(/^[a-zA-Z]/)) {
|
|
17
|
-
throw new Error(`Provided ${value} is not valid - must not start with a number.`);
|
|
18
|
-
} else if (value.match(/^([a-zA-Z0-9]+)$/) === null) {
|
|
19
|
-
throw new Error(`Provided ${value} is not valid - must be alphanumeric string.`);
|
|
20
|
-
} else if (_systemFields.fieldSystemFields.includes(value)) {
|
|
21
|
-
throw new Error(`Provided ${value} is not valid - "${value}" is an auto-generated field.`);
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
exports.validateFieldId = validateFieldId;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["validateFieldId","input","validation","validate","value","String","trim","charAt","match","Error","fieldSystemFields","includes"],"sources":["fieldIdValidation.ts"],"sourcesContent":["import { validation } from \"@webiny/validation\";\nimport { fieldSystemFields } from \"~/crud/contentModel/systemFields\";\n\nexport const validateFieldId = async (input: string): Promise<void> => {\n await validation.validate(input, \"required,maxLength:100\");\n\n const value = String(input || \"\").trim();\n\n if (!value.charAt(0).match(/^[a-zA-Z]/)) {\n throw new Error(`Provided ${value} is not valid - must not start with a number.`);\n } else if (value.match(/^([a-zA-Z0-9]+)$/) === null) {\n throw new Error(`Provided ${value} is not valid - must be alphanumeric string.`);\n } else if (fieldSystemFields.includes(value)) {\n throw new Error(`Provided ${value} is not valid - \"${value}\" is an auto-generated field.`);\n }\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AAEO,MAAMA,eAAe,GAAG,MAAOC,KAAP,IAAwC;EACnE,MAAMC,sBAAA,CAAWC,QAAX,CAAoBF,KAApB,EAA2B,wBAA3B,CAAN;EAEA,MAAMG,KAAK,GAAGC,MAAM,CAACJ,KAAK,IAAI,EAAV,CAAN,CAAoBK,IAApB,EAAd;;EAEA,IAAI,CAACF,KAAK,CAACG,MAAN,CAAa,CAAb,EAAgBC,KAAhB,CAAsB,WAAtB,CAAL,EAAyC;IACrC,MAAM,IAAIC,KAAJ,CAAW,YAAWL,KAAM,+CAA5B,CAAN;EACH,CAFD,MAEO,IAAIA,KAAK,CAACI,KAAN,CAAY,kBAAZ,MAAoC,IAAxC,EAA8C;IACjD,MAAM,IAAIC,KAAJ,CAAW,YAAWL,KAAM,8CAA5B,CAAN;EACH,CAFM,MAEA,IAAIM,+BAAA,CAAkBC,QAAlB,CAA2BP,KAA3B,CAAJ,EAAuC;IAC1C,MAAM,IAAIK,KAAJ,CAAW,YAAWL,KAAM,oBAAmBA,KAAM,+BAArD,CAAN;EACH;AACJ,CAZM"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const validateId: (value: string) => Promise<void>;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.validateId = void 0;
|
|
7
|
-
|
|
8
|
-
var _validation = require("@webiny/validation");
|
|
9
|
-
|
|
10
|
-
const validateId = async value => {
|
|
11
|
-
await _validation.validation.validate(value, "required,maxLength:100");
|
|
12
|
-
|
|
13
|
-
if (!value.charAt(0).match(/[a-zA-Z]/)) {
|
|
14
|
-
throw new Error(`Provided ID ${value} is not valid - must not start with a number.`);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
if (value.trim().toLowerCase() === "id") {
|
|
18
|
-
throw new Error(`Provided ID ${value} is not valid - "id" is an auto-generated field.`);
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
exports.validateId = validateId;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["validateId","value","validation","validate","charAt","match","Error","trim","toLowerCase"],"sources":["idValidation.ts"],"sourcesContent":["import { validation } from \"@webiny/validation\";\n\nexport const validateId = async (value: string): Promise<void> => {\n await validation.validate(value, \"required,maxLength:100\");\n if (!value.charAt(0).match(/[a-zA-Z]/)) {\n throw new Error(`Provided ID ${value} is not valid - must not start with a number.`);\n }\n if (value.trim().toLowerCase() === \"id\") {\n throw new Error(`Provided ID ${value} is not valid - \"id\" is an auto-generated field.`);\n }\n};\n"],"mappings":";;;;;;;AAAA;;AAEO,MAAMA,UAAU,GAAG,MAAOC,KAAP,IAAwC;EAC9D,MAAMC,sBAAA,CAAWC,QAAX,CAAoBF,KAApB,EAA2B,wBAA3B,CAAN;;EACA,IAAI,CAACA,KAAK,CAACG,MAAN,CAAa,CAAb,EAAgBC,KAAhB,CAAsB,UAAtB,CAAL,EAAwC;IACpC,MAAM,IAAIC,KAAJ,CAAW,eAAcL,KAAM,+CAA/B,CAAN;EACH;;EACD,IAAIA,KAAK,CAACM,IAAN,GAAaC,WAAb,OAA+B,IAAnC,EAAyC;IACrC,MAAM,IAAIF,KAAJ,CAAW,eAAcL,KAAM,kDAA/B,CAAN;EACH;AACJ,CARM"}
|
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.UpdateContentModelModel = exports.CreateContentModelModelFrom = exports.CreateContentModelModel = exports.ContentModelFieldModel = void 0;
|
|
7
|
-
|
|
8
|
-
var _validation = require("@webiny/validation");
|
|
9
|
-
|
|
10
|
-
var _commodoFieldsObject = require("commodo-fields-object");
|
|
11
|
-
|
|
12
|
-
var _fields = require("@commodo/fields");
|
|
13
|
-
|
|
14
|
-
var _fieldIdValidation = require("./fieldIdValidation");
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Package commodo-fields-object does not have types
|
|
18
|
-
*/
|
|
19
|
-
// @ts-ignore
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Package commodo-fields does not have object.
|
|
23
|
-
*/
|
|
24
|
-
// @ts-ignore
|
|
25
|
-
const requiredShortString = _validation.validation.create("required,maxLength:255");
|
|
26
|
-
|
|
27
|
-
const shortString = _validation.validation.create("maxLength:255");
|
|
28
|
-
|
|
29
|
-
const RendererModel = (0, _fields.withFields)({
|
|
30
|
-
name: (0, _fields.string)({
|
|
31
|
-
validation: requiredShortString
|
|
32
|
-
})
|
|
33
|
-
})();
|
|
34
|
-
const ContentModelFieldModel = (0, _fields.withFields)({
|
|
35
|
-
id: (0, _fields.string)({
|
|
36
|
-
validation: requiredShortString
|
|
37
|
-
}),
|
|
38
|
-
fieldId: (0, _fields.string)({
|
|
39
|
-
validation: _fieldIdValidation.validateFieldId
|
|
40
|
-
}),
|
|
41
|
-
label: (0, _fields.string)({
|
|
42
|
-
validation: requiredShortString
|
|
43
|
-
}),
|
|
44
|
-
helpText: (0, _fields.string)({
|
|
45
|
-
validation: shortString
|
|
46
|
-
}),
|
|
47
|
-
placeholderText: (0, _fields.string)({
|
|
48
|
-
validation: shortString
|
|
49
|
-
}),
|
|
50
|
-
type: (0, _fields.setOnce)()((0, _fields.string)({
|
|
51
|
-
validation: requiredShortString
|
|
52
|
-
})),
|
|
53
|
-
tags: (0, _commodoFieldsObject.object)({
|
|
54
|
-
value: [],
|
|
55
|
-
required: false
|
|
56
|
-
}),
|
|
57
|
-
multipleValues: (0, _fields.boolean)({
|
|
58
|
-
value: false
|
|
59
|
-
}),
|
|
60
|
-
predefinedValues: (0, _fields.fields)({
|
|
61
|
-
value: {},
|
|
62
|
-
instanceOf: (0, _fields.withFields)({
|
|
63
|
-
enabled: (0, _fields.boolean)(),
|
|
64
|
-
values: (0, _fields.fields)({
|
|
65
|
-
value: [],
|
|
66
|
-
list: true,
|
|
67
|
-
instanceOf: (0, _fields.withFields)({
|
|
68
|
-
label: (0, _fields.string)(),
|
|
69
|
-
value: (0, _fields.string)(),
|
|
70
|
-
selected: (0, _fields.boolean)()
|
|
71
|
-
})()
|
|
72
|
-
})
|
|
73
|
-
})()
|
|
74
|
-
}),
|
|
75
|
-
renderer: (0, _fields.fields)({
|
|
76
|
-
instanceOf: RendererModel,
|
|
77
|
-
validation: shortString
|
|
78
|
-
}),
|
|
79
|
-
validation: (0, _fields.fields)({
|
|
80
|
-
list: true,
|
|
81
|
-
value: [],
|
|
82
|
-
instanceOf: (0, _fields.withFields)({
|
|
83
|
-
name: (0, _fields.string)({
|
|
84
|
-
validation: requiredShortString
|
|
85
|
-
}),
|
|
86
|
-
message: (0, _fields.string)({
|
|
87
|
-
validation: shortString
|
|
88
|
-
}),
|
|
89
|
-
settings: (0, _commodoFieldsObject.object)({
|
|
90
|
-
value: {}
|
|
91
|
-
})
|
|
92
|
-
})()
|
|
93
|
-
}),
|
|
94
|
-
listValidation: (0, _fields.fields)({
|
|
95
|
-
list: true,
|
|
96
|
-
value: [],
|
|
97
|
-
instanceOf: (0, _fields.withFields)({
|
|
98
|
-
name: (0, _fields.string)({
|
|
99
|
-
validation: requiredShortString
|
|
100
|
-
}),
|
|
101
|
-
message: (0, _fields.string)({
|
|
102
|
-
validation: shortString
|
|
103
|
-
}),
|
|
104
|
-
settings: (0, _commodoFieldsObject.object)({
|
|
105
|
-
value: {}
|
|
106
|
-
})
|
|
107
|
-
})()
|
|
108
|
-
}),
|
|
109
|
-
settings: (0, _commodoFieldsObject.object)({
|
|
110
|
-
value: {}
|
|
111
|
-
})
|
|
112
|
-
/**
|
|
113
|
-
* By the default, field is not deleted.
|
|
114
|
-
*/
|
|
115
|
-
// isDeleted: boolean({ value: false })
|
|
116
|
-
|
|
117
|
-
})();
|
|
118
|
-
exports.ContentModelFieldModel = ContentModelFieldModel;
|
|
119
|
-
const CreateContentModelModel = (0, _fields.withFields)({
|
|
120
|
-
name: (0, _fields.string)({
|
|
121
|
-
validation: requiredShortString
|
|
122
|
-
}),
|
|
123
|
-
modelId: (0, _fields.string)({
|
|
124
|
-
validation: shortString
|
|
125
|
-
}),
|
|
126
|
-
description: (0, _fields.string)({
|
|
127
|
-
validation: shortString
|
|
128
|
-
}),
|
|
129
|
-
group: (0, _fields.string)({
|
|
130
|
-
validation: requiredShortString
|
|
131
|
-
}),
|
|
132
|
-
fields: (0, _fields.fields)({
|
|
133
|
-
instanceOf: ContentModelFieldModel,
|
|
134
|
-
value: [],
|
|
135
|
-
list: true,
|
|
136
|
-
required: true
|
|
137
|
-
}),
|
|
138
|
-
layout: (0, _commodoFieldsObject.object)({
|
|
139
|
-
value: [],
|
|
140
|
-
required: true
|
|
141
|
-
}),
|
|
142
|
-
tags: (0, _commodoFieldsObject.object)({
|
|
143
|
-
value: [],
|
|
144
|
-
required: false
|
|
145
|
-
})
|
|
146
|
-
})();
|
|
147
|
-
exports.CreateContentModelModel = CreateContentModelModel;
|
|
148
|
-
const CreateContentModelModelFrom = (0, _fields.withFields)({
|
|
149
|
-
name: (0, _fields.string)({
|
|
150
|
-
validation: requiredShortString
|
|
151
|
-
}),
|
|
152
|
-
modelId: (0, _fields.string)({
|
|
153
|
-
validation: shortString
|
|
154
|
-
}),
|
|
155
|
-
description: (0, _fields.string)({
|
|
156
|
-
validation: shortString
|
|
157
|
-
}),
|
|
158
|
-
group: (0, _fields.string)({
|
|
159
|
-
validation: requiredShortString
|
|
160
|
-
}),
|
|
161
|
-
locale: (0, _fields.string)({
|
|
162
|
-
validation: shortString
|
|
163
|
-
})
|
|
164
|
-
})();
|
|
165
|
-
exports.CreateContentModelModelFrom = CreateContentModelModelFrom;
|
|
166
|
-
const UpdateContentModelModel = (0, _fields.withFields)({
|
|
167
|
-
name: (0, _fields.string)({
|
|
168
|
-
validation: shortString
|
|
169
|
-
}),
|
|
170
|
-
description: (0, _fields.string)({
|
|
171
|
-
validation: shortString
|
|
172
|
-
}),
|
|
173
|
-
group: (0, _fields.string)({
|
|
174
|
-
validation: shortString
|
|
175
|
-
}),
|
|
176
|
-
titleFieldId: (0, _fields.string)(),
|
|
177
|
-
fields: (0, _fields.fields)({
|
|
178
|
-
instanceOf: ContentModelFieldModel,
|
|
179
|
-
value: [],
|
|
180
|
-
list: true,
|
|
181
|
-
required: true
|
|
182
|
-
}),
|
|
183
|
-
layout: (0, _commodoFieldsObject.object)({
|
|
184
|
-
value: [],
|
|
185
|
-
required: true
|
|
186
|
-
}),
|
|
187
|
-
tags: (0, _commodoFieldsObject.object)({
|
|
188
|
-
value: [],
|
|
189
|
-
required: false
|
|
190
|
-
})
|
|
191
|
-
})();
|
|
192
|
-
exports.UpdateContentModelModel = UpdateContentModelModel;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["requiredShortString","validation","create","shortString","RendererModel","withFields","name","string","ContentModelFieldModel","id","fieldId","validateFieldId","label","helpText","placeholderText","type","setOnce","tags","object","value","required","multipleValues","boolean","predefinedValues","fields","instanceOf","enabled","values","list","selected","renderer","message","settings","listValidation","CreateContentModelModel","modelId","description","group","layout","CreateContentModelModelFrom","locale","UpdateContentModelModel","titleFieldId"],"sources":["models.ts"],"sourcesContent":["import { validation } from \"@webiny/validation\";\n/**\n * Package commodo-fields-object does not have types\n */\n// @ts-ignore\nimport { object } from \"commodo-fields-object\";\n/**\n * Package commodo-fields does not have object.\n */\n// @ts-ignore\nimport { withFields, string, setOnce, boolean, fields } from \"@commodo/fields\";\nimport { validateFieldId } from \"./fieldIdValidation\";\n\nconst requiredShortString = validation.create(\"required,maxLength:255\");\nconst shortString = validation.create(\"maxLength:255\");\n\nconst RendererModel = withFields({\n name: string({ validation: requiredShortString })\n})();\n\nexport const ContentModelFieldModel = withFields({\n id: string({ validation: requiredShortString }),\n fieldId: string({\n validation: validateFieldId\n }),\n label: string({ validation: requiredShortString }),\n helpText: string({ validation: shortString }),\n placeholderText: string({ validation: shortString }),\n type: setOnce()(string({ validation: requiredShortString })),\n tags: object({ value: [], required: false }),\n multipleValues: boolean({ value: false }),\n predefinedValues: fields({\n value: {},\n instanceOf: withFields({\n enabled: boolean(),\n values: fields({\n value: [],\n list: true,\n instanceOf: withFields({\n label: string(),\n value: string(),\n selected: boolean()\n })()\n })\n })()\n }),\n renderer: fields({ instanceOf: RendererModel, validation: shortString }),\n validation: fields({\n list: true,\n value: [],\n instanceOf: withFields({\n name: string({ validation: requiredShortString }),\n message: string({ validation: shortString }),\n settings: object({ value: {} })\n })()\n }),\n listValidation: fields({\n list: true,\n value: [],\n instanceOf: withFields({\n name: string({ validation: requiredShortString }),\n message: string({ validation: shortString }),\n settings: object({ value: {} })\n })()\n }),\n settings: object({ value: {} })\n /**\n * By the default, field is not deleted.\n */\n // isDeleted: boolean({ value: false })\n})();\n\nexport const CreateContentModelModel = withFields({\n name: string({ validation: requiredShortString }),\n modelId: string({ validation: shortString }),\n description: string({ validation: shortString }),\n group: string({ validation: requiredShortString }),\n fields: fields({ instanceOf: ContentModelFieldModel, value: [], list: true, required: true }),\n layout: object({ value: [], required: true }),\n tags: object({ value: [], required: false })\n})();\n\nexport const CreateContentModelModelFrom = withFields({\n name: string({ validation: requiredShortString }),\n modelId: string({ validation: shortString }),\n description: string({ validation: shortString }),\n group: string({ validation: requiredShortString }),\n locale: string({ validation: shortString })\n})();\n\nexport const UpdateContentModelModel = withFields({\n name: string({ validation: shortString }),\n description: string({ validation: shortString }),\n group: string({ validation: shortString }),\n titleFieldId: string(),\n fields: fields({ instanceOf: ContentModelFieldModel, value: [], list: true, required: true }),\n layout: object({ value: [], required: true }),\n tags: object({ value: [], required: false })\n})();\n"],"mappings":";;;;;;;AAAA;;AAKA;;AAKA;;AACA;;AAVA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AAIA,MAAMA,mBAAmB,GAAGC,sBAAA,CAAWC,MAAX,CAAkB,wBAAlB,CAA5B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EAAE,IAAAC,cAAA,EAAO;IAAEN,UAAU,EAAEE;EAAd,CAAP,CADwC;EAE9CiC,WAAW,EAAE,IAAA7B,cAAA,EAAO;IAAEN,UAAU,EAAEE;EAAd,CAAP,CAFiC;EAG9CkC,KAAK,EAAE,IAAA9B,cAAA,EAAO;IAAEN,UAAU,EAAEE;EAAd,CAAP,CAHuC;EAI9CuC,YAAY,EAAE,IAAAnC,cAAA,GAJgC;EAK9CiB,MAAM,EAAE,IAAAA,cAAA,EAAO;IAAEC,UAAU,EAAEjB,sBAAd;IAAsCW,KAAK,EAAE,EAA7C;IAAiDS,IAAI,EAAE,IAAvD;IAA6DR,QAAQ,EAAE;EAAvE,CAAP,CALsC;EAM9CkB,MAAM,EAAE,IAAApB,2BAAA,EAAO;IAAEC,KAAK,EAAE,EAAT;IAAaC,QAAQ,EAAE;EAAvB,CAAP,CANsC;EAO9CH,IAAI,EAAE,IAAAC,2BAAA,EAAO;IAAEC,KAAK,EAAE,EAAT;IAAaC,QAAQ,EAAE;EAAvB,CAAP;AAPwC,CAAX,GAAhC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const fieldSystemFields: string[];
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.fieldSystemFields = void 0;
|
|
7
|
-
const fieldSystemFields = ["id", "fieldId", "storageId", "label", "helpText", "placeholderText", "type", "multipleValues", "predefinedValues", "renderer", "validation", "listValidation", "settings"];
|
|
8
|
-
exports.fieldSystemFields = fieldSystemFields;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["fieldSystemFields"],"sources":["systemFields.ts"],"sourcesContent":["export const fieldSystemFields: string[] = [\n \"id\",\n \"fieldId\",\n \"storageId\",\n \"label\",\n \"helpText\",\n \"placeholderText\",\n \"type\",\n \"multipleValues\",\n \"predefinedValues\",\n \"renderer\",\n \"validation\",\n \"listValidation\",\n \"settings\"\n];\n"],"mappings":";;;;;;AAAO,MAAMA,iBAA2B,GAAG,CACvC,IADuC,EAEvC,SAFuC,EAGvC,WAHuC,EAIvC,OAJuC,EAKvC,UALuC,EAMvC,iBANuC,EAOvC,MAPuC,EAQvC,gBARuC,EASvC,kBATuC,EAUvC,UAVuC,EAWvC,YAXuC,EAYvC,gBAZuC,EAavC,UAbuC,CAApC"}
|
package/upgrades/5.33.0/index.js
DELETED
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.createUpgrade = void 0;
|
|
9
|
-
|
|
10
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
|
-
|
|
12
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
13
|
-
|
|
14
|
-
const assignStorageId = fields => {
|
|
15
|
-
return fields.map(field => {
|
|
16
|
-
const settings = (0, _objectSpread2.default)({}, field.settings || {});
|
|
17
|
-
|
|
18
|
-
if (settings.fields && Array.isArray(settings.fields) === true) {
|
|
19
|
-
settings.fields = assignStorageId(settings.fields);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, field), {}, {
|
|
23
|
-
storageId: field.fieldId,
|
|
24
|
-
settings
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* If at least one field does not have storageId define, we should definitely update the model.
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const shouldUpdate = fields => {
|
|
34
|
-
return fields.some(field => {
|
|
35
|
-
var _field$settings;
|
|
36
|
-
|
|
37
|
-
if ((_field$settings = field.settings) !== null && _field$settings !== void 0 && _field$settings.fields) {
|
|
38
|
-
return shouldUpdate(field.settings.fields);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return !field.storageId;
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
const upgradeTenantModels = async params => {
|
|
46
|
-
const {
|
|
47
|
-
tenant,
|
|
48
|
-
cms,
|
|
49
|
-
i18n
|
|
50
|
-
} = params;
|
|
51
|
-
/**
|
|
52
|
-
* We need all locales for this tenant, so we can go and find all models for all the locales.
|
|
53
|
-
*/
|
|
54
|
-
|
|
55
|
-
const [locales] = await i18n.locales.storageOperations.list({
|
|
56
|
-
where: {
|
|
57
|
-
tenant: tenant.id
|
|
58
|
-
},
|
|
59
|
-
limit: 100
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
if (locales.length === 0) {
|
|
63
|
-
console.log(`There are no locales under the tenant "${tenant.id}".`);
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
for (const locale of locales) {
|
|
68
|
-
/**
|
|
69
|
-
* We need all the models that are not plugin models.
|
|
70
|
-
*/
|
|
71
|
-
const models = await cms.storageOperations.models.list({
|
|
72
|
-
where: {
|
|
73
|
-
tenant: tenant.id,
|
|
74
|
-
locale: locale.code
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
if (models.length === 0) {
|
|
79
|
-
console.log(`No models in tenant "${tenant.id}" and locale "${locale.code}" combination.`);
|
|
80
|
-
continue;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Then we need to go into each of the model fields and add the storageId, which is the same as the fieldId
|
|
84
|
-
*/
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
const updatedModels = models.filter(model => {
|
|
88
|
-
/**
|
|
89
|
-
* If model has at least one field with no storageId, continue with the update.
|
|
90
|
-
*/
|
|
91
|
-
const toUpdate = shouldUpdate(model.fields);
|
|
92
|
-
/**
|
|
93
|
-
* If not updating the model, lets log it - just in case...
|
|
94
|
-
*/
|
|
95
|
-
|
|
96
|
-
if (!toUpdate) {
|
|
97
|
-
console.log(`Skipping update of model "${model.modelId} - ${tenant.id} - ${locale.code}".`);
|
|
98
|
-
return false;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
return true;
|
|
102
|
-
}).map(model => {
|
|
103
|
-
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, model), {}, {
|
|
104
|
-
fields: assignStorageId(model.fields)
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
/**
|
|
108
|
-
* And update all the models
|
|
109
|
-
*/
|
|
110
|
-
|
|
111
|
-
for (const model of updatedModels) {
|
|
112
|
-
try {
|
|
113
|
-
await cms.storageOperations.models.update({
|
|
114
|
-
model
|
|
115
|
-
});
|
|
116
|
-
} catch (ex) {
|
|
117
|
-
throw new _error.default(`Could not update CMS model ${model.modelId}`, "MODEL_UPGRADE_ERROR", {
|
|
118
|
-
model
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* In the end we need to write the new cms system version.
|
|
125
|
-
*/
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
await cms.setSystemVersion("5.33.0");
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
const createUpgrade = () => {
|
|
132
|
-
return {
|
|
133
|
-
type: "api-upgrade",
|
|
134
|
-
version: "5.33.0",
|
|
135
|
-
app: "headless-cms",
|
|
136
|
-
apply: async context => {
|
|
137
|
-
const {
|
|
138
|
-
security,
|
|
139
|
-
tenancy,
|
|
140
|
-
cms,
|
|
141
|
-
i18n
|
|
142
|
-
} = context;
|
|
143
|
-
/**
|
|
144
|
-
* We need to be able to access all data.
|
|
145
|
-
*/
|
|
146
|
-
|
|
147
|
-
security.disableAuthorization();
|
|
148
|
-
const initialTenant = tenancy.getCurrentTenant();
|
|
149
|
-
const tenants = await tenancy.listTenants();
|
|
150
|
-
|
|
151
|
-
try {
|
|
152
|
-
for (const tenant of tenants) {
|
|
153
|
-
tenancy.setCurrentTenant(tenant);
|
|
154
|
-
await upgradeTenantModels({
|
|
155
|
-
tenant,
|
|
156
|
-
cms,
|
|
157
|
-
i18n
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
} catch (ex) {
|
|
161
|
-
console.log(`Upgrade error: ${JSON.stringify({
|
|
162
|
-
message: ex.message,
|
|
163
|
-
code: ex.code,
|
|
164
|
-
data: ex.data
|
|
165
|
-
})}`);
|
|
166
|
-
throw new _error.default(`Could not finish the 5.33.0 upgrade. Please contact Webiny team on Slack and share the error.`, "UPGRADE_ERROR", {
|
|
167
|
-
message: ex.message,
|
|
168
|
-
code: ex.code,
|
|
169
|
-
data: ex.data
|
|
170
|
-
});
|
|
171
|
-
} finally {
|
|
172
|
-
/**
|
|
173
|
-
* Always enable the security after all the code runs.
|
|
174
|
-
*/
|
|
175
|
-
security.enableAuthorization();
|
|
176
|
-
tenancy.setCurrentTenant(initialTenant);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
};
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
exports.createUpgrade = createUpgrade;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["assignStorageId","fields","map","field","settings","Array","isArray","storageId","fieldId","shouldUpdate","some","upgradeTenantModels","params","tenant","cms","i18n","locales","storageOperations","list","where","id","limit","length","console","log","locale","models","code","updatedModels","filter","model","toUpdate","modelId","update","ex","WebinyError","setSystemVersion","createUpgrade","type","version","app","apply","context","security","tenancy","disableAuthorization","initialTenant","getCurrentTenant","tenants","listTenants","setCurrentTenant","JSON","stringify","message","data","enableAuthorization"],"sources":["index.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { UpgradePlugin } from \"@webiny/api-upgrade\";\nimport { CmsContext, CmsModelField, HeadlessCms } from \"~/types\";\nimport { Tenant } from \"@webiny/api-tenancy/types\";\nimport { I18NContextObject } from \"@webiny/api-i18n/types\";\n\nconst assignStorageId = (fields: CmsModelField[]): CmsModelField[] => {\n return fields.map(field => {\n const settings = {\n ...(field.settings || {})\n };\n if (settings.fields && Array.isArray(settings.fields) === true) {\n settings.fields = assignStorageId(settings.fields);\n }\n return {\n ...field,\n storageId: field.fieldId,\n settings\n };\n });\n};\n/**\n * If at least one field does not have storageId define, we should definitely update the model.\n */\nconst shouldUpdate = (fields: CmsModelField[]): boolean => {\n return fields.some(field => {\n if (field.settings?.fields) {\n return shouldUpdate(field.settings.fields);\n }\n return !field.storageId;\n });\n};\n\ninterface UpgradeTenantModelsParams {\n tenant: Tenant;\n cms: HeadlessCms;\n i18n: I18NContextObject;\n}\n\nconst upgradeTenantModels = async (params: UpgradeTenantModelsParams): Promise<void> => {\n const { tenant, cms, i18n } = params;\n /**\n * We need all locales for this tenant, so we can go and find all models for all the locales.\n */\n const [locales] = await i18n.locales.storageOperations.list({\n where: {\n tenant: tenant.id\n },\n limit: 100\n });\n if (locales.length === 0) {\n console.log(`There are no locales under the tenant \"${tenant.id}\".`);\n return;\n }\n for (const locale of locales) {\n /**\n * We need all the models that are not plugin models.\n */\n const models = await cms.storageOperations.models.list({\n where: {\n tenant: tenant.id,\n locale: locale.code\n }\n });\n if (models.length === 0) {\n console.log(\n `No models in tenant \"${tenant.id}\" and locale \"${locale.code}\" combination.`\n );\n continue;\n }\n\n /**\n * Then we need to go into each of the model fields and add the storageId, which is the same as the fieldId\n */\n const updatedModels = models\n .filter(model => {\n /**\n * If model has at least one field with no storageId, continue with the update.\n */\n const toUpdate = shouldUpdate(model.fields);\n\n /**\n * If not updating the model, lets log it - just in case...\n */\n if (!toUpdate) {\n console.log(\n `Skipping update of model \"${model.modelId} - ${tenant.id} - ${locale.code}\".`\n );\n return false;\n }\n return true;\n })\n .map(model => {\n return {\n ...model,\n fields: assignStorageId(model.fields)\n };\n });\n /**\n * And update all the models\n */\n for (const model of updatedModels) {\n try {\n await cms.storageOperations.models.update({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n `Could not update CMS model ${model.modelId}`,\n \"MODEL_UPGRADE_ERROR\",\n {\n model\n }\n );\n }\n }\n }\n /**\n * In the end we need to write the new cms system version.\n */\n await cms.setSystemVersion(\"5.33.0\");\n};\n\nexport const createUpgrade = (): UpgradePlugin<CmsContext> => {\n return {\n type: \"api-upgrade\",\n version: \"5.33.0\",\n app: \"headless-cms\",\n apply: async context => {\n const { security, tenancy, cms, i18n } = context;\n\n /**\n * We need to be able to access all data.\n */\n security.disableAuthorization();\n\n const initialTenant = tenancy.getCurrentTenant();\n\n const tenants = await tenancy.listTenants();\n try {\n for (const tenant of tenants) {\n tenancy.setCurrentTenant(tenant);\n await upgradeTenantModels({\n tenant,\n cms,\n i18n\n });\n }\n } catch (ex) {\n console.log(\n `Upgrade error: ${JSON.stringify({\n message: ex.message,\n code: ex.code,\n data: ex.data\n })}`\n );\n throw new WebinyError(\n `Could not finish the 5.33.0 upgrade. Please contact Webiny team on Slack and share the error.`,\n \"UPGRADE_ERROR\",\n {\n message: ex.message,\n code: ex.code,\n data: ex.data\n }\n );\n } finally {\n /**\n * Always enable the security after all the code runs.\n */\n security.enableAuthorization();\n tenancy.setCurrentTenant(initialTenant);\n }\n }\n };\n};\n"],"mappings":";;;;;;;;;;;AAAA;;AAMA,MAAMA,eAAe,GAAIC,MAAD,IAA8C;EAClE,OAAOA,MAAM,CAACC,GAAP,CAAWC,KAAK,IAAI;IACvB,MAAMC,QAAQ,mCACND,KAAK,CAACC,QAAN,IAAkB,EADZ,CAAd;;IAGA,IAAIA,QAAQ,CAACH,MAAT,IAAmBI,KAAK,CAACC,OAAN,CAAcF,QAAQ,CAACH,MAAvB,MAAmC,IAA1D,EAAgE;MAC5DG,QAAQ,CAACH,MAAT,GAAkBD,eAAe,CAACI,QAAQ,CAACH,MAAV,CAAjC;IACH;;IACD,mEACOE,KADP;MAEII,SAAS,EAAEJ,KAAK,CAACK,OAFrB;MAGIJ;IAHJ;EAKH,CAZM,CA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MAEA,MAAMC,aAAa,GAAGF,OAAO,CAACG,gBAAR,EAAtB;MAEA,MAAMC,OAAO,GAAG,MAAMJ,OAAO,CAACK,WAAR,EAAtB;;MACA,IAAI;QACA,KAAK,MAAMpC,MAAX,IAAqBmC,OAArB,EAA8B;UAC1BJ,OAAO,CAACM,gBAAR,CAAyBrC,MAAzB;UACA,MAAMF,mBAAmB,CAAC;YACtBE,MADsB;YAEtBC,GAFsB;YAGtBC;UAHsB,CAAD,CAAzB;QAKH;MACJ,CATD,CASE,OAAOmB,EAAP,EAAW;QACTX,OAAO,CAACC,GAAR,CACK,kBAAiB2B,IAAI,CAACC,SAAL,CAAe;UAC7BC,OAAO,EAAEnB,EAAE,CAACmB,OADiB;UAE7B1B,IAAI,EAAEO,EAAE,CAACP,IAFoB;UAG7B2B,IAAI,EAAEpB,EAAE,CAACoB;QAHoB,CAAf,CAIf,EALP;QAOA,MAAM,IAAInB,cAAJ,CACD,+FADC,EAEF,eAFE,EAGF;UACIkB,OAAO,EAAEnB,EAAE,CAACmB,OADhB;UAEI1B,IAAI,EAAEO,EAAE,CAACP,IAFb;UAGI2B,IAAI,EAAEpB,EAAE,CAACoB;QAHb,CAHE,CAAN;MASH,CA1BD,SA0BU;QACN;AAChB;AACA;QACgBX,QAAQ,CAACY,mBAAT;QACAX,OAAO,CAACM,gBAAR,CAAyBJ,aAAzB;MACH;IACJ;EAhDE,CAAP;AAkDH,CAnDM"}
|
package/upgrades/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const createUpgrades: () => import("@webiny/api-upgrade").UpgradePlugin<import("../types").CmsContext>[];
|
package/upgrades/index.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createUpgrades = void 0;
|
|
7
|
-
|
|
8
|
-
var _ = require("./5.33.0");
|
|
9
|
-
|
|
10
|
-
const createUpgrades = () => [(0, _.createUpgrade)()];
|
|
11
|
-
|
|
12
|
-
exports.createUpgrades = createUpgrades;
|
package/upgrades/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["createUpgrades","create533Upgrade"],"sources":["index.ts"],"sourcesContent":["import { createUpgrade as create533Upgrade } from \"~/upgrades/5.33.0\";\n\nexport const createUpgrades = () => [create533Upgrade()];\n"],"mappings":";;;;;;;AAAA;;AAEO,MAAMA,cAAc,GAAG,MAAM,CAAC,IAAAC,eAAA,GAAD,CAA7B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const pluralizedTypeName: (typeName: string) => string;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.pluralizedTypeName = void 0;
|
|
9
|
-
|
|
10
|
-
var _pluralize = _interopRequireDefault(require("pluralize"));
|
|
11
|
-
|
|
12
|
-
// This will make it so if the content model name is a single capitalized letter
|
|
13
|
-
// Ex. A, pluralizedTypeName will capitalize the name to As, instead of AS
|
|
14
|
-
const pluralizedTypeName = typeName => {
|
|
15
|
-
let pluralizedTypeName;
|
|
16
|
-
|
|
17
|
-
if (typeName.length === 1) {
|
|
18
|
-
pluralizedTypeName = `${typeName}s`;
|
|
19
|
-
} else {
|
|
20
|
-
pluralizedTypeName = (0, _pluralize.default)(typeName);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return pluralizedTypeName;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
exports.pluralizedTypeName = pluralizedTypeName;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["pluralizedTypeName","typeName","length","pluralize"],"sources":["pluralizedTypeName.ts"],"sourcesContent":["import pluralize from \"pluralize\";\n\n// This will make it so if the content model name is a single capitalized letter\n// Ex. A, pluralizedTypeName will capitalize the name to As, instead of AS\nexport const pluralizedTypeName = (typeName: string): string => {\n let pluralizedTypeName;\n if (typeName.length === 1) {\n pluralizedTypeName = `${typeName}s`;\n } else {\n pluralizedTypeName = pluralize(typeName);\n }\n return pluralizedTypeName;\n};\n"],"mappings":";;;;;;;;;AAAA;;AAEA;AACA;AACO,MAAMA,kBAAkB,GAAIC,QAAD,IAA8B;EAC5D,IAAID,kBAAJ;;EACA,IAAIC,QAAQ,CAACC,MAAT,KAAoB,CAAxB,EAA2B;IACvBF,kBAAkB,GAAI,GAAEC,QAAS,GAAjC;EACH,CAFD,MAEO;IACHD,kBAAkB,GAAG,IAAAG,kBAAA,EAAUF,QAAV,CAArB;EACH;;EACD,OAAOD,kBAAP;AACH,CARM"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const removeNullValues: <T extends Record<string, any>>(target: T) => T;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.removeNullValues = void 0;
|
|
7
|
-
const removeNullValues = target => {
|
|
8
|
-
const result = {};
|
|
9
|
-
for (const key in target) {
|
|
10
|
-
if (target[key] === null) {
|
|
11
|
-
continue;
|
|
12
|
-
}
|
|
13
|
-
result[key] = target[key];
|
|
14
|
-
}
|
|
15
|
-
return result;
|
|
16
|
-
};
|
|
17
|
-
exports.removeNullValues = removeNullValues;
|