@pbuilder/sdk 0.18.0 → 0.20.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 +89 -3
- package/dist/acl/irwire/stdio-engine-client.d.ts +2 -1
- package/dist/acl/irwire/stdio-engine-client.js +12 -2
- package/dist/bin/pbuilder-codegen.js +148 -18
- package/dist/bin/pbuilder-conformance.js +24 -5
- package/dist/bounded-contexts/authoring/application/usecases/authoring-verbs/index.d.ts +15 -0
- package/dist/bounded-contexts/authoring/application/usecases/authoring-verbs/index.js +17 -0
- package/dist/bounded-contexts/authoring/application/usecases/run-factory/context.d.ts +21 -5
- package/dist/bounded-contexts/authoring/application/usecases/run-factory/context.js +59 -12
- package/dist/bounded-contexts/authoring/domain/aggregates/session/session.d.ts +4 -2
- package/dist/bounded-contexts/authoring/domain/aggregates/session/session.js +12 -3
- package/dist/bounded-contexts/authoring/domain/ports/engine-client.d.ts +2 -1
- package/dist/bounded-contexts/authoring/domain/services/define-dialect.d.ts +28 -1
- package/dist/bounded-contexts/authoring/domain/services/define-dialect.js +27 -3
- package/dist/bounded-contexts/authoring/domain/services/evaluation.d.ts +29 -0
- package/dist/bounded-contexts/authoring/domain/services/evaluation.js +43 -0
- package/dist/bounded-contexts/authoring/domain/services/glob-match.d.ts +4 -0
- package/dist/bounded-contexts/authoring/domain/services/glob-match.js +81 -0
- package/dist/bounded-contexts/authoring/domain/services/schema/input-rejection.d.ts +2 -0
- package/dist/bounded-contexts/authoring/domain/services/schema/input-rejection.js +8 -0
- package/dist/bounded-contexts/authoring/domain/services/schema/schema-parse.d.ts +3 -2
- package/dist/bounded-contexts/authoring/domain/services/schema/schema-parse.js +46 -4
- package/dist/bounded-contexts/authoring/domain/services/schema/schema-validate.d.ts +18 -2
- package/dist/bounded-contexts/authoring/domain/services/schema/schema-validate.js +131 -2
- package/dist/bounded-contexts/authoring/domain/valueobjects/authoring-error.d.ts +3 -2
- package/dist/bounded-contexts/authoring/domain/valueobjects/authoring-error.js +2 -0
- package/dist/bounded-contexts/authoring/domain/valueobjects/findings.d.ts +12 -0
- package/dist/bounded-contexts/authoring/domain/valueobjects/findings.js +57 -0
- package/dist/bounded-contexts/authoring/domain/valueobjects/schema-model.d.ts +19 -0
- package/dist/bounded-contexts/authoring/domain/valueobjects/schema-model.js +1 -0
- package/dist/bounded-contexts/authoring/infrastructure/in/codegen/cli.d.ts +7 -2
- package/dist/bounded-contexts/authoring/infrastructure/in/codegen/cli.js +28 -7
- package/dist/bounded-contexts/authoring/infrastructure/in/codegen/emit-type.d.ts +6 -1
- package/dist/bounded-contexts/authoring/infrastructure/in/codegen/emit-type.js +44 -11
- package/dist/bounded-contexts/authoring/infrastructure/in/codegen/project-codegen.d.ts +1 -0
- package/dist/bounded-contexts/authoring/infrastructure/in/codegen/project-codegen.js +5 -2
- package/dist/bounded-contexts/authoring/infrastructure/in/commons/index.d.ts +2 -1
- package/dist/bounded-contexts/authoring/infrastructure/in/commons/index.js +1 -1
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/angular/index.d.ts +14 -1
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/angular/index.js +15 -0
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/aspnet/index.d.ts +14 -1
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/aspnet/index.js +15 -0
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/csharp/index.d.ts +14 -1
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/csharp/index.js +15 -0
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/css/index.d.ts +14 -1
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/css/index.js +15 -0
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/json/index.d.ts +14 -1
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/json/index.js +15 -0
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/msbuild/index.d.ts +14 -1
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/msbuild/index.js +15 -0
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/nestjs/index.d.ts +14 -1
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/nestjs/index.js +15 -0
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/react/index.d.ts +14 -1
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/react/index.js +15 -0
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/typescript/index.d.ts +14 -1
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/typescript/index.js +15 -0
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/yaml/index.d.ts +14 -1
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/yaml/index.js +15 -0
- package/dist/bounded-contexts/authoring/testing/conformance/run-package.d.ts +17 -0
- package/dist/bounded-contexts/authoring/testing/conformance/run-package.js +124 -44
- package/dist/bounded-contexts/authoring/testing/contract-fake.d.ts +1 -0
- package/dist/bounded-contexts/authoring/testing/contract-fake.js +8 -0
- package/dist/bounded-contexts/authoring/testing/glob-pattern.d.ts +5 -0
- package/dist/bounded-contexts/authoring/testing/glob-pattern.js +20 -0
- package/dist/bounded-contexts/authoring/testing/harness/index.d.ts +18 -4
- package/dist/bounded-contexts/authoring/testing/harness/index.js +17 -4
- package/dist/bounded-contexts/authoring/testing/run-vehicle.d.ts +1 -0
- package/dist/bounded-contexts/authoring/testing/run-vehicle.js +4 -0
- package/dist/bounded-contexts/runner-hosting/infrastructure/in/bootstrap-bridge.d.ts +3 -0
- package/dist/bounded-contexts/runner-hosting/infrastructure/in/bootstrap-bridge.js +4 -0
- package/dist/bounded-contexts/runner-hosting/infrastructure/in/runner.js +52 -13
- package/dist/bounded-contexts/runner-hosting/infrastructure/in/single-instance-probe.d.ts +14 -3
- package/dist/bounded-contexts/runner-hosting/infrastructure/in/single-instance-probe.js +17 -8
- package/dist/conformance/index.d.ts +1 -1
- package/dist/conformance/index.js +1 -1
- package/dist/runner-manifest.json +37 -13
- package/dist/shared-kernel/wire-protocol.d.ts +1 -1
- package/dist/shared-kernel/wire-protocol.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// The listing the in-memory engines answer `list` with, matching as the engine's `tree.list` does.
|
|
2
|
+
import { posix } from "node:path";
|
|
3
|
+
import { alternatives, globMatcher } from "../domain/services/glob-match.js";
|
|
4
|
+
/**
|
|
5
|
+
* The paths among `files` that `pattern` matches and no `ignore` pattern does, sorted bytewise.
|
|
6
|
+
* Every alternative of `pattern` must stay inside the workspace, as the engine's gate requires.
|
|
7
|
+
*/
|
|
8
|
+
export function listMatching(files, pattern, ignore = []) {
|
|
9
|
+
for (const alternative of alternatives(pattern)) {
|
|
10
|
+
const normalized = posix.normalize(alternative);
|
|
11
|
+
if (posix.isAbsolute(alternative) || normalized === ".." || normalized.startsWith("../")) {
|
|
12
|
+
throw new Error("path escapes workspace");
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
const matches = globMatcher(pattern);
|
|
16
|
+
const ignored = ignore.map(globMatcher);
|
|
17
|
+
return [...files]
|
|
18
|
+
.filter((path) => matches(path) && !ignored.some((ignores) => ignores(path)))
|
|
19
|
+
.sort((a, b) => Buffer.compare(Buffer.from(a), Buffer.from(b)));
|
|
20
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Batch, Directive } from "../../domain/valueobjects/wire.ts";
|
|
2
2
|
import type { AuthoringError } from "../../domain/valueobjects/authoring-error.ts";
|
|
3
|
+
import type { Role } from "../../domain/valueobjects/findings.ts";
|
|
3
4
|
/**
|
|
4
5
|
* The outcome of running a factory via `runFactoryForTest`.
|
|
5
6
|
*
|
|
@@ -9,7 +10,7 @@ import type { AuthoringError } from "../../domain/valueobjects/authoring-error.t
|
|
|
9
10
|
* console.log(result.tree.get("src/greeting.ts"));
|
|
10
11
|
* }
|
|
11
12
|
*/
|
|
12
|
-
export interface RunResult {
|
|
13
|
+
export interface RunResult<R = unknown> {
|
|
13
14
|
/**
|
|
14
15
|
* The committed tree (`ContractFake.committedTree()`), path → content. Committed writes
|
|
15
16
|
* ONLY — an unmodified seed path is never present here, even if the factory read it.
|
|
@@ -29,6 +30,12 @@ export interface RunResult {
|
|
|
29
30
|
* emit seam. On a factory throw, the original thrown value, unmodified.
|
|
30
31
|
*/
|
|
31
32
|
error: AuthoringError | unknown;
|
|
33
|
+
/**
|
|
34
|
+
* The Result the run committed (A-14): what the factory returned, validated against the
|
|
35
|
+
* `result` its `schema.json` declares. `null` is a Result; `undefined` means the run
|
|
36
|
+
* committed none, because the factory declares none or the run failed.
|
|
37
|
+
*/
|
|
38
|
+
result: R | undefined;
|
|
32
39
|
}
|
|
33
40
|
export type { Batch, Directive };
|
|
34
41
|
/**
|
|
@@ -36,7 +43,7 @@ export type { Batch, Directive };
|
|
|
36
43
|
* actually happened — closing the gap where a write-only factory (one that buffers
|
|
37
44
|
* directives but is never observed to commit them) has no author-facing test to catch it.
|
|
38
45
|
*
|
|
39
|
-
* `fn` is the bare `(input) =>
|
|
46
|
+
* `fn` is the bare `(input) => R | Promise<R>` author function — never a
|
|
40
47
|
* `defineFactory`-wrapped runner. `runFactoryForTest` wraps `fn` internally by delegating to
|
|
41
48
|
* `defineFactory`, the SAME seam a future production runner will call (single-wrap-seam
|
|
42
49
|
* invariant) — it never reimplements the wrap. The harness constructs its own in-memory fake
|
|
@@ -59,6 +66,11 @@ export type { Batch, Directive };
|
|
|
59
66
|
* `packageDir` at all.
|
|
60
67
|
* @param options.declaredDialects - the names of the author-defined dialects the schematic's
|
|
61
68
|
* library declares in its Manifest; a handle of any other named dialect fails the run (A-16).
|
|
69
|
+
* @param options.role - the role the schematic declares in its Collection definition entry. With
|
|
70
|
+
* `evaluation`, `fn` returns its Findings and `result.result` holds them as they leave the
|
|
71
|
+
* schematic: each with its `source`, and only those inside the scope `include` and `exclude` name.
|
|
72
|
+
* @param options.name - the qualified name `collection:schematic` of the schematic, which an
|
|
73
|
+
* evaluation's findings carry as their `source`; required with the role `evaluation`.
|
|
62
74
|
*
|
|
63
75
|
* @example
|
|
64
76
|
* import { runFactoryForTest } from "@pbuilder/sdk/testing";
|
|
@@ -85,8 +97,10 @@ export type { Batch, Directive };
|
|
|
85
97
|
* expect(result.tree.get("src/greeting.ts")).toEqual("export const greeting = '{= .name =}';");
|
|
86
98
|
* });
|
|
87
99
|
*/
|
|
88
|
-
export declare function runFactoryForTest<O>(fn: (input: O) =>
|
|
100
|
+
export declare function runFactoryForTest<O, R = void>(fn: (input: O) => R | Promise<R>, input: O, options?: {
|
|
89
101
|
seed?: Record<string, string>;
|
|
90
102
|
packageDir?: string | URL;
|
|
91
103
|
declaredDialects?: readonly string[];
|
|
92
|
-
|
|
104
|
+
role?: Role;
|
|
105
|
+
name?: string;
|
|
106
|
+
}): Promise<RunResult<R>>;
|
|
@@ -6,7 +6,7 @@ import { nodePackageFiles } from "../../infrastructure/out/fs/package-files.js";
|
|
|
6
6
|
* actually happened — closing the gap where a write-only factory (one that buffers
|
|
7
7
|
* directives but is never observed to commit them) has no author-facing test to catch it.
|
|
8
8
|
*
|
|
9
|
-
* `fn` is the bare `(input) =>
|
|
9
|
+
* `fn` is the bare `(input) => R | Promise<R>` author function — never a
|
|
10
10
|
* `defineFactory`-wrapped runner. `runFactoryForTest` wraps `fn` internally by delegating to
|
|
11
11
|
* `defineFactory`, the SAME seam a future production runner will call (single-wrap-seam
|
|
12
12
|
* invariant) — it never reimplements the wrap. The harness constructs its own in-memory fake
|
|
@@ -29,6 +29,11 @@ import { nodePackageFiles } from "../../infrastructure/out/fs/package-files.js";
|
|
|
29
29
|
* `packageDir` at all.
|
|
30
30
|
* @param options.declaredDialects - the names of the author-defined dialects the schematic's
|
|
31
31
|
* library declares in its Manifest; a handle of any other named dialect fails the run (A-16).
|
|
32
|
+
* @param options.role - the role the schematic declares in its Collection definition entry. With
|
|
33
|
+
* `evaluation`, `fn` returns its Findings and `result.result` holds them as they leave the
|
|
34
|
+
* schematic: each with its `source`, and only those inside the scope `include` and `exclude` name.
|
|
35
|
+
* @param options.name - the qualified name `collection:schematic` of the schematic, which an
|
|
36
|
+
* evaluation's findings carry as their `source`; required with the role `evaluation`.
|
|
32
37
|
*
|
|
33
38
|
* @example
|
|
34
39
|
* import { runFactoryForTest } from "@pbuilder/sdk/testing";
|
|
@@ -56,9 +61,13 @@ import { nodePackageFiles } from "../../infrastructure/out/fs/package-files.js";
|
|
|
56
61
|
* });
|
|
57
62
|
*/
|
|
58
63
|
export async function runFactoryForTest(fn, input, options) {
|
|
64
|
+
if (options?.role === "evaluation" && options.name === undefined) {
|
|
65
|
+
throw new Error("runFactoryForTest: an evaluation factory needs options.name, the qualified name collection:schematic");
|
|
66
|
+
}
|
|
59
67
|
const fake = new ContractFake({ seed: options?.seed ?? {} });
|
|
60
68
|
const emitted = [];
|
|
61
69
|
const reads = new Map();
|
|
70
|
+
let committed;
|
|
62
71
|
const client = {
|
|
63
72
|
emit(batch) {
|
|
64
73
|
emitted.push(batch);
|
|
@@ -68,7 +77,11 @@ export async function runFactoryForTest(fn, input, options) {
|
|
|
68
77
|
reads.set(path, (reads.get(path) ?? 0) + 1);
|
|
69
78
|
return fake.read(path);
|
|
70
79
|
},
|
|
71
|
-
|
|
80
|
+
list(pattern, ignore) {
|
|
81
|
+
return fake.list(pattern, ignore);
|
|
82
|
+
},
|
|
83
|
+
commit(result) {
|
|
84
|
+
committed = result;
|
|
72
85
|
return fake.commit();
|
|
73
86
|
},
|
|
74
87
|
discard() {
|
|
@@ -80,10 +93,10 @@ export async function runFactoryForTest(fn, input, options) {
|
|
|
80
93
|
: { declaredDialects: options?.declaredDialects });
|
|
81
94
|
let error;
|
|
82
95
|
try {
|
|
83
|
-
await run(input, { client });
|
|
96
|
+
await run(input, { client, role: options?.role, name: options?.name });
|
|
84
97
|
}
|
|
85
98
|
catch (caught) {
|
|
86
99
|
error = caught;
|
|
87
100
|
}
|
|
88
|
-
return { tree: fake.committedTree(), emitted, reads, error };
|
|
101
|
+
return { tree: fake.committedTree(), emitted, reads, error, result: committed };
|
|
89
102
|
}
|
|
@@ -3,6 +3,7 @@ import type { Batch } from "../domain/valueobjects/wire.ts";
|
|
|
3
3
|
interface RunVehicleClient {
|
|
4
4
|
emit(batch: Batch): Promise<void>;
|
|
5
5
|
read(path: string): Promise<string | undefined>;
|
|
6
|
+
list(pattern: string, ignore?: readonly string[]): Promise<readonly string[]>;
|
|
6
7
|
commit(): Promise<void>;
|
|
7
8
|
discard(): Promise<void>;
|
|
8
9
|
}
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
// its allow-list is exactly one path, and this is not it). The port shape is satisfied via a
|
|
17
17
|
// LOCAL structural type instead — the same sanctioned pattern `src/testing/index.ts`'s facade
|
|
18
18
|
// uses for its own spy-wrapping.
|
|
19
|
+
import { listMatching } from "./glob-pattern.js";
|
|
19
20
|
function applyDirective(tree, directive) {
|
|
20
21
|
if (directive.op === "create") {
|
|
21
22
|
tree.set(directive.create.pathTemplate, directive.create.template);
|
|
@@ -91,6 +92,9 @@ export function createRunVehicle(seed) {
|
|
|
91
92
|
async read(path) {
|
|
92
93
|
return tree.get(path);
|
|
93
94
|
},
|
|
95
|
+
async list(pattern, ignore) {
|
|
96
|
+
return listMatching(tree.keys(), pattern, ignore);
|
|
97
|
+
},
|
|
94
98
|
async commit() {
|
|
95
99
|
// Nothing to promote — this vehicle applies eagerly on emit (no staging/committed
|
|
96
100
|
// distinction; each exercise is a fresh, single-purpose, single-run instance whose
|
|
@@ -15,6 +15,9 @@ export interface BridgeParams {
|
|
|
15
15
|
input: BridgeInput;
|
|
16
16
|
/** The Frame's declared dialects (A-16, CA-5); absent means none. */
|
|
17
17
|
dialects?: readonly DeclaredDialect[];
|
|
18
|
+
/** The root's role and qualified name (CA-19); absent when the engine has none to pass. */
|
|
19
|
+
role?: string;
|
|
20
|
+
name?: string;
|
|
18
21
|
}
|
|
19
22
|
export interface BridgeIo {
|
|
20
23
|
input: RunnerIo["input"];
|
|
@@ -46,6 +46,10 @@ function toArgv(params) {
|
|
|
46
46
|
argv.push("--input-file", params.input.path);
|
|
47
47
|
if (params.dialects !== undefined)
|
|
48
48
|
argv.push("--dialects", JSON.stringify(params.dialects));
|
|
49
|
+
if (params.role !== undefined)
|
|
50
|
+
argv.push("--role", params.role);
|
|
51
|
+
if (params.name !== undefined)
|
|
52
|
+
argv.push("--name", params.name);
|
|
49
53
|
return argv;
|
|
50
54
|
}
|
|
51
55
|
/**
|
|
@@ -42,9 +42,23 @@ export const INPUT_FILE_SIZE_CAP_BYTES = 10 * 1024 * 1024; // 10 MiB
|
|
|
42
42
|
function note(io, text) {
|
|
43
43
|
io.writeStderr(`${boundMessage(text)}\n`);
|
|
44
44
|
}
|
|
45
|
-
const DIALECTS_SHAPE =
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
const DIALECTS_SHAPE = 'pbuilder-runner: --dialects must be a JSON array of {name, version, root} or {kind: "local", name, root, path} strings';
|
|
46
|
+
function fields(entry, keys) {
|
|
47
|
+
if (typeof entry !== "object" || entry === null)
|
|
48
|
+
return undefined;
|
|
49
|
+
const record = entry;
|
|
50
|
+
const picked = {};
|
|
51
|
+
for (const key of keys) {
|
|
52
|
+
const field = record[key];
|
|
53
|
+
if (typeof field !== "string" || field === "")
|
|
54
|
+
return undefined;
|
|
55
|
+
picked[key] = field;
|
|
56
|
+
}
|
|
57
|
+
return picked;
|
|
58
|
+
}
|
|
59
|
+
// A-16 / CA-5 / CA-18: the dialects the Frame's library declares, as the engine read them from the
|
|
60
|
+
// Lock. An entry without `kind` is a published dialect. The value is never echoed: it holds
|
|
61
|
+
// absolute paths.
|
|
48
62
|
function parseDialects(value) {
|
|
49
63
|
let parsed;
|
|
50
64
|
try {
|
|
@@ -55,22 +69,38 @@ function parseDialects(value) {
|
|
|
55
69
|
}
|
|
56
70
|
if (!Array.isArray(parsed))
|
|
57
71
|
return undefined;
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
72
|
+
const dialects = [];
|
|
73
|
+
for (const entry of parsed) {
|
|
74
|
+
const kind = typeof entry === "object" && entry !== null ? entry.kind : undefined;
|
|
75
|
+
if (kind === "local") {
|
|
76
|
+
const local = fields(entry, ["name", "root", "path"]);
|
|
77
|
+
if (local === undefined)
|
|
78
|
+
return undefined;
|
|
79
|
+
dialects.push({ kind: "local", name: local.name, root: local.root, path: local.path });
|
|
80
|
+
}
|
|
81
|
+
else if (kind === undefined) {
|
|
82
|
+
const published = fields(entry, ["name", "version", "root"]);
|
|
83
|
+
if (published === undefined)
|
|
84
|
+
return undefined;
|
|
85
|
+
dialects.push({ name: published.name, version: published.version, root: published.root });
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
return undefined;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return dialects;
|
|
65
92
|
}
|
|
66
93
|
// REQ-RUN-01: `--factory <url>#<export>` required; exactly one of `--input <json>` XOR
|
|
67
|
-
// `--input-file <path>`; `--dialects <json>` optional, absent meaning none declared;
|
|
68
|
-
//
|
|
94
|
+
// `--input-file <path>`; `--dialects <json>` optional, absent meaning none declared; `--role`
|
|
95
|
+
// and `--name` optional, the root's role and qualified name the engine passes unread (CA-19);
|
|
96
|
+
// any unrecognized flag fails closed.
|
|
69
97
|
function parseArgv(argv) {
|
|
70
98
|
let factory;
|
|
71
99
|
let inputJson;
|
|
72
100
|
let inputFile;
|
|
73
101
|
let dialects = [];
|
|
102
|
+
let role;
|
|
103
|
+
let name;
|
|
74
104
|
for (let i = 0; i < argv.length; i += 2) {
|
|
75
105
|
const flag = argv[i];
|
|
76
106
|
const value = argv[i + 1];
|
|
@@ -89,6 +119,10 @@ function parseArgv(argv) {
|
|
|
89
119
|
return { error: DIALECTS_SHAPE };
|
|
90
120
|
dialects = declared;
|
|
91
121
|
}
|
|
122
|
+
else if (flag === "--role")
|
|
123
|
+
role = value;
|
|
124
|
+
else if (flag === "--name")
|
|
125
|
+
name = value;
|
|
92
126
|
else
|
|
93
127
|
return { error: composeWithToken("pbuilder-runner: unrecognized flag ", flag) };
|
|
94
128
|
}
|
|
@@ -100,9 +134,14 @@ function parseArgv(argv) {
|
|
|
100
134
|
if (inputJson === undefined && inputFile === undefined) {
|
|
101
135
|
return { error: "pbuilder-runner: exactly one of --input or --input-file is required" };
|
|
102
136
|
}
|
|
137
|
+
if (role === "evaluation" && name === undefined) {
|
|
138
|
+
return { error: "pbuilder-runner: --role evaluation needs --name, the qualified name collection:schematic" };
|
|
139
|
+
}
|
|
103
140
|
return {
|
|
104
141
|
factory,
|
|
105
142
|
dialects,
|
|
143
|
+
role,
|
|
144
|
+
name,
|
|
106
145
|
input: inputJson !== undefined ? { kind: "inline", json: inputJson } : { kind: "file", path: inputFile },
|
|
107
146
|
};
|
|
108
147
|
}
|
|
@@ -358,7 +397,7 @@ async function runRunnerBody(argv, io, opened) {
|
|
|
358
397
|
};
|
|
359
398
|
const client = new StdioEngineClient(channel);
|
|
360
399
|
try {
|
|
361
|
-
await run(resolvedInput.value, { client });
|
|
400
|
+
await run(resolvedInput.value, { client, role: parsed.role, name: parsed.name });
|
|
362
401
|
return 0;
|
|
363
402
|
}
|
|
364
403
|
catch (err) {
|
|
@@ -21,16 +21,27 @@ export type SingleInstanceProbeResult = {
|
|
|
21
21
|
* with the REAL default resolver in the split/unresolvable test cases.
|
|
22
22
|
*/
|
|
23
23
|
export declare function probeSingleInstance(factoryUrl: string, resolveSpecifier?: (specifier: string, anchorUrl: string) => string): SingleInstanceProbeResult;
|
|
24
|
-
/**
|
|
25
|
-
export interface
|
|
24
|
+
/** A published dialect, installed into the Cache: `root` is the package the Lock pins. */
|
|
25
|
+
export interface PublishedDialect {
|
|
26
|
+
kind?: undefined;
|
|
26
27
|
name: string;
|
|
27
28
|
version: string;
|
|
28
29
|
root: string;
|
|
29
30
|
}
|
|
31
|
+
/** A local dialect (CA-18): `root` is the folder the engine hashed, `path` its base file. */
|
|
32
|
+
export interface LocalDeclaredDialect {
|
|
33
|
+
kind: "local";
|
|
34
|
+
name: string;
|
|
35
|
+
root: string;
|
|
36
|
+
path: string;
|
|
37
|
+
}
|
|
38
|
+
/** One dialect the Frame's library declares (CA-5): published unless its `kind` is `"local"`. */
|
|
39
|
+
export type DeclaredDialect = PublishedDialect | LocalDeclaredDialect;
|
|
30
40
|
/**
|
|
31
41
|
* A-16 / A-4: before the factory starts, resolves each declared dialect's name from the factory's
|
|
32
42
|
* location, the same resolution its own `import` gets, and requires the real path inside the copy
|
|
33
|
-
* the Lock pins.
|
|
43
|
+
* the Lock pins. A local dialect's name is no specifier, so its base file's real path must sit inside
|
|
44
|
+
* its folder instead (CA-18). It keeps the dialect that runs the pinned one; it is no security boundary.
|
|
34
45
|
* Resolution-only, like `probeSingleInstance`; an unresolvable name fails the same way.
|
|
35
46
|
*/
|
|
36
47
|
export declare function probeDeclaredDialects(factoryUrl: string, dialects: readonly DeclaredDialect[], resolveSpecifier?: (specifier: string, anchorUrl: string) => string): SingleInstanceProbeResult;
|
|
@@ -117,27 +117,36 @@ export function probeSingleInstance(factoryUrl, resolveSpecifier = resolveSpecif
|
|
|
117
117
|
return { ok: true };
|
|
118
118
|
return { ok: false, message: splitMessage(runnerRoot, factoryRoot) };
|
|
119
119
|
}
|
|
120
|
-
function
|
|
120
|
+
function isInside(root, file) {
|
|
121
121
|
try {
|
|
122
|
-
const path = relative(realpathSync(root), realpathSync(
|
|
122
|
+
const path = relative(realpathSync(root), realpathSync(file));
|
|
123
123
|
return path !== "" && !path.startsWith("..") && !isAbsolute(path);
|
|
124
124
|
}
|
|
125
125
|
catch {
|
|
126
126
|
return false;
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
|
+
function resolvesInside(dialect, factoryUrl, resolveSpecifier) {
|
|
130
|
+
if (dialect.kind === "local")
|
|
131
|
+
return isInside(dialect.root, dialect.path);
|
|
132
|
+
try {
|
|
133
|
+
return isInside(dialect.root, resolveSpecifier(dialect.name, factoryUrl));
|
|
134
|
+
}
|
|
135
|
+
catch {
|
|
136
|
+
return false;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
129
139
|
/**
|
|
130
140
|
* A-16 / A-4: before the factory starts, resolves each declared dialect's name from the factory's
|
|
131
141
|
* location, the same resolution its own `import` gets, and requires the real path inside the copy
|
|
132
|
-
* the Lock pins.
|
|
142
|
+
* the Lock pins. A local dialect's name is no specifier, so its base file's real path must sit inside
|
|
143
|
+
* its folder instead (CA-18). It keeps the dialect that runs the pinned one; it is no security boundary.
|
|
133
144
|
* Resolution-only, like `probeSingleInstance`; an unresolvable name fails the same way.
|
|
134
145
|
*/
|
|
135
146
|
export function probeDeclaredDialects(factoryUrl, dialects, resolveSpecifier = resolveSpecifierPath) {
|
|
136
|
-
const outside = dialects.find((
|
|
147
|
+
const outside = dialects.find((dialect) => !resolvesInside(dialect, factoryUrl, resolveSpecifier));
|
|
137
148
|
if (outside === undefined)
|
|
138
149
|
return { ok: true };
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
message: `the factory does not start because the dialect "${outside.name}" resolves outside the package the Lock pins`,
|
|
142
|
-
};
|
|
150
|
+
const place = outside.kind === "local" ? "the folder of its base file" : "the package the Lock pins";
|
|
151
|
+
return { ok: false, message: `the factory does not start because the dialect "${outside.name}" resolves outside ${place}` };
|
|
143
152
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from "../bounded-contexts/authoring/testing/conformance/index.ts";
|
|
2
|
-
export { checkDialectPackage, type ConformanceFailure, type ConformanceReport, } from "../bounded-contexts/authoring/testing/conformance/run-package.ts";
|
|
2
|
+
export { checkDialectPackage, checkLocalDialect, type LocalDialect, type ConformanceFailure, type ConformanceReport, } from "../bounded-contexts/authoring/testing/conformance/run-package.ts";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from "../bounded-contexts/authoring/testing/conformance/index.js";
|
|
2
|
-
export { checkDialectPackage, } from "../bounded-contexts/authoring/testing/conformance/run-package.js";
|
|
2
|
+
export { checkDialectPackage, checkLocalDialect, } from "../bounded-contexts/authoring/testing/conformance/run-package.js";
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"manifestVersion": 1,
|
|
3
3
|
"algorithm": "sha256",
|
|
4
4
|
"entry": "dist/bin/pbuilder-runner.js",
|
|
5
|
-
"packageVersion": "0.
|
|
5
|
+
"packageVersion": "0.20.0",
|
|
6
6
|
"files": [
|
|
7
7
|
{
|
|
8
8
|
"path": "dist/acl/irwire/frame-reader.js",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
},
|
|
11
11
|
{
|
|
12
12
|
"path": "dist/acl/irwire/stdio-engine-client.js",
|
|
13
|
-
"sha256": "
|
|
13
|
+
"sha256": "0708fe083ad447fe69fa97c8512072c4fe957f34c073919adc2337c7687d60a9"
|
|
14
14
|
},
|
|
15
15
|
{
|
|
16
16
|
"path": "dist/bin/pbuilder-runner.js",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
},
|
|
19
19
|
{
|
|
20
20
|
"path": "dist/bounded-contexts/authoring/application/usecases/run-factory/context.js",
|
|
21
|
-
"sha256": "
|
|
21
|
+
"sha256": "0be3b6041f3588e8ee9a37d224fa5009e4a1dc3a11239b0a7f257b229dc2d230"
|
|
22
22
|
},
|
|
23
23
|
{
|
|
24
24
|
"path": "dist/bounded-contexts/authoring/application/usecases/run-factory/driving.js",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
},
|
|
27
27
|
{
|
|
28
28
|
"path": "dist/bounded-contexts/authoring/domain/aggregates/session/session.js",
|
|
29
|
-
"sha256": "
|
|
29
|
+
"sha256": "93605d869fcde9292acc77370b3a5a0df52ff84f1ce9b7023f0a44a8a1b19c39"
|
|
30
30
|
},
|
|
31
31
|
{
|
|
32
32
|
"path": "dist/bounded-contexts/authoring/domain/ports/emit-rejection.js",
|
|
@@ -40,13 +40,21 @@
|
|
|
40
40
|
"path": "dist/bounded-contexts/authoring/domain/services/directive-factory.js",
|
|
41
41
|
"sha256": "e3718b19c6609139f36d562daa44a4727d0d6d279a90736aa24722ab5df93d92"
|
|
42
42
|
},
|
|
43
|
+
{
|
|
44
|
+
"path": "dist/bounded-contexts/authoring/domain/services/evaluation.js",
|
|
45
|
+
"sha256": "c309775ce55a3858f7804835154a15d17f38736db3abf91ed2c7b5563cbc2b8a"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"path": "dist/bounded-contexts/authoring/domain/services/glob-match.js",
|
|
49
|
+
"sha256": "1518f8ba27114e34a7d0103015934ec98acf09718dc29a59655bbbef71148950"
|
|
50
|
+
},
|
|
43
51
|
{
|
|
44
52
|
"path": "dist/bounded-contexts/authoring/domain/services/run-context.js",
|
|
45
53
|
"sha256": "4c45aa26aa81b2ec59a6b09dbaf14da7be6d034bfc46e2b35aba2bfe0e641a49"
|
|
46
54
|
},
|
|
47
55
|
{
|
|
48
56
|
"path": "dist/bounded-contexts/authoring/domain/services/schema/input-rejection.js",
|
|
49
|
-
"sha256": "
|
|
57
|
+
"sha256": "fb7789824d3d387b796ea303f8d8dde9e9ae3aad2cfcb7226333ecc51e2fe898"
|
|
50
58
|
},
|
|
51
59
|
{
|
|
52
60
|
"path": "dist/bounded-contexts/authoring/domain/services/schema/schema-files.js",
|
|
@@ -58,19 +66,23 @@
|
|
|
58
66
|
},
|
|
59
67
|
{
|
|
60
68
|
"path": "dist/bounded-contexts/authoring/domain/services/schema/schema-parse.js",
|
|
61
|
-
"sha256": "
|
|
69
|
+
"sha256": "5b356f9778b604bb25540e260fe1b040f8bcf46112418c561f492ea3329973ef"
|
|
62
70
|
},
|
|
63
71
|
{
|
|
64
72
|
"path": "dist/bounded-contexts/authoring/domain/services/schema/schema-validate.js",
|
|
65
|
-
"sha256": "
|
|
73
|
+
"sha256": "bfafc4c94a9208b51621db29ad97fbdb8b48cddeabfe60ca78bf77c07450674d"
|
|
66
74
|
},
|
|
67
75
|
{
|
|
68
76
|
"path": "dist/bounded-contexts/authoring/domain/valueobjects/authoring-error.js",
|
|
69
|
-
"sha256": "
|
|
77
|
+
"sha256": "12bcb05ddffaade8ba3cadea33c30d469909e9c034415554456a1e4a765bfd19"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"path": "dist/bounded-contexts/authoring/domain/valueobjects/findings.js",
|
|
81
|
+
"sha256": "ddf9fa8688938ef11066de0e45916c2fa8d159fcd261b5d6641f74105730bc5f"
|
|
70
82
|
},
|
|
71
83
|
{
|
|
72
84
|
"path": "dist/bounded-contexts/authoring/domain/valueobjects/schema-model.js",
|
|
73
|
-
"sha256": "
|
|
85
|
+
"sha256": "6d015200921c8a72ef27941d287d460275bc944620ee9a7c140ad73354bbfc82"
|
|
74
86
|
},
|
|
75
87
|
{
|
|
76
88
|
"path": "dist/bounded-contexts/authoring/domain/valueobjects/wire.js",
|
|
@@ -94,11 +106,11 @@
|
|
|
94
106
|
},
|
|
95
107
|
{
|
|
96
108
|
"path": "dist/bounded-contexts/runner-hosting/infrastructure/in/runner.js",
|
|
97
|
-
"sha256": "
|
|
109
|
+
"sha256": "c2eceb3d4373d03b4782276fd9bef2a49f7048a52671f8a9225adac28309bf78"
|
|
98
110
|
},
|
|
99
111
|
{
|
|
100
112
|
"path": "dist/bounded-contexts/runner-hosting/infrastructure/in/single-instance-probe.js",
|
|
101
|
-
"sha256": "
|
|
113
|
+
"sha256": "5166df63dd3f9aef16b9d53b788cbdc8f67a0337bf537f2b8e166ff214752a96"
|
|
102
114
|
},
|
|
103
115
|
{
|
|
104
116
|
"path": "dist/platform/error-text.js",
|
|
@@ -118,11 +130,23 @@
|
|
|
118
130
|
},
|
|
119
131
|
{
|
|
120
132
|
"path": "dist/shared-kernel/wire-protocol.js",
|
|
121
|
-
"sha256": "
|
|
133
|
+
"sha256": "4668d233d209ad77d5205ffc66b19e79f680b5d9856e8a5f51e563a85211ebd6"
|
|
122
134
|
},
|
|
123
135
|
{
|
|
124
136
|
"path": "package.json",
|
|
125
|
-
"sha256": "
|
|
137
|
+
"sha256": "14a806989d9b9cb3af2dc9bf2cdd1a3e4ddd099d26ac7c23ec2bcbefd227666c"
|
|
126
138
|
}
|
|
139
|
+
],
|
|
140
|
+
"dialects": [
|
|
141
|
+
"angular",
|
|
142
|
+
"aspnet",
|
|
143
|
+
"csharp",
|
|
144
|
+
"css",
|
|
145
|
+
"json",
|
|
146
|
+
"msbuild",
|
|
147
|
+
"nestjs",
|
|
148
|
+
"react",
|
|
149
|
+
"typescript",
|
|
150
|
+
"yaml"
|
|
127
151
|
]
|
|
128
152
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const WIRE_PROTOCOL_VERSION = 1;
|
|
2
2
|
export declare const BRIDGE_CONTRACT_VERSION = 1;
|
|
3
|
-
export declare const REVERSE_CALLBACK_METHODS: readonly ["tree.read", "ir.emit", "ir.commit", "ir.discard"];
|
|
3
|
+
export declare const REVERSE_CALLBACK_METHODS: readonly ["tree.read", "tree.list", "ir.emit", "ir.commit", "ir.discard"];
|
|
4
4
|
export type ReverseMethod = (typeof REVERSE_CALLBACK_METHODS)[number];
|
|
5
5
|
export interface ReadyGreeting {
|
|
6
6
|
method: "ready";
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// guards (WPS-02/03/05/09). design.md § 4.3 Data Model gives these signatures verbatim.
|
|
3
3
|
export const WIRE_PROTOCOL_VERSION = 1; // ready.protocolVersion (transport) — DISTINCT from Batch.protocolVersion (IR)
|
|
4
4
|
export const BRIDGE_CONTRACT_VERSION = 1; // in-process JS bridge; independent of the wire (BRB-01)
|
|
5
|
-
export const REVERSE_CALLBACK_METHODS = ["tree.read", "ir.emit", "ir.commit", "ir.discard"];
|
|
5
|
+
export const REVERSE_CALLBACK_METHODS = ["tree.read", "tree.list", "ir.emit", "ir.commit", "ir.discard"];
|
|
6
6
|
// REQ-WPS-02.3: structural validity is method === "ready" plus an integer protocolVersion —
|
|
7
7
|
// no other shape (missing field, wrong type, non-integer version) qualifies.
|
|
8
8
|
export function isStructurallyValidGreeting(value) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pbuilder/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"description": "The public TypeScript/Bun authoring layer for Project Builder schematics. Authors file mutations (create, replaceContent, remove, rename, move, copy, copyIn), lowers them to IR, and talks to the Project Builder engine over framed stdio (see docs/engine-sdk-wire-spec.md).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|