@sequenceholdings/orm 2.8.5 → 2.10.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.
Files changed (56) hide show
  1. package/dist/authoring.cjs.map +1 -1
  2. package/dist/authoring.d.cts +2 -2
  3. package/dist/authoring.d.ts +2 -2
  4. package/dist/authoring.js.map +1 -1
  5. package/dist/canonical.cjs.map +1 -1
  6. package/dist/canonical.d.cts +72 -72
  7. package/dist/canonical.d.ts +72 -72
  8. package/dist/canonical.js.map +1 -1
  9. package/dist/cli.cjs +122 -68
  10. package/dist/cli.cjs.map +1 -1
  11. package/dist/cli.d.cts +32 -1
  12. package/dist/cli.d.ts +32 -1
  13. package/dist/cli.js +117 -69
  14. package/dist/cli.js.map +1 -1
  15. package/dist/client.cjs.map +1 -1
  16. package/dist/client.d.cts +1 -1
  17. package/dist/client.d.ts +1 -1
  18. package/dist/client.js.map +1 -1
  19. package/dist/compiler.cjs +259 -18
  20. package/dist/compiler.cjs.map +1 -1
  21. package/dist/compiler.d.cts +183 -3
  22. package/dist/compiler.d.ts +183 -3
  23. package/dist/compiler.js +254 -19
  24. package/dist/compiler.js.map +1 -1
  25. package/dist/{constants-Dou1RkTo.d.cts → constants-D2o0vK6U.d.cts} +8 -1
  26. package/dist/{constants-Dou1RkTo.d.ts → constants-D2o0vK6U.d.ts} +8 -1
  27. package/dist/dynamic-input.d.cts +1 -1
  28. package/dist/dynamic-input.d.ts +1 -1
  29. package/dist/index.cjs +53 -31
  30. package/dist/index.cjs.map +1 -1
  31. package/dist/index.d.cts +61 -60
  32. package/dist/index.d.ts +61 -60
  33. package/dist/index.js +51 -32
  34. package/dist/index.js.map +1 -1
  35. package/dist/ir.cjs +9 -7
  36. package/dist/ir.cjs.map +1 -1
  37. package/dist/ir.d.cts +85 -74
  38. package/dist/ir.d.ts +85 -74
  39. package/dist/ir.js +9 -8
  40. package/dist/ir.js.map +1 -1
  41. package/dist/predicate-v2.cjs +9 -7
  42. package/dist/predicate-v2.cjs.map +1 -1
  43. package/dist/predicate-v2.d.cts +3 -1
  44. package/dist/predicate-v2.d.ts +3 -1
  45. package/dist/predicate-v2.js +9 -7
  46. package/dist/predicate-v2.js.map +1 -1
  47. package/dist/sdl.cjs +8 -7
  48. package/dist/sdl.cjs.map +1 -1
  49. package/dist/sdl.d.cts +1 -1
  50. package/dist/sdl.d.ts +1 -1
  51. package/dist/sdl.js +8 -7
  52. package/dist/sdl.js.map +1 -1
  53. package/package.json +3 -3
  54. package/templates/orm-namespace/package.json +2 -1
  55. package/dist/{definition-DjfC7Lll.d.cts → definition-B99BsOAO.d.cts} +4 -4
  56. package/dist/{definition-DjfC7Lll.d.ts → definition-B99BsOAO.d.ts} +4 -4
@@ -100,5 +100,12 @@ declare function materializedRefreshFunctionName(table: string): string;
100
100
  * a full refresh never reads a snapshot older than a write it then overwrites.
101
101
  */
102
102
  declare function materializeLockKey(schema: string, table: string): string;
103
+ /**
104
+ * Committed copy of the exact operation documents a package registers —
105
+ * GraphQL text and SQL operations already materialized as inert JSON. Atlas
106
+ * recompiles it to check that a registered operation set is what a commit holds.
107
+ */
108
+ declare const OPERATION_DOCUMENTS_FILE = "operations.documents.json";
109
+ declare const OPERATION_DOCUMENTS_VERSION: 1;
103
110
 
104
- export { CELLS_FIELD as C, DEFINITION_FILE_EXTENSIONS as D, HASH_DOMAIN as H, IDENTIFIER_PATTERN as I, MATERIALIZE_ACTOR as M, NAMESPACE_PATTERN as N, ORM_DATA_TOKEN_HEADER as O, QUALIFIED_TABLE_PATTERN as Q, RESERVED_COLUMN_NAMES as R, SYNCED_SOURCE_PATTERN as S, CELL_PARTS as a, type CellPart as b, cellColumnName as c, ORM_SERVICE_DATA_TOKEN_HEADER as d, CAPABILITY_KEY_PATTERN as e, CELL_PART_SUFFIX as f, CLAIM_KEY_PATTERN as g, COLUMN_IDENTIFIER_PATTERN as h, CONSUMER_ROLE_SUFFIX as i, MATERIALIZE_CLAIMS_JSON as j, MAX_DEFINITION_FILE_BYTES as k, MAX_GENERATED_SDL_BYTES as l, MAX_IDENTIFIER_LENGTH as m, MAX_PERSISTED_READ_ROWS as n, MAX_TRACKED_COLUMN_NAME as o, NAMESPACE_CONFIG_FILENAMES as p, ORM_REGISTRATION_MAX_BYTES as q, ORM_SCHEMA_PREFIX as r, RESERVED_TABLE_NAMES as s, consumerRoleName as t, materializeLockKey as u, materializedRefreshFunctionName as v, ormSchemaName as w };
111
+ export { CELLS_FIELD as C, DEFINITION_FILE_EXTENSIONS as D, HASH_DOMAIN as H, IDENTIFIER_PATTERN as I, MATERIALIZE_ACTOR as M, NAMESPACE_PATTERN as N, ORM_DATA_TOKEN_HEADER as O, QUALIFIED_TABLE_PATTERN as Q, RESERVED_COLUMN_NAMES as R, SYNCED_SOURCE_PATTERN as S, CELL_PARTS as a, type CellPart as b, cellColumnName as c, ORM_SERVICE_DATA_TOKEN_HEADER as d, CAPABILITY_KEY_PATTERN as e, CELL_PART_SUFFIX as f, CLAIM_KEY_PATTERN as g, COLUMN_IDENTIFIER_PATTERN as h, CONSUMER_ROLE_SUFFIX as i, MATERIALIZE_CLAIMS_JSON as j, MAX_DEFINITION_FILE_BYTES as k, MAX_GENERATED_SDL_BYTES as l, MAX_IDENTIFIER_LENGTH as m, MAX_PERSISTED_READ_ROWS as n, MAX_TRACKED_COLUMN_NAME as o, NAMESPACE_CONFIG_FILENAMES as p, OPERATION_DOCUMENTS_FILE as q, OPERATION_DOCUMENTS_VERSION as r, ORM_REGISTRATION_MAX_BYTES as s, ORM_SCHEMA_PREFIX as t, RESERVED_TABLE_NAMES as u, consumerRoleName as v, materializeLockKey as w, materializedRefreshFunctionName as x, ormSchemaName as y };
@@ -100,5 +100,12 @@ declare function materializedRefreshFunctionName(table: string): string;
100
100
  * a full refresh never reads a snapshot older than a write it then overwrites.
101
101
  */
102
102
  declare function materializeLockKey(schema: string, table: string): string;
103
+ /**
104
+ * Committed copy of the exact operation documents a package registers —
105
+ * GraphQL text and SQL operations already materialized as inert JSON. Atlas
106
+ * recompiles it to check that a registered operation set is what a commit holds.
107
+ */
108
+ declare const OPERATION_DOCUMENTS_FILE = "operations.documents.json";
109
+ declare const OPERATION_DOCUMENTS_VERSION: 1;
103
110
 
104
- export { CELLS_FIELD as C, DEFINITION_FILE_EXTENSIONS as D, HASH_DOMAIN as H, IDENTIFIER_PATTERN as I, MATERIALIZE_ACTOR as M, NAMESPACE_PATTERN as N, ORM_DATA_TOKEN_HEADER as O, QUALIFIED_TABLE_PATTERN as Q, RESERVED_COLUMN_NAMES as R, SYNCED_SOURCE_PATTERN as S, CELL_PARTS as a, type CellPart as b, cellColumnName as c, ORM_SERVICE_DATA_TOKEN_HEADER as d, CAPABILITY_KEY_PATTERN as e, CELL_PART_SUFFIX as f, CLAIM_KEY_PATTERN as g, COLUMN_IDENTIFIER_PATTERN as h, CONSUMER_ROLE_SUFFIX as i, MATERIALIZE_CLAIMS_JSON as j, MAX_DEFINITION_FILE_BYTES as k, MAX_GENERATED_SDL_BYTES as l, MAX_IDENTIFIER_LENGTH as m, MAX_PERSISTED_READ_ROWS as n, MAX_TRACKED_COLUMN_NAME as o, NAMESPACE_CONFIG_FILENAMES as p, ORM_REGISTRATION_MAX_BYTES as q, ORM_SCHEMA_PREFIX as r, RESERVED_TABLE_NAMES as s, consumerRoleName as t, materializeLockKey as u, materializedRefreshFunctionName as v, ormSchemaName as w };
111
+ export { CELLS_FIELD as C, DEFINITION_FILE_EXTENSIONS as D, HASH_DOMAIN as H, IDENTIFIER_PATTERN as I, MATERIALIZE_ACTOR as M, NAMESPACE_PATTERN as N, ORM_DATA_TOKEN_HEADER as O, QUALIFIED_TABLE_PATTERN as Q, RESERVED_COLUMN_NAMES as R, SYNCED_SOURCE_PATTERN as S, CELL_PARTS as a, type CellPart as b, cellColumnName as c, ORM_SERVICE_DATA_TOKEN_HEADER as d, CAPABILITY_KEY_PATTERN as e, CELL_PART_SUFFIX as f, CLAIM_KEY_PATTERN as g, COLUMN_IDENTIFIER_PATTERN as h, CONSUMER_ROLE_SUFFIX as i, MATERIALIZE_CLAIMS_JSON as j, MAX_DEFINITION_FILE_BYTES as k, MAX_GENERATED_SDL_BYTES as l, MAX_IDENTIFIER_LENGTH as m, MAX_PERSISTED_READ_ROWS as n, MAX_TRACKED_COLUMN_NAME as o, NAMESPACE_CONFIG_FILENAMES as p, OPERATION_DOCUMENTS_FILE as q, OPERATION_DOCUMENTS_VERSION as r, ORM_REGISTRATION_MAX_BYTES as s, ORM_SCHEMA_PREFIX as t, RESERVED_TABLE_NAMES as u, consumerRoleName as v, materializeLockKey as w, materializedRefreshFunctionName as x, ormSchemaName as y };
@@ -1,6 +1,6 @@
1
1
  import { CmpOp, TableMetaIr } from './ir.cjs';
2
2
  import 'zod';
3
- import './constants-Dou1RkTo.cjs';
3
+ import './constants-D2o0vK6U.cjs';
4
4
 
5
5
  /**
6
6
  * §4f dynamic-input validators — PURE, data-only functions the data plane
@@ -1,6 +1,6 @@
1
1
  import { CmpOp, TableMetaIr } from './ir.js';
2
2
  import 'zod';
3
- import './constants-Dou1RkTo.js';
3
+ import './constants-D2o0vK6U.js';
4
4
 
5
5
  /**
6
6
  * §4f dynamic-input validators — PURE, data-only functions the data plane
package/dist/index.cjs CHANGED
@@ -205,6 +205,8 @@ function materializedRefreshFunctionName(table) {
205
205
  function materializeLockKey(schema, table) {
206
206
  return `orm:materialize:${schema}.${table}`;
207
207
  }
208
+ var OPERATION_DOCUMENTS_FILE = "operations.documents.json";
209
+ var OPERATION_DOCUMENTS_VERSION = 1;
208
210
 
209
211
  // src/errors.ts
210
212
  var OrmDefinitionError = class extends Error {
@@ -7152,19 +7154,20 @@ var variableIrSchema = zod.z.object({
7152
7154
  defaultValue: variableDefaultIrSchema.optional()
7153
7155
  });
7154
7156
  var sqlColumnSchema = zod.z.object({ name: zod.z.string(), type: zod.z.enum(["text", "boolean", "integer", "bigint", "numeric", "double", "uuid", "date", "timestamptz", "jsonb"]), nullable: zod.z.boolean() });
7157
+ var sqlObjectIrSchema = zod.z.object({
7158
+ ref: zod.z.string(),
7159
+ table: zod.z.string(),
7160
+ columns: zod.z.array(sqlColumnSchema.extend({ type: zod.z.string() })).min(1),
7161
+ scan: zod.z.string().min(1),
7162
+ read: zod.z.array(zod.z.string()).min(1)
7163
+ }).strict();
7155
7164
  var compiledOperationSchema = zod.z.object({
7156
7165
  language: zod.z.literal("sql").optional(),
7157
7166
  /** Server-compiled object catalog and permission ceiling, never caller SQL. */
7158
7167
  sqlQuery: zod.z.object({
7159
7168
  catalog: zod.z.object({
7160
7169
  identity: zod.z.string(),
7161
- objects: zod.z.array(zod.z.object({
7162
- ref: zod.z.string(),
7163
- table: zod.z.string(),
7164
- columns: zod.z.array(sqlColumnSchema.extend({ type: zod.z.string() })).min(1),
7165
- scan: zod.z.string().min(1),
7166
- read: zod.z.array(zod.z.string()).min(1)
7167
- }).strict()).min(1).max(256)
7170
+ objects: zod.z.array(sqlObjectIrSchema).min(1).max(256)
7168
7171
  }).strict(),
7169
7172
  read: zod.z.array(zod.z.string()).min(1).max(256),
7170
7173
  maxRows: zod.z.number().int().min(1).max(1e4)
@@ -7634,6 +7637,42 @@ async function readSnapshot(dir, ordinal) {
7634
7637
  const path$1 = path.join(dir, MIGRATIONS_DIRNAME, META_DIRNAME, `${pad(ordinal)}.snapshot.json`);
7635
7638
  return parseJson(path$1, await readSnapshotText(dir, ordinal));
7636
7639
  }
7640
+ async function verifyCommittedLedger(dir, entries) {
7641
+ const firstRequiredSnapshot = entries.length - 2;
7642
+ let previousId3;
7643
+ let previousSnapshotPresent = false;
7644
+ let previousHash = null;
7645
+ for (const [index3, entry] of entries.entries()) {
7646
+ const sql7 = await readMigrationSql(dir, entry);
7647
+ if (checksumOf(sql7) !== entry.checksum) {
7648
+ return `${MIGRATIONS_DIRNAME}/${entry.name}.sql does not match its journal checksum \u2014 committed migrations must not be edited`;
7649
+ }
7650
+ const snapshotText = index3 >= firstRequiredSnapshot ? await readSnapshotText(dir, entry.ordinal) : await readPrunableSnapshotText(dir, entry.ordinal);
7651
+ if (snapshotText !== void 0) {
7652
+ if (checksumOf(snapshotText) !== entry.snapshot_checksum) {
7653
+ return `the snapshot for ${entry.name} does not match its journal checksum \u2014 committed snapshots must not be edited (the next diff builds on it)`;
7654
+ }
7655
+ const snapshot = JSON.parse(snapshotText);
7656
+ if (previousSnapshotPresent && snapshot.prevId !== previousId3) {
7657
+ return `snapshot chain broken at ${entry.name} \u2014 regenerate the workspace with \`seq-studio orm diff\``;
7658
+ }
7659
+ previousId3 = snapshot.id;
7660
+ }
7661
+ previousSnapshotPresent = snapshotText !== void 0;
7662
+ if (entry.previous_content_hash !== previousHash) {
7663
+ return `content-hash chain broken at ${entry.name} \u2014 migrations must be appended in order by \`seq-studio orm diff\``;
7664
+ }
7665
+ previousHash = entry.content_hash;
7666
+ }
7667
+ return void 0;
7668
+ }
7669
+ async function readPrunableSnapshotText(dir, ordinal) {
7670
+ const path$1 = path.join(dir, MIGRATIONS_DIRNAME, META_DIRNAME, `${pad(ordinal)}.snapshot.json`);
7671
+ return promises.readFile(path$1, "utf8").catch((error) => {
7672
+ if (error instanceof Error && "code" in error && error.code === "ENOENT") return void 0;
7673
+ throw error;
7674
+ });
7675
+ }
7637
7676
  async function readMigrationSql(dir, entry) {
7638
7677
  const path$1 = path.join(dir, MIGRATIONS_DIRNAME, `${entry.name}.sql`);
7639
7678
  return promises.readFile(path$1, "utf8").catch(() => {
@@ -7794,30 +7833,10 @@ async function checkWorkspace({
7794
7833
  log(`no committed migrations for '${loaded.definition.namespace}' \u2014 run \`seq-studio orm diff\` and commit the result`);
7795
7834
  return 1;
7796
7835
  }
7797
- let previousId3;
7798
- let previousHash = null;
7799
- for (const entry of workspace.journal.entries) {
7800
- const sql7 = await readMigrationSql(dir, entry);
7801
- if (checksumOf(sql7) !== entry.checksum) {
7802
- log(`${MIGRATIONS_DIRNAME}/${entry.name}.sql does not match its journal checksum \u2014 committed migrations must not be edited`);
7803
- return 1;
7804
- }
7805
- const snapshotText = await readSnapshotText(dir, entry.ordinal);
7806
- if (checksumOf(snapshotText) !== entry.snapshot_checksum) {
7807
- log(`the snapshot for ${entry.name} does not match its journal checksum \u2014 committed snapshots must not be edited (the next diff builds on it)`);
7808
- return 1;
7809
- }
7810
- const snapshot = JSON.parse(snapshotText);
7811
- if (entry.ordinal > 1 && snapshot.prevId !== previousId3) {
7812
- log(`snapshot chain broken at ${entry.name} \u2014 regenerate the workspace with \`seq-studio orm diff\``);
7813
- return 1;
7814
- }
7815
- if (entry.previous_content_hash !== previousHash) {
7816
- log(`content-hash chain broken at ${entry.name} \u2014 migrations must be appended in order by \`seq-studio orm diff\``);
7817
- return 1;
7818
- }
7819
- previousId3 = snapshot.id;
7820
- previousHash = entry.content_hash;
7836
+ const broken = await verifyCommittedLedger(dir, workspace.journal.entries);
7837
+ if (broken) {
7838
+ log(broken);
7839
+ return 1;
7821
7840
  }
7822
7841
  if (tip.content_hash !== loaded.contentHash) {
7823
7842
  log(`definitions changed since ${tip.name} \u2014 run \`seq-studio orm diff\` and commit the new migration`);
@@ -8641,6 +8660,8 @@ exports.NAMESPACE_CONFIG_BRAND = NAMESPACE_CONFIG_BRAND;
8641
8660
  exports.NAMESPACE_CONFIG_FILE = NAMESPACE_CONFIG_FILE;
8642
8661
  exports.NAMESPACE_CONFIG_FILENAMES = NAMESPACE_CONFIG_FILENAMES;
8643
8662
  exports.NAMESPACE_PATTERN = NAMESPACE_PATTERN;
8663
+ exports.OPERATION_DOCUMENTS_FILE = OPERATION_DOCUMENTS_FILE;
8664
+ exports.OPERATION_DOCUMENTS_VERSION = OPERATION_DOCUMENTS_VERSION;
8644
8665
  exports.ORM_DATA_TOKEN_HEADER = ORM_DATA_TOKEN_HEADER;
8645
8666
  exports.ORM_MIGRATION_EXPORT_FILE = ORM_MIGRATION_EXPORT_FILE;
8646
8667
  exports.ORM_MIGRATION_EXPORT_MAX_BYTES = ORM_MIGRATION_EXPORT_MAX_BYTES;
@@ -8816,6 +8837,7 @@ exports.rootIrSchema = rootIrSchema;
8816
8837
  exports.securityStatements = securityStatements;
8817
8838
  exports.selectionIrSchema = selectionIrSchema;
8818
8839
  exports.serializeNamespace = serializeNamespace;
8840
+ exports.sqlObjectIrSchema = sqlObjectIrSchema;
8819
8841
  exports.sqlTypeName = sqlTypeName;
8820
8842
  exports.stableJson = stableJson;
8821
8843
  exports.syncedBackingRevokeStatements = syncedBackingRevokeStatements;