@ai-matrx/records 0.96.2 → 0.96.4
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/CHANGELOG.md +18 -0
- package/dist/memory/index.cjs +21 -3
- package/dist/memory/index.cjs.map +1 -1
- package/dist/memory/index.d.cts +1 -1
- package/dist/memory/index.d.ts +1 -1
- package/dist/memory/index.js +21 -3
- package/dist/memory/index.js.map +1 -1
- package/dist/templates/index.cjs +21 -3
- package/dist/templates/index.cjs.map +1 -1
- package/dist/templates/index.d.cts +2 -2
- package/dist/templates/index.d.ts +2 -2
- package/dist/templates/index.js +21 -3
- package/dist/templates/index.js.map +1 -1
- package/dist/{types-BhGs3f8s.d.cts → types-KdeN9-5L.d.cts} +11 -3
- package/dist/{types-DAruHh1G.d.ts → types-qvGJwpw3.d.ts} +11 -3
- package/package.json +2 -2
package/dist/templates/index.cjs
CHANGED
|
@@ -6125,11 +6125,28 @@ function compileInstallPlan(written) {
|
|
|
6125
6125
|
const spec = tokenizeValues({ ...written, attachments: void 0 }, attachmentKeys);
|
|
6126
6126
|
const bound = new Map(allTables(spec).filter((t) => t.bindsTo?.tableId).map((t) => [t.token, t.bindsTo]));
|
|
6127
6127
|
const has = (token, key) => bound.get(token)?.fields.includes(key) ?? false;
|
|
6128
|
+
const resolves = (target, v) => {
|
|
6129
|
+
const b = bound.get(target);
|
|
6130
|
+
return !b || !!b.seedRows || typeof v === "string" && !!b.rowIds?.[v];
|
|
6131
|
+
};
|
|
6128
6132
|
const tables = allTables(spec).map((t) => {
|
|
6129
|
-
if (bound.has(t.token)) return { ...t, rows: [] };
|
|
6130
|
-
const toBound = t.fields.filter((f) => f.parityType === "relation" && f.relationTarget && bound.has(f.relationTarget))
|
|
6133
|
+
if (bound.has(t.token)) return bound.get(t.token).seedRows ? t : { ...t, rows: [] };
|
|
6134
|
+
const toBound = t.fields.filter((f) => f.parityType === "relation" && f.relationTarget && bound.has(f.relationTarget));
|
|
6131
6135
|
if (!toBound.length) return t;
|
|
6132
|
-
|
|
6136
|
+
const lost = /* @__PURE__ */ new Set();
|
|
6137
|
+
const rows = t.rows.map((r) => {
|
|
6138
|
+
const values = { ...r.values ?? {} };
|
|
6139
|
+
for (const f of toBound) {
|
|
6140
|
+
const v = values[f.key];
|
|
6141
|
+
if (v === null || v === void 0) continue;
|
|
6142
|
+
const keep = Array.isArray(v) ? v.filter((x) => resolves(f.relationTarget, x)) : resolves(f.relationTarget, v) ? v : null;
|
|
6143
|
+
if (Array.isArray(keep) ? keep.length < v.length : keep === null) lost.add(f.key);
|
|
6144
|
+
if (keep === null || Array.isArray(keep) && !keep.length) delete values[f.key];
|
|
6145
|
+
else values[f.key] = keep;
|
|
6146
|
+
}
|
|
6147
|
+
return { ...r, values };
|
|
6148
|
+
});
|
|
6149
|
+
return { ...t, rows, fields: t.fields.map((f) => lost.has(f.key) && f.required ? { ...f, required: false } : f) };
|
|
6133
6150
|
});
|
|
6134
6151
|
const steps = [];
|
|
6135
6152
|
const tableRef = (token) => {
|
|
@@ -6205,6 +6222,7 @@ function compileInstallPlan(written) {
|
|
|
6205
6222
|
}
|
|
6206
6223
|
const rowIds = /* @__PURE__ */ new Map();
|
|
6207
6224
|
for (const t of tables) for (const r of t.rows) rowIds.set(`${t.token}.${r.key}`, minted(`row.${t.token}.${r.key}`));
|
|
6225
|
+
for (const [token, b] of bound) if (!b.seedRows) for (const [key, id] of Object.entries(b.rowIds ?? {})) rowIds.set(`${token}.${key}`, id);
|
|
6208
6226
|
const deferred = deferredRelations(tables);
|
|
6209
6227
|
for (const level of rowLevels(tables)) {
|
|
6210
6228
|
for (const t of level) {
|