@webiny/api-headless-cms 0.0.0-unstable.990c3ab1b6 → 0.0.0-unstable.aa00eecd97
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.d.ts +5 -2
- package/context.js +61 -8
- package/context.js.map +1 -1
- package/crud/contentEntry/markLockedFields.d.ts +1 -1
- package/crud/contentEntry/markLockedFields.js +17 -4
- package/crud/contentEntry/markLockedFields.js.map +1 -1
- package/crud/contentEntry/referenceFieldsMapping.js +40 -9
- package/crud/contentEntry/referenceFieldsMapping.js.map +1 -1
- package/crud/contentEntry/searchableFields.d.ts +9 -0
- package/crud/contentEntry/searchableFields.js +72 -0
- package/crud/contentEntry/searchableFields.js.map +1 -0
- package/crud/contentEntry.crud.d.ts +8 -5
- package/crud/contentEntry.crud.js +1081 -841
- package/crud/contentEntry.crud.js.map +1 -1
- package/crud/contentModel/beforeCreate.d.ts +2 -3
- package/crud/contentModel/beforeCreate.js +43 -81
- 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.d.ts +2 -4
- package/crud/contentModel/beforeUpdate.js +33 -5
- package/crud/contentModel/beforeUpdate.js.map +1 -1
- package/crud/contentModel/compatibility/modelApiName.d.ts +3 -0
- package/crud/contentModel/compatibility/modelApiName.js +24 -0
- package/crud/contentModel/compatibility/modelApiName.js.map +1 -0
- package/crud/contentModel/createFieldStorageId.js +4 -1
- package/crud/contentModel/createFieldStorageId.js.map +1 -1
- package/crud/contentModel/defaultFields.d.ts +5 -0
- package/crud/contentModel/defaultFields.js +58 -0
- package/crud/contentModel/defaultFields.js.map +1 -0
- package/crud/contentModel/fields/descriptionField.d.ts +2 -0
- package/crud/contentModel/fields/descriptionField.js +42 -0
- package/crud/contentModel/fields/descriptionField.js.map +1 -0
- package/crud/contentModel/fields/imageField.d.ts +2 -0
- package/crud/contentModel/fields/imageField.js +46 -0
- package/crud/contentModel/fields/imageField.js.map +1 -0
- package/crud/contentModel/fields/titleField.d.ts +2 -0
- package/crud/contentModel/fields/titleField.js +58 -0
- package/crud/contentModel/fields/titleField.js.map +1 -0
- 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/validateModel.d.ts +4 -4
- package/crud/contentModel/validateModel.js +6 -3
- package/crud/contentModel/validateModel.js.map +1 -1
- package/crud/contentModel/validateModelFields.d.ts +4 -4
- package/crud/contentModel/validateModelFields.js +123 -88
- package/crud/contentModel/validateModelFields.js.map +1 -1
- package/crud/contentModel/validation.d.ts +551 -0
- package/crud/contentModel/validation.js +145 -0
- package/crud/contentModel/validation.js.map +1 -0
- package/crud/contentModel.crud.js +369 -273
- package/crud/contentModel.crud.js.map +1 -1
- package/crud/contentModelGroup/validation.d.ts +30 -0
- package/crud/contentModelGroup/validation.js +34 -0
- package/crud/contentModelGroup/validation.js.map +1 -0
- package/crud/contentModelGroup.crud.js +189 -172
- 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/crud/system.crud.js +0 -60
- package/crud/system.crud.js.map +1 -1
- package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.d.ts +11 -0
- package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.js +203 -0
- package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.js.map +1 -0
- package/fieldConverters/index.d.ts +2 -1
- package/fieldConverters/index.js +2 -1
- package/fieldConverters/index.js.map +1 -1
- package/graphql/buildSchemaPlugins.d.ts +8 -3
- package/graphql/buildSchemaPlugins.js +3 -7
- package/graphql/buildSchemaPlugins.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 +6 -0
- package/graphql/createExecutableSchema.js +29 -0
- package/graphql/createExecutableSchema.js.map +1 -0
- 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.d.ts +8 -0
- package/graphql/generateSchema.js +31 -0
- package/graphql/generateSchema.js.map +1 -0
- 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 -104
- 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 -3
- package/graphql/index.js +2 -39
- package/graphql/index.js.map +1 -1
- package/graphql/schema/baseContentSchema.d.ts +6 -2
- package/graphql/schema/baseContentSchema.js +9 -11
- package/graphql/schema/baseContentSchema.js.map +1 -1
- package/graphql/schema/baseSchema.d.ts +3 -0
- package/graphql/schema/baseSchema.js +68 -0
- package/graphql/schema/baseSchema.js.map +1 -0
- package/graphql/schema/contentEntries.d.ts +6 -2
- package/graphql/schema/contentEntries.js +116 -65
- package/graphql/schema/contentEntries.js.map +1 -1
- package/graphql/schema/contentModelGroups.d.ts +6 -2
- package/graphql/schema/contentModelGroups.js +14 -10
- package/graphql/schema/contentModelGroups.js.map +1 -1
- package/graphql/schema/contentModels.d.ts +6 -2
- package/graphql/schema/contentModels.js +60 -8
- package/graphql/schema/contentModels.js.map +1 -1
- package/graphql/schema/createFieldResolvers.d.ts +2 -2
- package/graphql/schema/createFieldResolvers.js +18 -13
- package/graphql/schema/createFieldResolvers.js.map +1 -1
- package/graphql/schema/createFieldTypePluginRecords.d.ts +3 -0
- package/graphql/schema/createFieldTypePluginRecords.js +13 -0
- package/graphql/schema/createFieldTypePluginRecords.js.map +1 -0
- package/graphql/schema/createManageResolvers.d.ts +1 -1
- package/graphql/schema/createManageResolvers.js +37 -17
- package/graphql/schema/createManageResolvers.js.map +1 -1
- package/graphql/schema/createManageSDL.d.ts +3 -0
- package/graphql/schema/createManageSDL.js +81 -63
- package/graphql/schema/createManageSDL.js.map +1 -1
- package/graphql/schema/createPreviewResolvers.js +3 -7
- package/graphql/schema/createPreviewResolvers.js.map +1 -1
- package/graphql/schema/createReadResolvers.js +8 -7
- package/graphql/schema/createReadResolvers.js.map +1 -1
- package/graphql/schema/createReadSDL.d.ts +3 -0
- package/graphql/schema/createReadSDL.js +47 -36
- package/graphql/schema/createReadSDL.js.map +1 -1
- package/graphql/schema/resolvers/commonFieldResolvers.d.ts +3 -2
- package/graphql/schema/resolvers/commonFieldResolvers.js +2 -1
- package/graphql/schema/resolvers/commonFieldResolvers.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveDelete.d.ts +2 -1
- package/graphql/schema/resolvers/manage/resolveDelete.js +13 -3
- package/graphql/schema/resolvers/manage/resolveDelete.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveDeleteMultiple.d.ts +7 -0
- package/graphql/schema/resolvers/manage/resolveDeleteMultiple.js +20 -0
- package/graphql/schema/resolvers/manage/resolveDeleteMultiple.js.map +1 -0
- 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/graphql/schema/schemaPlugins.d.ts +8 -3
- package/graphql/schema/schemaPlugins.js +55 -52
- package/graphql/schema/schemaPlugins.js.map +1 -1
- package/graphql/system.js +55 -74
- package/graphql/system.js.map +1 -1
- package/graphqlFields/dynamicZone/dynamicZoneField.d.ts +2 -0
- package/graphqlFields/dynamicZone/dynamicZoneField.js +243 -0
- package/graphqlFields/dynamicZone/dynamicZoneField.js.map +1 -0
- package/graphqlFields/dynamicZone/dynamicZoneStorage.d.ts +3 -0
- package/graphqlFields/dynamicZone/dynamicZoneStorage.js +63 -0
- package/graphqlFields/dynamicZone/dynamicZoneStorage.js.map +1 -0
- package/graphqlFields/dynamicZone/index.d.ts +2 -0
- package/graphqlFields/dynamicZone/index.js +19 -0
- package/graphqlFields/dynamicZone/index.js.map +1 -0
- package/graphqlFields/index.d.ts +1 -1
- package/graphqlFields/index.js +2 -1
- package/graphqlFields/index.js.map +1 -1
- package/graphqlFields/number.js +4 -0
- package/graphqlFields/number.js.map +1 -1
- package/graphqlFields/object.js +131 -68
- package/graphqlFields/object.js.map +1 -1
- package/graphqlFields/ref.js +70 -56
- package/graphqlFields/ref.js.map +1 -1
- package/index.d.ts +5 -3
- package/index.js +27 -8
- package/index.js.map +1 -1
- package/package.json +40 -41
- package/plugins/CmsGraphQLSchemaPlugin.d.ts +5 -0
- package/plugins/CmsGraphQLSchemaPlugin.js +12 -0
- package/plugins/CmsGraphQLSchemaPlugin.js.map +1 -0
- package/plugins/CmsGraphQLSchemaSorterPlugin.d.ts +20 -0
- package/plugins/CmsGraphQLSchemaSorterPlugin.js +28 -0
- package/plugins/CmsGraphQLSchemaSorterPlugin.js.map +1 -0
- package/plugins/CmsModelFieldConverterPlugin.d.ts +2 -2
- package/plugins/CmsModelFieldConverterPlugin.js.map +1 -1
- package/plugins/CmsModelPlugin.d.ts +21 -3
- package/plugins/CmsModelPlugin.js +28 -2
- 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/StorageTransformPlugin.d.ts +11 -11
- package/plugins/StorageTransformPlugin.js.map +1 -1
- package/plugins/index.d.ts +3 -0
- package/plugins/index.js +33 -0
- package/plugins/index.js.map +1 -1
- package/storage/object.js +4 -2
- package/storage/object.js.map +1 -1
- package/types.d.ts +436 -149
- package/types.js +74 -8
- package/types.js.map +1 -1
- package/utils/converters/ConverterCollection.js +5 -2
- package/utils/converters/ConverterCollection.js.map +1 -1
- package/utils/converters/valueKeyStorageConverter.d.ts +1 -5
- package/utils/converters/valueKeyStorageConverter.js +26 -20
- package/utils/converters/valueKeyStorageConverter.js.map +1 -1
- package/utils/createTypeFromFields.d.ts +16 -0
- package/utils/createTypeFromFields.js +66 -0
- package/utils/createTypeFromFields.js.map +1 -0
- package/utils/createTypeName.d.ts +0 -2
- package/utils/createTypeName.js +4 -11
- package/utils/createTypeName.js.map +1 -1
- package/utils/entryStorage.js +14 -11
- package/utils/entryStorage.js.map +1 -1
- package/utils/getBaseFieldType.d.ts +2 -0
- package/utils/getBaseFieldType.js +10 -0
- package/utils/getBaseFieldType.js.map +1 -0
- package/utils/getEntryDescription.d.ts +2 -0
- package/utils/getEntryDescription.js +17 -0
- package/utils/getEntryDescription.js.map +1 -0
- package/utils/getEntryImage.d.ts +2 -0
- package/utils/getEntryImage.js +17 -0
- package/utils/getEntryImage.js.map +1 -0
- package/utils/getEntryTitle.d.ts +1 -1
- package/utils/getEntryTitle.js.map +1 -1
- package/utils/getSchemaFromFieldPlugins.d.ts +4 -7
- package/utils/getSchemaFromFieldPlugins.js +22 -14
- package/utils/getSchemaFromFieldPlugins.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/utils/ownership.d.ts +3 -3
- package/utils/ownership.js.map +1 -1
- package/utils/renderFields.d.ts +4 -2
- package/utils/renderFields.js +12 -3
- package/utils/renderFields.js.map +1 -1
- package/utils/renderGetFilterFields.d.ts +2 -2
- package/utils/renderGetFilterFields.js +9 -19
- package/utils/renderGetFilterFields.js.map +1 -1
- package/utils/renderInputFields.d.ts +4 -2
- package/utils/renderInputFields.js +19 -6
- package/utils/renderInputFields.js.map +1 -1
- package/utils/renderListFilterFields.d.ts +2 -1
- package/utils/renderListFilterFields.js +12 -21
- package/utils/renderListFilterFields.js.map +1 -1
- package/utils/renderSortEnum.d.ts +9 -5
- package/utils/renderSortEnum.js +23 -5
- package/utils/renderSortEnum.js.map +1 -1
- package/validators/dynamicZone.d.ts +2 -0
- package/validators/dynamicZone.js +20 -0
- package/validators/dynamicZone.js.map +1 -0
- package/validators/index.js +2 -1
- package/validators/index.js.map +1 -1
- package/crud/contentModel/createFieldModels.d.ts +0 -2
- package/crud/contentModel/createFieldModels.js +0 -20
- package/crud/contentModel/createFieldModels.js.map +0 -1
- package/crud/contentModel/fieldIdValidation.d.ts +0 -1
- package/crud/contentModel/fieldIdValidation.js +0 -20
- package/crud/contentModel/fieldIdValidation.js.map +0 -1
- package/crud/contentModel/idValidation.d.ts +0 -1
- package/crud/contentModel/idValidation.js +0 -17
- package/crud/contentModel/idValidation.js.map +0 -1
- package/crud/contentModel/models.d.ts +0 -4
- package/crud/contentModel/models.js +0 -173
- 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/crud/index.d.ts +0 -6
- package/crud/index.js +0 -69
- package/crud/index.js.map +0 -1
- package/graphql/schema/resolvers/manage/resolveRequestChanges.d.ts +0 -7
- package/graphql/schema/resolvers/manage/resolveRequestChanges.js +0 -21
- package/graphql/schema/resolvers/manage/resolveRequestChanges.js.map +0 -1
- package/graphql/schema/resolvers/manage/resolveRequestReview.d.ts +0 -7
- package/graphql/schema/resolvers/manage/resolveRequestReview.js +0 -21
- package/graphql/schema/resolvers/manage/resolveRequestReview.js.map +0 -1
- package/upgrades/5.33.0/index.d.ts +0 -3
- package/upgrades/5.33.0/index.js +0 -159
- package/upgrades/5.33.0/index.js.map +0 -1
- package/upgrades/index.d.ts +0 -1
- package/upgrades/index.js +0 -9
- package/upgrades/index.js.map +0 -1
- package/utils/filterModelFields.d.ts +0 -16
- package/utils/filterModelFields.js +0 -71
- package/utils/filterModelFields.js.map +0 -1
- package/utils/pluralizedTypeName.d.ts +0 -1
- package/utils/pluralizedTypeName.js +0 -20
- package/utils/pluralizedTypeName.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"}
|
package/utils/ownership.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { BaseCmsSecurityPermission, CmsContext,
|
|
1
|
+
import { BaseCmsSecurityPermission, CmsContext, CmsIdentity } from "../types";
|
|
2
2
|
interface OwnableRecord {
|
|
3
|
-
createdBy?:
|
|
4
|
-
ownedBy?:
|
|
3
|
+
createdBy?: CmsIdentity;
|
|
4
|
+
ownedBy?: CmsIdentity;
|
|
5
5
|
}
|
|
6
6
|
export declare const checkOwnership: (context: CmsContext, permission: BaseCmsSecurityPermission, record: OwnableRecord) => void;
|
|
7
7
|
export declare const validateOwnership: (context: CmsContext, permission: BaseCmsSecurityPermission, record: OwnableRecord) => boolean;
|
package/utils/ownership.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,
|
|
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, CmsIdentity } from \"~/types\";\nimport { NotAuthorizedError } from \"@webiny/api-security\";\n\ninterface OwnableRecord {\n createdBy?: CmsIdentity;\n ownedBy?: CmsIdentity;\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,OAAmB,EACnBC,UAAqC,EACrCC,MAAqB,KACd;EAAA;EACP,IAAI,CAACD,UAAU,CAACE,GAAG,EAAE;IACjB;EACJ;EAEA,MAAMC,QAAQ,GAAGJ,OAAO,CAACK,QAAQ,CAACC,WAAW,EAAE;EAC/C,MAAMC,KAAK,GAAGH,QAAQ,IAAI,oBAAAF,MAAM,CAACM,OAAO,oDAAd,gBAAgBC,EAAE,MAAKL,QAAQ,CAACK,EAAE;EAC5D,MAAMC,OAAO,GAAGN,QAAQ,IAAI,sBAAAF,MAAM,CAACS,SAAS,sDAAhB,kBAAkBF,EAAE,MAAKL,QAAQ,CAACK,EAAE;EAEhE,IAAI,CAACF,KAAK,IAAI,CAACG,OAAO,EAAE;IACpB,MAAM,IAAIE,+BAAkB,CAAC;MACzBC,IAAI,EAAE;QACFC,MAAM,EAAG;MACb;IACJ,CAAC,CAAC;EACN;AACJ,CAAC;AAAC;AAEK,MAAMC,iBAAiB,GAAG,CAC7Bf,OAAmB,EACnBC,UAAqC,EACrCC,MAAqB,KACX;EACV,IAAI;IACAH,cAAc,CAACC,OAAO,EAAEC,UAAU,EAAEC,MAAM,CAAC;IAC3C,OAAO,IAAI;EACf,CAAC,CAAC,MAAM;IACJ,OAAO,KAAK;EAChB;AACJ,CAAC;AAAC"}
|
package/utils/renderFields.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { ApiEndpoint, CmsFieldTypePlugins, CmsModel, CmsModelField, CmsModelFieldDefinition } from "../types";
|
|
2
2
|
interface RenderFieldsParams {
|
|
3
|
+
models: CmsModel[];
|
|
3
4
|
model: CmsModel;
|
|
5
|
+
fields: CmsModelField[];
|
|
4
6
|
type: ApiEndpoint;
|
|
5
7
|
fieldTypePlugins: CmsFieldTypePlugins;
|
|
6
8
|
}
|
|
@@ -8,8 +10,8 @@ interface RenderFields {
|
|
|
8
10
|
(params: RenderFieldsParams): CmsModelFieldDefinition[];
|
|
9
11
|
}
|
|
10
12
|
export declare const renderFields: RenderFields;
|
|
11
|
-
interface RenderFieldParams extends RenderFieldsParams {
|
|
13
|
+
interface RenderFieldParams extends Omit<RenderFieldsParams, "fields"> {
|
|
12
14
|
field: CmsModelField;
|
|
13
15
|
}
|
|
14
|
-
export declare const renderField: ({ model, type, field, fieldTypePlugins }: RenderFieldParams) => CmsModelFieldDefinition | null;
|
|
16
|
+
export declare const renderField: ({ models, model, type, field, fieldTypePlugins }: RenderFieldParams) => CmsModelFieldDefinition | null;
|
|
15
17
|
export {};
|
package/utils/renderFields.js
CHANGED
|
@@ -4,12 +4,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.renderFields = exports.renderField = void 0;
|
|
7
|
+
var _getBaseFieldType = require("./getBaseFieldType");
|
|
7
8
|
const renderFields = ({
|
|
9
|
+
models,
|
|
8
10
|
model,
|
|
11
|
+
fields,
|
|
9
12
|
type,
|
|
10
13
|
fieldTypePlugins
|
|
11
14
|
}) => {
|
|
12
|
-
return
|
|
15
|
+
return fields.map(field => renderField({
|
|
16
|
+
models,
|
|
13
17
|
model,
|
|
14
18
|
type,
|
|
15
19
|
field,
|
|
@@ -18,17 +22,22 @@ const renderFields = ({
|
|
|
18
22
|
};
|
|
19
23
|
exports.renderFields = renderFields;
|
|
20
24
|
const renderField = ({
|
|
25
|
+
models,
|
|
21
26
|
model,
|
|
22
27
|
type,
|
|
23
28
|
field,
|
|
24
29
|
fieldTypePlugins
|
|
25
30
|
}) => {
|
|
26
|
-
const plugin = fieldTypePlugins[field
|
|
31
|
+
const plugin = fieldTypePlugins[(0, _getBaseFieldType.getBaseFieldType)(field)];
|
|
27
32
|
if (!plugin) {
|
|
28
33
|
// Let's not render the field if it does not exist in the field plugins.
|
|
29
34
|
return null;
|
|
30
35
|
}
|
|
31
|
-
const
|
|
36
|
+
const {
|
|
37
|
+
createTypeField
|
|
38
|
+
} = plugin[type];
|
|
39
|
+
const defs = createTypeField({
|
|
40
|
+
models,
|
|
32
41
|
model,
|
|
33
42
|
field,
|
|
34
43
|
fieldTypePlugins
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["renderFields","model","
|
|
1
|
+
{"version":3,"names":["renderFields","models","model","fields","type","fieldTypePlugins","map","field","renderField","filter","Boolean","plugin","getBaseFieldType","createTypeField","defs"],"sources":["renderFields.ts"],"sourcesContent":["import {\n ApiEndpoint,\n CmsFieldTypePlugins,\n CmsModel,\n CmsModelField,\n CmsModelFieldDefinition,\n CmsModelFieldToGraphQLPlugin\n} from \"~/types\";\nimport { getBaseFieldType } from \"~/utils/getBaseFieldType\";\n\ninterface RenderFieldsParams {\n models: CmsModel[];\n model: CmsModel;\n fields: CmsModelField[];\n type: ApiEndpoint;\n fieldTypePlugins: CmsFieldTypePlugins;\n}\n\ninterface RenderFields {\n (params: RenderFieldsParams): CmsModelFieldDefinition[];\n}\n\nexport const renderFields: RenderFields = ({\n models,\n model,\n fields,\n type,\n fieldTypePlugins\n}): CmsModelFieldDefinition[] => {\n return fields\n .map(field => renderField({ models, model, type, field, fieldTypePlugins }))\n .filter(Boolean) as CmsModelFieldDefinition[];\n};\n\ninterface RenderFieldParams extends Omit<RenderFieldsParams, \"fields\"> {\n field: CmsModelField;\n}\n\nexport const renderField = ({\n models,\n model,\n type,\n field,\n fieldTypePlugins\n}: RenderFieldParams): CmsModelFieldDefinition | null => {\n const plugin = fieldTypePlugins[getBaseFieldType(field)];\n if (!plugin) {\n // Let's not render the field if it does not exist in the field plugins.\n return null;\n }\n const { createTypeField } = plugin[type] as CmsModelFieldToGraphQLPlugin[\"manage\"];\n const defs = createTypeField({\n models,\n model,\n field,\n fieldTypePlugins\n });\n\n if (!defs) {\n return null;\n } else if (typeof defs === \"string\") {\n return {\n fields: defs\n };\n }\n\n return defs;\n};\n"],"mappings":";;;;;;AAQA;AAcO,MAAMA,YAA0B,GAAG,CAAC;EACvCC,MAAM;EACNC,KAAK;EACLC,MAAM;EACNC,IAAI;EACJC;AACJ,CAAC,KAAgC;EAC7B,OAAOF,MAAM,CACRG,GAAG,CAACC,KAAK,IAAIC,WAAW,CAAC;IAAEP,MAAM;IAAEC,KAAK;IAAEE,IAAI;IAAEG,KAAK;IAAEF;EAAiB,CAAC,CAAC,CAAC,CAC3EI,MAAM,CAACC,OAAO,CAAC;AACxB,CAAC;AAAC;AAMK,MAAMF,WAAW,GAAG,CAAC;EACxBP,MAAM;EACNC,KAAK;EACLE,IAAI;EACJG,KAAK;EACLF;AACe,CAAC,KAAqC;EACrD,MAAMM,MAAM,GAAGN,gBAAgB,CAAC,IAAAO,kCAAgB,EAACL,KAAK,CAAC,CAAC;EACxD,IAAI,CAACI,MAAM,EAAE;IACT;IACA,OAAO,IAAI;EACf;EACA,MAAM;IAAEE;EAAgB,CAAC,GAAGF,MAAM,CAACP,IAAI,CAA2C;EAClF,MAAMU,IAAI,GAAGD,eAAe,CAAC;IACzBZ,MAAM;IACNC,KAAK;IACLK,KAAK;IACLF;EACJ,CAAC,CAAC;EAEF,IAAI,CAACS,IAAI,EAAE;IACP,OAAO,IAAI;EACf,CAAC,MAAM,IAAI,OAAOA,IAAI,KAAK,QAAQ,EAAE;IACjC,OAAO;MACHX,MAAM,EAAEW;IACZ,CAAC;EACL;EAEA,OAAOA,IAAI;AACf,CAAC;AAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { CmsFieldTypePlugins,
|
|
1
|
+
import { CmsFieldTypePlugins, CmsModelField } from "../types";
|
|
2
2
|
interface RenderGetFilterFieldsParams {
|
|
3
|
-
|
|
3
|
+
fields: CmsModelField[];
|
|
4
4
|
fieldTypePlugins: CmsFieldTypePlugins;
|
|
5
5
|
}
|
|
6
6
|
interface RenderGetFilterFields {
|
|
@@ -4,39 +4,29 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.renderGetFilterFields = void 0;
|
|
7
|
-
|
|
8
|
-
if (!plugins[fieldType] || !plugins[fieldType].read.createGetFilters) {
|
|
9
|
-
return null;
|
|
10
|
-
}
|
|
11
|
-
return plugins[fieldType].read.createGetFilters;
|
|
12
|
-
};
|
|
7
|
+
var _getBaseFieldType = require("./getBaseFieldType");
|
|
13
8
|
const renderGetFilterFields = ({
|
|
14
|
-
|
|
9
|
+
fields,
|
|
15
10
|
fieldTypePlugins
|
|
16
11
|
}) => {
|
|
17
|
-
const
|
|
12
|
+
const filters = ["id: ID", "entryId: String"];
|
|
13
|
+
for (const field of fields) {
|
|
14
|
+
var _plugin$read;
|
|
18
15
|
// Every time a client updates content model's fields, we check the type of each field. If a field plugin
|
|
19
16
|
// for a particular "field.type" doesn't exist on the backend yet, we throw an error. But still, we also
|
|
20
17
|
// want to be careful when accessing the field plugin here too. It is still possible to have a content model
|
|
21
18
|
// that contains a field, for which we don't have a plugin registered on the backend. For example, user
|
|
22
19
|
// could've just removed the plugin from the backend.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return fieldTypePlugins[field.type].isSearchable;
|
|
27
|
-
}).map(f => f.fieldId);
|
|
28
|
-
const filters = ["id: ID", "entryId: String"];
|
|
29
|
-
for (const fieldId of fieldIdList) {
|
|
30
|
-
const field = model.fields.find(item => item.fieldId === fieldId);
|
|
31
|
-
if (!field) {
|
|
20
|
+
const baseType = (0, _getBaseFieldType.getBaseFieldType)(field);
|
|
21
|
+
const plugin = fieldTypePlugins[baseType];
|
|
22
|
+
if (!(plugin !== null && plugin !== void 0 && plugin.isSearchable)) {
|
|
32
23
|
continue;
|
|
33
24
|
}
|
|
34
|
-
const createGetFilters =
|
|
25
|
+
const createGetFilters = (_plugin$read = plugin.read) === null || _plugin$read === void 0 ? void 0 : _plugin$read.createGetFilters;
|
|
35
26
|
if (typeof createGetFilters !== "function") {
|
|
36
27
|
continue;
|
|
37
28
|
}
|
|
38
29
|
filters.push(createGetFilters({
|
|
39
|
-
model,
|
|
40
30
|
field
|
|
41
31
|
}));
|
|
42
32
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["renderGetFilterFields","fields","fieldTypePlugins","filters","field","baseType","getBaseFieldType","plugin","isSearchable","createGetFilters","read","push","filter","Boolean","join"],"sources":["renderGetFilterFields.ts"],"sourcesContent":["import { CmsFieldTypePlugins, CmsModelField } from \"~/types\";\nimport { getBaseFieldType } from \"~/utils/getBaseFieldType\";\n\ninterface RenderGetFilterFieldsParams {\n fields: CmsModelField[];\n fieldTypePlugins: CmsFieldTypePlugins;\n}\ninterface RenderGetFilterFields {\n (params: RenderGetFilterFieldsParams): string;\n}\n\nexport const renderGetFilterFields: RenderGetFilterFields = ({ fields, fieldTypePlugins }) => {\n const filters: string[] = [\"id: ID\", \"entryId: String\"];\n\n for (const field of fields) {\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 const baseType = getBaseFieldType(field);\n const plugin = fieldTypePlugins[baseType];\n if (!plugin?.isSearchable) {\n continue;\n }\n const createGetFilters = plugin.read?.createGetFilters;\n if (typeof createGetFilters !== \"function\") {\n continue;\n }\n filters.push(createGetFilters({ field }));\n }\n\n return filters.filter(Boolean).join(\"\\n\");\n};\n"],"mappings":";;;;;;AACA;AAUO,MAAMA,qBAA4C,GAAG,CAAC;EAAEC,MAAM;EAAEC;AAAiB,CAAC,KAAK;EAC1F,MAAMC,OAAiB,GAAG,CAAC,QAAQ,EAAE,iBAAiB,CAAC;EAEvD,KAAK,MAAMC,KAAK,IAAIH,MAAM,EAAE;IAAA;IACxB;IACA;IACA;IACA;IACA;IACA,MAAMI,QAAQ,GAAG,IAAAC,kCAAgB,EAACF,KAAK,CAAC;IACxC,MAAMG,MAAM,GAAGL,gBAAgB,CAACG,QAAQ,CAAC;IACzC,IAAI,EAACE,MAAM,aAANA,MAAM,eAANA,MAAM,CAAEC,YAAY,GAAE;MACvB;IACJ;IACA,MAAMC,gBAAgB,mBAAGF,MAAM,CAACG,IAAI,iDAAX,aAAaD,gBAAgB;IACtD,IAAI,OAAOA,gBAAgB,KAAK,UAAU,EAAE;MACxC;IACJ;IACAN,OAAO,CAACQ,IAAI,CAACF,gBAAgB,CAAC;MAAEL;IAAM,CAAC,CAAC,CAAC;EAC7C;EAEA,OAAOD,OAAO,CAACS,MAAM,CAACC,OAAO,CAAC,CAACC,IAAI,CAAC,IAAI,CAAC;AAC7C,CAAC;AAAC"}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { CmsFieldTypePlugins, CmsModel, CmsModelField, CmsModelFieldDefinition } from "../types";
|
|
2
2
|
interface RenderInputFieldsParams {
|
|
3
|
+
models: CmsModel[];
|
|
3
4
|
model: CmsModel;
|
|
5
|
+
fields: CmsModelField[];
|
|
4
6
|
fieldTypePlugins: CmsFieldTypePlugins;
|
|
5
7
|
}
|
|
6
|
-
interface RenderInputFieldParams extends RenderInputFieldsParams {
|
|
8
|
+
interface RenderInputFieldParams extends Omit<RenderInputFieldsParams, "fields"> {
|
|
7
9
|
field: CmsModelField;
|
|
8
10
|
}
|
|
9
11
|
interface RenderInputFields {
|
|
10
12
|
(params: RenderInputFieldsParams): CmsModelFieldDefinition[];
|
|
11
13
|
}
|
|
12
14
|
export declare const renderInputFields: RenderInputFields;
|
|
13
|
-
export declare const renderInputField: ({ model, field, fieldTypePlugins }: RenderInputFieldParams) => CmsModelFieldDefinition | null;
|
|
15
|
+
export declare const renderInputField: ({ models, model, field, fieldTypePlugins }: RenderInputFieldParams) => CmsModelFieldDefinition | null;
|
|
14
16
|
export {};
|
|
@@ -4,18 +4,30 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.renderInputFields = exports.renderInputField = void 0;
|
|
7
|
+
var _getBaseFieldType = require("./getBaseFieldType");
|
|
7
8
|
const renderInputFields = ({
|
|
9
|
+
models,
|
|
8
10
|
model,
|
|
11
|
+
fields,
|
|
9
12
|
fieldTypePlugins
|
|
10
13
|
}) => {
|
|
11
|
-
return
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
return fields.reduce((result, field) => {
|
|
15
|
+
const input = renderInputField({
|
|
16
|
+
models,
|
|
17
|
+
model,
|
|
18
|
+
field,
|
|
19
|
+
fieldTypePlugins
|
|
20
|
+
});
|
|
21
|
+
if (!input) {
|
|
22
|
+
return result;
|
|
23
|
+
}
|
|
24
|
+
result.push(input);
|
|
25
|
+
return result;
|
|
26
|
+
}, []);
|
|
16
27
|
};
|
|
17
28
|
exports.renderInputFields = renderInputFields;
|
|
18
29
|
const renderInputField = ({
|
|
30
|
+
models,
|
|
19
31
|
model,
|
|
20
32
|
field,
|
|
21
33
|
fieldTypePlugins
|
|
@@ -25,12 +37,13 @@ const renderInputField = ({
|
|
|
25
37
|
// want to be careful when accessing the field plugin here too. It is still possible to have a content model
|
|
26
38
|
// that contains a field, for which we don't have a plugin registered on the backend. For example, user
|
|
27
39
|
// could've just removed the plugin from the backend.
|
|
28
|
-
const plugin = fieldTypePlugins[field
|
|
40
|
+
const plugin = fieldTypePlugins[(0, _getBaseFieldType.getBaseFieldType)(field)];
|
|
29
41
|
if (!plugin) {
|
|
30
42
|
// Let's not render the field if it does not exist in the field plugins.
|
|
31
43
|
return null;
|
|
32
44
|
}
|
|
33
45
|
const def = plugin.manage.createInputField({
|
|
46
|
+
models,
|
|
34
47
|
model,
|
|
35
48
|
field,
|
|
36
49
|
fieldTypePlugins
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["renderInputFields","model","fieldTypePlugins","
|
|
1
|
+
{"version":3,"names":["renderInputFields","models","model","fields","fieldTypePlugins","reduce","result","field","input","renderInputField","push","plugin","getBaseFieldType","def","manage","createInputField"],"sources":["renderInputFields.ts"],"sourcesContent":["import { CmsFieldTypePlugins, CmsModel, CmsModelField, CmsModelFieldDefinition } from \"~/types\";\nimport { getBaseFieldType } from \"~/utils/getBaseFieldType\";\n\ninterface RenderInputFieldsParams {\n models: CmsModel[];\n model: CmsModel;\n fields: CmsModelField[];\n fieldTypePlugins: CmsFieldTypePlugins;\n}\n\ninterface RenderInputFieldParams extends Omit<RenderInputFieldsParams, \"fields\"> {\n field: CmsModelField;\n}\n\ninterface RenderInputFields {\n (params: RenderInputFieldsParams): CmsModelFieldDefinition[];\n}\n\nexport const renderInputFields: RenderInputFields = ({\n models,\n model,\n fields,\n fieldTypePlugins\n}): CmsModelFieldDefinition[] => {\n return fields.reduce<CmsModelFieldDefinition[]>((result, field) => {\n const input = renderInputField({ models, model, field, fieldTypePlugins });\n if (!input) {\n return result;\n }\n result.push(input);\n return result;\n }, []);\n};\n\nexport const renderInputField = ({\n models,\n model,\n field,\n fieldTypePlugins\n}: RenderInputFieldParams): CmsModelFieldDefinition | null => {\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 const plugin = fieldTypePlugins[getBaseFieldType(field)];\n\n if (!plugin) {\n // Let's not render the field if it does not exist in the field plugins.\n return null;\n }\n\n const def = plugin.manage.createInputField({\n models,\n model,\n field,\n fieldTypePlugins\n });\n if (typeof def === \"string\") {\n return {\n fields: def\n };\n }\n\n return def;\n};\n"],"mappings":";;;;;;AACA;AAiBO,MAAMA,iBAAoC,GAAG,CAAC;EACjDC,MAAM;EACNC,KAAK;EACLC,MAAM;EACNC;AACJ,CAAC,KAAgC;EAC7B,OAAOD,MAAM,CAACE,MAAM,CAA4B,CAACC,MAAM,EAAEC,KAAK,KAAK;IAC/D,MAAMC,KAAK,GAAGC,gBAAgB,CAAC;MAAER,MAAM;MAAEC,KAAK;MAAEK,KAAK;MAAEH;IAAiB,CAAC,CAAC;IAC1E,IAAI,CAACI,KAAK,EAAE;MACR,OAAOF,MAAM;IACjB;IACAA,MAAM,CAACI,IAAI,CAACF,KAAK,CAAC;IAClB,OAAOF,MAAM;EACjB,CAAC,EAAE,EAAE,CAAC;AACV,CAAC;AAAC;AAEK,MAAMG,gBAAgB,GAAG,CAAC;EAC7BR,MAAM;EACNC,KAAK;EACLK,KAAK;EACLH;AACoB,CAAC,KAAqC;EAC1D;EACA;EACA;EACA;EACA;EACA,MAAMO,MAAM,GAAGP,gBAAgB,CAAC,IAAAQ,kCAAgB,EAACL,KAAK,CAAC,CAAC;EAExD,IAAI,CAACI,MAAM,EAAE;IACT;IACA,OAAO,IAAI;EACf;EAEA,MAAME,GAAG,GAAGF,MAAM,CAACG,MAAM,CAACC,gBAAgB,CAAC;IACvCd,MAAM;IACNC,KAAK;IACLK,KAAK;IACLH;EACJ,CAAC,CAAC;EACF,IAAI,OAAOS,GAAG,KAAK,QAAQ,EAAE;IACzB,OAAO;MACHV,MAAM,EAAEU;IACZ,CAAC;EACL;EAEA,OAAOA,GAAG;AACd,CAAC;AAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { ApiEndpoint, CmsFieldTypePlugins, CmsModel } from "../types";
|
|
1
|
+
import { ApiEndpoint, CmsFieldTypePlugins, CmsModel, CmsModelField } from "../types";
|
|
2
2
|
interface RenderListFilterFieldsParams {
|
|
3
3
|
model: CmsModel;
|
|
4
|
+
fields: CmsModelField[];
|
|
4
5
|
type: ApiEndpoint;
|
|
5
6
|
fieldTypePlugins: CmsFieldTypePlugins;
|
|
6
7
|
}
|
|
@@ -4,48 +4,39 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.renderListFilterFields = void 0;
|
|
7
|
-
|
|
8
|
-
* We cast as read type, because input and output of read and manage are same. This way we ease things.
|
|
9
|
-
* Internal stuff so it should be ok.
|
|
10
|
-
* TODO note that if changing read/manage types, change this as well.
|
|
11
|
-
*/
|
|
12
|
-
const getCreateListFilters = (plugins, fieldType, type) => {
|
|
13
|
-
if (!plugins[fieldType]) {
|
|
14
|
-
return null;
|
|
15
|
-
} else if (!plugins[fieldType][type]) {
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
18
|
-
return plugins[fieldType][type].createListFilters;
|
|
19
|
-
};
|
|
7
|
+
var _getBaseFieldType = require("./getBaseFieldType");
|
|
20
8
|
const renderListFilterFields = params => {
|
|
21
9
|
const {
|
|
22
10
|
model,
|
|
11
|
+
fields,
|
|
23
12
|
type,
|
|
24
13
|
fieldTypePlugins
|
|
25
14
|
} = params;
|
|
26
|
-
const
|
|
15
|
+
const result = [["id: ID", "id_not: ID", "id_in: [ID!]", "id_not_in: [ID!]", "entryId: String", "entryId_not: String", "entryId_in: [String!]", "entryId_not_in: [String!]", "createdOn: DateTime", "createdOn_gt: DateTime", "createdOn_gte: DateTime", "createdOn_lt: DateTime", "createdOn_lte: DateTime", "createdOn_between: [DateTime!]", "createdOn_not_between: [DateTime!]", "savedOn: DateTime", "savedOn_gt: DateTime", "savedOn_gte: DateTime", "savedOn_lt: DateTime", "savedOn_lte: DateTime", "savedOn_between: [DateTime!]", "savedOn_not_between: [DateTime!]", "createdBy: String", "createdBy_not: String", "createdBy_in: [String!]", "createdBy_not_in: [String!]", "ownedBy: String", "ownedBy_not: String", "ownedBy_in: [String!]", "ownedBy_not_in: [String!]"].join("\n")];
|
|
27
16
|
/**
|
|
28
17
|
* We can find different statuses only in the manage API endpoint.
|
|
29
18
|
*/
|
|
30
19
|
if (type === "manage") {
|
|
31
|
-
|
|
20
|
+
result.push("status: String", "status_not: String", "status_in: [String!]", "status_not_in: [String!]");
|
|
32
21
|
}
|
|
33
|
-
for (const field of
|
|
22
|
+
for (const field of fields) {
|
|
23
|
+
var _fieldTypePlugins$bas, _fieldTypePlugins$bas2;
|
|
34
24
|
// Every time a client updates content model's fields, we check the type of each field. If a field plugin
|
|
35
25
|
// for a particular "field.type" doesn't exist on the backend yet, we throw an error. But still, we also
|
|
36
26
|
// want to be careful when accessing the field plugin here too. It is still possible to have a content model
|
|
37
27
|
// that contains a field, for which we don't have a plugin registered on the backend. For example, user
|
|
38
28
|
// could've just removed the plugin from the backend.
|
|
39
|
-
|
|
40
|
-
const createListFilters =
|
|
29
|
+
const baseType = (0, _getBaseFieldType.getBaseFieldType)(field);
|
|
30
|
+
const createListFilters = (_fieldTypePlugins$bas = fieldTypePlugins[baseType]) === null || _fieldTypePlugins$bas === void 0 ? void 0 : (_fieldTypePlugins$bas2 = _fieldTypePlugins$bas[type]) === null || _fieldTypePlugins$bas2 === void 0 ? void 0 : _fieldTypePlugins$bas2.createListFilters;
|
|
41
31
|
if (typeof createListFilters !== "function") {
|
|
42
32
|
continue;
|
|
43
33
|
}
|
|
44
|
-
|
|
34
|
+
result.push(createListFilters({
|
|
45
35
|
model,
|
|
46
|
-
field
|
|
36
|
+
field,
|
|
37
|
+
plugins: fieldTypePlugins
|
|
47
38
|
}));
|
|
48
39
|
}
|
|
49
|
-
return
|
|
40
|
+
return result.filter(Boolean).join("\n");
|
|
50
41
|
};
|
|
51
42
|
exports.renderListFilterFields = renderListFilterFields;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["renderListFilterFields","params","model","fields","type","fieldTypePlugins","result","join","push","field","baseType","getBaseFieldType","createListFilters","plugins","filter","Boolean"],"sources":["renderListFilterFields.ts"],"sourcesContent":["import {\n ApiEndpoint,\n CmsFieldTypePlugins,\n CmsModel,\n CmsModelField,\n CmsModelFieldToGraphQLPlugin\n} from \"~/types\";\nimport { getBaseFieldType } from \"~/utils/getBaseFieldType\";\n\ninterface RenderListFilterFieldsParams {\n model: CmsModel;\n fields: CmsModelField[];\n type: ApiEndpoint;\n fieldTypePlugins: CmsFieldTypePlugins;\n}\ninterface RenderListFilterFields {\n (params: RenderListFilterFieldsParams): string;\n}\n\ntype CreateListFiltersType =\n | CmsModelFieldToGraphQLPlugin[\"read\"][\"createListFilters\"]\n | CmsModelFieldToGraphQLPlugin[\"manage\"][\"createListFilters\"];\n\nexport const renderListFilterFields: RenderListFilterFields = (params): string => {\n const { model, fields, type, fieldTypePlugins } = params;\n const result: string[] = [\n [\n \"id: ID\",\n \"id_not: ID\",\n \"id_in: [ID!]\",\n \"id_not_in: [ID!]\",\n \"entryId: String\",\n \"entryId_not: String\",\n \"entryId_in: [String!]\",\n \"entryId_not_in: [String!]\",\n \"createdOn: DateTime\",\n \"createdOn_gt: DateTime\",\n \"createdOn_gte: DateTime\",\n \"createdOn_lt: DateTime\",\n \"createdOn_lte: DateTime\",\n \"createdOn_between: [DateTime!]\",\n \"createdOn_not_between: [DateTime!]\",\n \"savedOn: DateTime\",\n \"savedOn_gt: DateTime\",\n \"savedOn_gte: DateTime\",\n \"savedOn_lt: DateTime\",\n \"savedOn_lte: DateTime\",\n \"savedOn_between: [DateTime!]\",\n \"savedOn_not_between: [DateTime!]\",\n \"createdBy: String\",\n \"createdBy_not: String\",\n \"createdBy_in: [String!]\",\n \"createdBy_not_in: [String!]\",\n \"ownedBy: String\",\n \"ownedBy_not: String\",\n \"ownedBy_in: [String!]\",\n \"ownedBy_not_in: [String!]\"\n ].join(\"\\n\")\n ];\n /**\n * We can find different statuses only in the manage API endpoint.\n */\n if (type === \"manage\") {\n result.push(\n \"status: String\",\n \"status_not: String\",\n \"status_in: [String!]\",\n \"status_not_in: [String!]\"\n );\n }\n\n for (const field of fields) {\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 const baseType = getBaseFieldType(field);\n const createListFilters: CreateListFiltersType | undefined =\n fieldTypePlugins[baseType]?.[type]?.createListFilters;\n if (typeof createListFilters !== \"function\") {\n continue;\n }\n result.push(createListFilters({ model, field, plugins: fieldTypePlugins }));\n }\n\n return result.filter(Boolean).join(\"\\n\");\n};\n"],"mappings":";;;;;;AAOA;AAgBO,MAAMA,sBAA8C,GAAIC,MAAM,IAAa;EAC9E,MAAM;IAAEC,KAAK;IAAEC,MAAM;IAAEC,IAAI;IAAEC;EAAiB,CAAC,GAAGJ,MAAM;EACxD,MAAMK,MAAgB,GAAG,CACrB,CACI,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,EACrB,uBAAuB,EACvB,2BAA2B,EAC3B,qBAAqB,EACrB,wBAAwB,EACxB,yBAAyB,EACzB,wBAAwB,EACxB,yBAAyB,EACzB,gCAAgC,EAChC,oCAAoC,EACpC,mBAAmB,EACnB,sBAAsB,EACtB,uBAAuB,EACvB,sBAAsB,EACtB,uBAAuB,EACvB,8BAA8B,EAC9B,kCAAkC,EAClC,mBAAmB,EACnB,uBAAuB,EACvB,yBAAyB,EACzB,6BAA6B,EAC7B,iBAAiB,EACjB,qBAAqB,EACrB,uBAAuB,EACvB,2BAA2B,CAC9B,CAACC,IAAI,CAAC,IAAI,CAAC,CACf;EACD;AACJ;AACA;EACI,IAAIH,IAAI,KAAK,QAAQ,EAAE;IACnBE,MAAM,CAACE,IAAI,CACP,gBAAgB,EAChB,oBAAoB,EACpB,sBAAsB,EACtB,0BAA0B,CAC7B;EACL;EAEA,KAAK,MAAMC,KAAK,IAAIN,MAAM,EAAE;IAAA;IACxB;IACA;IACA;IACA;IACA;IACA,MAAMO,QAAQ,GAAG,IAAAC,kCAAgB,EAACF,KAAK,CAAC;IACxC,MAAMG,iBAAoD,4BACtDP,gBAAgB,CAACK,QAAQ,CAAC,oFAA1B,sBAA6BN,IAAI,CAAC,2DAAlC,uBAAoCQ,iBAAiB;IACzD,IAAI,OAAOA,iBAAiB,KAAK,UAAU,EAAE;MACzC;IACJ;IACAN,MAAM,CAACE,IAAI,CAACI,iBAAiB,CAAC;MAAEV,KAAK;MAAEO,KAAK;MAAEI,OAAO,EAAER;IAAiB,CAAC,CAAC,CAAC;EAC/E;EAEA,OAAOC,MAAM,CAACQ,MAAM,CAACC,OAAO,CAAC,CAACR,IAAI,CAAC,IAAI,CAAC;AAC5C,CAAC;AAAC"}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import { CmsFieldTypePlugins, CmsModel } from "../types";
|
|
1
|
+
import { CmsFieldTypePlugins, CmsModel, CmsModelField } from "../types";
|
|
2
|
+
import { CmsGraphQLSchemaSorterPlugin } from "../plugins/CmsGraphQLSchemaSorterPlugin";
|
|
3
|
+
interface RenderSortEnumParams {
|
|
4
|
+
model: CmsModel;
|
|
5
|
+
fields: CmsModelField[];
|
|
6
|
+
fieldTypePlugins: CmsFieldTypePlugins;
|
|
7
|
+
sorterPlugins: CmsGraphQLSchemaSorterPlugin[];
|
|
8
|
+
}
|
|
2
9
|
interface RenderSortEnum {
|
|
3
|
-
(params:
|
|
4
|
-
model: CmsModel;
|
|
5
|
-
fieldTypePlugins: CmsFieldTypePlugins;
|
|
6
|
-
}): string;
|
|
10
|
+
(params: RenderSortEnumParams): string;
|
|
7
11
|
}
|
|
8
12
|
export declare const renderSortEnum: RenderSortEnum;
|
|
9
13
|
export {};
|
package/utils/renderSortEnum.js
CHANGED
|
@@ -4,15 +4,28 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.renderSortEnum = void 0;
|
|
7
|
+
var _getBaseFieldType = require("./getBaseFieldType");
|
|
7
8
|
const renderSortEnum = ({
|
|
8
9
|
model,
|
|
9
|
-
|
|
10
|
+
fields,
|
|
11
|
+
fieldTypePlugins,
|
|
12
|
+
sorterPlugins
|
|
10
13
|
}) => {
|
|
11
|
-
|
|
12
|
-
for (const field of
|
|
13
|
-
const plugin = fieldTypePlugins[field
|
|
14
|
+
let sorters = [`id_ASC`, `id_DESC`, "savedOn_ASC", "savedOn_DESC", "createdOn_ASC", "createdOn_DESC"];
|
|
15
|
+
for (const field of fields) {
|
|
16
|
+
const plugin = fieldTypePlugins[(0, _getBaseFieldType.getBaseFieldType)(field)];
|
|
14
17
|
if (!plugin) {
|
|
15
18
|
continue;
|
|
19
|
+
} else if (plugin.createSorters) {
|
|
20
|
+
const result = plugin.createSorters({
|
|
21
|
+
model,
|
|
22
|
+
field,
|
|
23
|
+
sorters
|
|
24
|
+
});
|
|
25
|
+
if (result) {
|
|
26
|
+
sorters = result;
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
16
29
|
}
|
|
17
30
|
if (!plugin.isSortable) {
|
|
18
31
|
continue;
|
|
@@ -20,6 +33,11 @@ const renderSortEnum = ({
|
|
|
20
33
|
sorters.push(`${field.fieldId}_ASC`);
|
|
21
34
|
sorters.push(`${field.fieldId}_DESC`);
|
|
22
35
|
}
|
|
23
|
-
return
|
|
36
|
+
return sorterPlugins.reduce((result, plugin) => {
|
|
37
|
+
return plugin.createSorter({
|
|
38
|
+
model,
|
|
39
|
+
sorters: result
|
|
40
|
+
});
|
|
41
|
+
}, sorters).join("\n");
|
|
24
42
|
};
|
|
25
43
|
exports.renderSortEnum = renderSortEnum;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["renderSortEnum","model","fieldTypePlugins","sorters","field","
|
|
1
|
+
{"version":3,"names":["renderSortEnum","model","fields","fieldTypePlugins","sorterPlugins","sorters","field","plugin","getBaseFieldType","createSorters","result","isSortable","push","fieldId","reduce","createSorter","join"],"sources":["renderSortEnum.ts"],"sourcesContent":["import { CmsFieldTypePlugins, CmsModel, CmsModelField } from \"~/types\";\nimport { getBaseFieldType } from \"~/utils/getBaseFieldType\";\nimport { CmsGraphQLSchemaSorterPlugin } from \"~/plugins/CmsGraphQLSchemaSorterPlugin\";\n\ninterface RenderSortEnumParams {\n model: CmsModel;\n fields: CmsModelField[];\n fieldTypePlugins: CmsFieldTypePlugins;\n sorterPlugins: CmsGraphQLSchemaSorterPlugin[];\n}\ninterface RenderSortEnum {\n (params: RenderSortEnumParams): string;\n}\n\nexport const renderSortEnum: RenderSortEnum = ({\n model,\n fields,\n fieldTypePlugins,\n sorterPlugins\n}): string => {\n let sorters: string[] = [\n `id_ASC`,\n `id_DESC`,\n \"savedOn_ASC\",\n \"savedOn_DESC\",\n \"createdOn_ASC\",\n \"createdOn_DESC\"\n ];\n\n for (const field of fields) {\n const plugin = fieldTypePlugins[getBaseFieldType(field)];\n if (!plugin) {\n continue;\n } else if (plugin.createSorters) {\n const result = plugin.createSorters({\n model,\n field,\n sorters\n });\n if (result) {\n sorters = result;\n continue;\n }\n }\n if (!plugin.isSortable) {\n continue;\n }\n sorters.push(`${field.fieldId}_ASC`);\n sorters.push(`${field.fieldId}_DESC`);\n }\n\n return sorterPlugins\n .reduce((result, plugin) => {\n return plugin.createSorter({\n model,\n sorters: result\n });\n }, sorters)\n .join(\"\\n\");\n};\n"],"mappings":";;;;;;AACA;AAaO,MAAMA,cAA8B,GAAG,CAAC;EAC3CC,KAAK;EACLC,MAAM;EACNC,gBAAgB;EAChBC;AACJ,CAAC,KAAa;EACV,IAAIC,OAAiB,GAAG,CACnB,QAAO,EACP,SAAQ,EACT,aAAa,EACb,cAAc,EACd,eAAe,EACf,gBAAgB,CACnB;EAED,KAAK,MAAMC,KAAK,IAAIJ,MAAM,EAAE;IACxB,MAAMK,MAAM,GAAGJ,gBAAgB,CAAC,IAAAK,kCAAgB,EAACF,KAAK,CAAC,CAAC;IACxD,IAAI,CAACC,MAAM,EAAE;MACT;IACJ,CAAC,MAAM,IAAIA,MAAM,CAACE,aAAa,EAAE;MAC7B,MAAMC,MAAM,GAAGH,MAAM,CAACE,aAAa,CAAC;QAChCR,KAAK;QACLK,KAAK;QACLD;MACJ,CAAC,CAAC;MACF,IAAIK,MAAM,EAAE;QACRL,OAAO,GAAGK,MAAM;QAChB;MACJ;IACJ;IACA,IAAI,CAACH,MAAM,CAACI,UAAU,EAAE;MACpB;IACJ;IACAN,OAAO,CAACO,IAAI,CAAE,GAAEN,KAAK,CAACO,OAAQ,MAAK,CAAC;IACpCR,OAAO,CAACO,IAAI,CAAE,GAAEN,KAAK,CAACO,OAAQ,OAAM,CAAC;EACzC;EAEA,OAAOT,aAAa,CACfU,MAAM,CAAC,CAACJ,MAAM,EAAEH,MAAM,KAAK;IACxB,OAAOA,MAAM,CAACQ,YAAY,CAAC;MACvBd,KAAK;MACLI,OAAO,EAAEK;IACb,CAAC,CAAC;EACN,CAAC,EAAEL,OAAO,CAAC,CACVW,IAAI,CAAC,IAAI,CAAC;AACnB,CAAC;AAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createDynamicZoneValidator = void 0;
|
|
7
|
+
const createDynamicZoneValidator = () => {
|
|
8
|
+
return {
|
|
9
|
+
type: "cms-model-field-validator",
|
|
10
|
+
name: "cms-model-field-validator-dynamic-zone",
|
|
11
|
+
validator: {
|
|
12
|
+
name: "dynamicZone",
|
|
13
|
+
validate() {
|
|
14
|
+
// TODO: implement validation.
|
|
15
|
+
return Promise.resolve(true);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
exports.createDynamicZoneValidator = createDynamicZoneValidator;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createDynamicZoneValidator","type","name","validator","validate","Promise","resolve"],"sources":["dynamicZone.ts"],"sourcesContent":["import { CmsModelFieldValidatorPlugin } from \"~/types\";\n\nexport const createDynamicZoneValidator = (): CmsModelFieldValidatorPlugin => {\n return {\n type: \"cms-model-field-validator\",\n name: \"cms-model-field-validator-dynamic-zone\",\n validator: {\n name: \"dynamicZone\",\n validate() {\n // TODO: implement validation.\n return Promise.resolve(true);\n }\n }\n };\n};\n"],"mappings":";;;;;;AAEO,MAAMA,0BAA0B,GAAG,MAAoC;EAC1E,OAAO;IACHC,IAAI,EAAE,2BAA2B;IACjCC,IAAI,EAAE,wCAAwC;IAC9CC,SAAS,EAAE;MACPD,IAAI,EAAE,aAAa;MACnBE,QAAQ,GAAG;QACP;QACA,OAAOC,OAAO,CAACC,OAAO,CAAC,IAAI,CAAC;MAChC;IACJ;EACJ,CAAC;AACL,CAAC;AAAC"}
|
package/validators/index.js
CHANGED
|
@@ -17,5 +17,6 @@ var _dateGte = require("./dateGte");
|
|
|
17
17
|
var _timeLte = require("./timeLte");
|
|
18
18
|
var _timeGte = require("./timeGte");
|
|
19
19
|
var _unique = require("./unique");
|
|
20
|
-
|
|
20
|
+
var _dynamicZone = require("./dynamicZone");
|
|
21
|
+
const createValidators = () => [(0, _gte.createGteValidator)(), (0, _in.createInValidator)(), (0, _lte.createLteValidator)(), (0, _maxLength.createMaxLengthValidator)(), (0, _minLength.createMinLengthValidator)(), (0, _pattern.createPatternValidator)(), (0, _required.createRequiredValidator)(), (0, _patternPlugins.createPatternValidatorPlugins)(), (0, _dateLte.createDateLteValidator)(), (0, _dateGte.createDateGteValidator)(), (0, _timeLte.createTimeLteValidator)(), (0, _timeGte.createTimeGteValidator)(), (0, _unique.createUniqueValidator)(), (0, _dynamicZone.createDynamicZoneValidator)()];
|
|
21
22
|
exports.createValidators = createValidators;
|
package/validators/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createValidators","createGteValidator","createInValidator","createLteValidator","createMaxLengthValidator","createMinLengthValidator","createPatternValidator","createRequiredValidator","createPatternValidatorPlugins","createDateLteValidator","createDateGteValidator","createTimeLteValidator","createTimeGteValidator","createUniqueValidator"],"sources":["index.ts"],"sourcesContent":["import { createGteValidator } from \"./gte\";\nimport { createInValidator } from \"./in\";\nimport { createLteValidator } from \"./lte\";\nimport { createMaxLengthValidator } from \"./maxLength\";\nimport { createMinLengthValidator } from \"./minLength\";\nimport { createPatternValidator } from \"./pattern\";\nimport { createRequiredValidator } from \"./required\";\nimport { createPatternValidatorPlugins } from \"./patternPlugins\";\nimport { createDateLteValidator } from \"./dateLte\";\nimport { createDateGteValidator } from \"./dateGte\";\nimport { createTimeLteValidator } from \"./timeLte\";\nimport { createTimeGteValidator } from \"./timeGte\";\nimport { createUniqueValidator } from \"./unique\";\n\nexport const createValidators = () => [\n createGteValidator(),\n createInValidator(),\n createLteValidator(),\n createMaxLengthValidator(),\n createMinLengthValidator(),\n createPatternValidator(),\n createRequiredValidator(),\n createPatternValidatorPlugins(),\n createDateLteValidator(),\n createDateGteValidator(),\n createTimeLteValidator(),\n createTimeGteValidator(),\n createUniqueValidator()\n];\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEO,MAAMA,gBAAgB,GAAG,MAAM,CAClC,IAAAC,uBAAkB,GAAE,EACpB,IAAAC,qBAAiB,GAAE,EACnB,IAAAC,uBAAkB,GAAE,EACpB,IAAAC,mCAAwB,GAAE,EAC1B,IAAAC,mCAAwB,GAAE,EAC1B,IAAAC,+BAAsB,GAAE,EACxB,IAAAC,iCAAuB,GAAE,EACzB,IAAAC,6CAA6B,GAAE,EAC/B,IAAAC,+BAAsB,GAAE,EACxB,IAAAC,+BAAsB,GAAE,EACxB,IAAAC,+BAAsB,GAAE,EACxB,IAAAC,+BAAsB,GAAE,EACxB,IAAAC,6BAAqB,GAAE,
|
|
1
|
+
{"version":3,"names":["createValidators","createGteValidator","createInValidator","createLteValidator","createMaxLengthValidator","createMinLengthValidator","createPatternValidator","createRequiredValidator","createPatternValidatorPlugins","createDateLteValidator","createDateGteValidator","createTimeLteValidator","createTimeGteValidator","createUniqueValidator","createDynamicZoneValidator"],"sources":["index.ts"],"sourcesContent":["import { createGteValidator } from \"./gte\";\nimport { createInValidator } from \"./in\";\nimport { createLteValidator } from \"./lte\";\nimport { createMaxLengthValidator } from \"./maxLength\";\nimport { createMinLengthValidator } from \"./minLength\";\nimport { createPatternValidator } from \"./pattern\";\nimport { createRequiredValidator } from \"./required\";\nimport { createPatternValidatorPlugins } from \"./patternPlugins\";\nimport { createDateLteValidator } from \"./dateLte\";\nimport { createDateGteValidator } from \"./dateGte\";\nimport { createTimeLteValidator } from \"./timeLte\";\nimport { createTimeGteValidator } from \"./timeGte\";\nimport { createUniqueValidator } from \"./unique\";\nimport { createDynamicZoneValidator } from \"./dynamicZone\";\n\nexport const createValidators = () => [\n createGteValidator(),\n createInValidator(),\n createLteValidator(),\n createMaxLengthValidator(),\n createMinLengthValidator(),\n createPatternValidator(),\n createRequiredValidator(),\n createPatternValidatorPlugins(),\n createDateLteValidator(),\n createDateGteValidator(),\n createTimeLteValidator(),\n createTimeGteValidator(),\n createUniqueValidator(),\n createDynamicZoneValidator()\n];\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEO,MAAMA,gBAAgB,GAAG,MAAM,CAClC,IAAAC,uBAAkB,GAAE,EACpB,IAAAC,qBAAiB,GAAE,EACnB,IAAAC,uBAAkB,GAAE,EACpB,IAAAC,mCAAwB,GAAE,EAC1B,IAAAC,mCAAwB,GAAE,EAC1B,IAAAC,+BAAsB,GAAE,EACxB,IAAAC,iCAAuB,GAAE,EACzB,IAAAC,6CAA6B,GAAE,EAC/B,IAAAC,+BAAsB,GAAE,EACxB,IAAAC,+BAAsB,GAAE,EACxB,IAAAC,+BAAsB,GAAE,EACxB,IAAAC,+BAAsB,GAAE,EACxB,IAAAC,6BAAqB,GAAE,EACvB,IAAAC,uCAA0B,GAAE,CAC/B;AAAC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createFieldModels = void 0;
|
|
7
|
-
var _models = require("./models");
|
|
8
|
-
const createFieldModels = async input => {
|
|
9
|
-
if (!input || input.length === 0) {
|
|
10
|
-
return [];
|
|
11
|
-
}
|
|
12
|
-
const fields = [];
|
|
13
|
-
for (const field of input) {
|
|
14
|
-
const fieldData = new _models.ContentModelFieldModel().populate(field);
|
|
15
|
-
await fieldData.validate();
|
|
16
|
-
fields.push(await fieldData.toJSON());
|
|
17
|
-
}
|
|
18
|
-
return fields;
|
|
19
|
-
};
|
|
20
|
-
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,KAA4B,IAA+B;EAC/F,IAAI,CAACA,KAAK,IAAIA,KAAK,CAACC,MAAM,KAAK,CAAC,EAAE;IAC9B,OAAO,EAAE;EACb;EACA,MAAMC,MAAuB,GAAG,EAAE;EAClC,KAAK,MAAMC,KAAK,IAAIH,KAAK,EAAE;IACvB,MAAMI,SAAS,GAAG,IAAIC,8BAAsB,EAAE,CAACC,QAAQ,CAACH,KAAK,CAAC;IAC9D,MAAMC,SAAS,CAACG,QAAQ,EAAE;IAC1BL,MAAM,CAACM,IAAI,CAAC,MAAMJ,SAAS,CAACK,MAAM,EAAE,CAAC;EACzC;EACA,OAAOP,MAAM;AACjB,CAAC;AAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const validateFieldId: (input: string) => Promise<void>;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.validateFieldId = void 0;
|
|
7
|
-
var _validation = require("@webiny/validation");
|
|
8
|
-
var _systemFields = require("./systemFields");
|
|
9
|
-
const validateFieldId = async input => {
|
|
10
|
-
await _validation.validation.validate(input, "required,maxLength:100");
|
|
11
|
-
const value = String(input || "").trim();
|
|
12
|
-
if (!value.charAt(0).match(/^[a-zA-Z]/)) {
|
|
13
|
-
throw new Error(`Provided ${value} is not valid - must not start with a number.`);
|
|
14
|
-
} else if (value.match(/^([a-zA-Z0-9]+)$/) === null) {
|
|
15
|
-
throw new Error(`Provided ${value} is not valid - must be alphanumeric string.`);
|
|
16
|
-
} else if (_systemFields.fieldSystemFields.includes(value)) {
|
|
17
|
-
throw new Error(`Provided ${value} is not valid - "${value}" is an auto-generated field.`);
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
exports.validateFieldId = validateFieldId;
|