@aventara/client 0.1.0-pilot.3 → 0.1.0-pilot.4
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 +8 -11
- package/dist/cli/command.parser.d.ts +1 -13
- package/dist/cli/generation-success.renderer.d.ts +0 -4
- package/dist/cli/terminal.prompter.d.ts +0 -6
- package/dist/cli/warning.renderer.d.ts +0 -6
- package/dist/cli.d.ts +0 -16
- package/dist/config/client-config.interface.d.ts +10 -20
- package/dist/config/config.loader.d.ts +0 -21
- package/dist/config/config.resolver.d.ts +2 -17
- package/dist/config/env.cascade.d.ts +0 -30
- package/dist/config/module-style.resolver.d.ts +0 -25
- package/dist/config/tsconfig.locator.d.ts +0 -24
- package/dist/contract/contract.acceptance.d.ts +0 -39
- package/dist/contract/contract.fetcher.d.ts +0 -29
- package/dist/contract/contract.loader.d.ts +0 -7
- package/dist/emit/banner.emitter.d.ts +0 -18
- package/dist/emit/banner.emitter.js +1 -1
- package/dist/emit/client-surface.emitter.d.ts +0 -23
- package/dist/emit/client-tree.emitter.d.ts +0 -20
- package/dist/emit/contract-carrier.emitter.d.ts +0 -7
- package/dist/emit/derivation.emitter.d.ts +0 -28
- package/dist/emit/emitted-tree.interface.d.ts +0 -53
- package/dist/emit/enum.emitter.d.ts +0 -20
- package/dist/emit/module-specifier.scanner.d.ts +0 -15
- package/dist/emit/module-style.interface.d.ts +0 -15
- package/dist/emit/name.deriver.d.ts +0 -71
- package/dist/emit/named-type.emitter.d.ts +0 -20
- package/dist/emit/runtime.emitter.d.ts +0 -50
- package/dist/emit/runtime.emitter.js +12 -19
- package/dist/emit/scalar.codec.d.ts +0 -39
- package/dist/emit/transaction.emitter.d.ts +0 -6
- package/dist/emit/transaction.emitter.js +3 -5
- package/dist/generate.d.ts +0 -36
- package/dist/index.d.ts +1 -5
- package/dist/init/client-config.template.d.ts +0 -8
- package/dist/init/client-init.planner.d.ts +0 -1
- package/dist/init/client-init.questions.d.ts +0 -8
- package/dist/output/output.validator.d.ts +0 -39
- package/dist/output/output.writer.d.ts +1 -110
- package/package.json +3 -3
|
@@ -1,33 +1,5 @@
|
|
|
1
1
|
import type * as ts from "typescript";
|
|
2
2
|
import type { ClientEmission } from "../emit/emitted-tree.interface.js";
|
|
3
|
-
/**
|
|
4
|
-
* It judges a directory the writer has just filled with `tree`, and answers with a
|
|
5
|
-
* value — the writer decides what a rejection means for the previous output.
|
|
6
|
-
*
|
|
7
|
-
* # Three checks, the strongest available first
|
|
8
|
-
*
|
|
9
|
-
* - **Shape**, always: the directory holds exactly `tree` — no file missing, none
|
|
10
|
-
* extra, every one byte-for-byte what was emitted — every file carries the
|
|
11
|
-
* ownership line, and every module a file names is a file of the tree, spelled
|
|
12
|
-
* the project's way. The ownership line is not decoration: the NEXT run reads it
|
|
13
|
-
* to decide that this directory is a previous generation it may replace whole,
|
|
14
|
-
* so a file without it would make the next run refuse. The imports are read
|
|
15
|
-
* lexically (`module-specifier.scanner.ts`), with no compiler — so a wrongly
|
|
16
|
-
* spelled import is refused even where the type check cannot run (TypeScript 7).
|
|
17
|
-
* - **Types**, when the `typescript` optional peer resolves FROM THE PROJECT in
|
|
18
|
-
* its peer range: a real program over the tree under a consumer's strictest
|
|
19
|
-
* plausible settings, in the project's module resolution and format
|
|
20
|
-
* (`compilerOptionsFor`). The tree is judged ALONE — the compiler host serves
|
|
21
|
-
* nothing outside the directory but TypeScript's own `lib` files, so an import
|
|
22
|
-
* the tree cannot satisfy itself fails here even when a `node_modules` beside
|
|
23
|
-
* the output could satisfy it.
|
|
24
|
-
* - **Syntax**, when it does not — or when the `typescript` that resolves has no
|
|
25
|
-
* classic compiler API: each file through Node's own TypeScript parser
|
|
26
|
-
* (`node:module`'s `stripTypeScriptTypes`, its ExperimentalWarning held back),
|
|
27
|
-
* with a loud warning of our own that the output was NOT type-checked. Degraded,
|
|
28
|
-
* never skipped, and never a refusal: the developer's own `tsc` still checks the
|
|
29
|
-
* tree when their project compiles.
|
|
30
|
-
*/
|
|
31
3
|
/** The `typescript` module, as the validator uses it. */
|
|
32
4
|
export type TypeScriptCompiler = typeof ts;
|
|
33
5
|
/**
|
|
@@ -41,18 +13,7 @@ export type TypeScriptResolver = () => Promise<TypeScriptCompiler | undefined>;
|
|
|
41
13
|
* a package from a file there: its `node_modules`, then each parent's.
|
|
42
14
|
*/
|
|
43
15
|
export declare function typeScriptResolverFor(specifier: string, directory: string): TypeScriptResolver;
|
|
44
|
-
/**
|
|
45
|
-
* The `typescript` of the project that compiles the client, resolved from its
|
|
46
|
-
* `generateAt`. Never this package's own: run through `npx`, the generator is
|
|
47
|
-
* installed in npm's cache, where its optional peer never is — and the type check
|
|
48
|
-
* is a stand-in for the project's own `tsc`, so the project's compiler is the one
|
|
49
|
-
* that answers.
|
|
50
|
-
*/
|
|
51
16
|
export declare function projectTypeScriptResolver(generateAt: string): TypeScriptResolver;
|
|
52
|
-
/**
|
|
53
|
-
* The lowest `typescript` the generator type-checks with: this package's
|
|
54
|
-
* optional peer range, `>=5.5.0` (`packaging-gate.spec.ts` holds the two equal).
|
|
55
|
-
*/
|
|
56
17
|
export declare const MINIMUM_TYPESCRIPT = "5.5.0";
|
|
57
18
|
/** How deeply the tree was judged. */
|
|
58
19
|
export type OutputCheck = "types" | "syntax" | "shape";
|
|
@@ -2,74 +2,6 @@ import * as fsPromises from "node:fs/promises";
|
|
|
2
2
|
import type { AbsolutePath } from "../config/client-config.interface.js";
|
|
3
3
|
import { type ClientEmission, type EmittedTree } from "../emit/emitted-tree.interface.js";
|
|
4
4
|
import { type OutputCheck, type TypeScriptResolver } from "./output.validator.js";
|
|
5
|
-
/**
|
|
6
|
-
* The output is written into `generateAt`, a directory the developer SHARES: it
|
|
7
|
-
* may hold their own files. The generator owns exactly these entries in it — the
|
|
8
|
-
* entry file `AvClient.ts` and `generated/` — and reads, refuses on, moves or
|
|
9
|
-
* deletes nothing else there, apart from the transient entries it names itself
|
|
10
|
-
* (`.aventara-next-*`, `.aventara-ready-*`, `.generated.aventara-previous`) and an
|
|
11
|
-
* unreleased build's entry files, `AvClient.mjs` and `AvClient.d.mts`, which it
|
|
12
|
-
* removes only while they carry the ownership line.
|
|
13
|
-
*
|
|
14
|
-
* - `generated/` is replaced WHOLE, never merged: a file the previous run emitted
|
|
15
|
-
* and this one does not is gone — an unreleased build's `.mjs` modules included.
|
|
16
|
-
* It is replaced only when every file in it carries the generated banner's
|
|
17
|
-
* ownership line (an empty directory owns nothing and is fine); otherwise the
|
|
18
|
-
* run is refused, naming the foreign files.
|
|
19
|
-
* - Each entry file is replaced only when it is absent or carries the ownership
|
|
20
|
-
* line; otherwise the run is refused, naming it.
|
|
21
|
-
* - `AvClient.mjs` and `AvClient.d.mts` — an unreleased build's entry — are
|
|
22
|
-
* removed when they carry the ownership line, so no stale JavaScript is left
|
|
23
|
-
* beside `AvClient.ts`. Without the line each is the developer's own file: never
|
|
24
|
-
* read beyond its head, never named, never removed. (pilot.0's and pilot.1's
|
|
25
|
-
* `AvClient.ts` is the entry file itself, replaced in place.)
|
|
26
|
-
*
|
|
27
|
-
* # The order, and its one window
|
|
28
|
-
*
|
|
29
|
-
* The whole tree — the entry files and `generated/` together — is written into a
|
|
30
|
-
* staging directory inside `generateAt` (same filesystem, so every move is one
|
|
31
|
-
* atomic `rename`) and validated there as one program. Then:
|
|
32
|
-
*
|
|
33
|
-
* 1. the staging directory is renamed `.aventara-ready-*`: from here it is known
|
|
34
|
-
* to be validated;
|
|
35
|
-
* 2. the previous `generated/` → `.generated.aventara-previous`;
|
|
36
|
-
* 3. the staged `generated/` → `generated/`;
|
|
37
|
-
* 4. the previous entry files, and an owned earlier entry, move aside into the
|
|
38
|
-
* ready directory; then each staged entry file moves in;
|
|
39
|
-
* 5. the previous `generated/` and the staging directory are removed.
|
|
40
|
-
*
|
|
41
|
-
* A failed step 3 renames the previous `generated/` straight back; a failed step 4
|
|
42
|
-
* moves what it moved back — the new entry files out, the previous ones in — then
|
|
43
|
-
* the new `generated/` out and the previous back, so a failure at any step leaves
|
|
44
|
-
* the previous output. Node has no atomic exchange of two entries, so two windows
|
|
45
|
-
* remain for a process KILLED mid-replace, and the next run's recovery closes each
|
|
46
|
-
* before it does anything else:
|
|
47
|
-
*
|
|
48
|
-
* - between 2 and 3, `generated/` does not exist: the previous one is put back;
|
|
49
|
-
* - between 3 and the end of 4, the new `generated/` sits beside the old entry
|
|
50
|
-
* files, or beside only some new ones: the validated entry files still staged in
|
|
51
|
-
* `.aventara-ready-*` are moved in, completing the new output rather than
|
|
52
|
-
* leaving a mismatched one.
|
|
53
|
-
*
|
|
54
|
-
* Staging directories that never reached step 1 were not validated and are
|
|
55
|
-
* removed.
|
|
56
|
-
*
|
|
57
|
-
* # Failure is a sentence
|
|
58
|
-
*
|
|
59
|
-
* A refusal, a rejected tree or a filesystem error (an `Error` with a `code`) is
|
|
60
|
-
* an `OutputWriteError` naming its stage — the person running the generator can
|
|
61
|
-
* act on it. Any other error is a defect and propagates with its stack — the very
|
|
62
|
-
* error thrown, not a wrapper — and what the run said before it is kept beside it,
|
|
63
|
-
* read by `warningsRaisedBeforeDefect`.
|
|
64
|
-
*
|
|
65
|
-
* A refusal carries every warning the run raised before it stopped, in the order a
|
|
66
|
-
* success would have returned them: a crash recovered in `prepare` changed the
|
|
67
|
-
* disk, and the person has to hear that even when the run then fails.
|
|
68
|
-
*
|
|
69
|
-
* A failed run removes the directories it created to reach `generateAt` — and only
|
|
70
|
-
* those, and only while empty — so a first run that fails leaves no empty
|
|
71
|
-
* `generateAt` behind.
|
|
72
|
-
*/
|
|
73
5
|
/** The four stages a write passes through, in order. */
|
|
74
6
|
export type OutputWriteStage = "prepare" | "temp" | "validate" | "replace";
|
|
75
7
|
/** A write that stopped; the previous output is intact unless it says otherwise. */
|
|
@@ -99,42 +31,18 @@ export declare function precedeDefect(defect: unknown, earlier: readonly string[
|
|
|
99
31
|
* its warnings; empty when nothing was, or for an error no run threw.
|
|
100
32
|
*/
|
|
101
33
|
export declare function warningsRaisedBeforeDefect(defect: unknown): readonly string[];
|
|
102
|
-
/**
|
|
103
|
-
* The filesystem calls the writer makes, `node:fs/promises` by default. A seam
|
|
104
|
-
* because the filesystem is the writer's one external collaborator, and the only
|
|
105
|
-
* way to prove a failure at the replace stage leaves the previous output intact
|
|
106
|
-
* is to make a real rename fail.
|
|
107
|
-
*/
|
|
108
34
|
export type OutputFileSystem = Pick<typeof fsPromises, "lstat" | "mkdir" | "open" | "readdir" | "rename" | "rm" | "rmdir" | "writeFile">;
|
|
109
35
|
export interface ClientOutputWriteInput {
|
|
110
36
|
/** What `emitClientTree` returned: the tree, and the warnings it raised. */
|
|
111
37
|
readonly emission: ClientEmission;
|
|
112
|
-
/** The resolved `generateAt`. Created when missing. */
|
|
113
38
|
readonly generateAt: AbsolutePath;
|
|
114
|
-
/**
|
|
115
|
-
* Content in the entry files or `generated/` the generator did not produce, which
|
|
116
|
-
* the person running it confirmed may be overwritten or removed — the paths
|
|
117
|
-
* `findForeignOutputContent` listed. Anything foreign that is not listed here is
|
|
118
|
-
* refused.
|
|
119
|
-
*/
|
|
120
39
|
readonly overrideForeign?: readonly string[];
|
|
121
|
-
/**
|
|
122
|
-
* The `typescript` optional peer; by default the project's own, resolved from
|
|
123
|
-
* `generateAt`.
|
|
124
|
-
*/
|
|
125
40
|
readonly resolveTypeScript?: TypeScriptResolver;
|
|
126
41
|
readonly fileSystem?: OutputFileSystem;
|
|
127
42
|
}
|
|
128
43
|
export interface ClientOutputWritten {
|
|
129
44
|
readonly generateAt: AbsolutePath;
|
|
130
|
-
/** How deeply the tree was validated before it replaced the output. */
|
|
131
45
|
readonly checked: OutputCheck;
|
|
132
|
-
/**
|
|
133
|
-
* Everything the run has to say without failing, in order: the emission's own
|
|
134
|
-
* warnings (the rename ladder's), then the validator's (a degraded check), then
|
|
135
|
-
* the writer's (a recovered crash, a leftover it could not remove). Returned,
|
|
136
|
-
* never printed: the CLI owns the terminal.
|
|
137
|
-
*/
|
|
138
46
|
readonly warnings: readonly string[];
|
|
139
47
|
}
|
|
140
48
|
/**
|
|
@@ -145,25 +53,8 @@ export interface ClientOutputWritten {
|
|
|
145
53
|
*/
|
|
146
54
|
export declare function writeClientOutput(input: ClientOutputWriteInput): Promise<ClientOutputWritten>;
|
|
147
55
|
/**
|
|
148
|
-
* Lists what in the entry files and `<generateAt>/generated/` the generator did
|
|
149
|
-
* not produce — a file without the ownership line, a symbolic link, anything that
|
|
150
|
-
* is not a regular file — so the person running it can be asked before a
|
|
151
|
-
* generation overwrites or removes it. Reads only; looks at nothing else in
|
|
152
|
-
* `generateAt`. Empty when `generateAt` does not exist yet.
|
|
153
|
-
*
|
|
154
|
-
* It sees what the write will see once it has recovered a killed run, without
|
|
155
|
-
* recovering it: a `generated/` the killed run moved aside with nothing in its
|
|
156
|
-
* place is read where it lies and its files named where recovery puts them back
|
|
157
|
-
* (`generated/…`). So the question asked, and `--yes`, cover them too — and a run
|
|
158
|
-
* that stops here has still touched nothing.
|
|
159
|
-
*
|
|
160
56
|
* @throws OutputWriteError when `generateAt` is not a directory, `generated` is
|
|
161
|
-
*
|
|
57
|
+
* not a directory or an entry file is not a file: no confirmation repairs that.
|
|
162
58
|
*/
|
|
163
59
|
export declare function findForeignOutputContent(generateAt: AbsolutePath, fileSystem?: OutputFileSystem): Promise<readonly string[]>;
|
|
164
|
-
/**
|
|
165
|
-
* Whether the entry files and `generated/` in `generateAt` hold exactly `tree` —
|
|
166
|
-
* every file byte for byte, no other file, no owned entry of an earlier build, and
|
|
167
|
-
* nothing a killed run moved aside — so that writing `tree` would change nothing.
|
|
168
|
-
*/
|
|
169
60
|
export declare function ownedOutputMatches(generateAt: AbsolutePath, tree: EmittedTree): Promise<boolean>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aventara/client",
|
|
3
|
-
"version": "0.1.0-pilot.
|
|
3
|
+
"version": "0.1.0-pilot.4",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE",
|
|
5
5
|
"description": "Development-time generator for Aventara typed remote clients.",
|
|
6
6
|
"type": "module",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"LICENSE-ADDITIONAL-PERMISSION.md"
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@aventara/core": "0.1.0-pilot.
|
|
26
|
+
"@aventara/core": "0.1.0-pilot.4",
|
|
27
27
|
"c12": "3.3.4",
|
|
28
28
|
"get-tsconfig": "4.10.0"
|
|
29
29
|
},
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"access": "public"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@aventara/testing": "0.1.0-pilot.
|
|
42
|
+
"@aventara/testing": "0.1.0-pilot.4",
|
|
43
43
|
"@types/node": "24.10.1",
|
|
44
44
|
"typescript": "^5.9.2"
|
|
45
45
|
},
|