@intentius/chant-lexicon-sql 0.124.14 → 0.124.16

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 (61) hide show
  1. package/dist/change-set.d.ts +174 -0
  2. package/dist/change-set.d.ts.map +1 -0
  3. package/dist/composites/audit-log-table.d.ts +12 -4
  4. package/dist/composites/audit-log-table.d.ts.map +1 -1
  5. package/dist/composites/cdc-mirror.d.ts +11 -4
  6. package/dist/composites/cdc-mirror.d.ts.map +1 -1
  7. package/dist/composites/events-table.d.ts +10 -3
  8. package/dist/composites/events-table.d.ts.map +1 -1
  9. package/dist/composites/join-table.d.ts +11 -3
  10. package/dist/composites/join-table.d.ts.map +1 -1
  11. package/dist/composites/refreshed-view.d.ts +11 -3
  12. package/dist/composites/refreshed-view.d.ts.map +1 -1
  13. package/dist/composites/replacing-table.d.ts +10 -3
  14. package/dist/composites/replacing-table.d.ts.map +1 -1
  15. package/dist/composites/rollup-view.d.ts +11 -4
  16. package/dist/composites/rollup-view.d.ts.map +1 -1
  17. package/dist/composites/sharded-table.d.ts +11 -4
  18. package/dist/composites/sharded-table.d.ts.map +1 -1
  19. package/dist/composites/soft-delete-table.d.ts +12 -4
  20. package/dist/composites/soft-delete-table.d.ts.map +1 -1
  21. package/dist/composites/tenant-table.d.ts +11 -3
  22. package/dist/composites/tenant-table.d.ts.map +1 -1
  23. package/dist/composites/typed.d.ts +13 -0
  24. package/dist/composites/typed.d.ts.map +1 -0
  25. package/dist/core/typed.d.ts +22 -0
  26. package/dist/core/typed.d.ts.map +1 -1
  27. package/dist/integrity.json +3 -3
  28. package/dist/lint/rules/sqlpg005.d.ts +5 -0
  29. package/dist/lint/rules/sqlpg005.d.ts.map +1 -1
  30. package/dist/manifest.json +1 -1
  31. package/dist/op/activities/clickhouse-rebuild.d.ts +6 -0
  32. package/dist/op/activities/clickhouse-rebuild.d.ts.map +1 -1
  33. package/dist/op/activities/postgres-migration.d.ts +6 -0
  34. package/dist/op/activities/postgres-migration.d.ts.map +1 -1
  35. package/dist/op/activity-contracts.d.ts +30 -0
  36. package/dist/op/activity-contracts.d.ts.map +1 -1
  37. package/dist/postgres/entities.d.ts +12 -3
  38. package/dist/postgres/entities.d.ts.map +1 -1
  39. package/dist/rules/sqlpg005.ts +11 -3
  40. package/package.json +2 -2
  41. package/src/change-set.test.ts +246 -0
  42. package/src/change-set.ts +354 -0
  43. package/src/composites/audit-log-table.ts +11 -4
  44. package/src/composites/cdc-mirror.ts +11 -4
  45. package/src/composites/events-table.ts +8 -3
  46. package/src/composites/join-table.ts +10 -3
  47. package/src/composites/refreshed-view.ts +10 -3
  48. package/src/composites/replacing-table.ts +8 -3
  49. package/src/composites/rollup-view.ts +11 -4
  50. package/src/composites/sharded-table.ts +9 -4
  51. package/src/composites/soft-delete-table.ts +11 -4
  52. package/src/composites/tenant-table.ts +10 -3
  53. package/src/composites/typed.ts +15 -0
  54. package/src/core/typed.ts +40 -0
  55. package/src/lint/rules/sqlpg005.ts +11 -3
  56. package/src/lint/rules/typed-names.test.ts +12 -0
  57. package/src/op/activities/clickhouse-rebuild.ts +11 -1
  58. package/src/op/activities/postgres-migration.ts +11 -1
  59. package/src/op/activity-contracts.ts +6 -2
  60. package/src/postgres/entities.ts +13 -4
  61. package/src/typed-columns.e2e.test.ts +17 -0
@@ -0,0 +1,174 @@
1
+ /**
2
+ * SQL plans as change-set parts (#3767, the document is #3181).
3
+ *
4
+ * The sql lexicon's declarative plans reach the change set through `chant
5
+ * lifecycle plan`. Two kinds of SQL plan do not, and this module is their
6
+ * adapter:
7
+ *
8
+ * - a versioned plan: the migrations a product (SQL Yodeler) would apply to
9
+ * an environment, each a list of steps in the shape `diffStatements`
10
+ * writes (`./core/statements.ts`). {@link sqlVersionedPlanPart}.
11
+ * - the plan step of the lexicon's own migration Ops, `ClickHouseRebuildOp`
12
+ * and `PostgresMigrationOp`. {@link clickhouseRebuildPart} and
13
+ * {@link postgresMigrationPart}.
14
+ *
15
+ * Each returns a part with planner `sql`, so it composes with every other
16
+ * member's in `composeChangeSet`, and a gate that binds the document gets its
17
+ * Cedar `context.plan` (#3182). A part written to a file as JSON reads back
18
+ * through core's `readChangeSetPart` with `planner: "sql"`.
19
+ *
20
+ * ## Entries
21
+ *
22
+ * One entry per object a plan touches, at the object's server name (`db.name`
23
+ * or `schema.name`), however many steps or migrations touch it. The action
24
+ * and disruption come from the change classes the steps carry, as the
25
+ * dialects' `CHANGE_CLASSES` and `PG_CHANGE_CLASSES` price them:
26
+ *
27
+ * - a `drop` class is a `delete` (`destroy`); a `create` class a `create`;
28
+ * - a `rebuild` or `expand` class, or a step a migration Op makes, is a
29
+ * `replace` (`replace`): the object, or a column of it, is built again;
30
+ * - anything else is an `update`, its disruption the worst class's
31
+ * (`metadata` in-place; `validate`, `concurrently` and `rewrite` rolling).
32
+ * A step marked destructive (a column drop) makes it `destroy`. A class
33
+ * neither dialect knows makes it `unknown`.
34
+ *
35
+ * A step may name its `action` itself, which wins over its classes.
36
+ *
37
+ * ## The import graph
38
+ *
39
+ * Like `@intentius/chant/change-set`, this module bundles small for a tool
40
+ * that runs it in CI with no TypeScript toolchain: it imports chant's plan
41
+ * hashing code and types only. `change-set.test.ts` holds that.
42
+ */
43
+ import type { ChangeSetAction, ChangeSetDisruption, ChangeSetHole, ChangeSetPart } from "@intentius/chant/change-set";
44
+ import type { MigrationStep, StatementChange } from "./core/statements.js";
45
+ /** The lexicon a SQL part's member and entries name. */
46
+ export declare const SQL_CHANGE_SET_LEXICON = "sql";
47
+ /**
48
+ * What each change class costs, both dialects together. The same values as
49
+ * `CHANGE_CLASSES.disruption` (ClickHouse) and `PG_CHANGE_CLASSES.disruption`
50
+ * (Postgres), copied so the rule tables stay out of the bundle; the test
51
+ * holds the two together.
52
+ */
53
+ export declare const SQL_CLASS_DISRUPTION: Readonly<Record<string, ChangeSetDisruption>>;
54
+ /**
55
+ * One step of a versioned plan: a `MigrationStep` as `diffStatements` or
56
+ * `chant sql diff --statements --json` writes it, with what a product knows
57
+ * besides. Only `name` and `type` (from `StepObject`) and `kind` are needed.
58
+ */
59
+ export type SqlPlanStep = MigrationStep & {
60
+ /** Already applied by an earlier, partial run: it proposes nothing. */
61
+ done?: boolean;
62
+ /** The action, when the product knows it better than the classes say. */
63
+ action?: ChangeSetAction;
64
+ /** A statement's classified changes, when the product has them; they become the entry's attributes. */
65
+ changes?: StatementChange[];
66
+ };
67
+ /** A migration of a versioned plan. A step may come wrapped as `{ step, done }`, as SQL Yodeler's plan view holds it. */
68
+ export interface SqlPlanMigration {
69
+ id: string;
70
+ steps: ReadonlyArray<SqlPlanStep | {
71
+ step: SqlPlanStep;
72
+ done?: boolean;
73
+ }>;
74
+ }
75
+ /**
76
+ * A versioned plan, in the shape a product fills: the migrations it would
77
+ * apply to one environment, in order. SQL Yodeler's `VersionedPlan` (`yodel
78
+ * plan <env> --json`) is one as it stands: `pending` for `migrations`, its
79
+ * `refusal` and `digest`.
80
+ */
81
+ export interface SqlVersionedPlan {
82
+ dialect: string;
83
+ /** The environment it plans into: the member's and every entry's `scope`. */
84
+ environment?: string;
85
+ /** The migrations to apply, in order. */
86
+ migrations?: ReadonlyArray<SqlPlanMigration>;
87
+ /** SQL Yodeler's name for `migrations`, read when `migrations` is absent. */
88
+ pending?: ReadonlyArray<SqlPlanMigration>;
89
+ /**
90
+ * The digest the product's own gate binds. When given, it is the member's
91
+ * `planDigest`, so a gate on the member alone and the product's approval
92
+ * bind one value. Absent, the adapter takes `computePlanDigest(
93
+ * "sql-versioned-plan", …)` over the dialect, environment and steps.
94
+ */
95
+ digest?: string;
96
+ /** Why the product would refuse to apply: the member is `failed`. */
97
+ refusal?: string | {
98
+ message: string;
99
+ };
100
+ /** What the product could not read; the plan says nothing about it. */
101
+ holes?: ChangeSetHole[];
102
+ }
103
+ export interface SqlVersionedPlanPartInput {
104
+ member: string;
105
+ plan: SqlVersionedPlan;
106
+ /** Default `"sql"`. */
107
+ lexicon?: string;
108
+ }
109
+ /** What the adapter gathers for one object across every step that touches it. */
110
+ interface ObjectChanges {
111
+ address: string;
112
+ type: string;
113
+ classes: string[];
114
+ actions: ChangeSetAction[];
115
+ destructive: boolean;
116
+ /** A step a migration Op makes. */
117
+ ops: string[];
118
+ manual: string[];
119
+ sql: string[];
120
+ fields: Map<string, StatementChange>;
121
+ }
122
+ /** The action and disruption of one object's changes, as the module's header says. */
123
+ export declare function sqlChangeAction(o: Pick<ObjectChanges, "classes" | "actions" | "destructive" | "ops">): {
124
+ action: ChangeSetAction;
125
+ disruption?: ChangeSetDisruption;
126
+ };
127
+ /**
128
+ * A versioned plan's part ({@link SqlVersionedPlan}): one entry per object
129
+ * its pending steps touch, `scope` the environment. A refusal makes the
130
+ * member `failed` with no plan digest; its entries stay, for a reader.
131
+ */
132
+ export declare function sqlVersionedPlanPart(input: SqlVersionedPlanPartInput): ChangeSetPart;
133
+ /**
134
+ * What a migration Op's plan step returns, as far as a part needs it:
135
+ * `clickhouseRebuildPlan`'s `RebuildPlanResult` and `postgresMigrationPlan`'s
136
+ * `MigrationPlanResult` (`./op/activities/`).
137
+ */
138
+ export interface SqlOpPlan {
139
+ state: string;
140
+ /** ClickHouse: the table, `database.name`. */
141
+ table?: string;
142
+ /** Postgres: `schema.table.column`. */
143
+ migration?: string;
144
+ /** The plan's digest; present while there is something to do. */
145
+ planDigest?: string;
146
+ /** Each classified change, as `<rule> <field>: <before> -> <after>`. */
147
+ changes: string[];
148
+ /** The same changes, structured. Each becomes an attribute; without them, only the field is read from `changes`. */
149
+ classified?: StatementChange[];
150
+ }
151
+ export interface SqlOpPlanPartInput {
152
+ member: string;
153
+ plan: SqlOpPlan;
154
+ /** The environment the Op runs against: the member's and the entry's `scope`. */
155
+ environment?: string;
156
+ /** Default `"sql"`. */
157
+ lexicon?: string;
158
+ }
159
+ /**
160
+ * The part of a `ClickHouseRebuildOp`'s plan step: while the state is
161
+ * `rebuild`, one `replace` of the table, its plan digest the step's (the
162
+ * value before the verification, not the swap gate's). `swapped` and `done`
163
+ * propose nothing.
164
+ */
165
+ export declare function clickhouseRebuildPart(input: SqlOpPlanPartInput): ChangeSetPart;
166
+ /**
167
+ * The part of a `PostgresMigrationOp`'s plan step: while the state is
168
+ * `migrate`, one `replace` of the table (`schema.table`) whose column it
169
+ * expands and contracts, its plan digest the step's. `switched` and `done`
170
+ * propose nothing.
171
+ */
172
+ export declare function postgresMigrationPart(input: SqlOpPlanPartInput): ChangeSetPart;
173
+ export {};
174
+ //# sourceMappingURL=change-set.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"change-set.d.ts","sourceRoot":"","sources":["../src/change-set.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAGH,OAAO,KAAK,EACV,eAAe,EAEf,mBAAmB,EAEnB,aAAa,EACb,aAAa,EACd,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAExE,wDAAwD;AACxD,eAAO,MAAM,sBAAsB,QAAQ,CAAC;AAE5C;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAS9E,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,aAAa,GAAG;IACxC,uEAAuE;IACvE,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,yEAAyE;IACzE,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB,uGAAuG;IACvG,OAAO,CAAC,EAAE,eAAe,EAAE,CAAC;CAC7B,CAAC;AAEF,yHAAyH;AACzH,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,aAAa,CAAC,WAAW,GAAG;QAAE,IAAI,EAAE,WAAW,CAAC;QAAC,IAAI,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;CAC3E;AAED;;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BAAgB,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,GAAG,aAAa,CA4BpF;AAID;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,8CAA8C;IAC9C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uCAAuC;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iEAAiE;IACjE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,wEAAwE;IACxE,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,oHAAoH;IACpH,UAAU,CAAC,EAAE,eAAe,EAAE,CAAC;CAChC;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,SAAS,CAAC;IAChB,iFAAiF;IACjF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,uBAAuB;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAgCD;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,kBAAkB,GAAG,aAAa,CAI9E;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,kBAAkB,GAAG,aAAa,CAK9E"}
@@ -11,6 +11,8 @@
11
11
  * question an audit log is asked most: what did this actor do, and when.
12
12
  */
13
13
  import { type PostgresIndex, type PostgresSchema, type PostgresTable } from "../postgres/entities.js";
14
+ import type { PostgresMemberName } from "../core/typed.js";
15
+ import type { Instance, TypedComposite } from "./typed.js";
14
16
  export interface AuditLogTableProps {
15
17
  /** The table's name, unqualified. The default partition is `<name>_default`. */
16
18
  name: string;
@@ -21,11 +23,17 @@ export interface AuditLogTableProps {
21
23
  /** The column naming who acted (default `actor`). */
22
24
  actor?: string;
23
25
  }
24
- export type AuditLogTableMembers = {
25
- table: PostgresTable;
26
- defaultPartition: PostgresTable;
26
+ /** `Table` and `Default` are the table's and its default partition's qualified names, when the call's props give them (chant#3787). */
27
+ export type AuditLogTableMembers<Table extends string = string, Default extends string = string> = {
28
+ table: PostgresTable<Table>;
29
+ defaultPartition: PostgresTable<Default>;
27
30
  actorIndex: PostgresIndex;
28
31
  };
32
+ type AuditLogTableCall = <const N extends string, const S extends PostgresSchema | string = "public">(props: AuditLogTableProps & {
33
+ name: N;
34
+ schema?: S;
35
+ }) => Instance<AuditLogTableMembers<PostgresMemberName<S, N>, PostgresMemberName<S, N, "_default">>>;
29
36
  /** An append-only audit log partitioned by month on its timestamp, with a default partition and an index by actor. */
30
- export declare const AuditLogTable: import("@intentius/chant").CompositeDefinition<AuditLogTableProps, AuditLogTableMembers>;
37
+ export declare const AuditLogTable: TypedComposite<AuditLogTableProps, AuditLogTableMembers<string, string>, AuditLogTableCall>;
38
+ export {};
31
39
  //# sourceMappingURL=audit-log-table.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"audit-log-table.d.ts","sourceRoot":"","sources":["../../src/composites/audit-log-table.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EAAgB,KAAK,aAAa,EAAE,KAAK,cAAc,EAAE,KAAK,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAEjH,MAAM,WAAW,kBAAkB;IACjC,gFAAgF;IAChF,IAAI,EAAE,MAAM,CAAC;IACb,mGAAmG;IACnG,MAAM,CAAC,EAAE,cAAc,GAAG,MAAM,CAAC;IACjC,wEAAwE;IACxE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qDAAqD;IACrD,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,oBAAoB,GAAG;IACjC,KAAK,EAAE,aAAa,CAAC;IACrB,gBAAgB,EAAE,aAAa,CAAC;IAChC,UAAU,EAAE,aAAa,CAAC;CAC3B,CAAC;AAEF,sHAAsH;AACtH,eAAO,MAAM,aAAa,0FAmBP,CAAC"}
1
+ {"version":3,"file":"audit-log-table.d.ts","sourceRoot":"","sources":["../../src/composites/audit-log-table.ts"],"names":[],"mappings":"AAAA;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{ type ClickHouseTable, type ClickHouseView } from "../clickhouse/entities.js";
12
+ import type { ClickHouseMemberName } from "../core/typed.js";
13
+ import type { Instance, TypedComposite } from "./typed.js";
12
14
  export interface CdcMirrorProps {
13
15
  /** The mirror table's name. The view of live rows is `<name>_current`. */
14
16
  name: string;
@@ -23,10 +25,15 @@ export interface CdcMirrorProps {
23
25
  /** A `PARTITION BY` expression. Left out by default. */
24
26
  partitionBy?: string;
25
27
  }
26
- export type CdcMirrorMembers = {
27
- table: ClickHouseTable;
28
- current: ClickHouseView;
28
+ /** `Table` and `Current` are the mirror's and its view's names, when the call's props give them (chant#3787). */
29
+ export type CdcMirrorMembers<Table extends string = string, Current extends string = string> = {
30
+ table: ClickHouseTable<Table>;
31
+ current: ClickHouseView<Current>;
29
32
  };
33
+ type CdcMirrorCall = <const N extends string>(props: CdcMirrorProps & {
34
+ name: N;
35
+ }) => Instance<CdcMirrorMembers<ClickHouseMemberName<N>, ClickHouseMemberName<N, "_current">>>;
30
36
  /** A ReplacingMergeTree mirror of a CDC-fed source table, with a view of the rows not deleted. */
31
- export declare const CdcMirror: import("@intentius/chant").CompositeDefinition<CdcMirrorProps, CdcMirrorMembers>;
37
+ export declare const CdcMirror: TypedComposite<CdcMirrorProps, CdcMirrorMembers<string, string>, CdcMirrorCall>;
38
+ export {};
32
39
  //# sourceMappingURL=cdc-mirror.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cdc-mirror.d.ts","sourceRoot":"","sources":["../../src/composites/cdc-mirror.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAe,KAAK,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAEhG,MAAM,WAAW,cAAc;IAC7B,0EAA0E;IAC1E,IAAI,EAAE,MAAM,CAAC;IACb,mFAAmF;IACnF,OAAO,EAAE,MAAM,CAAC;IAChB,wFAAwF;IACxF,UAAU,EAAE,MAAM,CAAC;IACnB,2EAA2E;IAC3E,OAAO,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AG;IAAE,IAAI,EAAE,CAAC,CAAA;CAAE,KAChC,QAAQ,CAAC,gBAAgB,CAAC,oBAAoB,CAAC,CAAC,CAAC,EAAE,oBAAoB,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;AAE9F,kGAAkG;AAClG,eAAO,MAAM,SAAS,iFAkBP,CAAC"}
@@ -8,6 +8,8 @@
8
8
  * when the partition and the TTL follow the same column.
9
9
  */
10
10
  import { type ClickHouseTable } from "../clickhouse/entities.js";
11
+ import type { ClickHouseMemberName } from "../core/typed.js";
12
+ import type { Instance, TypedComposite } from "./typed.js";
11
13
  export interface EventsTableProps {
12
14
  /** The table's name, `name` or `database.name`. */
13
15
  name: string;
@@ -24,9 +26,14 @@ export interface EventsTableProps {
24
26
  /** The partition key (default `toYYYYMM(<timestamp>)`). Keep it no finer than a day. */
25
27
  partitionBy?: string;
26
28
  }
27
- export type EventsTableMembers = {
28
- table: ClickHouseTable;
29
+ /** `Table` is the table's name, when the call's props give it (chant#3787). */
30
+ export type EventsTableMembers<Table extends string = string> = {
31
+ table: ClickHouseTable<Table>;
29
32
  };
33
+ type EventsTableCall = <const N extends string>(props: EventsTableProps & {
34
+ name: N;
35
+ }) => Instance<EventsTableMembers<ClickHouseMemberName<N>>>;
30
36
  /** An append-only MergeTree events table, partitioned by its timestamp and expired by TTL. */
31
- export declare const EventsTable: import("@intentius/chant").CompositeDefinition<EventsTableProps, EventsTableMembers>;
37
+ export declare const EventsTable: TypedComposite<EventsTableProps, EventsTableMembers<string>, EventsTableCall>;
38
+ export {};
32
39
  //# sourceMappingURL=events-table.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"events-table.d.ts","sourceRoot":"","sources":["../../src/composites/events-table.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAS,KAAK,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAErE,MAAM,WAAW,gBAAgB;IAC/B,mDAAmD;IACnD,IAAI,EAAE,MAAM,C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AK,eAAe,GAAG,CAAC,KAAK,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,gBAAgB,GAAG;IAAE,IAAI,EAAE,CAAC,CAAA;CAAE,KAAK,QAAQ,CAAC,kBAAkB,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAEhJ,8FAA8F;AAC9F,eAAO,MAAM,WAAW,+EAaP,CAAC"}
@@ -8,6 +8,8 @@
8
8
  * default, so deleting a row on either side removes its links.
9
9
  */
10
10
  import { type PostgresIndex, type PostgresSchema, type PostgresTable } from "../postgres/entities.js";
11
+ import type { PostgresMemberName } from "../core/typed.js";
12
+ import type { Instance, TypedComposite } from "./typed.js";
11
13
  export interface JoinTableProps {
12
14
  /** The table's name, unqualified. The reverse index is `<name>_reverse_idx`. */
13
15
  name: string;
@@ -32,10 +34,16 @@ export interface JoinTableProps {
32
34
  /** What happens to a link when the row it references is deleted (default `CASCADE`). */
33
35
  onDelete?: string;
34
36
  }
35
- export type JoinTableMembers = {
36
- table: PostgresTable;
37
+ /** `Table` is the join table's qualified name, when the call's props give it (chant#3787). */
38
+ export type JoinTableMembers<Table extends string = string> = {
39
+ table: PostgresTable<Table>;
37
40
  reverseIndex: PostgresIndex;
38
41
  };
42
+ type JoinTableCall = <const N extends string, const S extends PostgresSchema | string = "public">(props: JoinTableProps & {
43
+ name: N;
44
+ schema?: S;
45
+ }) => Instance<JoinTableMembers<PostgresMemberName<S, N>>>;
39
46
  /** The table of a many-to-many relation: two foreign keys, a composite primary key and the reverse index. */
40
- export declare const JoinTable: import("@intentius/chant").CompositeDefinition<JoinTableProps, JoinTableMembers>;
47
+ export declare const JoinTable: TypedComposite<JoinTableProps, JoinTableMembers<string>, JoinTableCall>;
48
+ export {};
41
49
  //# sourceMappingURL=join-table.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"join-table.d.ts","sourceRoot":"","sources":["../../src/composites/join-table.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,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,CAAC,EAAE,cAAc,GAAG,MAAM,CAAC;IACjC,4DAA4D;IAC5D,IAAI,EAAE,aAAa,CAAC;IACpB,sEAAsE;IACtE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,+DAA+D;IAC/D,UAAU,EAAE,MAAM,CAAC;IACnB,iDAAiD;IACjD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,6DAA6D;IAC7D,KAAK,EAAE,aAAa,CAAC;IACrB,uEAAuE;IACvE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gEAAgE;IAChE,WAAW,EAAE,MAAM,CAAC;IACpB,kDAAkD;IAClD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wFAAwF;IACxF,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,8FAA8F;AAC9F,MAAM,MAAM,gBAAgB,CAAC,KAAK,SAAS,MAAM,GAAG,MAAM,IAAI;IAC5D,KAAK,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC;IAC5B,YAAY,EAAE,aAAa,CAAC;CAC7B,CAAC;AAEF,KAAK,aAAa,GAAG,CAAC,KAAK,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,CAAC,CAAC,SAAS,cAAc,GAAG,MAAM,GAAG,QAAQ,EAC9F,KAAK,EAAE,cAAc,GAAG;IAAE,IAAI,EAAE,CAAC,CAAC;IAAC,MAAM,CAAC,EAAE,CAAC,CAAA;CAAE,KAC5C,QAAQ,CAAC,gBAAgB,CAAC,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AAE1D,6GAA6G;AAC7G,eAAO,MAAM,SAAS,yEAYP,CAAC"}
@@ -9,6 +9,8 @@
9
9
  * names the source's columns.
10
10
  */
11
11
  import { type PostgresIndex, type PostgresRelation, type PostgresSchema, type PostgresView } from "../postgres/entities.js";
12
+ import type { PostgresMemberName } from "../core/typed.js";
13
+ import type { Instance, TypedComposite } from "./typed.js";
12
14
  export interface RefreshedViewProps {
13
15
  /** The view's name, unqualified. The index is `<name>_key`. */
14
16
  name: string;
@@ -23,10 +25,16 @@ export interface RefreshedViewProps {
23
25
  /** The columns of the unique index, which must identify one row of the result (default `groupBy`). */
24
26
  uniqueOn?: string;
25
27
  }
26
- export type RefreshedViewMembers = {
27
- view: PostgresView;
28
+ /** `View` is the materialized view's qualified name, when the call's props give it (chant#3787). */
29
+ export type RefreshedViewMembers<View extends string = string> = {
30
+ view: PostgresView<View>;
28
31
  uniqueIndex: PostgresIndex;
29
32
  };
33
+ type RefreshedViewCall = <const N extends string, const S extends PostgresSchema | string = "public">(props: RefreshedViewProps & {
34
+ name: N;
35
+ schema?: S;
36
+ }) => Instance<RefreshedViewMembers<PostgresMemberName<S, N>>>;
30
37
  /** A materialized view over a source, with the unique index that allows REFRESH ... CONCURRENTLY. */
31
- export declare const RefreshedView: import("@intentius/chant").CompositeDefinition<RefreshedViewProps, RefreshedViewMembers>;
38
+ export declare const RefreshedView: TypedComposite<RefreshedViewProps, RefreshedViewMembers<string>, RefreshedViewCall>;
39
+ export {};
32
40
  //# sourceMappingURL=refreshed-view.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"refreshed-view.d.ts","sourceRoot":"","sources":["../../src/composites/refreshed-view.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAe,KAAK,aAAa,EAAE,KAAK,gBAAgB,EAAE,KAAK,cAAc,EAAE,KAAK,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEtI,MAAM,WAAW,kBAAkB;IACjC,+DAA+D;IAC/D,IAAI,EAAE,MAAM,CAAC;IACb,gFAAgF;IAChF,MAAM,CAAC,EAAE,cAAc,GAAG,MAAM,CAAC;IACjC,oEAAoE;IACpE,MAAM,EAAE,gBAAgB,CAAC;IACzB,wGAAwG;IACxG,MAAM,EAAE,MAAM,CAAC;IACf,kCAAkC;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,sGAAsG;IACtG,QAAQ,CAAC,EAAE,MAAM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A;CAAE,KAChD,QAAQ,CAAC,oBAAoB,CAAC,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AAE9D,qGAAqG;AACrG,eAAO,MAAM,aAAa,qFAUP,CAAC"}
@@ -12,6 +12,8 @@
12
12
  * the parameter that produced the field when the composite is interpreted.
13
13
  */
14
14
  import { type ClickHouseTable } from "../clickhouse/entities.js";
15
+ import type { ClickHouseMemberName } from "../core/typed.js";
16
+ import type { Instance, TypedComposite } from "./typed.js";
15
17
  export interface ReplacingTableProps {
16
18
  /** The table's name, `name` or `database.name`. */
17
19
  name: string;
@@ -26,9 +28,14 @@ export interface ReplacingTableProps {
26
28
  /** A `PARTITION BY` expression. Left out by default: a deduplicating table is usually small enough not to need one. */
27
29
  partitionBy?: string;
28
30
  }
29
- export type ReplacingTableMembers = {
30
- table: ClickHouseTable;
31
+ /** `Table` is the table's name, when the call's props give it (chant#3787). */
32
+ export type ReplacingTableMembers<Table extends string = string> = {
33
+ table: ClickHouseTable<Table>;
31
34
  };
35
+ type ReplacingTableCall = <const N extends string>(props: ReplacingTableProps & {
36
+ name: N;
37
+ }) => Instance<ReplacingTableMembers<ClickHouseMemberName<N>>>;
32
38
  /** A ReplacingMergeTree table that keeps the highest version of each row, with its version column. */
33
- export declare const ReplacingTable: import("@intentius/chant").CompositeDefinition<ReplacingTableProps, ReplacingTableMembers>;
39
+ export declare const ReplacingTable: TypedComposite<ReplacingTableProps, ReplacingTableMembers<string>, ReplacingTableCall>;
40
+ export {};
34
41
  //# sourceMappingURL=replacing-table.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"replacing-table.d.ts","sourceRoot":"","sources":["../../src/composites/replacing-table.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAS,KAAK,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAErE,MAAM,WAAW,mBAAmB;IAClC,mDAAmD;IACnD,IAAI,EAAE,MAAM,CAAC;IACb,iFAA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C,CAAA;CAAE,KAAK,QAAQ,CAAC,qBAAqB,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAEzJ,sGAAsG;AACtG,eAAO,MAAM,cAAc,wFAWP,CAAC"}
@@ -12,6 +12,8 @@
12
12
  * its target, and the build orders all three.
13
13
  */
14
14
  import { type ClickHouseRelation, type ClickHouseTable, type ClickHouseView } from "../clickhouse/entities.js";
15
+ import type { ClickHouseMemberName } from "../core/typed.js";
16
+ import type { Instance, TypedComposite } from "./typed.js";
15
17
  export interface RollupViewProps {
16
18
  /** The target table's name. The view is `<name>_mv`. */
17
19
  name: string;
@@ -30,10 +32,15 @@ export interface RollupViewProps {
30
32
  /** The target's partition key. Left out by default. */
31
33
  partitionBy?: string;
32
34
  }
33
- export type RollupViewMembers = {
34
- table: ClickHouseTable;
35
- view: ClickHouseView;
35
+ /** `Table` and `View` are the target table's and the view's names, when the call's props give them (chant#3787). */
36
+ export type RollupViewMembers<Table extends string = string, View extends string = string> = {
37
+ table: ClickHouseTable<Table>;
38
+ view: ClickHouseView<View>;
36
39
  };
40
+ type RollupViewCall = <const N extends string>(props: RollupViewProps & {
41
+ name: N;
42
+ }) => Instance<RollupViewMembers<ClickHouseMemberName<N>, ClickHouseMemberName<N, "_mv">>>;
37
43
  /** A materialized view that rolls a source table up into a target table it declares beside it. */
38
- export declare const RollupView: import("@intentius/chant").CompositeDefinition<RollupViewProps, RollupViewMembers>;
44
+ export declare const RollupView: TypedComposite<RollupViewProps, RollupViewMembers<string, string>, RollupViewCall>;
45
+ export {};
39
46
  //# sourceMappingURL=rollup-view.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"rollup-view.d.ts","sourceRoot":"","sources":["../../src/composites/rollup-view.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAe,KAAK,kBAAkB,EAAE,KAAK,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAEzH,MAAM,WAA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DAAuD;IACvD,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,oHAAoH;AACpH,MAAM,MAAM,iBAAiB,CAAC,KAAK,SAAS,MAAM,GAAG,MAAM,EAAE,IAAI,SAAS,MAAM,GAAG,MAAM,IAAI;IAC3F,KAAK,EAAE,eAAe,CAAC,KAAK,CAAC,CAAC;IAC9B,IAAI,EAAE,cAAc,CAAC,IAAI,CAAC,CAAC;CAC5B,CAAC;AAEF,KAAK,cAAc,GAAG,CAAC,KAAK,CAAC,CAAC,SAAS,MAAM,EAC3C,KAAK,EAAE,eAAe,GAAG;IAAE,IAAI,EAAE,CAAC,CAAA;CAAE,KACjC,QAAQ,CAAC,iBAAiB,CAAC,oBAAoB,CAAC,CAAC,CAAC,EAAE,oBAAoB,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;AAE1F,kGAAkG;AAClG,eAAO,MAAM,UAAU,oFAYP,CAAC"}
@@ -12,6 +12,8 @@
12
12
  * engine names its table in the current database.
13
13
  */
14
14
  import { type ClickHouseTable } from "../clickhouse/entities.js";
15
+ import type { ClickHouseMemberName } from "../core/typed.js";
16
+ import type { Instance, TypedComposite } from "./typed.js";
15
17
  export interface ShardedTableProps {
16
18
  /** The Distributed table's name, unqualified. The local table is `<name>_local`. */
17
19
  name: string;
@@ -26,10 +28,15 @@ export interface ShardedTableProps {
26
28
  /** The local table's partition key. Left out by default. */
27
29
  partitionBy?: string;
28
30
  }
29
- export type ShardedTableMembers = {
30
- local: ClickHouseTable;
31
- distributed: ClickHouseTable;
31
+ /** `Local` and `Distributed` are the two tables' names, when the call's props give them (chant#3787). */
32
+ export type ShardedTableMembers<Local extends string = string, Distributed extends string = string> = {
33
+ local: ClickHouseTable<Local>;
34
+ distributed: ClickHouseTable<Distributed>;
32
35
  };
36
+ type ShardedTableCall = <const N extends string>(props: ShardedTableProps & {
37
+ name: N;
38
+ }) => Instance<ShardedTableMembers<ClickHouseMemberName<N, "_local">, ClickHouseMemberName<N>>>;
33
39
  /** A ReplicatedMergeTree table on every node of a cluster and the Distributed table over it. */
34
- export declare const ShardedTable: import("@intentius/chant").CompositeDefinition<ShardedTableProps, ShardedTableMembers>;
40
+ export declare const ShardedTable: TypedComposite<ShardedTableProps, ShardedTableMembers<string, string>, ShardedTableCall>;
41
+ export {};
35
42
  //# sourceMappingURL=sharded-table.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sharded-table.d.ts","sourceRoot":"","sources":["../../src/composites/sharded-table.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAS,KAAK,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAErE,MAAM,WAAW,iBAAiB;IAChC,oFAAoF;IACpF,IAAI,EAAE,MAAM,CAAC;IACb,yFAAyF;IACzF,OAAO,EAAE,MAAM,CAAC;IAChB,8DAA8D;IAC9D,OAAO,EAAE,MAAM,CAAC;IAChB,kCAAkC;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,gFAAgF;IAChF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,4DAA4D;IAC5D,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,KAAK,EAAE,eAAe,CAAC;IACvB,WAAW,EAAE,eAAe,CAAC;CAC9B,CAAC;AAEF,gGAAgG;AAChG,eAAO,MAAM,YAAY,wFAUP,CAAC"}
1
+ {"version":3,"file":"sharded-table.d.ts","sourceRoot":"","sources":["../../src/composites/sharded-table.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAS,KAAK,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAExD,MAAM,WAAW,iBAAiB;IAChC,oFAAoF;IACpF,IAAI,EAAE,MAAM,CAAC;IACb,yFAAyF;IACzF,OAAO,EAAE,MAAM,CAAC;IAChB,8DAA8D;IAC9D,OAAO,EAAE,MAAM,CAAC;IAChB,kCAAkC;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,gFAAgF;IAChF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,4DAA4D;IAC5D,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,yGAAyG;AACzG,MAAM,MAAM,mBAAmB,CAAC,KAAK,SAAS,MAAM,GAAG,MAAM,EAAE,WAAW,SAAS,MAAM,GAAG,MAAM,IAAI;IACpG,KAAK,EAAE,eAAe,CAAC,KAAK,CAAC,CAAC;IAC9B,WAAW,EAAE,eAAe,CAAC,WAAW,CAAC,CAAC;CAC3C,CAAC;AAEF,KAAK,gBAAgB,GAAG,CAAC,KAAK,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,iBAAiB,GAAG;IAAE,IAAI,EAAE,CAAC,CAAA;CAAE,KAAK,QAAQ,CAAC,mBAAmB,CAAC,oBAAoB,CAAC,CAAC,EAAE,QAAQ,CAAC,EAAE,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAEtL,gGAAgG;AAChG,eAAO,MAAM,YAAY,0FAUP,CAAC"}
@@ -12,6 +12,8 @@
12
12
  * trigger it owns, sets `updated_at`.
13
13
  */
14
14
  import { type PostgresIndex, type PostgresSchema, type PostgresTable, type PostgresView } from "../postgres/entities.js";
15
+ import type { PostgresMemberName } from "../core/typed.js";
16
+ import type { Instance, TypedComposite } from "./typed.js";
15
17
  export interface SoftDeleteTableProps {
16
18
  /** The table's name, unqualified. The view is `<name>_live`. */
17
19
  name: string;
@@ -30,11 +32,17 @@ export interface SoftDeleteTableProps {
30
32
  /** The deletion timestamp column (default `deleted_at`). Null means the row is live. */
31
33
  deletedAt?: string;
32
34
  }
33
- export type SoftDeleteTableMembers = {
34
- table: PostgresTable;
35
- live: PostgresView;
35
+ /** `Table` and `Live` are the table's and the view's qualified names, when the call's props give them (chant#3787). */
36
+ export type SoftDeleteTableMembers<Table extends string = string, Live extends string = string> = {
37
+ table: PostgresTable<Table>;
38
+ live: PostgresView<Live>;
36
39
  liveIndex: PostgresIndex;
37
40
  };
41
+ type SoftDeleteTableCall = <const N extends string, const S extends PostgresSchema | string = "public">(props: SoftDeleteTableProps & {
42
+ name: N;
43
+ schema?: S;
44
+ }) => Instance<SoftDeleteTableMembers<PostgresMemberName<S, N>, PostgresMemberName<S, N, "_live">>>;
38
45
  /** A table with created and updated timestamps and a soft-delete column, a view of its live rows and an index over them. */
39
- export declare const SoftDeleteTable: import("@intentius/chant").CompositeDefinition<SoftDeleteTableProps, SoftDeleteTableMembers>;
46
+ export declare const SoftDeleteTable: TypedComposite<SoftDeleteTableProps, SoftDeleteTableMembers<string, string>, SoftDeleteTableCall>;
47
+ export {};
40
48
  //# sourceMappingURL=soft-delete-table.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"soft-delete-table.d.ts","sourceRoot":"","sources":["../../src/composites/soft-delete-table.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAA+B,KAAK,aAAa,EAAE,KAAK,cAAc,EAAE,KAAK,aAAa,EAAE,KAAK,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEnJ,MAAM,WAAW,oBAAoB;IACnC,gEAAgE;IAChE,IAAI,EAAE,MAAM,CAAC;IACb,wGAAwG;IACxG,MAAM,CAAC,EAAE,cAAc,GAAG,MAAM,CAAC;IACjC,iKAAiK;IACjK,OAAO,EAAE,MAAM,CAAC;IAChB,sGAAsG;IACtG,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,6GAA6G;IAC7G,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,4DAA4D;IAC5D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0DAA0D;IAC1D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wFAAwF;IACxF,SAAS,CAAC,EAAE,MAAM,C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;CAC1B,CAAC;AAEF,KAAK,mBAAmB,GAAG,CAAC,KAAK,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,CAAC,CAAC,SAAS,cAAc,GAAG,MAAM,GAAG,QAAQ,EACpG,KAAK,EAAE,oBAAoB,GAAG;IAAE,IAAI,EAAE,CAAC,CAAC;IAAC,MAAM,CAAC,EAAE,CAAC,CAAA;CAAE,KAClD,QAAQ,CAAC,sBAAsB,CAAC,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,kBAAkB,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;AAEnG,4HAA4H;AAC5H,eAAO,MAAM,eAAe,mGAiBP,CAAC"}
@@ -9,6 +9,8 @@
9
9
  * policy on the table is what keeps one tenant's role out of another's rows.
10
10
  */
11
11
  import { type PostgresIndex, type PostgresSchema, type PostgresTable } from "../postgres/entities.js";
12
+ import type { PostgresMemberName } from "../core/typed.js";
13
+ import type { Instance, TypedComposite } from "./typed.js";
12
14
  export interface TenantTableProps {
13
15
  /** The table's name, unqualified. The index is `<name>_tenant_idx`. */
14
16
  name: string;
@@ -25,10 +27,16 @@ export interface TenantTableProps {
25
27
  /** The tenant column's type (default `uuid`). */
26
28
  tenantType?: string;
27
29
  }
28
- export type TenantTableMembers = {
29
- table: PostgresTable;
30
+ /** `Table` is the table's qualified name, when the call's props give it (chant#3787). */
31
+ export type TenantTableMembers<Table extends string = string> = {
32
+ table: PostgresTable<Table>;
30
33
  index: PostgresIndex;
31
34
  };
35
+ type TenantTableCall = <const N extends string, const S extends PostgresSchema | string = "public">(props: TenantTableProps & {
36
+ name: N;
37
+ schema?: S;
38
+ }) => Instance<TenantTableMembers<PostgresMemberName<S, N>>>;
32
39
  /** A multi-tenant table with the tenant key first in its primary key and its index. */
33
- export declare const TenantTable: import("@intentius/chant").CompositeDefinition<TenantTableProps, TenantTableMembers>;
40
+ export declare const TenantTable: TypedComposite<TenantTableProps, TenantTableMembers<string>, TenantTableCall>;
41
+ export {};
34
42
  //# sourceMappingURL=tenant-table.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tenant-table.d.ts","sourceRoot":"","sources":["../../src/composites/tenant-table.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAgB,KAAK,aAAa,EAAE,KAAK,cAAc,EAAE,KAAK,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAEjH,MAAM,WAAW,gBAAgB;IAC/B,uEAAuE;IACvE,IAAI,EAAE,MAAM,CAAC;IACb,iFAAiF;IACjF,MAAM,CAAC,EAAE,cAAc,GAAG,MAAM,CAAC;IACjC,+GAA+G;IAC/G,OAAO,EAAE,MAAM,CAAC;IAChB,mEAAmE;IACnE,UAAU,EAAE,MAAM,CAAC;IACnB,kFAAkF;IAClF,OAAO,EAAE,MAAM,CAAC;IAChB,+CAA+C;IAC/C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iDAAiD;IACjD,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,aAAa,CAAC;IACrB,KAAK,EAAE,aAAa,CAAC;CACtB,CAAC;AAEF,uFAAuF;AACvF,eAAO,MAAM,WAAW,sFAYP,CAAC"}
1
+ {"version":3,"file":"tenant-table.d.ts","sourceRoot":"","sources":["../../src/composites/tenant-table.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAgB,KAAK,aAAa,EAAE,KAAK,cAAc,EAAE,KAAK,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACjH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAExD,MAAM,WAAW,gBAAgB;IAC/B,uEAAuE;IACvE,IAAI,EAAE,MAAM,CAAC;IACb,iFAAiF;IACjF,MAAM,CAAC,EAAE,cAAc,GAAG,MAAM,CAAC;IACjC,+GAA+G;IAC/G,OAAO,EAAE,MAAM,CAAC;IAChB,mEAAmE;IACnE,UAAU,EAAE,MAAM,CAAC;IACnB,kFAAkF;IAClF,OAAO,EAAE,MAAM,CAAC;IAChB,+CAA+C;IAC/C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iDAAiD;IACjD,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,yFAAyF;AACzF,MAAM,MAAM,kBAAkB,CAAC,KAAK,SAAS,MAAM,GAAG,MAAM,IAAI;IAC9D,KAAK,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC;IAC5B,KAAK,EAAE,aAAa,CAAC;CACtB,CAAC;AAEF,KAAK,eAAe,GAAG,CAAC,KAAK,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,CAAC,CAAC,SAAS,cAAc,GAAG,MAAM,GAAG,QAAQ,EAChG,KAAK,EAAE,gBAAgB,GAAG;IAAE,IAAI,EAAE,CAAC,CAAC;IAAC,MAAM,CAAC,EAAE,CAAC,CAAA;CAAE,KAC9C,QAAQ,CAAC,kBAAkB,CAAC,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AAE5D,uFAAuF;AACvF,eAAO,MAAM,WAAW,+EAYP,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * chant#3787 — the call signature a composite is typed with, so a member's
3
+ * `.columns` are the generated `SqlSchema` entry for the name its props give
4
+ * it. `users.table.columns.emial` then fails tsc as `table<"app.users">`'s
5
+ * would. The definition is unchanged at run time: `Composite`'s third type
6
+ * argument carries this signature in front of the plain one.
7
+ */
8
+ import type { CompositeDefinition, CompositeFactoryMembers, CompositeInstance } from "@intentius/chant/composite";
9
+ /** What a typed composite call returns: the instance, with its members' types. */
10
+ export type Instance<M extends CompositeFactoryMembers> = CompositeInstance<M> & M;
11
+ /** A composite definition whose precise, generic `Call` signature is tried before the plain `(props: P) => M`. */
12
+ export type TypedComposite<P, M extends CompositeFactoryMembers, Call> = Call & CompositeDefinition<P, M>;
13
+ //# sourceMappingURL=typed.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typed.d.ts","sourceRoot":"","sources":["../../src/composites/typed.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAElH,kFAAkF;AAClF,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,uBAAuB,IAAI,iBAAiB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;AAEnF,kHAAkH;AAClH,MAAM,MAAM,cAAc,CAAC,CAAC,EAAE,CAAC,SAAS,uBAAuB,EAAE,IAAI,IAAI,IAAI,GAAG,mBAAmB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC"}
@@ -100,6 +100,28 @@ type RowFromColumns<C> = {
100
100
  };
101
101
  /** A relation's row: `T` is its name or a relation's type carrying one. */
102
102
  export type RowIn<Registry, T> = T extends string ? RowFromColumns<ColumnsIn<Registry, T>> : T extends Named<infer N> ? RowFromColumns<ColumnsIn<Registry, N>> : never;
103
+ /** Whether `S` is a name the type system knows: a literal, not `string` and not {@link Unnamed}. */
104
+ type Known<S> = [S] extends [Unnamed] ? false : string extends S ? false : true;
105
+ /** A piece of a name a composite's props give: the literal, the name a {@link Named} entity carries, or {@link Unnamed}. */
106
+ type NamePiece<V> = [V] extends [string] ? Known<V> extends true ? V : Unnamed : [V] extends [Named<infer N>] ? (Known<N> extends true ? N : Unnamed) : Unnamed;
107
+ /**
108
+ * chant#3787 — the qualified name of a relation a Postgres composite declares
109
+ * as `${schema}.${name}${suffix}`: `schema` is the composite's `schema` prop (a
110
+ * string, or a schema whose tag was given its name, `schema<"app">`), `name`
111
+ * its `name` prop. Postgres folds both, as the build does. {@link Unnamed},
112
+ * so the columns stay unchecked, when either piece is not a known literal.
113
+ */
114
+ export type PostgresMemberName<Schema, Name, Suffix extends string = ""> = [NamePiece<Schema>, NamePiece<Name>] extends [
115
+ infer S extends string,
116
+ infer N extends string
117
+ ] ? Known<S> extends true ? Known<N> extends true ? `${Lowercase<S>}.${Lowercase<N>}${Suffix}` : Unnamed : Unnamed : Unnamed;
118
+ /**
119
+ * chant#3787 — the name of a relation a ClickHouse composite declares,
120
+ * `${name}${suffix}`, where `name` is its `name` prop as written (`events` or
121
+ * `analytics.events`). ClickHouse does not fold names. {@link Unnamed} when
122
+ * the name is not a known literal.
123
+ */
124
+ export type ClickHouseMemberName<Name, Suffix extends string = ""> = NamePiece<Name> extends infer N extends string ? Known<N> extends true ? `${N}${Suffix}` : Unnamed : Unnamed;
103
125
  /**
104
126
  * One `${}` the generator types. `references`: a column in a foreign key's
105
127
  * referenced column list, paired with `column`, the referencing table's own