@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 f, pipe as O } from "effect-app";
2
- import { useIntl as A } from "./vue-components.es3.js";
3
- const M = n.NonEmptyArray(n.String), L = (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: o }, l = {}) => {
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 (o) {
16
- for (const r of o) {
17
- const u = i ? `${i}.${r.name.toString()}` : r.name.toString(), a = g(r.type), p = !a, b = r.type;
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 y = r.type.types.filter(
19
+ const T = r.type.types.filter(
20
20
  (s) => s._tag !== "UndefinedKeyword" && s !== n.Null.ast
21
21
  );
22
- if (y.some(
22
+ if (T.some(
23
23
  (s) => "propertySignatures" in s
24
24
  )) {
25
25
  if (!a) {
26
26
  const s = m({
27
- parent: u,
27
+ parent: l,
28
28
  property: r.type,
29
- meta: { required: p, nullableOrUndefined: a }
29
+ meta: { required: u, nullableOrUndefined: a }
30
30
  });
31
- l[u] = s;
31
+ o[l] = s;
32
32
  }
33
- for (const s of y)
33
+ for (const s of T)
34
34
  "propertySignatures" in s && Object.assign(
35
- l,
35
+ o,
36
36
  m({
37
- parent: u,
37
+ parent: l,
38
38
  propertySignatures: s.propertySignatures,
39
- meta: { required: p, nullableOrUndefined: a }
39
+ meta: { required: u, nullableOrUndefined: a }
40
40
  })
41
41
  );
42
42
  } else {
43
- const s = m({
44
- parent: u,
45
- property: r.type,
46
- meta: { required: p, nullableOrUndefined: a }
47
- });
48
- l[u] = s;
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 b)
90
+ } else if ("propertySignatures" in A)
51
91
  Object.assign(
52
- l,
92
+ o,
53
93
  m({
54
- parent: u,
55
- propertySignatures: b.propertySignatures,
56
- meta: { required: p, nullableOrUndefined: a }
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 c = r.type.rest[0].type;
62
- if (c._tag === "TypeLiteral" && "propertySignatures" in c)
63
- for (const s of c.propertySignatures) {
64
- const S = `${u}.${s.name.toString()}`;
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 T of d.propertySignatures) {
69
- const h = `${S}.${T.name.toString()}`, x = m({
70
- parent: h,
71
- property: T.type,
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(T.type),
74
- nullableOrUndefined: g(T.type)
113
+ required: !g(y.type),
114
+ nullableOrUndefined: g(y.type)
75
115
  }
76
116
  });
77
- l[h] = x;
117
+ o[b] = S;
78
118
  }
79
119
  else
80
- l[S] = {
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: S,
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
- l[S] = d;
136
+ o[f] = d;
97
137
  }
98
138
  }
99
139
  } else
100
- l[u] = {
140
+ o[l] = {
101
141
  type: "multiple",
102
142
  members: r.type.elements,
103
143
  rest: r.type.rest,
104
- required: p,
144
+ required: u,
105
145
  nullableOrUndefined: a
106
146
  };
107
147
  else {
108
- const y = m({
109
- parent: u,
148
+ const T = m({
149
+ parent: l,
110
150
  property: r.type,
111
- meta: { required: p, nullableOrUndefined: a }
151
+ meta: { required: u, nullableOrUndefined: a }
112
152
  });
113
- l[u] = y;
153
+ o[l] = T;
114
154
  }
115
155
  }
116
- return l;
156
+ return o;
117
157
  }
118
158
  if (t) {
119
- const r = L(t);
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
- (p) => p._tag !== "UndefinedKeyword" && p !== n.Null.ast
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((p) => p.literal)
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 u = n.AST.getAnnotation(
188
+ const l = n.AST.getAnnotation(
149
189
  t,
150
190
  n.AST.JSONSchemaAnnotationId
151
- ).pipe(f.getOrElse(() => ({})));
152
- return e = { ...e, ...u }, "from" in t ? m({
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
- f.getOrElse(() => "unknown")
200
+ c.getOrElse(() => "unknown")
161
201
  ), e);
162
202
  }
163
- return l;
164
- }, v = (e) => {
203
+ return o;
204
+ }, q = (e) => {
165
205
  const i = e.ast, t = {};
166
206
  if (i._tag === "Transformation" || i._tag === "Refinement")
167
- return v(n.make(i.from));
207
+ return q(n.make(i.from));
168
208
  if ("propertySignatures" in i) {
169
- const o = m({
209
+ const p = m({
170
210
  propertySignatures: i.propertySignatures
171
211
  });
172
- if (Object.values(o).every((r) => r && "type" in r))
173
- return o;
174
- const l = (r, u = "") => {
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 p = u ? `${u}.${a}` : a;
177
- r[a] && typeof r[a] == "object" && "type" in r[a] ? t[p] = r[a] : r[a] && typeof r[a] == "object" && l(r[a], p);
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
- l(o);
220
+ o(p);
181
221
  }
182
222
  return t;
183
- }, N = (e) => n.extend(e, n.Struct({})), _ = (e) => {
184
- const i = v(e), t = O(
223
+ }, w = (e) => n.extend(e, n.Struct({})), $ = (e) => {
224
+ const i = q(e), t = L(
185
225
  e.ast,
186
- f.liftPredicate((o) => o._tag === "Refinement" && "filter" in o),
187
- f.flatMap((o) => n.AST.getJSONSchemaAnnotation(o)),
188
- f.filter((o) => "items" in o),
189
- f.filterMap(
190
- ({ items: o }) => n.decodeUnknownOption(M)(o)
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
- f.zipWith(
232
+ c.zipWith(
193
233
  n.AST.getMessageAnnotation(e.ast),
194
- (o, l) => ({
195
- items: o,
196
- message: l("")
234
+ (p, o) => ({
235
+ items: p,
236
+ message: o("")
197
237
  })
198
238
  ),
199
- f.getOrUndefined
239
+ c.getOrUndefined
200
240
  );
201
241
  return { schema: e, meta: i, filterItems: t };
202
- }, k = (e) => {
203
- const { trans: i } = A();
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
- }, w = (e, i) => n.NullOr(e).pipe(
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
- N as duplicateSchema,
294
- k as generateInputStandardSchemaFromFieldMeta,
295
- _ as generateMetaFromSchema,
296
- w as nullableInput
333
+ w as duplicateSchema,
334
+ K as generateInputStandardSchemaFromFieldMeta,
335
+ $ as generateMetaFromSchema,
336
+ P as nullableInput
297
337
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effect-app/vue-components",
3
- "version": "0.14.6",
3
+ "version": "0.15.0",
4
4
  "peerDependencies": {
5
5
  "@mdi/js": "^7.4.47",
6
6
  "@tanstack/vue-form": "^1.2.4",
@@ -292,13 +292,76 @@ export const createMeta = <T = any>(
292
292
  }
293
293
  }
294
294
  } else {
295
- // If no struct members, process as regular union
296
- const newMeta = createMeta<T>({
297
- parent: key,
298
- property: p.type,
299
- meta: { required: isRequired, nullableOrUndefined },
300
- })
301
- acc[key as NestedKeyOf<T>] = newMeta as FieldMeta
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
  }