@sequenceholdings/orm 2.8.2 → 2.8.3

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 CHANGED
@@ -127,6 +127,11 @@ seq-studio orm execute GetOpenDeals . \
127
127
  `variables.json` must contain a JSON object. The platform validates variables,
128
128
  operation requirements, and row policies as the signed-in caller.
129
129
 
130
+ For piped input, use `--variables-file -` (`/dev/stdin` is also supported).
131
+ The CLI consumes UTF-8 stdin until EOF before parsing the JSON object and
132
+ submitting the operation. This keeps large inputs in memory without a temporary
133
+ variables file. Input failures do not submit the operation or retry a mutation.
134
+
130
135
  Execute posts the persistent operation name and expected query/mutation kind to
131
136
  Atlas's `/api/data/v2` endpoint. Version 2 `operations.manifest.json` files contain
132
137
  names, kinds, and gates without schema or operation hashes. Updated clients also
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');
@@ -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 text4 = `${ctes.length ? `WITH ${ctes.join(", ")} ` : ""}${result.text}`;
5468
- if (list(node.sortClause).length) text4 += ` ORDER BY ${list(node.sortClause).map((n) => {
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]) text4 += ` ${keyword} ${this.expr(obj(node[key]), scope).text}`;
5480
+ if (node[key]) text5 += ` ${keyword} ${this.expr(obj(node[key]), scope).text}`;
5480
5481
  }
5481
5482
  this.depth--;
5482
- return { text: text4, columns: resolveUnknown ? columns.map((c) => c.type === "unknown" ? { ...c, type: "text" } : c) : columns };
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 text4 = `SELECT ${targets.join(", ")}${from ? ` FROM ${from}` : ""}`;
5524
- if (node.whereClause) text4 += ` WHERE ${this.expr(obj(node.whereClause), scope).text}`;
5525
- if (list(node.groupClause).length) text4 += ` GROUP BY ${list(node.groupClause).map((n) => this.expr(obj(n), scope).text).join(", ")}`;
5526
- if (node.havingClause) text4 += ` HAVING ${this.expr(obj(node.havingClause), scope).text}`;
5527
- return { text: text4, columns };
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(text4, indent) {
7125
- const escaped = text4.replace(/"""/g, '\\"""');
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 = (text4) => crypto.createHash("sha256").update(text4).digest("hex");
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 text4 = `${JSON.stringify(exported, null, 2)}
10666
+ const text5 = `${JSON.stringify(exported, null, 2)}
10666
10667
  `;
10667
- if (Buffer.byteLength(text4, "utf8") > ORM_MIGRATION_EXPORT_MAX_BYTES) throw new Error("ORM migration export exceeds the size limit");
10668
- return text4;
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 text4 = [
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: text4 };
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 text4 = await promises.readFile(path.resolve(flags["--spec"]), "utf8");
11286
+ const text5 = await promises.readFile(path.resolve(flags["--spec"]), "utf8");
11286
11287
  let parsed;
11287
11288
  try {
11288
- parsed = JSON.parse(text4);
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 text4 = renderOrmMigrationExport(exported);
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 !== text4) {
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, text4);
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
- parsed = JSON.parse(await promises.readFile(path.resolve(variablesFile), "utf8"));
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)}`