@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.
- package/README.md +37 -12
- package/dist/api-surface.d.ts +29 -0
- package/dist/api-surface.d.ts.map +1 -1
- package/dist/api-surface.js +47 -0
- package/dist/api-surface.js.map +1 -1
- package/dist/client-directive.d.ts +18 -0
- package/dist/client-directive.d.ts.map +1 -0
- package/dist/client-directive.js +37 -0
- package/dist/client-directive.js.map +1 -0
- package/dist/column-mapper.d.ts +12 -0
- package/dist/column-mapper.d.ts.map +1 -1
- package/dist/column-mapper.js +1 -0
- package/dist/column-mapper.js.map +1 -1
- package/dist/constants.d.ts +24 -11
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +54 -19
- package/dist/constants.js.map +1 -1
- package/dist/db-emitting.d.ts +6 -0
- package/dist/db-emitting.d.ts.map +1 -0
- package/dist/db-emitting.js +26 -0
- package/dist/db-emitting.js.map +1 -0
- package/dist/generator-registry.d.ts.map +1 -1
- package/dist/generator-registry.js +7 -1
- package/dist/generator-registry.js.map +1 -1
- package/dist/generator.d.ts +5 -0
- package/dist/generator.d.ts.map +1 -1
- package/dist/generator.js.map +1 -1
- package/dist/generators/agent-docs-file.d.ts +19 -0
- package/dist/generators/agent-docs-file.d.ts.map +1 -0
- package/dist/generators/agent-docs-file.js +257 -0
- package/dist/generators/agent-docs-file.js.map +1 -0
- package/dist/generators/agent-requirements-page.d.ts +22 -0
- package/dist/generators/agent-requirements-page.d.ts.map +1 -0
- package/dist/generators/agent-requirements-page.js +175 -0
- package/dist/generators/agent-requirements-page.js.map +1 -0
- package/dist/generators/agent-schema-input.d.ts +69 -0
- package/dist/generators/agent-schema-input.d.ts.map +1 -0
- package/dist/generators/agent-schema-input.js +23 -0
- package/dist/generators/agent-schema-input.js.map +1 -0
- package/dist/generators/agent-schema-page.d.ts +21 -0
- package/dist/generators/agent-schema-page.d.ts.map +1 -0
- package/dist/generators/agent-schema-page.js +241 -0
- package/dist/generators/agent-schema-page.js.map +1 -0
- package/dist/generators/agent-ui-page.d.ts +22 -0
- package/dist/generators/agent-ui-page.d.ts.map +1 -0
- package/dist/generators/agent-ui-page.js +253 -0
- package/dist/generators/agent-ui-page.js.map +1 -0
- package/dist/generators/api-docs-file.d.ts.map +1 -1
- package/dist/generators/api-docs-file.js +13 -6
- package/dist/generators/api-docs-file.js.map +1 -1
- package/dist/generators/api-model.d.ts +6 -0
- package/dist/generators/api-model.d.ts.map +1 -1
- package/dist/generators/api-model.js +54 -35
- package/dist/generators/api-model.js.map +1 -1
- package/dist/generators/callable-file.js +1 -1
- package/dist/generators/callable-file.js.map +1 -1
- package/dist/generators/docs-data-builder.d.ts.map +1 -1
- package/dist/generators/docs-data-builder.js +47 -2
- package/dist/generators/docs-data-builder.js.map +1 -1
- package/dist/generators/docs-data.d.ts +6 -2
- package/dist/generators/docs-data.d.ts.map +1 -1
- package/dist/generators/index.d.ts +3 -0
- package/dist/generators/index.d.ts.map +1 -1
- package/dist/generators/index.js +4 -0
- package/dist/generators/index.js.map +1 -1
- package/dist/generators/names-file.d.ts +17 -0
- package/dist/generators/names-file.d.ts.map +1 -0
- package/dist/generators/names-file.js +95 -0
- package/dist/generators/names-file.js.map +1 -0
- package/dist/generators/requirements-markdown.d.ts +18 -1
- package/dist/generators/requirements-markdown.d.ts.map +1 -1
- package/dist/generators/requirements-markdown.js +11 -9
- package/dist/generators/requirements-markdown.js.map +1 -1
- package/dist/generators/routes-file-hono.d.ts +17 -2
- package/dist/generators/routes-file-hono.d.ts.map +1 -1
- package/dist/generators/routes-file-hono.js +15 -12
- package/dist/generators/routes-file-hono.js.map +1 -1
- package/dist/generators/routes-file.d.ts +17 -2
- package/dist/generators/routes-file.d.ts.map +1 -1
- package/dist/generators/routes-file.js +10 -8
- package/dist/generators/routes-file.js.map +1 -1
- package/dist/generators/template-generator.d.ts.map +1 -1
- package/dist/generators/template-generator.js +20 -6
- package/dist/generators/template-generator.js.map +1 -1
- package/dist/index.d.ts +21 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +40 -4
- package/dist/index.js.map +1 -1
- package/dist/metaobjects-config.d.ts +67 -1
- package/dist/metaobjects-config.d.ts.map +1 -1
- package/dist/metaobjects-config.js +10 -1
- package/dist/metaobjects-config.js.map +1 -1
- package/dist/names.d.ts +275 -0
- package/dist/names.d.ts.map +1 -0
- package/dist/names.js +434 -0
- package/dist/names.js.map +1 -0
- package/dist/naming.d.ts +17 -0
- package/dist/naming.d.ts.map +1 -1
- package/dist/naming.js +21 -0
- package/dist/naming.js.map +1 -1
- package/dist/overwrite-policy.d.ts.map +1 -1
- package/dist/overwrite-policy.js +15 -3
- package/dist/overwrite-policy.js.map +1 -1
- package/dist/payload-codegen.d.ts.map +1 -1
- package/dist/payload-codegen.js +4 -3
- package/dist/payload-codegen.js.map +1 -1
- package/dist/projection/extract-view-spec.d.ts +25 -1
- package/dist/projection/extract-view-spec.d.ts.map +1 -1
- package/dist/projection/extract-view-spec.js +79 -6
- package/dist/projection/extract-view-spec.js.map +1 -1
- package/dist/prompt-generator-gate.d.ts +27 -0
- package/dist/prompt-generator-gate.d.ts.map +1 -0
- package/dist/prompt-generator-gate.js +62 -0
- package/dist/prompt-generator-gate.js.map +1 -0
- package/dist/reference-templates.d.ts +22 -5
- package/dist/reference-templates.d.ts.map +1 -1
- package/dist/reference-templates.js +55 -21
- package/dist/reference-templates.js.map +1 -1
- package/dist/render-context.d.ts +20 -1
- package/dist/render-context.d.ts.map +1 -1
- package/dist/render-context.js +2 -0
- package/dist/render-context.js.map +1 -1
- package/dist/retired-codegen-attrs.d.ts +32 -0
- package/dist/retired-codegen-attrs.d.ts.map +1 -0
- package/dist/retired-codegen-attrs.js +47 -0
- package/dist/retired-codegen-attrs.js.map +1 -0
- package/dist/routes-expose.d.ts +63 -0
- package/dist/routes-expose.d.ts.map +1 -0
- package/dist/routes-expose.js +57 -0
- package/dist/routes-expose.js.map +1 -0
- package/dist/runner.d.ts +18 -0
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +115 -7
- package/dist/runner.js.map +1 -1
- package/dist/templates/callable-file.d.ts +7 -2
- package/dist/templates/callable-file.d.ts.map +1 -1
- package/dist/templates/callable-file.js +54 -9
- package/dist/templates/callable-file.js.map +1 -1
- package/dist/templates/drizzle-schema.d.ts.map +1 -1
- package/dist/templates/drizzle-schema.js +236 -65
- package/dist/templates/drizzle-schema.js.map +1 -1
- package/dist/templates/entity-constants.d.ts +15 -6
- package/dist/templates/entity-constants.d.ts.map +1 -1
- package/dist/templates/entity-constants.js +85 -161
- package/dist/templates/entity-constants.js.map +1 -1
- package/dist/templates/entity-file.d.ts.map +1 -1
- package/dist/templates/entity-file.js +38 -4
- package/dist/templates/entity-file.js.map +1 -1
- package/dist/templates/entity-meta-file.d.ts +15 -1
- package/dist/templates/entity-meta-file.d.ts.map +1 -1
- package/dist/templates/entity-meta-file.js +12 -2
- package/dist/templates/entity-meta-file.js.map +1 -1
- package/dist/templates/entity-ui-descriptor.d.ts +112 -0
- package/dist/templates/entity-ui-descriptor.d.ts.map +1 -0
- package/dist/templates/entity-ui-descriptor.js +238 -0
- package/dist/templates/entity-ui-descriptor.js.map +1 -0
- package/dist/templates/field-meta.d.ts +46 -9
- package/dist/templates/field-meta.d.ts.map +1 -1
- package/dist/templates/field-meta.js +95 -21
- package/dist/templates/field-meta.js.map +1 -1
- package/dist/templates/names-decl.d.ts +38 -0
- package/dist/templates/names-decl.d.ts.map +1 -0
- package/dist/templates/names-decl.js +104 -0
- package/dist/templates/names-decl.js.map +1 -0
- package/dist/templates/output-parser.d.ts.map +1 -1
- package/dist/templates/output-parser.js +54 -8
- package/dist/templates/output-parser.js.map +1 -1
- package/dist/templates/projection-decl.d.ts +21 -0
- package/dist/templates/projection-decl.d.ts.map +1 -1
- package/dist/templates/projection-decl.js +53 -29
- package/dist/templates/projection-decl.js.map +1 -1
- package/dist/templates/queries-file.d.ts.map +1 -1
- package/dist/templates/queries-file.js +17 -2
- package/dist/templates/queries-file.js.map +1 -1
- package/dist/templates/render-helper.d.ts.map +1 -1
- package/dist/templates/render-helper.js +3 -1
- package/dist/templates/render-helper.js.map +1 -1
- package/dist/templates/requirement-test.d.ts.map +1 -1
- package/dist/templates/requirement-test.js +48 -21
- package/dist/templates/requirement-test.js.map +1 -1
- package/dist/templates/routes-file-hono.d.ts +2 -1
- package/dist/templates/routes-file-hono.d.ts.map +1 -1
- package/dist/templates/routes-file-hono.js +11 -2
- package/dist/templates/routes-file-hono.js.map +1 -1
- package/dist/templates/routes-file.d.ts +2 -1
- package/dist/templates/routes-file.d.ts.map +1 -1
- package/dist/templates/routes-file.js +54 -21
- package/dist/templates/routes-file.js.map +1 -1
- package/dist/templates/value-object-file.d.ts.map +1 -1
- package/dist/templates/value-object-file.js +15 -1
- package/dist/templates/value-object-file.js.map +1 -1
- package/dist/templates/view-decl.d.ts +37 -1
- package/dist/templates/view-decl.d.ts.map +1 -1
- package/dist/templates/view-decl.js +27 -3
- package/dist/templates/view-decl.js.map +1 -1
- package/dist/templates/zod-validators.d.ts +21 -0
- package/dist/templates/zod-validators.d.ts.map +1 -1
- package/dist/templates/zod-validators.js +40 -5
- package/dist/templates/zod-validators.js.map +1 -1
- package/dist/view-context.d.ts +24 -0
- package/dist/view-context.d.ts.map +1 -0
- package/dist/view-context.js +81 -0
- package/dist/view-context.js.map +1 -0
- package/package.json +6 -6
- package/src/api-surface.ts +53 -0
- package/src/client-directive.ts +36 -0
- package/src/column-mapper.ts +13 -0
- package/src/constants.ts +91 -16
- package/src/db-emitting.ts +31 -0
- package/src/generator-registry.ts +7 -0
- package/src/generator.ts +5 -0
- package/src/generators/agent-docs-file.ts +297 -0
- package/src/generators/agent-requirements-page.ts +199 -0
- package/src/generators/agent-schema-input.ts +88 -0
- package/src/generators/agent-schema-page.ts +297 -0
- package/src/generators/agent-ui-page.ts +290 -0
- package/src/generators/api-docs-file.ts +13 -6
- package/src/generators/api-model.ts +63 -34
- package/src/generators/callable-file.ts +1 -1
- package/src/generators/docs-data-builder.ts +46 -2
- package/src/generators/docs-data.ts +6 -2
- package/src/generators/index.ts +10 -0
- package/src/generators/names-file.ts +98 -0
- package/src/generators/requirements-markdown.ts +36 -2
- package/src/generators/routes-file-hono.ts +26 -15
- package/src/generators/routes-file.ts +20 -7
- package/src/generators/template-generator.ts +20 -6
- package/src/index.ts +63 -5
- package/src/metaobjects-config.ts +78 -2
- package/src/names.ts +630 -0
- package/src/naming.ts +23 -0
- package/src/overwrite-policy.ts +15 -3
- package/src/payload-codegen.ts +4 -3
- package/src/projection/extract-view-spec.ts +85 -6
- package/src/prompt-generator-gate.ts +73 -0
- package/src/reference/barrel.ts +3 -0
- package/src/reference/entity.ts +28 -2
- package/src/reference/names.ts +125 -0
- package/src/reference/queries.ts +14 -2
- package/src/reference/routes-hono.ts +113 -0
- package/src/reference/routes.ts +30 -9
- package/src/reference-templates.ts +61 -21
- package/src/render-context.ts +22 -1
- package/src/retired-codegen-attrs.ts +52 -0
- package/src/routes-expose.ts +86 -0
- package/src/runner.ts +129 -11
- package/src/templates/callable-file.ts +60 -8
- package/src/templates/drizzle-schema.ts +248 -60
- package/src/templates/entity-constants.ts +95 -184
- package/src/templates/entity-file.ts +46 -4
- package/src/templates/entity-meta-file.ts +16 -3
- package/src/templates/entity-ui-descriptor.ts +305 -0
- package/src/templates/field-meta.ts +100 -19
- package/src/templates/names-decl.ts +165 -0
- package/src/templates/output-parser.ts +54 -7
- package/src/templates/projection-decl.ts +72 -31
- package/src/templates/queries-file.ts +17 -2
- package/src/templates/render-helper.ts +3 -1
- package/src/templates/requirement-test.ts +49 -18
- package/src/templates/routes-file-hono.ts +14 -2
- package/src/templates/routes-file.ts +69 -24
- package/src/templates/value-object-file.ts +15 -1
- package/src/templates/view-decl.ts +53 -3
- package/src/templates/zod-validators.ts +41 -5
- package/src/view-context.ts +88 -0
package/dist/names.d.ts
ADDED
|
@@ -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,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