@pbuilder/sdk 0.13.0 → 0.15.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 +57 -42
- package/dist/{transport → acl/irwire}/frame-reader.d.ts +2 -0
- package/dist/{transport → acl/irwire}/frame-reader.js +57 -5
- package/dist/{transport → acl/irwire}/stdio-engine-client.d.ts +2 -2
- package/dist/{transport → acl/irwire}/stdio-engine-client.js +4 -4
- package/dist/bin/pbuilder-codegen.js +30 -35
- package/dist/bin/pbuilder-runner.js +6 -6
- package/dist/bounded-contexts/authoring/application/usecases/authoring-verbs/index.d.ts +106 -0
- package/dist/bounded-contexts/authoring/application/usecases/authoring-verbs/index.js +202 -0
- package/dist/{pending-directives → bounded-contexts/authoring/application/usecases/pending-directives}/render.d.ts +2 -2
- package/dist/{core → bounded-contexts/authoring/application/usecases/run-factory}/context.d.ts +12 -9
- package/dist/{core → bounded-contexts/authoring/application/usecases/run-factory}/context.js +59 -120
- package/dist/bounded-contexts/authoring/application/usecases/run-factory/driving.d.ts +5 -0
- package/dist/bounded-contexts/authoring/application/usecases/run-factory/driving.js +15 -0
- package/dist/bounded-contexts/authoring/application/usecases/scaffold/classify-transport.d.ts +51 -0
- package/dist/bounded-contexts/authoring/application/usecases/scaffold/classify-transport.js +105 -0
- package/dist/{scaffold → bounded-contexts/authoring/application/usecases/scaffold}/expander.d.ts +2 -1
- package/dist/{scaffold → bounded-contexts/authoring/application/usecases/scaffold}/expander.js +16 -7
- package/dist/{scaffold → bounded-contexts/authoring/application/usecases/scaffold}/index.d.ts +1 -1
- package/dist/{scaffold → bounded-contexts/authoring/application/usecases/scaffold}/index.js +7 -6
- package/dist/{scaffold → bounded-contexts/authoring/application/usecases/scaffold}/path-guards.d.ts +11 -10
- package/dist/{scaffold → bounded-contexts/authoring/application/usecases/scaffold}/path-guards.js +21 -48
- package/dist/{scaffold → bounded-contexts/authoring/application/usecases/scaffold}/walk.d.ts +2 -3
- package/dist/{scaffold → bounded-contexts/authoring/application/usecases/scaffold}/walk.js +37 -56
- package/dist/{core → bounded-contexts/authoring/domain/aggregates/session}/session.d.ts +2 -2
- package/dist/{core → bounded-contexts/authoring/domain/aggregates/session}/session.js +1 -1
- package/dist/{core → bounded-contexts/authoring/domain/entities}/dialect-handle.d.ts +1 -1
- package/dist/{core → bounded-contexts/authoring/domain/entities}/dialect-handle.js +10 -10
- package/dist/{core → bounded-contexts/authoring/domain/ports}/engine-client.d.ts +1 -1
- package/dist/bounded-contexts/authoring/domain/ports/package-files.d.ts +53 -0
- package/dist/bounded-contexts/authoring/domain/ports/package-files.js +11 -0
- package/dist/{core → bounded-contexts/authoring/domain/services}/define-dialect.d.ts +2 -2
- package/dist/{core → bounded-contexts/authoring/domain/services}/define-dialect.js +3 -3
- package/dist/{core → bounded-contexts/authoring/domain/services}/directive-factory.d.ts +2 -2
- package/dist/{core → bounded-contexts/authoring/domain/services}/directive-factory.js +37 -12
- package/dist/{scaffold → bounded-contexts/authoring/domain/services}/filename-pipeline.d.ts +11 -1
- package/dist/{scaffold → bounded-contexts/authoring/domain/services}/filename-pipeline.js +94 -3
- package/dist/{core/jsx-name-validator.d.ts → bounded-contexts/authoring/domain/services/identifier-names.d.ts} +8 -4
- package/dist/{core/jsx-name-validator.js → bounded-contexts/authoring/domain/services/identifier-names.js} +21 -28
- package/dist/bounded-contexts/authoring/domain/services/reject-tail.d.ts +9 -0
- package/dist/bounded-contexts/authoring/domain/services/reject-tail.js +30 -0
- package/dist/bounded-contexts/authoring/domain/services/run-context.d.ts +5 -0
- package/dist/bounded-contexts/authoring/domain/services/run-context.js +70 -0
- package/dist/{core → bounded-contexts/authoring/domain/services}/schema/input-rejection.d.ts +1 -1
- package/dist/{core → bounded-contexts/authoring/domain/services}/schema/input-rejection.js +1 -1
- package/dist/bounded-contexts/authoring/domain/services/schema/schema-files.d.ts +2 -0
- package/dist/bounded-contexts/authoring/domain/services/schema/schema-files.js +6 -0
- package/dist/{core → bounded-contexts/authoring/domain/services}/schema/schema-locate.d.ts +2 -1
- package/dist/{core → bounded-contexts/authoring/domain/services}/schema/schema-locate.js +13 -2
- package/dist/{core → bounded-contexts/authoring/domain/services}/schema/schema-parse.d.ts +1 -1
- package/dist/{core → bounded-contexts/authoring/domain/services}/schema/schema-parse.js +2 -14
- package/dist/{core → bounded-contexts/authoring/domain/services}/schema/schema-sufficiency.d.ts +4 -3
- package/dist/{core → bounded-contexts/authoring/domain/services}/schema/schema-sufficiency.js +8 -4
- package/dist/{core → bounded-contexts/authoring/domain/services}/schema/schema-validate.d.ts +1 -1
- package/dist/{core → bounded-contexts/authoring/domain/services}/schema/schema-validate.js +1 -1
- package/dist/{core → bounded-contexts/authoring/domain/valueobjects}/authoring-error.js +1 -1
- package/dist/{core → bounded-contexts/authoring/domain/valueobjects}/wire.d.ts +0 -3
- package/dist/bounded-contexts/authoring/domain/valueobjects/wire.js +28 -0
- package/dist/bounded-contexts/authoring/infrastructure/in/codegen/cli.d.ts +27 -0
- package/dist/bounded-contexts/authoring/infrastructure/in/codegen/cli.js +306 -0
- package/dist/bounded-contexts/authoring/infrastructure/in/codegen/emit-type.d.ts +7 -0
- package/dist/bounded-contexts/authoring/infrastructure/in/codegen/emit-type.js +68 -0
- package/dist/bounded-contexts/authoring/infrastructure/in/codegen/project-codegen.d.ts +19 -0
- package/dist/bounded-contexts/authoring/infrastructure/in/codegen/project-codegen.js +131 -0
- package/dist/bounded-contexts/authoring/infrastructure/in/commons/index.d.ts +182 -0
- package/dist/bounded-contexts/authoring/infrastructure/in/commons/index.js +94 -0
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/angular/index.d.ts +63 -0
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/angular/index.js +68 -0
- package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/angular/ops.js +9 -9
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/css/index.d.ts +40 -0
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/css/index.js +38 -0
- package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/css/ops.js +2 -2
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/json/index.d.ts +55 -0
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/json/index.js +54 -0
- package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/json/ops.d.ts +1 -1
- package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/json/ops.js +35 -8
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/nestjs/index.d.ts +43 -0
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/nestjs/index.js +46 -0
- package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/nestjs/ops.js +7 -7
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/react/index.d.ts +52 -0
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/react/index.js +73 -0
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/react/jsx-names.d.ts +4 -0
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/react/jsx-names.js +18 -0
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/react/match-tails.d.ts +4 -0
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/react/match-tails.js +25 -0
- package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/react/ops.js +5 -3
- package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/typescript/array-element.d.ts +7 -2
- package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/typescript/array-element.js +29 -15
- package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/typescript/ast.d.ts +5 -1
- package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/typescript/ast.js +22 -4
- package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/typescript/class-property.js +14 -19
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/typescript/index.d.ts +53 -0
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/typescript/index.js +37 -0
- package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/typescript/ops.d.ts +6 -1
- package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/typescript/ops.js +90 -54
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/yaml/index.d.ts +69 -0
- package/dist/bounded-contexts/authoring/infrastructure/out/dialects/yaml/index.js +70 -0
- package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/yaml/paths.d.ts +1 -1
- package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/yaml/paths.js +2 -2
- package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/yaml/presentation.js +1 -1
- package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/yaml/structural.js +2 -2
- package/dist/bounded-contexts/authoring/infrastructure/out/fs/package-files.d.ts +8 -0
- package/dist/bounded-contexts/authoring/infrastructure/out/fs/package-files.js +133 -0
- package/dist/bounded-contexts/authoring/testing/conformance/index.d.ts +157 -0
- package/dist/bounded-contexts/authoring/testing/conformance/index.js +261 -0
- package/dist/{testing → bounded-contexts/authoring/testing}/contract-fake.d.ts +2 -2
- package/dist/{testing → bounded-contexts/authoring/testing}/contract-fake.js +4 -3
- package/dist/bounded-contexts/authoring/testing/harness/index.d.ts +89 -0
- package/dist/bounded-contexts/authoring/testing/harness/index.js +85 -0
- package/dist/{conformance → bounded-contexts/authoring/testing}/run-vehicle.d.ts +1 -1
- package/dist/{transport → bounded-contexts/runner-hosting/infrastructure/in}/bootstrap-bridge.js +2 -2
- package/dist/{transport → bounded-contexts/runner-hosting/infrastructure/in}/exit-codes.js +5 -4
- package/dist/{transport → bounded-contexts/runner-hosting/infrastructure/in}/factory-pointer.js +1 -1
- package/dist/{transport → bounded-contexts/runner-hosting/infrastructure/in}/runner.d.ts +4 -0
- package/dist/{transport → bounded-contexts/runner-hosting/infrastructure/in}/runner.js +49 -23
- package/dist/{transport → bounded-contexts/runner-hosting/infrastructure/in}/single-instance-probe.js +1 -1
- package/dist/commons/index.d.ts +1 -278
- package/dist/commons/index.js +1 -286
- package/dist/conformance/index.d.ts +1 -157
- package/dist/conformance/index.js +1 -261
- package/dist/dialects/angular/index.d.ts +1 -63
- package/dist/dialects/angular/index.js +1 -68
- package/dist/dialects/css/index.d.ts +1 -40
- package/dist/dialects/css/index.js +1 -38
- package/dist/dialects/json/index.d.ts +1 -55
- package/dist/dialects/json/index.js +1 -54
- package/dist/dialects/nestjs/index.d.ts +1 -43
- package/dist/dialects/nestjs/index.js +1 -46
- package/dist/dialects/react/index.d.ts +1 -52
- package/dist/dialects/react/index.js +1 -73
- package/dist/dialects/typescript/index.d.ts +1 -53
- package/dist/dialects/typescript/index.js +1 -37
- package/dist/dialects/yaml/index.d.ts +1 -69
- package/dist/dialects/yaml/index.js +1 -70
- package/dist/{core → platform}/deep-equal.js +2 -2
- package/dist/{transport → platform}/error-text.js +2 -2
- package/dist/runner-manifest.json +66 -46
- package/dist/shared-kernel/batch-cap.d.ts +4 -0
- package/dist/{core/wire.js → shared-kernel/batch-cap.js} +9 -26
- package/dist/{transport → shared-kernel}/framing.js +2 -2
- package/dist/{transport → shared-kernel}/wire-protocol.js +1 -1
- package/dist/testing/index.d.ts +1 -84
- package/dist/testing/index.js +1 -82
- package/package.json +9 -3
- package/dist/core/index.d.ts +0 -10
- package/dist/core/index.js +0 -6
- package/dist/core/reject-tail.d.ts +0 -13
- package/dist/core/reject-tail.js +0 -52
- package/dist/core/schema/schema-discovery.d.ts +0 -13
- package/dist/core/schema/schema-discovery.js +0 -51
- package/dist/scaffold/classify-transport.d.ts +0 -54
- package/dist/scaffold/classify-transport.js +0 -119
- /package/dist/{pending-directives → bounded-contexts/authoring/application/usecases/pending-directives}/index.d.ts +0 -0
- /package/dist/{pending-directives → bounded-contexts/authoring/application/usecases/pending-directives}/index.js +0 -0
- /package/dist/{pending-directives → bounded-contexts/authoring/application/usecases/pending-directives}/render.js +0 -0
- /package/dist/{core → bounded-contexts/authoring/domain/entities}/base-handle.d.ts +0 -0
- /package/dist/{core → bounded-contexts/authoring/domain/entities}/base-handle.js +0 -0
- /package/dist/{core → bounded-contexts/authoring/domain/entities}/handle-state.d.ts +0 -0
- /package/dist/{core → bounded-contexts/authoring/domain/entities}/handle-state.js +0 -0
- /package/dist/{core → bounded-contexts/authoring/domain/ports}/emit-rejection.d.ts +0 -0
- /package/dist/{core → bounded-contexts/authoring/domain/ports}/emit-rejection.js +0 -0
- /package/dist/{core → bounded-contexts/authoring/domain/ports}/engine-client.js +0 -0
- /package/dist/{commons → bounded-contexts/authoring/domain/services}/classify-content.d.ts +0 -0
- /package/dist/{commons → bounded-contexts/authoring/domain/services}/classify-content.js +0 -0
- /package/dist/{core → bounded-contexts/authoring/domain/services}/schema/schema-digest.d.ts +0 -0
- /package/dist/{core → bounded-contexts/authoring/domain/services}/schema/schema-digest.js +0 -0
- /package/dist/{core → bounded-contexts/authoring/domain/valueobjects}/authoring-error.d.ts +0 -0
- /package/dist/{core → bounded-contexts/authoring/domain/valueobjects}/dialect-error.d.ts +0 -0
- /package/dist/{core → bounded-contexts/authoring/domain/valueobjects}/dialect-error.js +0 -0
- /package/dist/{core → bounded-contexts/authoring/domain/valueobjects}/json-value.d.ts +0 -0
- /package/dist/{core → bounded-contexts/authoring/domain/valueobjects}/json-value.js +0 -0
- /package/dist/{core/schema → bounded-contexts/authoring/domain/valueobjects}/schema-model.d.ts +0 -0
- /package/dist/{core/schema → bounded-contexts/authoring/domain/valueobjects}/schema-model.js +0 -0
- /package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/angular/ops.d.ts +0 -0
- /package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/css/ast.d.ts +0 -0
- /package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/css/ast.js +0 -0
- /package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/css/ops.d.ts +0 -0
- /package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/json/ast.d.ts +0 -0
- /package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/json/ast.js +0 -0
- /package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/nestjs/ops.d.ts +0 -0
- /package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/react/ast.d.ts +0 -0
- /package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/react/ast.js +0 -0
- /package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/react/ops.d.ts +0 -0
- /package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/typescript/class-property.d.ts +0 -0
- /package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/typescript/import-order.d.ts +0 -0
- /package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/typescript/import-order.js +0 -0
- /package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/typescript/pack.d.ts +0 -0
- /package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/typescript/pack.js +0 -0
- /package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/yaml/ast.d.ts +0 -0
- /package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/yaml/ast.js +0 -0
- /package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/yaml/documents.d.ts +0 -0
- /package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/yaml/documents.js +0 -0
- /package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/yaml/presentation.d.ts +0 -0
- /package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/yaml/structural.d.ts +0 -0
- /package/dist/{testing → bounded-contexts/authoring/testing}/rejection-messages.d.ts +0 -0
- /package/dist/{testing → bounded-contexts/authoring/testing}/rejection-messages.js +0 -0
- /package/dist/{conformance → bounded-contexts/authoring/testing}/run-vehicle.js +0 -0
- /package/dist/{transport → bounded-contexts/runner-hosting/infrastructure/in}/bootstrap-bridge.d.ts +0 -0
- /package/dist/{transport → bounded-contexts/runner-hosting/infrastructure/in}/exit-codes.d.ts +0 -0
- /package/dist/{transport → bounded-contexts/runner-hosting/infrastructure/in}/factory-pointer.d.ts +0 -0
- /package/dist/{transport → bounded-contexts/runner-hosting/infrastructure/in}/single-instance-probe.d.ts +0 -0
- /package/dist/{core → platform}/deep-equal.d.ts +0 -0
- /package/dist/{transport → platform}/error-text.d.ts +0 -0
- /package/dist/{core → platform}/fs-errors.d.ts +0 -0
- /package/dist/{core → platform}/fs-errors.js +0 -0
- /package/dist/{transport → shared-kernel}/framing.d.ts +0 -0
- /package/dist/{transport → shared-kernel}/wire-protocol.d.ts +0 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// The React dialect's match-count reject tails (REQ-RXD-04), built on the shared echo bound
|
|
2
|
+
// (ARCH-2, ADR-0071).
|
|
3
|
+
import { elementNameEcho } from "../../../../domain/services/reject-tail.js";
|
|
4
|
+
// ARCH-3 (council; corrected V8 — judgment-day Round 2, Judge B): `setJsxProp`'s match-count
|
|
5
|
+
// rejects (REQ-RXD-04) echo a POST-VALIDATION argument value (`elementName`) rather than
|
|
6
|
+
// refusing to — deliberate UX (naming which element wasn't found / matched), sanctioned by
|
|
7
|
+
// design §4.4. `elementName` is grammar-constrained (no quotes, no newlines — never an
|
|
8
|
+
// injection vector), but the grammar has no LENGTH ceiling, so the echo routes through
|
|
9
|
+
// `elementNameEcho` (reject-tail.ts's wide, marked 100-char bound) — NOT `boundedFragment`'s 16-char
|
|
10
|
+
// hostile-value cap — keeping every react reject message bounded without mangling ordinary
|
|
11
|
+
// names.
|
|
12
|
+
// Target prop NAMES are grammar-validated like `elementName`; their values are never echoed.
|
|
13
|
+
function withProps(propNames) {
|
|
14
|
+
return propNames.length === 0 ? "" : ` with props ${propNames.map((name) => `\`${elementNameEcho(name)}\``).join(", ")}`;
|
|
15
|
+
}
|
|
16
|
+
/** A JSX op's zero-match reject tail (REQ-RXD-04.4) — names the missing element, bounded. */
|
|
17
|
+
export function zeroMatchTail(elementName, propNames = []) {
|
|
18
|
+
return (`no element named \`${elementNameEcho(elementName)}\`${withProps(propNames)} was found — use \`.modify()\` to inspect ` +
|
|
19
|
+
"the file and edit it directly.");
|
|
20
|
+
}
|
|
21
|
+
/** A JSX op's multi-match reject tail (REQ-RXD-04.5) — names the element + count, bounded. */
|
|
22
|
+
export function multiMatchTail(opName, elementName, matchCount, propNames = []) {
|
|
23
|
+
return (`\`${elementNameEcho(elementName)}\`${withProps(propNames)} matched ${matchCount} elements — ${opName} requires ` +
|
|
24
|
+
"exactly one match; use `.modify()` to disambiguate.");
|
|
25
|
+
}
|
package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/react/ops.js
RENAMED
|
@@ -4,9 +4,11 @@
|
|
|
4
4
|
// contract, REQ-RXD-11/12 verbatim: it is emitted AS-IS, malformed or not, and becomes
|
|
5
5
|
// executable code the author is solely responsible for).
|
|
6
6
|
import { Node, SyntaxKind, } from "ts-morph";
|
|
7
|
-
import { dialectError } from "
|
|
8
|
-
import {
|
|
9
|
-
import { elementNameEcho
|
|
7
|
+
import { dialectError } from "../../../../domain/valueobjects/dialect-error.js";
|
|
8
|
+
import { assertValidImportBinding, validatedOp } from "../../../../domain/services/identifier-names.js";
|
|
9
|
+
import { elementNameEcho } from "../../../../domain/services/reject-tail.js";
|
|
10
|
+
import { assertValidAttributeName, assertValidElementName } from "./jsx-names.js";
|
|
11
|
+
import { multiMatchTail, zeroMatchTail } from "./match-tails.js";
|
|
10
12
|
import { parse } from "./ast.js";
|
|
11
13
|
function targetParts(target) {
|
|
12
14
|
if (typeof target === "string")
|
|
@@ -18,6 +18,8 @@ export type ArrayElement = string | {
|
|
|
18
18
|
};
|
|
19
19
|
export declare function appendEntry(ast: SourceFile, list: Node, entries: Node[], item: string, empty: string): void;
|
|
20
20
|
export declare function tokensOf(node: Node): string[];
|
|
21
|
+
export declare function sameTokens(a: string[], b: string[]): boolean;
|
|
22
|
+
export declare function declarationTokens(node: Node): string[];
|
|
21
23
|
/** True when `node` and the validated `element` are the same code, compared token by token. */
|
|
22
24
|
export declare function isSameElement(node: Node, element: unknown): boolean;
|
|
23
25
|
export declare function unwrap(node: Expression): Expression;
|
|
@@ -32,8 +34,11 @@ export declare function unwrap(node: Expression): Expression;
|
|
|
32
34
|
* author-trusted, like `addFunction`'s `source`.
|
|
33
35
|
*/
|
|
34
36
|
export declare function addArrayElement(ast: SourceFile, locator: ArrayLocator, element: ArrayElement): void;
|
|
35
|
-
/**
|
|
36
|
-
|
|
37
|
+
/**
|
|
38
|
+
* The validated source text of `element`, parsed as code of the file `ast` belongs to; rejects
|
|
39
|
+
* like `addArrayElement` does.
|
|
40
|
+
*/
|
|
41
|
+
export declare function elementText(element: unknown, ast?: SourceFile): string;
|
|
37
42
|
/**
|
|
38
43
|
* `addArrayElement` for a dialect that builds `locator` itself: `label` heads the reject
|
|
39
44
|
* tail in place of `addArrayElement(<locator>)`.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Node, SyntaxKind, ts, } from "ts-morph";
|
|
2
|
-
import { dialectError } from "
|
|
3
|
-
import { handlePathFor } from "
|
|
4
|
-
import { elementNameEcho } from "
|
|
5
|
-
import { assertValidImportBinding, assertValidPropertyKey } from "
|
|
2
|
+
import { dialectError } from "../../../../domain/valueobjects/dialect-error.js";
|
|
3
|
+
import { handlePathFor } from "../../../../domain/entities/dialect-handle.js";
|
|
4
|
+
import { elementNameEcho } from "../../../../domain/services/reject-tail.js";
|
|
5
|
+
import { assertValidImportBinding, assertValidPropertyKey } from "../../../../domain/services/identifier-names.js";
|
|
6
6
|
import { parse } from "./ast.js";
|
|
7
7
|
// Appends `item` after the last entry of an array or object literal, keeping its layout: one
|
|
8
8
|
// line stays one line, a multi-line list gets a new line at the last entry's indentation, and
|
|
@@ -71,11 +71,17 @@ function assertLocator(locator) {
|
|
|
71
71
|
assertValidPropertyKey(entries[0][0], "path");
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
|
+
// The extension the author's code is parsed as: that of the file it goes into, so JSX is
|
|
75
|
+
// accepted in `.tsx` and `.jsx`, and type syntax is not in `.jsx`.
|
|
76
|
+
function scriptExtension(node) {
|
|
77
|
+
const extension = node.getSourceFile().getExtension();
|
|
78
|
+
return extension === ".tsx" || extension === ".jsx" ? extension : ".ts";
|
|
79
|
+
}
|
|
74
80
|
// The only element of `[text]`, or undefined when `text` is not exactly one plain element.
|
|
75
|
-
function parseElement(text) {
|
|
81
|
+
function parseElement(text, extension) {
|
|
76
82
|
let parsed;
|
|
77
83
|
try {
|
|
78
|
-
parsed = parse(`[${text}]
|
|
84
|
+
parsed = parse(`[${text}]`, extension);
|
|
79
85
|
}
|
|
80
86
|
catch {
|
|
81
87
|
return undefined;
|
|
@@ -89,17 +95,17 @@ function parseElement(text) {
|
|
|
89
95
|
return elements[0];
|
|
90
96
|
}
|
|
91
97
|
// Returns the element's parsed node once it is proven to be a single array element.
|
|
92
|
-
function elementNode(element) {
|
|
98
|
+
function elementNode(element, extension) {
|
|
93
99
|
if (typeof element === "string") {
|
|
94
100
|
assertValidImportBinding(element, "element");
|
|
95
|
-
return parseElement(element);
|
|
101
|
+
return parseElement(element, extension);
|
|
96
102
|
}
|
|
97
103
|
if (!isPlainObject(element) || !hasExactKeys(element, ["expression"]) || typeof element.expression !== "string") {
|
|
98
104
|
throw dialectError(ELEMENT_SHAPE);
|
|
99
105
|
}
|
|
100
106
|
// Wrapping in brackets and requiring exactly one plain element blocks every breakout: a
|
|
101
107
|
// closed bracket, a comma, or a comment that swallows `]` yields a different parse.
|
|
102
|
-
const node = parseElement(element.expression.trim());
|
|
108
|
+
const node = parseElement(element.expression.trim(), extension);
|
|
103
109
|
if (node === undefined)
|
|
104
110
|
throw dialectError(EXPRESSION_RULE);
|
|
105
111
|
return node;
|
|
@@ -124,12 +130,17 @@ export function tokensOf(node) {
|
|
|
124
130
|
visit(node.compilerNode);
|
|
125
131
|
return tokens.filter((token, index) => token !== "," || ![")", "]", "}"].includes(tokens[index + 1] ?? ""));
|
|
126
132
|
}
|
|
127
|
-
function sameTokens(a, b) {
|
|
133
|
+
export function sameTokens(a, b) {
|
|
128
134
|
return a.length === b.length && a.every((token, index) => token === b[index]);
|
|
129
135
|
}
|
|
136
|
+
// Tokens without a trailing `;`, so `b = 1` and `b = 1;` are the same declaration.
|
|
137
|
+
export function declarationTokens(node) {
|
|
138
|
+
const tokens = tokensOf(node);
|
|
139
|
+
return tokens.at(-1) === ";" ? tokens.slice(0, -1) : tokens;
|
|
140
|
+
}
|
|
130
141
|
/** True when `node` and the validated `element` are the same code, compared token by token. */
|
|
131
142
|
export function isSameElement(node, element) {
|
|
132
|
-
return sameTokens(tokensOf(node), tokensOf(elementNode(element)));
|
|
143
|
+
return sameTokens(tokensOf(node), tokensOf(elementNode(element, scriptExtension(node))));
|
|
133
144
|
}
|
|
134
145
|
export function unwrap(node) {
|
|
135
146
|
let current = node;
|
|
@@ -290,16 +301,19 @@ export function addArrayElement(ast, locator, element) {
|
|
|
290
301
|
assertLocator(locator);
|
|
291
302
|
appendArrayElement(ast, locator, element, `addArrayElement(${locatorEcho(locator)})`);
|
|
292
303
|
}
|
|
293
|
-
/**
|
|
294
|
-
|
|
295
|
-
|
|
304
|
+
/**
|
|
305
|
+
* The validated source text of `element`, parsed as code of the file `ast` belongs to; rejects
|
|
306
|
+
* like `addArrayElement` does.
|
|
307
|
+
*/
|
|
308
|
+
export function elementText(element, ast) {
|
|
309
|
+
return elementNode(element, ast === undefined ? ".ts" : scriptExtension(ast)).getText();
|
|
296
310
|
}
|
|
297
311
|
/**
|
|
298
312
|
* `addArrayElement` for a dialect that builds `locator` itself: `label` heads the reject
|
|
299
313
|
* tail in place of `addArrayElement(<locator>)`.
|
|
300
314
|
*/
|
|
301
315
|
export function appendArrayElement(ast, locator, element, label) {
|
|
302
|
-
const node = elementNode(element);
|
|
316
|
+
const node = elementNode(element, scriptExtension(ast));
|
|
303
317
|
const item = node.getText();
|
|
304
318
|
const fail = (reason) => {
|
|
305
319
|
throw dialectError(`${label} on "${handlePathFor(ast)}" — ${reason}. Edit it with .modify().`);
|
package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/typescript/ast.d.ts
RENAMED
|
@@ -28,12 +28,15 @@ export declare function detectNewLineKind(source: string): NewLineKind;
|
|
|
28
28
|
* frozen contained-error prefix; this function's own thrown message is never surfaced
|
|
29
29
|
* directly to the author.
|
|
30
30
|
*
|
|
31
|
+
* `extension` sets the script kind, for author code parsed as the file it goes into would be; the
|
|
32
|
+
* dialect itself parses with the default.
|
|
33
|
+
*
|
|
31
34
|
* Row-139 (stage-5b, executor-latitude, no REQ of its own): classification below reads off
|
|
32
35
|
* `getSyntacticDiagnostics()`'s own diagnostic objects — never an assumption about a caught
|
|
33
36
|
* error's own-enumerable-properties or call-stack shape. Verified already in this shape; no
|
|
34
37
|
* heuristic-based classification exists in this function to sweep out.
|
|
35
38
|
*/
|
|
36
|
-
export declare function parse(source: string): SourceFile;
|
|
39
|
+
export declare function parse(source: string, extension?: ".ts" | ".tsx" | ".jsx"): SourceFile;
|
|
37
40
|
/**
|
|
38
41
|
* Prints the live AST back to a string — the ONLY serialization point (ADR-0006's "serialize
|
|
39
42
|
* once at flush", realised by the dialect handle's memoized lazy getter). Re-prepends a BOM
|
|
@@ -41,3 +44,4 @@ export declare function parse(source: string): SourceFile;
|
|
|
41
44
|
* does not carry it.
|
|
42
45
|
*/
|
|
43
46
|
export declare function print(ast: SourceFile): string;
|
|
47
|
+
export declare function omitsSemicolons(ast: SourceFile): boolean;
|
package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/typescript/ast.js
RENAMED
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
// a fresh `Project` per parse so the setting can vary per source, never a module-level
|
|
4
4
|
// singleton. No language-service formatter is ever invoked (REQ-TSD-02.3): this module calls
|
|
5
5
|
// no `.formatText()`/language-service API anywhere.
|
|
6
|
-
import { Project, NewLineKind, QuoteKind, IndentationText } from "ts-morph";
|
|
6
|
+
import { Node, Project, NewLineKind, QuoteKind, IndentationText } from "ts-morph";
|
|
7
7
|
// In-memory-only path fed to ts-morph's virtual file system — never a real disk path; the
|
|
8
8
|
// dialect handle (src/core/dialect-handle.ts) owns the AUTHOR-FACING path, this is purely an
|
|
9
9
|
// internal identifier ts-morph's Project API requires.
|
|
10
|
-
const
|
|
10
|
+
const VIRTUAL_STEM = "dialect-source";
|
|
11
11
|
const BOM = "";
|
|
12
12
|
// ts-morph's `SourceFile#getFullText()` does NOT round-trip a leading UTF-8 BOM (verified
|
|
13
13
|
// empirically against the pinned ts-morph@28.0.0 — the design's "preserved by ts-morph
|
|
@@ -66,12 +66,15 @@ function detectQuoteKind(sourceFile) {
|
|
|
66
66
|
* frozen contained-error prefix; this function's own thrown message is never surfaced
|
|
67
67
|
* directly to the author.
|
|
68
68
|
*
|
|
69
|
+
* `extension` sets the script kind, for author code parsed as the file it goes into would be; the
|
|
70
|
+
* dialect itself parses with the default.
|
|
71
|
+
*
|
|
69
72
|
* Row-139 (stage-5b, executor-latitude, no REQ of its own): classification below reads off
|
|
70
73
|
* `getSyntacticDiagnostics()`'s own diagnostic objects — never an assumption about a caught
|
|
71
74
|
* error's own-enumerable-properties or call-stack shape. Verified already in this shape; no
|
|
72
75
|
* heuristic-based classification exists in this function to sweep out.
|
|
73
76
|
*/
|
|
74
|
-
export function parse(source) {
|
|
77
|
+
export function parse(source, extension = ".ts") {
|
|
75
78
|
const startsWithBom = source.startsWith(BOM);
|
|
76
79
|
const body = startsWithBom ? source.slice(BOM.length) : source;
|
|
77
80
|
const project = new Project({
|
|
@@ -83,7 +86,7 @@ export function parse(source) {
|
|
|
83
86
|
usePrefixAndSuffixTextForRename: false,
|
|
84
87
|
},
|
|
85
88
|
});
|
|
86
|
-
const sourceFile = project.createSourceFile(
|
|
89
|
+
const sourceFile = project.createSourceFile(`${VIRTUAL_STEM}${extension}`, body);
|
|
87
90
|
project.manipulationSettings.set({ quoteKind: detectQuoteKind(sourceFile) });
|
|
88
91
|
if (startsWithBom)
|
|
89
92
|
hadBom.set(sourceFile, true);
|
|
@@ -103,3 +106,18 @@ export function print(ast) {
|
|
|
103
106
|
const text = ast.getFullText();
|
|
104
107
|
return hadBom.get(ast) === true ? BOM + text : text;
|
|
105
108
|
}
|
|
109
|
+
// Inserted statements keep the file's statement-terminating semicolon style: ts-morph always
|
|
110
|
+
// prints one, so it is dropped only when the file's terminable top-level statements mostly
|
|
111
|
+
// omit it (a file with no such statements, or a tie, keeps it).
|
|
112
|
+
export function omitsSemicolons(ast) {
|
|
113
|
+
const terminable = ast
|
|
114
|
+
.getStatements()
|
|
115
|
+
.filter((statement) => Node.isImportDeclaration(statement) ||
|
|
116
|
+
Node.isExportDeclaration(statement) ||
|
|
117
|
+
Node.isExportAssignment(statement) ||
|
|
118
|
+
Node.isVariableStatement(statement) ||
|
|
119
|
+
Node.isExpressionStatement(statement) ||
|
|
120
|
+
Node.isTypeAliasDeclaration(statement));
|
|
121
|
+
const terminated = terminable.filter((statement) => statement.getText().endsWith(";")).length;
|
|
122
|
+
return terminable.length - terminated > terminated;
|
|
123
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Node, SyntaxKind } from "ts-morph";
|
|
2
|
-
import { dialectError } from "
|
|
3
|
-
import { handlePathFor } from "
|
|
4
|
-
import { assertValidImportBinding } from "
|
|
5
|
-
import { elementNameEcho } from "
|
|
6
|
-
import { elementText,
|
|
7
|
-
import { parse } from "./ast.js";
|
|
2
|
+
import { dialectError } from "../../../../domain/valueobjects/dialect-error.js";
|
|
3
|
+
import { handlePathFor } from "../../../../domain/entities/dialect-handle.js";
|
|
4
|
+
import { assertGrammar, assertNotDenylisted, assertValidImportBinding, IMPORT_BINDING_GRAMMAR } from "../../../../domain/services/identifier-names.js";
|
|
5
|
+
import { elementNameEcho } from "../../../../domain/services/reject-tail.js";
|
|
6
|
+
import { declarationTokens, elementText, sameTokens } from "./array-element.js";
|
|
7
|
+
import { omitsSemicolons, parse } from "./ast.js";
|
|
8
8
|
const OPTIONS_SHAPE = '`options` must be { scope?, readonly? } with scope "public", "protected" or "private" — fix the options, or use ' +
|
|
9
9
|
"`.modify()` to make this edit directly.";
|
|
10
10
|
export function assertClassPropertyOptions(options) {
|
|
@@ -18,20 +18,13 @@ export function assertClassPropertyOptions(options) {
|
|
|
18
18
|
if (!valid)
|
|
19
19
|
throw dialectError(OPTIONS_SHAPE);
|
|
20
20
|
}
|
|
21
|
-
function declarationOf(property) {
|
|
21
|
+
function declarationOf(property, semicolon) {
|
|
22
22
|
const modifiers = [property.scope, property.readonly ? "readonly" : undefined].filter((m) => m !== undefined);
|
|
23
|
-
return [...modifiers, `${property.name} = ${property.initializer}
|
|
24
|
-
}
|
|
25
|
-
// Tokens without a trailing `;`, so `b = 1` and `b = 1;` are the same declaration.
|
|
26
|
-
function declarationTokens(node) {
|
|
27
|
-
const tokens = tokensOf(node);
|
|
28
|
-
return tokens.at(-1) === ";" ? tokens.slice(0, -1) : tokens;
|
|
23
|
+
return [...modifiers, `${property.name} = ${property.initializer}${semicolon ? ";" : ""}`].join(" ");
|
|
29
24
|
}
|
|
30
25
|
function sameDeclaration(member, text) {
|
|
31
26
|
const parsed = parse(`class X {\n${text}\n}`).getClassOrThrow("X").getMembers()[0];
|
|
32
|
-
|
|
33
|
-
const b = declarationTokens(parsed);
|
|
34
|
-
return a.length === b.length && a.every((token, index) => token === b[index]);
|
|
27
|
+
return sameTokens(declarationTokens(member), declarationTokens(parsed));
|
|
35
28
|
}
|
|
36
29
|
/**
|
|
37
30
|
* Inserts `property` into `cls`: after its last property, else before its first member, else
|
|
@@ -39,7 +32,7 @@ function sameDeclaration(member, text) {
|
|
|
39
32
|
* any other member with that name rejects through `fail`.
|
|
40
33
|
*/
|
|
41
34
|
export function insertClassProperty(ast, cls, property, fail) {
|
|
42
|
-
const text = declarationOf(property);
|
|
35
|
+
const text = declarationOf(property, !omitsSemicolons(ast));
|
|
43
36
|
const members = cls.getMembers();
|
|
44
37
|
const named = members.filter((member) => Node.hasName(member) && member.getName() === property.name);
|
|
45
38
|
if (named.length > 0) {
|
|
@@ -83,9 +76,11 @@ export function insertClassProperty(ast, cls, property, fail) {
|
|
|
83
76
|
*/
|
|
84
77
|
export function addClassProperty(ast, className, name, initializer, options) {
|
|
85
78
|
assertValidImportBinding(className, "className");
|
|
86
|
-
|
|
79
|
+
// A reserved word is a valid property name (`default = 2`), so only the grammar and the denylist apply.
|
|
80
|
+
assertGrammar("name", name, IMPORT_BINDING_GRAMMAR, "be a valid JavaScript identifier");
|
|
81
|
+
assertNotDenylisted("name", name);
|
|
87
82
|
assertClassPropertyOptions(options);
|
|
88
|
-
const value = elementText({ expression: initializer });
|
|
83
|
+
const value = elementText({ expression: initializer }, ast);
|
|
89
84
|
const fail = (reason) => {
|
|
90
85
|
throw dialectError(`addClassProperty("${elementNameEcho(className)}", "${elementNameEcho(name)}") on "${handlePathFor(ast)}" — ${reason}. Edit it with .modify().`);
|
|
91
86
|
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { SourceFile } from "ts-morph";
|
|
2
|
+
import { type Handle } from "../../../../domain/services/define-dialect.ts";
|
|
3
|
+
import type { ArrayElement, ArrayLocator } from "./array-element.ts";
|
|
4
|
+
import type { ClassPropertyOptions } from "./class-property.ts";
|
|
5
|
+
export * as astLibrary from "ts-morph";
|
|
6
|
+
type TypeScriptOps = {
|
|
7
|
+
addImport: (ast: SourceFile, name: string, from: string, options?: {
|
|
8
|
+
position?: "sorted";
|
|
9
|
+
}) => void;
|
|
10
|
+
addDefaultImport: (ast: SourceFile, name: string, from: string) => void;
|
|
11
|
+
addNamespaceImport: (ast: SourceFile, name: string, from: string) => void;
|
|
12
|
+
addTypeImport: (ast: SourceFile, name: string, from: string) => void;
|
|
13
|
+
addSideEffectImport: (ast: SourceFile, from: string) => void;
|
|
14
|
+
addReExport: (ast: SourceFile, name: string, from: string) => void;
|
|
15
|
+
addExportAll: (ast: SourceFile, from: string, options?: {
|
|
16
|
+
as?: string;
|
|
17
|
+
}) => void;
|
|
18
|
+
addFunction: (ast: SourceFile, name: string, source: string, options?: {
|
|
19
|
+
export?: boolean;
|
|
20
|
+
}) => void;
|
|
21
|
+
addVariable: (ast: SourceFile, name: string, initializer: string, options?: {
|
|
22
|
+
export?: boolean;
|
|
23
|
+
kind?: "const" | "let" | "var";
|
|
24
|
+
}) => void;
|
|
25
|
+
addClass: (ast: SourceFile, name: string, source: string, options?: {
|
|
26
|
+
export?: boolean;
|
|
27
|
+
}) => void;
|
|
28
|
+
removeImport: (ast: SourceFile, name: string, from: string) => void;
|
|
29
|
+
removeExport: (ast: SourceFile, name: string, from: string) => void;
|
|
30
|
+
removeExportAll: (ast: SourceFile, from: string, options?: {
|
|
31
|
+
as?: string;
|
|
32
|
+
}) => void;
|
|
33
|
+
addArrayElement: (ast: SourceFile, locator: ArrayLocator, element: ArrayElement) => void;
|
|
34
|
+
addClassProperty: (ast: SourceFile, className: string, name: string, initializer: string, options?: ClassPropertyOptions) => void;
|
|
35
|
+
sortImports: (ast: SourceFile) => void;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Opens a TypeScript file for dialect-aware editing — the dialect's entry verb into a Session
|
|
39
|
+
* (REQ-DG-01.2). Returns an awaitable, chainable `Handle` exposing the universal `.modify()`
|
|
40
|
+
* escape hatch plus the dialect's named ops (`addImport`, `addDefaultImport`,
|
|
41
|
+
* `addNamespaceImport`, `addTypeImport`, `addSideEffectImport`, `addReExport`, `addExportAll`,
|
|
42
|
+
* `addFunction`, `addVariable`, `addClass`, `removeImport`, `removeExport`, `removeExportAll`,
|
|
43
|
+
* `addArrayElement`, `addClassProperty`). Reads route through `Session.read` only (REQ-MC-03); edits
|
|
44
|
+
* coalesce into a single `modify` at flush (REQ-MC-01/02).
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* import * as ts from "@pbuilder/sdk/typescript";
|
|
48
|
+
*
|
|
49
|
+
* export const run = async () => {
|
|
50
|
+
* await ts.find("src/index.ts").addImport("readFileSync", "node:fs");
|
|
51
|
+
* };
|
|
52
|
+
*/
|
|
53
|
+
export declare function find(path: string): Handle<"found", SourceFile, TypeScriptOps>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// S-002: the TypeScript dialect module — `@pbuilder/sdk/typescript` (REQ-TSD-01, frozen
|
|
2
|
+
// subpath, ADR-0014 amendment). Composes the sanctioned kit surface ONLY
|
|
3
|
+
// (`defineDialect`/`defineOpPack`/`withOps` from `../../core/define-dialect.ts`) — no
|
|
4
|
+
// port-internal machinery is imported anywhere in this tree (REQ-DG-04.1, see
|
|
5
|
+
// test/fitness/fit-08-no-kit-bleed.test.ts and fit-10-engine-client-port-guard.test.ts).
|
|
6
|
+
// Namespace import surface (ADR-0003): `import * as ts from "@pbuilder/sdk/typescript"`,
|
|
7
|
+
// then `ts.find(path)`.
|
|
8
|
+
import { defineDialect, defineOpPack, withOps } from "../../../../domain/services/define-dialect.js";
|
|
9
|
+
import { parse, print } from "./ast.js";
|
|
10
|
+
import { typescriptOps } from "./pack.js";
|
|
11
|
+
export * as astLibrary from "ts-morph";
|
|
12
|
+
const opsPack = defineOpPack(typescriptOps);
|
|
13
|
+
const baseDialect = defineDialect({
|
|
14
|
+
extensions: [".ts"],
|
|
15
|
+
ast: { parse, print },
|
|
16
|
+
ops: {},
|
|
17
|
+
});
|
|
18
|
+
const typescriptDialect = withOps(baseDialect, opsPack);
|
|
19
|
+
/**
|
|
20
|
+
* Opens a TypeScript file for dialect-aware editing — the dialect's entry verb into a Session
|
|
21
|
+
* (REQ-DG-01.2). Returns an awaitable, chainable `Handle` exposing the universal `.modify()`
|
|
22
|
+
* escape hatch plus the dialect's named ops (`addImport`, `addDefaultImport`,
|
|
23
|
+
* `addNamespaceImport`, `addTypeImport`, `addSideEffectImport`, `addReExport`, `addExportAll`,
|
|
24
|
+
* `addFunction`, `addVariable`, `addClass`, `removeImport`, `removeExport`, `removeExportAll`,
|
|
25
|
+
* `addArrayElement`, `addClassProperty`). Reads route through `Session.read` only (REQ-MC-03); edits
|
|
26
|
+
* coalesce into a single `modify` at flush (REQ-MC-01/02).
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* import * as ts from "@pbuilder/sdk/typescript";
|
|
30
|
+
*
|
|
31
|
+
* export const run = async () => {
|
|
32
|
+
* await ts.find("src/index.ts").addImport("readFileSync", "node:fs");
|
|
33
|
+
* };
|
|
34
|
+
*/
|
|
35
|
+
export function find(path) {
|
|
36
|
+
return typescriptDialect.find(path);
|
|
37
|
+
}
|
package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/typescript/ops.d.ts
RENAMED
|
@@ -8,7 +8,7 @@ import { type SourceFile } from "ts-morph";
|
|
|
8
8
|
* 0. Validation (REQ-TSD-13, runs FIRST, strictly before Step 1): `name` MUST be a valid
|
|
9
9
|
* plain-JS identifier, MUST NOT be a reserved or strict-mode-restricted word, and MUST
|
|
10
10
|
* NOT be a denylisted name (`assertValidImportBinding`, reused verbatim from
|
|
11
|
-
* `
|
|
11
|
+
* `domain/services/identifier-names.ts`) — REJECTS via a PATH-LESS `dialectError` before Step
|
|
12
12
|
* 1/2/3/4 ever evaluate `name`, even when `name` would ALSO collide under Step 2
|
|
13
13
|
* (REQ-TSD-13.6, precedence pinned: validation wins, never the collision message).
|
|
14
14
|
* 1. Already-bound (idempotency, SAME module only): if an EXISTING declaration for `from`
|
|
@@ -70,6 +70,11 @@ import { type SourceFile } from "ts-morph";
|
|
|
70
70
|
export declare function addImport(ast: SourceFile, name: string, from: string, options?: {
|
|
71
71
|
position?: "sorted";
|
|
72
72
|
}): void;
|
|
73
|
+
/**
|
|
74
|
+
* `addImport`'s steps 1-4 for a `name` already validated, rejecting a taken name under `opName`:
|
|
75
|
+
* the op the author called, which may add the import on the author's behalf.
|
|
76
|
+
*/
|
|
77
|
+
export declare function importBinding(ast: SourceFile, opName: string, name: string, from: string, sorted?: boolean): void;
|
|
73
78
|
/**
|
|
74
79
|
* Adds `import name from "from";` (V2 REQ-TSD-13). `name` is validated first, as in
|
|
75
80
|
* `addImport`. A no-op when `from` already has the default import `name`. Rejects when `from`
|