@webiny/app-headless-cms-common 0.0.0-unstable.06b2ede40f
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/Fields/ErrorBoundary.d.ts +24 -0
- package/Fields/ErrorBoundary.js +40 -0
- package/Fields/ErrorBoundary.js.map +1 -0
- package/Fields/FieldElement.d.ts +64 -0
- package/Fields/FieldElement.js +71 -0
- package/Fields/FieldElement.js.map +1 -0
- package/Fields/FieldElementError.d.ts +7 -0
- package/Fields/FieldElementError.js +26 -0
- package/Fields/FieldElementError.js.map +1 -0
- package/Fields/Fields.d.ts +11 -0
- package/Fields/Fields.js +35 -0
- package/Fields/Fields.js.map +1 -0
- package/Fields/Label.d.ts +6 -0
- package/Fields/Label.js +10 -0
- package/Fields/Label.js.map +1 -0
- package/Fields/index.d.ts +3 -0
- package/Fields/index.js +5 -0
- package/Fields/index.js.map +1 -0
- package/Fields/useBind.d.ts +9 -0
- package/Fields/useBind.js +113 -0
- package/Fields/useBind.js.map +1 -0
- package/Fields/useRenderPlugins.d.ts +1 -0
- package/Fields/useRenderPlugins.js +7 -0
- package/Fields/useRenderPlugins.js.map +1 -0
- package/LICENSE +21 -0
- package/ModelFieldProvider/ModelFieldContext.d.ts +36 -0
- package/ModelFieldProvider/ModelFieldContext.js +26 -0
- package/ModelFieldProvider/ModelFieldContext.js.map +1 -0
- package/ModelFieldProvider/index.d.ts +2 -0
- package/ModelFieldProvider/index.js +4 -0
- package/ModelFieldProvider/index.js.map +1 -0
- package/ModelFieldProvider/useModelField.d.ts +16 -0
- package/ModelFieldProvider/useModelField.js +29 -0
- package/ModelFieldProvider/useModelField.js.map +1 -0
- package/ModelProvider/ModelContext.d.ts +9 -0
- package/ModelProvider/ModelContext.js +12 -0
- package/ModelProvider/ModelContext.js.map +1 -0
- package/ModelProvider/index.d.ts +2 -0
- package/ModelProvider/index.js +4 -0
- package/ModelProvider/index.js.map +1 -0
- package/ModelProvider/useModel.d.ts +9 -0
- package/ModelProvider/useModel.js +16 -0
- package/ModelProvider/useModel.js.map +1 -0
- package/README.md +18 -0
- package/constants.d.ts +1 -0
- package/constants.js +3 -0
- package/constants.js.map +1 -0
- package/createFieldsList.d.ts +8 -0
- package/createFieldsList.js +49 -0
- package/createFieldsList.js.map +1 -0
- package/createValidationContainer.d.ts +18 -0
- package/createValidationContainer.js +26 -0
- package/createValidationContainer.js.map +1 -0
- package/createValidators.d.ts +3 -0
- package/createValidators.js +52 -0
- package/createValidators.js.map +1 -0
- package/entries.graphql.d.ts +218 -0
- package/entries.graphql.js +402 -0
- package/entries.graphql.js.map +1 -0
- package/getModelTitleFieldId.d.ts +2 -0
- package/getModelTitleFieldId.js +8 -0
- package/getModelTitleFieldId.js.map +1 -0
- package/index.d.ts +10 -0
- package/index.js +12 -0
- package/index.js.map +1 -0
- package/package.json +52 -0
- package/prepareFormData.d.ts +2 -0
- package/prepareFormData.js +71 -0
- package/prepareFormData.js.map +1 -0
- package/types/index.d.ts +567 -0
- package/types/index.js +56 -0
- package/types/index.js.map +1 -0
- package/types/model.d.ts +100 -0
- package/types/model.js +3 -0
- package/types/model.js.map +1 -0
- package/types/shared.d.ts +5 -0
- package/types/shared.js +3 -0
- package/types/shared.js.map +1 -0
- package/types/validation.d.ts +79 -0
- package/types/validation.js +3 -0
- package/types/validation.js.map +1 -0
package/types/model.d.ts
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import type { Validator } from "@webiny/validation/types";
|
|
2
|
+
import type { CmsModelFieldValidator } from "./validation";
|
|
3
|
+
import type { CmsDynamicZoneTemplate, CmsEditorFieldPredefinedValues, CmsModelFieldRendererPlugin } from "./index";
|
|
4
|
+
import type { CmsIdentity } from "./shared";
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated Use `CmsModelField` instead.
|
|
7
|
+
*/
|
|
8
|
+
export type CmsEditorField<T = unknown> = CmsModelField<T>;
|
|
9
|
+
export interface CmsModelFieldSettings<T = unknown> {
|
|
10
|
+
defaultValue?: string | boolean | number | null | undefined;
|
|
11
|
+
defaultSetValue?: string;
|
|
12
|
+
type?: string;
|
|
13
|
+
fields?: CmsModelField<T>[];
|
|
14
|
+
layout?: string[][];
|
|
15
|
+
models?: Pick<CmsModel, "modelId">[];
|
|
16
|
+
templates?: CmsDynamicZoneTemplate[];
|
|
17
|
+
imagesOnly?: boolean;
|
|
18
|
+
[key: string]: any;
|
|
19
|
+
}
|
|
20
|
+
export type CmsModelField<T = unknown> = T & {
|
|
21
|
+
id: string;
|
|
22
|
+
type: string;
|
|
23
|
+
fieldId: CmsEditorFieldId;
|
|
24
|
+
storageId?: string;
|
|
25
|
+
label: string;
|
|
26
|
+
helpText?: string;
|
|
27
|
+
placeholderText?: string;
|
|
28
|
+
validation?: (CmsModelFieldValidator | Validator)[];
|
|
29
|
+
listValidation?: CmsModelFieldValidator[];
|
|
30
|
+
multipleValues?: boolean;
|
|
31
|
+
predefinedValues?: CmsEditorFieldPredefinedValues;
|
|
32
|
+
settings?: CmsModelFieldSettings<T>;
|
|
33
|
+
renderer: {
|
|
34
|
+
name: string;
|
|
35
|
+
settings?: Record<string, any>;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Use this only for programmatic assignment of renderers.
|
|
39
|
+
* Since functions cannot be serialized, this can only work via code.
|
|
40
|
+
*/
|
|
41
|
+
| CmsModelFieldRendererPlugin["renderer"]["render"];
|
|
42
|
+
tags?: string[];
|
|
43
|
+
};
|
|
44
|
+
export type CmsEditorFieldId = string;
|
|
45
|
+
export type CmsEditorFieldsLayout = CmsEditorFieldId[][];
|
|
46
|
+
/**
|
|
47
|
+
* @category GraphQL
|
|
48
|
+
* @category Model
|
|
49
|
+
*/
|
|
50
|
+
export type CmsEditorContentModel = CmsModel;
|
|
51
|
+
/**
|
|
52
|
+
* @category GraphQL
|
|
53
|
+
* @category Group
|
|
54
|
+
*/
|
|
55
|
+
export interface CmsGroup {
|
|
56
|
+
id: string;
|
|
57
|
+
name: string;
|
|
58
|
+
slug: string;
|
|
59
|
+
icon: string;
|
|
60
|
+
description?: string;
|
|
61
|
+
contentModels: CmsModel[];
|
|
62
|
+
createdBy: CmsIdentity;
|
|
63
|
+
/**
|
|
64
|
+
* Tells if this group is a plugin one (cannot be changed/deleted)
|
|
65
|
+
*/
|
|
66
|
+
plugin?: boolean;
|
|
67
|
+
}
|
|
68
|
+
export interface CmsModel {
|
|
69
|
+
id: string;
|
|
70
|
+
group: Pick<CmsGroup, "id" | "name">;
|
|
71
|
+
description?: string;
|
|
72
|
+
version: number;
|
|
73
|
+
layout?: CmsEditorFieldsLayout;
|
|
74
|
+
fields: CmsModelField[];
|
|
75
|
+
lockedFields: CmsModelField[];
|
|
76
|
+
icon: string;
|
|
77
|
+
name: string;
|
|
78
|
+
modelId: string;
|
|
79
|
+
singularApiName: string;
|
|
80
|
+
pluralApiName: string;
|
|
81
|
+
titleFieldId: string | null;
|
|
82
|
+
descriptionFieldId: string | null;
|
|
83
|
+
imageFieldId: string | null;
|
|
84
|
+
settings: {
|
|
85
|
+
[key: string]: any;
|
|
86
|
+
};
|
|
87
|
+
status: string;
|
|
88
|
+
savedOn: string;
|
|
89
|
+
meta: any;
|
|
90
|
+
createdBy: CmsIdentity;
|
|
91
|
+
tags: string[];
|
|
92
|
+
/**
|
|
93
|
+
* If model is a plugin one (it cannot be changed/deleted)
|
|
94
|
+
*/
|
|
95
|
+
plugin?: boolean;
|
|
96
|
+
/**
|
|
97
|
+
* Is model currently being deleted?
|
|
98
|
+
*/
|
|
99
|
+
isBeingDeleted?: boolean;
|
|
100
|
+
}
|
package/types/model.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["model.ts"],"sourcesContent":["import type { Validator } from \"@webiny/validation/types\";\nimport type { CmsModelFieldValidator } from \"~/types/validation\";\nimport type {\n CmsDynamicZoneTemplate,\n CmsEditorFieldPredefinedValues,\n CmsModelFieldRendererPlugin\n} from \"~/types/index\";\nimport type { CmsIdentity } from \"~/types/shared\";\n\n/**\n * @deprecated Use `CmsModelField` instead.\n */\nexport type CmsEditorField<T = unknown> = CmsModelField<T>;\n\nexport interface CmsModelFieldSettings<T = unknown> {\n defaultValue?: string | boolean | number | null | undefined;\n defaultSetValue?: string;\n type?: string;\n fields?: CmsModelField<T>[];\n layout?: string[][];\n models?: Pick<CmsModel, \"modelId\">[];\n templates?: CmsDynamicZoneTemplate[];\n imagesOnly?: boolean;\n [key: string]: any;\n}\n\nexport type CmsModelField<T = unknown> = T & {\n id: string;\n type: string;\n fieldId: CmsEditorFieldId;\n storageId?: string;\n label: string;\n helpText?: string;\n placeholderText?: string;\n validation?: (CmsModelFieldValidator | Validator)[];\n listValidation?: CmsModelFieldValidator[];\n multipleValues?: boolean;\n predefinedValues?: CmsEditorFieldPredefinedValues;\n settings?: CmsModelFieldSettings<T>;\n renderer:\n | {\n name: string;\n settings?: Record<string, any>;\n }\n /**\n * Use this only for programmatic assignment of renderers.\n * Since functions cannot be serialized, this can only work via code.\n */\n | CmsModelFieldRendererPlugin[\"renderer\"][\"render\"];\n tags?: string[];\n};\n\nexport type CmsEditorFieldId = string;\nexport type CmsEditorFieldsLayout = CmsEditorFieldId[][];\n\n/**\n * @category GraphQL\n * @category Model\n */\nexport type CmsEditorContentModel = CmsModel;\n\n/**\n * @category GraphQL\n * @category Group\n */\nexport interface CmsGroup {\n id: string;\n name: string;\n slug: string;\n icon: string;\n description?: string;\n contentModels: CmsModel[];\n createdBy: CmsIdentity;\n /**\n * Tells if this group is a plugin one (cannot be changed/deleted)\n */\n plugin?: boolean;\n}\n\nexport interface CmsModel {\n id: string;\n group: Pick<CmsGroup, \"id\" | \"name\">;\n description?: string;\n version: number;\n layout?: CmsEditorFieldsLayout;\n fields: CmsModelField[];\n lockedFields: CmsModelField[];\n icon: string;\n name: string;\n modelId: string;\n singularApiName: string;\n pluralApiName: string;\n titleFieldId: string | null;\n descriptionFieldId: string | null;\n imageFieldId: string | null;\n settings: {\n [key: string]: any;\n };\n status: string;\n savedOn: string;\n meta: any;\n createdBy: CmsIdentity;\n tags: string[];\n /**\n * If model is a plugin one (it cannot be changed/deleted)\n */\n plugin?: boolean;\n /**\n * Is model currently being deleted?\n */\n isBeingDeleted?: boolean;\n}\n"],"mappings":"","ignoreList":[]}
|
package/types/shared.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["shared.ts"],"sourcesContent":["export interface CmsIdentity {\n id: string;\n displayName: string;\n type: string;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
import type { Plugin } from "@webiny/plugins/types";
|
|
3
|
+
import type { CmsModelField } from "./";
|
|
4
|
+
export interface CmsModelFieldValidatorConfigAdapter {
|
|
5
|
+
isRequired(): boolean;
|
|
6
|
+
getName(): string;
|
|
7
|
+
getLabel(): string;
|
|
8
|
+
getDescription(): string;
|
|
9
|
+
getDefaultMessage(): string;
|
|
10
|
+
getDefaultSettings(): Record<string, any> | undefined;
|
|
11
|
+
getVariables(): CmsModelFieldValidatorVariable[];
|
|
12
|
+
getVariableDescription(variableName: string): string | undefined;
|
|
13
|
+
}
|
|
14
|
+
export interface CmsModelFieldValidatorVariable {
|
|
15
|
+
name: string;
|
|
16
|
+
description: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* This interface is used in the validator configuration UI (Field dialog).
|
|
20
|
+
*/
|
|
21
|
+
export interface CmsModelFieldValidatorConfig {
|
|
22
|
+
name: string;
|
|
23
|
+
required?: boolean;
|
|
24
|
+
label?: string;
|
|
25
|
+
description?: string;
|
|
26
|
+
defaultMessage?: string;
|
|
27
|
+
defaultSettings?: Record<string, any>;
|
|
28
|
+
variables?: CmsModelFieldValidatorVariable[];
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* This interface allows you to control the title, description, and validators located in the specific
|
|
32
|
+
* validators group, like `validators` or `listValidators` within the Field dialog.
|
|
33
|
+
*/
|
|
34
|
+
export interface CmsModelFieldValidatorsGroup {
|
|
35
|
+
validators: (string | CmsModelFieldValidatorConfig)[];
|
|
36
|
+
title?: string;
|
|
37
|
+
description?: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* This interface allows you to generate validators based on the field configuration.
|
|
41
|
+
*/
|
|
42
|
+
export interface CmsModelFieldValidatorsFactory {
|
|
43
|
+
(field: CmsModelField): string[] | CmsModelFieldValidatorsGroup;
|
|
44
|
+
}
|
|
45
|
+
export interface CmsModelFieldValidator {
|
|
46
|
+
name: string;
|
|
47
|
+
message?: string;
|
|
48
|
+
settings?: any;
|
|
49
|
+
}
|
|
50
|
+
export interface CmsModelFieldValidatorPlugin<T = any> extends Plugin {
|
|
51
|
+
type: "cms-model-field-validator";
|
|
52
|
+
validator: {
|
|
53
|
+
name: string;
|
|
54
|
+
label: string;
|
|
55
|
+
description: string;
|
|
56
|
+
defaultMessage: string;
|
|
57
|
+
variables?: CmsModelFieldValidatorVariable[];
|
|
58
|
+
defaultSettings?: Record<string, any>;
|
|
59
|
+
getVariableValues?: (context: {
|
|
60
|
+
validator: CmsModelFieldValidator;
|
|
61
|
+
}) => Record<string, string>;
|
|
62
|
+
renderSettings?: (config: CmsModelFieldValidatorConfigAdapter) => React.ReactElement;
|
|
63
|
+
renderCustomUi?: () => React.ReactElement;
|
|
64
|
+
validate: (value: T, context: {
|
|
65
|
+
validator: CmsModelFieldValidator;
|
|
66
|
+
field: CmsModelField;
|
|
67
|
+
}) => Promise<any>;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
export interface CmsModelFieldRegexValidatorExpressionPlugin extends Plugin {
|
|
71
|
+
type: "cms-model-field-regex-validator-expression";
|
|
72
|
+
pattern: {
|
|
73
|
+
name: string;
|
|
74
|
+
message: string;
|
|
75
|
+
label: string;
|
|
76
|
+
regex: string;
|
|
77
|
+
flags: string;
|
|
78
|
+
};
|
|
79
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["validation.ts"],"sourcesContent":["import type * as React from \"react\";\nimport type { Plugin } from \"@webiny/plugins/types\";\nimport type { CmsModelField } from \"~/types\";\n\nexport interface CmsModelFieldValidatorConfigAdapter {\n isRequired(): boolean;\n getName(): string;\n getLabel(): string;\n getDescription(): string;\n getDefaultMessage(): string;\n getDefaultSettings(): Record<string, any> | undefined;\n getVariables(): CmsModelFieldValidatorVariable[];\n getVariableDescription(variableName: string): string | undefined;\n}\n\nexport interface CmsModelFieldValidatorVariable {\n name: string;\n description: string;\n}\n\n/**\n * This interface is used in the validator configuration UI (Field dialog).\n */\nexport interface CmsModelFieldValidatorConfig {\n name: string;\n required?: boolean;\n label?: string;\n description?: string;\n defaultMessage?: string;\n defaultSettings?: Record<string, any>;\n variables?: CmsModelFieldValidatorVariable[];\n}\n\n/**\n * This interface allows you to control the title, description, and validators located in the specific\n * validators group, like `validators` or `listValidators` within the Field dialog.\n */\nexport interface CmsModelFieldValidatorsGroup {\n validators: (string | CmsModelFieldValidatorConfig)[];\n title?: string;\n description?: string;\n}\n\n/**\n * This interface allows you to generate validators based on the field configuration.\n */\nexport interface CmsModelFieldValidatorsFactory {\n (field: CmsModelField): string[] | CmsModelFieldValidatorsGroup;\n}\n\nexport interface CmsModelFieldValidator {\n name: string;\n message?: string;\n settings?: any;\n}\n\nexport interface CmsModelFieldValidatorPlugin<T = any> extends Plugin {\n type: \"cms-model-field-validator\";\n validator: {\n name: string;\n label: string;\n description: string;\n defaultMessage: string;\n variables?: CmsModelFieldValidatorVariable[];\n defaultSettings?: Record<string, any>;\n getVariableValues?: (context: {\n validator: CmsModelFieldValidator;\n }) => Record<string, string>;\n renderSettings?: (config: CmsModelFieldValidatorConfigAdapter) => React.ReactElement;\n renderCustomUi?: () => React.ReactElement;\n validate: (\n value: T,\n context: {\n validator: CmsModelFieldValidator;\n field: CmsModelField;\n }\n ) => Promise<any>;\n };\n}\n\nexport interface CmsModelFieldRegexValidatorExpressionPlugin extends Plugin {\n type: \"cms-model-field-regex-validator-expression\";\n pattern: {\n name: string;\n message: string;\n label: string;\n regex: string;\n flags: string;\n };\n}\n"],"mappings":"","ignoreList":[]}
|