@dads-framework/toolbox 0.1.0 → 0.3.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.
Files changed (215) hide show
  1. package/README.md +102 -39
  2. package/bin/dad-dev.js +12 -0
  3. package/bin/usage.js +34 -4
  4. package/dist/access-diff-format.d.ts +16 -0
  5. package/dist/access-diff-format.d.ts.map +1 -0
  6. package/dist/access-diff-format.js +119 -0
  7. package/dist/access-diff-format.js.map +1 -0
  8. package/dist/access-diff-types.d.ts +79 -0
  9. package/dist/access-diff-types.d.ts.map +1 -0
  10. package/dist/access-diff-types.js +3 -0
  11. package/dist/access-diff-types.js.map +1 -0
  12. package/dist/access-diff.d.ts +21 -0
  13. package/dist/access-diff.d.ts.map +1 -0
  14. package/dist/access-diff.js +226 -0
  15. package/dist/access-diff.js.map +1 -0
  16. package/dist/access-import.d.ts +22 -0
  17. package/dist/access-import.d.ts.map +1 -0
  18. package/dist/access-import.js +30 -0
  19. package/dist/access-import.js.map +1 -0
  20. package/dist/access-migrate.d.ts +37 -0
  21. package/dist/access-migrate.d.ts.map +1 -0
  22. package/dist/access-migrate.js +250 -0
  23. package/dist/access-migrate.js.map +1 -0
  24. package/dist/access-source-loader.d.ts +16 -0
  25. package/dist/access-source-loader.d.ts.map +1 -0
  26. package/dist/access-source-loader.js +171 -0
  27. package/dist/access-source-loader.js.map +1 -0
  28. package/dist/access-tree.d.ts +23 -0
  29. package/dist/access-tree.d.ts.map +1 -0
  30. package/dist/access-tree.js +39 -0
  31. package/dist/access-tree.js.map +1 -0
  32. package/dist/access-zed-io.d.ts +6 -0
  33. package/dist/access-zed-io.d.ts.map +1 -0
  34. package/dist/access-zed-io.js +31 -0
  35. package/dist/access-zed-io.js.map +1 -0
  36. package/dist/cli-access-args.d.ts +25 -0
  37. package/dist/cli-access-args.d.ts.map +1 -0
  38. package/dist/cli-access-args.js +168 -0
  39. package/dist/cli-access-args.js.map +1 -0
  40. package/dist/cli-access-commands.d.ts +3 -0
  41. package/dist/cli-access-commands.d.ts.map +1 -0
  42. package/dist/cli-access-commands.js +120 -0
  43. package/dist/cli-access-commands.js.map +1 -0
  44. package/dist/cli-io.d.ts +6 -0
  45. package/dist/cli-io.d.ts.map +1 -1
  46. package/dist/cli-io.js +14 -0
  47. package/dist/cli-io.js.map +1 -1
  48. package/dist/cli-migrate-commands.d.ts +2 -0
  49. package/dist/cli-migrate-commands.d.ts.map +1 -0
  50. package/dist/cli-migrate-commands.js +59 -0
  51. package/dist/cli-migrate-commands.js.map +1 -0
  52. package/dist/cli-project-commands.d.ts.map +1 -1
  53. package/dist/cli-project-commands.js +1 -0
  54. package/dist/cli-project-commands.js.map +1 -1
  55. package/dist/cli.js +20 -5
  56. package/dist/cli.js.map +1 -1
  57. package/dist/dads-initialization-arguments.d.ts +2 -0
  58. package/dist/dads-initialization-arguments.d.ts.map +1 -1
  59. package/dist/dads-initialization-arguments.js +15 -3
  60. package/dist/dads-initialization-arguments.js.map +1 -1
  61. package/dist/dev/cli.d.ts +2 -0
  62. package/dist/dev/cli.d.ts.map +1 -0
  63. package/dist/dev/cli.js +123 -0
  64. package/dist/dev/cli.js.map +1 -0
  65. package/dist/dev/dev-config.d.ts +20 -0
  66. package/dist/dev/dev-config.d.ts.map +1 -0
  67. package/dist/dev/dev-config.js +36 -0
  68. package/dist/dev/dev-config.js.map +1 -0
  69. package/dist/dev/git-worktrees.d.ts +14 -0
  70. package/dist/dev/git-worktrees.d.ts.map +1 -0
  71. package/dist/dev/git-worktrees.js +41 -0
  72. package/dist/dev/git-worktrees.js.map +1 -0
  73. package/dist/dev/index.d.ts +2 -0
  74. package/dist/dev/index.d.ts.map +1 -0
  75. package/dist/dev/index.js +2 -0
  76. package/dist/dev/index.js.map +1 -0
  77. package/dist/dev/managed-processes.d.ts +6 -0
  78. package/dist/dev/managed-processes.d.ts.map +1 -0
  79. package/dist/dev/managed-processes.js +57 -0
  80. package/dist/dev/managed-processes.js.map +1 -0
  81. package/dist/dev/process-inspection.d.ts +5 -0
  82. package/dist/dev/process-inspection.d.ts.map +1 -0
  83. package/dist/dev/process-inspection.js +68 -0
  84. package/dist/dev/process-inspection.js.map +1 -0
  85. package/dist/dev/slot-environment.d.ts +6 -0
  86. package/dist/dev/slot-environment.d.ts.map +1 -0
  87. package/dist/dev/slot-environment.js +117 -0
  88. package/dist/dev/slot-environment.js.map +1 -0
  89. package/dist/dev/slot-run.d.ts +16 -0
  90. package/dist/dev/slot-run.d.ts.map +1 -0
  91. package/dist/dev/slot-run.js +90 -0
  92. package/dist/dev/slot-run.js.map +1 -0
  93. package/dist/dev/slot-state.d.ts +16 -0
  94. package/dist/dev/slot-state.d.ts.map +1 -0
  95. package/dist/dev/slot-state.js +66 -0
  96. package/dist/dev/slot-state.js.map +1 -0
  97. package/dist/dev/slot-supervisor.d.ts +2 -0
  98. package/dist/dev/slot-supervisor.d.ts.map +1 -0
  99. package/dist/dev/slot-supervisor.js +103 -0
  100. package/dist/dev/slot-supervisor.js.map +1 -0
  101. package/dist/dev/worktree-decision.d.ts +23 -0
  102. package/dist/dev/worktree-decision.d.ts.map +1 -0
  103. package/dist/dev/worktree-decision.js +21 -0
  104. package/dist/dev/worktree-decision.js.map +1 -0
  105. package/dist/dev/worktree-lifecycle.d.ts +8 -0
  106. package/dist/dev/worktree-lifecycle.d.ts.map +1 -0
  107. package/dist/dev/worktree-lifecycle.js +174 -0
  108. package/dist/dev/worktree-lifecycle.js.map +1 -0
  109. package/dist/doctor/signals/anxious-attachment/kind-inversions.d.ts.map +1 -1
  110. package/dist/doctor/signals/anxious-attachment/kind-inversions.js +19 -10
  111. package/dist/doctor/signals/anxious-attachment/kind-inversions.js.map +1 -1
  112. package/dist/doctor/signals/commitment-issues/test-count.d.ts +3 -3
  113. package/dist/doctor/signals/commitment-issues/test-count.d.ts.map +1 -1
  114. package/dist/doctor/signals/commitment-issues/test-count.js +9 -7
  115. package/dist/doctor/signals/commitment-issues/test-count.js.map +1 -1
  116. package/dist/doctor/signals/its-not-you-its-my-boundaries/lint-rules.d.ts.map +1 -1
  117. package/dist/doctor/signals/its-not-you-its-my-boundaries/lint-rules.js +5 -1
  118. package/dist/doctor/signals/its-not-you-its-my-boundaries/lint-rules.js.map +1 -1
  119. package/dist/doctor/signals/people-pleasing/forbidden-403.d.ts +5 -5
  120. package/dist/doctor/signals/people-pleasing/forbidden-403.d.ts.map +1 -1
  121. package/dist/doctor/signals/people-pleasing/forbidden-403.js +57 -17
  122. package/dist/doctor/signals/people-pleasing/forbidden-403.js.map +1 -1
  123. package/dist/doctor/signals/scanners/lint-configuration.d.ts.map +1 -1
  124. package/dist/doctor/signals/scanners/lint-configuration.js +17 -5
  125. package/dist/doctor/signals/scanners/lint-configuration.js.map +1 -1
  126. package/dist/doctor/signals/scanners/package-graph.d.ts +1 -0
  127. package/dist/doctor/signals/scanners/package-graph.d.ts.map +1 -1
  128. package/dist/doctor/signals/scanners/package-graph.js +8 -0
  129. package/dist/doctor/signals/scanners/package-graph.js.map +1 -1
  130. package/dist/doctor/signals/scanners/source-bindings.d.ts +16 -0
  131. package/dist/doctor/signals/scanners/source-bindings.d.ts.map +1 -0
  132. package/dist/doctor/signals/scanners/source-bindings.js +57 -0
  133. package/dist/doctor/signals/scanners/source-bindings.js.map +1 -0
  134. package/dist/doctor/signals/scanners/web-renderers.js +2 -2
  135. package/dist/doctor/signals/scanners/web-renderers.js.map +1 -1
  136. package/dist/doctor/signals/the-paper-wall/explicit-wrapper-conformance.d.ts.map +1 -1
  137. package/dist/doctor/signals/the-paper-wall/explicit-wrapper-conformance.js +26 -64
  138. package/dist/doctor/signals/the-paper-wall/explicit-wrapper-conformance.js.map +1 -1
  139. package/dist/doctor/signals/the-paper-wall/table-wrapper-conformance.d.ts +6 -0
  140. package/dist/doctor/signals/the-paper-wall/table-wrapper-conformance.d.ts.map +1 -0
  141. package/dist/doctor/signals/the-paper-wall/table-wrapper-conformance.js +212 -0
  142. package/dist/doctor/signals/the-paper-wall/table-wrapper-conformance.js.map +1 -0
  143. package/dist/doctor/signals/the-paper-wall/wrapper-conformance-provider.d.ts +10 -0
  144. package/dist/doctor/signals/the-paper-wall/wrapper-conformance-provider.d.ts.map +1 -0
  145. package/dist/doctor/signals/the-paper-wall/wrapper-conformance-provider.js +71 -0
  146. package/dist/doctor/signals/the-paper-wall/wrapper-conformance-provider.js.map +1 -0
  147. package/dist/doctor/signals/you-are-looking-for-a-father-figure/framework-in-core.d.ts.map +1 -1
  148. package/dist/doctor/signals/you-are-looking-for-a-father-figure/framework-in-core.js +5 -1
  149. package/dist/doctor/signals/you-are-looking-for-a-father-figure/framework-in-core.js.map +1 -1
  150. package/dist/index.d.ts +7 -0
  151. package/dist/index.d.ts.map +1 -1
  152. package/dist/index.js +7 -0
  153. package/dist/index.js.map +1 -1
  154. package/dist/initialize-dads-project.d.ts +2 -0
  155. package/dist/initialize-dads-project.d.ts.map +1 -1
  156. package/dist/initialize-dads-project.js +4 -1
  157. package/dist/initialize-dads-project.js.map +1 -1
  158. package/dist/migrate-v03-map.d.ts +11 -0
  159. package/dist/migrate-v03-map.d.ts.map +1 -0
  160. package/dist/migrate-v03-map.js +204 -0
  161. package/dist/migrate-v03-map.js.map +1 -0
  162. package/dist/migrate-v03.d.ts +20 -0
  163. package/dist/migrate-v03.d.ts.map +1 -0
  164. package/dist/migrate-v03.js +280 -0
  165. package/dist/migrate-v03.js.map +1 -0
  166. package/dist/resource-generators/access-generator.d.ts.map +1 -1
  167. package/dist/resource-generators/access-generator.js +17 -26
  168. package/dist/resource-generators/access-generator.js.map +1 -1
  169. package/dist/resource-generators/domain-generator.d.ts.map +1 -1
  170. package/dist/resource-generators/domain-generator.js +9 -2
  171. package/dist/resource-generators/domain-generator.js.map +1 -1
  172. package/dist/resource-generators/email-generator.js +2 -2
  173. package/dist/resource-generators/endpoint-generator.js +2 -2
  174. package/dist/resource-generators/generator-dependencies.js +7 -11
  175. package/dist/resource-generators/generator-dependencies.js.map +1 -1
  176. package/dist/resource-generators/resource-contract.js +2 -2
  177. package/dist/resource-generators/resource-pages.js +1 -1
  178. package/dist/resource-generators/resource-proof.d.ts.map +1 -1
  179. package/dist/resource-generators/resource-proof.js +10 -17
  180. package/dist/resource-generators/resource-proof.js.map +1 -1
  181. package/dist/resource-generators/resource-routes.js +1 -1
  182. package/dist/resource-generators/table-generator.js +1 -1
  183. package/dist/starter-project/kit-starter.generated.d.ts.map +1 -1
  184. package/dist/starter-project/kit-starter.generated.js +103 -50
  185. package/dist/starter-project/kit-starter.generated.js.map +1 -1
  186. package/dist/starter-project/minimal-project-assembly.d.ts +4 -0
  187. package/dist/starter-project/minimal-project-assembly.d.ts.map +1 -0
  188. package/dist/starter-project/minimal-project-assembly.js +363 -0
  189. package/dist/starter-project/minimal-project-assembly.js.map +1 -0
  190. package/dist/starter-project/minimal-project-docs-and-tests.d.ts +4 -0
  191. package/dist/starter-project/minimal-project-docs-and-tests.d.ts.map +1 -0
  192. package/dist/starter-project/minimal-project-docs-and-tests.js +309 -0
  193. package/dist/starter-project/minimal-project-docs-and-tests.js.map +1 -0
  194. package/dist/starter-project/minimal-project-server.d.ts +4 -0
  195. package/dist/starter-project/minimal-project-server.d.ts.map +1 -0
  196. package/dist/starter-project/minimal-project-server.js +120 -0
  197. package/dist/starter-project/minimal-project-server.js.map +1 -0
  198. package/dist/starter-project/minimal-project-web.d.ts +4 -0
  199. package/dist/starter-project/minimal-project-web.d.ts.map +1 -0
  200. package/dist/starter-project/minimal-project-web.js +344 -0
  201. package/dist/starter-project/minimal-project-web.js.map +1 -0
  202. package/dist/starter-project/minimal-project-workbench.d.ts +4 -0
  203. package/dist/starter-project/minimal-project-workbench.d.ts.map +1 -0
  204. package/dist/starter-project/minimal-project-workbench.js +371 -0
  205. package/dist/starter-project/minimal-project-workbench.js.map +1 -0
  206. package/dist/starter-project/render-minimal-project.d.ts +6 -0
  207. package/dist/starter-project/render-minimal-project.d.ts.map +1 -0
  208. package/dist/starter-project/render-minimal-project.js +162 -0
  209. package/dist/starter-project/render-minimal-project.js.map +1 -0
  210. package/dist/starter-project/render-starter-project.d.ts +2 -0
  211. package/dist/starter-project/render-starter-project.d.ts.map +1 -1
  212. package/dist/starter-project/render-starter-project.js +4 -0
  213. package/dist/starter-project/render-starter-project.js.map +1 -1
  214. package/dist/toolbox.tsbuildinfo +1 -1
  215. package/package.json +11 -4
package/README.md CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  The optional `dad` command line. It initializes and adopts Dads projects,
4
4
  explains which package owns a path, plans and runs the verification a change
5
- earns, and drives the authorization workflows a project has adopted. No runtime
6
- framework package depends on it.
5
+ earns, and inspects HTTP and code-health rules. Application runtime packages can
6
+ operate without it.
7
7
 
8
8
  ## What Dad does for you
9
9
 
@@ -13,33 +13,29 @@ declarations, so the answer does not change with who is asking.
13
13
 
14
14
  ## Try it
15
15
 
16
- With Node 24 and Docker Compose running, create an app with the Toolbox
17
- installed. For a Toolbox-only installation in an existing project, run
18
- `npm install --save-dev @dads-framework/toolbox`.
16
+ From a Dads application such as the generated starter, install the Toolbox
17
+ and ask which package owns the notes route.
19
18
 
20
19
  ```sh
21
- npm create dads@latest my-app
22
- cd my-app
20
+ npm install --save-dev @dads-framework/toolbox
23
21
  npx dad orient domains/notes/server/routes.ts --json
24
- npx dad doctor explain enmeshment
25
22
  ```
26
23
 
27
- The creator prints the assigned browser, customer API, and staff API URLs
28
- after the Docker stack responds. Run `npm start` to start the stack again.
29
- Use the generated README for local sign-in and verification and `DEPLOY.md`
30
- for hosting outside development.
24
+ The result contains `ok: true` and identifies the owner, its verification
25
+ commands, and the path to its README. Run `npx dad doctor explain enmeshment`
26
+ to see the explanation for that diagnostic.
31
27
 
32
- ```
33
- @dads-framework/toolbox
34
- Explains Dads ownership and runs deterministic agent workflows.
35
- Skill: dads-orient
36
- Verify: npm test -w @dads-framework/toolbox
37
- ```
28
+ To create a project that already includes the Toolbox, run
29
+ `npm create dads@0.3.0 my-app` with Node 24 and Docker Compose running.
38
30
 
39
31
  Dads is the framework; its packages live under `@dads-framework/*`, and `dad`
40
32
  is the executable this package exposes. `dad --help` (or `dad help`) prints the
41
33
  command index. Run `dad add --help` for the generator index.
42
34
 
35
+ Run the command from the generated app root. The starter’s
36
+ [`dads.project.json`](../../../apps/kit-workbench/dads.project.json) declares ownership and verification, and
37
+ [`domains/notes/server/routes.ts`](../../../apps/kit-workbench/domains/notes/server/routes.ts) is the file passed to `orient`.
38
+
43
39
  ## Commands
44
40
 
45
41
  Add `--json` to the documented command to emit machine-readable output. Without it, most commands print the same object
@@ -54,7 +50,7 @@ Applies the same idempotent recipes as `create-dads`. `--existing` writes an
54
50
  isolated project under `<path>/dads` beside an existing application,
55
51
  `--dry-run` previews the owned files, and `--skip-install` leaves dependency
56
52
  installation to another tool. Use `npm start` in the generated app to start
57
- Docker, or use `npm create dads@latest` to install and start a new app in
53
+ Docker, or use `npm create dads@0.3.0` to install and start a new app in
58
54
  one step.
59
55
 
60
56
  Generated projects include Git hooks, a shared CI shell job, and optional GitHub
@@ -68,6 +64,15 @@ Links `.cursor/skills`, `.claude/skills`, and `.codex/skills` at
68
64
  `../.agents/skills` so every harness reads one skill library. Each harness is
69
65
  reported as `created` or `correct`.
70
66
 
67
+ `dad migrate 0.3 [path] [--dry-run] [--json]`
68
+
69
+ Rewrites a `0.1.x` or `0.2.x` workspace to the consolidated `0.3.0` package
70
+ surface: updates every `package.json` (deduplicating merged packages and adding
71
+ any newly-optional peer providers the project already used), rewrites TypeScript,
72
+ JavaScript, CSS, and `tsconfig*.json` specifiers to their new subpaths, and
73
+ updates `dads.project.json` boundaries. Idempotent and safe to preview with
74
+ `--dry-run`.
75
+
71
76
  ### Orientation
72
77
 
73
78
  The `documentation` field in JSON points to the owning README or project
@@ -292,7 +297,10 @@ paths, custom roots, and a two-API example.
292
297
  ### Generators
293
298
 
294
299
  `dad add --help` lists the nine commands for domains, endpoints, tables,
295
- access, flags, email, pages, resources, and dependency libraries.
300
+ access, flags, email, pages, resources, and dependency libraries. In the
301
+ starter, preview a domain on the staff API with
302
+ `npx dad add domain inventory --api staff --dry-run --json`. The preview
303
+ lists the planned files and registration without editing the project.
296
304
  [Generator guide](../../../docs/generators.md)
297
305
 
298
306
  ### Dependency libraries
@@ -304,6 +312,43 @@ update workspace links and the lockfile. See the
304
312
  [dependency library guide](../../../docs/dependency-libraries.md) for the
305
313
  workflow from an owning repository to a consuming repository.
306
314
 
315
+ ### Access schemas
316
+
317
+ `dad access import <schema.zed> [--out <path>] [--dry-run] [--json]`
318
+
319
+ Reads a SpiceDB `.zed` schema file, parses it with `@dads-framework/access`,
320
+ and emits strict Dads TypeScript (`actor`, `resource`, `compileAccess`).
321
+ Without `--out` or `--json`, the generated TypeScript prints directly to stdout
322
+ so `npx dad access import schema.zed > access.ts` works out of the box. With
323
+ `--out <path>`, Dad creates parent directories and writes the file unless
324
+ `--dry-run` is set. Unsupported SpiceDB constructs such as `caveat` fail with a
325
+ line-numbered error and exit `1`.
326
+
327
+ `dad access tree <schema.ts|schema.zed> [--json]`
328
+
329
+ Loads a TypeScript/JavaScript access module (`.ts`, `.mts`, `.js`, `.mjs`)
330
+ exporting an `AccessModel` or `actor`/`resource` definitions, or a SpiceDB
331
+ `.zed` schema file, and renders the deterministic ASCII hierarchy tree showing
332
+ actors, resources, roles, permissions, and inherited children.
333
+
334
+ `dad access diff <before> <after> [--json]`
335
+
336
+ Loads both access sources (`.ts`, `.mts`, `.js`, `.mjs`, or `.zed`, including
337
+ mixing `.ts` and `.zed`) and compares resources, roles, subject types,
338
+ expiration flags, and computed permissions. Every change is classified as either
339
+ `safe` or `breaking` (`removed-resource`, `removed-role`, `narrowed-role`,
340
+ `removed-expiration`), with `requiresMigration` indicating whether stored
341
+ relationships must be migrated before writing the new schema.
342
+
343
+ `dad access migrate <slug> --from <before> --to <after> [--out <dir>] [--dry-run] [--json]`
344
+
345
+ Computes the schema diff between `<before>` and `<after>` (`.ts`, `.mts`,
346
+ `.js`, `.mjs`, or `.zed`), assigns the next sequential `NNNN_<slug>` identifier
347
+ in `--out` (defaulting to `./access/migrations`), and scaffolds a connected
348
+ `(from, to)` migration file using `defineAccessMigration` pre-populated with
349
+ typed `copyRole` / `dropRole` stubs and snapshot metadata. Pass `--dry-run` to
350
+ preview without writing. Run `dad access --help` for subcommand usage.
351
+
307
352
  ## Use it
308
353
 
309
354
  The package also exports the surface the CLI is built from, which is how
@@ -315,6 +360,10 @@ The package also exports the surface the CLI is built from, which is how
315
360
  - Orientation: `loadDadsProject`, `findDadsProjectRoot`, `parseDadsProject`,
316
361
  `orientProjectPath`, `recommendChangedVerification`,
317
362
  `synchronizeAgentSkills`.
363
+ - Access: `loadAccessSource`, `importZedSchema`, `renderAccessTree`,
364
+ `renderZedAccessTree`, `diffAccessSources`, `diffZedSchemas`,
365
+ `diffAccessIrDefinitions`, `scaffoldAccessMigrationFromSources`,
366
+ `scaffoldAccessMigration`, `DEFAULT_ACCESS_MIGRATIONS_DIR`.
318
367
 
319
368
  ## What it refuses to do
320
369
 
@@ -342,6 +391,14 @@ positional argument.
342
391
 
343
392
  A successful `--json` run prints one line beginning `{"ok":true,…}`. `init`
344
393
  reports `initialization` and `installed`. `add library` reports `result`.
394
+ `access import` reports `inputPath`, `outPath`, `definitionCount`,
395
+ `definitions`, `dryRun`, `written`, and `code`.
396
+ `access tree` reports `inputPath`, `definitionCount`, `definitions`, and
397
+ `tree`.
398
+ `access diff` reports `beforePath`, `afterPath`, `safe`, `breaking`,
399
+ `permissionChanges`, `requiresMigration`, and `summary`.
400
+ `access migrate` reports `id`, `slug`, `fromPath`, `toPath`, `outDir`,
401
+ `filePath`, `dryRun`, `written`, `requiresMigration`, `diff`, and `code`.
345
402
  `test:recommend` prints `changedScope`, `recommendation`, and `notApplicable`;
346
403
  `verify` prints those plus `report`. A failure prints
347
404
  `{"ok":false,"error":"<message>"}` on stderr and exits `1`; without `--json`
@@ -359,25 +416,31 @@ followed by
359
416
 
360
417
  Errors, and when each happens:
361
418
 
362
- | Message | When |
363
- | --------------------------------------------------------------------------- | ------------------------------------------------------- |
364
- | `Could not find dads.project.json from <path>.` | No Dads project above the working directory |
365
- | `orient requires a project-relative path.` | `orient` or `explain` with no path |
366
- | `No declared package owns <path>.` | `orient`, `explain`, on an unowned path |
367
- | `inspect requires http-operation "<METHOD /path>".` | A malformed `inspect` invocation |
368
- | `--profile must be standard or strict.` | `doctor` with any other profile |
369
- | `No daddy issue is named <id>.` | `doctor --issue` or `doctor explain` with an unknown id |
370
- | `--today must be a date written YYYY-MM-DD.` | `doctor --today` with anything else |
371
- | `doctor takes at most one path.` / `doctor explain requires an issue id.` | A malformed `doctor` invocation |
372
- | `No literal HTTP operation named <name> was found.` | `inspect` matched nothing |
373
- | `Refusing to initialize non-empty directory <path>. …` | `init` target holds files and no `dads.project.json` |
374
- | `Refusing to overwrite conflicting file <path>.` | An owned file exists with different content |
375
- | `Unknown option <option>.` / `Option <option> was provided more than once.` | A bad `init` argument list |
376
- | `<option> requires a value.` / `<option> may only be provided once.` | A value option given wrongly |
377
- | `Invalid verification base <ref>.` | `--base` names no commit |
378
- | `Unable to read the changed git scope[: <detail>]` | Git could not report the changed paths |
379
- | `Refusing to replace existing package script <name>. …` | A recipe script name is already taken |
380
- | `npm install failed[: <detail>]` | Dependency installation failed |
419
+ | Message | When |
420
+ | ------------------------------------------------------------------------------ | ------------------------------------------------------- |
421
+ | `Could not find dads.project.json from <path>.` | No Dads project above the working directory |
422
+ | `orient requires a project-relative path.` | `orient` or `explain` with no path |
423
+ | `No declared package owns <path>.` | `orient`, `explain`, on an unowned path |
424
+ | `inspect requires http-operation "<METHOD /path>".` | A malformed `inspect` invocation |
425
+ | `--profile must be standard or strict.` | `doctor` with any other profile |
426
+ | `No daddy issue is named <id>.` | `doctor --issue` or `doctor explain` with an unknown id |
427
+ | `--today must be a date written YYYY-MM-DD.` | `doctor --today` with anything else |
428
+ | `doctor takes at most one path.` / `doctor explain requires an issue id.` | A malformed `doctor` invocation |
429
+ | `No literal HTTP operation named <name> was found.` | `inspect` matched nothing |
430
+ | `Refusing to initialize non-empty directory <path>. …` | `init` target holds files and no `dads.project.json` |
431
+ | `Refusing to overwrite conflicting file <path>.` | An owned file exists with different content |
432
+ | `Unknown option <option>.` / `Option <option> was provided more than once.` | A bad `init` argument list |
433
+ | `<option> requires a value.` / `<option> may only be provided once.` | A value option given wrongly |
434
+ | `Invalid verification base <ref>.` | `--base` names no commit |
435
+ | `Unable to read the changed git scope[: <detail>]` | Git could not report the changed paths |
436
+ | `Refusing to replace existing package script <name>. …` | A recipe script name is already taken |
437
+ | `access import requires a path to a .zed schema file.` | `access import` with no schema path |
438
+ | `access tree requires a path to a .ts or .zed access file.` | `access tree` with no schema path |
439
+ | `access diff requires <before> and <after> schema file paths (.ts or .zed).` | `access diff` with fewer than two schema paths |
440
+ | `access migrate requires a migration slug.` | `access migrate` with no slug |
441
+ | `access migrate requires --from <before>.` / `--to <after>.` | `access migrate` missing `--from` or `--to` |
442
+ | `Zed schema file not found: <path>.` / `Access schema file not found: <path>.` | `access` command with a missing schema file |
443
+ | `npm install failed[: <detail>]` | Dependency installation failed |
381
444
 
382
445
  The package requires Node.js 22 or newer.
383
446
 
package/bin/dad-dev.js ADDED
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env node
2
+ import process from "node:process";
3
+ import { runDevCommand } from "../dist/dev/cli.js";
4
+
5
+ try {
6
+ process.stdout.write(await runDevCommand(process.argv.slice(2)));
7
+ } catch (error) {
8
+ process.stderr.write(
9
+ `dad-dev: ${error instanceof Error ? error.message : "command failed"}\n`,
10
+ );
11
+ process.exitCode = 1;
12
+ }
package/bin/usage.js CHANGED
@@ -3,11 +3,22 @@ const addCommands = [
3
3
  " add domain|endpoint|table|access|flag|email|page|resource <name> [--domain <name>] [--api <name>] [--dry-run] [--json]",
4
4
  ];
5
5
 
6
+ const accessCommands = [
7
+ " access import <schema.zed> [--out <path>] [--dry-run] [--json]",
8
+ " access tree <schema.ts|schema.zed> [--json]",
9
+ " access diff <before> <after> [--json]",
10
+ " access migrate <slug> --from <before> --to <after> [--out <dir>] [--dry-run] [--json]",
11
+ ];
12
+
13
+ const accessSubcommands = new Set(["import", "tree", "diff", "migrate"]);
14
+
6
15
  export const usage = [
7
16
  "Usage: dad <command>",
8
- " init <path> [--existing] [--name <name>] [--dry-run] [--skip-install] [--json]",
17
+ " init <path> [--existing] [--name <name>] [--template minimal|example] [--dry-run] [--skip-install] [--json]",
9
18
  ...addCommands,
10
19
  " add --help",
20
+ ...accessCommands,
21
+ " access --help",
11
22
  " orient|explain <path> [--json]",
12
23
  ' inspect http-operation "<METHOD /path>" [--json]',
13
24
  " check boundaries [--json]",
@@ -18,20 +29,39 @@ export const usage = [
18
29
  " test plan|run|explain|init [--manifest path] [--base ref] [--head ref] [--all] [--task id] [--jobs n] [--report [path]] [--force] --json",
19
30
  " test:recommend --changed [--base <ref>] [--json]",
20
31
  " verify --changed [--base <ref>] [--full] [--no-cache] [--json]",
32
+ " migrate 0.3 [path] [--dry-run] [--json]",
21
33
  " skills:sync [--json]",
22
34
  "",
23
35
  "Examples",
24
36
  " dad init ./catalog",
37
+ " dad init ./catalog --template minimal",
25
38
  " dad add resource products --api customer --dry-run",
39
+ " dad access import schema.zed --out src/access.ts",
40
+ " dad access tree src/access.ts",
41
+ " dad access diff before.ts after.ts",
42
+ " dad access migrate rename_editor --from before.ts --to after.ts",
26
43
  " dad orient domains/products/index.ts --json",
27
44
  ].join("\n");
28
45
 
29
46
  const addUsage = ["Usage: dad add <generator>", ...addCommands].join("\n");
47
+ const accessUsage = ["Usage: dad access <subcommand>", ...accessCommands].join(
48
+ "\n",
49
+ );
50
+
51
+ function isHelpFlag(argument) {
52
+ return argument === "--help" || argument === "-h";
53
+ }
30
54
 
31
55
  export function helpFor(args) {
32
- const [command, subject] = args;
56
+ const [command, subject, detail] = args;
33
57
  if (command === "--help" || command === "help") return usage;
34
- if (command === "add" && (subject === "--help" || subject === "-h"))
35
- return addUsage;
58
+ if (command === "add" && isHelpFlag(subject)) return addUsage;
59
+ if (command === "access" && isHelpFlag(subject)) return accessUsage;
60
+ if (
61
+ command === "access" &&
62
+ accessSubcommands.has(subject) &&
63
+ isHelpFlag(detail)
64
+ )
65
+ return accessUsage;
36
66
  return undefined;
37
67
  }
@@ -0,0 +1,16 @@
1
+ /** Formatting and canonicalization helpers for `dad access diff`. */
2
+ import type { AccessIrSubject, AccessIrTerm } from "@dads-framework/access";
3
+ import type { AccessDiffBreakingChange, AccessDiffSafeChange, AccessPermissionChangeSummary, AccessSchemaDiff } from "./access-diff-types.js";
4
+ export type AccessDiffSummaryCounts = {
5
+ readonly safe: readonly AccessDiffSafeChange[];
6
+ readonly breaking: readonly AccessDiffBreakingChange[];
7
+ readonly permissionChanges: readonly AccessPermissionChangeSummary[];
8
+ };
9
+ export declare function formatBaseSubject(subject: AccessIrSubject): string;
10
+ export declare function formatPermissionExpression(terms: readonly AccessIrTerm[]): string;
11
+ export declare function canonicalPermissionKey(terms: readonly AccessIrTerm[]): string;
12
+ export declare function formatAccessDiffSummary(counts: AccessDiffSummaryCounts, requiresMigration: boolean): string;
13
+ export declare function formatBreakingChange(change: AccessDiffBreakingChange): string;
14
+ export declare function formatSafeChange(change: AccessDiffSafeChange): string;
15
+ export declare function formatAccessDiffReport(diff: AccessSchemaDiff): string;
16
+ //# sourceMappingURL=access-diff-format.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"access-diff-format.d.ts","sourceRoot":"","sources":["../src/access-diff-format.ts"],"names":[],"mappings":"AAAA,qEAAqE;AAErE,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC5E,OAAO,KAAK,EACV,wBAAwB,EACxB,oBAAoB,EACpB,6BAA6B,EAC7B,gBAAgB,EACjB,MAAM,wBAAwB,CAAC;AAEhC,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,CAAC,IAAI,EAAE,SAAS,oBAAoB,EAAE,CAAC;IAC/C,QAAQ,CAAC,QAAQ,EAAE,SAAS,wBAAwB,EAAE,CAAC;IACvD,QAAQ,CAAC,iBAAiB,EAAE,SAAS,6BAA6B,EAAE,CAAC;CACtE,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,eAAe,GAAG,MAAM,CAIlE;AAED,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,SAAS,YAAY,EAAE,GAC7B,MAAM,CAER;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,SAAS,YAAY,EAAE,GAAG,MAAM,CAE7E;AAED,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,uBAAuB,EAC/B,iBAAiB,EAAE,OAAO,GACzB,MAAM,CAkBR;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,wBAAwB,GAAG,MAAM,CAW7E;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,oBAAoB,GAAG,MAAM,CAiBrE;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,gBAAgB,GAAG,MAAM,CAkBrE"}
@@ -0,0 +1,119 @@
1
+ /** Formatting and canonicalization helpers for `dad access diff`. */
2
+ export function formatBaseSubject(subject) {
3
+ if (subject.kind === "type")
4
+ return subject.wireName;
5
+ if (subject.kind === "wildcard")
6
+ return `${subject.wireName}:*`;
7
+ return `${subject.wireName}#${subject.relation}`;
8
+ }
9
+ export function formatPermissionExpression(terms) {
10
+ return terms.map(formatTerm).join(" + ");
11
+ }
12
+ export function canonicalPermissionKey(terms) {
13
+ return terms.map(canonicalTermKey).sort().join(" | ");
14
+ }
15
+ export function formatAccessDiffSummary(counts, requiresMigration) {
16
+ if (counts.safe.length === 0 && counts.breaking.length === 0) {
17
+ return "No access schema changes.";
18
+ }
19
+ const parts = [];
20
+ if (counts.breaking.length > 0) {
21
+ parts.push(`${counts.breaking.length} breaking change(s): ${counts.breaking.map(formatBreakingChange).join(", ")}`);
22
+ }
23
+ if (counts.safe.length > 0) {
24
+ parts.push(`${counts.safe.length} safe change(s)`);
25
+ }
26
+ if (counts.permissionChanges.length > 0) {
27
+ parts.push(`${counts.permissionChanges.length} permission update(s)`);
28
+ }
29
+ const prefix = requiresMigration ? "Migration required" : "Safe change";
30
+ return `${prefix}: ${parts.join("; ")}.`;
31
+ }
32
+ export function formatBreakingChange(change) {
33
+ switch (change.kind) {
34
+ case "removed-resource":
35
+ return `removed resource ${change.resource}`;
36
+ case "removed-role":
37
+ return `removed role ${change.resource}#${change.role}`;
38
+ case "narrowed-role":
39
+ return `narrowed ${change.resource}#${change.role} (removed ${change.subject})`;
40
+ case "removed-expiration":
41
+ return `removed expiration on ${change.resource}#${change.role} (${change.subject})`;
42
+ }
43
+ }
44
+ export function formatSafeChange(change) {
45
+ switch (change.kind) {
46
+ case "added-resource":
47
+ return `added resource ${change.resource}`;
48
+ case "added-role":
49
+ return `added role ${change.resource}#${change.role}`;
50
+ case "widened-role":
51
+ return `widened ${change.resource}#${change.role} (added ${change.subject})`;
52
+ case "added-expiration":
53
+ return `added expiration on ${change.resource}#${change.role} (${change.subject})`;
54
+ case "added-permission":
55
+ return `added permission ${change.resource}#${change.permission} = ${change.expression}`;
56
+ case "modified-permission":
57
+ return `modified permission ${change.resource}#${change.permission}: ${change.before} -> ${change.after}`;
58
+ case "removed-permission":
59
+ return `removed permission ${change.resource}#${change.permission} (was ${change.before})`;
60
+ }
61
+ }
62
+ export function formatAccessDiffReport(diff) {
63
+ const lines = [
64
+ diff.summary,
65
+ `requiresMigration: ${diff.requiresMigration ? "true" : "false"}`,
66
+ ];
67
+ if (diff.breaking.length > 0) {
68
+ lines.push("Breaking changes:");
69
+ for (const entry of diff.breaking) {
70
+ lines.push(` - [${entry.kind}] ${formatBreakingChange(entry)}`);
71
+ }
72
+ }
73
+ if (diff.safe.length > 0) {
74
+ lines.push("Safe changes:");
75
+ for (const entry of diff.safe) {
76
+ lines.push(` - [${entry.kind}] ${formatSafeChange(entry)}`);
77
+ }
78
+ }
79
+ return `${lines.join("\n")}\n`;
80
+ }
81
+ function formatTerm(term) {
82
+ switch (term.kind) {
83
+ case "role":
84
+ case "permission":
85
+ return term.name;
86
+ case "through":
87
+ return `${term.roleName}->${term.targetPermission}`;
88
+ case "through-all":
89
+ return `${term.roleName}.all(${term.targetPermission})`;
90
+ case "gated":
91
+ return `(${formatTerm(term.term)} & ${formatTerm(term.condition)})`;
92
+ case "both":
93
+ return `(${formatTerm(term.left)} & ${formatTerm(term.right)})`;
94
+ case "excluding":
95
+ return `(${formatTerm(term.term)} - ${formatTerm(term.banned)})`;
96
+ case "or":
97
+ return `(${term.terms.map(formatTerm).join(" + ")})`;
98
+ }
99
+ }
100
+ function canonicalTermKey(term) {
101
+ switch (term.kind) {
102
+ case "role":
103
+ case "permission":
104
+ return `ref:${term.name}`;
105
+ case "through":
106
+ return `through:${term.roleName}->${term.targetPermission}`;
107
+ case "through-all":
108
+ return `through-all:${term.roleName}.all(${term.targetPermission})`;
109
+ case "gated":
110
+ return `both:(${canonicalTermKey(term.term)}&${canonicalTermKey(term.condition)})`;
111
+ case "both":
112
+ return `both:(${canonicalTermKey(term.left)}&${canonicalTermKey(term.right)})`;
113
+ case "excluding":
114
+ return `excluding:(${canonicalTermKey(term.term)}-${canonicalTermKey(term.banned)})`;
115
+ case "or":
116
+ return `or:(${term.terms.map(canonicalTermKey).sort().join("+")})`;
117
+ }
118
+ }
119
+ //# sourceMappingURL=access-diff-format.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"access-diff-format.js","sourceRoot":"","sources":["../src/access-diff-format.ts"],"names":[],"mappings":"AAAA,qEAAqE;AAgBrE,MAAM,UAAU,iBAAiB,CAAC,OAAwB;IACxD,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM;QAAE,OAAO,OAAO,CAAC,QAAQ,CAAC;IACrD,IAAI,OAAO,CAAC,IAAI,KAAK,UAAU;QAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,IAAI,CAAC;IAChE,OAAO,GAAG,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;AACn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AS,CAAC,GAAG,CAAC;QACrF,KAAK,MAAM;YACT,OAAO,SAAS,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC;QACjF,KAAK,WAAW;YACd,OAAO,cAAc,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC;QACvF,KAAK,IAAI;YACP,OAAO,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;IACvE,CAAC;AACH,CAAC"}
@@ -0,0 +1,79 @@
1
+ /** Type definitions for pure-IR `.zed` schema diffing. */
2
+ export type AccessDiffSafeChange = {
3
+ readonly kind: "added-resource";
4
+ readonly resource: string;
5
+ } | {
6
+ readonly kind: "added-role";
7
+ readonly resource: string;
8
+ readonly role: string;
9
+ } | {
10
+ readonly kind: "widened-role";
11
+ readonly resource: string;
12
+ readonly role: string;
13
+ readonly subject: string;
14
+ } | {
15
+ readonly kind: "added-expiration";
16
+ readonly resource: string;
17
+ readonly role: string;
18
+ readonly subject: string;
19
+ } | {
20
+ readonly kind: "added-permission";
21
+ readonly resource: string;
22
+ readonly permission: string;
23
+ readonly expression: string;
24
+ } | {
25
+ readonly kind: "modified-permission";
26
+ readonly resource: string;
27
+ readonly permission: string;
28
+ readonly before: string;
29
+ readonly after: string;
30
+ } | {
31
+ readonly kind: "removed-permission";
32
+ readonly resource: string;
33
+ readonly permission: string;
34
+ readonly before: string;
35
+ };
36
+ export type AccessDiffBreakingChange = {
37
+ readonly kind: "removed-resource";
38
+ readonly resource: string;
39
+ } | {
40
+ readonly kind: "removed-role";
41
+ readonly resource: string;
42
+ readonly role: string;
43
+ } | {
44
+ readonly kind: "narrowed-role";
45
+ readonly resource: string;
46
+ readonly role: string;
47
+ readonly subject: string;
48
+ } | {
49
+ readonly kind: "removed-expiration";
50
+ readonly resource: string;
51
+ readonly role: string;
52
+ readonly subject: string;
53
+ };
54
+ export type AccessPermissionChangeSummary = {
55
+ readonly kind: "added" | "modified" | "removed";
56
+ readonly resource: string;
57
+ readonly permission: string;
58
+ readonly before?: string;
59
+ readonly after?: string;
60
+ readonly description: string;
61
+ };
62
+ export type AccessSchemaDiff = {
63
+ readonly safe: readonly AccessDiffSafeChange[];
64
+ readonly breaking: readonly AccessDiffBreakingChange[];
65
+ readonly permissionChanges: readonly AccessPermissionChangeSummary[];
66
+ readonly requiresMigration: boolean;
67
+ readonly summary: string;
68
+ };
69
+ export type DiffZedSchemasOptions = {
70
+ readonly beforePath: string;
71
+ readonly afterPath: string;
72
+ readonly cwd?: string;
73
+ };
74
+ export type ZedSchemaDiffResult = {
75
+ readonly beforePath: string;
76
+ readonly afterPath: string;
77
+ readonly diff: AccessSchemaDiff;
78
+ };
79
+ //# sourceMappingURL=access-diff-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"access-diff-types.d.ts","sourceRoot":"","sources":["../src/access-diff-types.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAE1D,MAAM,MAAM,oBAAoB,GAC5B;IAAE,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAC9D;IACE,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,kBAAk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
1
+ /** Type definitions for pure-IR `.zed` schema diffing. */
2
+ export {};
3
+ //# sourceMappingURL=access-diff-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"access-diff-types.js","sourceRoot":"","sources":["../src/access-diff-types.ts"],"names":[],"mappings":"AAAA,0DAA0D"}
@@ -0,0 +1,21 @@
1
+ /** Pure-IR schema diffing for SpiceDB `.zed` schemas. */
2
+ import { type AccessIrDefinition } from "@dads-framework/access";
3
+ import type { AccessSchemaDiff, DiffZedSchemasOptions, ZedSchemaDiffResult } from "./access-diff-types.js";
4
+ export type { AccessDiffBreakingChange, AccessDiffSafeChange, AccessPermissionChangeSummary, AccessSchemaDiff, DiffZedSchemasOptions, ZedSchemaDiffResult, } from "./access-diff-types.js";
5
+ /**
6
+ * Load two access sources (`.ts`, `.mts`, `.js`, `.mjs`, or `.zed`), emit
7
+ * their access IR, and classify every change into safe additions/permission
8
+ * edits vs breaking removals.
9
+ */
10
+ export declare function diffAccessSources(options: DiffZedSchemasOptions): Promise<ZedSchemaDiffResult>;
11
+ /**
12
+ * Read two `.zed` schema files, parse them into Dads access IR, and classify
13
+ * every change into safe additions/permission edits vs breaking removals.
14
+ */
15
+ export declare function diffZedSchemas(options: DiffZedSchemasOptions): ZedSchemaDiffResult;
16
+ /**
17
+ * Compare two access IR definition lists and classify every resource, role,
18
+ * subject, expiration, and permission change into safe vs breaking.
19
+ */
20
+ export declare function diffAccessIrDefinitions(before: readonly AccessIrDefinition[], after: readonly AccessIrDefinition[]): AccessSchemaDiff;
21
+ //# sourceMappingURL=access-diff.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"access-diff.d.ts","sourceRoot":"","sources":["../src/access-diff.ts"],"names":[],"mappings":"AAAA,yDAAyD;AAGzD,OAAO,EAEL,KAAK,kBAAkB,EAIxB,MAAM,wBAAwB,CAAC;AAOhC,OAAO,KAAK,EAIV,gBAAgB,EAChB,qBAAqB,EACrB,mBAAmB,EACpB,MAAM,wBAAwB,CAAC;AAIhC,YAAY,EACV,wBAAwB,EACxB,oBAAoB,EACpB,6BAA6B,EAC7B,gBAAgB,EAChB,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,wBAAwB,CAAC;AAQhC;;;;GAIG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,mBAAmB,CAAC,CAU9B;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,qBAAqB,GAC7B,mBAAmB,CASrB;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,SAAS,kBAAkB,EAAE,EACrC,KAAK,EAAE,SAAS,kBAAkB,EAAE,GACnC,gBAAgB,CA0BlB"}