@tsed/schema-formio 7.0.0-beta.12 → 7.0.0-beta.15
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/lib/cjs/components/anyToComponent.js +1 -1
- package/lib/cjs/components/anyToComponent.js.map +1 -1
- package/lib/cjs/components/propertiesToComponents.js +8 -3
- package/lib/cjs/components/propertiesToComponents.js.map +1 -1
- package/lib/cjs/utils/getFormioSchema.js.map +1 -1
- package/lib/esm/components/anyToComponent.js +1 -1
- package/lib/esm/components/anyToComponent.js.map +1 -1
- package/lib/esm/components/propertiesToComponents.js +8 -3
- package/lib/esm/components/propertiesToComponents.js.map +1 -1
- package/lib/esm/utils/getFormioSchema.js.map +1 -1
- package/lib/types/utils/getFormioSchema.d.ts +1 -1
- package/package.json +9 -9
- package/readme.md +1 -1
|
@@ -5,7 +5,7 @@ const FormioMappersContainer_1 = require("../registries/FormioMappersContainer")
|
|
|
5
5
|
const getRef_1 = require("../utils/getRef");
|
|
6
6
|
function anyToComponent(schema, options) {
|
|
7
7
|
schema = (0, getRef_1.getRef)(schema, options);
|
|
8
|
-
switch (schema
|
|
8
|
+
switch (schema?.type) {
|
|
9
9
|
case "object":
|
|
10
10
|
if (!schema.properties && !schema.$ref) {
|
|
11
11
|
return (0, FormioMappersContainer_1.execMapper)("map", schema, options);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anyToComponent.js","sourceRoot":"","sources":["../../../src/components/anyToComponent.ts"],"names":[],"mappings":";;;AAAA,iFAAsF;AACtF,4CAAuC;AAEvC,SAAgB,cAAc,CAAC,MAAW,EAAE,OAAY;IACtD,MAAM,GAAG,IAAA,eAAM,EAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEjC,QAAQ,MAAM,
|
|
1
|
+
{"version":3,"file":"anyToComponent.js","sourceRoot":"","sources":["../../../src/components/anyToComponent.ts"],"names":[],"mappings":";;;AAAA,iFAAsF;AACtF,4CAAuC;AAEvC,SAAgB,cAAc,CAAC,MAAW,EAAE,OAAY;IACtD,MAAM,GAAG,IAAA,eAAM,EAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEjC,QAAQ,MAAM,EAAE,IAAI,EAAE;QACpB,KAAK,QAAQ;YACX,IAAI,CAAC,MAAM,CAAC,UAAU,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE;gBACtC,OAAO,IAAA,mCAAU,EAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;aAC3C;YAED,OAAO,IAAA,mCAAU,EAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;QAC/C,KAAK,OAAO;YACV,OAAO,IAAA,mCAAU,EAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;QAC9C,KAAK,QAAQ;YACX,OAAO,IAAA,mCAAU,EAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;QAC/C,KAAK,SAAS;YACZ,OAAO,IAAA,mCAAU,EAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;QAChD,KAAK,SAAS,CAAC;QACf,KAAK,QAAQ;YACX,OAAO,IAAA,mCAAU,EAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;KAChD;IAED,OAAO,EAAE,CAAC;AACZ,CAAC;AAtBD,wCAsBC;AAED,IAAA,6CAAoB,EAAC,KAAK,EAAE,cAAc,CAAC,CAAC","sourcesContent":["import {execMapper, registerFormioMapper} from \"../registries/FormioMappersContainer\";\nimport {getRef} from \"../utils/getRef\";\n\nexport function anyToComponent(schema: any, options: any) {\n schema = getRef(schema, options);\n\n switch (schema?.type) {\n case \"object\":\n if (!schema.properties && !schema.$ref) {\n return execMapper(\"map\", schema, options);\n }\n\n return execMapper(\"nested\", schema, options);\n case \"array\":\n return execMapper(\"array\", schema, options);\n case \"string\":\n return execMapper(\"string\", schema, options);\n case \"boolean\":\n return execMapper(\"boolean\", schema, options);\n case \"integer\":\n case \"number\":\n return execMapper(\"number\", schema, options);\n }\n\n return {};\n}\n\nregisterFormioMapper(\"any\", anyToComponent);\n"]}
|
|
@@ -6,7 +6,7 @@ const change_case_1 = require("change-case");
|
|
|
6
6
|
const FormioMappersContainer_1 = require("../registries/FormioMappersContainer");
|
|
7
7
|
function bindResolvers(component, options) {
|
|
8
8
|
if (component.data) {
|
|
9
|
-
const data = component.data;
|
|
9
|
+
const data = { ...component.data };
|
|
10
10
|
Object.entries(data).forEach(([key, resolver]) => {
|
|
11
11
|
if ((0, core_1.isFunction)(resolver)) {
|
|
12
12
|
options.resolvers.push(async (form) => {
|
|
@@ -14,7 +14,12 @@ function bindResolvers(component, options) {
|
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
16
|
});
|
|
17
|
+
return {
|
|
18
|
+
...component,
|
|
19
|
+
data
|
|
20
|
+
};
|
|
17
21
|
}
|
|
22
|
+
return component;
|
|
18
23
|
}
|
|
19
24
|
function mapValidation(key, base, schema, propSchema) {
|
|
20
25
|
const required = (schema.required || []).includes(key);
|
|
@@ -54,13 +59,13 @@ function propertiesToComponents(schema, options) {
|
|
|
54
59
|
Object.entries(schema.properties).forEach(([key, propSchema]) => {
|
|
55
60
|
const tabsOptions = propSchema["x-formiotabs"];
|
|
56
61
|
const base = (0, FormioMappersContainer_1.execMapper)("any", propSchema, { parentKey: key, ...options });
|
|
57
|
-
|
|
62
|
+
let component = (0, core_1.cleanObject)({
|
|
58
63
|
key,
|
|
59
64
|
...base,
|
|
60
65
|
label: base.label == false ? undefined : base.label || propSchema.title || (0, change_case_1.sentenceCase)(key),
|
|
61
66
|
validate: mapValidation(key, base, schema, propSchema)
|
|
62
67
|
});
|
|
63
|
-
bindResolvers(component, options);
|
|
68
|
+
component = bindResolvers(component, options);
|
|
64
69
|
if (tabsOptions) {
|
|
65
70
|
if (!tabs.pushed) {
|
|
66
71
|
components.push(tabs);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"propertiesToComponents.js","sourceRoot":"","sources":["../../../src/components/propertiesToComponents.ts"],"names":[],"mappings":";;;AAAA,qCAAmD;
|
|
1
|
+
{"version":3,"file":"propertiesToComponents.js","sourceRoot":"","sources":["../../../src/components/propertiesToComponents.ts"],"names":[],"mappings":";;;AAAA,qCAAmD;AAEnD,6CAAyC;AACzC,iFAAsF;AAEtF,SAAS,aAAa,CAAC,SAA0B,EAAE,OAAY;IAC7D,IAAI,SAAS,CAAC,IAAI,EAAE;QAClB,MAAM,IAAI,GAAG,EAAC,GAAG,SAAS,CAAC,IAAI,EAAC,CAAC;QAEjC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,QAAQ,CAAC,EAAE,EAAE;YAC/C,IAAI,IAAA,iBAAU,EAAC,QAAQ,CAAC,EAAE;gBACxB,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,IAAgB,EAAE,EAAE;oBAChD,IAAI,CAAC,GAAG,CAAC,GAAG,MAAM,QAAQ,CAAC,EAAC,GAAG,OAAO,EAAE,SAAS,EAAE,IAAI,EAAC,CAAC,CAAC;gBAC5D,CAAC,CAAC,CAAC;aACJ;QACH,CAAC,CAAC,CAAC;QAEH,OAAO;YACL,GAAG,SAAS;YACZ,IAAI;SACL,CAAC;KACH;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,aAAa,CAAC,GAAW,EAAE,IAAqB,EAAE,MAAW,EAAE,UAAe;IACrF,MAAM,QAAQ,GAAG,CAAC,MAAM,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IACvD,MAAM,QAAQ,GAAG;QACf,GAAG,CAAC,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAC;QACxB,QAAQ;QACR,OAAO,EAAE,UAAU,CAAC,OAAO;QAC3B,SAAS,EAAE,CAAC,QAAQ,IAAI,CAAC,QAAQ,IAAI,UAAU,CAAC,SAAS,GAAG,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ponent, FormioForm} from \"@tsed/formio-types\";\nimport {sentenceCase} from \"change-case\";\nimport {execMapper, registerFormioMapper} from \"../registries/FormioMappersContainer\";\n\nfunction bindResolvers(component: FormioComponent, options: any) {\n if (component.data) {\n const data = {...component.data};\n\n Object.entries(data).forEach(([key, resolver]) => {\n if (isFunction(resolver)) {\n options.resolvers.push(async (form: FormioForm) => {\n data[key] = await resolver({...options, component, form});\n });\n }\n });\n\n return {\n ...component,\n data\n };\n }\n\n return component;\n}\n\nfunction mapValidation(key: string, base: FormioComponent, schema: any, propSchema: any) {\n const required = (schema.required || []).includes(key);\n const validate = {\n ...(base.validate || {}),\n required,\n pattern: propSchema.pattern,\n minLength: !required || (required && propSchema.minLength > 1) ? propSchema.minLength : undefined,\n maxLength: propSchema.maxLength,\n min: propSchema.minimum,\n max: propSchema.maximum\n };\n\n switch (propSchema.type) {\n case \"string\":\n if (propSchema.minLength === 0 && validate.required) {\n validate.minLength = undefined;\n validate.required = false;\n }\n break;\n case \"boolean\":\n validate.required = false;\n break;\n }\n\n return cleanObject(validate);\n}\n\nexport function propertiesToComponents(schema: any, options: any): any[] {\n const tabs = {\n label: \"Tabs\",\n key: \"tabs\",\n type: \"tabs\",\n input: false,\n tableView: false,\n components: new Map<string, any>(),\n pushed: false\n };\n const components: any[] = [];\n\n Object.entries(schema.properties).forEach(([key, propSchema]: [string, any]) => {\n const tabsOptions = propSchema[\"x-formiotabs\"];\n const base = execMapper(\"any\", propSchema, {parentKey: key, ...options});\n\n let component = cleanObject({\n key,\n ...base,\n label: base.label == false ? undefined : base.label || propSchema.title || sentenceCase(key),\n validate: mapValidation(key, base, schema, propSchema)\n });\n\n component = bindResolvers(component, options);\n\n if (tabsOptions) {\n if (!tabs.pushed) {\n components.push(tabs);\n tabs.pushed = true;\n }\n\n if (!tabs.components.has(tabsOptions.key)) {\n tabs.components.set(tabsOptions.key, {\n ...tabsOptions,\n components: []\n });\n }\n\n tabs.components.get(tabsOptions.key).components.push(component);\n } else {\n components.push(component);\n }\n });\n\n if (tabs.components.size) {\n tabs.components = [...tabs.components.values()] as any;\n }\n\n return components;\n}\n\nregisterFormioMapper(\"properties\", propertiesToComponents);\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getFormioSchema.js","sourceRoot":"","sources":["../../../src/utils/getFormioSchema.ts"],"names":[],"mappings":";;;AAAA,qCAA0C;AAC1C,yCAA+E;AAE/E,iFAAgE;AAChE,iEAA4D;AAC5D,6CAAsC;AACtC,wCAAsC;AACtC,0CAAwC;AACxC,4CAA0C;AAC1C,yCAAuC;AACvC,4CAA0C;AAC1C,yCAAuC;AACvC,wCAAsC;AACtC,2CAAyC;AACzC,2CAAyC;AACzC,0CAAwC;AACxC,0CAAwC;AACxC,gDAA8C;AAC9C,2CAAyC;AAElC,KAAK,UAAU,eAAe,CACnC,KAA+B,EAC/B,UAA6B,EAAE;IAE/B,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,SAAS,CAAC;KAClB;IAED,IAAI,IAAA,eAAQ,EAAC,KAAK,CAAC,EAAE;QACnB,OAAO,eAAe,CAAC,+BAAc,CAAC,GAAG,CAAC,KAAK,CAAc,EAAE,OAAO,CAAC,CAAC;KACzE;IAED,MAAM,MAAM,GAAG,wBAAe,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC3C,MAAM,MAAM,GAAG,IAAA,sBAAa,EAAC,MAAM,EAAE;QACnC,GAAG,OAAO;QACV,UAAU,EAAE,IAAI;KACjB,CAAC,CAAC;IAEH,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;IACrC,MAAM,WAAW,GAAG,IAAA,uBAAS,EAAC,IAAI,CAAC,CAAC;IACpC,MAAM,SAAS,GAAmB,EAAE,CAAC;IACrC,MAAM,UAAU,GAAG,IAAA,mCAAU,EAAC,YAAY,EAAE,MAAM,EAAE,EAAC,GAAG,OAAO,EAAE,WAAW,EAAE,MAAM,CAAC,WAAW,EAAE,SAAS,EAAC,CAAC,CAAC;IAC9G,MAAM,IAAI,GAAG;QACX,KAAK,EAAE,IAAI;QACX,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE,MAAM;QACf,IAAI,EAAE,EAAE;QACR,MAAM,EAAE,EAAE;QACV,gBAAgB,EAAE,EAAE;QACpB,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAM,aAAa,EAAE,EAAE,CAAC;QAC3C,IAAI,EAAE,WAAW;QACjB,WAAW;QACX,UAAU;KACX,CAAC;IAEF,MAAM,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,QAAa,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IAE7E,OAAO,IAA6B,CAAC;AACvC,CAAC;AAtCD,0CAsCC","sourcesContent":["import {isString, Type} from \"@tsed/core\";\nimport {getJsonSchema, JsonEntityStore, JsonSchemaOptions} from \"@tsed/schema\";\nimport {FormioForm} from \"@tsed/formio-types\";\nimport {execMapper} from \"../registries/FormioMappersContainer\";\nimport {FormsContainer} from \"../registries/FormsContainer\";\nimport {paramCase} from \"change-case\";\nimport \"../components/anyToComponent\";\nimport \"../components/arrayToComponent\";\nimport \"../components/booleanToComponent\";\nimport \"../components/dateToComponent\";\nimport \"../components/defaultToComponent\";\nimport \"../components/enumToComponent\";\nimport \"../components/mapToComponent\";\nimport \"../components/nestedToComponent\";\nimport \"../components/numberToComponent\";\nimport \"../components/objectToEditGrid\";\nimport \"../components/panelToComponent\";\nimport \"../components/propertiesToComponents\";\nimport \"../components/stringToComponent\";\n\nexport async function getFormioSchema(\n model: string | any | undefined,\n options: JsonSchemaOptions = {}\n): Promise<Omit<FormioForm, \"
|
|
1
|
+
{"version":3,"file":"getFormioSchema.js","sourceRoot":"","sources":["../../../src/utils/getFormioSchema.ts"],"names":[],"mappings":";;;AAAA,qCAA0C;AAC1C,yCAA+E;AAE/E,iFAAgE;AAChE,iEAA4D;AAC5D,6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X,UAAU;KACX,CAAC;IAEF,MAAM,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,QAAa,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IAE7E,OAAO,IAA6B,CAAC;AACvC,CAAC;AAtCD,0CAsCC","sourcesContent":["import {isString, Type} from \"@tsed/core\";\nimport {getJsonSchema, JsonEntityStore, JsonSchemaOptions} from \"@tsed/schema\";\nimport {FormioForm} from \"@tsed/formio-types\";\nimport {execMapper} from \"../registries/FormioMappersContainer\";\nimport {FormsContainer} from \"../registries/FormsContainer\";\nimport {paramCase} from \"change-case\";\nimport \"../components/anyToComponent\";\nimport \"../components/arrayToComponent\";\nimport \"../components/booleanToComponent\";\nimport \"../components/dateToComponent\";\nimport \"../components/defaultToComponent\";\nimport \"../components/enumToComponent\";\nimport \"../components/mapToComponent\";\nimport \"../components/nestedToComponent\";\nimport \"../components/numberToComponent\";\nimport \"../components/objectToEditGrid\";\nimport \"../components/panelToComponent\";\nimport \"../components/propertiesToComponents\";\nimport \"../components/stringToComponent\";\n\nexport async function getFormioSchema(\n model: string | any | undefined,\n options: JsonSchemaOptions = {}\n): Promise<Omit<FormioForm, \"_id\" | \"deleted\" | \"owner\"> | undefined> {\n if (!model) {\n return undefined;\n }\n\n if (isString(model)) {\n return getFormioSchema(FormsContainer.get(model) as Type<any>, options);\n }\n\n const entity = JsonEntityStore.from(model);\n const schema = getJsonSchema(entity, {\n ...options,\n customKeys: true\n });\n\n const name = entity.schema.getName();\n const machineName = paramCase(name);\n const resolvers: Promise<any>[] = [];\n const components = execMapper(\"properties\", schema, {...options, definitions: schema.definitions, resolvers});\n const form = {\n title: name,\n type: \"form\",\n display: \"form\",\n tags: [],\n access: [],\n submissionAccess: [],\n ...entity.store.get<any>(\"formio:form\", {}),\n name: machineName,\n machineName,\n components\n };\n\n await Promise.all(resolvers.map((resolver: any) => resolver(form, options)));\n\n return form as unknown as FormioForm;\n}\n"]}
|
|
@@ -2,7 +2,7 @@ import { execMapper, registerFormioMapper } from "../registries/FormioMappersCon
|
|
|
2
2
|
import { getRef } from "../utils/getRef.js";
|
|
3
3
|
export function anyToComponent(schema, options) {
|
|
4
4
|
schema = getRef(schema, options);
|
|
5
|
-
switch (schema
|
|
5
|
+
switch (schema?.type) {
|
|
6
6
|
case "object":
|
|
7
7
|
if (!schema.properties && !schema.$ref) {
|
|
8
8
|
return execMapper("map", schema, options);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anyToComponent.js","sourceRoot":"","sources":["../../../src/components/anyToComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,oBAAoB,EAAC,MAAM,sCAAsC,CAAC;AACtF,OAAO,EAAC,MAAM,EAAC,MAAM,iBAAiB,CAAC;AAEvC,MAAM,UAAU,cAAc,CAAC,MAAW,EAAE,OAAY;IACtD,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEjC,QAAQ,MAAM,
|
|
1
|
+
{"version":3,"file":"anyToComponent.js","sourceRoot":"","sources":["../../../src/components/anyToComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,oBAAoB,EAAC,MAAM,sCAAsC,CAAC;AACtF,OAAO,EAAC,MAAM,EAAC,MAAM,iBAAiB,CAAC;AAEvC,MAAM,UAAU,cAAc,CAAC,MAAW,EAAE,OAAY;IACtD,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEjC,QAAQ,MAAM,EAAE,IAAI,EAAE;QACpB,KAAK,QAAQ;YACX,IAAI,CAAC,MAAM,CAAC,UAAU,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE;gBACtC,OAAO,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;aAC3C;YAED,OAAO,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;QAC/C,KAAK,OAAO;YACV,OAAO,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;QAC9C,KAAK,QAAQ;YACX,OAAO,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;QAC/C,KAAK,SAAS;YACZ,OAAO,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;QAChD,KAAK,SAAS,CAAC;QACf,KAAK,QAAQ;YACX,OAAO,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;KAChD;IAED,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,oBAAoB,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC","sourcesContent":["import {execMapper, registerFormioMapper} from \"../registries/FormioMappersContainer\";\nimport {getRef} from \"../utils/getRef\";\n\nexport function anyToComponent(schema: any, options: any) {\n schema = getRef(schema, options);\n\n switch (schema?.type) {\n case \"object\":\n if (!schema.properties && !schema.$ref) {\n return execMapper(\"map\", schema, options);\n }\n\n return execMapper(\"nested\", schema, options);\n case \"array\":\n return execMapper(\"array\", schema, options);\n case \"string\":\n return execMapper(\"string\", schema, options);\n case \"boolean\":\n return execMapper(\"boolean\", schema, options);\n case \"integer\":\n case \"number\":\n return execMapper(\"number\", schema, options);\n }\n\n return {};\n}\n\nregisterFormioMapper(\"any\", anyToComponent);\n"]}
|
|
@@ -3,7 +3,7 @@ import { sentenceCase } from "change-case";
|
|
|
3
3
|
import { execMapper, registerFormioMapper } from "../registries/FormioMappersContainer.js";
|
|
4
4
|
function bindResolvers(component, options) {
|
|
5
5
|
if (component.data) {
|
|
6
|
-
const data = component.data;
|
|
6
|
+
const data = { ...component.data };
|
|
7
7
|
Object.entries(data).forEach(([key, resolver]) => {
|
|
8
8
|
if (isFunction(resolver)) {
|
|
9
9
|
options.resolvers.push(async (form) => {
|
|
@@ -11,7 +11,12 @@ function bindResolvers(component, options) {
|
|
|
11
11
|
});
|
|
12
12
|
}
|
|
13
13
|
});
|
|
14
|
+
return {
|
|
15
|
+
...component,
|
|
16
|
+
data
|
|
17
|
+
};
|
|
14
18
|
}
|
|
19
|
+
return component;
|
|
15
20
|
}
|
|
16
21
|
function mapValidation(key, base, schema, propSchema) {
|
|
17
22
|
const required = (schema.required || []).includes(key);
|
|
@@ -51,13 +56,13 @@ export function propertiesToComponents(schema, options) {
|
|
|
51
56
|
Object.entries(schema.properties).forEach(([key, propSchema]) => {
|
|
52
57
|
const tabsOptions = propSchema["x-formiotabs"];
|
|
53
58
|
const base = execMapper("any", propSchema, { parentKey: key, ...options });
|
|
54
|
-
|
|
59
|
+
let component = cleanObject({
|
|
55
60
|
key,
|
|
56
61
|
...base,
|
|
57
62
|
label: base.label == false ? undefined : base.label || propSchema.title || sentenceCase(key),
|
|
58
63
|
validate: mapValidation(key, base, schema, propSchema)
|
|
59
64
|
});
|
|
60
|
-
bindResolvers(component, options);
|
|
65
|
+
component = bindResolvers(component, options);
|
|
61
66
|
if (tabsOptions) {
|
|
62
67
|
if (!tabs.pushed) {
|
|
63
68
|
components.push(tabs);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"propertiesToComponents.js","sourceRoot":"","sources":["../../../src/components/propertiesToComponents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAE,UAAU,EAAC,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"propertiesToComponents.js","sourceRoot":"","sources":["../../../src/components/propertiesToComponents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAE,UAAU,EAAC,MAAM,YAAY,CAAC;AAEnD,OAAO,EAAC,YAAY,EAAC,MAAM,aAAa,CAAC;AACzC,OAAO,EAAC,UAAU,EAAE,oBAAoB,EAAC,MAAM,sCAAsC,CAAC;AAEtF,SAAS,aAAa,CAAC,SAA0B,EAAE,OAAY;IAC7D,IAAI,SAAS,CAAC,IAAI,EAAE;QAClB,MAAM,IAAI,GAAG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CAAC;QAE9C,IAAI,WAAW,EAAE;YACf,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;gBAChB,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACtB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;aACpB;YAED,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE;gBACzC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,WAAW,CAAC,GAAG,EAAE;oBACnC,GAAG,WAAW;oBACd,UAAU,EAAE,EAAE;iBACf,CAAC,CAAC;aACJ;YAED,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;SACjE;aAAM;YACL,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;SAC5B;IACH,CAAC,CAAC,CAAC;IAEH,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE;QACxB,IAAI,CAAC,UAAU,GAAG,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAQ,CAAC;KACxD;IAED,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,oBAAoB,CAAC,YAAY,EAAE,sBAAsB,CAAC,CAAC","sourcesContent":["import {cleanObject, isFunction} from \"@tsed/core\";\nimport {FormioComponent, FormioForm} from \"@tsed/formio-types\";\nimport {sentenceCase} from \"change-case\";\nimport {execMapper, registerFormioMapper} from \"../registries/FormioMappersContainer\";\n\nfunction bindResolvers(component: FormioComponent, options: any) {\n if (component.data) {\n const data = {...component.data};\n\n Object.entries(data).forEach(([key, resolver]) => {\n if (isFunction(resolver)) {\n options.resolvers.push(async (form: FormioForm) => {\n data[key] = await resolver({...options, component, form});\n });\n }\n });\n\n return {\n ...component,\n data\n };\n }\n\n return component;\n}\n\nfunction mapValidation(key: string, base: FormioComponent, schema: any, propSchema: any) {\n const required = (schema.required || []).includes(key);\n const validate = {\n ...(base.validate || {}),\n required,\n pattern: propSchema.pattern,\n minLength: !required || (required && propSchema.minLength > 1) ? propSchema.minLength : undefined,\n maxLength: propSchema.maxLength,\n min: propSchema.minimum,\n max: propSchema.maximum\n };\n\n switch (propSchema.type) {\n case \"string\":\n if (propSchema.minLength === 0 && validate.required) {\n validate.minLength = undefined;\n validate.required = false;\n }\n break;\n case \"boolean\":\n validate.required = false;\n break;\n }\n\n return cleanObject(validate);\n}\n\nexport function propertiesToComponents(schema: any, options: any): any[] {\n const tabs = {\n label: \"Tabs\",\n key: \"tabs\",\n type: \"tabs\",\n input: false,\n tableView: false,\n components: new Map<string, any>(),\n pushed: false\n };\n const components: any[] = [];\n\n Object.entries(schema.properties).forEach(([key, propSchema]: [string, any]) => {\n const tabsOptions = propSchema[\"x-formiotabs\"];\n const base = execMapper(\"any\", propSchema, {parentKey: key, ...options});\n\n let component = cleanObject({\n key,\n ...base,\n label: base.label == false ? undefined : base.label || propSchema.title || sentenceCase(key),\n validate: mapValidation(key, base, schema, propSchema)\n });\n\n component = bindResolvers(component, options);\n\n if (tabsOptions) {\n if (!tabs.pushed) {\n components.push(tabs);\n tabs.pushed = true;\n }\n\n if (!tabs.components.has(tabsOptions.key)) {\n tabs.components.set(tabsOptions.key, {\n ...tabsOptions,\n components: []\n });\n }\n\n tabs.components.get(tabsOptions.key).components.push(component);\n } else {\n components.push(component);\n }\n });\n\n if (tabs.components.size) {\n tabs.components = [...tabs.components.values()] as any;\n }\n\n return components;\n}\n\nregisterFormioMapper(\"properties\", propertiesToComponents);\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getFormioSchema.js","sourceRoot":"","sources":["../../../src/utils/getFormioSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAO,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAC,aAAa,EAAE,eAAe,EAAoB,MAAM,cAAc,CAAC;AAE/E,OAAO,EAAC,UAAU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,GAAG;QACX,KAAK,EAAE,IAAI;QACX,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE,MAAM;QACf,IAAI,EAAE,EAAE;QACR,MAAM,EAAE,EAAE;QACV,gBAAgB,EAAE,EAAE;QACpB,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAM,aAAa,EAAE,EAAE,CAAC;QAC3C,IAAI,EAAE,WAAW;QACjB,WAAW;QACX,UAAU;KACX,CAAC;IAEF,MAAM,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,QAAa,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IAE7E,OAAO,IAA6B,CAAC;AACvC,CAAC","sourcesContent":["import {isString, Type} from \"@tsed/core\";\nimport {getJsonSchema, JsonEntityStore, JsonSchemaOptions} from \"@tsed/schema\";\nimport {FormioForm} from \"@tsed/formio-types\";\nimport {execMapper} from \"../registries/FormioMappersContainer\";\nimport {FormsContainer} from \"../registries/FormsContainer\";\nimport {paramCase} from \"change-case\";\nimport \"../components/anyToComponent\";\nimport \"../components/arrayToComponent\";\nimport \"../components/booleanToComponent\";\nimport \"../components/dateToComponent\";\nimport \"../components/defaultToComponent\";\nimport \"../components/enumToComponent\";\nimport \"../components/mapToComponent\";\nimport \"../components/nestedToComponent\";\nimport \"../components/numberToComponent\";\nimport \"../components/objectToEditGrid\";\nimport \"../components/panelToComponent\";\nimport \"../components/propertiesToComponents\";\nimport \"../components/stringToComponent\";\n\nexport async function getFormioSchema(\n model: string | any | undefined,\n options: JsonSchemaOptions = {}\n): Promise<Omit<FormioForm, \"
|
|
1
|
+
{"version":3,"file":"getFormioSchema.js","sourceRoot":"","sources":["../../../src/utils/getFormioSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAO,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAC,aAAa,EAAE,eAAe,EAAoB,MAAM,cAAc,CAAC;AAE/E,OA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9G,MAAM,IAAI,GAAG;QACX,KAAK,EAAE,IAAI;QACX,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE,MAAM;QACf,IAAI,EAAE,EAAE;QACR,MAAM,EAAE,EAAE;QACV,gBAAgB,EAAE,EAAE;QACpB,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAM,aAAa,EAAE,EAAE,CAAC;QAC3C,IAAI,EAAE,WAAW;QACjB,WAAW;QACX,UAAU;KACX,CAAC;IAEF,MAAM,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,QAAa,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IAE7E,OAAO,IAA6B,CAAC;AACvC,CAAC","sourcesContent":["import {isString, Type} from \"@tsed/core\";\nimport {getJsonSchema, JsonEntityStore, JsonSchemaOptions} from \"@tsed/schema\";\nimport {FormioForm} from \"@tsed/formio-types\";\nimport {execMapper} from \"../registries/FormioMappersContainer\";\nimport {FormsContainer} from \"../registries/FormsContainer\";\nimport {paramCase} from \"change-case\";\nimport \"../components/anyToComponent\";\nimport \"../components/arrayToComponent\";\nimport \"../components/booleanToComponent\";\nimport \"../components/dateToComponent\";\nimport \"../components/defaultToComponent\";\nimport \"../components/enumToComponent\";\nimport \"../components/mapToComponent\";\nimport \"../components/nestedToComponent\";\nimport \"../components/numberToComponent\";\nimport \"../components/objectToEditGrid\";\nimport \"../components/panelToComponent\";\nimport \"../components/propertiesToComponents\";\nimport \"../components/stringToComponent\";\n\nexport async function getFormioSchema(\n model: string | any | undefined,\n options: JsonSchemaOptions = {}\n): Promise<Omit<FormioForm, \"_id\" | \"deleted\" | \"owner\"> | undefined> {\n if (!model) {\n return undefined;\n }\n\n if (isString(model)) {\n return getFormioSchema(FormsContainer.get(model) as Type<any>, options);\n }\n\n const entity = JsonEntityStore.from(model);\n const schema = getJsonSchema(entity, {\n ...options,\n customKeys: true\n });\n\n const name = entity.schema.getName();\n const machineName = paramCase(name);\n const resolvers: Promise<any>[] = [];\n const components = execMapper(\"properties\", schema, {...options, definitions: schema.definitions, resolvers});\n const form = {\n title: name,\n type: \"form\",\n display: \"form\",\n tags: [],\n access: [],\n submissionAccess: [],\n ...entity.store.get<any>(\"formio:form\", {}),\n name: machineName,\n machineName,\n components\n };\n\n await Promise.all(resolvers.map((resolver: any) => resolver(form, options)));\n\n return form as unknown as FormioForm;\n}\n"]}
|
|
@@ -13,4 +13,4 @@ import "../components/objectToEditGrid";
|
|
|
13
13
|
import "../components/panelToComponent";
|
|
14
14
|
import "../components/propertiesToComponents";
|
|
15
15
|
import "../components/stringToComponent";
|
|
16
|
-
export declare function getFormioSchema(model: string | any | undefined, options?: JsonSchemaOptions): Promise<Omit<FormioForm, "
|
|
16
|
+
export declare function getFormioSchema(model: string | any | undefined, options?: JsonSchemaOptions): Promise<Omit<FormioForm, "_id" | "deleted" | "owner"> | undefined>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/schema-formio",
|
|
3
|
-
"version": "7.0.0-beta.
|
|
3
|
+
"version": "7.0.0-beta.15",
|
|
4
4
|
"description": "Transform Ts.ED Schema & JsonSchema to a valid Formio schema",
|
|
5
5
|
"private": false,
|
|
6
6
|
"source": "./src/index.ts",
|
|
@@ -33,19 +33,19 @@
|
|
|
33
33
|
"tsed"
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@tsed/formio-types": "7.0.0-beta.
|
|
36
|
+
"@tsed/formio-types": "7.0.0-beta.15",
|
|
37
37
|
"change-case": "4.1.2",
|
|
38
|
-
"tslib": "2.
|
|
38
|
+
"tslib": "2.4.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@tsed/core": "7.0.0-beta.
|
|
42
|
-
"@tsed/openspec": "7.0.0-beta.
|
|
43
|
-
"@tsed/schema": "7.0.0-beta.
|
|
41
|
+
"@tsed/core": "7.0.0-beta.15",
|
|
42
|
+
"@tsed/openspec": "7.0.0-beta.15",
|
|
43
|
+
"@tsed/schema": "7.0.0-beta.15"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
|
-
"@tsed/core": "^7.0.0-beta.
|
|
47
|
-
"@tsed/openspec": "^7.0.0-beta.
|
|
48
|
-
"@tsed/schema": "^7.0.0-beta.
|
|
46
|
+
"@tsed/core": "^7.0.0-beta.15",
|
|
47
|
+
"@tsed/openspec": "^7.0.0-beta.15",
|
|
48
|
+
"@tsed/schema": "^7.0.0-beta.15",
|
|
49
49
|
"formiojs": ">=4.0.0",
|
|
50
50
|
"lodash": ">=4.0.0",
|
|
51
51
|
"moment": ">=2.0.0"
|
package/readme.md
CHANGED
|
@@ -186,7 +186,7 @@ Support this project by becoming a sponsor. Your logo will show up here with a l
|
|
|
186
186
|
|
|
187
187
|
The MIT License (MIT)
|
|
188
188
|
|
|
189
|
-
Copyright (c) 2016 -
|
|
189
|
+
Copyright (c) 2016 - 2022 Romain Lenzotti
|
|
190
190
|
|
|
191
191
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
192
192
|
|