clivly 0.9.6 → 0.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 (146) hide show
  1. package/README.md +24 -12
  2. package/{adapter-C2eRbBfo.d.cts → adapter-1TN0zohk.d.cts} +1 -1
  3. package/{adapter-D5LRa-NA.d.mts → adapter-uxirB88i.d.mts} +1 -1
  4. package/{auth-adapter-Bjgo8LhN.d.mts → auth-adapter-CXTiW3Mb.d.cts} +1 -1
  5. package/{auth-adapter-DWzgl5Yq.d.cts → auth-adapter-DSuYwv1c.d.mts} +1 -1
  6. package/auth-better-auth.d.cts +1 -1
  7. package/auth-better-auth.d.mts +1 -1
  8. package/auth-clerk.d.cts +1 -1
  9. package/auth-clerk.d.mts +1 -1
  10. package/auth-workos.d.cts +1 -1
  11. package/auth-workos.d.mts +1 -1
  12. package/core-adapter.d.cts +1 -1
  13. package/core-adapter.d.mts +1 -1
  14. package/core-auth-adapter.cjs +1 -1
  15. package/core-auth-adapter.d.cts +1 -1
  16. package/core-auth-adapter.d.mts +1 -1
  17. package/core-auth-adapter.mjs +1 -1
  18. package/core-drizzle.cjs +1 -1
  19. package/core-drizzle.d.cts +1 -1
  20. package/core-drizzle.d.mts +1 -1
  21. package/core-drizzle.mjs +1 -1
  22. package/core-entity-config.cjs +1 -1
  23. package/core-entity-config.d.cts +1 -1
  24. package/core-entity-config.d.mts +1 -1
  25. package/core-entity-config.mjs +1 -1
  26. package/core-entity-heuristics.cjs +1 -0
  27. package/core-entity-heuristics.d.cts +3 -3
  28. package/core-entity-heuristics.d.mts +3 -3
  29. package/core-entity-heuristics.mjs +2 -2
  30. package/core-mapping-form.cjs +1 -1
  31. package/core-mapping-form.d.cts +1 -1
  32. package/core-mapping-form.d.mts +1 -1
  33. package/core-mapping-form.mjs +1 -1
  34. package/core-mappings-config.cjs +1 -1
  35. package/core-mappings-config.d.cts +1 -1
  36. package/core-mappings-config.d.mts +1 -1
  37. package/core-mappings-config.mjs +1 -1
  38. package/core-sync-engine.cjs +1 -1
  39. package/core-sync-engine.d.cts +1 -1
  40. package/core-sync-engine.d.mts +1 -1
  41. package/core-sync-engine.mjs +1 -1
  42. package/core-types.cjs +4 -0
  43. package/core-types.d.cts +2 -2
  44. package/core-types.d.mts +2 -2
  45. package/core-types.mjs +2 -1
  46. package/core-view-compiler.cjs +1 -1
  47. package/core-view-compiler.d.cts +1 -1
  48. package/core-view-compiler.d.mts +1 -1
  49. package/core-view-compiler.mjs +1 -1
  50. package/core.cjs +18 -17
  51. package/core.d.cts +10 -10
  52. package/core.d.mts +10 -10
  53. package/core.mjs +10 -9
  54. package/{drizzle-DEtRrqtc.d.cts → drizzle-DTOuGXEn.d.cts} +4 -2
  55. package/{drizzle-bfjVzYR6.cjs → drizzle-DcB7OfBp.cjs} +9 -1
  56. package/{drizzle-CiK8MMEZ.d.mts → drizzle-SGapoly2.d.mts} +4 -2
  57. package/{drizzle-3kvhkwO7.mjs → drizzle-wbcuG-cy.mjs} +9 -1
  58. package/drizzle.cjs +58 -24
  59. package/drizzle.d.cts +10 -4
  60. package/drizzle.d.mts +10 -4
  61. package/drizzle.mjs +58 -24
  62. package/{entity-config-CusbTOJ1.mjs → entity-config-C4d3K9CP.mjs} +114 -8
  63. package/{entity-config-B2RA53nw.d.cts → entity-config-DNQAMbMS.d.cts} +27 -1
  64. package/{entity-config-B2RA53nw.d.mts → entity-config-DNQAMbMS.d.mts} +27 -1
  65. package/{entity-config-DE30_RpU.cjs → entity-config-DgAe0_YD.cjs} +119 -7
  66. package/index.cjs +56 -15
  67. package/index.mjs +56 -15
  68. package/internal-BAOG5eE4.d.mts +226 -0
  69. package/internal-BHJ0X3fC.d.cts +226 -0
  70. package/internal-Bgiimp5D.mjs +144 -0
  71. package/internal-Cz59xMj8.cjs +167 -0
  72. package/internal-adapter.d.cts +1 -1
  73. package/internal-adapter.d.mts +1 -1
  74. package/internal-auth-adapter.d.cts +1 -1
  75. package/internal-auth-adapter.d.mts +1 -1
  76. package/internal-drizzle.cjs +1 -1
  77. package/internal-drizzle.d.cts +1 -1
  78. package/internal-drizzle.d.mts +1 -1
  79. package/internal-drizzle.mjs +1 -1
  80. package/internal-entity-config.cjs +1 -1
  81. package/internal-entity-config.d.cts +1 -1
  82. package/internal-entity-config.d.mts +1 -1
  83. package/internal-entity-config.mjs +1 -1
  84. package/internal-entity-heuristics.cjs +34 -1
  85. package/internal-entity-heuristics.d.cts +8 -2
  86. package/internal-entity-heuristics.d.mts +8 -2
  87. package/internal-entity-heuristics.mjs +34 -2
  88. package/internal-mapping-form.d.cts +1 -1
  89. package/internal-mapping-form.d.mts +1 -1
  90. package/internal-mappings-config.cjs +1 -1
  91. package/internal-mappings-config.d.cts +1 -1
  92. package/internal-mappings-config.d.mts +1 -1
  93. package/internal-mappings-config.mjs +1 -1
  94. package/internal-sync-engine.cjs +1 -1
  95. package/internal-sync-engine.d.cts +1 -1
  96. package/internal-sync-engine.d.mts +1 -1
  97. package/internal-sync-engine.mjs +1 -1
  98. package/internal-types.cjs +4 -0
  99. package/internal-types.d.cts +2 -2
  100. package/internal-types.d.mts +2 -2
  101. package/internal-types.mjs +2 -1
  102. package/internal-view-compiler.cjs +1 -1
  103. package/internal-view-compiler.d.cts +1 -1
  104. package/internal-view-compiler.d.mts +1 -1
  105. package/internal-view-compiler.mjs +1 -1
  106. package/internal.cjs +17 -15
  107. package/internal.d.cts +10 -10
  108. package/internal.d.mts +10 -10
  109. package/internal.mjs +9 -8
  110. package/{mapping-form-DH77BXLv.d.mts → mapping-form-Cc7Ewv8c.d.mts} +1 -1
  111. package/{mapping-form-J0aU6O7l.d.cts → mapping-form-DwdbYAfR.d.cts} +1 -1
  112. package/{mappings-config-D9dsonoi.d.mts → mappings-config-Be9D43Np.d.mts} +1 -1
  113. package/{mappings-config-RQLGx8ub.d.cts → mappings-config-DUt4-9iO.d.cts} +1 -1
  114. package/{mappings-config-CjCmT-aU.cjs → mappings-config-Dx9ldgdf.cjs} +2 -16
  115. package/{mappings-config-7qQ47p9K.mjs → mappings-config-MoXBeI8p.mjs} +1 -15
  116. package/{namespace-probe-Ckn9yJ6F.d.mts → namespace-probe-9ScMDR0t.d.mts} +42 -2
  117. package/{namespace-probe-DaTJINS-.d.cts → namespace-probe-DC4tbmLj.d.cts} +42 -2
  118. package/package.json +1 -1
  119. package/{projection-hnPSgH6G.mjs → projection-CSGJbZlZ.mjs} +1 -1
  120. package/{projection-DEwL-D8R.cjs → projection-Dz6_i1-w.cjs} +0 -6
  121. package/{projection-sql-iHy-Cx6V.cjs → projection-sql-CbXCKt3s.cjs} +1 -1
  122. package/{projection-sql-9zzTVGvf.mjs → projection-sql-iHoiYr1R.mjs} +1 -1
  123. package/{sdk-w8Kv_XnW.cjs → sdk-B1vX4kUJ.cjs} +347 -17
  124. package/{sdk-Dkq6ELkf.mjs → sdk-D6gX0TXS.mjs} +347 -17
  125. package/sdk.cjs +2 -2
  126. package/sdk.d.cts +3 -3
  127. package/sdk.d.mts +3 -3
  128. package/sdk.mjs +2 -2
  129. package/{sync-engine-BLgwLpR6.cjs → sync-engine-B0FT1ax6.cjs} +1 -1
  130. package/{sync-engine-B_IzoUSx.mjs → sync-engine-CTSIcLlZ.mjs} +1 -1
  131. package/{sync-engine-BG2O1an2.d.cts → sync-engine-Df0kHAoJ.d.cts} +2 -2
  132. package/{sync-engine-DgQbrJON.d.mts → sync-engine-ugFacJ6G.d.mts} +2 -2
  133. package/{types-B1oRXdNP.d.cts → types-Cq1uHUKp.d.cts} +28 -2
  134. package/{types-B1oRXdNP.d.mts → types-Cq1uHUKp.d.mts} +28 -2
  135. package/types-Cq5gHCTq.cjs +20 -0
  136. package/types-YJTkXKzU.mjs +9 -0
  137. package/{view-compiler-D_6gfXFr.mjs → view-compiler-BzKk8nY3.mjs} +2 -2
  138. package/{view-compiler-CmEdAMwj.d.cts → view-compiler-D3zp9S3K.d.cts} +1 -1
  139. package/{view-compiler-Bo7pqXW3.d.mts → view-compiler-TpzDTu7z.d.mts} +1 -1
  140. package/{view-compiler-BHI5E4QI.cjs → view-compiler-ZKZbd3SK.cjs} +2 -2
  141. package/vite.d.cts +1 -1
  142. package/vite.d.mts +1 -1
  143. package/internal-BQ47iN6f.cjs +0 -259
  144. package/internal-ChufvXE6.mjs +0 -212
  145. package/internal-CvlFk3KC.d.mts +0 -180
  146. package/internal-DGUOLQAq.d.cts +0 -180
@@ -1,180 +0,0 @@
1
- import { M as ProjectionIdentity, N as ProjectionJoin, P as ProjectionMapping, j as ProjectionFieldBinding, l as ConfigValidationError, m as DiscoveredSchemaTable, p as DiscoveredColumnMeta } from "./entity-config-B2RA53nw.mjs";
2
- //#region ../core/src/projection-cardinality.d.ts
3
- declare function joinFansOut(join: ProjectionJoin, joinTable: DiscoveredSchemaTable): boolean;
4
- /** Every join in the projection that can multiply rows. */
5
- declare function fanOutJoins(projection: ProjectionMapping, tablesByName: Map<string, DiscoveredSchemaTable>): ProjectionJoin[];
6
- //#endregion
7
- //#region ../core/src/projection-draft.d.ts
8
- /**
9
- * The builder's in-progress shape.
10
- *
11
- * A draft is deliberately looser than a `ProjectionMapping`: it exists while
12
- * the user is still choosing things, so every field can be empty. All of the
13
- * builder's rules live here as pure functions, which keeps the React components
14
- * presentational and lets the rules be tested without a DOM.
15
- */
16
- interface ProjectionDraft {
17
- baseTable: string;
18
- entityKey: string;
19
- fieldBindings: Record<string, ProjectionFieldBinding>;
20
- identity: ProjectionIdentity;
21
- joins: ProjectionJoin[];
22
- }
23
- declare function emptyProjectionDraft(baseTable: string): ProjectionDraft;
24
- /**
25
- * The ON conditions implied by a foreign key between the two tables, so the
26
- * builder can pre-fill a join instead of making the user hand-pick columns.
27
- * Returns [] when no FK relates them — the user then picks manually.
28
- */
29
- declare function suggestJoinConditions(baseTable: string, joinTable: string, schema: DiscoveredSchemaTable[], joinKey: string): ProjectionJoin["on"];
30
- /**
31
- * Add a join on `joinTable`, keyed and pre-filled.
32
- *
33
- * The key is the table's own name where that is free, because it is what the
34
- * user already calls the table; a collision falls back to `_2`, `_3` and so on.
35
- * Uniqueness is not cosmetic — the key is the SQL alias and the name every ref
36
- * addresses the table by, so two joins sharing one would make every ref
37
- * ambiguous. `base` is reserved for the base table and can never be taken.
38
- */
39
- declare function addDraftJoin(draft: ProjectionDraft, joinTable: string, schema: DiscoveredSchemaTable[]): ProjectionDraft;
40
- /**
41
- * Remove a join, and everything that addressed it.
42
- *
43
- * Refs to a removed join are refs to a table the projection no longer declares.
44
- * Left in place they fail validation as "unknown ref table", which blames the
45
- * field — or, worse, the identity — for the join's removal. Identity falls back
46
- * to the base primary key, the same default a new draft starts from.
47
- */
48
- declare function removeDraftJoin(draft: ProjectionDraft, joinKey: string): ProjectionDraft;
49
- /** One selectable table in the builder's column pickers. */
50
- interface DraftRefOption {
51
- columns: string[];
52
- label: string;
53
- ref: string;
54
- }
55
- /**
56
- * Every table a field or identity may currently read from, in ref order: the
57
- * base table first, then each join.
58
- *
59
- * Returns [] when the base table is not in the discovered schema — there is
60
- * nothing truthful to offer, and inventing columns would let someone build a
61
- * projection that cannot compile.
62
- */
63
- declare function draftRefOptions(draft: ProjectionDraft, schema: DiscoveredSchemaTable[]): DraftRefOption[];
64
- /** A draft becomes a projection once it has a valid key and ≥1 binding. */
65
- declare function draftToProjection(draft: ProjectionDraft): ProjectionMapping | null;
66
- /**
67
- * Every reason this draft cannot be saved, one per cause and each anchored to
68
- * the section that owns it.
69
- *
70
- * One lumped "Name the object and map a field." was all this used to return for
71
- * an incomplete draft, at the bare path "projection". Two consequences, both
72
- * bad: a builder had nowhere to attach the message, and — because it returned
73
- * before validating — a fanning join under a `base_pk` identity stayed silent
74
- * until the draft was otherwise complete, which is well after the point where
75
- * the user chose the join.
76
- */
77
- declare function draftErrors(draft: ProjectionDraft, schema: DiscoveredSchemaTable[]): ConfigValidationError[];
78
- /**
79
- * Per-join fan-out, for the builder's inline cardinality hints.
80
- *
81
- * Answered from the joins alone. Joins are chosen before the key and the fields
82
- * are filled in, and a fan-out warning is precisely what should steer the
83
- * identity choice while it is being made — requiring a complete draft put the
84
- * hint after the decision it exists to inform.
85
- */
86
- declare function describeCardinality(draft: ProjectionDraft, schema: DiscoveredSchemaTable[]): Array<{
87
- fansOut: boolean;
88
- joinKey: string;
89
- }>;
90
- //#endregion
91
- //#region ../core/src/projection-sql.d.ts
92
- /**
93
- * SQL generation for projection-backed entities.
94
- *
95
- * Base and joins are aliased by their ref key (`base`, then each join's `key`),
96
- * which is what allows the same table to be joined twice and keeps generated
97
- * SQL independent of host table names.
98
- *
99
- * Pure string generation — no DB access. Identifiers are escaped so output is
100
- * deterministic and injection-safe.
101
- */
102
- /** Quote a single identifier part, escaping embedded double-quotes. */
103
- declare function quoteIdent(name: string): string;
104
- /**
105
- * The identity expression. Composite identities concatenate their parts with
106
- * `::`; validation guarantees every part is NOT NULL and non-text, which is
107
- * what makes the concatenation collision-free.
108
- *
109
- * Exported unaliased because two paths need the same expression under different
110
- * names: the view compiler aliases it `id`, and the SDK's projection push source
111
- * also orders and keyset-paginates by it. Sharing one definition is what keeps
112
- * a pushed row's `id` identical to the one the view would have produced.
113
- */
114
- declare function compileProjectionIdentity(projection: ProjectionMapping, basePkColumn: string): string;
115
- declare function compileProjectionSelect(projection: ProjectionMapping, basePkColumn: string): {
116
- columns: string[];
117
- selectItems: string[];
118
- };
119
- declare function compileProjectionJoins(projection: ProjectionMapping): string[];
120
- /** `FROM <baseTable> AS "base"` — the alias every ref resolves against. */
121
- declare function compileProjectionFrom(projection: ProjectionMapping): string;
122
- /**
123
- * Hard ceiling on preview rows, regardless of what a caller asks for.
124
- *
125
- * A preview runs against a production database from a button a user can click
126
- * as often as they like, so the cap belongs beside the query rather than in
127
- * whichever caller happens to be passing a limit today.
128
- */
129
- declare const PREVIEW_MAX_ROWS = 50;
130
- /**
131
- * One SELECT reading a few rows through an UNSAVED projection, for the derived
132
- * object builder's preview.
133
- *
134
- * Lives here, beside the view compiler, because both sides of the round trip
135
- * need the identical statement: an embedded org runs it against its own
136
- * database from `@clivly.com/api`, and a cloud org's host app runs it from
137
- * `@clivly/sdk`. Two copies would be free to disagree about what the user is
138
- * being shown, which is the whole value of a preview.
139
- *
140
- * Columns are aliased by FIELD NAME, not by ref token. That is the deliberate
141
- * difference from the push source, which aliases by token because cloud ingest
142
- * reads `row[token]`; a preview is read by a person, in a table whose headers
143
- * are the field names they just typed.
144
- */
145
- declare function compileProjectionPreview(projection: ProjectionMapping, limit: number): string;
146
- //#endregion
147
- //#region ../core/src/projection-validate.d.ts
148
- /**
149
- * Validate a projection against the discovered schema. Returns every error
150
- * found (not just the first) so a builder UI can show them all at once.
151
- */
152
- declare function validateProjection(projection: ProjectionMapping, schema: DiscoveredSchemaTable[], base: string): ConfigValidationError[];
153
- //#endregion
154
- //#region ../core/src/schema-meta.d.ts
155
- /**
156
- * Accessors over a discovered table's schema-v2 metadata.
157
- *
158
- * Every helper treats *absent* metadata as **unknown**, never as a negative
159
- * fact. `coversUniqueKey` returning false on a v1 payload is what makes
160
- * projection validation fail closed: we cannot prove a join is many-to-one, so
161
- * we refuse to compile it rather than guess.
162
- */
163
- declare function columnMetaFor(table: DiscoveredSchemaTable, column: string): DiscoveredColumnMeta | undefined;
164
- /**
165
- * Every primary-key column. More than one entry means a composite PK, which is
166
- * why `base_pk` identity is rejected for such tables.
167
- */
168
- declare function primaryKeyColumns(table: DiscoveredSchemaTable): string[];
169
- /**
170
- * Do `columns` contain every column of at least one unique key on `table`?
171
- *
172
- * This is the fan-out test. A join whose ON columns cover a unique key of the
173
- * joined table matches at most one row per base row; one that does not can
174
- * match many.
175
- */
176
- declare function coversUniqueKey(table: DiscoveredSchemaTable, columns: string[]): boolean;
177
- /** Is this table's payload rich enough to validate a projection against? */
178
- declare function hasRichMeta(table: DiscoveredSchemaTable): boolean;
179
- //#endregion
180
- export { fanOutJoins as C, suggestJoinConditions as S, draftErrors as _, validateProjection as a, emptyProjectionDraft as b, compileProjectionIdentity as c, compileProjectionSelect as d, quoteIdent as f, describeCardinality as g, addDraftJoin as h, primaryKeyColumns as i, compileProjectionJoins as l, ProjectionDraft as m, coversUniqueKey as n, PREVIEW_MAX_ROWS as o, DraftRefOption as p, hasRichMeta as r, compileProjectionFrom as s, columnMetaFor as t, compileProjectionPreview as u, draftRefOptions as v, joinFansOut as w, removeDraftJoin as x, draftToProjection as y };
@@ -1,180 +0,0 @@
1
- import { M as ProjectionIdentity, N as ProjectionJoin, P as ProjectionMapping, j as ProjectionFieldBinding, l as ConfigValidationError, m as DiscoveredSchemaTable, p as DiscoveredColumnMeta } from "./entity-config-B2RA53nw.cjs";
2
- //#region ../core/src/projection-cardinality.d.ts
3
- declare function joinFansOut(join: ProjectionJoin, joinTable: DiscoveredSchemaTable): boolean;
4
- /** Every join in the projection that can multiply rows. */
5
- declare function fanOutJoins(projection: ProjectionMapping, tablesByName: Map<string, DiscoveredSchemaTable>): ProjectionJoin[];
6
- //#endregion
7
- //#region ../core/src/projection-draft.d.ts
8
- /**
9
- * The builder's in-progress shape.
10
- *
11
- * A draft is deliberately looser than a `ProjectionMapping`: it exists while
12
- * the user is still choosing things, so every field can be empty. All of the
13
- * builder's rules live here as pure functions, which keeps the React components
14
- * presentational and lets the rules be tested without a DOM.
15
- */
16
- interface ProjectionDraft {
17
- baseTable: string;
18
- entityKey: string;
19
- fieldBindings: Record<string, ProjectionFieldBinding>;
20
- identity: ProjectionIdentity;
21
- joins: ProjectionJoin[];
22
- }
23
- declare function emptyProjectionDraft(baseTable: string): ProjectionDraft;
24
- /**
25
- * The ON conditions implied by a foreign key between the two tables, so the
26
- * builder can pre-fill a join instead of making the user hand-pick columns.
27
- * Returns [] when no FK relates them — the user then picks manually.
28
- */
29
- declare function suggestJoinConditions(baseTable: string, joinTable: string, schema: DiscoveredSchemaTable[], joinKey: string): ProjectionJoin["on"];
30
- /**
31
- * Add a join on `joinTable`, keyed and pre-filled.
32
- *
33
- * The key is the table's own name where that is free, because it is what the
34
- * user already calls the table; a collision falls back to `_2`, `_3` and so on.
35
- * Uniqueness is not cosmetic — the key is the SQL alias and the name every ref
36
- * addresses the table by, so two joins sharing one would make every ref
37
- * ambiguous. `base` is reserved for the base table and can never be taken.
38
- */
39
- declare function addDraftJoin(draft: ProjectionDraft, joinTable: string, schema: DiscoveredSchemaTable[]): ProjectionDraft;
40
- /**
41
- * Remove a join, and everything that addressed it.
42
- *
43
- * Refs to a removed join are refs to a table the projection no longer declares.
44
- * Left in place they fail validation as "unknown ref table", which blames the
45
- * field — or, worse, the identity — for the join's removal. Identity falls back
46
- * to the base primary key, the same default a new draft starts from.
47
- */
48
- declare function removeDraftJoin(draft: ProjectionDraft, joinKey: string): ProjectionDraft;
49
- /** One selectable table in the builder's column pickers. */
50
- interface DraftRefOption {
51
- columns: string[];
52
- label: string;
53
- ref: string;
54
- }
55
- /**
56
- * Every table a field or identity may currently read from, in ref order: the
57
- * base table first, then each join.
58
- *
59
- * Returns [] when the base table is not in the discovered schema — there is
60
- * nothing truthful to offer, and inventing columns would let someone build a
61
- * projection that cannot compile.
62
- */
63
- declare function draftRefOptions(draft: ProjectionDraft, schema: DiscoveredSchemaTable[]): DraftRefOption[];
64
- /** A draft becomes a projection once it has a valid key and ≥1 binding. */
65
- declare function draftToProjection(draft: ProjectionDraft): ProjectionMapping | null;
66
- /**
67
- * Every reason this draft cannot be saved, one per cause and each anchored to
68
- * the section that owns it.
69
- *
70
- * One lumped "Name the object and map a field." was all this used to return for
71
- * an incomplete draft, at the bare path "projection". Two consequences, both
72
- * bad: a builder had nowhere to attach the message, and — because it returned
73
- * before validating — a fanning join under a `base_pk` identity stayed silent
74
- * until the draft was otherwise complete, which is well after the point where
75
- * the user chose the join.
76
- */
77
- declare function draftErrors(draft: ProjectionDraft, schema: DiscoveredSchemaTable[]): ConfigValidationError[];
78
- /**
79
- * Per-join fan-out, for the builder's inline cardinality hints.
80
- *
81
- * Answered from the joins alone. Joins are chosen before the key and the fields
82
- * are filled in, and a fan-out warning is precisely what should steer the
83
- * identity choice while it is being made — requiring a complete draft put the
84
- * hint after the decision it exists to inform.
85
- */
86
- declare function describeCardinality(draft: ProjectionDraft, schema: DiscoveredSchemaTable[]): Array<{
87
- fansOut: boolean;
88
- joinKey: string;
89
- }>;
90
- //#endregion
91
- //#region ../core/src/projection-sql.d.ts
92
- /**
93
- * SQL generation for projection-backed entities.
94
- *
95
- * Base and joins are aliased by their ref key (`base`, then each join's `key`),
96
- * which is what allows the same table to be joined twice and keeps generated
97
- * SQL independent of host table names.
98
- *
99
- * Pure string generation — no DB access. Identifiers are escaped so output is
100
- * deterministic and injection-safe.
101
- */
102
- /** Quote a single identifier part, escaping embedded double-quotes. */
103
- declare function quoteIdent(name: string): string;
104
- /**
105
- * The identity expression. Composite identities concatenate their parts with
106
- * `::`; validation guarantees every part is NOT NULL and non-text, which is
107
- * what makes the concatenation collision-free.
108
- *
109
- * Exported unaliased because two paths need the same expression under different
110
- * names: the view compiler aliases it `id`, and the SDK's projection push source
111
- * also orders and keyset-paginates by it. Sharing one definition is what keeps
112
- * a pushed row's `id` identical to the one the view would have produced.
113
- */
114
- declare function compileProjectionIdentity(projection: ProjectionMapping, basePkColumn: string): string;
115
- declare function compileProjectionSelect(projection: ProjectionMapping, basePkColumn: string): {
116
- columns: string[];
117
- selectItems: string[];
118
- };
119
- declare function compileProjectionJoins(projection: ProjectionMapping): string[];
120
- /** `FROM <baseTable> AS "base"` — the alias every ref resolves against. */
121
- declare function compileProjectionFrom(projection: ProjectionMapping): string;
122
- /**
123
- * Hard ceiling on preview rows, regardless of what a caller asks for.
124
- *
125
- * A preview runs against a production database from a button a user can click
126
- * as often as they like, so the cap belongs beside the query rather than in
127
- * whichever caller happens to be passing a limit today.
128
- */
129
- declare const PREVIEW_MAX_ROWS = 50;
130
- /**
131
- * One SELECT reading a few rows through an UNSAVED projection, for the derived
132
- * object builder's preview.
133
- *
134
- * Lives here, beside the view compiler, because both sides of the round trip
135
- * need the identical statement: an embedded org runs it against its own
136
- * database from `@clivly.com/api`, and a cloud org's host app runs it from
137
- * `@clivly/sdk`. Two copies would be free to disagree about what the user is
138
- * being shown, which is the whole value of a preview.
139
- *
140
- * Columns are aliased by FIELD NAME, not by ref token. That is the deliberate
141
- * difference from the push source, which aliases by token because cloud ingest
142
- * reads `row[token]`; a preview is read by a person, in a table whose headers
143
- * are the field names they just typed.
144
- */
145
- declare function compileProjectionPreview(projection: ProjectionMapping, limit: number): string;
146
- //#endregion
147
- //#region ../core/src/projection-validate.d.ts
148
- /**
149
- * Validate a projection against the discovered schema. Returns every error
150
- * found (not just the first) so a builder UI can show them all at once.
151
- */
152
- declare function validateProjection(projection: ProjectionMapping, schema: DiscoveredSchemaTable[], base: string): ConfigValidationError[];
153
- //#endregion
154
- //#region ../core/src/schema-meta.d.ts
155
- /**
156
- * Accessors over a discovered table's schema-v2 metadata.
157
- *
158
- * Every helper treats *absent* metadata as **unknown**, never as a negative
159
- * fact. `coversUniqueKey` returning false on a v1 payload is what makes
160
- * projection validation fail closed: we cannot prove a join is many-to-one, so
161
- * we refuse to compile it rather than guess.
162
- */
163
- declare function columnMetaFor(table: DiscoveredSchemaTable, column: string): DiscoveredColumnMeta | undefined;
164
- /**
165
- * Every primary-key column. More than one entry means a composite PK, which is
166
- * why `base_pk` identity is rejected for such tables.
167
- */
168
- declare function primaryKeyColumns(table: DiscoveredSchemaTable): string[];
169
- /**
170
- * Do `columns` contain every column of at least one unique key on `table`?
171
- *
172
- * This is the fan-out test. A join whose ON columns cover a unique key of the
173
- * joined table matches at most one row per base row; one that does not can
174
- * match many.
175
- */
176
- declare function coversUniqueKey(table: DiscoveredSchemaTable, columns: string[]): boolean;
177
- /** Is this table's payload rich enough to validate a projection against? */
178
- declare function hasRichMeta(table: DiscoveredSchemaTable): boolean;
179
- //#endregion
180
- export { fanOutJoins as C, suggestJoinConditions as S, draftErrors as _, validateProjection as a, emptyProjectionDraft as b, compileProjectionIdentity as c, compileProjectionSelect as d, quoteIdent as f, describeCardinality as g, addDraftJoin as h, primaryKeyColumns as i, compileProjectionJoins as l, ProjectionDraft as m, coversUniqueKey as n, PREVIEW_MAX_ROWS as o, DraftRefOption as p, hasRichMeta as r, compileProjectionFrom as s, columnMetaFor as t, compileProjectionPreview as u, draftRefOptions as v, joinFansOut as w, removeDraftJoin as x, draftToProjection as y };