@sequenceholdings/orm 2.0.0 → 2.1.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 (69) hide show
  1. package/README.md +94 -2
  2. package/dist/authoring.cjs +1474 -54
  3. package/dist/authoring.cjs.map +1 -1
  4. package/dist/authoring.d.cts +242 -4
  5. package/dist/authoring.d.ts +242 -4
  6. package/dist/authoring.js +1465 -56
  7. package/dist/authoring.js.map +1 -1
  8. package/dist/canonical.cjs +740 -42
  9. package/dist/canonical.cjs.map +1 -1
  10. package/dist/canonical.d.cts +742 -53
  11. package/dist/canonical.d.ts +742 -53
  12. package/dist/canonical.js +724 -43
  13. package/dist/canonical.js.map +1 -1
  14. package/dist/cli.cjs +2478 -328
  15. package/dist/cli.cjs.map +1 -1
  16. package/dist/cli.js +2480 -330
  17. package/dist/cli.js.map +1 -1
  18. package/dist/client.cjs +90 -25
  19. package/dist/client.cjs.map +1 -1
  20. package/dist/client.d.cts +39 -22
  21. package/dist/client.d.ts +39 -22
  22. package/dist/client.js +87 -26
  23. package/dist/client.js.map +1 -1
  24. package/dist/compiler.cjs +1755 -329
  25. package/dist/compiler.cjs.map +1 -1
  26. package/dist/compiler.d.cts +56 -3
  27. package/dist/compiler.d.ts +56 -3
  28. package/dist/compiler.js +1756 -330
  29. package/dist/compiler.js.map +1 -1
  30. package/dist/constants-YoFGjIBM.d.cts +99 -0
  31. package/dist/constants-YoFGjIBM.d.ts +99 -0
  32. package/dist/dynamic-input.d.cts +1 -0
  33. package/dist/dynamic-input.d.ts +1 -0
  34. package/dist/index.cjs +1973 -164
  35. package/dist/index.cjs.map +1 -1
  36. package/dist/index.d.cts +474 -100
  37. package/dist/index.d.ts +474 -100
  38. package/dist/index.js +1940 -167
  39. package/dist/index.js.map +1 -1
  40. package/dist/ir.cjs +869 -46
  41. package/dist/ir.cjs.map +1 -1
  42. package/dist/ir.d.cts +699 -25
  43. package/dist/ir.d.ts +699 -25
  44. package/dist/ir.js +861 -47
  45. package/dist/ir.js.map +1 -1
  46. package/dist/{naming-CTvWSRTf.d.ts → naming-CPfx7EfF.d.ts} +28 -1
  47. package/dist/{naming-DRyinU4u.d.cts → naming-CU9ThP_E.d.cts} +28 -1
  48. package/dist/policy-1iZbGnZZ.d.cts +24 -0
  49. package/dist/policy-1iZbGnZZ.d.ts +24 -0
  50. package/dist/predicate-v2.cjs +852 -49
  51. package/dist/predicate-v2.cjs.map +1 -1
  52. package/dist/predicate-v2.d.cts +2 -1
  53. package/dist/predicate-v2.d.ts +2 -1
  54. package/dist/predicate-v2.js +852 -49
  55. package/dist/predicate-v2.js.map +1 -1
  56. package/dist/sdl.cjs +1309 -58
  57. package/dist/sdl.cjs.map +1 -1
  58. package/dist/sdl.d.cts +7 -3
  59. package/dist/sdl.d.ts +7 -3
  60. package/dist/sdl.js +1305 -59
  61. package/dist/sdl.js.map +1 -1
  62. package/package.json +11 -6
  63. package/templates/orm-namespace/CLAUDE.md +6 -4
  64. package/templates/orm-namespace/codegen.preset.d.cts +7 -0
  65. package/templates/orm-namespace/codegen.ts +2 -1
  66. package/templates/orm-namespace/graphql/example/queries.ts +4 -3
  67. package/templates/orm-namespace/package.json +2 -1
  68. package/templates/orm-namespace/schema/tables.ts +3 -2
  69. package/templates/orm-namespace/sequence.config.ts +7 -11
@@ -3,8 +3,10 @@ import { ClaimKey, PredIr, RootIr, InputRefKind, TableMetaIr, CompiledOperation,
3
3
  import { DocumentNode, OperationDefinitionNode, FragmentDefinitionNode, GraphQLSchema, ValueNode, SelectionSetNode } from 'graphql';
4
4
  export { DynamicInputIssue, DynamicInputResult, NormalizedBoolExp, NormalizedOnConflict, NormalizedOrderBy, NormalizedRow, ORDER_BY_DIRECTIONS, ScalarKind, allowedBoolExpOperators, allowedOps, validateAppendInput, validateBoolExpInput, validateInsertInput, validateOnConflictInput, validateOrderByInput, validateSelectColumns, validateSetInput } from './dynamic-input.cjs';
5
5
  export { CompilePolicyInput, CompilePredicateInput, POLICY_COMPARE_OPS, POLICY_MAX_LINK_DEPTH, ParsedPolicy, PolicyColumnInfo, PolicyCompareOp, PolicyCompileError, PolicyCompileErrorCode, PolicyLinkInfo, PolicyNode, PolicyOperand, PolicyParseError, PolicyResolver, PolicyTableInfo, assertClaimsOnlyWhen, compilePolicy, compilePredicateV2, parsePolicy, walkPolicy } from './predicate-v2.cjs';
6
- export { P as PLATFORM_USER_TYPENAME, c as camelCase, e as enumTypeName, p as pascalCase } from './naming-DRyinU4u.cjs';
6
+ export { P as PLATFORM_USER_TYPENAME, c as camelCase, g as enumTypeName, p as pascalCase } from './naming-CU9ThP_E.cjs';
7
7
  import 'zod';
8
+ import './constants-YoFGjIBM.cjs';
9
+ import './policy-1iZbGnZZ.cjs';
8
10
 
9
11
  type DiagnosticSeverity = 'error' | 'warning';
10
12
  interface CompilerDiagnostic {
@@ -109,6 +111,7 @@ declare function queryRootNames(table: string): {
109
111
  select: string;
110
112
  byPk: string;
111
113
  aggregate: string;
114
+ aggregateGroups: string;
112
115
  };
113
116
  type MutationOp = 'insert' | 'insertOne' | 'update' | 'updateByPk' | 'delete' | 'deleteByPk';
114
117
  declare function mutationRootNames(table: string): Record<MutationOp, string>;
@@ -132,7 +135,7 @@ declare function classifyInputType(name: string, tableByTypename: ReadonlyMap<st
132
135
  */
133
136
 
134
137
  interface QueryRootInfo {
135
- kind: 'select' | 'byPk' | 'aggregate';
138
+ kind: 'select' | 'byPk' | 'aggregate' | 'aggregateGroups';
136
139
  table: string;
137
140
  }
138
141
  interface CrudMutationRootInfo {
@@ -156,7 +159,13 @@ interface CowMutationRootInfo {
156
159
  /** Override: properties copied INSERT…SELECT from synced (pk included). */
157
160
  copyColumns: readonly string[];
158
161
  }
159
- type MutationRootInfo = CrudMutationRootInfo | CowMutationRootInfo;
162
+ /** A resolved-table write root (the table is the resolved view). */
163
+ interface ResolvedMutationRootInfo {
164
+ op: 'resolvedWrite';
165
+ action: 'insert' | 'update' | 'delete' | 'revert';
166
+ table: string;
167
+ }
168
+ type MutationRootInfo = CrudMutationRootInfo | CowMutationRootInfo | ResolvedMutationRootInfo;
160
169
  interface CompileContext {
161
170
  namespace: string;
162
171
  tables: Record<string, TableMetaIr>;
@@ -328,6 +337,7 @@ declare class OperationLowerer {
328
337
  private readonly variables;
329
338
  constructor(ctx: CompileContext, restricted: RestrictedOperation);
330
339
  private meta;
340
+ /** A data column — cell-metadata columns are reachable only through `cells { … }`. */
331
341
  private column;
332
342
  private link;
333
343
  private fieldCandidates;
@@ -346,11 +356,48 @@ declare class OperationLowerer {
346
356
  private lowerLimit;
347
357
  private lowerOffset;
348
358
  lowerSelection(selectionSet: SelectionSetNode, table: string): SelectionIr;
359
+ /**
360
+ * `cells { <column> { at by … } }` — typed per-cell metadata. Plain tables
361
+ * offer `at`/`by`; resolved tables add the winning `source` and newer
362
+ * `conflicts { source at value }`.
363
+ */
364
+ private lowerCells;
349
365
  /** The `{ aggregate { count sum {…} avg {…} } nodes {…} }` block shared by roots and relations. */
350
366
  private lowerAggregateSelection;
367
+ /**
368
+ * The `{ key {…} aggregate {…} }` block of a grouped aggregate root. Same
369
+ * `aggregate` sub-block as the ungrouped shape (shared via
370
+ * `lowerAggregateFields`), but `key` replaces `nodes` — see the IR comment on
371
+ * `aggregateGroupsRootSchema` for why grouped roots have no `nodes`.
372
+ */
373
+ private lowerGroupedAggregateSelection;
374
+ /**
375
+ * `key { month officer }` → the projected group columns. Every field must be
376
+ * one of the query's own group keys: any other column is indeterminate
377
+ * within a group, so selecting it is a document error rather than an
378
+ * arbitrary pick.
379
+ */
380
+ private lowerGroupKeySelection;
381
+ /** The `count` / `sum {…}` / `avg {…}` fields inside an `aggregate { … }` block. */
382
+ private lowerAggregateFields;
351
383
  lowerRoots(operation: OperationDefinitionNode, kind: 'query' | 'mutation'): RootIr[];
384
+ private parseAffectedRowAssertion;
352
385
  private parseRootDirectives;
353
386
  private lowerQueryRoot;
387
+ /** `<t>AggregateGroups(where:, groupBy:, limit:, offset:)` → an aggregateGroups root. */
388
+ private lowerAggregateGroupsRoot;
389
+ /**
390
+ * `groupBy: [{ column: startedAt, bucket: MONTH }, …]` → GroupByKeyIr[].
391
+ *
392
+ * Document-authored only: a whole-argument variable is rejected rather than
393
+ * becoming a §4f slot. Group keys choose which expressions reach GROUP BY,
394
+ * and dynamic-input.ts refuses aggregation shapes from client input on the
395
+ * same reasoning — `where` stays dynamic, which is what runtime filtering
396
+ * actually needs.
397
+ */
398
+ private lowerGroupBy;
399
+ /** Like lowerLimit, but bounded by MAX_GROUPS and defaulting to it. */
400
+ private lowerGroupLimit;
354
401
  /** byPk-style pk arguments: one argument per primary-key column, exactly. */
355
402
  private lowerPkArgs;
356
403
  private lowerMutationRoot;
@@ -362,6 +409,12 @@ declare class OperationLowerer {
362
409
  * the structured fields, never from authored statements.
363
410
  */
364
411
  private lowerCowRoot;
412
+ /**
413
+ * Resolved-table roots: insertOne(object), updateByPk(pkColumns, _set),
414
+ * deleteByPk(pk…), revertByPk(pkColumns, columns). The executor writes only
415
+ * the touched cells into the manual source; `returning` reads the view.
416
+ */
417
+ private lowerResolvedRoot;
365
418
  private lowerMutationResponse;
366
419
  private lowerInsertObjects;
367
420
  private lowerInsertRow;
@@ -3,8 +3,10 @@ import { ClaimKey, PredIr, RootIr, InputRefKind, TableMetaIr, CompiledOperation,
3
3
  import { DocumentNode, OperationDefinitionNode, FragmentDefinitionNode, GraphQLSchema, ValueNode, SelectionSetNode } from 'graphql';
4
4
  export { DynamicInputIssue, DynamicInputResult, NormalizedBoolExp, NormalizedOnConflict, NormalizedOrderBy, NormalizedRow, ORDER_BY_DIRECTIONS, ScalarKind, allowedBoolExpOperators, allowedOps, validateAppendInput, validateBoolExpInput, validateInsertInput, validateOnConflictInput, validateOrderByInput, validateSelectColumns, validateSetInput } from './dynamic-input.js';
5
5
  export { CompilePolicyInput, CompilePredicateInput, POLICY_COMPARE_OPS, POLICY_MAX_LINK_DEPTH, ParsedPolicy, PolicyColumnInfo, PolicyCompareOp, PolicyCompileError, PolicyCompileErrorCode, PolicyLinkInfo, PolicyNode, PolicyOperand, PolicyParseError, PolicyResolver, PolicyTableInfo, assertClaimsOnlyWhen, compilePolicy, compilePredicateV2, parsePolicy, walkPolicy } from './predicate-v2.js';
6
- export { P as PLATFORM_USER_TYPENAME, c as camelCase, e as enumTypeName, p as pascalCase } from './naming-CTvWSRTf.js';
6
+ export { P as PLATFORM_USER_TYPENAME, c as camelCase, g as enumTypeName, p as pascalCase } from './naming-CPfx7EfF.js';
7
7
  import 'zod';
8
+ import './constants-YoFGjIBM.js';
9
+ import './policy-1iZbGnZZ.js';
8
10
 
9
11
  type DiagnosticSeverity = 'error' | 'warning';
10
12
  interface CompilerDiagnostic {
@@ -109,6 +111,7 @@ declare function queryRootNames(table: string): {
109
111
  select: string;
110
112
  byPk: string;
111
113
  aggregate: string;
114
+ aggregateGroups: string;
112
115
  };
113
116
  type MutationOp = 'insert' | 'insertOne' | 'update' | 'updateByPk' | 'delete' | 'deleteByPk';
114
117
  declare function mutationRootNames(table: string): Record<MutationOp, string>;
@@ -132,7 +135,7 @@ declare function classifyInputType(name: string, tableByTypename: ReadonlyMap<st
132
135
  */
133
136
 
134
137
  interface QueryRootInfo {
135
- kind: 'select' | 'byPk' | 'aggregate';
138
+ kind: 'select' | 'byPk' | 'aggregate' | 'aggregateGroups';
136
139
  table: string;
137
140
  }
138
141
  interface CrudMutationRootInfo {
@@ -156,7 +159,13 @@ interface CowMutationRootInfo {
156
159
  /** Override: properties copied INSERT…SELECT from synced (pk included). */
157
160
  copyColumns: readonly string[];
158
161
  }
159
- type MutationRootInfo = CrudMutationRootInfo | CowMutationRootInfo;
162
+ /** A resolved-table write root (the table is the resolved view). */
163
+ interface ResolvedMutationRootInfo {
164
+ op: 'resolvedWrite';
165
+ action: 'insert' | 'update' | 'delete' | 'revert';
166
+ table: string;
167
+ }
168
+ type MutationRootInfo = CrudMutationRootInfo | CowMutationRootInfo | ResolvedMutationRootInfo;
160
169
  interface CompileContext {
161
170
  namespace: string;
162
171
  tables: Record<string, TableMetaIr>;
@@ -328,6 +337,7 @@ declare class OperationLowerer {
328
337
  private readonly variables;
329
338
  constructor(ctx: CompileContext, restricted: RestrictedOperation);
330
339
  private meta;
340
+ /** A data column — cell-metadata columns are reachable only through `cells { … }`. */
331
341
  private column;
332
342
  private link;
333
343
  private fieldCandidates;
@@ -346,11 +356,48 @@ declare class OperationLowerer {
346
356
  private lowerLimit;
347
357
  private lowerOffset;
348
358
  lowerSelection(selectionSet: SelectionSetNode, table: string): SelectionIr;
359
+ /**
360
+ * `cells { <column> { at by … } }` — typed per-cell metadata. Plain tables
361
+ * offer `at`/`by`; resolved tables add the winning `source` and newer
362
+ * `conflicts { source at value }`.
363
+ */
364
+ private lowerCells;
349
365
  /** The `{ aggregate { count sum {…} avg {…} } nodes {…} }` block shared by roots and relations. */
350
366
  private lowerAggregateSelection;
367
+ /**
368
+ * The `{ key {…} aggregate {…} }` block of a grouped aggregate root. Same
369
+ * `aggregate` sub-block as the ungrouped shape (shared via
370
+ * `lowerAggregateFields`), but `key` replaces `nodes` — see the IR comment on
371
+ * `aggregateGroupsRootSchema` for why grouped roots have no `nodes`.
372
+ */
373
+ private lowerGroupedAggregateSelection;
374
+ /**
375
+ * `key { month officer }` → the projected group columns. Every field must be
376
+ * one of the query's own group keys: any other column is indeterminate
377
+ * within a group, so selecting it is a document error rather than an
378
+ * arbitrary pick.
379
+ */
380
+ private lowerGroupKeySelection;
381
+ /** The `count` / `sum {…}` / `avg {…}` fields inside an `aggregate { … }` block. */
382
+ private lowerAggregateFields;
351
383
  lowerRoots(operation: OperationDefinitionNode, kind: 'query' | 'mutation'): RootIr[];
384
+ private parseAffectedRowAssertion;
352
385
  private parseRootDirectives;
353
386
  private lowerQueryRoot;
387
+ /** `<t>AggregateGroups(where:, groupBy:, limit:, offset:)` → an aggregateGroups root. */
388
+ private lowerAggregateGroupsRoot;
389
+ /**
390
+ * `groupBy: [{ column: startedAt, bucket: MONTH }, …]` → GroupByKeyIr[].
391
+ *
392
+ * Document-authored only: a whole-argument variable is rejected rather than
393
+ * becoming a §4f slot. Group keys choose which expressions reach GROUP BY,
394
+ * and dynamic-input.ts refuses aggregation shapes from client input on the
395
+ * same reasoning — `where` stays dynamic, which is what runtime filtering
396
+ * actually needs.
397
+ */
398
+ private lowerGroupBy;
399
+ /** Like lowerLimit, but bounded by MAX_GROUPS and defaulting to it. */
400
+ private lowerGroupLimit;
354
401
  /** byPk-style pk arguments: one argument per primary-key column, exactly. */
355
402
  private lowerPkArgs;
356
403
  private lowerMutationRoot;
@@ -362,6 +409,12 @@ declare class OperationLowerer {
362
409
  * the structured fields, never from authored statements.
363
410
  */
364
411
  private lowerCowRoot;
412
+ /**
413
+ * Resolved-table roots: insertOne(object), updateByPk(pkColumns, _set),
414
+ * deleteByPk(pk…), revertByPk(pkColumns, columns). The executor writes only
415
+ * the touched cells into the manual source; `returning` reads the view.
416
+ */
417
+ private lowerResolvedRoot;
365
418
  private lowerMutationResponse;
366
419
  private lowerInsertObjects;
367
420
  private lowerInsertRow;