@webda/content-mapper 0.0.0-stage → 4.0.0-beta.5
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/LICENSE +166 -0
- package/lib/coercions.d.ts +22 -0
- package/lib/coercions.d.ts.map +1 -0
- package/lib/coercions.js +10 -0
- package/lib/coercions.js.map +1 -0
- package/lib/context.d.ts +56 -0
- package/lib/context.d.ts.map +1 -0
- package/lib/context.js +111 -0
- package/lib/context.js.map +1 -0
- package/lib/defaults.d.ts +31 -0
- package/lib/defaults.d.ts.map +1 -0
- package/lib/defaults.js +33 -0
- package/lib/defaults.js.map +1 -0
- package/lib/generators/accessors.d.ts +15 -0
- package/lib/generators/accessors.d.ts.map +1 -0
- package/lib/generators/accessors.js +567 -0
- package/lib/generators/accessors.js.map +1 -0
- package/lib/generators/behaviors.d.ts +21 -0
- package/lib/generators/behaviors.d.ts.map +1 -0
- package/lib/generators/behaviors.js +292 -0
- package/lib/generators/behaviors.js.map +1 -0
- package/lib/generators/imports.d.ts +86 -0
- package/lib/generators/imports.d.ts.map +1 -0
- package/lib/generators/imports.js +205 -0
- package/lib/generators/imports.js.map +1 -0
- package/lib/generators/loadparameters.d.ts +7 -0
- package/lib/generators/loadparameters.d.ts.map +1 -0
- package/lib/generators/loadparameters.js +175 -0
- package/lib/generators/loadparameters.js.map +1 -0
- package/lib/generators/qlvalidator.d.ts +53 -0
- package/lib/generators/qlvalidator.d.ts.map +1 -0
- package/lib/generators/qlvalidator.js +238 -0
- package/lib/generators/qlvalidator.js.map +1 -0
- package/lib/index.d.ts +53 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +36 -0
- package/lib/index.js.map +1 -0
- package/lib/module-discovery.d.ts +211 -0
- package/lib/module-discovery.d.ts.map +1 -0
- package/lib/module-discovery.js +662 -0
- package/lib/module-discovery.js.map +1 -0
- package/lib/module.d.ts +213 -0
- package/lib/module.d.ts.map +1 -0
- package/lib/module.js +1243 -0
- package/lib/module.js.map +1 -0
- package/lib/plan.d.ts +101 -0
- package/lib/plan.d.ts.map +1 -0
- package/lib/plan.js +61 -0
- package/lib/plan.js.map +1 -0
- package/lib/property-order.d.ts +37 -0
- package/lib/property-order.d.ts.map +1 -0
- package/lib/property-order.js +141 -0
- package/lib/property-order.js.map +1 -0
- package/lib/schema/action.d.ts +46 -0
- package/lib/schema/action.d.ts.map +1 -0
- package/lib/schema/action.js +190 -0
- package/lib/schema/action.js.map +1 -0
- package/lib/schema/annotations.d.ts +63 -0
- package/lib/schema/annotations.d.ts.map +1 -0
- package/lib/schema/annotations.js +116 -0
- package/lib/schema/annotations.js.map +1 -0
- package/lib/schema/converter.d.ts +363 -0
- package/lib/schema/converter.d.ts.map +1 -0
- package/lib/schema/converter.js +1377 -0
- package/lib/schema/converter.js.map +1 -0
- package/lib/schema/jsdoc.d.ts +34 -0
- package/lib/schema/jsdoc.d.ts.map +1 -0
- package/lib/schema/jsdoc.js +206 -0
- package/lib/schema/jsdoc.js.map +1 -0
- package/lib/schema/model.d.ts +27 -0
- package/lib/schema/model.d.ts.map +1 -0
- package/lib/schema/model.js +86 -0
- package/lib/schema/model.js.map +1 -0
- package/lib/schema/project.d.ts +34 -0
- package/lib/schema/project.d.ts.map +1 -0
- package/lib/schema/project.js +305 -0
- package/lib/schema/project.js.map +1 -0
- package/lib/schema/service.d.ts +62 -0
- package/lib/schema/service.d.ts.map +1 -0
- package/lib/schema/service.js +130 -0
- package/lib/schema/service.js.map +1 -0
- package/lib/schema/types.d.ts +61 -0
- package/lib/schema/types.d.ts.map +1 -0
- package/lib/schema/types.js +36 -0
- package/lib/schema/types.js.map +1 -0
- package/lib/schema/worker-cli.d.ts +3 -0
- package/lib/schema/worker-cli.d.ts.map +1 -0
- package/lib/schema/worker-cli.js +7 -0
- package/lib/schema/worker-cli.js.map +1 -0
- package/lib/schema/worker.d.ts +81 -0
- package/lib/schema/worker.d.ts.map +1 -0
- package/lib/schema/worker.js +186 -0
- package/lib/schema/worker.js.map +1 -0
- package/lib/server.d.ts +2 -0
- package/lib/server.d.ts.map +1 -0
- package/lib/server.js +133 -0
- package/lib/server.js.map +1 -0
- package/lib/session.d.ts +84 -0
- package/lib/session.d.ts.map +1 -0
- package/lib/session.js +141 -0
- package/lib/session.js.map +1 -0
- package/lib/spans.d.ts +46 -0
- package/lib/spans.d.ts.map +1 -0
- package/lib/spans.js +64 -0
- package/lib/spans.js.map +1 -0
- package/lib/twopass.d.ts +45 -0
- package/lib/twopass.d.ts.map +1 -0
- package/lib/twopass.js +87 -0
- package/lib/twopass.js.map +1 -0
- package/lib/vite.d.ts +20 -0
- package/lib/vite.d.ts.map +1 -0
- package/lib/vite.js +41 -0
- package/lib/vite.js.map +1 -0
- package/package.json +93 -3
- package/README.md +0 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
|
2
|
+
Version 3, 29 June 2007
|
|
3
|
+
|
|
4
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
|
5
|
+
Everyone is permitted to copy and distribute verbatim copies
|
|
6
|
+
of this license document, but changing it is not allowed.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
This version of the GNU Lesser General Public License incorporates
|
|
10
|
+
the terms and conditions of version 3 of the GNU General Public
|
|
11
|
+
License, supplemented by the additional permissions listed below.
|
|
12
|
+
|
|
13
|
+
0. Additional Definitions.
|
|
14
|
+
|
|
15
|
+
As used herein, "this License" refers to version 3 of the GNU Lesser
|
|
16
|
+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
|
17
|
+
General Public License.
|
|
18
|
+
|
|
19
|
+
"The Library" refers to a covered work governed by this License,
|
|
20
|
+
other than an Application or a Combined Work as defined below.
|
|
21
|
+
|
|
22
|
+
An "Application" is any work that makes use of an interface provided
|
|
23
|
+
by the Library, but which is not otherwise based on the Library.
|
|
24
|
+
Defining a subclass of a class defined by the Library is deemed a mode
|
|
25
|
+
of using an interface provided by the Library.
|
|
26
|
+
|
|
27
|
+
A "Combined Work" is a work produced by combining or linking an
|
|
28
|
+
Application with the Library. The particular version of the Library
|
|
29
|
+
with which the Combined Work was made is also called the "Linked
|
|
30
|
+
Version".
|
|
31
|
+
|
|
32
|
+
The "Minimal Corresponding Source" for a Combined Work means the
|
|
33
|
+
Corresponding Source for the Combined Work, excluding any source code
|
|
34
|
+
for portions of the Combined Work that, considered in isolation, are
|
|
35
|
+
based on the Application, and not on the Linked Version.
|
|
36
|
+
|
|
37
|
+
The "Corresponding Application Code" for a Combined Work means the
|
|
38
|
+
object code and/or source code for the Application, including any data
|
|
39
|
+
and utility programs needed for reproducing the Combined Work from the
|
|
40
|
+
Application, but excluding the System Libraries of the Combined Work.
|
|
41
|
+
|
|
42
|
+
1. Exception to Section 3 of the GNU GPL.
|
|
43
|
+
|
|
44
|
+
You may convey a covered work under sections 3 and 4 of this License
|
|
45
|
+
without being bound by section 3 of the GNU GPL.
|
|
46
|
+
|
|
47
|
+
2. Conveying Modified Versions.
|
|
48
|
+
|
|
49
|
+
If you modify a copy of the Library, and, in your modifications, a
|
|
50
|
+
facility refers to a function or data to be supplied by an Application
|
|
51
|
+
that uses the facility (other than as an argument passed when the
|
|
52
|
+
facility is invoked), then you may convey a copy of the modified
|
|
53
|
+
version:
|
|
54
|
+
|
|
55
|
+
a) under this License, provided that you make a good faith effort to
|
|
56
|
+
ensure that, in the event an Application does not supply the
|
|
57
|
+
function or data, the facility still operates, and performs
|
|
58
|
+
whatever part of its purpose remains meaningful, or
|
|
59
|
+
|
|
60
|
+
b) under the GNU GPL, with none of the additional permissions of
|
|
61
|
+
this License applicable to that copy.
|
|
62
|
+
|
|
63
|
+
3. Object Code Incorporating Material from Library Header Files.
|
|
64
|
+
|
|
65
|
+
The object code form of an Application may incorporate material from
|
|
66
|
+
a header file that is part of the Library. You may convey such object
|
|
67
|
+
code under terms of your choice, provided that, if the incorporated
|
|
68
|
+
material is not limited to numerical parameters, data structure
|
|
69
|
+
layouts and accessors, or small macros, inline functions and templates
|
|
70
|
+
(ten or fewer lines in length), you do both of the following:
|
|
71
|
+
|
|
72
|
+
a) Give prominent notice with each copy of the object code that the
|
|
73
|
+
Library is used in it and that the Library and its use are
|
|
74
|
+
covered by this License.
|
|
75
|
+
|
|
76
|
+
b) Accompany the object code with a copy of the GNU GPL and this license
|
|
77
|
+
document.
|
|
78
|
+
|
|
79
|
+
4. Combined Works.
|
|
80
|
+
|
|
81
|
+
You may convey a Combined Work under terms of your choice that,
|
|
82
|
+
taken together, effectively do not restrict modification of the
|
|
83
|
+
portions of the Library contained in the Combined Work and reverse
|
|
84
|
+
engineering for debugging such modifications, if you also do each of
|
|
85
|
+
the following:
|
|
86
|
+
|
|
87
|
+
a) Give prominent notice with each copy of the Combined Work that
|
|
88
|
+
the Library is used in it and that the Library and its use are
|
|
89
|
+
covered by this License.
|
|
90
|
+
|
|
91
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
|
92
|
+
document.
|
|
93
|
+
|
|
94
|
+
c) For a Combined Work that displays copyright notices during
|
|
95
|
+
execution, include the copyright notice for the Library among
|
|
96
|
+
these notices, as well as a reference directing the user to the
|
|
97
|
+
copies of the GNU GPL and this license document.
|
|
98
|
+
|
|
99
|
+
d) Do one of the following:
|
|
100
|
+
|
|
101
|
+
0) Convey the Minimal Corresponding Source under the terms of this
|
|
102
|
+
License, and the Corresponding Application Code in a form
|
|
103
|
+
suitable for, and under terms that permit, the user to
|
|
104
|
+
recombine or relink the Application with a modified version of
|
|
105
|
+
the Linked Version to produce a modified Combined Work, in the
|
|
106
|
+
manner specified by section 6 of the GNU GPL for conveying
|
|
107
|
+
Corresponding Source.
|
|
108
|
+
|
|
109
|
+
1) Use a suitable shared library mechanism for linking with the
|
|
110
|
+
Library. A suitable mechanism is one that (a) uses at run time
|
|
111
|
+
a copy of the Library already present on the user's computer
|
|
112
|
+
system, and (b) will operate properly with a modified version
|
|
113
|
+
of the Library that is interface-compatible with the Linked
|
|
114
|
+
Version.
|
|
115
|
+
|
|
116
|
+
e) Provide Installation Information, but only if you would otherwise
|
|
117
|
+
be required to provide such information under section 6 of the
|
|
118
|
+
GNU GPL, and only to the extent that such information is
|
|
119
|
+
necessary to install and execute a modified version of the
|
|
120
|
+
Combined Work produced by recombining or relinking the
|
|
121
|
+
Application with a modified version of the Linked Version. (If
|
|
122
|
+
you use option 4d0, the Installation Information must accompany
|
|
123
|
+
the Minimal Corresponding Source and Corresponding Application
|
|
124
|
+
Code. If you use option 4d1, you must provide the Installation
|
|
125
|
+
Information in the manner specified by section 6 of the GNU GPL
|
|
126
|
+
for conveying Corresponding Source.)
|
|
127
|
+
|
|
128
|
+
5. Combined Libraries.
|
|
129
|
+
|
|
130
|
+
You may place library facilities that are a work based on the
|
|
131
|
+
Library side by side in a single library together with other library
|
|
132
|
+
facilities that are not Applications and are not covered by this
|
|
133
|
+
License, and convey such a combined library under terms of your
|
|
134
|
+
choice, if you do both of the following:
|
|
135
|
+
|
|
136
|
+
a) Accompany the combined library with a copy of the same work based
|
|
137
|
+
on the Library, uncombined with any other library facilities,
|
|
138
|
+
conveyed under the terms of this License.
|
|
139
|
+
|
|
140
|
+
b) Give prominent notice with the combined library that part of it
|
|
141
|
+
is a work based on the Library, and explaining where to find the
|
|
142
|
+
accompanying uncombined form of the same work.
|
|
143
|
+
|
|
144
|
+
6. Revised Versions of the GNU Lesser General Public License.
|
|
145
|
+
|
|
146
|
+
The Free Software Foundation may publish revised and/or new versions
|
|
147
|
+
of the GNU Lesser General Public License from time to time. Such new
|
|
148
|
+
versions will be similar in spirit to the present version, but may
|
|
149
|
+
differ in detail to address new problems or concerns.
|
|
150
|
+
|
|
151
|
+
Each version is given a distinguishing version number. If the
|
|
152
|
+
Library as you received it specifies that a certain numbered version
|
|
153
|
+
of the GNU Lesser General Public License "or any later version"
|
|
154
|
+
applies to it, you have the option of following the terms and
|
|
155
|
+
conditions either of that published version or of any later version
|
|
156
|
+
published by the Free Software Foundation. If the Library as you
|
|
157
|
+
received it does not specify a version number of the GNU Lesser
|
|
158
|
+
General Public License, you may choose any version of the GNU Lesser
|
|
159
|
+
General Public License ever published by the Free Software Foundation.
|
|
160
|
+
|
|
161
|
+
If the Library as you received it specifies that a proxy can decide
|
|
162
|
+
whether future versions of the GNU Lesser General Public License shall
|
|
163
|
+
apply, that proxy's public statement of acceptance of any version is
|
|
164
|
+
permanent authorization for you to choose that version for the
|
|
165
|
+
Library.
|
|
166
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Defines the widened setter type for a coercible property type.
|
|
3
|
+
*
|
|
4
|
+
* When the compiler's morpher transforms `createdAt: Date` into a getter/setter pair,
|
|
5
|
+
* the setter accepts `string | number | Date`. This registry tells the language service
|
|
6
|
+
* plugin which types get this treatment, so the IDE can:
|
|
7
|
+
* - Show the widened setter type on hover
|
|
8
|
+
* - Suppress false TS2322 errors when assigning e.g. a string to a Date field
|
|
9
|
+
*
|
|
10
|
+
* This mirrors the COERCION_REGISTRY in @webda/compiler's accessors.ts.
|
|
11
|
+
*/
|
|
12
|
+
export interface CoercionRule {
|
|
13
|
+
/** The wider type accepted by the setter (e.g. "string | number | Date" for Date fields). */
|
|
14
|
+
setterType: string;
|
|
15
|
+
}
|
|
16
|
+
export type CoercionRegistry = Record<string, CoercionRule>;
|
|
17
|
+
/**
|
|
18
|
+
* Default coercion rules matching @webda/compiler's COERCION_REGISTRY.
|
|
19
|
+
* Extend via the plugin config in tsconfig.json.
|
|
20
|
+
*/
|
|
21
|
+
export declare const DEFAULT_COERCIONS: CoercionRegistry;
|
|
22
|
+
//# sourceMappingURL=coercions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coercions.d.ts","sourceRoot":"","sources":["../src/coercions.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,MAAM,WAAW,YAAY;IAC3B,6FAA6F;IAC7F,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;AAE5D;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,gBAI/B,CAAC"}
|
package/lib/coercions.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default coercion rules matching @webda/compiler's COERCION_REGISTRY.
|
|
3
|
+
* Extend via the plugin config in tsconfig.json.
|
|
4
|
+
*/
|
|
5
|
+
export const DEFAULT_COERCIONS = {
|
|
6
|
+
Date: {
|
|
7
|
+
setterType: "string | number | Date"
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=coercions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coercions.js","sourceRoot":"","sources":["../src/coercions.ts"],"names":[],"mappings":"AAoBA;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAqB;IACjD,IAAI,EAAE;QACJ,UAAU,EAAE,wBAAwB;KACrC;CACF,CAAC"}
|
package/lib/context.d.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { Node, SourceFile } from "typescript/unstable/ast";
|
|
2
|
+
import type { AnalysisContext } from "./plan.ts";
|
|
3
|
+
/**
|
|
4
|
+
* Read a node's source text, skipping leading trivia.
|
|
5
|
+
* @param sf - containing source file
|
|
6
|
+
* @param node - the node
|
|
7
|
+
* @returns exact source text
|
|
8
|
+
*/
|
|
9
|
+
export declare function textOf(sf: SourceFile, node: Node): string;
|
|
10
|
+
/**
|
|
11
|
+
* Read a node's leading trivia (comments), used to find JSDoc tags. The TS7 AST
|
|
12
|
+
* package exposes no `getJSDocTags` helper, so tags are matched on trivia text.
|
|
13
|
+
* @param sf - containing source file
|
|
14
|
+
* @param node - the node
|
|
15
|
+
* @returns raw trivia text
|
|
16
|
+
*/
|
|
17
|
+
export declare function triviaOf(sf: SourceFile, node: Node): string;
|
|
18
|
+
/**
|
|
19
|
+
* Names appearing in a class's `extends` clause.
|
|
20
|
+
* @param sf - containing source file
|
|
21
|
+
* @param cls - class declaration
|
|
22
|
+
* @returns base class names, usually one
|
|
23
|
+
*/
|
|
24
|
+
export declare function baseNames(sf: SourceFile, cls: any): string[];
|
|
25
|
+
/** A live analysis session; dispose to shut down the server process. */
|
|
26
|
+
export interface Session {
|
|
27
|
+
ctx: AnalysisContext;
|
|
28
|
+
dispose(): void;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Open a project and build an analysis context over it.
|
|
32
|
+
* @param configFile - absolute tsconfig path
|
|
33
|
+
* @param rootDir - source root; only files beneath it are analysed
|
|
34
|
+
* @param fs - optional virtual filesystem callbacks (used by pass 2)
|
|
35
|
+
* @returns the session
|
|
36
|
+
*/
|
|
37
|
+
export declare function openSession(configFile: string, rootDir: string, fs?: any): Session;
|
|
38
|
+
/**
|
|
39
|
+
* Iterate class declarations in a source file.
|
|
40
|
+
* @param sf - the source file
|
|
41
|
+
* @returns class declarations
|
|
42
|
+
*/
|
|
43
|
+
export declare function classesOf(sf: SourceFile): any[];
|
|
44
|
+
/**
|
|
45
|
+
* Member name as written, or undefined for computed names.
|
|
46
|
+
* @param member - a class element
|
|
47
|
+
* @returns the member name
|
|
48
|
+
*/
|
|
49
|
+
export declare function memberName(member: any): string | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* Whether a class element carries the `static` modifier.
|
|
52
|
+
* @param member - a class element
|
|
53
|
+
* @returns true when static
|
|
54
|
+
*/
|
|
55
|
+
export declare function isStatic(member: any): boolean;
|
|
56
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAEjD;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,GAAG,MAAM,CAGzD;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,GAAG,MAAM,CAG3D;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,GAAG,GAAG,MAAM,EAAE,CAW5D;AAED,wEAAwE;AACxE,MAAM,WAAW,OAAO;IACtB,GAAG,EAAE,eAAe,CAAC;IACrB,OAAO,IAAI,IAAI,CAAC;CACjB;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,GAAG,GAAG,OAAO,CAyBlF;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,EAAE,EAAE,UAAU,GAAG,GAAG,EAAE,CAE/C;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,GAAG,GAAG,MAAM,GAAG,SAAS,CAE1D;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,GAAG,GAAG,OAAO,CAG7C"}
|
package/lib/context.js
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds the typed {@link AnalysisContext} for pass 1.
|
|
3
|
+
*
|
|
4
|
+
* This is the part the scanner-based prototype could not do. Detecting the
|
|
5
|
+
* dominant coercion kinds in this codebase — `ManyToOne` -> `ModelLink` with a
|
|
6
|
+
* `@WebdaAutoSetter` `set`, and `OneToMany` -> `ModelRelated` — requires
|
|
7
|
+
* following type aliases through the checker. Roughly 100 such declarations
|
|
8
|
+
* exist in `the packages source tree` versus ~4 plain `Date` fields, so a syntactic pass
|
|
9
|
+
* covers the rare case and misses the common one.
|
|
10
|
+
*/
|
|
11
|
+
import { API } from "typescript/unstable/sync";
|
|
12
|
+
import * as is from "typescript/unstable/ast/is";
|
|
13
|
+
/**
|
|
14
|
+
* Read a node's source text, skipping leading trivia.
|
|
15
|
+
* @param sf - containing source file
|
|
16
|
+
* @param node - the node
|
|
17
|
+
* @returns exact source text
|
|
18
|
+
*/
|
|
19
|
+
export function textOf(sf, node) {
|
|
20
|
+
const start = typeof node.getStart === "function" ? node.getStart() : node.pos;
|
|
21
|
+
return sf.text.slice(start, node.end);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Read a node's leading trivia (comments), used to find JSDoc tags. The TS7 AST
|
|
25
|
+
* package exposes no `getJSDocTags` helper, so tags are matched on trivia text.
|
|
26
|
+
* @param sf - containing source file
|
|
27
|
+
* @param node - the node
|
|
28
|
+
* @returns raw trivia text
|
|
29
|
+
*/
|
|
30
|
+
export function triviaOf(sf, node) {
|
|
31
|
+
const start = typeof node.getStart === "function" ? node.getStart() : node.pos;
|
|
32
|
+
return sf.text.slice(node.pos, start);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Names appearing in a class's `extends` clause.
|
|
36
|
+
* @param sf - containing source file
|
|
37
|
+
* @param cls - class declaration
|
|
38
|
+
* @returns base class names, usually one
|
|
39
|
+
*/
|
|
40
|
+
export function baseNames(sf, cls) {
|
|
41
|
+
const out = [];
|
|
42
|
+
for (const clause of cls.heritageClauses ?? []) {
|
|
43
|
+
// 95 === SyntaxKind.ExtendsKeyword
|
|
44
|
+
if (clause.token !== 95)
|
|
45
|
+
continue;
|
|
46
|
+
for (const t of clause.types) {
|
|
47
|
+
const expr = t.expression ?? t;
|
|
48
|
+
out.push(expr?.text ?? textOf(sf, expr));
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return out;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Open a project and build an analysis context over it.
|
|
55
|
+
* @param configFile - absolute tsconfig path
|
|
56
|
+
* @param rootDir - source root; only files beneath it are analysed
|
|
57
|
+
* @param fs - optional virtual filesystem callbacks (used by pass 2)
|
|
58
|
+
* @returns the session
|
|
59
|
+
*/
|
|
60
|
+
export function openSession(configFile, rootDir, fs) {
|
|
61
|
+
const api = new API({ cwd: rootDir, ...(fs ? { fs } : {}) });
|
|
62
|
+
const snapshot = api.createSnapshot({ openProjects: [configFile] });
|
|
63
|
+
const project = snapshot.getProjects()[0];
|
|
64
|
+
if (!project) {
|
|
65
|
+
api.close();
|
|
66
|
+
throw new Error(`No project loaded for ${configFile}`);
|
|
67
|
+
}
|
|
68
|
+
const program = project.program;
|
|
69
|
+
const checker = project.checker;
|
|
70
|
+
const sourceFiles = [];
|
|
71
|
+
for (const fileName of program.getSourceFileNames()) {
|
|
72
|
+
if (!fileName.startsWith(rootDir))
|
|
73
|
+
continue;
|
|
74
|
+
if (fileName.endsWith(".d.ts"))
|
|
75
|
+
continue;
|
|
76
|
+
const sf = program.getSourceFile(fileName);
|
|
77
|
+
if (sf)
|
|
78
|
+
sourceFiles.push(sf);
|
|
79
|
+
}
|
|
80
|
+
sourceFiles.sort((a, b) => (a.fileName < b.fileName ? -1 : 1));
|
|
81
|
+
return {
|
|
82
|
+
ctx: { project, program, checker, sourceFiles, textOf, triviaOf, baseNames },
|
|
83
|
+
dispose: () => api.close()
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Iterate class declarations in a source file.
|
|
88
|
+
* @param sf - the source file
|
|
89
|
+
* @returns class declarations
|
|
90
|
+
*/
|
|
91
|
+
export function classesOf(sf) {
|
|
92
|
+
return sf.statements.filter(s => is.isClassDeclaration(s) && s.name);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Member name as written, or undefined for computed names.
|
|
96
|
+
* @param member - a class element
|
|
97
|
+
* @returns the member name
|
|
98
|
+
*/
|
|
99
|
+
export function memberName(member) {
|
|
100
|
+
return member?.name?.text;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Whether a class element carries the `static` modifier.
|
|
104
|
+
* @param member - a class element
|
|
105
|
+
* @returns true when static
|
|
106
|
+
*/
|
|
107
|
+
export function isStatic(member) {
|
|
108
|
+
// 125 === SyntaxKind.StaticKeyword
|
|
109
|
+
return !!member.modifiers?.some((m) => m.kind === 125);
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,GAAG,EAA8B,MAAM,0BAA0B,CAAC;AAE3E,OAAO,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAGjD;;;;;GAKG;AACH,MAAM,UAAU,MAAM,CAAC,EAAc,EAAE,IAAU;IAC/C,MAAM,KAAK,GAAG,OAAQ,IAAY,CAAC,QAAQ,KAAK,UAAU,CAAC,CAAC,CAAE,IAAY,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;IACjG,OAAO,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;AACxC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,QAAQ,CAAC,EAAc,EAAE,IAAU;IACjD,MAAM,KAAK,GAAG,OAAQ,IAAY,CAAC,QAAQ,KAAK,UAAU,CAAC,CAAC,CAAE,IAAY,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;IACjG,OAAO,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;AACxC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CAAC,EAAc,EAAE,GAAQ;IAChD,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,KAAK,MAAM,MAAM,IAAI,GAAG,CAAC,eAAe,IAAI,EAAE,EAAE,CAA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mSession}) and the build
|
|
5
|
+
* ({@link runTwoPass}) must produce the same text, or hover and diagnostics
|
|
6
|
+
* describe code that is not the code that ships. Keeping two literal lists
|
|
7
|
+
* equal by hand is exactly how that drifts.
|
|
8
|
+
*
|
|
9
|
+
* `loadParametersGenerator` is deliberately **not** here. Nothing in the
|
|
10
|
+
* framework calls `loadParameters`: a service's parameters are built by
|
|
11
|
+
* `createConfiguration`, which `Application` installs from the
|
|
12
|
+
* `Configuration` entry in `webda.module.json`. The TypeScript 6 pipeline
|
|
13
|
+
* never generated it either — that was `webdac code`, which walked zero
|
|
14
|
+
* files. Generating it would add a dead method to every service and break
|
|
15
|
+
* emit parity with what ships today. It stays exported for callers who
|
|
16
|
+
* still want it.
|
|
17
|
+
*/
|
|
18
|
+
import { type AccessorOptions } from "./generators/accessors.ts";
|
|
19
|
+
import type { Generator } from "./plan.ts";
|
|
20
|
+
/** Options the default generators accept. */
|
|
21
|
+
export interface DefaultGeneratorOptions extends AccessorOptions {
|
|
22
|
+
/** Module specifier providing the WebdaQL `escape` helper. */
|
|
23
|
+
qlModule?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Build the default generator set.
|
|
27
|
+
* @param options - storage and WebdaQL module specifiers
|
|
28
|
+
* @returns the generators, in the order they run
|
|
29
|
+
*/
|
|
30
|
+
export declare function defaultGenerators(options?: DefaultGeneratorOptions): Generator[];
|
|
31
|
+
//# sourceMappingURL=defaults.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../src/defaults.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAsB,KAAK,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAGrF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE3C,6CAA6C;AAC7C,MAAM,WAAW,uBAAwB,SAAQ,eAAe;IAC9D,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,GAAE,uBAA4B,GAAG,SAAS,EAAE,CAMpF"}
|
package/lib/defaults.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The generator set both hosts run by default.
|
|
3
|
+
*
|
|
4
|
+
* One list, not two. The editor ({@link WarmSession}) and the build
|
|
5
|
+
* ({@link runTwoPass}) must produce the same text, or hover and diagnostics
|
|
6
|
+
* describe code that is not the code that ships. Keeping two literal lists
|
|
7
|
+
* equal by hand is exactly how that drifts.
|
|
8
|
+
*
|
|
9
|
+
* `loadParametersGenerator` is deliberately **not** here. Nothing in the
|
|
10
|
+
* framework calls `loadParameters`: a service's parameters are built by
|
|
11
|
+
* `createConfiguration`, which `Application` installs from the
|
|
12
|
+
* `Configuration` entry in `webda.module.json`. The TypeScript 6 pipeline
|
|
13
|
+
* never generated it either — that was `webdac code`, which walked zero
|
|
14
|
+
* files. Generating it would add a dead method to every service and break
|
|
15
|
+
* emit parity with what ships today. It stays exported for callers who
|
|
16
|
+
* still want it.
|
|
17
|
+
*/
|
|
18
|
+
import { accessorsGenerator } from "./generators/accessors.js";
|
|
19
|
+
import { behaviorsGenerator } from "./generators/behaviors.js";
|
|
20
|
+
import { qlValidatorGenerator } from "./generators/qlvalidator.js";
|
|
21
|
+
/**
|
|
22
|
+
* Build the default generator set.
|
|
23
|
+
* @param options - storage and WebdaQL module specifiers
|
|
24
|
+
* @returns the generators, in the order they run
|
|
25
|
+
*/
|
|
26
|
+
export function defaultGenerators(options = {}) {
|
|
27
|
+
return [
|
|
28
|
+
accessorsGenerator({ accessorsForAll: options.accessorsForAll, storageModule: options.storageModule }),
|
|
29
|
+
behaviorsGenerator({ storageModule: options.storageModule }),
|
|
30
|
+
qlValidatorGenerator({ qlModule: options.qlModule })
|
|
31
|
+
];
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=defaults.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaults.js","sourceRoot":"","sources":["../src/defaults.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,kBAAkB,EAAwB,MAAM,2BAA2B,CAAC;AACrF,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AASnE;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAO,GAA4B,EAAE;IACrE,OAAO;QACL,kBAAkB,CAAC,EAAE,eAAe,EAAE,OAAO,CAAC,eAAe,EAAE,aAAa,EAAE,OAAO,CAAC,aAAa,EAAE,CAAC;QACtG,kBAAkB,CAAC,EAAE,aAAa,EAAE,OAAO,CAAC,aAAa,EAAE,CAAC;QAC5D,oBAAoB,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC;KACrD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Generator } from "../plan.ts";
|
|
2
|
+
/** Options for the accessor generator. */
|
|
3
|
+
export interface AccessorOptions {
|
|
4
|
+
/** Treat every class as eligible, not just models. */
|
|
5
|
+
accessorsForAll?: boolean;
|
|
6
|
+
/** Module specifier providing `WEBDA_STORAGE`. */
|
|
7
|
+
storageModule?: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Create the accessor generator.
|
|
11
|
+
* @param options - generator options
|
|
12
|
+
* @returns a generator
|
|
13
|
+
*/
|
|
14
|
+
export declare function accessorsGenerator(options?: AccessorOptions): Generator;
|
|
15
|
+
//# sourceMappingURL=accessors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accessors.d.ts","sourceRoot":"","sources":["../../src/generators/accessors.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAoC,SAAS,EAAE,MAAM,YAAY,CAAC;AAwF9E,0CAA0C;AAC1C,MAAM,WAAW,eAAe;IAC9B,sDAAsD;IACtD,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,kDAAkD;IAClD,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAmWD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,GAAE,eAAoB,GAAG,SAAS,CA2J3E"}
|