@sequenceholdings/orm 2.8.2 → 2.8.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/README.md +5 -0
- package/dist/authoring.cjs +31 -8
- package/dist/authoring.cjs.map +1 -1
- package/dist/authoring.d.cts +8 -2
- package/dist/authoring.d.ts +8 -2
- package/dist/authoring.js +31 -8
- package/dist/authoring.js.map +1 -1
- package/dist/canonical.cjs +1 -1
- package/dist/canonical.cjs.map +1 -1
- package/dist/canonical.d.cts +1 -1
- package/dist/canonical.d.ts +1 -1
- package/dist/canonical.js +1 -1
- package/dist/canonical.js.map +1 -1
- package/dist/cli.cjs +27 -24
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +31 -28
- package/dist/cli.js.map +1 -1
- package/dist/compiler.cjs +1 -1
- package/dist/compiler.cjs.map +1 -1
- package/dist/compiler.d.cts +4 -4
- package/dist/compiler.d.ts +4 -4
- package/dist/compiler.js +1 -1
- package/dist/compiler.js.map +1 -1
- package/dist/index.cjs +31 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -9
- package/dist/index.d.ts +7 -9
- package/dist/index.js +31 -8
- package/dist/index.js.map +1 -1
- package/dist/ir.cjs +1 -1
- package/dist/ir.cjs.map +1 -1
- package/dist/ir.d.cts +2 -2
- package/dist/ir.d.ts +2 -2
- package/dist/ir.js +1 -1
- package/dist/ir.js.map +1 -1
- package/dist/{naming-CU9ThP_E.d.cts → naming-BMZKFO0W.d.cts} +1 -2
- package/dist/{naming-CPfx7EfF.d.ts → naming-DUk7AcXs.d.ts} +1 -2
- package/dist/predicate-v2.cjs +1 -1
- package/dist/predicate-v2.cjs.map +1 -1
- package/dist/predicate-v2.d.cts +3 -3
- package/dist/predicate-v2.d.ts +3 -3
- package/dist/predicate-v2.js +1 -1
- package/dist/predicate-v2.js.map +1 -1
- package/dist/sdl.cjs +1 -1
- package/dist/sdl.cjs.map +1 -1
- package/dist/sdl.d.cts +2 -2
- package/dist/sdl.d.ts +2 -2
- package/dist/sdl.js +1 -1
- package/dist/sdl.js.map +1 -1
- package/package.json +1 -1
- package/src/codegen-gql/apollo-hooks.cjs +1 -1
- package/src/codegen-gql/server-fns.cjs +1 -1
- package/templates/orm-namespace/graphql/example/queries.ts +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var promises = require('fs/promises');
|
|
4
4
|
var module$1 = require('module');
|
|
5
5
|
var path = require('path');
|
|
6
|
+
var consumers = require('stream/consumers');
|
|
6
7
|
var url = require('url');
|
|
7
8
|
var jiti = require('jiti');
|
|
8
9
|
var crypto = require('crypto');
|
|
@@ -986,7 +987,7 @@ var canonicalTableSchema = zod.z.object({
|
|
|
986
987
|
table: identifier2,
|
|
987
988
|
displayName: zod.z.string().trim().min(1).max(120).optional(),
|
|
988
989
|
description: zod.z.string().max(2e3).optional(),
|
|
989
|
-
/** Table-level rename hint
|
|
990
|
+
/** Table-level rename hint. */
|
|
990
991
|
renamedFrom: identifier2.optional(),
|
|
991
992
|
/** Synced/reflected read-only tables (`source: schema.table`) — v1 semantics. */
|
|
992
993
|
source: zod.z.string().regex(QUALIFIED_TABLE_PATTERN).optional(),
|
|
@@ -5464,8 +5465,8 @@ var SqlEmitter = class {
|
|
|
5464
5465
|
}
|
|
5465
5466
|
const result = node.op === "SETOP_UNION" ? this.union(node, scope) : this.projection(node, scope);
|
|
5466
5467
|
const { columns } = result;
|
|
5467
|
-
let
|
|
5468
|
-
if (list(node.sortClause).length)
|
|
5468
|
+
let text5 = `${ctes.length ? `WITH ${ctes.join(", ")} ` : ""}${result.text}`;
|
|
5469
|
+
if (list(node.sortClause).length) text5 += ` ORDER BY ${list(node.sortClause).map((n) => {
|
|
5469
5470
|
const sort = obj(obj(n).SortBy);
|
|
5470
5471
|
only(sort, ["node", "sortby_dir", "sortby_nulls", "location"]);
|
|
5471
5472
|
const direction = sort.sortby_dir === "SORTBY_DESC" ? "DESC" : sort.sortby_dir === "SORTBY_ASC" || sort.sortby_dir === "SORTBY_DEFAULT" ? "ASC" : fail3("unsupported SQL sort");
|
|
@@ -5476,10 +5477,10 @@ var SqlEmitter = class {
|
|
|
5476
5477
|
return `${projected.length === 1 ? quoteIdentifier(projected[0].name) : this.expr(value, scope).text} ${direction}${nulls}`;
|
|
5477
5478
|
}).join(", ")}`;
|
|
5478
5479
|
for (const [key, keyword] of [["limitCount", "LIMIT"], ["limitOffset", "OFFSET"]]) {
|
|
5479
|
-
if (node[key])
|
|
5480
|
+
if (node[key]) text5 += ` ${keyword} ${this.expr(obj(node[key]), scope).text}`;
|
|
5480
5481
|
}
|
|
5481
5482
|
this.depth--;
|
|
5482
|
-
return { text:
|
|
5483
|
+
return { text: text5, columns: resolveUnknown ? columns.map((c) => c.type === "unknown" ? { ...c, type: "text" } : c) : columns };
|
|
5483
5484
|
}
|
|
5484
5485
|
union(node, scope) {
|
|
5485
5486
|
for (const key of ["targetList", "fromClause", "whereClause", "groupClause", "havingClause"]) {
|
|
@@ -5520,11 +5521,11 @@ var SqlEmitter = class {
|
|
|
5520
5521
|
}
|
|
5521
5522
|
}
|
|
5522
5523
|
if (!targets.length || targets.length > 256) fail3("invalid SQL projection");
|
|
5523
|
-
let
|
|
5524
|
-
if (node.whereClause)
|
|
5525
|
-
if (list(node.groupClause).length)
|
|
5526
|
-
if (node.havingClause)
|
|
5527
|
-
return { text:
|
|
5524
|
+
let text5 = `SELECT ${targets.join(", ")}${from ? ` FROM ${from}` : ""}`;
|
|
5525
|
+
if (node.whereClause) text5 += ` WHERE ${this.expr(obj(node.whereClause), scope).text}`;
|
|
5526
|
+
if (list(node.groupClause).length) text5 += ` GROUP BY ${list(node.groupClause).map((n) => this.expr(obj(n), scope).text).join(", ")}`;
|
|
5527
|
+
if (node.havingClause) text5 += ` HAVING ${this.expr(obj(node.havingClause), scope).text}`;
|
|
5528
|
+
return { text: text5, columns };
|
|
5528
5529
|
}
|
|
5529
5530
|
from(node, scope) {
|
|
5530
5531
|
this.budget();
|
|
@@ -7121,8 +7122,8 @@ function renderEnum(name2, values) {
|
|
|
7121
7122
|
${values.map((value) => ` ${value}`).join("\n")}
|
|
7122
7123
|
}`;
|
|
7123
7124
|
}
|
|
7124
|
-
function descriptionLines(
|
|
7125
|
-
const escaped =
|
|
7125
|
+
function descriptionLines(text5, indent) {
|
|
7126
|
+
const escaped = text5.replace(/"""/g, '\\"""');
|
|
7126
7127
|
return [`${indent}"""`, ...escaped.split("\n").map((line) => `${indent}${line}`), `${indent}"""`];
|
|
7127
7128
|
}
|
|
7128
7129
|
var PATTERN_COMPARISON_TYPES = /* @__PURE__ */ new Set(["String", "Int", "bigint", "uuid"]);
|
|
@@ -10293,7 +10294,7 @@ async function readMigrationSql(dir, entry) {
|
|
|
10293
10294
|
throw new OrmDefinitionError("missing migration file", path$1);
|
|
10294
10295
|
});
|
|
10295
10296
|
}
|
|
10296
|
-
var checksumOf = (
|
|
10297
|
+
var checksumOf = (text5) => crypto.createHash("sha256").update(text5).digest("hex");
|
|
10297
10298
|
var migrationName = (ordinal, contentHash) => `${pad(ordinal)}_${contentHash.slice(0, 12)}`;
|
|
10298
10299
|
function renderMigrationSql({
|
|
10299
10300
|
name: name2,
|
|
@@ -10662,10 +10663,10 @@ function createOrmMigrationExport({ schemaHash, payload }) {
|
|
|
10662
10663
|
return { ...contents, checksum: checksum(contents) };
|
|
10663
10664
|
}
|
|
10664
10665
|
function renderOrmMigrationExport(exported) {
|
|
10665
|
-
const
|
|
10666
|
+
const text5 = `${JSON.stringify(exported, null, 2)}
|
|
10666
10667
|
`;
|
|
10667
|
-
if (Buffer.byteLength(
|
|
10668
|
-
return
|
|
10668
|
+
if (Buffer.byteLength(text5, "utf8") > ORM_MIGRATION_EXPORT_MAX_BYTES) throw new Error("ORM migration export exceeds the size limit");
|
|
10669
|
+
return text5;
|
|
10669
10670
|
}
|
|
10670
10671
|
|
|
10671
10672
|
// src/compiler-gql/role-warnings.ts
|
|
@@ -10885,7 +10886,7 @@ function renderImportScript({
|
|
|
10885
10886
|
const procedure = renderProcedure({ targetSql, sourceSql, mapped, keys, onConflict, batchSize });
|
|
10886
10887
|
const call = `CALL pg_temp.seq_orm_import(${resume.join(", ")});`;
|
|
10887
10888
|
const omittedLine = omitted.length > 0 ? `-- Omitted columns keep their database default or NULL: ${omitted.join(", ")}` : "-- Every column is mapped.";
|
|
10888
|
-
const
|
|
10889
|
+
const text5 = [
|
|
10889
10890
|
"-- Sequence ORM data import",
|
|
10890
10891
|
`-- namespace: ${namespace}`,
|
|
10891
10892
|
`-- target: ${schemaName}.${table.table}`,
|
|
@@ -10909,7 +10910,7 @@ function renderImportScript({
|
|
|
10909
10910
|
call,
|
|
10910
10911
|
""
|
|
10911
10912
|
].join("\n");
|
|
10912
|
-
return { probeSql, text:
|
|
10913
|
+
return { probeSql, text: text5 };
|
|
10913
10914
|
}
|
|
10914
10915
|
function renderProbe({
|
|
10915
10916
|
sourceSql,
|
|
@@ -11282,10 +11283,10 @@ async function readSpec(flags) {
|
|
|
11282
11283
|
if (flags["--table"] || flags["--from"] || flags["--map"]) {
|
|
11283
11284
|
return { error: "--spec replaces --table, --from, and --map" };
|
|
11284
11285
|
}
|
|
11285
|
-
const
|
|
11286
|
+
const text5 = await promises.readFile(path.resolve(flags["--spec"]), "utf8");
|
|
11286
11287
|
let parsed;
|
|
11287
11288
|
try {
|
|
11288
|
-
parsed = JSON.parse(
|
|
11289
|
+
parsed = JSON.parse(text5);
|
|
11289
11290
|
} catch {
|
|
11290
11291
|
return { error: `--spec ${flags["--spec"]} is not valid JSON` };
|
|
11291
11292
|
}
|
|
@@ -11365,6 +11366,7 @@ var USAGE = `usage:
|
|
|
11365
11366
|
--no-wait returns once the apply is queued
|
|
11366
11367
|
seq-studio orm execute <operation> [dir] --variables-file <file> -e <env>
|
|
11367
11368
|
execute one named persisted operation from this checkout's manifest as the signed-in caller
|
|
11369
|
+
variables-file accepts - or /dev/stdin to read JSON from stdin until EOF
|
|
11368
11370
|
seq-studio orm execute <namespace> <operation> -e <env> [--variables-file <file>] [--var <name>=<value>]...
|
|
11369
11371
|
execute the deployed version's operation by name (no checkout; seq-studio only)
|
|
11370
11372
|
seq-studio orm diff [dir] write/verify the committed migration standalone (--check is the offline CI gate; --allow-destructive consents; --rebase records a v1 -> v2 conversion as a verified no-op)
|
|
@@ -11645,21 +11647,21 @@ async function generateCommand(rest) {
|
|
|
11645
11647
|
schema_snapshot: workspace.tipSnapshot,
|
|
11646
11648
|
...migration ? { migration } : {}
|
|
11647
11649
|
} });
|
|
11648
|
-
const
|
|
11650
|
+
const text5 = renderOrmMigrationExport(exported);
|
|
11649
11651
|
const path$1 = path.join(dir, ORM_MIGRATION_EXPORT_FILE);
|
|
11650
11652
|
if (check) {
|
|
11651
11653
|
const committed = await promises.readFile(path$1, "utf8").catch((error) => {
|
|
11652
11654
|
if (error instanceof Error && "code" in error && error.code === "ENOENT") return void 0;
|
|
11653
11655
|
throw error;
|
|
11654
11656
|
});
|
|
11655
|
-
if (committed !==
|
|
11657
|
+
if (committed !== text5) {
|
|
11656
11658
|
console.error(`${ORM_MIGRATION_EXPORT_FILE} is missing or stale; run seq-studio orm generate ${dir} --migration-export and commit it`);
|
|
11657
11659
|
return 1;
|
|
11658
11660
|
}
|
|
11659
11661
|
console.log(`${ORM_MIGRATION_EXPORT_FILE} matches the current definitions, operations, and committed migration`);
|
|
11660
11662
|
return 0;
|
|
11661
11663
|
}
|
|
11662
|
-
await promises.writeFile(path$1,
|
|
11664
|
+
await promises.writeFile(path$1, text5);
|
|
11663
11665
|
console.log(`wrote ${ORM_MIGRATION_EXPORT_FILE} (${exported.checksum.slice(0, 12)})`);
|
|
11664
11666
|
}
|
|
11665
11667
|
await writeGenerateOutputs(dir, compiled.project);
|
|
@@ -11750,7 +11752,8 @@ function parseExecuteArgs(rest) {
|
|
|
11750
11752
|
async function readExecuteVariables(variablesFile) {
|
|
11751
11753
|
let parsed;
|
|
11752
11754
|
try {
|
|
11753
|
-
|
|
11755
|
+
const contents = variablesFile === "-" || variablesFile === "/dev/stdin" ? await consumers.text(process.stdin) : await promises.readFile(path.resolve(variablesFile), "utf8");
|
|
11756
|
+
parsed = JSON.parse(contents);
|
|
11754
11757
|
} catch (error) {
|
|
11755
11758
|
throw new OrmDefinitionError(
|
|
11756
11759
|
`could not read JSON variables from ${variablesFile}: ${error instanceof Error ? error.message : String(error)}`
|