mobiletto-orm-typedef-gen 2.1.57 → 2.1.60
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/generate.js +2 -4
- package/lib/cjs/templates/yup.ts.hbs +11 -11
- package/lib/esm/generate.js +2 -4
- package/lib/esm/templates/yup.ts.hbs +11 -11
- package/package.json +2 -2
package/lib/cjs/generate.js
CHANGED
|
@@ -94,10 +94,8 @@ const defaultPrepareContext = (typeDef, ctx) => {
|
|
|
94
94
|
field.testCode = field.test.valid.toString();
|
|
95
95
|
}
|
|
96
96
|
field.Name = capitalize(field.name);
|
|
97
|
-
field.fullName =
|
|
98
|
-
|
|
99
|
-
? field.label
|
|
100
|
-
: (ctx.name !== typeDef.typeName ? ctx.name + "_" : "") + field.name;
|
|
97
|
+
field.fullName = (ctx.name !== typeDef.typeName ? ctx.name + "_" : "") + field.name;
|
|
98
|
+
field.labelName = typeof field.label === "string" ? field.label : field.fullName;
|
|
101
99
|
}
|
|
102
100
|
ctx.fieldNamesArray = JSON.stringify(fieldNames);
|
|
103
101
|
ctx.fieldParamsArray = fieldNames.join(",");
|
|
@@ -5,20 +5,20 @@ import * as yup from "yup";{{/if}}
|
|
|
5
5
|
|
|
6
6
|
export const {{Name}}SchemaFields = {{{curlyOpen}}}{{#each fields}}
|
|
7
7
|
{{name}}: {{#if typeIsObject}}{{ ../Name }}_{{name}}Schema{{else}}{{#if typeIsArray}}yup.array().of(yup.{{valueType}}{{else}}yup.{{type}}{{/if}}(){{#if typeIsString}}.trim().transform(v => v === '' ? undefined : v){{/if}}{{#if isEnum}}
|
|
8
|
-
{{arrayIndent}}.oneOf({{{enumValues}}}, '{{
|
|
9
|
-
{{arrayIndent}}.min({{minValue}}, '{{
|
|
10
|
-
{{arrayIndent}}.max({{maxValue}}, '{{
|
|
11
|
-
{{arrayIndent}}.min({{min}}, '{{
|
|
12
|
-
{{arrayIndent}}.max({{max}}, '{{
|
|
13
|
-
{{arrayIndent}}.matches({{{regexValue}}}, '{{
|
|
14
|
-
{{arrayIndent}}.typeError('{{
|
|
15
|
-
.typeError('{{
|
|
16
|
-
.required('{{
|
|
8
|
+
{{arrayIndent}}.oneOf({{{enumValues}}}, '{{labelName}}_enum'){{/if}}{{#if minValue}}
|
|
9
|
+
{{arrayIndent}}.min({{minValue}}, '{{labelName}}_minValue'){{/if}}{{#if maxValue}}
|
|
10
|
+
{{arrayIndent}}.max({{maxValue}}, '{{labelName}}_maxValue'){{/if}}{{#if min}}
|
|
11
|
+
{{arrayIndent}}.min({{min}}, '{{labelName}}_min'){{/if}}{{#if max}}
|
|
12
|
+
{{arrayIndent}}.max({{max}}, '{{labelName}}_max'){{/if}}{{#if regex}}
|
|
13
|
+
{{arrayIndent}}.matches({{{regexValue}}}, '{{labelName}}_regex'){{/if}}
|
|
14
|
+
{{arrayIndent}}.typeError('{{labelName}}_invalid'){{#if typeIsArray}})
|
|
15
|
+
.typeError('{{labelName}}_invalid'){{/if}}{{/if}}{{#if required}}
|
|
16
|
+
.required('{{labelName}}_required'){{else}}
|
|
17
17
|
.notRequired(){{/if}}{{#if default}}
|
|
18
18
|
.default({{{defaultValue}}}){{/if}}{{#if test}}
|
|
19
19
|
.test({
|
|
20
20
|
name: "{{test.message}}",
|
|
21
|
-
message: '{{
|
|
21
|
+
message: '{{labelName}}_{{test.message}}',
|
|
22
22
|
skipAbsent: true,
|
|
23
23
|
test(value{{#if ../typescript}}: string | number | boolean | null | undefined{{/if}}, ctx) {
|
|
24
24
|
const t = {{{testCode}}};
|
|
@@ -31,7 +31,7 @@ export const {{Name}}SchemaFields = {{{curlyOpen}}}{{#each fields}}
|
|
|
31
31
|
const v{{#if ../typescript}}: Record<string, unknown>{{/if}} = { {{whenFieldNames}} };
|
|
32
32
|
return w(v);
|
|
33
33
|
},
|
|
34
|
-
then: (schema) => schema.required('{{
|
|
34
|
+
then: (schema) => schema.required('{{labelName}}_required'),
|
|
35
35
|
otherwise: (schema) => schema.notRequired(),
|
|
36
36
|
}){{/if}},{{/each}}
|
|
37
37
|
};
|
package/lib/esm/generate.js
CHANGED
|
@@ -94,10 +94,8 @@ const defaultPrepareContext = (typeDef, ctx) => {
|
|
|
94
94
|
field.testCode = field.test.valid.toString();
|
|
95
95
|
}
|
|
96
96
|
field.Name = capitalize(field.name);
|
|
97
|
-
field.fullName =
|
|
98
|
-
|
|
99
|
-
? field.label
|
|
100
|
-
: (ctx.name !== typeDef.typeName ? ctx.name + "_" : "") + field.name;
|
|
97
|
+
field.fullName = (ctx.name !== typeDef.typeName ? ctx.name + "_" : "") + field.name;
|
|
98
|
+
field.labelName = typeof field.label === "string" ? field.label : field.fullName;
|
|
101
99
|
}
|
|
102
100
|
ctx.fieldNamesArray = JSON.stringify(fieldNames);
|
|
103
101
|
ctx.fieldParamsArray = fieldNames.join(",");
|
|
@@ -5,20 +5,20 @@ import * as yup from "yup";{{/if}}
|
|
|
5
5
|
|
|
6
6
|
export const {{Name}}SchemaFields = {{{curlyOpen}}}{{#each fields}}
|
|
7
7
|
{{name}}: {{#if typeIsObject}}{{ ../Name }}_{{name}}Schema{{else}}{{#if typeIsArray}}yup.array().of(yup.{{valueType}}{{else}}yup.{{type}}{{/if}}(){{#if typeIsString}}.trim().transform(v => v === '' ? undefined : v){{/if}}{{#if isEnum}}
|
|
8
|
-
{{arrayIndent}}.oneOf({{{enumValues}}}, '{{
|
|
9
|
-
{{arrayIndent}}.min({{minValue}}, '{{
|
|
10
|
-
{{arrayIndent}}.max({{maxValue}}, '{{
|
|
11
|
-
{{arrayIndent}}.min({{min}}, '{{
|
|
12
|
-
{{arrayIndent}}.max({{max}}, '{{
|
|
13
|
-
{{arrayIndent}}.matches({{{regexValue}}}, '{{
|
|
14
|
-
{{arrayIndent}}.typeError('{{
|
|
15
|
-
.typeError('{{
|
|
16
|
-
.required('{{
|
|
8
|
+
{{arrayIndent}}.oneOf({{{enumValues}}}, '{{labelName}}_enum'){{/if}}{{#if minValue}}
|
|
9
|
+
{{arrayIndent}}.min({{minValue}}, '{{labelName}}_minValue'){{/if}}{{#if maxValue}}
|
|
10
|
+
{{arrayIndent}}.max({{maxValue}}, '{{labelName}}_maxValue'){{/if}}{{#if min}}
|
|
11
|
+
{{arrayIndent}}.min({{min}}, '{{labelName}}_min'){{/if}}{{#if max}}
|
|
12
|
+
{{arrayIndent}}.max({{max}}, '{{labelName}}_max'){{/if}}{{#if regex}}
|
|
13
|
+
{{arrayIndent}}.matches({{{regexValue}}}, '{{labelName}}_regex'){{/if}}
|
|
14
|
+
{{arrayIndent}}.typeError('{{labelName}}_invalid'){{#if typeIsArray}})
|
|
15
|
+
.typeError('{{labelName}}_invalid'){{/if}}{{/if}}{{#if required}}
|
|
16
|
+
.required('{{labelName}}_required'){{else}}
|
|
17
17
|
.notRequired(){{/if}}{{#if default}}
|
|
18
18
|
.default({{{defaultValue}}}){{/if}}{{#if test}}
|
|
19
19
|
.test({
|
|
20
20
|
name: "{{test.message}}",
|
|
21
|
-
message: '{{
|
|
21
|
+
message: '{{labelName}}_{{test.message}}',
|
|
22
22
|
skipAbsent: true,
|
|
23
23
|
test(value{{#if ../typescript}}: string | number | boolean | null | undefined{{/if}}, ctx) {
|
|
24
24
|
const t = {{{testCode}}};
|
|
@@ -31,7 +31,7 @@ export const {{Name}}SchemaFields = {{{curlyOpen}}}{{#each fields}}
|
|
|
31
31
|
const v{{#if ../typescript}}: Record<string, unknown>{{/if}} = { {{whenFieldNames}} };
|
|
32
32
|
return w(v);
|
|
33
33
|
},
|
|
34
|
-
then: (schema) => schema.required('{{
|
|
34
|
+
then: (schema) => schema.required('{{labelName}}_required'),
|
|
35
35
|
otherwise: (schema) => schema.notRequired(),
|
|
36
36
|
}){{/if}},{{/each}}
|
|
37
37
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mobiletto-orm-typedef-gen",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.60",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "generate various files based on mobiletto-orm-typedef definitions",
|
|
6
6
|
"keywords": [
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"eslint": "^8.44.0",
|
|
53
53
|
"eslint-config-prettier": "^8.8.0",
|
|
54
54
|
"handlebars": "^4.7.7",
|
|
55
|
-
"mobiletto-orm-typedef": "^2.2.
|
|
55
|
+
"mobiletto-orm-typedef": "^2.2.13",
|
|
56
56
|
"mocha": "^10.2.0",
|
|
57
57
|
"prettier": "^3.0.0",
|
|
58
58
|
"tslint-config-prettier": "^1.18.0",
|