@descryy/adapter-kotlin 0.4.0 → 0.5.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.
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Property reads on a JPA model, per function — golden pattern 07's READS half.
3
+ *
4
+ * **Why this is a second file and not part of `jpa.ts`.** Two lanes built a
5
+ * Kotlin ORM reader in the same session. `lane-r3-gokotlin`'s is the one in
6
+ * `jpa.ts`: it resolves superclasses, gates shape completeness and carries the
7
+ * adapter's one R3 fact kind. `lane-orm-breadth`'s was an R2 reader and is
8
+ * superseded by it — except for this function, which the other never had, and
9
+ * without which `adapter-kotlin` loses golden 07. Kept verbatim, in its own
10
+ * module, because `jpa.ts` already exports a different `JpaField`.
11
+ */
12
+ /**
13
+ * Property reads in one function, per model.
14
+ *
15
+ * Only a receiver whose type a binding WROTE is considered. Kotlin infers
16
+ * aggressively and `val order = load(id)` states nothing at the binding site —
17
+ * resolving it would mean reading the callee's signature, which is a different
18
+ * and larger claim than this reader makes.
19
+ */
20
+ export function fieldReadsIn(func, resolveModel) {
21
+ const byModel = new Map();
22
+ for (const read of func.fieldReads) {
23
+ const model = resolveModel(read.receiverType);
24
+ if (model === undefined)
25
+ continue;
26
+ let fields = byModel.get(model);
27
+ if (fields === undefined) {
28
+ fields = new Set();
29
+ byModel.set(model, fields);
30
+ }
31
+ fields.add(read.field);
32
+ }
33
+ return [...byModel.entries()].map(([model, fields]) => ({ model, fields: [...fields].sort() }));
34
+ }
35
+ //# sourceMappingURL=jpa-reads.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jpa-reads.js","sourceRoot":"","sources":["../src/jpa-reads.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AASH;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAC1B,IAAgB,EAChB,YAAyD;IAEzD,MAAM,OAAO,GAAG,IAAI,GAAG,EAAuB,CAAC;IAC/C,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;QACnC,MAAM,KAAK,GAAG,YAAY,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAC9C,IAAI,KAAK,KAAK,SAAS;YAAE,SAAS;QAClC,IAAI,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAChC,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACzB,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;YACnB,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAC7B,CAAC;QACD,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACzB,CAAC;IACD,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;AAClG,CAAC"}
package/dist/jpa.d.ts ADDED
@@ -0,0 +1,147 @@
1
+ /**
2
+ * The ORM framework extractor for Kotlin — JPA/Hibernate, read from source.
3
+ *
4
+ * **A `MODEL` is a framework claim, earned here** (DEC-127), and the rules are
5
+ * `adapter-java/src/jpa.ts`'s, ported onto Kotlin's own grammar rather than
6
+ * re-derived: admission is one annotation (`@Entity`), provenance is the
7
+ * import table, and a stated nullability this reader cannot evaluate is listed
8
+ * rather than guessed. Two adapters disagreeing on one golden pattern is the
9
+ * failure mode the conformance harness exists to prevent, and the two JVM
10
+ * adapters read the *same* mapping — so where Kotlin and Java can answer
11
+ * alike, they answer alike.
12
+ *
13
+ * ## Three grammar facts that decide this design
14
+ *
15
+ * **1.** A Kotlin property is declared in two places, not one: a
16
+ * `class_parameter` in the `primary_constructor` carrying `val`/`var`
17
+ * (`binding_pattern_kind`), and a `property_declaration` in the `class_body`.
18
+ * A constructor parameter *without* `val`/`var` is not a property and is not a
19
+ * column — the distinction is one keyword and there is no second signal for it.
20
+ *
21
+ * **2.** Nullability is in the type, as `nullable_type` wrapping the
22
+ * `user_type`. That is a stated fact, and one Java has no spelling for. It is
23
+ * **not** a NOT NULL claim: a non-null `String` is still `java.lang.String` on
24
+ * the JVM and Hibernate defaults its column nullable, exactly as for Java. A
25
+ * non-null `Long`/`Int`/`Boolean`/… *does* compile to a JVM primitive, which
26
+ * is precisely `adapter-java`'s `primitive-type` rule in Kotlin's spelling and
27
+ * is read as such. Claiming more than that from Kotlin's null-safety would put
28
+ * the two JVM adapters into disagreement on identical mappings.
29
+ *
30
+ * **3.** An annotation may carry a `use_site_target` (`@field:Column`,
31
+ * `@get:Id`) as a sibling of the `user_type`, so the name is read past it.
32
+ * Kotlin JPA codebases write these constantly; a reader matching on the
33
+ * annotation node's text would see none of them.
34
+ *
35
+ * ## The two-property declaration-site test, and why gates and not comments
36
+ *
37
+ * An R3 claim resting on a declaration rather than a checker has to answer
38
+ * two questions: (a) is the physical shape **stated**, and (b) is the declared
39
+ * set **complete**? (a) holds — every persistent property is a `val`/`var`
40
+ * with a written type or it is not readable at all. (b) holds only for the
41
+ * constructs this reader classifies, and a framework guarantee covers nothing
42
+ * else, so the four shapes that break completeness are **gated** rather than
43
+ * noted: see {@link Refusal}. `adapter-swift`'s lane established the rule; the
44
+ * cost of not holding it is a table reported with three of its thirty columns
45
+ * that reads as complete.
46
+ */
47
+ import type { Node } from "@descryy/adapter-treesitter";
48
+ import type { KotlinImport } from "./parse.ts";
49
+ /** One `val`/`var` of a candidate entity, as written. */
50
+ export interface KotlinJpaProperty {
51
+ readonly name: string;
52
+ readonly annotations: readonly string[];
53
+ /**
54
+ * `@Column(nullable = …)`: the boolean as written, `null` when the argument
55
+ * is present but unevaluable (`nullable = FLAG`), `undefined` when absent.
56
+ * The third state is the point — a stated answer this reader failed to read
57
+ * must not fall through to the framework default, which reports the opposite
58
+ * of the source as fact.
59
+ */
60
+ readonly columnNullable: boolean | null | undefined;
61
+ /** The written type's outermost name, `undefined` when Kotlin inferred it. */
62
+ readonly writtenType: string | undefined;
63
+ /** `T?` as written. */
64
+ readonly nullableType: boolean;
65
+ /** An explicit `get()`/`set()` — whether a backing field exists is not readable. */
66
+ readonly hasAccessor: boolean;
67
+ /** `by lazy { … }` and friends: the value is not held in a field this reader can describe. */
68
+ readonly delegated: boolean;
69
+ }
70
+ /** A class declaration carrying at least one annotation this extractor knows. */
71
+ export interface KotlinJpaDeclaration {
72
+ readonly name: string;
73
+ /** Enclosing type path, outermost first — the identity `extract.ts` mints against. */
74
+ readonly owners: readonly string[];
75
+ readonly annotations: readonly string[];
76
+ /** The mapped table where the source names one; `null` when only a strategy would give it. */
77
+ readonly table: string | null;
78
+ readonly properties: readonly KotlinJpaProperty[];
79
+ /**
80
+ * The written name of the one **invoked** supertype. Kotlin requires a
81
+ * superclass's constructor to be called and forbids invoking an interface,
82
+ * so unlike Java's `extendsNames[0]` this is decidable from syntax alone —
83
+ * which is what makes gate E1 possible rather than a guess.
84
+ */
85
+ readonly superclass: string | undefined;
86
+ readonly startLine: number;
87
+ readonly endLine: number;
88
+ }
89
+ /**
90
+ * Every persistence-annotated declaration in this file, read while the tree is
91
+ * alive. `adapter.ts` deletes the tree immediately after `readKotlinFile`, so
92
+ * this runs there and everything downstream works from the result.
93
+ */
94
+ export declare function readJpaDeclarations(root: Node, imports: readonly KotlinImport[]): readonly KotlinJpaDeclaration[];
95
+ /** Mirrors `adapter-java`'s `JpaField`, so one shape crosses both JVM adapters. */
96
+ export interface JpaField {
97
+ readonly name: string;
98
+ readonly nullable: boolean;
99
+ /**
100
+ * Where the answer came from. One value wider than Java's set:
101
+ * `declared-type` is a `T?` written in the source, which Java has no
102
+ * spelling for and which is a *stated* nullable rather than a defaulted one.
103
+ * It costs nothing above the IR boundary — `attrs` carries the language part.
104
+ */
105
+ readonly nullableFrom: "declared" | "annotation" | "primitive-type" | "declared-type" | "framework-default";
106
+ }
107
+ export interface JpaModel {
108
+ readonly className: string;
109
+ readonly owners: readonly string[];
110
+ readonly table: string | null;
111
+ readonly fields: readonly JpaField[];
112
+ readonly line: number;
113
+ /** Properties whose shape is written in a form this reader cannot evaluate. */
114
+ readonly undecided: readonly string[];
115
+ }
116
+ /**
117
+ * A shape this reader refused because it could not prove the column set
118
+ * complete. The four gates, each a construct Kotlin can represent and this
119
+ * reader cannot enumerate:
120
+ *
121
+ * E1 unresolvable superclass · E2 `@Entity` superclass ·
122
+ * E3 `@Embedded`/`@EmbeddedId` · E4 `@Inheritance`/`@DiscriminatorColumn`.
123
+ *
124
+ * The `MODEL` node still stands — *this class is persisted* is read from one
125
+ * annotation and remains true. Only the shape, the part that would carry R3,
126
+ * is withheld.
127
+ */
128
+ export interface JpaRefusal {
129
+ readonly className: string;
130
+ readonly reason: string;
131
+ }
132
+ /** The minimum of a `KotlinFile` this reader needs, so tests can supply one. */
133
+ export interface JpaUnit {
134
+ readonly packageName: string;
135
+ readonly jpaDeclarations: readonly KotlinJpaDeclaration[];
136
+ }
137
+ /** Resolve a written supertype name to its declaration, anywhere in the batch. */
138
+ export type ResolveSuper = (written: string, from: JpaUnit) => {
139
+ declaration: KotlinJpaDeclaration;
140
+ unit: JpaUnit;
141
+ } | undefined;
142
+ /** Every JPA entity this unit declares, plus every shape it refused and why. */
143
+ export declare function jpaModels(unit: JpaUnit, resolve: ResolveSuper): {
144
+ models: JpaModel[];
145
+ refusals: JpaRefusal[];
146
+ };
147
+ //# sourceMappingURL=jpa.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jpa.d.ts","sourceRoot":"","sources":["../src/jpa.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AAExD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAqF/C,y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4
+ * **A `MODEL` is a framework claim, earned here** (DEC-127), and the rules are
5
+ * `adapter-java/src/jpa.ts`'s, ported onto Kotlin's own grammar rather than
6
+ * re-derived: admission is one annotation (`@Entity`), provenance is the
7
+ * import table, and a stated nullability this reader cannot evaluate is listed
8
+ * rather than guessed. Two adapters disagreeing on one golden pattern is the
9
+ * failure mode the conformance harness exists to prevent, and the two JVM
10
+ * adapters read the *same* mapping — so where Kotlin and Java can answer
11
+ * alike, they answer alike.
12
+ *
13
+ * ## Three grammar facts that decide this design
14
+ *
15
+ * **1.** A Kotlin property is declared in two places, not one: a
16
+ * `class_parameter` in the `primary_constructor` carrying `val`/`var`
17
+ * (`binding_pattern_kind`), and a `property_declaration` in the `class_body`.
18
+ * A constructor parameter *without* `val`/`var` is not a property and is not a
19
+ * column — the distinction is one keyword and there is no second signal for it.
20
+ *
21
+ * **2.** Nullability is in the type, as `nullable_type` wrapping the
22
+ * `user_type`. That is a stated fact, and one Java has no spelling for. It is
23
+ * **not** a NOT NULL claim: a non-null `String` is still `java.lang.String` on
24
+ * the JVM and Hibernate defaults its column nullable, exactly as for Java. A
25
+ * non-null `Long`/`Int`/`Boolean`/… *does* compile to a JVM primitive, which
26
+ * is precisely `adapter-java`'s `primitive-type` rule in Kotlin's spelling and
27
+ * is read as such. Claiming more than that from Kotlin's null-safety would put
28
+ * the two JVM adapters into disagreement on identical mappings.
29
+ *
30
+ * **3.** An annotation may carry a `use_site_target` (`@field:Column`,
31
+ * `@get:Id`) as a sibling of the `user_type`, so the name is read past it.
32
+ * Kotlin JPA codebases write these constantly; a reader matching on the
33
+ * annotation node's text would see none of them.
34
+ *
35
+ * ## The two-property declaration-site test, and why gates and not comments
36
+ *
37
+ * An R3 claim resting on a declaration rather than a checker has to answer
38
+ * two questions: (a) is the physical shape **stated**, and (b) is the declared
39
+ * set **complete**? (a) holds — every persistent property is a `val`/`var`
40
+ * with a written type or it is not readable at all. (b) holds only for the
41
+ * constructs this reader classifies, and a framework guarantee covers nothing
42
+ * else, so the four shapes that break completeness are **gated** rather than
43
+ * noted: see {@link Refusal}. `adapter-swift`'s lane established the rule; the
44
+ * cost of not holding it is a table reported with three of its thirty columns
45
+ * that reads as complete.
46
+ */
47
+ const JPA_PACKAGES = ["jakarta.persistence", "javax.persistence"];
48
+ /**
49
+ * Spring Data MongoDB's own mapping package, kept separate from
50
+ * {@link JPA_PACKAGES} for `adapter-java`'s reason: a unit can import one
51
+ * framework without the other, and merging would let a JPA-only file's
52
+ * `@Document`-shaped lookalike through on JPA's provenance.
53
+ */
54
+ const MONGO_PACKAGES = ["org.springframework.data.mongodb"];
55
+ /**
56
+ * Kotlin types that compile to a JVM primitive **when non-null**. `Long` is
57
+ * `long`; `Long?` boxes to `java.lang.Long`. This is `adapter-java`'s
58
+ * `primitive` field, derived from Kotlin's own type rather than from a
59
+ * keyword.
60
+ */
61
+ const JVM_PRIMITIVES = new Set(["Byte", "Short", "Int", "Long", "Float", "Double", "Boolean", "Char"]);
62
+ const namedChildren = (node) => {
63
+ const out = [];
64
+ for (let i = 0; i < node.namedChildCount; i += 1) {
65
+ const child = node.namedChild(i);
66
+ if (child !== null)
67
+ out.push(child);
68
+ }
69
+ return out;
70
+ };
71
+ const firstOfType = (node, type) => namedChildren(node).find((child) => child.type === type);
72
+ const lineOf = (node) => node.startPosition.row + 1;
73
+ /** A plain string literal's content, or `undefined` for anything else (interpolation included). */
74
+ function stringValueOf(node) {
75
+ if (node === undefined || node.type !== "string_literal")
76
+ return undefined;
77
+ let content = "";
78
+ for (const child of namedChildren(node)) {
79
+ if (child.type !== "string_content")
80
+ return undefined;
81
+ content += child.text;
82
+ }
83
+ return content;
84
+ }
85
+ /** Every annotation on a declaration's own `modifiers` block. */
86
+ function annotationsOf(node) {
87
+ const block = firstOfType(node, "modifiers");
88
+ if (block === undefined)
89
+ return [];
90
+ const out = [];
91
+ for (const child of namedChildren(block)) {
92
+ if (child.type !== "annotation")
93
+ continue;
94
+ // `use_site_target` sits before the type, so both lookups skip past it.
95
+ const invocation = firstOfType(child, "constructor_invocation");
96
+ const userType = invocation === undefined ? firstOfType(child, "user_type") : firstOfType(invocation, "user_type");
97
+ const name = userType === undefined ? undefined : firstOfType(userType, "type_identifier")?.text;
98
+ if (name === undefined)
99
+ continue;
100
+ const rawArguments = [];
101
+ const stringValues = [];
102
+ const valueArgs = invocation === undefined ? undefined : firstOfType(invocation, "value_arguments");
103
+ for (const va of valueArgs === undefined ? [] : namedChildren(valueArgs)) {
104
+ if (va.type !== "value_argument")
105
+ continue;
106
+ rawArguments.push(va.text);
107
+ const parts = namedChildren(va);
108
+ const isNamed = parts.length === 2 && parts[0]?.type === "simple_identifier";
109
+ const argName = isNamed ? parts[0]?.text : undefined;
110
+ const value = stringValueOf(isNamed ? parts[1] : parts[0]);
111
+ if (value === undefined)
112
+ continue;
113
+ if (argName === undefined || argName === "name" || argName === "collection")
114
+ stringValues.push(value);
115
+ }
116
+ out.push({ name, rawArguments, stringValues });
117
+ }
118
+ return out;
119
+ }
120
+ function typeOf(node) {
121
+ if (node === undefined)
122
+ return { name: undefined, nullable: false };
123
+ if (node.type === "nullable_type") {
124
+ const inner = typeOf(namedChildren(node).find((c) => c.type !== "type_modifiers"));
125
+ return { name: inner.name, nullable: true };
126
+ }
127
+ if (node.type === "user_type")
128
+ return { name: firstOfType(node, "type_identifier")?.text, nullable: false };
129
+ if (node.type === "function_type" || node.type === "parenthesized_type")
130
+ return { name: node.type, nullable: false };
131
+ return { name: undefined, nullable: false };
132
+ }
133
+ const TYPE_NODES = new Set(["user_type", "nullable_type", "function_type", "parenthesized_type"]);
134
+ function propertyFrom(name, typeNode, owner, extras) {
135
+ const annotations = annotationsOf(owner);
136
+ const column = annotations.find((a) => a.name === "Column");
137
+ const { name: writtenType, nullable } = typeOf(typeNode);
138
+ return {
139
+ name,
140
+ annotations: annotations.map((a) => a.name),
141
+ columnNullable: column === undefined ? undefined : declaredNullable(column),
142
+ writtenType,
143
+ nullableType: nullable,
144
+ ...extras,
145
+ };
146
+ }
147
+ /**
148
+ * `nullable = false` read from the raw argument text, the same treatment
149
+ * `adapter-java` gives it: a boolean is not a string literal, so it does not
150
+ * reach the literal list, and the parse does not special-case a framework's
151
+ * vocabulary.
152
+ */
153
+ function declaredNullable(column) {
154
+ for (const raw of column.rawArguments) {
155
+ const match = /^\s*nullable\s*=\s*(.+?)\s*$/s.exec(raw);
156
+ if (match === null)
157
+ continue;
158
+ const value = match[1];
159
+ if (value === "false")
160
+ return false;
161
+ if (value === "true")
162
+ return true;
163
+ return null;
164
+ }
165
+ return undefined;
166
+ }
167
+ /** Properties declared in the primary constructor — `val`/`var` only. */
168
+ function constructorProperties(decl) {
169
+ const ctor = firstOfType(decl, "primary_constructor");
170
+ if (ctor === undefined)
171
+ return [];
172
+ const out = [];
173
+ for (const param of namedChildren(ctor)) {
174
+ if (param.type !== "class_parameter")
175
+ continue;
176
+ // No `val`/`var` means this is a constructor argument, not a property,
177
+ // and JPA persists no such thing.
178
+ if (firstOfType(param, "binding_pattern_kind") === undefined)
179
+ continue;
180
+ const name = firstOfType(param, "simple_identifier")?.text;
181
+ if (name === undefined)
182
+ continue;
183
+ const typeNode = namedChildren(param).find((c) => TYPE_NODES.has(c.type));
184
+ out.push(propertyFrom(name, typeNode, param, { hasAccessor: false, delegated: false }));
185
+ }
186
+ return out;
187
+ }
188
+ /** Properties declared in the class body. A `companion_object`'s own are not this class's. */
189
+ function bodyProperties(decl) {
190
+ const body = namedChildren(decl).find((c) => c.type === "class_body" || c.type === "enum_class_body");
191
+ if (body === undefined)
192
+ return [];
193
+ const out = [];
194
+ for (const child of namedChildren(body)) {
195
+ if (child.type !== "property_declaration")
196
+ continue;
197
+ const variable = firstOfType(child, "variable_declaration");
198
+ if (variable === undefined)
199
+ continue;
200
+ const name = firstOfType(variable, "simple_identifier")?.text;
201
+ if (name === undefined)
202
+ continue;
203
+ const typeNode = namedChildren(variable).find((c) => TYPE_NODES.has(c.type));
204
+ const kids = namedChildren(child);
205
+ out.push(propertyFrom(name, typeNode, child, {
206
+ hasAccessor: kids.some((c) => c.type === "getter" || c.type === "setter"),
207
+ delegated: kids.some((c) => c.type === "property_delegate"),
208
+ }));
209
+ }
210
+ return out;
211
+ }
212
+ /** The mapped table or collection, or `null` when only a naming strategy would say. */
213
+ function tableOf(annotations) {
214
+ const table = annotations.find((a) => a.name === "Table") ?? annotations.find((a) => a.name === "Document");
215
+ if (table === undefined)
216
+ return null;
217
+ return table.stringValues[0] ?? null;
218
+ }
219
+ /**
220
+ * Does this unit import a persistence framework? Provenance rule, ported
221
+ * unchanged: a class annotated `@Entity`/`@Document` in a file importing no
222
+ * persistence package is not an entity of it — both names are common enough
223
+ * to have lookalikes elsewhere.
224
+ */
225
+ function importsPersistenceFramework(imports) {
226
+ const packages = [...JPA_PACKAGES, ...MONGO_PACKAGES];
227
+ return imports.some((each) => each.isWildcard ? packages.includes(each.path) : packages.some((pkg) => each.path.startsWith(`${pkg}.`)));
228
+ }
229
+ const CLASS_NODES = new Set(["class_declaration", "object_declaration"]);
230
+ /**
231
+ * Every persistence-annotated declaration in this file, read while the tree is
232
+ * alive. `adapter.ts` deletes the tree immediately after `readKotlinFile`, so
233
+ * this runs there and everything downstream works from the result.
234
+ */
235
+ export function readJpaDeclarations(root, imports) {
236
+ if (!importsPersistenceFramework(imports))
237
+ return [];
238
+ const out = [];
239
+ const walk = (node, owners) => {
240
+ for (const child of namedChildren(node)) {
241
+ if (!CLASS_NODES.has(child.type)) {
242
+ if (child.namedChildCount > 0)
243
+ walk(child, owners);
244
+ continue;
245
+ }
246
+ const name = firstOfType(child, "type_identifier")?.text;
247
+ if (name === undefined)
248
+ continue;
249
+ const annotations = annotationsOf(child);
250
+ // The one invoked supertype. Kotlin forbids invoking an interface, so
251
+ // "invoked" is not a prior here the way `parse.ts` treats it for
252
+ // `INHERITS`/`IMPLEMENTS` — it is the answer.
253
+ let superclass;
254
+ for (const spec of namedChildren(child)) {
255
+ if (spec.type !== "delegation_specifier")
256
+ continue;
257
+ const invocation = firstOfType(spec, "constructor_invocation");
258
+ if (invocation === undefined)
259
+ continue;
260
+ superclass = firstOfType(firstOfType(invocation, "user_type") ?? invocation, "type_identifier")?.text;
261
+ }
262
+ out.push({
263
+ name,
264
+ owners,
265
+ annotations: annotations.map((a) => a.name),
266
+ table: tableOf(annotations),
267
+ properties: [...constructorProperties(child), ...bodyProperties(child)],
268
+ superclass,
269
+ startLine: lineOf(child),
270
+ endLine: child.endPosition.row + 1,
271
+ });
272
+ const body = namedChildren(child).find((c) => c.type === "class_body" || c.type === "enum_class_body");
273
+ if (body !== undefined)
274
+ walk(body, [...owners, name]);
275
+ }
276
+ };
277
+ walk(root, []);
278
+ return out;
279
+ }
280
+ const has = (decl, name) => decl.annotations.includes(name);
281
+ const isEntity = (decl) => (has(decl, "Entity") || has(decl, "Document")) && !has(decl, "Embeddable") && !has(decl, "MappedSuperclass");
282
+ /**
283
+ * The columns an entity inherits, deepest ancestor first, or a refusal.
284
+ * `@MappedSuperclass` ancestors contribute; a plain open class contributes
285
+ * nothing itself but may extend one that does; an `@Entity` ancestor is a JPA
286
+ * inheritance strategy this cannot read (E2); an unresolvable one leaves the
287
+ * set unprovable (E1).
288
+ */
289
+ function inherited(decl, unit, resolve) {
290
+ const chain = [];
291
+ const seen = new Set([`${unit.packageName}::${[...decl.owners, decl.name].join(".")}`]);
292
+ let current = { declaration: decl, unit };
293
+ for (;;) {
294
+ const written = current.declaration.superclass;
295
+ if (written === undefined)
296
+ return { fields: chain };
297
+ const parent = resolve(written, current.unit);
298
+ if (parent === undefined) {
299
+ return {
300
+ refusal: `the superclass \`${written}\` is not declared in this batch, so the columns it contributes ` +
301
+ "cannot be enumerated and the column set cannot be shown complete. The shape is withheld " +
302
+ "rather than reported as a complete list that is missing rows.",
303
+ };
304
+ }
305
+ const key = `${parent.unit.packageName}::${[...parent.declaration.owners, parent.declaration.name].join(".")}`;
306
+ if (seen.has(key))
307
+ return { fields: chain };
308
+ seen.add(key);
309
+ if (has(parent.declaration, "Entity") || has(parent.declaration, "Document")) {
310
+ return {
311
+ refusal: `the superclass \`${written}\` is itself an @Entity, so a JPA inheritance strategy ` +
312
+ "(single-table, joined, table-per-class) decides where each column lives and no source file " +
313
+ "here states which. Refused rather than guessed.",
314
+ };
315
+ }
316
+ // Deepest ancestor first, so the base id leads the list. Deterministic.
317
+ if (has(parent.declaration, "MappedSuperclass"))
318
+ chain.unshift(...parent.declaration.properties);
319
+ current = parent;
320
+ }
321
+ }
322
+ /** Every JPA entity this unit declares, plus every shape it refused and why. */
323
+ export function jpaModels(unit, resolve) {
324
+ const models = [];
325
+ const refusals = [];
326
+ for (const decl of unit.jpaDeclarations) {
327
+ if (!isEntity(decl))
328
+ continue;
329
+ // E4 — a discriminator column is a real column declared by no property.
330
+ const strategy = decl.annotations.find((a) => a === "Inheritance" || a === "DiscriminatorColumn");
331
+ if (strategy !== undefined) {
332
+ refusals.push({
333
+ className: decl.name,
334
+ reason: `@${strategy} puts a discriminator column on this table that no property declares, so the ` +
335
+ "properties are not the complete column set. The shape is withheld.",
336
+ });
337
+ continue;
338
+ }
339
+ const up = inherited(decl, unit, resolve);
340
+ if ("refusal" in up) {
341
+ refusals.push({ className: decl.name, reason: up.refusal });
342
+ continue;
343
+ }
344
+ // A subclass's own declaration wins over an inherited one.
345
+ const own = new Set(decl.properties.map((p) => p.name));
346
+ const all = [...up.fields.filter((p) => !own.has(p.name)), ...decl.properties];
347
+ // E3 — an embeddable's columns flatten into this table and this reader
348
+ // enumerates none of them. Checked over the WHOLE set, inherited included.
349
+ const embedded = all.find((p) => p.annotations.includes("Embedded") || p.annotations.includes("EmbeddedId"));
350
+ if (embedded !== undefined) {
351
+ refusals.push({
352
+ className: decl.name,
353
+ reason: `\`${embedded.name}\` is @Embedded, so the embeddable's own columns flatten into this table. ` +
354
+ "This reader enumerates one property where the table carries several, which would read as a " +
355
+ "complete column set and is not. The shape is withheld.",
356
+ });
357
+ continue;
358
+ }
359
+ const fields = [];
360
+ const undecided = [];
361
+ for (const property of all) {
362
+ if (property.annotations.includes("Transient"))
363
+ continue;
364
+ // Not decidable, and listed rather than guessed or dropped.
365
+ if (property.columnNullable === null) {
366
+ undecided.push(property.name);
367
+ continue;
368
+ }
369
+ if (property.delegated || property.hasAccessor || property.writtenType === undefined) {
370
+ undecided.push(property.name);
371
+ continue;
372
+ }
373
+ let nullable;
374
+ let nullableFrom;
375
+ if (property.columnNullable !== undefined) {
376
+ nullable = property.columnNullable;
377
+ nullableFrom = "declared";
378
+ }
379
+ else if (property.annotations.includes("Id") || property.annotations.includes("NotNull")) {
380
+ nullable = false;
381
+ nullableFrom = "annotation";
382
+ }
383
+ else if (!property.nullableType && JVM_PRIMITIVES.has(property.writtenType)) {
384
+ // Non-null `Long` is JVM `long` and cannot hold null; `Long?` boxes.
385
+ // Java's rule 4, in Kotlin's spelling.
386
+ nullable = false;
387
+ nullableFrom = "primitive-type";
388
+ }
389
+ else if (property.nullableType) {
390
+ // Stated nullable. Same boolean the framework default would give, and
391
+ // a different fact: the source says so.
392
+ nullable = true;
393
+ nullableFrom = "declared-type";
394
+ }
395
+ else {
396
+ nullable = true;
397
+ nullableFrom = "framework-default";
398
+ }
399
+ fields.push({ name: property.name, nullable, nullableFrom });
400
+ }
401
+ // A MODEL with nothing readable would claim a table it cannot describe.
402
+ if (fields.length === 0 && undecided.length === 0)
403
+ continue;
404
+ models.push({
405
+ className: decl.name,
406
+ owners: decl.owners,
407
+ table: decl.table,
408
+ fields,
409
+ line: decl.startLine,
410
+ undecided,
411
+ });
412
+ }
413
+ return { models, refusals };
414
+ }
415
+ //# sourceMappingURL=jpa.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jpa.js","sourceRoot":"","sources":["../src/jpa.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAMH,MAAM,YAAY,GAAG,CAAC,qBAAqB,EAAE,mBAAmB,CAAC,CAAC;AAElE;;;;;GAKG;A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