@pbuilder/sdk 0.15.1 → 0.17.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 +52 -1
- package/dist/bounded-contexts/authoring/domain/services/repeatable.d.ts +19 -0
- package/dist/bounded-contexts/authoring/domain/services/repeatable.js +24 -0
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/aspnet/index.d.ts +48 -0
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/aspnet/index.js +46 -0
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/aspnet/ops.d.ts +11 -0
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/aspnet/ops.js +126 -0
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/csharp/ast.d.ts +29 -0
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/csharp/ast.js +41 -0
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/csharp/index.d.ts +44 -0
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/csharp/index.js +45 -0
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/csharp/names.d.ts +7 -0
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/csharp/names.js +72 -0
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/csharp/ops.d.ts +19 -0
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/csharp/ops.js +255 -0
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/csharp/pack.d.ts +9 -0
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/csharp/pack.js +2 -0
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/csharp/syntax.d.ts +26 -0
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/csharp/syntax.js +111 -0
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/csharp/tree-sitter-c_sharp.LICENSE +23 -0
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/csharp/tree-sitter-c_sharp.wasm +0 -0
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/json/ops.d.ts +4 -4
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/json/ops.js +9 -8
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/msbuild/ast.d.ts +22 -0
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/msbuild/ast.js +17 -0
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/msbuild/index.d.ts +37 -0
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/msbuild/index.js +38 -0
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/msbuild/ops.d.ts +2 -0
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/msbuild/ops.js +93 -0
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/msbuild/xml.d.ts +20 -0
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/msbuild/xml.js +50 -0
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/yaml/documents.d.ts +3 -3
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/yaml/documents.js +5 -4
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/yaml/structural.d.ts +5 -5
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/yaml/structural.js +9 -8
- package/dist/bounded-contexts/authoring/testing/conformance/index.js +27 -0
- package/dist/dialects/aspnet/index.d.ts +1 -0
- package/dist/dialects/aspnet/index.js +1 -0
- package/dist/dialects/csharp/index.d.ts +1 -0
- package/dist/dialects/csharp/index.js +1 -0
- package/dist/dialects/msbuild/index.d.ts +1 -0
- package/dist/dialects/msbuild/index.js +1 -0
- package/dist/runner-manifest.json +6 -2
- package/package.json +20 -2
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { dialectError } from "../../../../domain/valueobjects/dialect-error.js";
|
|
2
|
+
import { validatedOp } from "../../../../domain/services/identifier-names.js";
|
|
3
|
+
import { readElements } from "./xml.js";
|
|
4
|
+
const OP = "addProjectReference";
|
|
5
|
+
const DEFAULT_UNIT = " ";
|
|
6
|
+
function assertPath(path) {
|
|
7
|
+
const rule = "a relative path whose file name ends in `proj`";
|
|
8
|
+
if (typeof path !== "string")
|
|
9
|
+
throw dialectError(`${OP} — \`path\` must be ${rule}.`);
|
|
10
|
+
const fileName = path.slice(Math.max(path.lastIndexOf("/"), path.lastIndexOf("\\")) + 1);
|
|
11
|
+
if (/^([/\\]|[A-Za-z]:)/.test(path) || !fileName.endsWith("proj")) {
|
|
12
|
+
throw dialectError(`${OP} — \`path\` ${JSON.stringify(path)} is not ${rule}.`);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function escapeAttribute(value) {
|
|
16
|
+
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
17
|
+
}
|
|
18
|
+
const sameReference = (a, b) => a.replace(/\\/g, "/") === b.replace(/\\/g, "/");
|
|
19
|
+
/** The whitespace before `offset` on its line, or `undefined` when other text precedes it there. */
|
|
20
|
+
function lineIndent(text, offset) {
|
|
21
|
+
const prefix = text.slice(text.lastIndexOf("\n", offset - 1) + 1, offset);
|
|
22
|
+
return /^[ \t]*$/.test(prefix) ? prefix : undefined;
|
|
23
|
+
}
|
|
24
|
+
/** The first indentation step the file shows between an element and its parent, else two spaces. */
|
|
25
|
+
function indentUnit(text, root) {
|
|
26
|
+
const parents = [root];
|
|
27
|
+
for (const parent of parents) {
|
|
28
|
+
const outer = lineIndent(text, parent.start);
|
|
29
|
+
for (const child of parent.children) {
|
|
30
|
+
const inner = lineIndent(text, child.start);
|
|
31
|
+
if (outer !== undefined && inner !== undefined && inner.length > outer.length && inner.startsWith(outer)) {
|
|
32
|
+
return inner.slice(outer.length);
|
|
33
|
+
}
|
|
34
|
+
parents.push(child);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return DEFAULT_UNIT;
|
|
38
|
+
}
|
|
39
|
+
function* descendants(element) {
|
|
40
|
+
for (const child of element.children) {
|
|
41
|
+
yield child;
|
|
42
|
+
yield* descendants(child);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function splice(doc, from, to, insert) {
|
|
46
|
+
doc.text = doc.text.slice(0, from) + insert + doc.text.slice(to);
|
|
47
|
+
}
|
|
48
|
+
export const addProjectReference = validatedOp(([path]) => assertPath(path), (doc, path) => {
|
|
49
|
+
let project;
|
|
50
|
+
try {
|
|
51
|
+
project = readElements(doc.text);
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
throw dialectError(`${OP}(${JSON.stringify(path)}) — the file is not well-formed XML.`);
|
|
55
|
+
}
|
|
56
|
+
if (project?.name !== "Project") {
|
|
57
|
+
const root = project === undefined ? "the file has no root element" : `the root element is \`${project.name}\``;
|
|
58
|
+
throw dialectError(`${OP}(${JSON.stringify(path)}) — ${root}; it needs \`Project\`.`);
|
|
59
|
+
}
|
|
60
|
+
for (const element of descendants(project)) {
|
|
61
|
+
const include = element.attributes.get("Include");
|
|
62
|
+
if (element.name === "ProjectReference" && include !== undefined && sameReference(include, path))
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const text = doc.text;
|
|
66
|
+
const eol = text.includes("\r\n") ? "\r\n" : "\n";
|
|
67
|
+
const unit = indentUnit(text, project);
|
|
68
|
+
const reference = `<ProjectReference Include="${escapeAttribute(path)}" />`;
|
|
69
|
+
const group = project.children.find((child) => child.name === "ItemGroup" && !child.attributes.has("Condition") && child.children.some((c) => c.name === "ProjectReference"));
|
|
70
|
+
if (group !== undefined) {
|
|
71
|
+
const last = group.children.filter((c) => c.name === "ProjectReference").at(-1);
|
|
72
|
+
const indent = lineIndent(text, last.start) ?? (lineIndent(text, group.start) ?? "") + unit;
|
|
73
|
+
splice(doc, last.end, last.end, `${eol}${indent}${reference}`);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const projectIndent = lineIndent(text, project.start) ?? "";
|
|
77
|
+
const last = project.children.at(-1);
|
|
78
|
+
const indent = (last && lineIndent(text, last.start)) ?? projectIndent + unit;
|
|
79
|
+
const block = `${indent}<ItemGroup>${eol}${indent}${unit}${reference}${eol}${indent}</ItemGroup>`;
|
|
80
|
+
if (last !== undefined) {
|
|
81
|
+
splice(doc, last.end, last.end, `${eol}${eol}${block}`);
|
|
82
|
+
}
|
|
83
|
+
else if (project.selfClosing) {
|
|
84
|
+
let cut = text.lastIndexOf("/", project.end - 1);
|
|
85
|
+
while (/\s/.test(text[cut - 1]))
|
|
86
|
+
cut--;
|
|
87
|
+
splice(doc, cut, project.end, `>${eol}${block}${eol}${projectIndent}</Project>`);
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
const closeOnOwnLine = text.slice(project.openEnd, project.closeStart).includes("\n");
|
|
91
|
+
splice(doc, project.openEnd, project.openEnd, `${eol}${block}${closeOnOwnLine ? "" : eol + projectIndent}`);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One element with its source offsets: `start` is its `<`, `openEnd` is just past its open
|
|
3
|
+
* tag's `>`, `closeStart` is the `<` of its close tag, and `end` is just past the element.
|
|
4
|
+
* A self-closing element has `openEnd === closeStart === end`.
|
|
5
|
+
*/
|
|
6
|
+
export interface XmlElement {
|
|
7
|
+
name: string;
|
|
8
|
+
attributes: ReadonlyMap<string, string>;
|
|
9
|
+
start: number;
|
|
10
|
+
openEnd: number;
|
|
11
|
+
closeStart: number;
|
|
12
|
+
end: number;
|
|
13
|
+
selfClosing: boolean;
|
|
14
|
+
children: XmlElement[];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Reads the element tree of `text`, or `undefined` for an empty text, throwing on anything
|
|
18
|
+
* that is not well-formed XML 1.0.
|
|
19
|
+
*/
|
|
20
|
+
export declare function readElements(text: string): XmlElement | undefined;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { SaxesParser } from "saxes";
|
|
2
|
+
/**
|
|
3
|
+
* Reads the element tree of `text`, or `undefined` for an empty text, throwing on anything
|
|
4
|
+
* that is not well-formed XML 1.0.
|
|
5
|
+
*/
|
|
6
|
+
export function readElements(text) {
|
|
7
|
+
if (text === "")
|
|
8
|
+
return undefined;
|
|
9
|
+
const parser = new SaxesParser({ position: true });
|
|
10
|
+
const stack = [];
|
|
11
|
+
let root;
|
|
12
|
+
let failed = false;
|
|
13
|
+
parser.on("error", () => {
|
|
14
|
+
failed = true;
|
|
15
|
+
});
|
|
16
|
+
// `position` sits just past the tag's `>`; a raw `<` cannot occur inside a tag, so the last
|
|
17
|
+
// one before it is the tag's start.
|
|
18
|
+
parser.on("opentag", (node) => {
|
|
19
|
+
const openEnd = parser.position;
|
|
20
|
+
const element = {
|
|
21
|
+
name: node.name,
|
|
22
|
+
attributes: new Map(Object.entries(node.attributes)),
|
|
23
|
+
start: text.lastIndexOf("<", openEnd - 1),
|
|
24
|
+
openEnd,
|
|
25
|
+
closeStart: openEnd,
|
|
26
|
+
end: openEnd,
|
|
27
|
+
selfClosing: node.isSelfClosing,
|
|
28
|
+
children: [],
|
|
29
|
+
};
|
|
30
|
+
(stack.at(-1)?.children ?? []).push(element);
|
|
31
|
+
root ??= element;
|
|
32
|
+
stack.push(element);
|
|
33
|
+
});
|
|
34
|
+
parser.on("closetag", () => {
|
|
35
|
+
const element = stack.pop();
|
|
36
|
+
if (element.selfClosing)
|
|
37
|
+
return;
|
|
38
|
+
element.end = parser.position;
|
|
39
|
+
element.closeStart = text.lastIndexOf("<", element.end - 1);
|
|
40
|
+
});
|
|
41
|
+
try {
|
|
42
|
+
parser.write(text).close();
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
failed = true;
|
|
46
|
+
}
|
|
47
|
+
if (failed || root === undefined)
|
|
48
|
+
throw new Error("invalid XML");
|
|
49
|
+
return root;
|
|
50
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type YamlStream } from "./ast.ts";
|
|
2
2
|
import { type YamlValue } from "./paths.ts";
|
|
3
3
|
/** Inserts a document holding `value` at `options.index`, by default at the end. */
|
|
4
|
-
export declare
|
|
4
|
+
export declare const addDocument: (ast: YamlStream, value: YamlValue, options?: {
|
|
5
5
|
index?: number;
|
|
6
|
-
})
|
|
6
|
+
}) => void;
|
|
7
7
|
/** Removes the document at `index`. */
|
|
8
|
-
export declare
|
|
8
|
+
export declare const removeDocument: (ast: YamlStream, index: number) => void;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// Document-level ops for multi-document files.
|
|
2
|
+
import { repeatable } from "../../../../domain/services/repeatable.js";
|
|
2
3
|
import { newDocument } from "./ast.js";
|
|
3
4
|
import { assertValue, fail, isPlainObject } from "./paths.js";
|
|
4
5
|
function assertIndex(op, index, max) {
|
|
@@ -7,18 +8,18 @@ function assertIndex(op, index, max) {
|
|
|
7
8
|
}
|
|
8
9
|
}
|
|
9
10
|
/** Inserts a document holding `value` at `options.index`, by default at the end. */
|
|
10
|
-
export function addDocument(ast, value, options) {
|
|
11
|
+
export const addDocument = repeatable(function addDocument(ast, value, options) {
|
|
11
12
|
assertValue("addDocument", [], value);
|
|
12
13
|
if (options !== undefined && !isPlainObject(options))
|
|
13
14
|
fail("addDocument", null, "options must be a plain object.");
|
|
14
15
|
const index = options?.index ?? ast.documents.length;
|
|
15
16
|
assertIndex("addDocument", index, ast.documents.length);
|
|
16
17
|
ast.documents.splice(index, 0, newDocument(value));
|
|
17
|
-
}
|
|
18
|
+
});
|
|
18
19
|
/** Removes the document at `index`. */
|
|
19
|
-
export function removeDocument(ast, index) {
|
|
20
|
+
export const removeDocument = repeatable(function removeDocument(ast, index) {
|
|
20
21
|
if (typeof index !== "number" || !Number.isInteger(index) || index < 0 || index >= ast.documents.length) {
|
|
21
22
|
fail("removeDocument", null, `document ${String(index)} is out of range; the file has ${ast.documents.length} document(s).`);
|
|
22
23
|
}
|
|
23
24
|
ast.documents.splice(index, 1);
|
|
24
|
-
}
|
|
25
|
+
});
|
|
@@ -10,19 +10,19 @@ export declare function removeKey(ast: YamlStream, path: YamlPath, options?: Doc
|
|
|
10
10
|
/** Renames a mapping key in place, keeping its value, position, and comments. */
|
|
11
11
|
export declare function renameKey(ast: YamlStream, path: YamlPath, newKey: string, options?: DocumentOption): void;
|
|
12
12
|
/** Inserts a sequence item before `index`; `index` equal to the length appends. */
|
|
13
|
-
export declare
|
|
13
|
+
export declare const insertItem: (ast: YamlStream, path: YamlPath, index: number, value: YamlValue, options?: DocumentOption) => void;
|
|
14
14
|
/** Appends a sequence item, creating the sequence; `{ unique: true }` skips a deep-equal duplicate. */
|
|
15
|
-
export declare
|
|
15
|
+
export declare const appendItem: (ast: YamlStream, path: YamlPath, value: YamlValue, options?: DocumentOption & {
|
|
16
16
|
unique?: boolean;
|
|
17
|
-
})
|
|
17
|
+
}) => void;
|
|
18
18
|
/** Removes the sequence item at `index`. */
|
|
19
|
-
export declare
|
|
19
|
+
export declare const removeItem: (ast: YamlStream, path: YamlPath, index: number, options?: DocumentOption) => void;
|
|
20
20
|
/** Removes every sequence item deep-equal to `value`; no match is a no-op. */
|
|
21
21
|
export declare function removeValue(ast: YamlStream, path: YamlPath, value: YamlValue, options?: DocumentOption): void;
|
|
22
22
|
/** Replaces the sequence item at `index`, keeping its comments. */
|
|
23
23
|
export declare function replaceItem(ast: YamlStream, path: YamlPath, index: number, value: YamlValue, options?: DocumentOption): void;
|
|
24
24
|
/** Moves the item at `from` so it sits at `to`; the others keep their relative order. */
|
|
25
|
-
export declare
|
|
25
|
+
export declare const moveItem: (ast: YamlStream, path: YamlPath, from: number, to: number, options?: DocumentOption) => void;
|
|
26
26
|
/** Deep-merges a plain object into the mapping at `path`, creating it when absent. */
|
|
27
27
|
export declare function merge(ast: YamlStream, path: YamlPath, value: {
|
|
28
28
|
[key: string]: YamlValue;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Structural ops: the JSON dialect's catalogue over `yaml` nodes, with "object" read as mapping
|
|
2
2
|
// and "array" as sequence.
|
|
3
|
+
import { repeatable } from "../../../../domain/services/repeatable.js";
|
|
3
4
|
import { isAlias, isMap, isSeq } from "yaml";
|
|
4
5
|
import { deepEqual } from "../../../../../../platform/deep-equal.js";
|
|
5
6
|
import { formatPath } from "../../../../domain/valueobjects/json-value.js";
|
|
@@ -101,16 +102,16 @@ function assertIndex(op, path, index, max) {
|
|
|
101
102
|
}
|
|
102
103
|
}
|
|
103
104
|
/** Inserts a sequence item before `index`; `index` equal to the length appends. */
|
|
104
|
-
export function insertItem(ast, path, index, value, options) {
|
|
105
|
+
export const insertItem = repeatable(function insertItem(ast, path, index, value, options) {
|
|
105
106
|
assertPath("insertItem", path);
|
|
106
107
|
assertValue("insertItem", path, value);
|
|
107
108
|
const document = selectDocument("insertItem", ast, options);
|
|
108
109
|
const seq = requireSequence("insertItem", document, path);
|
|
109
110
|
assertIndex("insertItem", path, index, seq.items.length);
|
|
110
111
|
seq.items.splice(index, 0, createNode(document, value));
|
|
111
|
-
}
|
|
112
|
+
});
|
|
112
113
|
/** Appends a sequence item, creating the sequence; `{ unique: true }` skips a deep-equal duplicate. */
|
|
113
|
-
export function appendItem(ast, path, value, options) {
|
|
114
|
+
export const appendItem = repeatable(function appendItem(ast, path, value, options) {
|
|
114
115
|
assertPath("appendItem", path);
|
|
115
116
|
assertValue("appendItem", path, value);
|
|
116
117
|
const document = selectDocument("appendItem", ast, options, true);
|
|
@@ -118,16 +119,16 @@ export function appendItem(ast, path, value, options) {
|
|
|
118
119
|
if (options?.unique === true && seq.items.some((item) => deepEqual(toValue(document, item), value)))
|
|
119
120
|
return;
|
|
120
121
|
seq.items.push(createNode(document, value));
|
|
121
|
-
}
|
|
122
|
+
});
|
|
122
123
|
/** Removes the sequence item at `index`. */
|
|
123
|
-
export function removeItem(ast, path, index, options) {
|
|
124
|
+
export const removeItem = repeatable(function removeItem(ast, path, index, options) {
|
|
124
125
|
assertPath("removeItem", path);
|
|
125
126
|
const document = selectDocument("removeItem", ast, options);
|
|
126
127
|
const seq = requireSequence("removeItem", document, path);
|
|
127
128
|
assertIndex("removeItem", path, index, seq.items.length - 1);
|
|
128
129
|
seq.items.splice(index, 1);
|
|
129
130
|
assertAliasesResolve("removeItem", document);
|
|
130
|
-
}
|
|
131
|
+
});
|
|
131
132
|
/** Removes every sequence item deep-equal to `value`; no match is a no-op. */
|
|
132
133
|
export function removeValue(ast, path, value, options) {
|
|
133
134
|
assertPath("removeValue", path);
|
|
@@ -153,7 +154,7 @@ export function replaceItem(ast, path, index, value, options) {
|
|
|
153
154
|
assertAliasesResolve("replaceItem", document);
|
|
154
155
|
}
|
|
155
156
|
/** Moves the item at `from` so it sits at `to`; the others keep their relative order. */
|
|
156
|
-
export function moveItem(ast, path, from, to, options) {
|
|
157
|
+
export const moveItem = repeatable(function moveItem(ast, path, from, to, options) {
|
|
157
158
|
assertPath("moveItem", path);
|
|
158
159
|
const document = selectDocument("moveItem", ast, options);
|
|
159
160
|
const seq = requireSequence("moveItem", document, path);
|
|
@@ -162,7 +163,7 @@ export function moveItem(ast, path, from, to, options) {
|
|
|
162
163
|
const [item] = seq.items.splice(from, 1);
|
|
163
164
|
seq.items.splice(to, 0, item);
|
|
164
165
|
assertAliasesResolve("moveItem", document);
|
|
165
|
-
}
|
|
166
|
+
});
|
|
166
167
|
function changes(current, incoming) {
|
|
167
168
|
if (!isPlainObject(current))
|
|
168
169
|
return true;
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
// Drives real runs via `defineFactory` + the kit-internal `run-vehicle.ts` transport —
|
|
15
15
|
// imported for INTERNAL use only, never re-exported (FIT-08 bans re-export of kit symbols
|
|
16
16
|
// from this path, not internal use of them).
|
|
17
|
+
import { isRepeatable } from "../../domain/services/repeatable.js";
|
|
17
18
|
import { defineFactory } from "../../application/usecases/run-factory/context.js";
|
|
18
19
|
import { deepEqual } from "../../../../platform/deep-equal.js";
|
|
19
20
|
import { createRunVehicle } from "../run-vehicle.js";
|
|
@@ -68,6 +69,31 @@ async function runExercise(dialect, exercise, opts) {
|
|
|
68
69
|
.map((d) => d.modify);
|
|
69
70
|
return { modifies, directives };
|
|
70
71
|
}
|
|
72
|
+
// A-11: every op that sets a state is idempotent, so applying the chain again to its own
|
|
73
|
+
// result leaves the file as it is. A chain holding an op the dialect declares `repeatable`, or
|
|
74
|
+
// a `.modify` step (author code, not a dialect op), is not checked.
|
|
75
|
+
async function assertIdempotent(fixture, exercise) {
|
|
76
|
+
const opNames = [];
|
|
77
|
+
for (const step of exercise.chain) {
|
|
78
|
+
if ("modify" in step)
|
|
79
|
+
return;
|
|
80
|
+
if (isRepeatable(fixture.baseDialect.ops[step.op]) || isRepeatable(fixture.opPack[step.op]))
|
|
81
|
+
return;
|
|
82
|
+
opNames.push(step.op);
|
|
83
|
+
}
|
|
84
|
+
let again;
|
|
85
|
+
try {
|
|
86
|
+
again = await runExercise(fixture.baseDialect, { seed: exercise.expect, path: exercise.path, chain: exercise.chain }, { injectReadAfterFirstOp: false });
|
|
87
|
+
}
|
|
88
|
+
catch (err) {
|
|
89
|
+
throw new Error(`testOpPack: A-11 idempotency — re-applying the chain [${opNames.join(", ")}] to its own result threw: ` +
|
|
90
|
+
(err instanceof Error ? err.message : String(err)));
|
|
91
|
+
}
|
|
92
|
+
if (again.modifies.some((modify) => modify.content !== exercise.expect)) {
|
|
93
|
+
throw new Error(`testOpPack: A-11 idempotency — applying the chain [${opNames.join(", ")}] again to its own result changed the file; ` +
|
|
94
|
+
"an op whose effect depends on how many times it is applied must be declared with repeatable()");
|
|
95
|
+
}
|
|
96
|
+
}
|
|
71
97
|
// REQ-DC-06 (ADR-0012 amendment clause 1): four mandatory adversarial samples, injected
|
|
72
98
|
// ADDITIVELY into every `testDialect`/`testOpPack` run — `DialectFixture` carries no field
|
|
73
99
|
// capable of disabling this (compile-level guarantee, REQ-DC-06.2, see test/conformance/planted/
|
|
@@ -246,6 +272,7 @@ export async function testOpPack(fixture) {
|
|
|
246
272
|
throw new Error("testOpPack: REQ-DC-05.2 — the cumulative (second) split directive's content did not byte-exact match the fixture's expect value");
|
|
247
273
|
}
|
|
248
274
|
}
|
|
275
|
+
await assertIdempotent(fixture, exercise);
|
|
249
276
|
}
|
|
250
277
|
// REQ-DC-06/REQ-DC-08 (verify-in-loop-4 Finding #1): the four mandatory adversarial
|
|
251
278
|
// samples' round-trip + real-base probe, run against `fixture.baseDialect` — same
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../../bounded-contexts/authoring/infrastructure/out/dialects/aspnet/index.ts";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../../bounded-contexts/authoring/infrastructure/out/dialects/aspnet/index.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../../bounded-contexts/authoring/infrastructure/out/dialects/csharp/index.ts";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../../bounded-contexts/authoring/infrastructure/out/dialects/csharp/index.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../../bounded-contexts/authoring/infrastructure/out/dialects/msbuild/index.ts";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../../bounded-contexts/authoring/infrastructure/out/dialects/msbuild/index.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.17.0",
|
|
6
6
|
"files": [
|
|
7
7
|
{
|
|
8
8
|
"path": "dist/acl/irwire/frame-reader.js",
|
|
@@ -76,6 +76,10 @@
|
|
|
76
76
|
"path": "dist/bounded-contexts/authoring/domain/valueobjects/wire.js",
|
|
77
77
|
"sha256": "965bd72c7ec6f914edc717cf2fd4aaff6395857fb486f0301e2fb4e0977e0616"
|
|
78
78
|
},
|
|
79
|
+
{
|
|
80
|
+
"path": "dist/bounded-contexts/authoring/infrastructure/out/dialects/csharp/tree-sitter-c_sharp.wasm",
|
|
81
|
+
"sha256": "e137386fcdfc2562a058f8048c76ab77b0663a318cb62d8026cd4d2e94944231"
|
|
82
|
+
},
|
|
79
83
|
{
|
|
80
84
|
"path": "dist/bounded-contexts/authoring/infrastructure/out/fs/package-files.js",
|
|
81
85
|
"sha256": "58a0bef6c4a7649dbbd5b5890f5cdeacb85bfdf9f805d973b22f2ce2e09e79da"
|
|
@@ -118,7 +122,7 @@
|
|
|
118
122
|
},
|
|
119
123
|
{
|
|
120
124
|
"path": "package.json",
|
|
121
|
-
"sha256": "
|
|
125
|
+
"sha256": "3eb04bed3bfdd43ea2f25b0c13267688c052056eddc410ec6cfc0b7f0f7df927"
|
|
122
126
|
}
|
|
123
127
|
]
|
|
124
128
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pbuilder/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.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",
|
|
@@ -92,6 +92,21 @@
|
|
|
92
92
|
"types": "./dist/dialects/css/index.d.ts",
|
|
93
93
|
"import": "./dist/dialects/css/index.js",
|
|
94
94
|
"default": "./dist/dialects/css/index.js"
|
|
95
|
+
},
|
|
96
|
+
"./csharp": {
|
|
97
|
+
"types": "./dist/dialects/csharp/index.d.ts",
|
|
98
|
+
"import": "./dist/dialects/csharp/index.js",
|
|
99
|
+
"default": "./dist/dialects/csharp/index.js"
|
|
100
|
+
},
|
|
101
|
+
"./aspnet": {
|
|
102
|
+
"types": "./dist/dialects/aspnet/index.d.ts",
|
|
103
|
+
"import": "./dist/dialects/aspnet/index.js",
|
|
104
|
+
"default": "./dist/dialects/aspnet/index.js"
|
|
105
|
+
},
|
|
106
|
+
"./msbuild": {
|
|
107
|
+
"types": "./dist/dialects/msbuild/index.d.ts",
|
|
108
|
+
"import": "./dist/dialects/msbuild/index.js",
|
|
109
|
+
"default": "./dist/dialects/msbuild/index.js"
|
|
95
110
|
}
|
|
96
111
|
},
|
|
97
112
|
"scripts": {
|
|
@@ -99,7 +114,8 @@
|
|
|
99
114
|
"typecheck": "tsc --noEmit",
|
|
100
115
|
"typecheck:permissive-proof": "tsc --noEmit -p tsconfig.permissive-proof.json",
|
|
101
116
|
"prebuild": "rm -rf dist",
|
|
102
|
-
"build": "tsc -p tsconfig.build.json && bun run build:codegen && bun run build:manifest",
|
|
117
|
+
"build": "tsc -p tsconfig.build.json && bun run build:assets && bun run build:codegen && bun run build:manifest",
|
|
118
|
+
"build:assets": "bun scripts/copy-dist-assets.ts",
|
|
103
119
|
"build:codegen": "bun build bin/pbuilder-codegen.ts --outfile dist/bin/pbuilder-codegen.js --target node --banner \"#!/usr/bin/env node\"",
|
|
104
120
|
"build:manifest": "bun scripts/generate-runner-manifest.ts",
|
|
105
121
|
"regen:closure-baseline": "bun scripts/regen-closure-baseline.ts",
|
|
@@ -124,7 +140,9 @@
|
|
|
124
140
|
"dependencies": {
|
|
125
141
|
"jsonc-parser": "3.3.1",
|
|
126
142
|
"postcss": "8.5.30",
|
|
143
|
+
"saxes": "6.0.0",
|
|
127
144
|
"ts-morph": "28.0.0",
|
|
145
|
+
"web-tree-sitter": "0.27.2",
|
|
128
146
|
"yaml": "2.9.1"
|
|
129
147
|
}
|
|
130
148
|
}
|