@ai-matrx/data 0.26.0 → 0.26.2
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 +13 -0
- package/bin/generate.mjs +16 -2
- package/bin/matrx-data.mjs +2 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.26.2
|
|
4
|
+
|
|
5
|
+
Automatic changed-only republish (docs/metadata drift since the last tag — see
|
|
6
|
+
`git diff npm/data/v0.26.1..npm/data/v0.26.2 -- apps/shared/data`).
|
|
7
|
+
No source changes intended and no consumer action required.
|
|
8
|
+
|
|
9
|
+
## 0.26.1 — generate --only
|
|
10
|
+
|
|
11
|
+
- `matrx-data generate --only a,b,schema.c` keeps only the named tables, views and functions (a package
|
|
12
|
+
that calls 29 functions of `public` generates 13 KB, not the schema's 517 KB); an unknown name fails.
|
|
13
|
+
|
|
14
|
+
Consumer action: none.
|
|
15
|
+
|
|
3
16
|
## 0.26.0 — callAll: every row of a set-returning function
|
|
4
17
|
|
|
5
18
|
- **`callAll(db, fn, args, { order })`** — the complete read of a set-returning database function:
|
package/bin/generate.mjs
CHANGED
|
@@ -195,17 +195,31 @@ function readDescriptionFile(dir, name) {
|
|
|
195
195
|
throw new Error(`${name} not found in ${dir} (neither ${name} nor ${name}.gz)`);
|
|
196
196
|
}
|
|
197
197
|
|
|
198
|
-
|
|
198
|
+
/** Keep only the named tables/views/functions (`--only a,b,schema.c`); an unknown name is an error. */
|
|
199
|
+
function pick(desc, only) {
|
|
200
|
+
if (!only?.length) return desc;
|
|
201
|
+
const want = new Set(only.filter((n) => !n.includes(".") || n.startsWith(`${desc.schema}.`)).map((n) => n.slice(n.indexOf(".") + 1)));
|
|
202
|
+
const keep = (rec) => Object.fromEntries(Object.entries(rec ?? {}).filter(([n]) => want.has(n)));
|
|
203
|
+
const out = { ...desc, tables: keep(desc.tables), views: keep(desc.views), functions: keep(desc.functions) };
|
|
204
|
+
return out;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export function generate({ from = BUNDLED_DESCRIPTION, out, schemas, only, check, importFrom, flagsIndex = process.argv.includes("--flags-index") }) {
|
|
199
208
|
const index = JSON.parse(readDescriptionFile(from, "index.json"));
|
|
200
209
|
const names = schemas?.length ? schemas : Object.keys(index.schemas).sort();
|
|
201
210
|
const files = {};
|
|
202
211
|
const descs = [];
|
|
203
212
|
for (const s of names) {
|
|
204
213
|
if (!index.schemas[s]) throw new Error(`schema "${s}" is not in the description (${Object.keys(index.schemas).length} schemas)`);
|
|
205
|
-
const desc = JSON.parse(readDescriptionFile(from, `${s}.json`));
|
|
214
|
+
const desc = pick(JSON.parse(readDescriptionFile(from, `${s}.json`)), only);
|
|
206
215
|
descs.push(desc);
|
|
207
216
|
files[`${s}.ts`] = renderSchema(desc, index.schemas[s].sha256, importFrom);
|
|
208
217
|
}
|
|
218
|
+
if (only?.length) {
|
|
219
|
+
const found = new Set(descs.flatMap((d) => [...Object.keys(d.tables), ...Object.keys(d.views), ...Object.keys(d.functions)].flatMap((n) => [n, `${d.schema}.${n}`])));
|
|
220
|
+
const missing = only.filter((n) => !found.has(n));
|
|
221
|
+
if (missing.length) throw new Error(`--only names nothing in the description: ${missing.join(", ")}`);
|
|
222
|
+
}
|
|
209
223
|
if (flagsIndex) {
|
|
210
224
|
for (const d of descs) files[`${d.schema}.flags.ts`] = renderSchemaFlags(d, importFrom);
|
|
211
225
|
files["flags-index.ts"] = renderFlagLoaders(descs.map((d) => d.schema), importFrom);
|
package/bin/matrx-data.mjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* matrx-data — @ai-matrx/data's build-time CLI.
|
|
4
4
|
*
|
|
5
5
|
* matrx-data emit [--out <dir>] [--check] live database → the database description (read-only)
|
|
6
|
-
* matrx-data generate --out <dir> [--from <dir>] [--schemas a,b] [--flags-index] [--check]
|
|
6
|
+
* matrx-data generate --out <dir> [--from <dir>] [--schemas a,b] [--only t1,fn2] [--flags-index] [--check]
|
|
7
7
|
* description → typed doors in THIS app (--from defaults to the description
|
|
8
8
|
* shipped inside this package version)
|
|
9
9
|
*
|
|
@@ -35,6 +35,7 @@ async function main() {
|
|
|
35
35
|
...(from ? { from: path.resolve(from) } : {}),
|
|
36
36
|
out: path.resolve(out),
|
|
37
37
|
schemas: flag("--schemas")?.split(",").map((s) => s.trim()).filter(Boolean),
|
|
38
|
+
only: flag("--only")?.split(",").map((s) => s.trim()).filter(Boolean),
|
|
38
39
|
check: rest.includes("--check"),
|
|
39
40
|
importFrom: flag("--import-from") ?? "@ai-matrx/data/db",
|
|
40
41
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-matrx/data",
|
|
3
|
-
"version": "0.26.
|
|
3
|
+
"version": "0.26.2",
|
|
4
4
|
"description": "The opinionated AI Matrx data layer: the /db tier's hard-won Supabase primitives — optimistic concurrency, complete-list reads, JSONB merge, session-retry, the domain-wide auth cookie, realtime channel hygiene — the /net resilience trio, and the /files lane: the Matrx file-communication client (durable-ref resolution, the mx_files_session bootstrap, authenticated blob fetch, uploads, the public-link door).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -213,5 +213,5 @@
|
|
|
213
213
|
"test:watch": "vitest",
|
|
214
214
|
"verify:tarball": "node ./scripts/verify-tarball.mjs"
|
|
215
215
|
},
|
|
216
|
-
"gitHead": "
|
|
216
|
+
"gitHead": "5793e7bb0e48ba81443175cc745f27bbd19225a7"
|
|
217
217
|
}
|