svelte-reflector 2.1.7 → 2.1.8
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.
|
@@ -14,6 +14,7 @@ export declare class PrimitiveProp {
|
|
|
14
14
|
private readonly example;
|
|
15
15
|
private readonly fallbackExample;
|
|
16
16
|
private readonly defaultValue;
|
|
17
|
+
private readonly max;
|
|
17
18
|
private get effectiveType();
|
|
18
19
|
/** Non-required fields become nullable (| null) instead of optional (?) */
|
|
19
20
|
private get isEffectivelyNullable();
|
|
@@ -13,6 +13,7 @@ export class PrimitiveProp {
|
|
|
13
13
|
example;
|
|
14
14
|
fallbackExample;
|
|
15
15
|
defaultValue;
|
|
16
|
+
max;
|
|
16
17
|
get effectiveType() {
|
|
17
18
|
return this.customType ?? this.rawType;
|
|
18
19
|
}
|
|
@@ -30,6 +31,7 @@ export class PrimitiveProp {
|
|
|
30
31
|
this.example = example;
|
|
31
32
|
this.fallbackExample = emptyExample;
|
|
32
33
|
this.defaultValue = schemaObject.default;
|
|
34
|
+
this.max = schemaObject.maximum;
|
|
33
35
|
const buildedType = customType ?? type;
|
|
34
36
|
const treated = treatPropertyName(name);
|
|
35
37
|
this.name = treated.name;
|
|
@@ -113,8 +115,9 @@ export class PrimitiveProp {
|
|
|
113
115
|
typeParam = `<${this.effectiveType}>`;
|
|
114
116
|
}
|
|
115
117
|
const nullableParam = this.isNullable ? "nullable: true, " : "";
|
|
118
|
+
const maxParam = this.max !== undefined ? `max: ${this.max}, ` : "";
|
|
116
119
|
return `
|
|
117
|
-
build${typeParam}({ key: ${keyExpr}, placeholder: ${this.example}, example: ${buildedExample}, required: ${required}, ${nullableParam}${buildedValidator()}})
|
|
120
|
+
build${typeParam}({ key: ${keyExpr}, placeholder: ${this.example}, example: ${buildedExample}, required: ${required}, ${nullableParam}${maxParam}${buildedValidator()}})
|
|
118
121
|
`;
|
|
119
122
|
}
|
|
120
123
|
thisDot() {
|
|
@@ -46,6 +46,7 @@ export class BuildedInput<T> {
|
|
|
46
46
|
required: boolean;
|
|
47
47
|
nullable: boolean;
|
|
48
48
|
placeholder: T;
|
|
49
|
+
max?: number;
|
|
49
50
|
readonly kind = "builded";
|
|
50
51
|
readonly validator?: ValidatorFn<T>;
|
|
51
52
|
|
|
@@ -55,9 +56,10 @@ export class BuildedInput<T> {
|
|
|
55
56
|
required: boolean;
|
|
56
57
|
nullable?: boolean;
|
|
57
58
|
placeholder: T;
|
|
59
|
+
max?: number;
|
|
58
60
|
validator?: ValidatorFn<T>;
|
|
59
61
|
}) {
|
|
60
|
-
const { example, required, nullable, key, validator, placeholder } = params;
|
|
62
|
+
const { example, required, nullable, key, validator, placeholder, max } = params;
|
|
61
63
|
|
|
62
64
|
const initial = key === undefined ? example : key;
|
|
63
65
|
|
|
@@ -67,6 +69,10 @@ export class BuildedInput<T> {
|
|
|
67
69
|
this.nullable = nullable ?? false;
|
|
68
70
|
this.placeholder = placeholder;
|
|
69
71
|
|
|
72
|
+
if (max !== undefined) {
|
|
73
|
+
this.max = max;
|
|
74
|
+
}
|
|
75
|
+
|
|
70
76
|
if (validator) {
|
|
71
77
|
this.validator = validator;
|
|
72
78
|
}
|
|
@@ -116,6 +122,7 @@ export function build<T>(params: {
|
|
|
116
122
|
placeholder: T;
|
|
117
123
|
required: boolean;
|
|
118
124
|
nullable?: boolean;
|
|
125
|
+
max?: number;
|
|
119
126
|
validator?: ValidatorFn<T>;
|
|
120
127
|
}): BuildedInput<T> {
|
|
121
128
|
return new BuildedInput(params);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svelte-reflector",
|
|
3
|
-
"version": "2.1.
|
|
4
|
-
"description": "Reflects
|
|
3
|
+
"version": "2.1.8",
|
|
4
|
+
"description": "Reflects types from openAPI schemas",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|