@sequenceholdings/orm 2.7.1 → 2.8.1

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 (47) hide show
  1. package/README.md +18 -4
  2. package/dist/authoring.cjs +21 -0
  3. package/dist/authoring.cjs.map +1 -1
  4. package/dist/authoring.d.cts +1 -1
  5. package/dist/authoring.d.ts +1 -1
  6. package/dist/authoring.js +21 -0
  7. package/dist/authoring.js.map +1 -1
  8. package/dist/canonical.d.cts +71 -71
  9. package/dist/canonical.d.ts +71 -71
  10. package/dist/cli.cjs +3460 -3337
  11. package/dist/cli.cjs.map +1 -1
  12. package/dist/cli.d.cts +13 -1
  13. package/dist/cli.d.ts +13 -1
  14. package/dist/cli.js +3459 -3338
  15. package/dist/cli.js.map +1 -1
  16. package/dist/client.cjs +24 -6
  17. package/dist/client.cjs.map +1 -1
  18. package/dist/client.d.cts +12 -3
  19. package/dist/client.d.ts +12 -3
  20. package/dist/client.js +24 -6
  21. package/dist/client.js.map +1 -1
  22. package/dist/compiler.cjs +844 -15
  23. package/dist/compiler.cjs.map +1 -1
  24. package/dist/compiler.d.cts +12 -2
  25. package/dist/compiler.d.ts +12 -2
  26. package/dist/compiler.js +844 -17
  27. package/dist/compiler.js.map +1 -1
  28. package/dist/index.cjs +21 -0
  29. package/dist/index.cjs.map +1 -1
  30. package/dist/index.d.cts +57 -57
  31. package/dist/index.d.ts +57 -57
  32. package/dist/index.js +21 -0
  33. package/dist/index.js.map +1 -1
  34. package/dist/ir.d.cts +72 -72
  35. package/dist/ir.d.ts +72 -72
  36. package/dist/sdl.cjs +3 -3
  37. package/dist/sdl.cjs.map +1 -1
  38. package/dist/sdl.d.cts +2 -0
  39. package/dist/sdl.d.ts +2 -0
  40. package/dist/sdl.js +3 -3
  41. package/dist/sdl.js.map +1 -1
  42. package/package.json +1 -1
  43. package/templates/orm-namespace/graphql/example/queries.ts +52 -5
  44. package/templates/orm-namespace/schema/tables.ts +5 -2
  45. package/templates/orm-namespace/sequence.config.ts +6 -4
  46. package/dist/{definition-DjfC7Lll.d.cts → definition-B99BsOAO.d.cts} +4 -4
  47. package/dist/{definition-DjfC7Lll.d.ts → definition-B99BsOAO.d.ts} +4 -4
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { AuthoringContext, AuthoringRegistration, COLUMN_BRAND, COLUMN_DEFAULT_FNS, CatalogFolders, CheckInput, ColumnBuilder, ColumnDefaultFn, ColumnDefaultLiteral, ColumnTypeSpec, Comparator, CowMutationInput, DrizzleRelation, DurationInput, ENUM_BRAND, EnumRef, EtlSourceInput, ExternalObjectRef, ForeignKeyInput, FunctionRef, IndexInput, LINK_BRAND, LinkKind, LoadNamespaceOptions, LoadedNamespaceV2, ManualSourceInput, NAMESPACE_CONFIG_BRAND, NAMESPACE_CONFIG_FILE, NamespaceCapabilitiesInput, NamespaceCatalog, NamespaceConfigInput, ORM_TO_PIPELINE_TYPE, OrmContractColumnMap, OrmContractPipelineColumn, OrmSyncedTableContract, OrmToPipelineType, OverlayTableRef, OverlayWinsUnionInput, OverrideRowMutationInput, PolicyInput, PolicyVariantInput, PolicyWithVariantsInput, PrefetchSourceInput, ReferentialAction, RelationRef, ResolvedSourceInput, ResolvedTableConfig, ResolvedTablePoliciesInput, RevertOverlayMutationInput, SCHEMA_DIR, SYNCED_CONTRACT_HASH_DOMAIN, SeqLink, SeqNamespaceConfig, SeqTable, SeqView, SerializeNamespaceInput, SyncedTableConfig, SyncedTablePoliciesInput, TABLE_BRAND, TableConfig, TablePoliciesInput, TableRef, ToManyOptions, ToOneOptions, ToPlatformUserOptions, TypedSyncedTableConfig, VIEW_BRAND, ViewConfig, ViewPoliciesInput, ViewQueryContext, ViewSelectQuery, activeAuthoringContext, beginAuthoringContext, computeCanonicalHash, computeSyncedContractHash, custom, defineEnum, defineNamespace, defineResolvedTable, defineSyncedTable, defineTable, defineView, deriveColumnName, endAuthoringContext, etlSource, extractOrmSyncedTableContract, highest, isColumnBuilder, isEnumRef, isSeqLink, isSeqNamespaceConfig, isSeqTable, isSeqView, latest, loadNamespaceFromDir, lowest, managedFn, manualSource, nonNullFirst, objectRef, overlayWinsUnion, overrideRowMutation, prefetchSource, priority, revertOverlayMutation, serializeNamespace, syncedContractSurface, t, toMany, toOne, toPlatformUser, validateNamespaceCatalog } from './authoring.js';
2
- export { S as SqlOperationDefinition, d as defineOperation } from './definition-DjfC7Lll.js';
2
+ export { S as SqlOperationDefinition, d as defineOperation } from './definition-B99BsOAO.js';
3
3
  import { CanonicalDefinition } from './canonical.js';
4
4
  export { CANONICAL_FORMAT, CanonicalColumn, CanonicalEnum, CanonicalLink, CanonicalTable, CanonicalView, IDENTIFIER_RE, OntologyContract, canonicalActionSchema, canonicalColumnSchema, canonicalDefinitionSchema, canonicalEnumSchema, canonicalIndexSchema, canonicalLinkSchema, canonicalPoliciesSchema, canonicalRelations, canonicalTableSchema, canonicalViewSchema, normalizeCanonical, ontologyContractSchema, readOntologyContract } from './canonical.js';
5
5
  import { CustomRolesBlock } from '@sequenceholdings/custom-roles-manifest';
@@ -53,13 +53,13 @@ declare const actionParamSchema: z.ZodObject<{
53
53
  bigint: "bigint";
54
54
  boolean: "boolean";
55
55
  date: "date";
56
- text: "text";
57
- timestamptz: "timestamptz";
58
- jsonb: "jsonb";
59
56
  uuid: "uuid";
57
+ text: "text";
60
58
  integer: "integer";
61
59
  numeric: "numeric";
62
60
  double: "double";
61
+ timestamptz: "timestamptz";
62
+ jsonb: "jsonb";
63
63
  }>;
64
64
  optional: z.ZodOptional<z.ZodBoolean>;
65
65
  description: z.ZodOptional<z.ZodString>;
@@ -78,13 +78,13 @@ declare const actionSchema: z.ZodObject<{
78
78
  bigint: "bigint";
79
79
  boolean: "boolean";
80
80
  date: "date";
81
- text: "text";
82
- timestamptz: "timestamptz";
83
- jsonb: "jsonb";
84
81
  uuid: "uuid";
82
+ text: "text";
85
83
  integer: "integer";
86
84
  numeric: "numeric";
87
85
  double: "double";
86
+ timestamptz: "timestamptz";
87
+ jsonb: "jsonb";
88
88
  }>;
89
89
  optional: z.ZodOptional<z.ZodBoolean>;
90
90
  description: z.ZodOptional<z.ZodString>;
@@ -95,19 +95,19 @@ declare const actionSchema: z.ZodObject<{
95
95
  bigint: "bigint";
96
96
  boolean: "boolean";
97
97
  date: "date";
98
- text: "text";
99
- timestamptz: "timestamptz";
100
- jsonb: "jsonb";
101
98
  uuid: "uuid";
99
+ text: "text";
102
100
  integer: "integer";
103
101
  numeric: "numeric";
104
102
  double: "double";
103
+ timestamptz: "timestamptz";
104
+ jsonb: "jsonb";
105
105
  }>>>;
106
106
  audit: z.ZodOptional<z.ZodObject<{
107
107
  action: z.ZodEnum<{
108
108
  update: "update";
109
- create: "create";
110
109
  delete: "delete";
110
+ create: "create";
111
111
  }>;
112
112
  resource: z.ZodOptional<z.ZodString>;
113
113
  }, z.core.$strict>>;
@@ -130,13 +130,13 @@ declare const columnTypeSchema: z.ZodEnum<{
130
130
  bigint: "bigint";
131
131
  boolean: "boolean";
132
132
  date: "date";
133
- text: "text";
134
- timestamptz: "timestamptz";
135
- jsonb: "jsonb";
136
133
  uuid: "uuid";
134
+ text: "text";
137
135
  integer: "integer";
138
136
  numeric: "numeric";
139
137
  double: "double";
138
+ timestamptz: "timestamptz";
139
+ jsonb: "jsonb";
140
140
  }>;
141
141
  /**
142
142
  * True when the default is one of the allowlisted SQL function calls for its
@@ -162,13 +162,13 @@ declare const columnSchema: z.ZodObject<{
162
162
  bigint: "bigint";
163
163
  boolean: "boolean";
164
164
  date: "date";
165
- text: "text";
166
- timestamptz: "timestamptz";
167
- jsonb: "jsonb";
168
165
  uuid: "uuid";
166
+ text: "text";
169
167
  integer: "integer";
170
168
  numeric: "numeric";
171
169
  double: "double";
170
+ timestamptz: "timestamptz";
171
+ jsonb: "jsonb";
172
172
  }>;
173
173
  primary_key: z.ZodOptional<z.ZodBoolean>;
174
174
  nullable: z.ZodOptional<z.ZodBoolean>;
@@ -212,13 +212,13 @@ declare const tableFileSchema: z.ZodObject<{
212
212
  bigint: "bigint";
213
213
  boolean: "boolean";
214
214
  date: "date";
215
- text: "text";
216
- timestamptz: "timestamptz";
217
- jsonb: "jsonb";
218
215
  uuid: "uuid";
216
+ text: "text";
219
217
  integer: "integer";
220
218
  numeric: "numeric";
221
219
  double: "double";
220
+ timestamptz: "timestamptz";
221
+ jsonb: "jsonb";
222
222
  }>;
223
223
  primary_key: z.ZodOptional<z.ZodBoolean>;
224
224
  nullable: z.ZodOptional<z.ZodBoolean>;
@@ -263,13 +263,13 @@ declare const tableFileSchema: z.ZodObject<{
263
263
  bigint: "bigint";
264
264
  boolean: "boolean";
265
265
  date: "date";
266
- text: "text";
267
- timestamptz: "timestamptz";
268
- jsonb: "jsonb";
269
266
  uuid: "uuid";
267
+ text: "text";
270
268
  integer: "integer";
271
269
  numeric: "numeric";
272
270
  double: "double";
271
+ timestamptz: "timestamptz";
272
+ jsonb: "jsonb";
273
273
  }>;
274
274
  optional: z.ZodOptional<z.ZodBoolean>;
275
275
  description: z.ZodOptional<z.ZodString>;
@@ -280,19 +280,19 @@ declare const tableFileSchema: z.ZodObject<{
280
280
  bigint: "bigint";
281
281
  boolean: "boolean";
282
282
  date: "date";
283
- text: "text";
284
- timestamptz: "timestamptz";
285
- jsonb: "jsonb";
286
283
  uuid: "uuid";
284
+ text: "text";
287
285
  integer: "integer";
288
286
  numeric: "numeric";
289
287
  double: "double";
288
+ timestamptz: "timestamptz";
289
+ jsonb: "jsonb";
290
290
  }>>>;
291
291
  audit: z.ZodOptional<z.ZodObject<{
292
292
  action: z.ZodEnum<{
293
293
  update: "update";
294
- create: "create";
295
294
  delete: "delete";
295
+ create: "create";
296
296
  }>;
297
297
  resource: z.ZodOptional<z.ZodString>;
298
298
  }, z.core.$strict>>;
@@ -804,13 +804,13 @@ declare const ormMigrationExportSchema: z.ZodObject<{
804
804
  bigint: "bigint";
805
805
  boolean: "boolean";
806
806
  date: "date";
807
- text: "text";
808
- timestamptz: "timestamptz";
809
- jsonb: "jsonb";
810
807
  uuid: "uuid";
808
+ text: "text";
811
809
  integer: "integer";
812
810
  numeric: "numeric";
813
811
  double: "double";
812
+ timestamptz: "timestamptz";
813
+ jsonb: "jsonb";
814
814
  }>, z.ZodObject<{
815
815
  enum: z.ZodString;
816
816
  }, z.core.$strip>]>;
@@ -832,10 +832,10 @@ declare const ormMigrationExportSchema: z.ZodObject<{
832
832
  of: z.ZodString;
833
833
  part: z.ZodEnum<{
834
834
  at: "at";
835
- by: "by";
836
- rev: "rev";
837
835
  source: "source";
836
+ by: "by";
838
837
  conflicts: "conflicts";
838
+ rev: "rev";
839
839
  }>;
840
840
  }, z.core.$strict>>;
841
841
  }, z.core.$strip>>>;
@@ -919,21 +919,21 @@ declare const ormMigrationExportSchema: z.ZodObject<{
919
919
  bigint: "bigint";
920
920
  boolean: "boolean";
921
921
  date: "date";
922
- text: "text";
923
- timestamptz: "timestamptz";
924
- jsonb: "jsonb";
925
922
  uuid: "uuid";
923
+ text: "text";
926
924
  integer: "integer";
927
925
  numeric: "numeric";
928
926
  double: "double";
927
+ timestamptz: "timestamptz";
928
+ jsonb: "jsonb";
929
929
  }>;
930
930
  nullable: z.ZodDefault<z.ZodBoolean>;
931
931
  }, z.core.$strip>>>;
932
932
  executes: z.ZodString;
933
933
  returns: z.ZodDefault<z.ZodEnum<{
934
934
  rows: "rows";
935
- rowsAffected: "rowsAffected";
936
935
  scalar: "scalar";
936
+ rowsAffected: "rowsAffected";
937
937
  }>>;
938
938
  audit: z.ZodOptional<z.ZodObject<{
939
939
  action: z.ZodString;
@@ -989,13 +989,13 @@ declare const ormMigrationExportSchema: z.ZodObject<{
989
989
  bigint: "bigint";
990
990
  boolean: "boolean";
991
991
  date: "date";
992
- text: "text";
993
- timestamptz: "timestamptz";
994
- jsonb: "jsonb";
995
992
  uuid: "uuid";
993
+ text: "text";
996
994
  integer: "integer";
997
995
  numeric: "numeric";
998
996
  double: "double";
997
+ timestamptz: "timestamptz";
998
+ jsonb: "jsonb";
999
999
  }>, z.ZodObject<{
1000
1000
  enum: z.ZodString;
1001
1001
  }, z.core.$strip>]>;
@@ -1017,10 +1017,10 @@ declare const ormMigrationExportSchema: z.ZodObject<{
1017
1017
  of: z.ZodString;
1018
1018
  part: z.ZodEnum<{
1019
1019
  at: "at";
1020
- by: "by";
1021
- rev: "rev";
1022
1020
  source: "source";
1021
+ by: "by";
1023
1022
  conflicts: "conflicts";
1023
+ rev: "rev";
1024
1024
  }>;
1025
1025
  }, z.core.$strict>>;
1026
1026
  }, z.core.$strip>>;
@@ -1069,8 +1069,8 @@ declare const ormMigrationExportSchema: z.ZodObject<{
1069
1069
  sources: z.ZodArray<z.ZodObject<{
1070
1070
  name: z.ZodString;
1071
1071
  kind: z.ZodEnum<{
1072
- manual: "manual";
1073
1072
  prefetch: "prefetch";
1073
+ manual: "manual";
1074
1074
  etl: "etl";
1075
1075
  }>;
1076
1076
  table: z.ZodString;
@@ -1192,13 +1192,13 @@ declare const ormMigrationExportSchema: z.ZodObject<{
1192
1192
  bigint: "bigint";
1193
1193
  boolean: "boolean";
1194
1194
  date: "date";
1195
- text: "text";
1196
- timestamptz: "timestamptz";
1197
- jsonb: "jsonb";
1198
1195
  uuid: "uuid";
1196
+ text: "text";
1199
1197
  integer: "integer";
1200
1198
  numeric: "numeric";
1201
1199
  double: "double";
1200
+ timestamptz: "timestamptz";
1201
+ jsonb: "jsonb";
1202
1202
  }>, z.ZodObject<{
1203
1203
  enum: z.ZodString;
1204
1204
  }, z.core.$strip>]>;
@@ -1220,10 +1220,10 @@ declare const ormMigrationExportSchema: z.ZodObject<{
1220
1220
  of: z.ZodString;
1221
1221
  part: z.ZodEnum<{
1222
1222
  at: "at";
1223
- by: "by";
1224
- rev: "rev";
1225
1223
  source: "source";
1224
+ by: "by";
1226
1225
  conflicts: "conflicts";
1226
+ rev: "rev";
1227
1227
  }>;
1228
1228
  }, z.core.$strict>>;
1229
1229
  }, z.core.$strip>>>;
@@ -1307,21 +1307,21 @@ declare const ormMigrationExportSchema: z.ZodObject<{
1307
1307
  bigint: "bigint";
1308
1308
  boolean: "boolean";
1309
1309
  date: "date";
1310
- text: "text";
1311
- timestamptz: "timestamptz";
1312
- jsonb: "jsonb";
1313
1310
  uuid: "uuid";
1311
+ text: "text";
1314
1312
  integer: "integer";
1315
1313
  numeric: "numeric";
1316
1314
  double: "double";
1315
+ timestamptz: "timestamptz";
1316
+ jsonb: "jsonb";
1317
1317
  }>;
1318
1318
  nullable: z.ZodDefault<z.ZodBoolean>;
1319
1319
  }, z.core.$strip>>>;
1320
1320
  executes: z.ZodString;
1321
1321
  returns: z.ZodDefault<z.ZodEnum<{
1322
1322
  rows: "rows";
1323
- rowsAffected: "rowsAffected";
1324
1323
  scalar: "scalar";
1324
+ rowsAffected: "rowsAffected";
1325
1325
  }>>;
1326
1326
  audit: z.ZodOptional<z.ZodObject<{
1327
1327
  action: z.ZodString;
@@ -1377,13 +1377,13 @@ declare const ormMigrationExportSchema: z.ZodObject<{
1377
1377
  bigint: "bigint";
1378
1378
  boolean: "boolean";
1379
1379
  date: "date";
1380
- text: "text";
1381
- timestamptz: "timestamptz";
1382
- jsonb: "jsonb";
1383
1380
  uuid: "uuid";
1381
+ text: "text";
1384
1382
  integer: "integer";
1385
1383
  numeric: "numeric";
1386
1384
  double: "double";
1385
+ timestamptz: "timestamptz";
1386
+ jsonb: "jsonb";
1387
1387
  }>, z.ZodObject<{
1388
1388
  enum: z.ZodString;
1389
1389
  }, z.core.$strip>]>;
@@ -1405,10 +1405,10 @@ declare const ormMigrationExportSchema: z.ZodObject<{
1405
1405
  of: z.ZodString;
1406
1406
  part: z.ZodEnum<{
1407
1407
  at: "at";
1408
- by: "by";
1409
- rev: "rev";
1410
1408
  source: "source";
1409
+ by: "by";
1411
1410
  conflicts: "conflicts";
1411
+ rev: "rev";
1412
1412
  }>;
1413
1413
  }, z.core.$strict>>;
1414
1414
  }, z.core.$strip>>;
@@ -1457,8 +1457,8 @@ declare const ormMigrationExportSchema: z.ZodObject<{
1457
1457
  sources: z.ZodArray<z.ZodObject<{
1458
1458
  name: z.ZodString;
1459
1459
  kind: z.ZodEnum<{
1460
- manual: "manual";
1461
1460
  prefetch: "prefetch";
1461
+ manual: "manual";
1462
1462
  etl: "etl";
1463
1463
  }>;
1464
1464
  table: z.ZodString;
package/dist/index.js CHANGED
@@ -315,6 +315,22 @@ function toPlatformUser(options) {
315
315
  function isSeqLink(value) {
316
316
  return typeof value === "object" && value !== null && value.kind === LINK_BRAND;
317
317
  }
318
+ var TABLE_CONFIG_KEYS = /* @__PURE__ */ new Set([
319
+ "displayName",
320
+ "description",
321
+ "renamedFrom",
322
+ "primaryKey",
323
+ "indexes",
324
+ "checks",
325
+ "foreignKeys",
326
+ "links",
327
+ "policies",
328
+ "cowMutations",
329
+ "cellMetadata",
330
+ "cellRevisions",
331
+ "materializes",
332
+ "internal"
333
+ ]);
318
334
  function isSeqTable(value) {
319
335
  return typeof value === "object" && value !== null && value.kind === TABLE_BRAND;
320
336
  }
@@ -329,6 +345,11 @@ function assertIdentifier({ value, what, file, pattern = IDENTIFIER_PATTERN }) {
329
345
  function defineTable(name2, columns, config = {}) {
330
346
  const file = activeAuthoringContext()?.currentFile;
331
347
  assertIdentifier({ value: name2, what: "table name", file });
348
+ for (const key of Object.keys(config)) {
349
+ if (!TABLE_CONFIG_KEYS.has(key)) {
350
+ throw new OrmDefinitionError(`table "${name2}": unknown defineTable option "${key}"`, file);
351
+ }
352
+ }
332
353
  const entries = Object.entries(columns);
333
354
  if (entries.length === 0) {
334
355
  throw new OrmDefinitionError(`table "${name2}" declares no columns`, file);