@metaobjectsdev/codegen-ts 0.24.4 → 0.25.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 (265) hide show
  1. package/README.md +37 -12
  2. package/dist/api-surface.d.ts +29 -0
  3. package/dist/api-surface.d.ts.map +1 -1
  4. package/dist/api-surface.js +47 -0
  5. package/dist/api-surface.js.map +1 -1
  6. package/dist/client-directive.d.ts +18 -0
  7. package/dist/client-directive.d.ts.map +1 -0
  8. package/dist/client-directive.js +37 -0
  9. package/dist/client-directive.js.map +1 -0
  10. package/dist/column-mapper.d.ts +12 -0
  11. package/dist/column-mapper.d.ts.map +1 -1
  12. package/dist/column-mapper.js +1 -0
  13. package/dist/column-mapper.js.map +1 -1
  14. package/dist/constants.d.ts +24 -11
  15. package/dist/constants.d.ts.map +1 -1
  16. package/dist/constants.js +54 -19
  17. package/dist/constants.js.map +1 -1
  18. package/dist/db-emitting.d.ts +6 -0
  19. package/dist/db-emitting.d.ts.map +1 -0
  20. package/dist/db-emitting.js +26 -0
  21. package/dist/db-emitting.js.map +1 -0
  22. package/dist/generator-registry.d.ts.map +1 -1
  23. package/dist/generator-registry.js +7 -1
  24. package/dist/generator-registry.js.map +1 -1
  25. package/dist/generator.d.ts +5 -0
  26. package/dist/generator.d.ts.map +1 -1
  27. package/dist/generator.js.map +1 -1
  28. package/dist/generators/agent-docs-file.d.ts +19 -0
  29. package/dist/generators/agent-docs-file.d.ts.map +1 -0
  30. package/dist/generators/agent-docs-file.js +257 -0
  31. package/dist/generators/agent-docs-file.js.map +1 -0
  32. package/dist/generators/agent-requirements-page.d.ts +22 -0
  33. package/dist/generators/agent-requirements-page.d.ts.map +1 -0
  34. package/dist/generators/agent-requirements-page.js +175 -0
  35. package/dist/generators/agent-requirements-page.js.map +1 -0
  36. package/dist/generators/agent-schema-input.d.ts +69 -0
  37. package/dist/generators/agent-schema-input.d.ts.map +1 -0
  38. package/dist/generators/agent-schema-input.js +23 -0
  39. package/dist/generators/agent-schema-input.js.map +1 -0
  40. package/dist/generators/agent-schema-page.d.ts +21 -0
  41. package/dist/generators/agent-schema-page.d.ts.map +1 -0
  42. package/dist/generators/agent-schema-page.js +241 -0
  43. package/dist/generators/agent-schema-page.js.map +1 -0
  44. package/dist/generators/agent-ui-page.d.ts +22 -0
  45. package/dist/generators/agent-ui-page.d.ts.map +1 -0
  46. package/dist/generators/agent-ui-page.js +253 -0
  47. package/dist/generators/agent-ui-page.js.map +1 -0
  48. package/dist/generators/api-docs-file.d.ts.map +1 -1
  49. package/dist/generators/api-docs-file.js +13 -6
  50. package/dist/generators/api-docs-file.js.map +1 -1
  51. package/dist/generators/api-model.d.ts +6 -0
  52. package/dist/generators/api-model.d.ts.map +1 -1
  53. package/dist/generators/api-model.js +54 -35
  54. package/dist/generators/api-model.js.map +1 -1
  55. package/dist/generators/callable-file.js +1 -1
  56. package/dist/generators/callable-file.js.map +1 -1
  57. package/dist/generators/docs-data-builder.d.ts.map +1 -1
  58. package/dist/generators/docs-data-builder.js +47 -2
  59. package/dist/generators/docs-data-builder.js.map +1 -1
  60. package/dist/generators/docs-data.d.ts +6 -2
  61. package/dist/generators/docs-data.d.ts.map +1 -1
  62. package/dist/generators/index.d.ts +3 -0
  63. package/dist/generators/index.d.ts.map +1 -1
  64. package/dist/generators/index.js +4 -0
  65. package/dist/generators/index.js.map +1 -1
  66. package/dist/generators/names-file.d.ts +17 -0
  67. package/dist/generators/names-file.d.ts.map +1 -0
  68. package/dist/generators/names-file.js +95 -0
  69. package/dist/generators/names-file.js.map +1 -0
  70. package/dist/generators/requirements-markdown.d.ts +18 -1
  71. package/dist/generators/requirements-markdown.d.ts.map +1 -1
  72. package/dist/generators/requirements-markdown.js +11 -9
  73. package/dist/generators/requirements-markdown.js.map +1 -1
  74. package/dist/generators/routes-file-hono.d.ts +17 -2
  75. package/dist/generators/routes-file-hono.d.ts.map +1 -1
  76. package/dist/generators/routes-file-hono.js +15 -12
  77. package/dist/generators/routes-file-hono.js.map +1 -1
  78. package/dist/generators/routes-file.d.ts +17 -2
  79. package/dist/generators/routes-file.d.ts.map +1 -1
  80. package/dist/generators/routes-file.js +10 -8
  81. package/dist/generators/routes-file.js.map +1 -1
  82. package/dist/generators/template-generator.d.ts.map +1 -1
  83. package/dist/generators/template-generator.js +20 -6
  84. package/dist/generators/template-generator.js.map +1 -1
  85. package/dist/index.d.ts +21 -5
  86. package/dist/index.d.ts.map +1 -1
  87. package/dist/index.js +40 -4
  88. package/dist/index.js.map +1 -1
  89. package/dist/metaobjects-config.d.ts +67 -1
  90. package/dist/metaobjects-config.d.ts.map +1 -1
  91. package/dist/metaobjects-config.js +10 -1
  92. package/dist/metaobjects-config.js.map +1 -1
  93. package/dist/names.d.ts +275 -0
  94. package/dist/names.d.ts.map +1 -0
  95. package/dist/names.js +434 -0
  96. package/dist/names.js.map +1 -0
  97. package/dist/naming.d.ts +17 -0
  98. package/dist/naming.d.ts.map +1 -1
  99. package/dist/naming.js +21 -0
  100. package/dist/naming.js.map +1 -1
  101. package/dist/overwrite-policy.d.ts.map +1 -1
  102. package/dist/overwrite-policy.js +15 -3
  103. package/dist/overwrite-policy.js.map +1 -1
  104. package/dist/payload-codegen.d.ts.map +1 -1
  105. package/dist/payload-codegen.js +4 -3
  106. package/dist/payload-codegen.js.map +1 -1
  107. package/dist/projection/extract-view-spec.d.ts +25 -1
  108. package/dist/projection/extract-view-spec.d.ts.map +1 -1
  109. package/dist/projection/extract-view-spec.js +79 -6
  110. package/dist/projection/extract-view-spec.js.map +1 -1
  111. package/dist/prompt-generator-gate.d.ts +27 -0
  112. package/dist/prompt-generator-gate.d.ts.map +1 -0
  113. package/dist/prompt-generator-gate.js +62 -0
  114. package/dist/prompt-generator-gate.js.map +1 -0
  115. package/dist/reference-templates.d.ts +22 -5
  116. package/dist/reference-templates.d.ts.map +1 -1
  117. package/dist/reference-templates.js +55 -21
  118. package/dist/reference-templates.js.map +1 -1
  119. package/dist/render-context.d.ts +20 -1
  120. package/dist/render-context.d.ts.map +1 -1
  121. package/dist/render-context.js +2 -0
  122. package/dist/render-context.js.map +1 -1
  123. package/dist/retired-codegen-attrs.d.ts +32 -0
  124. package/dist/retired-codegen-attrs.d.ts.map +1 -0
  125. package/dist/retired-codegen-attrs.js +47 -0
  126. package/dist/retired-codegen-attrs.js.map +1 -0
  127. package/dist/routes-expose.d.ts +63 -0
  128. package/dist/routes-expose.d.ts.map +1 -0
  129. package/dist/routes-expose.js +57 -0
  130. package/dist/routes-expose.js.map +1 -0
  131. package/dist/runner.d.ts +18 -0
  132. package/dist/runner.d.ts.map +1 -1
  133. package/dist/runner.js +115 -7
  134. package/dist/runner.js.map +1 -1
  135. package/dist/templates/callable-file.d.ts +7 -2
  136. package/dist/templates/callable-file.d.ts.map +1 -1
  137. package/dist/templates/callable-file.js +54 -9
  138. package/dist/templates/callable-file.js.map +1 -1
  139. package/dist/templates/drizzle-schema.d.ts.map +1 -1
  140. package/dist/templates/drizzle-schema.js +236 -65
  141. package/dist/templates/drizzle-schema.js.map +1 -1
  142. package/dist/templates/entity-constants.d.ts +15 -6
  143. package/dist/templates/entity-constants.d.ts.map +1 -1
  144. package/dist/templates/entity-constants.js +85 -161
  145. package/dist/templates/entity-constants.js.map +1 -1
  146. package/dist/templates/entity-file.d.ts.map +1 -1
  147. package/dist/templates/entity-file.js +38 -4
  148. package/dist/templates/entity-file.js.map +1 -1
  149. package/dist/templates/entity-meta-file.d.ts +15 -1
  150. package/dist/templates/entity-meta-file.d.ts.map +1 -1
  151. package/dist/templates/entity-meta-file.js +12 -2
  152. package/dist/templates/entity-meta-file.js.map +1 -1
  153. package/dist/templates/entity-ui-descriptor.d.ts +112 -0
  154. package/dist/templates/entity-ui-descriptor.d.ts.map +1 -0
  155. package/dist/templates/entity-ui-descriptor.js +238 -0
  156. package/dist/templates/entity-ui-descriptor.js.map +1 -0
  157. package/dist/templates/field-meta.d.ts +46 -9
  158. package/dist/templates/field-meta.d.ts.map +1 -1
  159. package/dist/templates/field-meta.js +95 -21
  160. package/dist/templates/field-meta.js.map +1 -1
  161. package/dist/templates/names-decl.d.ts +38 -0
  162. package/dist/templates/names-decl.d.ts.map +1 -0
  163. package/dist/templates/names-decl.js +104 -0
  164. package/dist/templates/names-decl.js.map +1 -0
  165. package/dist/templates/output-parser.d.ts.map +1 -1
  166. package/dist/templates/output-parser.js +54 -8
  167. package/dist/templates/output-parser.js.map +1 -1
  168. package/dist/templates/projection-decl.d.ts +21 -0
  169. package/dist/templates/projection-decl.d.ts.map +1 -1
  170. package/dist/templates/projection-decl.js +53 -29
  171. package/dist/templates/projection-decl.js.map +1 -1
  172. package/dist/templates/queries-file.d.ts.map +1 -1
  173. package/dist/templates/queries-file.js +17 -2
  174. package/dist/templates/queries-file.js.map +1 -1
  175. package/dist/templates/render-helper.d.ts.map +1 -1
  176. package/dist/templates/render-helper.js +3 -1
  177. package/dist/templates/render-helper.js.map +1 -1
  178. package/dist/templates/requirement-test.d.ts.map +1 -1
  179. package/dist/templates/requirement-test.js +48 -21
  180. package/dist/templates/requirement-test.js.map +1 -1
  181. package/dist/templates/routes-file-hono.d.ts +2 -1
  182. package/dist/templates/routes-file-hono.d.ts.map +1 -1
  183. package/dist/templates/routes-file-hono.js +11 -2
  184. package/dist/templates/routes-file-hono.js.map +1 -1
  185. package/dist/templates/routes-file.d.ts +2 -1
  186. package/dist/templates/routes-file.d.ts.map +1 -1
  187. package/dist/templates/routes-file.js +54 -21
  188. package/dist/templates/routes-file.js.map +1 -1
  189. package/dist/templates/value-object-file.d.ts.map +1 -1
  190. package/dist/templates/value-object-file.js +15 -1
  191. package/dist/templates/value-object-file.js.map +1 -1
  192. package/dist/templates/view-decl.d.ts +37 -1
  193. package/dist/templates/view-decl.d.ts.map +1 -1
  194. package/dist/templates/view-decl.js +27 -3
  195. package/dist/templates/view-decl.js.map +1 -1
  196. package/dist/templates/zod-validators.d.ts +21 -0
  197. package/dist/templates/zod-validators.d.ts.map +1 -1
  198. package/dist/templates/zod-validators.js +40 -5
  199. package/dist/templates/zod-validators.js.map +1 -1
  200. package/dist/view-context.d.ts +24 -0
  201. package/dist/view-context.d.ts.map +1 -0
  202. package/dist/view-context.js +81 -0
  203. package/dist/view-context.js.map +1 -0
  204. package/package.json +6 -6
  205. package/src/api-surface.ts +53 -0
  206. package/src/client-directive.ts +36 -0
  207. package/src/column-mapper.ts +13 -0
  208. package/src/constants.ts +91 -16
  209. package/src/db-emitting.ts +31 -0
  210. package/src/generator-registry.ts +7 -0
  211. package/src/generator.ts +5 -0
  212. package/src/generators/agent-docs-file.ts +297 -0
  213. package/src/generators/agent-requirements-page.ts +199 -0
  214. package/src/generators/agent-schema-input.ts +88 -0
  215. package/src/generators/agent-schema-page.ts +297 -0
  216. package/src/generators/agent-ui-page.ts +290 -0
  217. package/src/generators/api-docs-file.ts +13 -6
  218. package/src/generators/api-model.ts +63 -34
  219. package/src/generators/callable-file.ts +1 -1
  220. package/src/generators/docs-data-builder.ts +46 -2
  221. package/src/generators/docs-data.ts +6 -2
  222. package/src/generators/index.ts +10 -0
  223. package/src/generators/names-file.ts +98 -0
  224. package/src/generators/requirements-markdown.ts +36 -2
  225. package/src/generators/routes-file-hono.ts +26 -15
  226. package/src/generators/routes-file.ts +20 -7
  227. package/src/generators/template-generator.ts +20 -6
  228. package/src/index.ts +63 -5
  229. package/src/metaobjects-config.ts +78 -2
  230. package/src/names.ts +630 -0
  231. package/src/naming.ts +23 -0
  232. package/src/overwrite-policy.ts +15 -3
  233. package/src/payload-codegen.ts +4 -3
  234. package/src/projection/extract-view-spec.ts +85 -6
  235. package/src/prompt-generator-gate.ts +73 -0
  236. package/src/reference/barrel.ts +3 -0
  237. package/src/reference/entity.ts +28 -2
  238. package/src/reference/names.ts +125 -0
  239. package/src/reference/queries.ts +14 -2
  240. package/src/reference/routes-hono.ts +113 -0
  241. package/src/reference/routes.ts +30 -9
  242. package/src/reference-templates.ts +61 -21
  243. package/src/render-context.ts +22 -1
  244. package/src/retired-codegen-attrs.ts +52 -0
  245. package/src/routes-expose.ts +86 -0
  246. package/src/runner.ts +129 -11
  247. package/src/templates/callable-file.ts +60 -8
  248. package/src/templates/drizzle-schema.ts +248 -60
  249. package/src/templates/entity-constants.ts +95 -184
  250. package/src/templates/entity-file.ts +46 -4
  251. package/src/templates/entity-meta-file.ts +16 -3
  252. package/src/templates/entity-ui-descriptor.ts +305 -0
  253. package/src/templates/field-meta.ts +100 -19
  254. package/src/templates/names-decl.ts +165 -0
  255. package/src/templates/output-parser.ts +54 -7
  256. package/src/templates/projection-decl.ts +72 -31
  257. package/src/templates/queries-file.ts +17 -2
  258. package/src/templates/render-helper.ts +3 -1
  259. package/src/templates/requirement-test.ts +49 -18
  260. package/src/templates/routes-file-hono.ts +14 -2
  261. package/src/templates/routes-file.ts +69 -24
  262. package/src/templates/value-object-file.ts +15 -1
  263. package/src/templates/view-decl.ts +53 -3
  264. package/src/templates/zod-validators.ts +41 -5
  265. package/src/view-context.ts +88 -0
@@ -0,0 +1,275 @@
1
+ /**
2
+ * §A2/§A3 — the ONE place a data name is resolved for a generator run.
3
+ *
4
+ * Both the names artifact (namesFile) and the entity generator that consumes it call this,
5
+ * so the constant and the binding it describes cannot be produced by different resolvers or
6
+ * different arguments. That is the whole rule; a name computed twice is a name that can
7
+ * disagree with itself.
8
+ */
9
+ import { type ColumnNamingStrategy, type MetaObject } from "@metaobjectsdev/metadata";
10
+ import { type Code } from "ts-poet";
11
+ import type { RenderContext } from "./render-context.js";
12
+ export interface FieldNames {
13
+ readonly name: string;
14
+ readonly column: string;
15
+ }
16
+ /**
17
+ * One `source.rdb` child, under the ROLE it plays.
18
+ *
19
+ * The physical name is carried under a key NAMED FOR THE KIND — `table`, `view`,
20
+ * `materializedView`, `proc`, `function` — and that key is not invented here: it is
21
+ * `PHYSICAL_NAME_ATTR_BY_KIND`, the metamodel's own FR-016/ADR-0018 alias map, the same
22
+ * one the canonical serializer rewrites through. So the artifact spells a physical name
23
+ * the way the metadata that declared it does.
24
+ *
25
+ * This is the half of the shape that earns the restructure. A single flat `name` held a
26
+ * table, a view and a stored procedure in the same run, told apart only by a sibling
27
+ * `kind`; under `as const`, `LedgerNames.sources.replica.table` is now a compile error,
28
+ * because that source is a view. The read site answers the question instead of the reader
29
+ * having to.
30
+ */
31
+ export interface SourceNames {
32
+ readonly type: string;
33
+ readonly subType: string;
34
+ /** The `@kind` value, defaulted per ADR-0007 Rule 3 — the discriminator for the alias below. */
35
+ readonly kind: string;
36
+ readonly schema?: string | undefined;
37
+ /** The physical name, under the alias for `kind`. Exactly one of these is present. */
38
+ readonly table?: string | undefined;
39
+ readonly view?: string | undefined;
40
+ readonly materializedView?: string | undefined;
41
+ readonly proc?: string | undefined;
42
+ readonly function?: string | undefined;
43
+ }
44
+ /**
45
+ * One `identity.*` or `index.*` child.
46
+ *
47
+ * `subType` is load-bearing rather than decorative: it is the ONLY thing distinguishing a
48
+ * unique alternate key from a non-unique lookup index, which is the whole reason ADR-0040
49
+ * put uniqueness in the type rather than in an attribute.
50
+ *
51
+ * `index` — the database name — is present only where a shared resolver produces it:
52
+ * `identity.secondary` and `index.lookup`, via `resolveIndexName`. It is deliberately
53
+ * ABSENT on `identity.primary`, because no such name exists to carry: migrate hardcodes
54
+ * `<table>_pkey` on Postgres, emits an unnamed PK on SQLite, and no port's codegen names a
55
+ * primary key at all. Carrying it would restate a migrate-only, dialect-conditional
56
+ * formula in an artifact whose entire promise is that a name is spelled once — the #293
57
+ * defect, re-created by the mechanism built to prevent it.
58
+ */
59
+ export interface KeyNames {
60
+ readonly type: string;
61
+ readonly subType: string;
62
+ readonly name: string;
63
+ /** The database index name. Present for `identity.secondary` and `index.lookup` only. */
64
+ readonly index?: string | undefined;
65
+ }
66
+ /** The object whose names artifact this one extends. */
67
+ export interface SuperNames {
68
+ readonly name: string;
69
+ readonly package?: string | undefined;
70
+ }
71
+ export interface ObjectNames {
72
+ /** The metamodel type — always `object`. */
73
+ readonly type: string;
74
+ /** The metamodel subType — `entity` | `projection` | `value`. */
75
+ readonly subType: string;
76
+ /**
77
+ * The object's OWN name — `"Customer"`, not `"TBL_CUST_MASTER"`.
78
+ *
79
+ * It held the physical name until 0.25.0, which is the one change here that a hand-
80
+ * written consumer can adopt WITHOUT a compile error: `pgTable(CustomerNames.name, …)`
81
+ * still compiles and now binds a table called `Customer`. The release note leads with
82
+ * that; no gate here can see it, because the code that breaks is not generated.
83
+ */
84
+ readonly name: string;
85
+ /**
86
+ * Every `source.rdb` child, keyed by effective `@role` (`primary` | `replica`).
87
+ *
88
+ * Role is the honest axis: the loader requires exactly one primary, and every consumer
89
+ * that binds a second source picks it by role. Keying by role is also what finally gives
90
+ * a WRITE-THROUGH entity's replica view a home — it declares two physical names, the
91
+ * artifact carried one, and both TypeScript and C# emitted the second as a literal.
92
+ *
93
+ * Empty on a FRAGMENT: an abstract base with no source of its own contributes columns
94
+ * and must never acquire a physical name it never declared.
95
+ */
96
+ readonly sources: Readonly<Record<string, SourceNames>>;
97
+ /** The sources DECLARED HERE — what this artifact emits. See `ownFields`. */
98
+ readonly ownSources: Readonly<Record<string, SourceNames>>;
99
+ /**
100
+ * Every field, INHERITED INCLUDED. This is what a consumer looks a column up in, so a
101
+ * lookup for an inherited field must hit — miss and the caller falls back to a literal
102
+ * (see `columnExpr`), which is the whole defect this artifact exists to remove.
103
+ */
104
+ readonly fields: Readonly<Record<string, FieldNames>>;
105
+ /**
106
+ * The fields DECLARED HERE — what the artifact EMITS. Inherited ones are declared by
107
+ * the super's artifact and reached through it, so a subtype states each physical name
108
+ * once instead of restating its parent's.
109
+ *
110
+ * ADR-0039's ONE sanctioned own-accessor use, in the exact form the ADR names: codegen
111
+ * emitting a generated subclass, iterating own members so inherited ones are not
112
+ * re-emitted.
113
+ */
114
+ readonly ownFields: Readonly<Record<string, FieldNames>>;
115
+ /** Every `identity.*` child, inherited included; keyed by metamodel name. */
116
+ readonly identities: Readonly<Record<string, KeyNames>>;
117
+ /** The identities DECLARED HERE. See `ownFields`. */
118
+ readonly ownIdentities: Readonly<Record<string, KeyNames>>;
119
+ /** Every `index.*` child, inherited included; keyed by metamodel name. */
120
+ readonly indexes: Readonly<Record<string, KeyNames>>;
121
+ /** The indexes DECLARED HERE. See `ownFields`. */
122
+ readonly ownIndexes: Readonly<Record<string, KeyNames>>;
123
+ /** The nearest ancestor carrying an artifact of its own, when there is one. */
124
+ readonly superNames?: SuperNames | undefined;
125
+ /**
126
+ * True when the primary source is the SUPER's rather than declared here — a TPH
127
+ * subtype, which shares its base's single table. Structural (the two resolve to the
128
+ * SAME source node), never an equality test on the resolved strings: the physical
129
+ * name, kind and schema then all come from the super's artifact rather than being
130
+ * restated.
131
+ */
132
+ readonly inheritsSource: boolean;
133
+ }
134
+ /**
135
+ * The nearest ancestor of `obj` that carries a names artifact of its own, or undefined.
136
+ *
137
+ * Walks past an ancestor with nothing to contribute — an abstract marker with no fields,
138
+ * no keys and no source emits no artifact, so there is nothing to extend and the search
139
+ * continues upward rather than stopping at a name that does not exist.
140
+ */
141
+ export declare function namesArtifactSuperOf(obj: MetaObject): MetaObject | undefined;
142
+ export declare function resolveObjectNames(obj: MetaObject, strategy?: ColumnNamingStrategy): ObjectNames | undefined;
143
+ /**
144
+ * The names FRAGMENT for an object that a sourced object extends but which declares no
145
+ * source of its own — the `BaseEntity` pattern: shared fields, no table.
146
+ *
147
+ * Separate from {@link resolveObjectNames} on purpose, and the separation is the #248 rule
148
+ * intact rather than weakened. "Has a primary source" still decides whether an object is a
149
+ * database participant, so an `object.value` carrying fields resolves to nothing here as it
150
+ * always has. A fragment is emitted only for an object REACHED from a participant by
151
+ * walking `extends` upward — which is the only context in which its fields are columns at
152
+ * all. It carries no `kind`/`name`/`readOnly`, because it has no physical name and must
153
+ * never acquire one.
154
+ *
155
+ * Returns undefined when the object declares nothing of its own: an abstract marker has
156
+ * nothing to extend, and emitting an empty artifact for it would put a name in the import
157
+ * graph that says nothing. "Nothing" is {@link declaresNamesContent} — fields OR keys, the
158
+ * same question {@link namesArtifactSuperOf} asks, so the walk and the emit cannot disagree
159
+ * about which ancestors exist.
160
+ */
161
+ export declare function resolveSuperFragmentNames(obj: MetaObject, strategy?: ColumnNamingStrategy): ObjectNames | undefined;
162
+ /**
163
+ * §B2 — the shared builder every `<Object>Names` reference call site used to hand-roll:
164
+ * check whether the artifact exists in this run (`ctx.includeNames`), resolve the
165
+ * constant (`resolveObjectNames`), and build the ts-poet import symbol pointing at
166
+ * `<Object>.names.ts`. Returns undefined whenever the artifact does not exist for this
167
+ * object in this run — a PRESENCE guard ("is the artifact in this run at all"), never the
168
+ * divergence refusal that `primaryRdbSource` owns: this function never compares a
169
+ * resolved value to a literal, it only asks whether the constant exists.
170
+ *
171
+ * `fromPackage` is the package of the FILE BEING EMITTED — the file that will hold the
172
+ * `import { <Object>Names } from …` line — and defaults to `obj.package`, correct for
173
+ * every site that emits `obj`'s OWN module (the entity generator referencing its own
174
+ * names artifact, same object on both ends). A caller emitting a DIFFERENT object's file
175
+ * and reaching across packages for `obj`'s names artifact — an M:N routes file, which
176
+ * lives in the SOURCE entity's package, importing the junction/target's `<X>Names` — MUST
177
+ * pass the emitting file's own package explicitly. Making this an explicit parameter
178
+ * (rather than assuming same-package the way a plain sibling specifier does) is what
179
+ * surfaces that choice: see routes-file.ts's `resolveJunctionColumn`, the one site that
180
+ * got it wrong by assuming same-package.
181
+ */
182
+ export declare function namesRef(obj: MetaObject, ctx: RenderContext, fromPackage?: string | undefined): {
183
+ readonly resolved: ObjectNames;
184
+ readonly symbol: Code;
185
+ } | undefined;
186
+ /**
187
+ * Adapts a `namesRef()` result to the `{ name, symbol }` shape `renderEntityConstants` /
188
+ * `renderEntityMetaFile` accept. Kept as a separate, narrower shape from `namesRef`'s own
189
+ * `{ resolved, symbol }` rather than folded together: those two functions' parameter
190
+ * predates this helper, and an adopter who already ejected the ADR-0034 reference
191
+ * template calls them with exactly this `{ name, symbol }` shape — widening the required
192
+ * shape to `resolved` would fail to compile in every such copy.
193
+ */
194
+ export declare function namesConstArg(names: {
195
+ readonly resolved: ObjectNames;
196
+ readonly symbol: Code;
197
+ } | undefined, role?: string): {
198
+ readonly name: string;
199
+ readonly symbol: Code;
200
+ } | undefined;
201
+ /**
202
+ * The physical-name expression every §A6 `$table` / view-name site builds: the constant
203
+ * when the artifact is present, the literal otherwise. No equality guard — but the two
204
+ * branches earn that two different ways, and both are worth naming:
205
+ *
206
+ * - A TABLE literal (`drizzle-schema.ts`, `entity-constants.ts`) comes from
207
+ * `dbTable`/`resolveTableName`, which delegate to `primaryRdbSource` — the same lookup
208
+ * `resolveObjectNames` uses — so a disagreeing object has already thrown.
209
+ * - A VIEW literal (`projection-decl.ts`, `view-decl.ts`) comes from `viewName()`
210
+ * (`extract-view-spec.ts`), which reads OWN read-only sources only. That cannot diverge:
211
+ * a concrete projection may not inherit a source (`ERR_PROJECTION_INHERITED_SOURCE`) and
212
+ * the loader allows one own primary, so there is nothing for it to disagree with.
213
+ *
214
+ * Either way a reference here is the single spelling, never a lookalike computed twice.
215
+ *
216
+ * `role` selects WHICH source — the parameter that did not exist while the artifact held
217
+ * one name. A write-through entity declares two physical names; passing `replica` is how
218
+ * the read view stops being a literal in TypeScript and C# alike.
219
+ */
220
+ export declare function physicalNameExpr(names: {
221
+ readonly symbol: Code;
222
+ } | undefined, literal: string, obj: MetaObject, role?: string): Code;
223
+ /**
224
+ * The physical-name alias key for `obj`'s source in `role` — `table`, `view`, `proc`, …
225
+ *
226
+ * Derived from the object rather than taken as a parameter, so a call site cannot pass an
227
+ * alias that disagrees with the source it is describing. Reads the metamodel's own
228
+ * `PHYSICAL_NAME_ATTR_BY_KIND`; a local switch here would be a second answer to a
229
+ * question the metamodel already answers, which is the defect class this file exists for.
230
+ */
231
+ export declare function sourceAliasOf(obj: MetaObject, role?: string): string | undefined;
232
+ /**
233
+ * A source's `@schema` expression, or undefined when the source declares none.
234
+ *
235
+ * Undefined rather than a literal fallback: an absent `@schema` means "the dialect's
236
+ * default", which a caller expresses by omitting the qualifier entirely — emitting `""`
237
+ * or `"public"` would be this artifact inventing a name the author never wrote.
238
+ */
239
+ export declare function sourceSchemaExpr(names: {
240
+ readonly resolved: ObjectNames;
241
+ readonly symbol: Code;
242
+ } | undefined, role?: string): Code | undefined;
243
+ /**
244
+ * An index's database-name expression — the constant when the artifact carries the node,
245
+ * the literal otherwise.
246
+ *
247
+ * The literal arm goes through `resolveIndexName` rather than reading `node.name`, so the
248
+ * names-off path and the names-on path answer with the same function. That is the whole
249
+ * lesson of `fdb4118f1`: two spellings of one name agree until they do not.
250
+ */
251
+ export declare function indexNameExpr(names: {
252
+ readonly resolved: ObjectNames;
253
+ readonly symbol: Code;
254
+ } | undefined, node: {
255
+ readonly name: string;
256
+ readonly type: string;
257
+ readonly subType: string;
258
+ }): Code;
259
+ /**
260
+ * A field's physical-column expression: the constant when the given artifact carries the
261
+ * field, the literal otherwise.
262
+ *
263
+ * The literal arm is a PRESENCE guard — "no artifact in this run", the documented ADR-0034
264
+ * opt-out — and NOT a divergence guard. It used to carry a second sanctioned case: a TPH
265
+ * fold emitting a subtype's own columns, which the BASE's artifact never saw. That was
266
+ * never a presence question; the constant existed the whole time, in the subtype's own
267
+ * artifact. Callers now resolve the declaring entity's ref before falling back
268
+ * (`drizzle-schema.ts`), so a miss no longer has a known-good explanation and the fallback
269
+ * is the last resort it was meant to be.
270
+ */
271
+ export declare function columnExpr(names: {
272
+ readonly resolved: ObjectNames;
273
+ readonly symbol: Code;
274
+ } | undefined, fieldName: string, literal: string): Code;
275
+ //# sourceMappingURL=names.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"names.d.ts","sourceRoot":"","sources":["../src/names.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAaL,KAAK,oBAAoB,EACzB,KAAK,UAAU,EAEhB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAa,KAAK,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CA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