@fayz-ai/core 0.38.0 → 0.39.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.
- package/dist/{chunk-ODTOKMD3.js → chunk-FTQOB7HF.js} +13 -3
- package/dist/chunk-FTQOB7HF.js.map +1 -0
- package/dist/{chunk-KGZK47XI.js → chunk-U2K7ZEDA.js} +61 -4
- package/dist/chunk-U2K7ZEDA.js.map +1 -0
- package/dist/data/index.js +1 -1
- package/dist/data/metadata-fields.d.ts +19 -0
- package/dist/data/metadata-fields.d.ts.map +1 -0
- package/dist/data/resolve.d.ts.map +1 -1
- package/dist/i18n/index.js +1 -1
- package/dist/i18n/shell-translations.en.d.ts.map +1 -1
- package/dist/i18n/shell-translations.pt-br.d.ts.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +30 -5
- package/dist/index.js.map +1 -1
- package/dist/lib/impersonation.d.ts +30 -0
- package/dist/lib/impersonation.d.ts.map +1 -0
- package/dist/{shell-translations.pt-br-TTVH5GSD.js → shell-translations.pt-br-CBHOC37X.js} +12 -2
- package/dist/shell-translations.pt-br-CBHOC37X.js.map +1 -0
- package/dist/types/crud.d.ts +6 -0
- package/dist/types/crud.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-KGZK47XI.js.map +0 -1
- package/dist/chunk-ODTOKMD3.js.map +0 -1
- package/dist/shell-translations.pt-br-TTVH5GSD.js.map +0 -1
|
@@ -1381,6 +1381,63 @@ function resetActiveUnit() {
|
|
|
1381
1381
|
notify();
|
|
1382
1382
|
}
|
|
1383
1383
|
|
|
1384
|
+
// src/data/metadata-fields.ts
|
|
1385
|
+
function withMetadataFields(provider, fields) {
|
|
1386
|
+
const paths = Array.isArray(fields) ? fields.map((k) => [k, [k]]) : Object.entries(fields).map(([k, p]) => [k, p.split(".")]);
|
|
1387
|
+
if (paths.length === 0) return provider;
|
|
1388
|
+
const getIn = (obj, path) => path.reduce((o, seg) => o && typeof o === "object" ? o[seg] : void 0, obj);
|
|
1389
|
+
const setIn = (obj, path, value) => {
|
|
1390
|
+
const [head, ...rest] = path;
|
|
1391
|
+
if (!head) return obj;
|
|
1392
|
+
if (rest.length === 0) return { ...obj, [head]: value };
|
|
1393
|
+
const child = obj[head] && typeof obj[head] === "object" && !Array.isArray(obj[head]) ? obj[head] : {};
|
|
1394
|
+
return { ...obj, [head]: setIn(child, rest, value) };
|
|
1395
|
+
};
|
|
1396
|
+
const lift = (row) => {
|
|
1397
|
+
const meta = row.metadata;
|
|
1398
|
+
if (!meta || typeof meta !== "object") return row;
|
|
1399
|
+
const out = { ...row };
|
|
1400
|
+
for (const [k, p] of paths) {
|
|
1401
|
+
const v = getIn(meta, p);
|
|
1402
|
+
if (out[k] === void 0 && v !== void 0) out[k] = v;
|
|
1403
|
+
}
|
|
1404
|
+
return out;
|
|
1405
|
+
};
|
|
1406
|
+
const split = (data) => {
|
|
1407
|
+
const rest = { ...data };
|
|
1408
|
+
const patch = [];
|
|
1409
|
+
for (const [k, p] of paths) {
|
|
1410
|
+
if (k in rest) {
|
|
1411
|
+
patch.push([p, rest[k] === "" ? null : rest[k]]);
|
|
1412
|
+
delete rest[k];
|
|
1413
|
+
}
|
|
1414
|
+
}
|
|
1415
|
+
return { rest, patch };
|
|
1416
|
+
};
|
|
1417
|
+
const apply = (base, patch) => patch.reduce((acc, [p, v]) => setIn(acc, p, v), base);
|
|
1418
|
+
return {
|
|
1419
|
+
...provider,
|
|
1420
|
+
async list(query) {
|
|
1421
|
+
const r = await provider.list(query);
|
|
1422
|
+
return { ...r, data: r.data.map(lift) };
|
|
1423
|
+
},
|
|
1424
|
+
async create(data) {
|
|
1425
|
+
const { rest, patch } = split(data);
|
|
1426
|
+
if (patch.length === 0) return lift(await provider.create(data));
|
|
1427
|
+
const base = rest.metadata ?? {};
|
|
1428
|
+
return lift(await provider.create({ ...rest, metadata: apply(base, patch) }));
|
|
1429
|
+
},
|
|
1430
|
+
async update(id, data) {
|
|
1431
|
+
const { rest, patch } = split(data);
|
|
1432
|
+
if (patch.length === 0) return lift(await provider.update(id, data));
|
|
1433
|
+
const { data: rows } = await provider.list({ filters: { id }, pageSize: 1, countMode: "none" });
|
|
1434
|
+
const current = rows[0]?.metadata ?? {};
|
|
1435
|
+
const incoming = rest.metadata ?? {};
|
|
1436
|
+
return lift(await provider.update(id, { ...rest, metadata: apply({ ...current, ...incoming }, patch) }));
|
|
1437
|
+
}
|
|
1438
|
+
};
|
|
1439
|
+
}
|
|
1440
|
+
|
|
1384
1441
|
// src/data/custom-fields.ts
|
|
1385
1442
|
var KEY = "customFields";
|
|
1386
1443
|
function patchOf(data) {
|
|
@@ -1633,7 +1690,7 @@ function resolveDataProvider(entityDef, mockData, options = {}) {
|
|
|
1633
1690
|
...unitConfig
|
|
1634
1691
|
}), entityDef.data.archetype)));
|
|
1635
1692
|
}
|
|
1636
|
-
return cached(withAddress(createSupabaseProvider(entityDef.data.table, {
|
|
1693
|
+
return cached(withAddress(withMetadataFields(createSupabaseProvider(entityDef.data.table, {
|
|
1637
1694
|
schema: entityDef.data.schema,
|
|
1638
1695
|
tenantId: entityDef.data.tenantScoped === false ? void 0 : tenantId,
|
|
1639
1696
|
tenantIdColumn: entityDef.data.tenantIdColumn,
|
|
@@ -1643,7 +1700,7 @@ function resolveDataProvider(entityDef, mockData, options = {}) {
|
|
|
1643
1700
|
filters: entityDef.data.filters,
|
|
1644
1701
|
defaults: entityDef.data.defaults,
|
|
1645
1702
|
...unitConfig
|
|
1646
|
-
})));
|
|
1703
|
+
}), entityDef.data.metadataFields ?? [])));
|
|
1647
1704
|
}
|
|
1648
1705
|
if (entityDef.data?.table) {
|
|
1649
1706
|
console.warn(
|
|
@@ -1933,5 +1990,5 @@ async function bulkRemove(provider, ids, options) {
|
|
|
1933
1990
|
}
|
|
1934
1991
|
|
|
1935
1992
|
export { CustomFieldsError, DATA_CHANGED_EVENT, DataError, FIELDS_TABLE, attachPersistentCache, bulkCreate, bulkRemove, cacheKeyFor, cachePrefixFor, clearCustomFieldsCache, countByTenant, createArchetypeProvider, createEventBus, createFayzApiProvider, createMockProvider, dataCall, dataQuery, emitDataChanged, eventBus, getActiveUnitId, getPersistentCache, invalidateCount, isKnownMissing, isUnitMode, localList, matchesDataChange, mergeCustomFields, onDataChanged, registerDataTelemetry, rememberIfMissing, replicaKeyFor, resetActiveUnit, resetMissingObjects, resolveCustomFields, resolveDataProvider, setActiveUnitId, setUnitMode, subscribeActiveUnit, syncReplica, toDataError, useActiveUnitId, useDataChanged, useUnitMode, validateCustomFields, withCache, withOffline };
|
|
1936
|
-
//# sourceMappingURL=chunk-
|
|
1937
|
-
//# sourceMappingURL=chunk-
|
|
1993
|
+
//# sourceMappingURL=chunk-U2K7ZEDA.js.map
|
|
1994
|
+
//# sourceMappingURL=chunk-U2K7ZEDA.js.map
|