@effect-app/vue-components 4.0.0-beta.47 → 4.0.0-beta.48
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.
|
@@ -395,58 +395,46 @@ function A(t, n) {
|
|
|
395
395
|
return r;
|
|
396
396
|
}
|
|
397
397
|
function j(e) {
|
|
398
|
-
return e && "fields" in e && typeof e.fields == "object";
|
|
399
|
-
}
|
|
400
|
-
function M(e) {
|
|
401
398
|
return e && "members" in e && Array.isArray(e.members);
|
|
402
399
|
}
|
|
403
|
-
var
|
|
400
|
+
var M = (e, t = {}) => {
|
|
404
401
|
let n = e.ast, r = _(n);
|
|
405
402
|
if (r !== void 0) return r;
|
|
406
403
|
if (f(e.ast) === "null") return null;
|
|
407
|
-
if (f(e.ast)
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
let a = N(i, t[r] || {});
|
|
417
|
-
a === void 0 ? f(i.ast) === "undefined" && (n[r] = void 0) : n[r] = a;
|
|
404
|
+
if (f(e.ast) === "undefined") return;
|
|
405
|
+
let i = a.AST.isObjects(n) ? n : a.AST.isDeclaration(n) ? c(n) : void 0;
|
|
406
|
+
if (i && a.AST.isObjects(i)) {
|
|
407
|
+
let e = {};
|
|
408
|
+
for (let n of i.propertySignatures) {
|
|
409
|
+
let r = n.name.toString(), i = n.type, o = _(i);
|
|
410
|
+
if (o !== void 0) {
|
|
411
|
+
e[r] = o;
|
|
412
|
+
continue;
|
|
418
413
|
}
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
...t
|
|
422
|
-
};
|
|
414
|
+
let s = M(a.make(i), t[r] || {});
|
|
415
|
+
s === void 0 ? f(i) === "undefined" && (e[r] = void 0) : e[r] = s;
|
|
423
416
|
}
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
if (o !== void 0) {
|
|
438
|
-
e[n] = o;
|
|
439
|
-
continue;
|
|
440
|
-
}
|
|
441
|
-
let s = N(a.make(i), t[n] || {});
|
|
442
|
-
s === void 0 ? f(i) === "undefined" && (e[n] = void 0) : e[n] = s;
|
|
443
|
-
}
|
|
444
|
-
return e;
|
|
417
|
+
return {
|
|
418
|
+
...e,
|
|
419
|
+
...t
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
let o = a.AST.isUnion(n) ? n.types : j(e) ? e.members.map((e) => e.ast) : void 0;
|
|
423
|
+
if (o) {
|
|
424
|
+
let e = {};
|
|
425
|
+
for (let t of o) {
|
|
426
|
+
let n = c(t);
|
|
427
|
+
if (a.AST.isObjects(n)) for (let t of n.propertySignatures) {
|
|
428
|
+
let n = t.name.toString(), r = _(t.type), i = e[n] ? _(e[n].ast) : void 0;
|
|
429
|
+
(!e[n] || r !== void 0 && i === void 0) && (e[n] = { ast: t.type });
|
|
445
430
|
}
|
|
446
|
-
if (a.AST.isString(n)) return "";
|
|
447
|
-
if (a.AST.isBoolean(n)) return !1;
|
|
448
431
|
}
|
|
432
|
+
return Object.keys(e).length === 0 ? Object.keys(t).length > 0 ? t : void 0 : Object.entries(e).reduce((e, [n, { ast: r }]) => (e[n] = M(a.make(r), t[n] || {}), e), t);
|
|
433
|
+
}
|
|
434
|
+
if (Object.keys(t).length === 0) {
|
|
435
|
+
if (a.AST.isString(n)) return "";
|
|
436
|
+
if (a.AST.isBoolean(n)) return !1;
|
|
449
437
|
}
|
|
450
438
|
};
|
|
451
439
|
//#endregion
|
|
452
|
-
export { b as createMeta, A as deepMerge,
|
|
440
|
+
export { b as createMeta, A as deepMerge, M as defaultsValueFromSchema, T as duplicateSchema, D as generateInputStandardSchemaFromFieldMeta, E as generateMetaFromSchema, k as getInputType, f as isNullableOrUndefined, w as toFormSchema };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effect-app/vue-components",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.48",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"@mdi/js": "^7.4.47",
|
|
6
6
|
"effect": "^4.0.0-beta.43",
|
|
@@ -57,8 +57,8 @@
|
|
|
57
57
|
"highlight.js": "^11.11.1",
|
|
58
58
|
"mitt": "^3.0.1",
|
|
59
59
|
"vue3-highlightjs": "^1.0.5",
|
|
60
|
-
"@effect-app/vue": "4.0.0-beta.
|
|
61
|
-
"effect-app": "4.0.0-beta.
|
|
60
|
+
"@effect-app/vue": "4.0.0-beta.48",
|
|
61
|
+
"effect-app": "4.0.0-beta.48"
|
|
62
62
|
},
|
|
63
63
|
"scripts": {
|
|
64
64
|
"check": "vue-tsc",
|
|
@@ -1207,20 +1207,10 @@ export function deepMerge(target: any, source: any) {
|
|
|
1207
1207
|
return result
|
|
1208
1208
|
}
|
|
1209
1209
|
|
|
1210
|
-
// Type definitions for schemas with fields and members
|
|
1211
|
-
type SchemaWithFields = {
|
|
1212
|
-
fields: Record<string, S.Schema<any>>
|
|
1213
|
-
}
|
|
1214
|
-
|
|
1215
1210
|
type SchemaWithMembers = {
|
|
1216
1211
|
members: readonly S.Schema<any>[]
|
|
1217
1212
|
}
|
|
1218
1213
|
|
|
1219
|
-
// Type guards to check schema types
|
|
1220
|
-
function hasFields(schema: any): schema is SchemaWithFields {
|
|
1221
|
-
return schema && "fields" in schema && typeof schema.fields === "object"
|
|
1222
|
-
}
|
|
1223
|
-
|
|
1224
1214
|
function hasMembers(schema: any): schema is SchemaWithMembers {
|
|
1225
1215
|
return schema && "members" in schema && Array.isArray(schema.members)
|
|
1226
1216
|
}
|
|
@@ -1244,23 +1234,31 @@ export const defaultsValueFromSchema = (
|
|
|
1244
1234
|
return undefined
|
|
1245
1235
|
}
|
|
1246
1236
|
|
|
1247
|
-
//
|
|
1248
|
-
|
|
1249
|
-
|
|
1237
|
+
// Handle structs via AST (covers plain structs, transformed schemas like decodeTo, ExtendedClass, etc.)
|
|
1238
|
+
const objectsAst = S.AST.isObjects(ast)
|
|
1239
|
+
? ast
|
|
1240
|
+
: S.AST.isDeclaration(ast)
|
|
1241
|
+
? unwrapDeclaration(ast)
|
|
1242
|
+
: undefined
|
|
1243
|
+
if (objectsAst && S.AST.isObjects(objectsAst)) {
|
|
1250
1244
|
const result: Record<string, any> = {}
|
|
1251
1245
|
|
|
1252
|
-
for (const
|
|
1253
|
-
const
|
|
1254
|
-
|
|
1255
|
-
|
|
1246
|
+
for (const prop of objectsAst.propertySignatures) {
|
|
1247
|
+
const key = prop.name.toString()
|
|
1248
|
+
const propType = prop.type
|
|
1249
|
+
|
|
1250
|
+
const propDefault = getDefaultFromAst(propType)
|
|
1251
|
+
if (propDefault !== undefined) {
|
|
1252
|
+
result[key] = propDefault
|
|
1256
1253
|
continue
|
|
1257
1254
|
}
|
|
1258
1255
|
|
|
1259
|
-
|
|
1260
|
-
const
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1256
|
+
const propSchema = S.make(propType)
|
|
1257
|
+
const propValue = defaultsValueFromSchema(propSchema, record[key] || {})
|
|
1258
|
+
|
|
1259
|
+
if (propValue !== undefined) {
|
|
1260
|
+
result[key] = propValue
|
|
1261
|
+
} else if (isNullableOrUndefined(propType) === "undefined") {
|
|
1264
1262
|
result[key] = undefined
|
|
1265
1263
|
}
|
|
1266
1264
|
}
|
|
@@ -1268,74 +1266,41 @@ export const defaultsValueFromSchema = (
|
|
|
1268
1266
|
return { ...result, ...record }
|
|
1269
1267
|
}
|
|
1270
1268
|
|
|
1271
|
-
//
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1269
|
+
// Handle unions via AST or schema-level .members
|
|
1270
|
+
const unionTypes = S.AST.isUnion(ast)
|
|
1271
|
+
? ast.types
|
|
1272
|
+
: hasMembers(schema)
|
|
1273
|
+
? schema.members.map((m) => m.ast)
|
|
1274
|
+
: undefined
|
|
1275
|
+
if (unionTypes) {
|
|
1276
|
+
const mergedFields: Record<string, { ast: S.AST.AST }> = {}
|
|
1275
1277
|
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
}
|
|
1289
|
-
// If both have defaults or neither have defaults, keep the first one (existing)
|
|
1290
|
-
})
|
|
1291
|
-
return acc
|
|
1278
|
+
for (const memberAstRaw of unionTypes) {
|
|
1279
|
+
const memberAst = unwrapDeclaration(memberAstRaw)
|
|
1280
|
+
if (!S.AST.isObjects(memberAst)) continue
|
|
1281
|
+
|
|
1282
|
+
for (const prop of memberAst.propertySignatures) {
|
|
1283
|
+
const key = prop.name.toString()
|
|
1284
|
+
const fieldDefault = getDefaultFromAst(prop.type)
|
|
1285
|
+
const existingDefault = mergedFields[key] ? getDefaultFromAst(mergedFields[key]!.ast) : undefined
|
|
1286
|
+
|
|
1287
|
+
if (!mergedFields[key] || (fieldDefault !== undefined && existingDefault === undefined)) {
|
|
1288
|
+
mergedFields[key] = { ast: prop.type }
|
|
1289
|
+
}
|
|
1292
1290
|
}
|
|
1293
|
-
|
|
1294
|
-
}, {} as Record<string, any>)
|
|
1291
|
+
}
|
|
1295
1292
|
|
|
1296
|
-
if (Object.keys(
|
|
1293
|
+
if (Object.keys(mergedFields).length === 0) {
|
|
1297
1294
|
return Object.keys(record).length > 0 ? record : undefined
|
|
1298
1295
|
}
|
|
1299
1296
|
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
acc[key] = defaultsValueFromSchema(value, record[key] || {})
|
|
1297
|
+
return Object.entries(mergedFields).reduce((acc, [key, { ast: propAst }]) => {
|
|
1298
|
+
acc[key] = defaultsValueFromSchema(S.make(propAst), record[key] || {})
|
|
1303
1299
|
return acc
|
|
1304
1300
|
}, record)
|
|
1305
1301
|
}
|
|
1306
1302
|
|
|
1307
1303
|
if (Object.keys(record).length === 0) {
|
|
1308
|
-
if (S.AST.isObjects(ast)) {
|
|
1309
|
-
// Process TypeLiteral fields directly to build the result object
|
|
1310
|
-
const result: Record<string, any> = { ...record }
|
|
1311
|
-
|
|
1312
|
-
for (const prop of ast.propertySignatures) {
|
|
1313
|
-
const key = prop.name.toString()
|
|
1314
|
-
const propType = prop.type
|
|
1315
|
-
|
|
1316
|
-
const propDefault = getDefaultFromAst(propType)
|
|
1317
|
-
if (propDefault !== undefined) {
|
|
1318
|
-
result[key] = propDefault
|
|
1319
|
-
continue
|
|
1320
|
-
}
|
|
1321
|
-
|
|
1322
|
-
// Create a schema from the property type and get its defaults
|
|
1323
|
-
const propSchema = S.make(propType)
|
|
1324
|
-
|
|
1325
|
-
// Recursively process the property - don't pas for prop processing
|
|
1326
|
-
// to allow proper unwrapping of nested structures
|
|
1327
|
-
const propValue = defaultsValueFromSchema(propSchema, record[key] || {})
|
|
1328
|
-
|
|
1329
|
-
if (propValue !== undefined) {
|
|
1330
|
-
result[key] = propValue
|
|
1331
|
-
} else if (isNullableOrUndefined(propType) === "undefined") {
|
|
1332
|
-
result[key] = undefined
|
|
1333
|
-
}
|
|
1334
|
-
}
|
|
1335
|
-
|
|
1336
|
-
return result
|
|
1337
|
-
}
|
|
1338
|
-
|
|
1339
1304
|
if (S.AST.isString(ast)) {
|
|
1340
1305
|
return ""
|
|
1341
1306
|
}
|