tinybase 8.3.0-beta.1 → 8.3.0-beta.3
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/@types/_internal/ui-solid/index.d.ts +0 -0
- package/@types/_internal/ui-solid/with-schemas/index.d.ts +1104 -0
- package/@types/persisters/index.d.ts +2 -2
- package/@types/persisters/with-schemas/index.d.ts +2 -2
- package/@types/schematizers/schematizer-arktype/index.d.ts +5 -4
- package/@types/schematizers/schematizer-effect/index.d.ts +7 -7
- package/@types/schematizers/schematizer-typebox/index.d.ts +4 -3
- package/@types/schematizers/schematizer-valibot/index.d.ts +5 -4
- package/@types/schematizers/schematizer-yup/index.d.ts +4 -3
- package/@types/schematizers/schematizer-zod/index.d.ts +6 -5
- package/@types/ui-react/index.d.ts +6 -6
- package/@types/ui-react/with-schemas/index.d.ts +6 -6
- package/@types/ui-solid/index.d.ts +16336 -0
- package/@types/ui-solid/with-schemas/index.d.ts +16951 -0
- package/@types/ui-svelte/index.d.ts +6123 -80
- package/@types/ui-svelte/with-schemas/index.d.ts +7348 -89
- package/agents.md +3 -3
- package/min/schematizers/schematizer-arktype/index.js +1 -1
- package/min/schematizers/schematizer-arktype/index.js.gz +0 -0
- package/min/schematizers/schematizer-arktype/with-schemas/index.js +1 -1
- package/min/schematizers/schematizer-arktype/with-schemas/index.js.gz +0 -0
- package/min/schematizers/schematizer-effect/index.js +1 -1
- package/min/schematizers/schematizer-effect/index.js.gz +0 -0
- package/min/schematizers/schematizer-effect/with-schemas/index.js +1 -1
- package/min/schematizers/schematizer-effect/with-schemas/index.js.gz +0 -0
- package/min/schematizers/schematizer-typebox/index.js +1 -1
- package/min/schematizers/schematizer-typebox/index.js.gz +0 -0
- package/min/schematizers/schematizer-typebox/with-schemas/index.js +1 -1
- package/min/schematizers/schematizer-typebox/with-schemas/index.js.gz +0 -0
- package/min/schematizers/schematizer-valibot/index.js +1 -1
- package/min/schematizers/schematizer-valibot/index.js.gz +0 -0
- package/min/schematizers/schematizer-valibot/with-schemas/index.js +1 -1
- package/min/schematizers/schematizer-valibot/with-schemas/index.js.gz +0 -0
- package/min/schematizers/schematizer-yup/index.js +1 -1
- package/min/schematizers/schematizer-yup/index.js.gz +0 -0
- package/min/schematizers/schematizer-yup/with-schemas/index.js +1 -1
- package/min/schematizers/schematizer-yup/with-schemas/index.js.gz +0 -0
- package/min/schematizers/schematizer-zod/index.js +1 -1
- package/min/schematizers/schematizer-zod/index.js.gz +0 -0
- package/min/schematizers/schematizer-zod/with-schemas/index.js +1 -1
- package/min/schematizers/schematizer-zod/with-schemas/index.js.gz +0 -0
- package/min/ui-react/index.js +1 -1
- package/min/ui-react/index.js.gz +0 -0
- package/min/ui-react/with-schemas/index.js +1 -1
- package/min/ui-react/with-schemas/index.js.gz +0 -0
- package/min/ui-solid/index.js +1 -0
- package/min/ui-solid/index.js.gz +0 -0
- package/min/ui-solid/with-schemas/index.js +1 -0
- package/min/ui-solid/with-schemas/index.js.gz +0 -0
- package/min/ui-svelte/index.js +1 -1
- package/min/ui-svelte/index.js.gz +0 -0
- package/min/ui-svelte/with-schemas/index.js +1 -1
- package/min/ui-svelte/with-schemas/index.js.gz +0 -0
- package/package.json +48 -8
- package/readme.md +3 -3
- package/releases.md +55 -14
- package/schematizers/schematizer-arktype/index.js +16 -11
- package/schematizers/schematizer-arktype/with-schemas/index.js +16 -11
- package/schematizers/schematizer-effect/index.js +27 -14
- package/schematizers/schematizer-effect/with-schemas/index.js +27 -14
- package/schematizers/schematizer-typebox/index.js +13 -4
- package/schematizers/schematizer-typebox/with-schemas/index.js +13 -4
- package/schematizers/schematizer-valibot/index.js +17 -1
- package/schematizers/schematizer-valibot/with-schemas/index.js +17 -1
- package/schematizers/schematizer-yup/index.js +16 -5
- package/schematizers/schematizer-yup/with-schemas/index.js +16 -5
- package/schematizers/schematizer-zod/index.js +16 -6
- package/schematizers/schematizer-zod/with-schemas/index.js +16 -6
- package/ui-react/index.js +1 -1
- package/ui-react/with-schemas/index.js +1 -1
- package/ui-solid/index.js +2154 -0
- package/ui-solid/with-schemas/index.js +2154 -0
- package/ui-svelte/index.js +11 -4
- package/ui-svelte/with-schemas/index.js +11 -4
|
@@ -28,6 +28,7 @@ const isTrue = (thing) => thing === true;
|
|
|
28
28
|
const isFalse = (thing) => thing === false;
|
|
29
29
|
const ifNotNullish = getIfNotFunction(isNullish);
|
|
30
30
|
const ifNotUndefined = getIfNotFunction(isUndefined);
|
|
31
|
+
const isString = (thing) => getTypeOf(thing) == STRING;
|
|
31
32
|
const isArray = (thing) => Array.isArray(thing);
|
|
32
33
|
const size = (arrayOrString) => arrayOrString.length;
|
|
33
34
|
|
|
@@ -112,21 +113,25 @@ const createCustomSchematizer = (unwrapSchema, getProperties) => {
|
|
|
112
113
|
};
|
|
113
114
|
|
|
114
115
|
const unwrapSchema = (schema, defaultValue, allowNull) => {
|
|
115
|
-
|
|
116
|
+
const schemaData = schema?.json ?? schema;
|
|
117
|
+
if (isArray(schemaData)) {
|
|
116
118
|
const hasNull = !arrayEvery(
|
|
117
|
-
|
|
119
|
+
schemaData,
|
|
118
120
|
(item) => !isNull(item?.[UNIT]) && !isNull(item),
|
|
119
121
|
);
|
|
120
122
|
if (
|
|
121
|
-
size(
|
|
122
|
-
isFalse(
|
|
123
|
-
isTrue(
|
|
123
|
+
size(schemaData) === 2 &&
|
|
124
|
+
isFalse(schemaData[0]?.[UNIT]) &&
|
|
125
|
+
isTrue(schemaData[1]?.[UNIT])
|
|
124
126
|
) {
|
|
125
127
|
return [{[TYPE]: BOOLEAN}, defaultValue, allowNull ?? false];
|
|
126
128
|
}
|
|
129
|
+
if (arrayEvery(schemaData, (item) => isString(item?.[UNIT] ?? item))) {
|
|
130
|
+
return [{[TYPE]: STRING}, defaultValue, allowNull ?? false];
|
|
131
|
+
}
|
|
127
132
|
if (hasNull) {
|
|
128
133
|
const nonNullItem = arrayFind(
|
|
129
|
-
|
|
134
|
+
schemaData,
|
|
130
135
|
(item) => !isNull(item?.[UNIT]) && !isNull(item) && item !== '=',
|
|
131
136
|
);
|
|
132
137
|
if (nonNullItem) {
|
|
@@ -134,14 +139,14 @@ const unwrapSchema = (schema, defaultValue, allowNull) => {
|
|
|
134
139
|
}
|
|
135
140
|
}
|
|
136
141
|
}
|
|
137
|
-
if (
|
|
138
|
-
!isArray(schema) &&
|
|
139
|
-
!isUndefined(schema?.[SEQUENCE] ?? schema?.json?.[SEQUENCE])
|
|
140
|
-
) {
|
|
142
|
+
if (!isArray(schemaData) && !isUndefined(schemaData?.[SEQUENCE])) {
|
|
141
143
|
return [{[TYPE]: ARRAY}, defaultValue, allowNull ?? false];
|
|
142
144
|
}
|
|
145
|
+
if (!isArray(schemaData) && isString(schemaData?.[UNIT])) {
|
|
146
|
+
return [{[TYPE]: STRING}, defaultValue, allowNull ?? false];
|
|
147
|
+
}
|
|
143
148
|
return [
|
|
144
|
-
{[TYPE]:
|
|
149
|
+
{[TYPE]: schemaData?.[DOMAIN] || schemaData},
|
|
145
150
|
defaultValue,
|
|
146
151
|
allowNull ?? false,
|
|
147
152
|
];
|
|
@@ -28,6 +28,7 @@ const isTrue = (thing) => thing === true;
|
|
|
28
28
|
const isFalse = (thing) => thing === false;
|
|
29
29
|
const ifNotNullish = getIfNotFunction(isNullish);
|
|
30
30
|
const ifNotUndefined = getIfNotFunction(isUndefined);
|
|
31
|
+
const isString = (thing) => getTypeOf(thing) == STRING;
|
|
31
32
|
const isArray = (thing) => Array.isArray(thing);
|
|
32
33
|
const size = (arrayOrString) => arrayOrString.length;
|
|
33
34
|
|
|
@@ -112,21 +113,25 @@ const createCustomSchematizer = (unwrapSchema, getProperties) => {
|
|
|
112
113
|
};
|
|
113
114
|
|
|
114
115
|
const unwrapSchema = (schema, defaultValue, allowNull) => {
|
|
115
|
-
|
|
116
|
+
const schemaData = schema?.json ?? schema;
|
|
117
|
+
if (isArray(schemaData)) {
|
|
116
118
|
const hasNull = !arrayEvery(
|
|
117
|
-
|
|
119
|
+
schemaData,
|
|
118
120
|
(item) => !isNull(item?.[UNIT]) && !isNull(item),
|
|
119
121
|
);
|
|
120
122
|
if (
|
|
121
|
-
size(
|
|
122
|
-
isFalse(
|
|
123
|
-
isTrue(
|
|
123
|
+
size(schemaData) === 2 &&
|
|
124
|
+
isFalse(schemaData[0]?.[UNIT]) &&
|
|
125
|
+
isTrue(schemaData[1]?.[UNIT])
|
|
124
126
|
) {
|
|
125
127
|
return [{[TYPE]: BOOLEAN}, defaultValue, allowNull ?? false];
|
|
126
128
|
}
|
|
129
|
+
if (arrayEvery(schemaData, (item) => isString(item?.[UNIT] ?? item))) {
|
|
130
|
+
return [{[TYPE]: STRING}, defaultValue, allowNull ?? false];
|
|
131
|
+
}
|
|
127
132
|
if (hasNull) {
|
|
128
133
|
const nonNullItem = arrayFind(
|
|
129
|
-
|
|
134
|
+
schemaData,
|
|
130
135
|
(item) => !isNull(item?.[UNIT]) && !isNull(item) && item !== '=',
|
|
131
136
|
);
|
|
132
137
|
if (nonNullItem) {
|
|
@@ -134,14 +139,14 @@ const unwrapSchema = (schema, defaultValue, allowNull) => {
|
|
|
134
139
|
}
|
|
135
140
|
}
|
|
136
141
|
}
|
|
137
|
-
if (
|
|
138
|
-
!isArray(schema) &&
|
|
139
|
-
!isUndefined(schema?.[SEQUENCE] ?? schema?.json?.[SEQUENCE])
|
|
140
|
-
) {
|
|
142
|
+
if (!isArray(schemaData) && !isUndefined(schemaData?.[SEQUENCE])) {
|
|
141
143
|
return [{[TYPE]: ARRAY}, defaultValue, allowNull ?? false];
|
|
142
144
|
}
|
|
145
|
+
if (!isArray(schemaData) && isString(schemaData?.[UNIT])) {
|
|
146
|
+
return [{[TYPE]: STRING}, defaultValue, allowNull ?? false];
|
|
147
|
+
}
|
|
143
148
|
return [
|
|
144
|
-
{[TYPE]:
|
|
149
|
+
{[TYPE]: schemaData?.[DOMAIN] || schemaData},
|
|
145
150
|
defaultValue,
|
|
146
151
|
allowNull ?? false,
|
|
147
152
|
];
|
|
@@ -113,27 +113,40 @@ const unwrapSchema = (schema, defaultValue, allowNull) => {
|
|
|
113
113
|
const type = ast._tag;
|
|
114
114
|
if (type === UNION) {
|
|
115
115
|
const types = ast.types;
|
|
116
|
+
const nonNullType = arrayFind(
|
|
117
|
+
types,
|
|
118
|
+
(t) => !(t._tag === LITERAL && isNull(t.literal)),
|
|
119
|
+
);
|
|
116
120
|
return [
|
|
117
|
-
{[TYPE]: getSimpleType(
|
|
121
|
+
{[TYPE]: getSimpleType(nonNullType)},
|
|
118
122
|
defaultValue,
|
|
119
123
|
allowNull ||
|
|
120
124
|
!!arrayFind(types, (t) => t._tag === LITERAL && isNull(t.literal)),
|
|
121
125
|
];
|
|
122
126
|
}
|
|
123
|
-
return [{[TYPE]: getSimpleType(
|
|
127
|
+
return [{[TYPE]: getSimpleType(ast)}, defaultValue, allowNull || false];
|
|
128
|
+
};
|
|
129
|
+
const getSimpleType = (ast) => {
|
|
130
|
+
const tag = ast?._tag;
|
|
131
|
+
const literalType = typeof ast?.literal;
|
|
132
|
+
return tag === LITERAL
|
|
133
|
+
? literalType === STRING ||
|
|
134
|
+
literalType === NUMBER ||
|
|
135
|
+
literalType === BOOLEAN
|
|
136
|
+
? literalType
|
|
137
|
+
: EMPTY_STRING
|
|
138
|
+
: tag === STRING_KEYWORD
|
|
139
|
+
? STRING
|
|
140
|
+
: tag === NUMBER_KEYWORD
|
|
141
|
+
? NUMBER
|
|
142
|
+
: tag === BOOLEAN_KEYWORD
|
|
143
|
+
? BOOLEAN
|
|
144
|
+
: tag === TUPLE_TYPE
|
|
145
|
+
? ARRAY
|
|
146
|
+
: tag === TYPE_LITERAL
|
|
147
|
+
? OBJECT
|
|
148
|
+
: EMPTY_STRING;
|
|
124
149
|
};
|
|
125
|
-
const getSimpleType = (tag) =>
|
|
126
|
-
tag === STRING_KEYWORD
|
|
127
|
-
? STRING
|
|
128
|
-
: tag === NUMBER_KEYWORD
|
|
129
|
-
? NUMBER
|
|
130
|
-
: tag === BOOLEAN_KEYWORD
|
|
131
|
-
? BOOLEAN
|
|
132
|
-
: tag === TUPLE_TYPE
|
|
133
|
-
? ARRAY
|
|
134
|
-
: tag === TYPE_LITERAL
|
|
135
|
-
? OBJECT
|
|
136
|
-
: EMPTY_STRING;
|
|
137
150
|
const getProperties = (schema) => {
|
|
138
151
|
const ast = schema.ast;
|
|
139
152
|
if (ast._tag === TYPE_LITERAL) {
|
|
@@ -113,27 +113,40 @@ const unwrapSchema = (schema, defaultValue, allowNull) => {
|
|
|
113
113
|
const type = ast._tag;
|
|
114
114
|
if (type === UNION) {
|
|
115
115
|
const types = ast.types;
|
|
116
|
+
const nonNullType = arrayFind(
|
|
117
|
+
types,
|
|
118
|
+
(t) => !(t._tag === LITERAL && isNull(t.literal)),
|
|
119
|
+
);
|
|
116
120
|
return [
|
|
117
|
-
{[TYPE]: getSimpleType(
|
|
121
|
+
{[TYPE]: getSimpleType(nonNullType)},
|
|
118
122
|
defaultValue,
|
|
119
123
|
allowNull ||
|
|
120
124
|
!!arrayFind(types, (t) => t._tag === LITERAL && isNull(t.literal)),
|
|
121
125
|
];
|
|
122
126
|
}
|
|
123
|
-
return [{[TYPE]: getSimpleType(
|
|
127
|
+
return [{[TYPE]: getSimpleType(ast)}, defaultValue, allowNull || false];
|
|
128
|
+
};
|
|
129
|
+
const getSimpleType = (ast) => {
|
|
130
|
+
const tag = ast?._tag;
|
|
131
|
+
const literalType = typeof ast?.literal;
|
|
132
|
+
return tag === LITERAL
|
|
133
|
+
? literalType === STRING ||
|
|
134
|
+
literalType === NUMBER ||
|
|
135
|
+
literalType === BOOLEAN
|
|
136
|
+
? literalType
|
|
137
|
+
: EMPTY_STRING
|
|
138
|
+
: tag === STRING_KEYWORD
|
|
139
|
+
? STRING
|
|
140
|
+
: tag === NUMBER_KEYWORD
|
|
141
|
+
? NUMBER
|
|
142
|
+
: tag === BOOLEAN_KEYWORD
|
|
143
|
+
? BOOLEAN
|
|
144
|
+
: tag === TUPLE_TYPE
|
|
145
|
+
? ARRAY
|
|
146
|
+
: tag === TYPE_LITERAL
|
|
147
|
+
? OBJECT
|
|
148
|
+
: EMPTY_STRING;
|
|
124
149
|
};
|
|
125
|
-
const getSimpleType = (tag) =>
|
|
126
|
-
tag === STRING_KEYWORD
|
|
127
|
-
? STRING
|
|
128
|
-
: tag === NUMBER_KEYWORD
|
|
129
|
-
? NUMBER
|
|
130
|
-
: tag === BOOLEAN_KEYWORD
|
|
131
|
-
? BOOLEAN
|
|
132
|
-
: tag === TUPLE_TYPE
|
|
133
|
-
? ARRAY
|
|
134
|
-
: tag === TYPE_LITERAL
|
|
135
|
-
? OBJECT
|
|
136
|
-
: EMPTY_STRING;
|
|
137
150
|
const getProperties = (schema) => {
|
|
138
151
|
const ast = schema.ast;
|
|
139
152
|
if (ast._tag === TYPE_LITERAL) {
|
|
@@ -22,8 +22,9 @@ const ifNotNullish = getIfNotFunction(isNullish);
|
|
|
22
22
|
const ifNotUndefined = getIfNotFunction(isUndefined);
|
|
23
23
|
const size = (arrayOrString) => arrayOrString.length;
|
|
24
24
|
|
|
25
|
+
const arrayEvery = (array, cb) => array.every(cb);
|
|
25
26
|
const arrayForEach = (array, cb) => array.forEach(cb);
|
|
26
|
-
const
|
|
27
|
+
const arrayFilter = (array, cb) => array.filter(cb);
|
|
27
28
|
|
|
28
29
|
const object = Object;
|
|
29
30
|
const getPrototypeOf = (obj) => object.getPrototypeOf(obj);
|
|
@@ -105,9 +106,17 @@ const unwrapSchema = (schema, defaultValue, allowNull) => {
|
|
|
105
106
|
if (schema?.[ANY_OF]) {
|
|
106
107
|
const types = schema[ANY_OF];
|
|
107
108
|
const hasNull = types.some((t) => t?.type === NULL);
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
|
|
109
|
+
const nonNullTypes = arrayFilter(types, (t) => t?.type !== NULL);
|
|
110
|
+
const firstNonNullType = nonNullTypes[0];
|
|
111
|
+
if (
|
|
112
|
+
firstNonNullType &&
|
|
113
|
+
arrayEvery(nonNullTypes, (type) => type?.type === firstNonNullType.type)
|
|
114
|
+
) {
|
|
115
|
+
return unwrapSchema(
|
|
116
|
+
firstNonNullType,
|
|
117
|
+
defaultValue ?? schema?.[DEFAULT],
|
|
118
|
+
hasNull || allowNull,
|
|
119
|
+
);
|
|
111
120
|
}
|
|
112
121
|
}
|
|
113
122
|
return [schema, defaultValue ?? schema?.[DEFAULT], allowNull ?? false];
|
|
@@ -22,8 +22,9 @@ const ifNotNullish = getIfNotFunction(isNullish);
|
|
|
22
22
|
const ifNotUndefined = getIfNotFunction(isUndefined);
|
|
23
23
|
const size = (arrayOrString) => arrayOrString.length;
|
|
24
24
|
|
|
25
|
+
const arrayEvery = (array, cb) => array.every(cb);
|
|
25
26
|
const arrayForEach = (array, cb) => array.forEach(cb);
|
|
26
|
-
const
|
|
27
|
+
const arrayFilter = (array, cb) => array.filter(cb);
|
|
27
28
|
|
|
28
29
|
const object = Object;
|
|
29
30
|
const getPrototypeOf = (obj) => object.getPrototypeOf(obj);
|
|
@@ -105,9 +106,17 @@ const unwrapSchema = (schema, defaultValue, allowNull) => {
|
|
|
105
106
|
if (schema?.[ANY_OF]) {
|
|
106
107
|
const types = schema[ANY_OF];
|
|
107
108
|
const hasNull = types.some((t) => t?.type === NULL);
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
|
|
109
|
+
const nonNullTypes = arrayFilter(types, (t) => t?.type !== NULL);
|
|
110
|
+
const firstNonNullType = nonNullTypes[0];
|
|
111
|
+
if (
|
|
112
|
+
firstNonNullType &&
|
|
113
|
+
arrayEvery(nonNullTypes, (type) => type?.type === firstNonNullType.type)
|
|
114
|
+
) {
|
|
115
|
+
return unwrapSchema(
|
|
116
|
+
firstNonNullType,
|
|
117
|
+
defaultValue ?? schema?.[DEFAULT],
|
|
118
|
+
hasNull || allowNull,
|
|
119
|
+
);
|
|
111
120
|
}
|
|
112
121
|
}
|
|
113
122
|
return [schema, defaultValue ?? schema?.[DEFAULT], allowNull ?? false];
|
|
@@ -23,8 +23,10 @@ const isNullish = (thing) => thing == null;
|
|
|
23
23
|
const isUndefined = (thing) => thing === void 0;
|
|
24
24
|
const ifNotNullish = getIfNotFunction(isNullish);
|
|
25
25
|
const ifNotUndefined = getIfNotFunction(isUndefined);
|
|
26
|
+
const isString = (thing) => getTypeOf(thing) == STRING;
|
|
26
27
|
const size = (arrayOrString) => arrayOrString.length;
|
|
27
28
|
|
|
29
|
+
const arrayEvery = (array, cb) => array.every(cb);
|
|
28
30
|
const arrayForEach = (array, cb) => array.forEach(cb);
|
|
29
31
|
|
|
30
32
|
const object = Object;
|
|
@@ -103,6 +105,8 @@ const createCustomSchematizer = (unwrapSchema, getProperties) => {
|
|
|
103
105
|
});
|
|
104
106
|
};
|
|
105
107
|
|
|
108
|
+
const LITERAL = 'literal';
|
|
109
|
+
const PICKLIST = 'picklist';
|
|
106
110
|
const unwrapSchema = (schema, defaultValue, allowNull) => {
|
|
107
111
|
const type = schema?.type;
|
|
108
112
|
return type === OPTIONAL
|
|
@@ -115,7 +119,19 @@ const unwrapSchema = (schema, defaultValue, allowNull) => {
|
|
|
115
119
|
defaultValue ?? schema?.[FALLBACK],
|
|
116
120
|
allowNull ?? false,
|
|
117
121
|
]
|
|
118
|
-
:
|
|
122
|
+
: type === PICKLIST && arrayEvery(schema.options, isString)
|
|
123
|
+
? [
|
|
124
|
+
{[TYPE]: STRING},
|
|
125
|
+
defaultValue ?? schema?.[FALLBACK],
|
|
126
|
+
allowNull ?? false,
|
|
127
|
+
]
|
|
128
|
+
: type === LITERAL && isString(schema.literal)
|
|
129
|
+
? [
|
|
130
|
+
{[TYPE]: STRING},
|
|
131
|
+
defaultValue ?? schema?.[FALLBACK],
|
|
132
|
+
allowNull ?? false,
|
|
133
|
+
]
|
|
134
|
+
: [schema, defaultValue ?? schema?.[FALLBACK], allowNull ?? false];
|
|
119
135
|
};
|
|
120
136
|
const getProperties = (schema) => schema?.entries;
|
|
121
137
|
const createValibotSchematizer = () =>
|
|
@@ -23,8 +23,10 @@ const isNullish = (thing) => thing == null;
|
|
|
23
23
|
const isUndefined = (thing) => thing === void 0;
|
|
24
24
|
const ifNotNullish = getIfNotFunction(isNullish);
|
|
25
25
|
const ifNotUndefined = getIfNotFunction(isUndefined);
|
|
26
|
+
const isString = (thing) => getTypeOf(thing) == STRING;
|
|
26
27
|
const size = (arrayOrString) => arrayOrString.length;
|
|
27
28
|
|
|
29
|
+
const arrayEvery = (array, cb) => array.every(cb);
|
|
28
30
|
const arrayForEach = (array, cb) => array.forEach(cb);
|
|
29
31
|
|
|
30
32
|
const object = Object;
|
|
@@ -103,6 +105,8 @@ const createCustomSchematizer = (unwrapSchema, getProperties) => {
|
|
|
103
105
|
});
|
|
104
106
|
};
|
|
105
107
|
|
|
108
|
+
const LITERAL = 'literal';
|
|
109
|
+
const PICKLIST = 'picklist';
|
|
106
110
|
const unwrapSchema = (schema, defaultValue, allowNull) => {
|
|
107
111
|
const type = schema?.type;
|
|
108
112
|
return type === OPTIONAL
|
|
@@ -115,7 +119,19 @@ const unwrapSchema = (schema, defaultValue, allowNull) => {
|
|
|
115
119
|
defaultValue ?? schema?.[FALLBACK],
|
|
116
120
|
allowNull ?? false,
|
|
117
121
|
]
|
|
118
|
-
:
|
|
122
|
+
: type === PICKLIST && arrayEvery(schema.options, isString)
|
|
123
|
+
? [
|
|
124
|
+
{[TYPE]: STRING},
|
|
125
|
+
defaultValue ?? schema?.[FALLBACK],
|
|
126
|
+
allowNull ?? false,
|
|
127
|
+
]
|
|
128
|
+
: type === LITERAL && isString(schema.literal)
|
|
129
|
+
? [
|
|
130
|
+
{[TYPE]: STRING},
|
|
131
|
+
defaultValue ?? schema?.[FALLBACK],
|
|
132
|
+
allowNull ?? false,
|
|
133
|
+
]
|
|
134
|
+
: [schema, defaultValue ?? schema?.[FALLBACK], allowNull ?? false];
|
|
119
135
|
};
|
|
120
136
|
const getProperties = (schema) => schema?.entries;
|
|
121
137
|
const createValibotSchematizer = () =>
|
|
@@ -19,8 +19,10 @@ const isNullish = (thing) => thing == null;
|
|
|
19
19
|
const isUndefined = (thing) => thing === void 0;
|
|
20
20
|
const ifNotNullish = getIfNotFunction(isNullish);
|
|
21
21
|
const ifNotUndefined = getIfNotFunction(isUndefined);
|
|
22
|
+
const isString = (thing) => getTypeOf(thing) == STRING;
|
|
22
23
|
const size = (arrayOrString) => arrayOrString.length;
|
|
23
24
|
|
|
25
|
+
const arrayEvery = (array, cb) => array.every(cb);
|
|
24
26
|
const arrayForEach = (array, cb) => array.forEach(cb);
|
|
25
27
|
|
|
26
28
|
const object = Object;
|
|
@@ -99,11 +101,20 @@ const createCustomSchematizer = (unwrapSchema, getProperties) => {
|
|
|
99
101
|
});
|
|
100
102
|
};
|
|
101
103
|
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
104
|
+
const MIXED = 'mixed';
|
|
105
|
+
const unwrapSchema = (schema, defaultValue, allowNull) => {
|
|
106
|
+
const oneOf = schema?._whitelist ? Array.from(schema._whitelist) : [];
|
|
107
|
+
return [
|
|
108
|
+
{
|
|
109
|
+
[TYPE]:
|
|
110
|
+
schema?.type === MIXED && size(oneOf) > 0 && arrayEvery(oneOf, isString)
|
|
111
|
+
? STRING
|
|
112
|
+
: schema?.type,
|
|
113
|
+
},
|
|
114
|
+
defaultValue ?? schema?.spec?.[DEFAULT],
|
|
115
|
+
allowNull || schema?.spec?.[NULLABLE] || false,
|
|
116
|
+
];
|
|
117
|
+
};
|
|
107
118
|
const getProperties = (schema) => schema?.fields;
|
|
108
119
|
const createYupSchematizer = () =>
|
|
109
120
|
createCustomSchematizer(unwrapSchema, getProperties);
|
|
@@ -19,8 +19,10 @@ const isNullish = (thing) => thing == null;
|
|
|
19
19
|
const isUndefined = (thing) => thing === void 0;
|
|
20
20
|
const ifNotNullish = getIfNotFunction(isNullish);
|
|
21
21
|
const ifNotUndefined = getIfNotFunction(isUndefined);
|
|
22
|
+
const isString = (thing) => getTypeOf(thing) == STRING;
|
|
22
23
|
const size = (arrayOrString) => arrayOrString.length;
|
|
23
24
|
|
|
25
|
+
const arrayEvery = (array, cb) => array.every(cb);
|
|
24
26
|
const arrayForEach = (array, cb) => array.forEach(cb);
|
|
25
27
|
|
|
26
28
|
const object = Object;
|
|
@@ -99,11 +101,20 @@ const createCustomSchematizer = (unwrapSchema, getProperties) => {
|
|
|
99
101
|
});
|
|
100
102
|
};
|
|
101
103
|
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
104
|
+
const MIXED = 'mixed';
|
|
105
|
+
const unwrapSchema = (schema, defaultValue, allowNull) => {
|
|
106
|
+
const oneOf = schema?._whitelist ? Array.from(schema._whitelist) : [];
|
|
107
|
+
return [
|
|
108
|
+
{
|
|
109
|
+
[TYPE]:
|
|
110
|
+
schema?.type === MIXED && size(oneOf) > 0 && arrayEvery(oneOf, isString)
|
|
111
|
+
? STRING
|
|
112
|
+
: schema?.type,
|
|
113
|
+
},
|
|
114
|
+
defaultValue ?? schema?.spec?.[DEFAULT],
|
|
115
|
+
allowNull || schema?.spec?.[NULLABLE] || false,
|
|
116
|
+
];
|
|
117
|
+
};
|
|
107
118
|
const getProperties = (schema) => schema?.fields;
|
|
108
119
|
const createYupSchematizer = () =>
|
|
109
120
|
createCustomSchematizer(unwrapSchema, getProperties);
|
|
@@ -21,8 +21,10 @@ const isNullish = (thing) => thing == null;
|
|
|
21
21
|
const isUndefined = (thing) => thing === void 0;
|
|
22
22
|
const ifNotNullish = getIfNotFunction(isNullish);
|
|
23
23
|
const ifNotUndefined = getIfNotFunction(isUndefined);
|
|
24
|
+
const isString = (thing) => getTypeOf(thing) == STRING;
|
|
24
25
|
const size = (arrayOrString) => arrayOrString.length;
|
|
25
26
|
|
|
27
|
+
const arrayEvery = (array, cb) => array.every(cb);
|
|
26
28
|
const arrayForEach = (array, cb) => array.forEach(cb);
|
|
27
29
|
|
|
28
30
|
const object = Object;
|
|
@@ -101,19 +103,27 @@ const createCustomSchematizer = (unwrapSchema, getProperties) => {
|
|
|
101
103
|
});
|
|
102
104
|
};
|
|
103
105
|
|
|
106
|
+
const ENUM = 'enum';
|
|
107
|
+
const LITERAL = 'literal';
|
|
108
|
+
const getDef = (schema) => schema?.def ?? schema?._zod?.def;
|
|
104
109
|
const unwrapSchema = (schema, defaultValue, allowNull) => {
|
|
105
|
-
const
|
|
110
|
+
const def = getDef(schema);
|
|
111
|
+
const type = def?.type;
|
|
106
112
|
return type === OPTIONAL
|
|
107
|
-
? unwrapSchema(
|
|
113
|
+
? unwrapSchema(def.innerType, defaultValue, allowNull)
|
|
108
114
|
: type === NULLABLE
|
|
109
|
-
? unwrapSchema(
|
|
115
|
+
? unwrapSchema(def.innerType, defaultValue, true)
|
|
110
116
|
: type === DEFAULT
|
|
111
|
-
? unwrapSchema(
|
|
117
|
+
? unwrapSchema(def.innerType, def.defaultValue, allowNull)
|
|
112
118
|
: type === RECORD
|
|
113
119
|
? [{type: OBJECT}, defaultValue, allowNull ?? false]
|
|
114
|
-
:
|
|
120
|
+
: type === ENUM
|
|
121
|
+
? [{[TYPE]: STRING}, defaultValue, allowNull ?? false]
|
|
122
|
+
: type === LITERAL && arrayEvery(def.values, isString)
|
|
123
|
+
? [{[TYPE]: STRING}, defaultValue, allowNull ?? false]
|
|
124
|
+
: [schema, defaultValue, allowNull ?? false];
|
|
115
125
|
};
|
|
116
|
-
const getProperties = (schema) => schema?.
|
|
126
|
+
const getProperties = (schema) => getDef(schema)?.shape;
|
|
117
127
|
const createZodSchematizer = () =>
|
|
118
128
|
createCustomSchematizer(unwrapSchema, getProperties);
|
|
119
129
|
|
|
@@ -21,8 +21,10 @@ const isNullish = (thing) => thing == null;
|
|
|
21
21
|
const isUndefined = (thing) => thing === void 0;
|
|
22
22
|
const ifNotNullish = getIfNotFunction(isNullish);
|
|
23
23
|
const ifNotUndefined = getIfNotFunction(isUndefined);
|
|
24
|
+
const isString = (thing) => getTypeOf(thing) == STRING;
|
|
24
25
|
const size = (arrayOrString) => arrayOrString.length;
|
|
25
26
|
|
|
27
|
+
const arrayEvery = (array, cb) => array.every(cb);
|
|
26
28
|
const arrayForEach = (array, cb) => array.forEach(cb);
|
|
27
29
|
|
|
28
30
|
const object = Object;
|
|
@@ -101,19 +103,27 @@ const createCustomSchematizer = (unwrapSchema, getProperties) => {
|
|
|
101
103
|
});
|
|
102
104
|
};
|
|
103
105
|
|
|
106
|
+
const ENUM = 'enum';
|
|
107
|
+
const LITERAL = 'literal';
|
|
108
|
+
const getDef = (schema) => schema?.def ?? schema?._zod?.def;
|
|
104
109
|
const unwrapSchema = (schema, defaultValue, allowNull) => {
|
|
105
|
-
const
|
|
110
|
+
const def = getDef(schema);
|
|
111
|
+
const type = def?.type;
|
|
106
112
|
return type === OPTIONAL
|
|
107
|
-
? unwrapSchema(
|
|
113
|
+
? unwrapSchema(def.innerType, defaultValue, allowNull)
|
|
108
114
|
: type === NULLABLE
|
|
109
|
-
? unwrapSchema(
|
|
115
|
+
? unwrapSchema(def.innerType, defaultValue, true)
|
|
110
116
|
: type === DEFAULT
|
|
111
|
-
? unwrapSchema(
|
|
117
|
+
? unwrapSchema(def.innerType, def.defaultValue, allowNull)
|
|
112
118
|
: type === RECORD
|
|
113
119
|
? [{type: OBJECT}, defaultValue, allowNull ?? false]
|
|
114
|
-
:
|
|
120
|
+
: type === ENUM
|
|
121
|
+
? [{[TYPE]: STRING}, defaultValue, allowNull ?? false]
|
|
122
|
+
: type === LITERAL && arrayEvery(def.values, isString)
|
|
123
|
+
? [{[TYPE]: STRING}, defaultValue, allowNull ?? false]
|
|
124
|
+
: [schema, defaultValue, allowNull ?? false];
|
|
115
125
|
};
|
|
116
|
-
const getProperties = (schema) => schema?.
|
|
126
|
+
const getProperties = (schema) => getDef(schema)?.shape;
|
|
117
127
|
const createZodSchematizer = () =>
|
|
118
128
|
createCustomSchematizer(unwrapSchema, getProperties);
|
|
119
129
|
|
package/ui-react/index.js
CHANGED
|
@@ -2161,7 +2161,7 @@ const BackwardCheckpointsView = getUseCheckpointView(
|
|
|
2161
2161
|
);
|
|
2162
2162
|
|
|
2163
2163
|
const CurrentCheckpointView = getUseCheckpointView((checkpointIds) =>
|
|
2164
|
-
|
|
2164
|
+
isNullish(checkpointIds[1]) ? [] : [checkpointIds[1]],
|
|
2165
2165
|
);
|
|
2166
2166
|
|
|
2167
2167
|
const ForwardCheckpointsView = getUseCheckpointView(
|
|
@@ -2161,7 +2161,7 @@ const BackwardCheckpointsView = getUseCheckpointView(
|
|
|
2161
2161
|
);
|
|
2162
2162
|
|
|
2163
2163
|
const CurrentCheckpointView = getUseCheckpointView((checkpointIds) =>
|
|
2164
|
-
|
|
2164
|
+
isNullish(checkpointIds[1]) ? [] : [checkpointIds[1]],
|
|
2165
2165
|
);
|
|
2166
2166
|
|
|
2167
2167
|
const ForwardCheckpointsView = getUseCheckpointView(
|