@effect-app/vue-components 0.14.6 → 0.15.0
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { S as n, Option as
|
|
2
|
-
import { useIntl as
|
|
3
|
-
const
|
|
1
|
+
import { S as n, Option as c, pipe as L } from "effect-app";
|
|
2
|
+
import { useIntl as U } from "./vue-components.es3.js";
|
|
3
|
+
const _ = n.NonEmptyArray(n.String), N = (e) => n.AST.isUnion(e) && e.types.find((i) => i._tag === "UndefinedKeyword" || i === n.Null.ast), g = (e) => !e || !n.AST.isUnion(e) ? !1 : e.types.find((i) => i._tag === "UndefinedKeyword") ? "undefined" : e.types.find((i) => i === n.Null.ast) ? "null" : !1, m = ({ meta: e = {}, parent: i = "", property: t, propertySignatures: p }, o = {}) => {
|
|
4
4
|
if (t && t._tag === "Transformation")
|
|
5
5
|
return m({
|
|
6
6
|
parent: i,
|
|
@@ -12,72 +12,112 @@ const M = n.NonEmptyArray(n.String), L = (e) => n.AST.isUnion(e) && e.types.find
|
|
|
12
12
|
meta: e,
|
|
13
13
|
propertySignatures: t.propertySignatures
|
|
14
14
|
});
|
|
15
|
-
if (
|
|
16
|
-
for (const r of
|
|
17
|
-
const
|
|
15
|
+
if (p) {
|
|
16
|
+
for (const r of p) {
|
|
17
|
+
const l = i ? `${i}.${r.name.toString()}` : r.name.toString(), a = g(r.type), u = !a, A = r.type;
|
|
18
18
|
if (n.AST.isUnion(r.type)) {
|
|
19
|
-
const
|
|
19
|
+
const T = r.type.types.filter(
|
|
20
20
|
(s) => s._tag !== "UndefinedKeyword" && s !== n.Null.ast
|
|
21
21
|
);
|
|
22
|
-
if (
|
|
22
|
+
if (T.some(
|
|
23
23
|
(s) => "propertySignatures" in s
|
|
24
24
|
)) {
|
|
25
25
|
if (!a) {
|
|
26
26
|
const s = m({
|
|
27
|
-
parent:
|
|
27
|
+
parent: l,
|
|
28
28
|
property: r.type,
|
|
29
|
-
meta: { required:
|
|
29
|
+
meta: { required: u, nullableOrUndefined: a }
|
|
30
30
|
});
|
|
31
|
-
l
|
|
31
|
+
o[l] = s;
|
|
32
32
|
}
|
|
33
|
-
for (const s of
|
|
33
|
+
for (const s of T)
|
|
34
34
|
"propertySignatures" in s && Object.assign(
|
|
35
|
-
|
|
35
|
+
o,
|
|
36
36
|
m({
|
|
37
|
-
parent:
|
|
37
|
+
parent: l,
|
|
38
38
|
propertySignatures: s.propertySignatures,
|
|
39
|
-
meta: { required:
|
|
39
|
+
meta: { required: u, nullableOrUndefined: a }
|
|
40
40
|
})
|
|
41
41
|
);
|
|
42
42
|
} else {
|
|
43
|
-
const s =
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
43
|
+
const s = T.filter(n.AST.isTupleType);
|
|
44
|
+
if (s.length > 0) {
|
|
45
|
+
const f = s[0];
|
|
46
|
+
if (o[l] = {
|
|
47
|
+
type: "multiple",
|
|
48
|
+
members: f.elements,
|
|
49
|
+
rest: f.rest,
|
|
50
|
+
required: u,
|
|
51
|
+
nullableOrUndefined: a
|
|
52
|
+
}, f.rest && f.rest.length > 0) {
|
|
53
|
+
const d = f.rest[0];
|
|
54
|
+
if (d.type._tag === "TypeLiteral" && "propertySignatures" in d.type)
|
|
55
|
+
for (const y of d.type.propertySignatures) {
|
|
56
|
+
const b = `${l}.${y.name.toString()}`, S = m({
|
|
57
|
+
parent: b,
|
|
58
|
+
property: y.type,
|
|
59
|
+
meta: {
|
|
60
|
+
required: !g(y.type),
|
|
61
|
+
nullableOrUndefined: g(y.type)
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
if (S && typeof S == "object" && "type" in S && (o[b] = S, S.type === "multiple" && n.AST.isTupleType(y.type) && y.type.rest && y.type.rest.length > 0)) {
|
|
65
|
+
const O = y.type.rest[0];
|
|
66
|
+
if (O.type._tag === "TypeLiteral" && "propertySignatures" in O.type)
|
|
67
|
+
for (const v of O.type.propertySignatures) {
|
|
68
|
+
const M = `${b}.${v.name.toString()}`, x = m({
|
|
69
|
+
parent: M,
|
|
70
|
+
property: v.type,
|
|
71
|
+
meta: {
|
|
72
|
+
required: !g(v.type),
|
|
73
|
+
nullableOrUndefined: g(v.type)
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
x && typeof x == "object" && "type" in x && (o[M] = x);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
} else {
|
|
82
|
+
const f = m({
|
|
83
|
+
parent: l,
|
|
84
|
+
property: r.type,
|
|
85
|
+
meta: { required: u, nullableOrUndefined: a }
|
|
86
|
+
});
|
|
87
|
+
o[l] = f;
|
|
88
|
+
}
|
|
49
89
|
}
|
|
50
|
-
} else if ("propertySignatures" in
|
|
90
|
+
} else if ("propertySignatures" in A)
|
|
51
91
|
Object.assign(
|
|
52
|
-
|
|
92
|
+
o,
|
|
53
93
|
m({
|
|
54
|
-
parent:
|
|
55
|
-
propertySignatures:
|
|
56
|
-
meta: { required:
|
|
94
|
+
parent: l,
|
|
95
|
+
propertySignatures: A.propertySignatures,
|
|
96
|
+
meta: { required: u, nullableOrUndefined: a }
|
|
57
97
|
})
|
|
58
98
|
);
|
|
59
99
|
else if (n.AST.isTupleType(r.type))
|
|
60
100
|
if (r.type.rest.length > 0 && r.type.rest[0].type._tag === "TypeLiteral" && "propertySignatures" in r.type.rest[0].type) {
|
|
61
|
-
const
|
|
62
|
-
if (
|
|
63
|
-
for (const s of
|
|
64
|
-
const
|
|
101
|
+
const h = r.type.rest[0].type;
|
|
102
|
+
if (h._tag === "TypeLiteral" && "propertySignatures" in h)
|
|
103
|
+
for (const s of h.propertySignatures) {
|
|
104
|
+
const f = `${l}.${s.name.toString()}`;
|
|
65
105
|
if (n.AST.isTupleType(s.type) && s.type.rest.length > 0) {
|
|
66
106
|
const d = s.type.rest[0].type;
|
|
67
107
|
if (d._tag === "TypeLiteral" && "propertySignatures" in d)
|
|
68
|
-
for (const
|
|
69
|
-
const
|
|
70
|
-
parent:
|
|
71
|
-
property:
|
|
108
|
+
for (const y of d.propertySignatures) {
|
|
109
|
+
const b = `${f}.${y.name.toString()}`, S = m({
|
|
110
|
+
parent: b,
|
|
111
|
+
property: y.type,
|
|
72
112
|
meta: {
|
|
73
|
-
required: !g(
|
|
74
|
-
nullableOrUndefined: g(
|
|
113
|
+
required: !g(y.type),
|
|
114
|
+
nullableOrUndefined: g(y.type)
|
|
75
115
|
}
|
|
76
116
|
});
|
|
77
|
-
|
|
117
|
+
o[b] = S;
|
|
78
118
|
}
|
|
79
119
|
else
|
|
80
|
-
|
|
120
|
+
o[f] = {
|
|
81
121
|
type: "multiple",
|
|
82
122
|
members: s.type.elements,
|
|
83
123
|
rest: s.type.rest,
|
|
@@ -86,40 +126,40 @@ const M = n.NonEmptyArray(n.String), L = (e) => n.AST.isUnion(e) && e.types.find
|
|
|
86
126
|
};
|
|
87
127
|
} else {
|
|
88
128
|
const d = m({
|
|
89
|
-
parent:
|
|
129
|
+
parent: f,
|
|
90
130
|
property: s.type,
|
|
91
131
|
meta: {
|
|
92
132
|
required: !g(s.type),
|
|
93
133
|
nullableOrUndefined: g(s.type)
|
|
94
134
|
}
|
|
95
135
|
});
|
|
96
|
-
|
|
136
|
+
o[f] = d;
|
|
97
137
|
}
|
|
98
138
|
}
|
|
99
139
|
} else
|
|
100
|
-
l
|
|
140
|
+
o[l] = {
|
|
101
141
|
type: "multiple",
|
|
102
142
|
members: r.type.elements,
|
|
103
143
|
rest: r.type.rest,
|
|
104
|
-
required:
|
|
144
|
+
required: u,
|
|
105
145
|
nullableOrUndefined: a
|
|
106
146
|
};
|
|
107
147
|
else {
|
|
108
|
-
const
|
|
109
|
-
parent:
|
|
148
|
+
const T = m({
|
|
149
|
+
parent: l,
|
|
110
150
|
property: r.type,
|
|
111
|
-
meta: { required:
|
|
151
|
+
meta: { required: u, nullableOrUndefined: a }
|
|
112
152
|
});
|
|
113
|
-
l
|
|
153
|
+
o[l] = T;
|
|
114
154
|
}
|
|
115
155
|
}
|
|
116
|
-
return
|
|
156
|
+
return o;
|
|
117
157
|
}
|
|
118
158
|
if (t) {
|
|
119
|
-
const r =
|
|
159
|
+
const r = N(t);
|
|
120
160
|
if (Object.hasOwnProperty.call(e, "required") || (e.required = !r), n.AST.isUnion(t)) {
|
|
121
161
|
const a = t.types.find(
|
|
122
|
-
(
|
|
162
|
+
(u) => u._tag !== "UndefinedKeyword" && u !== n.Null.ast
|
|
123
163
|
);
|
|
124
164
|
return "propertySignatures" in a ? m({
|
|
125
165
|
propertySignatures: a.propertySignatures,
|
|
@@ -128,7 +168,7 @@ const M = n.NonEmptyArray(n.String), L = (e) => n.AST.isUnion(e) && e.types.find
|
|
|
128
168
|
}) : t.types.every(n.AST.isLiteral) ? {
|
|
129
169
|
...e,
|
|
130
170
|
type: "select",
|
|
131
|
-
members: t.types.map((
|
|
171
|
+
members: t.types.map((u) => u.literal)
|
|
132
172
|
} : {
|
|
133
173
|
...e,
|
|
134
174
|
...m({
|
|
@@ -145,11 +185,11 @@ const M = n.NonEmptyArray(n.String), L = (e) => n.AST.isUnion(e) && e.types.find
|
|
|
145
185
|
members: t.elements,
|
|
146
186
|
rest: t.rest
|
|
147
187
|
};
|
|
148
|
-
const
|
|
188
|
+
const l = n.AST.getAnnotation(
|
|
149
189
|
t,
|
|
150
190
|
n.AST.JSONSchemaAnnotationId
|
|
151
|
-
).pipe(
|
|
152
|
-
return e = { ...e, ...
|
|
191
|
+
).pipe(c.getOrElse(() => ({})));
|
|
192
|
+
return e = { ...e, ...l }, "from" in t ? m({
|
|
153
193
|
parent: i,
|
|
154
194
|
meta: e,
|
|
155
195
|
property: t.from
|
|
@@ -157,50 +197,50 @@ const M = n.NonEmptyArray(n.String), L = (e) => n.AST.isUnion(e) && e.types.find
|
|
|
157
197
|
t,
|
|
158
198
|
n.AST.TitleAnnotationId
|
|
159
199
|
).pipe(
|
|
160
|
-
|
|
200
|
+
c.getOrElse(() => "unknown")
|
|
161
201
|
), e);
|
|
162
202
|
}
|
|
163
|
-
return
|
|
164
|
-
},
|
|
203
|
+
return o;
|
|
204
|
+
}, q = (e) => {
|
|
165
205
|
const i = e.ast, t = {};
|
|
166
206
|
if (i._tag === "Transformation" || i._tag === "Refinement")
|
|
167
|
-
return
|
|
207
|
+
return q(n.make(i.from));
|
|
168
208
|
if ("propertySignatures" in i) {
|
|
169
|
-
const
|
|
209
|
+
const p = m({
|
|
170
210
|
propertySignatures: i.propertySignatures
|
|
171
211
|
});
|
|
172
|
-
if (Object.values(
|
|
173
|
-
return
|
|
174
|
-
const
|
|
212
|
+
if (Object.values(p).every((r) => r && "type" in r))
|
|
213
|
+
return p;
|
|
214
|
+
const o = (r, l = "") => {
|
|
175
215
|
for (const a in r) {
|
|
176
|
-
const
|
|
177
|
-
r[a] && typeof r[a] == "object" && "type" in r[a] ? t[
|
|
216
|
+
const u = l ? `${l}.${a}` : a;
|
|
217
|
+
r[a] && typeof r[a] == "object" && "type" in r[a] ? t[u] = r[a] : r[a] && typeof r[a] == "object" && o(r[a], u);
|
|
178
218
|
}
|
|
179
219
|
};
|
|
180
|
-
|
|
220
|
+
o(p);
|
|
181
221
|
}
|
|
182
222
|
return t;
|
|
183
|
-
},
|
|
184
|
-
const i =
|
|
223
|
+
}, w = (e) => n.extend(e, n.Struct({})), $ = (e) => {
|
|
224
|
+
const i = q(e), t = L(
|
|
185
225
|
e.ast,
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
({ items:
|
|
226
|
+
c.liftPredicate((p) => p._tag === "Refinement" && "filter" in p),
|
|
227
|
+
c.flatMap((p) => n.AST.getJSONSchemaAnnotation(p)),
|
|
228
|
+
c.filter((p) => "items" in p),
|
|
229
|
+
c.filterMap(
|
|
230
|
+
({ items: p }) => n.decodeUnknownOption(_)(p)
|
|
191
231
|
),
|
|
192
|
-
|
|
232
|
+
c.zipWith(
|
|
193
233
|
n.AST.getMessageAnnotation(e.ast),
|
|
194
|
-
(
|
|
195
|
-
items:
|
|
196
|
-
message:
|
|
234
|
+
(p, o) => ({
|
|
235
|
+
items: p,
|
|
236
|
+
message: o("")
|
|
197
237
|
})
|
|
198
238
|
),
|
|
199
|
-
|
|
239
|
+
c.getOrUndefined
|
|
200
240
|
);
|
|
201
241
|
return { schema: e, meta: i, filterItems: t };
|
|
202
|
-
},
|
|
203
|
-
const { trans: i } =
|
|
242
|
+
}, K = (e) => {
|
|
243
|
+
const { trans: i } = U();
|
|
204
244
|
let t;
|
|
205
245
|
switch (e.type) {
|
|
206
246
|
case "string":
|
|
@@ -282,7 +322,7 @@ const M = n.NonEmptyArray(n.String), L = (e) => n.AST.isUnion(e) && e.types.find
|
|
|
282
322
|
message: () => i("validation.empty")
|
|
283
323
|
})
|
|
284
324
|
) : t = n.NullishOr(t), n.standardSchemaV1(t);
|
|
285
|
-
},
|
|
325
|
+
}, P = (e, i) => n.NullOr(e).pipe(
|
|
286
326
|
n.transform(n.typeSchema(e), {
|
|
287
327
|
decode: (t) => t ?? i(),
|
|
288
328
|
encode: (t) => t
|
|
@@ -290,8 +330,8 @@ const M = n.NonEmptyArray(n.String), L = (e) => n.AST.isUnion(e) && e.types.find
|
|
|
290
330
|
);
|
|
291
331
|
export {
|
|
292
332
|
m as createMeta,
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
333
|
+
w as duplicateSchema,
|
|
334
|
+
K as generateInputStandardSchemaFromFieldMeta,
|
|
335
|
+
$ as generateMetaFromSchema,
|
|
336
|
+
P as nullableInput
|
|
297
337
|
};
|
package/package.json
CHANGED
|
@@ -292,13 +292,76 @@ export const createMeta = <T = any>(
|
|
|
292
292
|
}
|
|
293
293
|
}
|
|
294
294
|
} else {
|
|
295
|
-
//
|
|
296
|
-
const
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
295
|
+
// Check if any of the union types are arrays (TupleType)
|
|
296
|
+
const arrayTypes = nonNullTypes.filter(S.AST.isTupleType)
|
|
297
|
+
if (arrayTypes.length > 0) {
|
|
298
|
+
const arrayType = arrayTypes[0] // Take the first array type
|
|
299
|
+
|
|
300
|
+
acc[key as NestedKeyOf<T>] = {
|
|
301
|
+
type: "multiple",
|
|
302
|
+
members: arrayType.elements,
|
|
303
|
+
rest: arrayType.rest,
|
|
304
|
+
required: isRequired,
|
|
305
|
+
nullableOrUndefined
|
|
306
|
+
} as FieldMeta
|
|
307
|
+
|
|
308
|
+
// If the array has struct elements, also create metadata for their properties
|
|
309
|
+
if (arrayType.rest && arrayType.rest.length > 0) {
|
|
310
|
+
const restElement = arrayType.rest[0]
|
|
311
|
+
if (restElement.type._tag === "TypeLiteral" && "propertySignatures" in restElement.type) {
|
|
312
|
+
|
|
313
|
+
for (const prop of restElement.type.propertySignatures) {
|
|
314
|
+
const propKey = `${key}.${prop.name.toString()}`
|
|
315
|
+
|
|
316
|
+
const propMeta = createMeta<T>({
|
|
317
|
+
parent: propKey,
|
|
318
|
+
property: prop.type,
|
|
319
|
+
meta: {
|
|
320
|
+
required: !isNullableOrUndefined(prop.type),
|
|
321
|
+
nullableOrUndefined: isNullableOrUndefined(prop.type)
|
|
322
|
+
}
|
|
323
|
+
})
|
|
324
|
+
|
|
325
|
+
// add to accumulator if valid
|
|
326
|
+
if (propMeta && typeof propMeta === 'object' && 'type' in propMeta) {
|
|
327
|
+
acc[propKey as NestedKeyOf<T>] = propMeta as FieldMeta
|
|
328
|
+
|
|
329
|
+
if (propMeta.type === "multiple" && S.AST.isTupleType(prop.type) && prop.type.rest && prop.type.rest.length > 0) {
|
|
330
|
+
const nestedRestElement = prop.type.rest[0]
|
|
331
|
+
if (nestedRestElement.type._tag === "TypeLiteral" && "propertySignatures" in nestedRestElement.type) {
|
|
332
|
+
|
|
333
|
+
for (const nestedProp of nestedRestElement.type.propertySignatures) {
|
|
334
|
+
const nestedPropKey = `${propKey}.${nestedProp.name.toString()}`
|
|
335
|
+
|
|
336
|
+
const nestedPropMeta = createMeta<T>({
|
|
337
|
+
parent: nestedPropKey,
|
|
338
|
+
property: nestedProp.type,
|
|
339
|
+
meta: {
|
|
340
|
+
required: !isNullableOrUndefined(nestedProp.type),
|
|
341
|
+
nullableOrUndefined: isNullableOrUndefined(nestedProp.type)
|
|
342
|
+
}
|
|
343
|
+
})
|
|
344
|
+
|
|
345
|
+
// add to accumulator if valid
|
|
346
|
+
if (nestedPropMeta && typeof nestedPropMeta === 'object' && 'type' in nestedPropMeta) {
|
|
347
|
+
acc[nestedPropKey as NestedKeyOf<T>] = nestedPropMeta as FieldMeta
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
} else {
|
|
357
|
+
// If no struct members and no arrays, process as regular union
|
|
358
|
+
const newMeta = createMeta<T>({
|
|
359
|
+
parent: key,
|
|
360
|
+
property: p.type,
|
|
361
|
+
meta: { required: isRequired, nullableOrUndefined },
|
|
362
|
+
})
|
|
363
|
+
acc[key as NestedKeyOf<T>] = newMeta as FieldMeta
|
|
364
|
+
}
|
|
302
365
|
}
|
|
303
366
|
} else if ("propertySignatures" in typeToProcess) {
|
|
304
367
|
Object.assign(
|
|
@@ -381,6 +444,8 @@ export const createMeta = <T = any>(
|
|
|
381
444
|
property: p.type,
|
|
382
445
|
meta: { required: isRequired, nullableOrUndefined },
|
|
383
446
|
})
|
|
447
|
+
|
|
448
|
+
|
|
384
449
|
acc[key as NestedKeyOf<T>] = newMeta as FieldMeta
|
|
385
450
|
}
|
|
386
451
|
}
|