@pbuilder/sdk 0.14.0 → 0.15.1

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.
Files changed (207) hide show
  1. package/README.md +57 -42
  2. package/dist/{transport → acl/irwire}/frame-reader.d.ts +2 -0
  3. package/dist/{transport → acl/irwire}/frame-reader.js +57 -5
  4. package/dist/{transport → acl/irwire}/stdio-engine-client.d.ts +2 -2
  5. package/dist/{transport → acl/irwire}/stdio-engine-client.js +4 -4
  6. package/dist/bin/pbuilder-codegen.js +30 -35
  7. package/dist/bin/pbuilder-runner.js +6 -6
  8. package/dist/bounded-contexts/authoring/application/usecases/authoring-verbs/index.d.ts +106 -0
  9. package/dist/bounded-contexts/authoring/application/usecases/authoring-verbs/index.js +202 -0
  10. package/dist/{pending-directives → bounded-contexts/authoring/application/usecases/pending-directives}/render.d.ts +2 -2
  11. package/dist/{core → bounded-contexts/authoring/application/usecases/run-factory}/context.d.ts +12 -9
  12. package/dist/{core → bounded-contexts/authoring/application/usecases/run-factory}/context.js +59 -120
  13. package/dist/bounded-contexts/authoring/application/usecases/run-factory/driving.d.ts +5 -0
  14. package/dist/bounded-contexts/authoring/application/usecases/run-factory/driving.js +15 -0
  15. package/dist/bounded-contexts/authoring/application/usecases/scaffold/classify-transport.d.ts +51 -0
  16. package/dist/bounded-contexts/authoring/application/usecases/scaffold/classify-transport.js +105 -0
  17. package/dist/{scaffold → bounded-contexts/authoring/application/usecases/scaffold}/expander.d.ts +2 -1
  18. package/dist/{scaffold → bounded-contexts/authoring/application/usecases/scaffold}/expander.js +13 -7
  19. package/dist/{scaffold → bounded-contexts/authoring/application/usecases/scaffold}/index.d.ts +1 -1
  20. package/dist/{scaffold → bounded-contexts/authoring/application/usecases/scaffold}/index.js +7 -6
  21. package/dist/{scaffold → bounded-contexts/authoring/application/usecases/scaffold}/path-guards.d.ts +11 -10
  22. package/dist/{scaffold → bounded-contexts/authoring/application/usecases/scaffold}/path-guards.js +21 -48
  23. package/dist/{scaffold → bounded-contexts/authoring/application/usecases/scaffold}/walk.d.ts +2 -3
  24. package/dist/{scaffold → bounded-contexts/authoring/application/usecases/scaffold}/walk.js +37 -56
  25. package/dist/{core → bounded-contexts/authoring/domain/aggregates/session}/session.d.ts +2 -2
  26. package/dist/{core → bounded-contexts/authoring/domain/aggregates/session}/session.js +1 -1
  27. package/dist/{core → bounded-contexts/authoring/domain/entities}/dialect-handle.d.ts +1 -1
  28. package/dist/{core → bounded-contexts/authoring/domain/entities}/dialect-handle.js +10 -10
  29. package/dist/{core → bounded-contexts/authoring/domain/ports}/engine-client.d.ts +1 -1
  30. package/dist/bounded-contexts/authoring/domain/ports/package-files.d.ts +53 -0
  31. package/dist/bounded-contexts/authoring/domain/ports/package-files.js +11 -0
  32. package/dist/{core → bounded-contexts/authoring/domain/services}/define-dialect.d.ts +2 -2
  33. package/dist/{core → bounded-contexts/authoring/domain/services}/define-dialect.js +3 -3
  34. package/dist/{core → bounded-contexts/authoring/domain/services}/directive-factory.d.ts +2 -2
  35. package/dist/{core → bounded-contexts/authoring/domain/services}/directive-factory.js +37 -12
  36. package/dist/{scaffold → bounded-contexts/authoring/domain/services}/filename-pipeline.d.ts +7 -5
  37. package/dist/{scaffold → bounded-contexts/authoring/domain/services}/filename-pipeline.js +28 -8
  38. package/dist/{core/jsx-name-validator.d.ts → bounded-contexts/authoring/domain/services/identifier-names.d.ts} +8 -4
  39. package/dist/{core/jsx-name-validator.js → bounded-contexts/authoring/domain/services/identifier-names.js} +21 -28
  40. package/dist/bounded-contexts/authoring/domain/services/reject-tail.d.ts +9 -0
  41. package/dist/bounded-contexts/authoring/domain/services/reject-tail.js +30 -0
  42. package/dist/bounded-contexts/authoring/domain/services/run-context.d.ts +5 -0
  43. package/dist/bounded-contexts/authoring/domain/services/run-context.js +70 -0
  44. package/dist/{core → bounded-contexts/authoring/domain/services}/schema/input-rejection.d.ts +1 -1
  45. package/dist/{core → bounded-contexts/authoring/domain/services}/schema/input-rejection.js +1 -1
  46. package/dist/bounded-contexts/authoring/domain/services/schema/schema-files.d.ts +2 -0
  47. package/dist/bounded-contexts/authoring/domain/services/schema/schema-files.js +6 -0
  48. package/dist/{core → bounded-contexts/authoring/domain/services}/schema/schema-locate.d.ts +2 -1
  49. package/dist/{core → bounded-contexts/authoring/domain/services}/schema/schema-locate.js +13 -2
  50. package/dist/{core → bounded-contexts/authoring/domain/services}/schema/schema-parse.d.ts +1 -1
  51. package/dist/{core → bounded-contexts/authoring/domain/services}/schema/schema-parse.js +2 -14
  52. package/dist/{core → bounded-contexts/authoring/domain/services}/schema/schema-sufficiency.d.ts +4 -3
  53. package/dist/{core → bounded-contexts/authoring/domain/services}/schema/schema-sufficiency.js +8 -4
  54. package/dist/{core → bounded-contexts/authoring/domain/services}/schema/schema-validate.d.ts +1 -1
  55. package/dist/{core → bounded-contexts/authoring/domain/services}/schema/schema-validate.js +1 -1
  56. package/dist/{core → bounded-contexts/authoring/domain/valueobjects}/authoring-error.js +1 -1
  57. package/dist/{core → bounded-contexts/authoring/domain/valueobjects}/wire.d.ts +0 -3
  58. package/dist/bounded-contexts/authoring/domain/valueobjects/wire.js +28 -0
  59. package/dist/bounded-contexts/authoring/infrastructure/in/codegen/cli.d.ts +27 -0
  60. package/dist/bounded-contexts/authoring/infrastructure/in/codegen/cli.js +306 -0
  61. package/dist/bounded-contexts/authoring/infrastructure/in/codegen/emit-type.d.ts +7 -0
  62. package/dist/bounded-contexts/authoring/infrastructure/in/codegen/emit-type.js +68 -0
  63. package/dist/bounded-contexts/authoring/infrastructure/in/codegen/project-codegen.d.ts +19 -0
  64. package/dist/bounded-contexts/authoring/infrastructure/in/codegen/project-codegen.js +131 -0
  65. package/dist/bounded-contexts/authoring/infrastructure/in/commons/index.d.ts +182 -0
  66. package/dist/bounded-contexts/authoring/infrastructure/in/commons/index.js +94 -0
  67. package/dist/bounded-contexts/authoring/infrastructure/out/dialects/angular/index.d.ts +63 -0
  68. package/dist/bounded-contexts/authoring/infrastructure/out/dialects/angular/index.js +68 -0
  69. package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/angular/ops.js +9 -9
  70. package/dist/bounded-contexts/authoring/infrastructure/out/dialects/css/index.d.ts +40 -0
  71. package/dist/bounded-contexts/authoring/infrastructure/out/dialects/css/index.js +38 -0
  72. package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/css/ops.js +2 -2
  73. package/dist/bounded-contexts/authoring/infrastructure/out/dialects/json/index.d.ts +55 -0
  74. package/dist/bounded-contexts/authoring/infrastructure/out/dialects/json/index.js +54 -0
  75. package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/json/ops.d.ts +1 -1
  76. package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/json/ops.js +35 -8
  77. package/dist/bounded-contexts/authoring/infrastructure/out/dialects/nestjs/index.d.ts +43 -0
  78. package/dist/bounded-contexts/authoring/infrastructure/out/dialects/nestjs/index.js +46 -0
  79. package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/nestjs/ops.js +7 -7
  80. package/dist/bounded-contexts/authoring/infrastructure/out/dialects/react/index.d.ts +52 -0
  81. package/dist/bounded-contexts/authoring/infrastructure/out/dialects/react/index.js +73 -0
  82. package/dist/bounded-contexts/authoring/infrastructure/out/dialects/react/jsx-names.d.ts +4 -0
  83. package/dist/bounded-contexts/authoring/infrastructure/out/dialects/react/jsx-names.js +18 -0
  84. package/dist/bounded-contexts/authoring/infrastructure/out/dialects/react/match-tails.d.ts +4 -0
  85. package/dist/bounded-contexts/authoring/infrastructure/out/dialects/react/match-tails.js +25 -0
  86. package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/react/ops.js +5 -3
  87. package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/typescript/array-element.d.ts +7 -2
  88. package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/typescript/array-element.js +29 -15
  89. package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/typescript/ast.d.ts +5 -1
  90. package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/typescript/ast.js +22 -4
  91. package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/typescript/class-property.js +14 -19
  92. package/dist/bounded-contexts/authoring/infrastructure/out/dialects/typescript/index.d.ts +53 -0
  93. package/dist/bounded-contexts/authoring/infrastructure/out/dialects/typescript/index.js +37 -0
  94. package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/typescript/ops.d.ts +6 -1
  95. package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/typescript/ops.js +90 -54
  96. package/dist/bounded-contexts/authoring/infrastructure/out/dialects/yaml/index.d.ts +69 -0
  97. package/dist/bounded-contexts/authoring/infrastructure/out/dialects/yaml/index.js +70 -0
  98. package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/yaml/paths.d.ts +1 -1
  99. package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/yaml/paths.js +2 -2
  100. package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/yaml/presentation.js +1 -1
  101. package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/yaml/structural.js +2 -2
  102. package/dist/bounded-contexts/authoring/infrastructure/out/fs/package-files.d.ts +8 -0
  103. package/dist/bounded-contexts/authoring/infrastructure/out/fs/package-files.js +133 -0
  104. package/dist/bounded-contexts/authoring/testing/conformance/index.d.ts +157 -0
  105. package/dist/bounded-contexts/authoring/testing/conformance/index.js +261 -0
  106. package/dist/{testing → bounded-contexts/authoring/testing}/contract-fake.d.ts +2 -2
  107. package/dist/{testing → bounded-contexts/authoring/testing}/contract-fake.js +4 -3
  108. package/dist/bounded-contexts/authoring/testing/harness/index.d.ts +89 -0
  109. package/dist/bounded-contexts/authoring/testing/harness/index.js +85 -0
  110. package/dist/{conformance → bounded-contexts/authoring/testing}/run-vehicle.d.ts +1 -1
  111. package/dist/{transport → bounded-contexts/runner-hosting/infrastructure/in}/bootstrap-bridge.js +2 -2
  112. package/dist/{transport → bounded-contexts/runner-hosting/infrastructure/in}/exit-codes.js +5 -4
  113. package/dist/{transport → bounded-contexts/runner-hosting/infrastructure/in}/factory-pointer.js +1 -1
  114. package/dist/{transport → bounded-contexts/runner-hosting/infrastructure/in}/runner.d.ts +4 -0
  115. package/dist/{transport → bounded-contexts/runner-hosting/infrastructure/in}/runner.js +49 -23
  116. package/dist/{transport → bounded-contexts/runner-hosting/infrastructure/in}/single-instance-probe.js +1 -1
  117. package/dist/commons/index.d.ts +1 -278
  118. package/dist/commons/index.js +1 -286
  119. package/dist/conformance/index.d.ts +1 -157
  120. package/dist/conformance/index.js +1 -261
  121. package/dist/dialects/angular/index.d.ts +1 -63
  122. package/dist/dialects/angular/index.js +1 -68
  123. package/dist/dialects/css/index.d.ts +1 -40
  124. package/dist/dialects/css/index.js +1 -38
  125. package/dist/dialects/json/index.d.ts +1 -55
  126. package/dist/dialects/json/index.js +1 -54
  127. package/dist/dialects/nestjs/index.d.ts +1 -43
  128. package/dist/dialects/nestjs/index.js +1 -46
  129. package/dist/dialects/react/index.d.ts +1 -52
  130. package/dist/dialects/react/index.js +1 -73
  131. package/dist/dialects/typescript/index.d.ts +1 -53
  132. package/dist/dialects/typescript/index.js +1 -37
  133. package/dist/dialects/yaml/index.d.ts +1 -69
  134. package/dist/dialects/yaml/index.js +1 -70
  135. package/dist/{core → platform}/deep-equal.js +2 -2
  136. package/dist/{transport → platform}/error-text.js +2 -2
  137. package/dist/runner-manifest.json +66 -46
  138. package/dist/shared-kernel/batch-cap.d.ts +4 -0
  139. package/dist/{core/wire.js → shared-kernel/batch-cap.js} +9 -26
  140. package/dist/{transport → shared-kernel}/framing.js +2 -2
  141. package/dist/{transport → shared-kernel}/wire-protocol.js +1 -1
  142. package/dist/testing/index.d.ts +1 -84
  143. package/dist/testing/index.js +1 -82
  144. package/package.json +9 -3
  145. package/dist/core/index.d.ts +0 -10
  146. package/dist/core/index.js +0 -6
  147. package/dist/core/reject-tail.d.ts +0 -13
  148. package/dist/core/reject-tail.js +0 -52
  149. package/dist/core/schema/schema-discovery.d.ts +0 -13
  150. package/dist/core/schema/schema-discovery.js +0 -51
  151. package/dist/scaffold/classify-transport.d.ts +0 -54
  152. package/dist/scaffold/classify-transport.js +0 -119
  153. /package/dist/{pending-directives → bounded-contexts/authoring/application/usecases/pending-directives}/index.d.ts +0 -0
  154. /package/dist/{pending-directives → bounded-contexts/authoring/application/usecases/pending-directives}/index.js +0 -0
  155. /package/dist/{pending-directives → bounded-contexts/authoring/application/usecases/pending-directives}/render.js +0 -0
  156. /package/dist/{core → bounded-contexts/authoring/domain/entities}/base-handle.d.ts +0 -0
  157. /package/dist/{core → bounded-contexts/authoring/domain/entities}/base-handle.js +0 -0
  158. /package/dist/{core → bounded-contexts/authoring/domain/entities}/handle-state.d.ts +0 -0
  159. /package/dist/{core → bounded-contexts/authoring/domain/entities}/handle-state.js +0 -0
  160. /package/dist/{core → bounded-contexts/authoring/domain/ports}/emit-rejection.d.ts +0 -0
  161. /package/dist/{core → bounded-contexts/authoring/domain/ports}/emit-rejection.js +0 -0
  162. /package/dist/{core → bounded-contexts/authoring/domain/ports}/engine-client.js +0 -0
  163. /package/dist/{commons → bounded-contexts/authoring/domain/services}/classify-content.d.ts +0 -0
  164. /package/dist/{commons → bounded-contexts/authoring/domain/services}/classify-content.js +0 -0
  165. /package/dist/{core → bounded-contexts/authoring/domain/services}/schema/schema-digest.d.ts +0 -0
  166. /package/dist/{core → bounded-contexts/authoring/domain/services}/schema/schema-digest.js +0 -0
  167. /package/dist/{core → bounded-contexts/authoring/domain/valueobjects}/authoring-error.d.ts +0 -0
  168. /package/dist/{core → bounded-contexts/authoring/domain/valueobjects}/dialect-error.d.ts +0 -0
  169. /package/dist/{core → bounded-contexts/authoring/domain/valueobjects}/dialect-error.js +0 -0
  170. /package/dist/{core → bounded-contexts/authoring/domain/valueobjects}/json-value.d.ts +0 -0
  171. /package/dist/{core → bounded-contexts/authoring/domain/valueobjects}/json-value.js +0 -0
  172. /package/dist/{core/schema → bounded-contexts/authoring/domain/valueobjects}/schema-model.d.ts +0 -0
  173. /package/dist/{core/schema → bounded-contexts/authoring/domain/valueobjects}/schema-model.js +0 -0
  174. /package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/angular/ops.d.ts +0 -0
  175. /package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/css/ast.d.ts +0 -0
  176. /package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/css/ast.js +0 -0
  177. /package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/css/ops.d.ts +0 -0
  178. /package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/json/ast.d.ts +0 -0
  179. /package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/json/ast.js +0 -0
  180. /package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/nestjs/ops.d.ts +0 -0
  181. /package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/react/ast.d.ts +0 -0
  182. /package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/react/ast.js +0 -0
  183. /package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/react/ops.d.ts +0 -0
  184. /package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/typescript/class-property.d.ts +0 -0
  185. /package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/typescript/import-order.d.ts +0 -0
  186. /package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/typescript/import-order.js +0 -0
  187. /package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/typescript/pack.d.ts +0 -0
  188. /package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/typescript/pack.js +0 -0
  189. /package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/yaml/ast.d.ts +0 -0
  190. /package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/yaml/ast.js +0 -0
  191. /package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/yaml/documents.d.ts +0 -0
  192. /package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/yaml/documents.js +0 -0
  193. /package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/yaml/presentation.d.ts +0 -0
  194. /package/dist/{dialects → bounded-contexts/authoring/infrastructure/out/dialects}/yaml/structural.d.ts +0 -0
  195. /package/dist/{testing → bounded-contexts/authoring/testing}/rejection-messages.d.ts +0 -0
  196. /package/dist/{testing → bounded-contexts/authoring/testing}/rejection-messages.js +0 -0
  197. /package/dist/{conformance → bounded-contexts/authoring/testing}/run-vehicle.js +0 -0
  198. /package/dist/{transport → bounded-contexts/runner-hosting/infrastructure/in}/bootstrap-bridge.d.ts +0 -0
  199. /package/dist/{transport → bounded-contexts/runner-hosting/infrastructure/in}/exit-codes.d.ts +0 -0
  200. /package/dist/{transport → bounded-contexts/runner-hosting/infrastructure/in}/factory-pointer.d.ts +0 -0
  201. /package/dist/{transport → bounded-contexts/runner-hosting/infrastructure/in}/single-instance-probe.d.ts +0 -0
  202. /package/dist/{core → platform}/deep-equal.d.ts +0 -0
  203. /package/dist/{transport → platform}/error-text.d.ts +0 -0
  204. /package/dist/{core → platform}/fs-errors.d.ts +0 -0
  205. /package/dist/{core → platform}/fs-errors.js +0 -0
  206. /package/dist/{transport → shared-kernel}/framing.d.ts +0 -0
  207. /package/dist/{transport → shared-kernel}/wire-protocol.d.ts +0 -0
@@ -1,261 +1 @@
1
- // CONF-01: the conformance kit — testDialect / testOpPack (ADR-0012).
2
- //
3
- // S-004 (ADR-0012 amendment): real CORE bodies against the REAL TypeScript dialect — byte-
4
- // exact round-trip (REQ-DC-01), single-op fidelity + unchanged-elsewhere (REQ-DC-02),
5
- // coalescing-to-one content-verified (REQ-DC-03), seam-serializability (REQ-DC-04), and the
6
- // read-boundary-split live counterpart (REQ-DC-05.2). Both functions are now
7
- // `Promise<void>` (rev 3, Q3): observing DC-03/DC-04 requires awaiting a REAL async
8
- // coalescing run (the handle's `#tail`, the run-boundary join, and `Session.flush` are all
9
- // async) — a synchronous body could only inspect the emitted batch via a mock/bypass, which
10
- // ADR-0012 and REQ-TSD-07 (ContractFake-only) forbid. Every failure REJECTS the returned
11
- // promise with a descriptive Error (never a sync throw) — planted violations (REQ-DC-05)
12
- // surface through an expect-reject wrapper at the call site.
13
- //
14
- // Drives real runs via `defineFactory` + the kit-internal `run-vehicle.ts` transport —
15
- // imported for INTERNAL use only, never re-exported (FIT-08 bans re-export of kit symbols
16
- // from this path, not internal use of them).
17
- import { defineFactory } from "../core/context.js";
18
- import { deepEqual } from "../core/deep-equal.js";
19
- import { createRunVehicle } from "./run-vehicle.js";
20
- // REQ-DC-04 (seam-serializability): `JSON.parse(JSON.stringify(directive))` must deep-equal
21
- // `directive` for EVERY emitted directive. Two DISTINCT failure modes a planted `.modify()` can
22
- // trigger (REQ-DC-04.1/.2): a closure attached to directive content is silently DROPPED by
23
- // JSON.stringify (caught by the deepEqual mismatch below); a live AST node with circular
24
- // parent pointers makes JSON.stringify itself THROW (caught by the try/catch below).
25
- function assertSerializable(directives, label) {
26
- for (const directive of directives) {
27
- let roundTripped;
28
- try {
29
- roundTripped = JSON.parse(JSON.stringify(directive));
30
- }
31
- catch (err) {
32
- throw new Error(`testOpPack: REQ-DC-04 seam-serializability (${label}) — a directive failed JSON.stringify, ` +
33
- `likely a live AST node with circular references attached to directive content: ` +
34
- `${err instanceof Error ? err.message : String(err)}`);
35
- }
36
- if (!deepEqual(directive, roundTripped)) {
37
- throw new Error(`testOpPack: REQ-DC-04 seam-serializability (${label}) — JSON.parse(JSON.stringify(directive)) ` +
38
- `did not deep-equal the original directive; a non-serializable value (e.g. a closure) was ` +
39
- `silently dropped`);
40
- }
41
- }
42
- }
43
- // Runs ONE exercise through a fresh, isolated run-vehicle (§4.4c): seeds `path` with `seed`,
44
- // chains the exercise's ops on `baseDialect.find(path)` (`{op,args}` -> `handle[op](...args)`;
45
- // `{modify}` -> `handle.modify(fn)`), optionally injects `handle.read()` right after the FIRST op
46
- // (the read-boundary-split re-run), awaits, and returns every modify directive observed
47
- // across the whole run, in emission order.
48
- async function runExercise(dialect, exercise, opts) {
49
- const path = exercise.path ?? `op-exercise${dialect.extensions[0] ?? ""}`;
50
- const { client, emitted } = createRunVehicle({ [path]: exercise.seed });
51
- const runner = defineFactory(async () => {
52
- // `any`: fixtures span arbitrary op-packs, so the exercised handle's op-derived members
53
- // are not known at this generic boundary (mirrors OpPackFixture's own `unknown`-at-the-
54
- // boundary posture, design §4.3).
55
- let handle = dialect.find(path);
56
- for (const [index, step] of exercise.chain.entries()) {
57
- handle = "modify" in step ? handle.modify(step.modify) : handle[step.op](...step.args);
58
- if (opts.injectReadAfterFirstOp && index === 0) {
59
- await handle.read();
60
- }
61
- }
62
- await handle;
63
- });
64
- await runner(undefined, { client });
65
- const directives = emitted.flatMap((b) => b.instructions);
66
- const modifies = directives
67
- .filter((d) => d.op === "modify")
68
- .map((d) => d.modify);
69
- return { modifies, directives };
70
- }
71
- // REQ-DC-06 (ADR-0012 amendment clause 1): four mandatory adversarial samples, injected
72
- // ADDITIVELY into every `testDialect`/`testOpPack` run — `DialectFixture` carries no field
73
- // capable of disabling this (compile-level guarantee, REQ-DC-06.2, see test/conformance/planted/
74
- // opt-out-attempt.test.ts). No source text is valid in every language, so the samples derive
75
- // from a source the dialect itself declares valid (the library-exercise seed, or the first
76
- // op-exercise seed): only the empty file, line endings, the BOM, and size are format-neutral.
77
- // Language-specific adversarial samples belong in each dialect's own `fixture.samples`.
78
- const BOM = "\uFEFF";
79
- const LARGE_SAMPLE_BYTES = 4 * 1024 * 1024;
80
- function mandatoryAdversarialSamples(validSource) {
81
- const lf = validSource.replace(/^\uFEFF/, "").replace(/\r\n/g, "\n");
82
- const terminated = lf.endsWith("\n") ? lf : `${lf}\n`;
83
- return [
84
- "", // empty file
85
- terminated.replace(/\n/g, "\r\n"), // CRLF
86
- BOM + terminated, // UTF-8 BOM
87
- terminated + "\n".repeat(LARGE_SAMPLE_BYTES), // 4 MiB serialized-boundary sample (REQ-TSD-03.7 precedent)
88
- ];
89
- }
90
- const UNDECLARED_EXTENSION = ".pbuilder-undeclared";
91
- // Shared by `testDialect` and `testOpPack` (verify-in-loop-4 Finding #1): the round-trip +
92
- // real-base-probe loop is ONE mechanism, run against whichever dialect reference the caller
93
- // holds (`fixture.dialect` for testDialect, `fixture.baseDialect` for testOpPack) — REQ-DC-06's
94
- // chapeau ("into EVERY testDialect/testOpPack run") and REQ-DC-08 (real-base-dialect rule) both
95
- // name a dialect's `ast.parse`/`ast.print` pair, not an op-chain, so no per-op synthesis is
96
- // needed to satisfy either for `testOpPack`. `label` scopes error messages to the caller.
97
- function runRoundTripProbe(dialectAst, samples, label) {
98
- for (const sample of samples) {
99
- const ast = dialectAst.parse(sample);
100
- // REQ-DC-08 (real-base-dialect rule): a stub/mock parse that returns nothing or hands
101
- // back the input string unchanged would let an identity round-trip pass vacuously —
102
- // reject before the round-trip assertion can even run.
103
- if (ast === null || ast === undefined || ast === sample) {
104
- throw new Error(`${label}: REQ-DC-08 real-base-dialect rule — dialect.ast.parse(sample) returned a ` +
105
- "nullish value or the input string unchanged; a real dialect's parse must produce a distinct AST");
106
- }
107
- const roundTripped = dialectAst.print(ast);
108
- if (roundTripped !== sample) {
109
- const preview = sample.length > 80 ? `${sample.slice(0, 80)}...` : sample;
110
- throw new Error(`${label}: REQ-DC-01 round-trip fidelity — print(parse(sample)) did not byte-exact match ` +
111
- `the original sample: ${JSON.stringify(preview)}`);
112
- }
113
- }
114
- }
115
- /**
116
- * Runs the conformance suite for a dialect: asserts parse/print no-op round-trip fidelity
117
- * (REQ-DC-01) — `print(parse(sample)) === sample` BYTE-EXACT, never AST-equal, for every
118
- * sample in `fixture.samples` PLUS the four mandatory adversarial samples the kit injects on
119
- * every run (REQ-DC-06 — additive, not opt-out-able). Before each round-trip check, verifies
120
- * `fixture.dialect.ast.parse` is a REAL parser, not an identity/stub function (REQ-DC-08): a
121
- * `parse` returning `null`/`undefined`, or the input string unchanged, fails BEFORE the
122
- * round-trip assertion could vacuously pass.
123
- *
124
- * Requires runtime library exports matching independent adapter evidence, then exercises
125
- * the actual module's `find().modify()` through a real run with byte-exact emitted output.
126
- */
127
- export async function testDialect(fixture) {
128
- const module = fixture.module;
129
- if (!module || typeof module.find !== "function") {
130
- throw new Error("testDialect: module must expose callable find");
131
- }
132
- if (!module.astLibrary || typeof module.astLibrary !== "object") {
133
- throw new Error("testDialect: module must expose runtime astLibrary");
134
- }
135
- const expected = fixture.expectedAstLibrary;
136
- if (!expected || typeof expected !== "object") {
137
- throw new Error("testDialect: independent expectedAstLibrary evidence is required");
138
- }
139
- const keys = Object.keys(expected);
140
- if (keys.length === 0 || keys.length !== Object.keys(module.astLibrary).length ||
141
- keys.some((key) => !Object.hasOwn(module.astLibrary, key) ||
142
- !Object.is(Reflect.get(module.astLibrary, key), Reflect.get(expected, key)))) {
143
- throw new Error("testDialect: astLibrary runtime library mismatch with adapter evidence");
144
- }
145
- const samples = [...fixture.samples, ...mandatoryAdversarialSamples(fixture.libraryExercise.seed)];
146
- runRoundTripProbe(fixture.dialect.ast, samples, "testDialect");
147
- const exercise = fixture.libraryExercise;
148
- const { client, emitted } = createRunVehicle({ [exercise.path]: exercise.seed });
149
- // A-11: `find` must reject an extension the dialect does not declare. Probed inside the run,
150
- // because outside a Session a conforming `find` would throw for the wrong reason.
151
- const undeclaredPath = `conformance-probe${UNDECLARED_EXTENSION}`;
152
- let acceptedUndeclared = !fixture.dialect.extensions.includes(UNDECLARED_EXTENSION);
153
- const run = defineFactory(async () => {
154
- try {
155
- module.find(undeclaredPath);
156
- }
157
- catch {
158
- acceptedUndeclared = false;
159
- }
160
- await module.find(exercise.path).modify((ast) => exercise.modify(ast, module.astLibrary));
161
- });
162
- await run(undefined, { client });
163
- if (acceptedUndeclared) {
164
- throw new Error(`testDialect: find accepted "${undeclaredPath}", an undeclared extension (A-11)`);
165
- }
166
- const directives = emitted.flatMap((batch) => batch.instructions);
167
- if (!deepEqual(directives, [{ op: "modify", modify: { path: exercise.path, content: exercise.expect } }])) {
168
- throw new Error("testDialect: library exercise did not emit the expected byte-exact modify");
169
- }
170
- }
171
- /**
172
- * Runs the conformance suite for an op-pack against a REAL base dialect (never a mock,
173
- * ADR-0012): for each of `fixture.exercises`, asserts single-op fidelity +
174
- * unchanged-elsewhere (REQ-DC-02) / coalescing-to-one content-verified (REQ-DC-03) via a
175
- * no-read run, seam-serializability (REQ-DC-04) over every emitted directive, and — for
176
- * every multi-op exercise — the read-boundary split (REQ-DC-05.2's live counterpart): a
177
- * mid-chain `read()` must force exactly TWO cumulative modify directives, never one. Finally,
178
- * asserts `fixture.baseDialect` survives the four mandatory adversarial samples' round-trip +
179
- * real-base probe (REQ-DC-06/REQ-DC-08 — additive, not opt-out-able, same mechanism
180
- * `testDialect` runs), unconditionally on every call whose exercises pass.
181
- *
182
- * @example
183
- * await testOpPack({
184
- * opPack: myInsertImportOps,
185
- * baseDialect: myTypeScriptDialect,
186
- * exercises: [
187
- * {
188
- * seed: "export const x = 1;",
189
- * chain: [{ op: "addImport", args: ["readFileSync", "node:fs"] }],
190
- * expect: 'import { readFileSync } from "node:fs";\nexport const x = 1;',
191
- * },
192
- * ],
193
- * });
194
- */
195
- export async function testOpPack(fixture) {
196
- if (fixture.exercises.length === 0) {
197
- throw new Error("testOpPack: fixture.exercises must include at least one exercise — REQ-DC-02..04 are untestable without one");
198
- }
199
- const hasMultiOpExercise = fixture.exercises.some((exercise) => exercise.chain.length >= 2);
200
- if (!hasMultiOpExercise) {
201
- throw new Error("testOpPack: fixture.exercises must include at least one multi-op exercise (>=2 ops) — " +
202
- "REQ-DC-03 (coalescing-to-one, >=2 distinguishable ops) is mandatory");
203
- }
204
- for (const exercise of fixture.exercises) {
205
- // REQ-DC-02 (single-op exercises) / REQ-DC-03 (multi-op exercises): a no-read run must
206
- // coalesce to EXACTLY ONE modify for `path`, byte-exact `expect` — a FULL-output
207
- // comparison proves BOTH the op's intended effect AND that every other region stayed
208
- // byte-stable (never a `contains` substring, Theatre Criteria).
209
- const direct = await runExercise(fixture.baseDialect, exercise, { injectReadAfterFirstOp: false });
210
- // Serializability checked FIRST (REQ-DC-04) — a directive whose content isn't even a
211
- // proper serializable string makes a byte-exact comparison moot, and ordering it first
212
- // proves DC-04's own assertion is what fails a closure-/live-node-smuggle fixture,
213
- // rather than an incidental content mismatch masking it.
214
- assertSerializable(direct.directives, "no-read exercise");
215
- if (direct.modifies.length !== 1) {
216
- throw new Error(`testOpPack: REQ-DC-02/03 — expected exactly ONE modify directive for a no-read chain, got ${direct.modifies.length}`);
217
- }
218
- if (direct.modifies[0]?.content !== exercise.expect) {
219
- throw new Error("testOpPack: REQ-DC-02/03 — the coalesced modify's content did not byte-exact match the fixture's expect value");
220
- }
221
- if (exercise.chain.length >= 2) {
222
- // Read-boundary split (fifth core assertion, self-derived — the live counterpart of
223
- // the planted REQ-DC-05.2). Re-run injecting `handle.read()` right after the FIRST
224
- // op: the GLOBAL flush-before-read (ADR-0015) forces exactly TWO modify directives
225
- // whose cumulative content equals `expect`; directive #1's expected content is
226
- // SELF-DERIVED by running the first op ALONE — no extra fixture field.
227
- const firstOpOnly = {
228
- seed: exercise.seed,
229
- path: exercise.path,
230
- chain: exercise.chain.slice(0, 1),
231
- };
232
- const firstOnly = await runExercise(fixture.baseDialect, firstOpOnly, { injectReadAfterFirstOp: false });
233
- const expectedFirst = firstOnly.modifies[0]?.content;
234
- if (expectedFirst === undefined) {
235
- throw new Error("testOpPack: REQ-DC-05.2 — could not self-derive directive #1's expected content (the first op alone produced no modify)");
236
- }
237
- const split = await runExercise(fixture.baseDialect, exercise, { injectReadAfterFirstOp: true });
238
- assertSerializable(split.directives, "read-split exercise");
239
- if (split.modifies.length !== 2) {
240
- throw new Error(`testOpPack: REQ-DC-05.2 read-boundary split — expected exactly TWO modify directives after a mid-chain read, got ${split.modifies.length}`);
241
- }
242
- if (split.modifies[0]?.content !== expectedFirst) {
243
- throw new Error("testOpPack: REQ-DC-05.2 — the first split directive's content did not match the self-derived first-op-alone content");
244
- }
245
- if (split.modifies[1]?.content !== exercise.expect) {
246
- 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
- }
248
- }
249
- }
250
- // REQ-DC-06/REQ-DC-08 (verify-in-loop-4 Finding #1): the four mandatory adversarial
251
- // samples' round-trip + real-base probe, run against `fixture.baseDialect` — same
252
- // mechanism `testDialect` runs, independent of `fixture.exercises`. Deliberately LAST
253
- // (not first, unlike testDialect): a fixture's own exercises target ONE specific
254
- // REQ-DC-02..05 failure mode against a baseDialect that may be intentionally non-generic
255
- // (e.g. this repo's own REQ-DC-05 planted-violation fixtures use hand-rolled/identity
256
- // `ast` pairs to isolate that ONE mode) — ordering the probe last lets that exercise-level
257
- // failure surface for its own reason first, while still running the probe unconditionally
258
- // on every call whose exercises pass, exactly as REQ-DC-06's "regardless of what samples
259
- // the contributor's own fixture supplies" demands.
260
- runRoundTripProbe(fixture.baseDialect.ast, mandatoryAdversarialSamples(fixture.exercises[0].seed), "testOpPack");
261
- }
1
+ export * from "../bounded-contexts/authoring/testing/conformance/index.js";
@@ -1,63 +1 @@
1
- import type { SourceFile } from "ts-morph";
2
- import { type Handle } from "../../core/define-dialect.ts";
3
- import { typescriptOps } from "../typescript/pack.ts";
4
- import type { ArrayElement } from "../typescript/array-element.ts";
5
- import { type InjectionOptions, type InputOptions, type LazyRouteSpec, type NamedImport, type OutputOptions, type RouteSpec, type StateOptions } from "./ops.ts";
6
- export * as astLibrary from "ts-morph";
7
- export type { InjectionOptions, InputOptions, LazyRouteSpec, NamedImport, OutputOptions, RouteSpec, StateOptions };
8
- type InsertOp = (ast: SourceFile, element: ArrayElement, imports?: readonly NamedImport[]) => void;
9
- type AngularOps = {
10
- addComponentImport: InsertOp;
11
- addComponentProvider: InsertOp;
12
- addRootProvider: InsertOp;
13
- addRoute: (ast: SourceFile, route: RouteSpec) => void;
14
- addLazyRoute: (ast: SourceFile, route: LazyRouteSpec) => void;
15
- addInjection: (ast: SourceFile, name: string, token: ArrayElement, options?: InjectionOptions) => void;
16
- addInput: (ast: SourceFile, name: string, options?: InputOptions) => void;
17
- addModel: (ast: SourceFile, name: string, options?: InputOptions) => void;
18
- addOutput: (ast: SourceFile, name: string, options?: OutputOptions) => void;
19
- addSignal: (ast: SourceFile, name: string, initial: string, options?: StateOptions) => void;
20
- addComputed: (ast: SourceFile, name: string, expression: string, options?: StateOptions) => void;
21
- addNgModuleImport: InsertOp;
22
- addDeclaration: InsertOp;
23
- addNgModuleProvider: InsertOp;
24
- addNgModuleExport: InsertOp;
25
- addBootstrap: InsertOp;
26
- };
27
- /**
28
- * Opens a `.ts` file of an Angular project for editing. The handle carries every
29
- * `@pbuilder/sdk/typescript` op plus the Angular ops below, chained on one handle and written
30
- * once.
31
- *
32
- * Each op takes `(element, imports?)`: `element` is an identifier, or `{ expression }` for
33
- * code such as `provideHttpClient(withFetch())`, and `imports` lists the `{ name, from }`
34
- * named imports that code needs, each added with `addImport`'s rules. An element already
35
- * listed is a no-op.
36
- *
37
- * - `addComponentImport` / `addComponentProvider` append to `imports` / `providers` of the
38
- * file's only `@Component`, creating the metadata object or the array when missing.
39
- * - `addRootProvider` appends to the root `providers` of the file's only variable typed
40
- * `ApplicationConfig`, or of the only `bootstrapApplication(...)` config object.
41
- * - `addRoute({ path, component, from })` imports `component` and adds an eager route;
42
- * `addLazyRoute({ path, loadComponent | loadChildren, export? })` adds a lazy one. Both go
43
- * to the file's only variable typed `Routes` or `Route[]`, before a `**` route when there is
44
- * one, since the first matching route wins. A different route with the same `path` rejects.
45
- *
46
- * They reject, leaving the file unchanged, when the target is missing, ambiguous, or not a
47
- * literal. Use `.modify(fn)` for those files.
48
- *
49
- * @example
50
- * import * as angular from "@pbuilder/sdk/angular";
51
- *
52
- * // src/app/app.config.ts before:
53
- * // export const appConfig: ApplicationConfig = { providers: [provideRouter(routes)] };
54
- * export const run = async () => {
55
- * await angular.find("src/app/app.config.ts").addRootProvider({ expression: "provideHttpClient(withFetch())" }, [
56
- * { name: "provideHttpClient", from: "@angular/common/http" },
57
- * { name: "withFetch", from: "@angular/common/http" },
58
- * ]);
59
- * };
60
- * // -> import { provideHttpClient, withFetch } from "@angular/common/http";
61
- * // -> export const appConfig: ApplicationConfig = { providers: [provideRouter(routes), provideHttpClient(withFetch())] };
62
- */
63
- export declare function find(path: string): Handle<"found", SourceFile, AngularOps & typeof typescriptOps>;
1
+ export * from "../../bounded-contexts/authoring/infrastructure/out/dialects/angular/index.ts";
@@ -1,68 +1 @@
1
- import { defineDialect, defineOpPack, withOps } from "../../core/define-dialect.js";
2
- import { parse, print } from "../typescript/ast.js";
3
- import { typescriptOps } from "../typescript/pack.js";
4
- import { addBootstrap, addComponentImport, addComponentProvider, addComputed, addDeclaration, addInjection, addInput, addLazyRoute, addModel, addNgModuleExport, addNgModuleImport, addNgModuleProvider, addOutput, addRootProvider, addRoute, addSignal, } from "./ops.js";
5
- export * as astLibrary from "ts-morph";
6
- const angularOps = defineOpPack({
7
- addComponentImport,
8
- addComponentProvider,
9
- addRootProvider,
10
- addRoute,
11
- addLazyRoute,
12
- addInjection,
13
- addInput,
14
- addModel,
15
- addOutput,
16
- addSignal,
17
- addComputed,
18
- addNgModuleImport,
19
- addDeclaration,
20
- addNgModuleProvider,
21
- addNgModuleExport,
22
- addBootstrap,
23
- });
24
- const baseDialect = defineDialect({
25
- extensions: [".ts"],
26
- ast: { parse, print },
27
- ops: {},
28
- });
29
- const angularDialect = withOps(baseDialect, typescriptOps, angularOps);
30
- /**
31
- * Opens a `.ts` file of an Angular project for editing. The handle carries every
32
- * `@pbuilder/sdk/typescript` op plus the Angular ops below, chained on one handle and written
33
- * once.
34
- *
35
- * Each op takes `(element, imports?)`: `element` is an identifier, or `{ expression }` for
36
- * code such as `provideHttpClient(withFetch())`, and `imports` lists the `{ name, from }`
37
- * named imports that code needs, each added with `addImport`'s rules. An element already
38
- * listed is a no-op.
39
- *
40
- * - `addComponentImport` / `addComponentProvider` append to `imports` / `providers` of the
41
- * file's only `@Component`, creating the metadata object or the array when missing.
42
- * - `addRootProvider` appends to the root `providers` of the file's only variable typed
43
- * `ApplicationConfig`, or of the only `bootstrapApplication(...)` config object.
44
- * - `addRoute({ path, component, from })` imports `component` and adds an eager route;
45
- * `addLazyRoute({ path, loadComponent | loadChildren, export? })` adds a lazy one. Both go
46
- * to the file's only variable typed `Routes` or `Route[]`, before a `**` route when there is
47
- * one, since the first matching route wins. A different route with the same `path` rejects.
48
- *
49
- * They reject, leaving the file unchanged, when the target is missing, ambiguous, or not a
50
- * literal. Use `.modify(fn)` for those files.
51
- *
52
- * @example
53
- * import * as angular from "@pbuilder/sdk/angular";
54
- *
55
- * // src/app/app.config.ts before:
56
- * // export const appConfig: ApplicationConfig = { providers: [provideRouter(routes)] };
57
- * export const run = async () => {
58
- * await angular.find("src/app/app.config.ts").addRootProvider({ expression: "provideHttpClient(withFetch())" }, [
59
- * { name: "provideHttpClient", from: "@angular/common/http" },
60
- * { name: "withFetch", from: "@angular/common/http" },
61
- * ]);
62
- * };
63
- * // -> import { provideHttpClient, withFetch } from "@angular/common/http";
64
- * // -> export const appConfig: ApplicationConfig = { providers: [provideRouter(routes), provideHttpClient(withFetch())] };
65
- */
66
- export function find(path) {
67
- return angularDialect.find(path);
68
- }
1
+ export * from "../../bounded-contexts/authoring/infrastructure/out/dialects/angular/index.js";
@@ -1,40 +1 @@
1
- import type { Root } from "postcss";
2
- import { type Handle, type Query } from "../../core/define-dialect.ts";
3
- import { getDeclaration, type CssTarget, type DeclarationOptions } from "./ops.ts";
4
- export * as astLibrary from "postcss";
5
- export { getDeclaration };
6
- export type { CssTarget, DeclarationOptions };
7
- type CssOps = {
8
- setDeclaration: (ast: Root, target: CssTarget, property: string, value: string, options?: DeclarationOptions) => void;
9
- removeDeclaration: (ast: Root, target: CssTarget, property: string) => void;
10
- getDeclaration: Query<Root, [target: CssTarget, property: string], ReturnType<typeof getDeclaration>>;
11
- };
12
- /**
13
- * Opens a `.css` file to set and remove declarations. A target names one top-level block —
14
- * `{ selector: ":root" }`, `{ atRule: "theme" }`, or `{ atRule: "media", params, selector }` —
15
- * and every op edits only the declaration it addresses: comments, `@import`s, other rules,
16
- * indentation, line endings, and a BOM survive. Any other extension throws synchronously with
17
- * the `dialect operation failed: ` prefix. `.modify(fn)` hands `fn` the live PostCSS `Root`;
18
- * use `astLibrary` (`postcss`) for anything the ops do not cover.
19
- *
20
- * @example
21
- * import * as css from "@pbuilder/sdk/css";
22
- *
23
- * // tokens.css before: @import "tailwindcss";\n\n@theme {\n --color-primary: #0b254d;\n}\n
24
- * export const run = async () => {
25
- * await css
26
- * .find("tokens.css")
27
- * .setDeclaration({ atRule: "theme" }, "--color-primary", "#1974f9")
28
- * .setDeclaration({ selector: "html[data-theme='nylon']" }, "--color-primary", "#0b254d");
29
- * };
30
- * // -> @import "tailwindcss";
31
- * // ->
32
- * // -> @theme {
33
- * // -> --color-primary: #1974f9;
34
- * // -> }
35
- * // ->
36
- * // -> html[data-theme='nylon'] {
37
- * // -> --color-primary: #0b254d;
38
- * // -> }
39
- */
40
- export declare function find(path: string): Handle<"found", Root, CssOps>;
1
+ export * from "../../bounded-contexts/authoring/infrastructure/out/dialects/css/index.ts";
@@ -1,38 +1 @@
1
- import { defineDialect, defineOpPack, query, withOps } from "../../core/define-dialect.js";
2
- import { parse, print } from "./ast.js";
3
- import { getDeclaration, removeDeclaration, setDeclaration } from "./ops.js";
4
- export * as astLibrary from "postcss";
5
- export { getDeclaration };
6
- const opsPack = defineOpPack({ setDeclaration, removeDeclaration, getDeclaration: query(getDeclaration) });
7
- const cssDialect = withOps(defineDialect({ extensions: [".css"], ast: { parse, print }, ops: {} }), opsPack);
8
- /**
9
- * Opens a `.css` file to set and remove declarations. A target names one top-level block —
10
- * `{ selector: ":root" }`, `{ atRule: "theme" }`, or `{ atRule: "media", params, selector }` —
11
- * and every op edits only the declaration it addresses: comments, `@import`s, other rules,
12
- * indentation, line endings, and a BOM survive. Any other extension throws synchronously with
13
- * the `dialect operation failed: ` prefix. `.modify(fn)` hands `fn` the live PostCSS `Root`;
14
- * use `astLibrary` (`postcss`) for anything the ops do not cover.
15
- *
16
- * @example
17
- * import * as css from "@pbuilder/sdk/css";
18
- *
19
- * // tokens.css before: @import "tailwindcss";\n\n@theme {\n --color-primary: #0b254d;\n}\n
20
- * export const run = async () => {
21
- * await css
22
- * .find("tokens.css")
23
- * .setDeclaration({ atRule: "theme" }, "--color-primary", "#1974f9")
24
- * .setDeclaration({ selector: "html[data-theme='nylon']" }, "--color-primary", "#0b254d");
25
- * };
26
- * // -> @import "tailwindcss";
27
- * // ->
28
- * // -> @theme {
29
- * // -> --color-primary: #1974f9;
30
- * // -> }
31
- * // ->
32
- * // -> html[data-theme='nylon'] {
33
- * // -> --color-primary: #0b254d;
34
- * // -> }
35
- */
36
- export function find(path) {
37
- return cssDialect.find(path);
38
- }
1
+ export * from "../../bounded-contexts/authoring/infrastructure/out/dialects/css/index.js";
@@ -1,55 +1 @@
1
- import { type Handle } from "../../core/define-dialect.ts";
2
- import type { JsonPath, JsonValue } from "../../core/json-value.ts";
3
- import { type JsonDocument } from "./ast.ts";
4
- import { type AppendOptions, type KeyPosition, type SortOptions } from "./ops.ts";
5
- export * as astLibrary from "jsonc-parser";
6
- export type { JsonDocument, JsonPath, JsonValue, KeyPosition, AppendOptions, SortOptions };
7
- type JsonOps = {
8
- setValue: (ast: JsonDocument, path: JsonPath, value: JsonValue, options?: KeyPosition) => void;
9
- addKey: (ast: JsonDocument, path: JsonPath, value: JsonValue, options?: KeyPosition) => void;
10
- removeKey: (ast: JsonDocument, path: JsonPath) => void;
11
- renameKey: (ast: JsonDocument, path: JsonPath, newKey: string) => void;
12
- insertItem: (ast: JsonDocument, path: JsonPath, index: number, value: JsonValue) => void;
13
- appendItem: (ast: JsonDocument, path: JsonPath, value: JsonValue, options?: AppendOptions) => void;
14
- removeItem: (ast: JsonDocument, path: JsonPath, index: number) => void;
15
- removeValue: (ast: JsonDocument, path: JsonPath, value: JsonValue) => void;
16
- replaceItem: (ast: JsonDocument, path: JsonPath, index: number, value: JsonValue) => void;
17
- moveItem: (ast: JsonDocument, path: JsonPath, from: number, to: number) => void;
18
- merge: (ast: JsonDocument, path: JsonPath, value: {
19
- [key: string]: JsonValue;
20
- }) => void;
21
- updateValue: <T extends JsonValue>(ast: JsonDocument, path: JsonPath, fn: (current: JsonValue | undefined) => T) => void;
22
- moveValue: (ast: JsonDocument, from: JsonPath, to: JsonPath) => void;
23
- copyValue: (ast: JsonDocument, from: JsonPath, to: JsonPath) => void;
24
- sortKeys: (ast: JsonDocument, path: JsonPath, options?: SortOptions) => void;
25
- };
26
- /**
27
- * Opens a `.json` or `.jsonc` file for structural editing. Every op addresses a value by a
28
- * path array (`["scripts", "build"]`, `["files", 0]`) and edits only the bytes it must:
29
- * comments, key order, indentation, line endings, a BOM, and the trailing newline survive.
30
- * Any other extension, a basename with no stem (`.json`), or an extensionless path throws
31
- * synchronously with the `dialect operation failed: ` prefix. `.modify(fn)` hands `fn` the
32
- * live `JsonDocument`; edit its `text` with `astLibrary` (`jsonc-parser`) for anything the
33
- * ops do not cover, such as comments.
34
- *
35
- * @example
36
- * import * as json from "@pbuilder/sdk/json";
37
- *
38
- * // package.json before: {\n "name": "app"\n}\n
39
- * export const run = async () => {
40
- * await json
41
- * .find("package.json")
42
- * .setValue(["scripts", "build"], "tsc")
43
- * .appendItem(["files"], "dist", { unique: true });
44
- * };
45
- * // -> {
46
- * // -> "name": "app",
47
- * // -> "scripts": {
48
- * // -> "build": "tsc"
49
- * // -> },
50
- * // -> "files": [
51
- * // -> "dist"
52
- * // -> ]
53
- * // -> }
54
- */
55
- export declare function find(path: string): Handle<"found", JsonDocument, JsonOps>;
1
+ export * from "../../bounded-contexts/authoring/infrastructure/out/dialects/json/index.ts";
@@ -1,54 +1 @@
1
- import { defineDialect, defineOpPack, withOps } from "../../core/define-dialect.js";
2
- import { parse, print } from "./ast.js";
3
- import { addKey, appendItem, copyValue, insertItem, merge, moveItem, moveValue, removeItem, removeKey, removeValue, renameKey, replaceItem, setValue, sortKeys, updateValue, } from "./ops.js";
4
- export * as astLibrary from "jsonc-parser";
5
- const opsPack = defineOpPack({
6
- setValue,
7
- addKey,
8
- removeKey,
9
- renameKey,
10
- insertItem,
11
- appendItem,
12
- removeItem,
13
- removeValue,
14
- replaceItem,
15
- moveItem,
16
- merge,
17
- updateValue,
18
- moveValue,
19
- copyValue,
20
- sortKeys,
21
- });
22
- const jsonDialect = withOps(defineDialect({ extensions: [".json", ".jsonc"], ast: { parse, print }, ops: {} }), opsPack);
23
- /**
24
- * Opens a `.json` or `.jsonc` file for structural editing. Every op addresses a value by a
25
- * path array (`["scripts", "build"]`, `["files", 0]`) and edits only the bytes it must:
26
- * comments, key order, indentation, line endings, a BOM, and the trailing newline survive.
27
- * Any other extension, a basename with no stem (`.json`), or an extensionless path throws
28
- * synchronously with the `dialect operation failed: ` prefix. `.modify(fn)` hands `fn` the
29
- * live `JsonDocument`; edit its `text` with `astLibrary` (`jsonc-parser`) for anything the
30
- * ops do not cover, such as comments.
31
- *
32
- * @example
33
- * import * as json from "@pbuilder/sdk/json";
34
- *
35
- * // package.json before: {\n "name": "app"\n}\n
36
- * export const run = async () => {
37
- * await json
38
- * .find("package.json")
39
- * .setValue(["scripts", "build"], "tsc")
40
- * .appendItem(["files"], "dist", { unique: true });
41
- * };
42
- * // -> {
43
- * // -> "name": "app",
44
- * // -> "scripts": {
45
- * // -> "build": "tsc"
46
- * // -> },
47
- * // -> "files": [
48
- * // -> "dist"
49
- * // -> ]
50
- * // -> }
51
- */
52
- export function find(path) {
53
- return jsonDialect.find(path);
54
- }
1
+ export * from "../../bounded-contexts/authoring/infrastructure/out/dialects/json/index.js";
@@ -1,43 +1 @@
1
- import type { SourceFile } from "ts-morph";
2
- import { type Handle } from "../../core/define-dialect.ts";
3
- import { typescriptOps } from "../typescript/pack.ts";
4
- export * as astLibrary from "ts-morph";
5
- type ModuleOps = {
6
- addProvider: (ast: SourceFile, name: string, from: string) => void;
7
- addController: (ast: SourceFile, name: string, from: string) => void;
8
- addModuleImport: (ast: SourceFile, name: string, from: string) => void;
9
- addExport: (ast: SourceFile, name: string, from: string) => void;
10
- };
11
- type NestOps = typeof typescriptOps & ModuleOps;
12
- /**
13
- * Opens a `.ts` file of a NestJS project for editing. The handle carries every
14
- * `@pbuilder/sdk/typescript` op plus the `@Module` ops below, chained on one handle and
15
- * written once.
16
- *
17
- * `addProvider`, `addController`, `addModuleImport` and `addExport` each take
18
- * `(name, from)`: they add `import { name } from "from"` with the same rules as `addImport`,
19
- * then append `name` to the `providers`, `controllers`, `imports` or `exports` array of the
20
- * file's only `@Module` class, creating the metadata object or the array when missing. They
21
- * reject, leaving the file unchanged, when the file has no `@Module` class or more than one,
22
- * or when the metadata or the array is not a literal. Use `.modify(fn)` for those files and
23
- * for entries that are not a plain class name, such as `ConfigModule.forRoot()`.
24
- *
25
- * @example
26
- * import * as nestjs from "@pbuilder/sdk/nestjs";
27
- *
28
- * // src/app.module.ts before:
29
- * // @Module({ providers: [AppService] })
30
- * // export class AppModule {}
31
- * export const run = async () => {
32
- * await nestjs
33
- * .find("src/app.module.ts")
34
- * .addModuleImport("UsersModule", "./users/users.module")
35
- * .addProvider("UsersService", "./users/users.service");
36
- * };
37
- * // -> import { UsersModule } from "./users/users.module";
38
- * // -> import { UsersService } from "./users/users.service";
39
- * // ->
40
- * // -> @Module({ providers: [AppService, UsersService], imports: [UsersModule] })
41
- * // -> export class AppModule {}
42
- */
43
- export declare function find(path: string): Handle<"found", SourceFile, NestOps>;
1
+ export * from "../../bounded-contexts/authoring/infrastructure/out/dialects/nestjs/index.ts";