@shivaedev/quality 0.57.1 → 0.59.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +34 -0
- package/README.md +19 -6
- package/dist/adapters/ImportAnalysisFailure.d.ts +10 -0
- package/dist/adapters/ImportAnalysisFailure.d.ts.map +1 -0
- package/dist/adapters/ImportAnalysisFailure.js +4 -0
- package/dist/adapters/ImportAnalysisFailure.js.map +1 -0
- package/dist/adapters/ImportCompiler.d.ts +2 -13
- package/dist/adapters/ImportCompiler.d.ts.map +1 -1
- package/dist/adapters/ImportCompiler.js +7 -13
- package/dist/adapters/ImportCompiler.js.map +1 -1
- package/dist/adapters/bodyReferences.d.ts +10 -0
- package/dist/adapters/bodyReferences.d.ts.map +1 -0
- package/dist/adapters/bodyReferences.js +125 -0
- package/dist/adapters/bodyReferences.js.map +1 -0
- package/dist/adapters/engineEscapes.d.ts +10 -0
- package/dist/adapters/engineEscapes.d.ts.map +1 -0
- package/dist/adapters/engineEscapes.js +103 -0
- package/dist/adapters/engineEscapes.js.map +1 -0
- package/dist/adapters/imports/analysisFailure.d.ts +3 -0
- package/dist/adapters/imports/analysisFailure.d.ts.map +1 -0
- package/dist/adapters/imports/analysisFailure.js +5 -0
- package/dist/adapters/imports/analysisFailure.js.map +1 -0
- package/dist/adapters/imports/analyzeDepartures.d.ts +5 -0
- package/dist/adapters/imports/analyzeDepartures.d.ts.map +1 -0
- package/dist/adapters/imports/analyzeDepartures.js +5 -0
- package/dist/adapters/imports/analyzeDepartures.js.map +1 -0
- package/dist/adapters/imports/analyzeGraph.d.ts +4 -0
- package/dist/adapters/imports/analyzeGraph.d.ts.map +1 -0
- package/dist/adapters/imports/analyzeGraph.js +6 -0
- package/dist/adapters/imports/analyzeGraph.js.map +1 -0
- package/dist/adapters/imports/checkBrowser.d.ts +4 -0
- package/dist/adapters/imports/checkBrowser.d.ts.map +1 -0
- package/dist/adapters/imports/checkBrowser.js +4 -0
- package/dist/adapters/imports/checkBrowser.js.map +1 -0
- package/dist/adapters/indirectServiceReferences.d.ts +3 -0
- package/dist/adapters/indirectServiceReferences.d.ts.map +1 -0
- package/dist/adapters/indirectServiceReferences.js +19 -0
- package/dist/adapters/indirectServiceReferences.js.map +1 -0
- package/dist/adapters/knip/entryPointFindings.d.ts +1 -1
- package/dist/adapters/knip/entryPointFindings.d.ts.map +1 -1
- package/dist/adapters/nativeTransactionFindings.d.ts +4 -0
- package/dist/adapters/nativeTransactionFindings.d.ts.map +1 -0
- package/dist/adapters/nativeTransactionFindings.js +98 -0
- package/dist/adapters/nativeTransactionFindings.js.map +1 -0
- package/dist/adapters/outcomeAssertions.d.ts +9 -0
- package/dist/adapters/outcomeAssertions.d.ts.map +1 -0
- package/dist/adapters/outcomeAssertions.js +94 -0
- package/dist/adapters/outcomeAssertions.js.map +1 -0
- package/dist/adapters/outsideImportFindings.d.ts +1 -1
- package/dist/adapters/outsideImportFindings.d.ts.map +1 -1
- package/dist/adapters/positiveRefusalFindings.d.ts +4 -0
- package/dist/adapters/positiveRefusalFindings.d.ts.map +1 -0
- package/dist/adapters/positiveRefusalFindings.js +41 -0
- package/dist/adapters/positiveRefusalFindings.js.map +1 -0
- package/dist/adapters/queueReadoutFindings.d.ts +1 -1
- package/dist/adapters/queueReadoutFindings.d.ts.map +1 -1
- package/dist/adapters/rpcBoundaryFindings.d.ts +4 -0
- package/dist/adapters/rpcBoundaryFindings.d.ts.map +1 -0
- package/dist/adapters/rpcBoundaryFindings.js +90 -0
- package/dist/adapters/rpcBoundaryFindings.js.map +1 -0
- package/dist/adapters/serviceAccess.d.ts +4 -0
- package/dist/adapters/serviceAccess.d.ts.map +1 -0
- package/dist/adapters/serviceAccess.js +33 -0
- package/dist/adapters/serviceAccess.js.map +1 -0
- package/dist/adapters/serviceAssemblyImports.d.ts +10 -0
- package/dist/adapters/serviceAssemblyImports.d.ts.map +1 -0
- package/dist/adapters/serviceAssemblyImports.js +71 -0
- package/dist/adapters/serviceAssemblyImports.js.map +1 -0
- package/dist/adapters/serviceAssemblySyntax.d.ts +10 -0
- package/dist/adapters/serviceAssemblySyntax.d.ts.map +1 -0
- package/dist/adapters/serviceAssemblySyntax.js +105 -0
- package/dist/adapters/serviceAssemblySyntax.js.map +1 -0
- package/dist/adapters/serviceDefinitionProblems.d.ts +7 -0
- package/dist/adapters/serviceDefinitionProblems.d.ts.map +1 -0
- package/dist/adapters/serviceDefinitionProblems.js +43 -0
- package/dist/adapters/serviceDefinitionProblems.js.map +1 -0
- package/dist/adapters/serviceIdFindings.d.ts.map +1 -1
- package/dist/adapters/serviceIdFindings.js +12 -7
- package/dist/adapters/serviceIdFindings.js.map +1 -1
- package/dist/adapters/transactionChanges.d.ts +3 -0
- package/dist/adapters/transactionChanges.d.ts.map +1 -0
- package/dist/adapters/transactionChanges.js +81 -0
- package/dist/adapters/transactionChanges.js.map +1 -0
- package/dist/adapters/vitePort.d.ts +2 -0
- package/dist/adapters/vitePort.d.ts.map +1 -0
- package/dist/adapters/vitePort.js +5 -0
- package/dist/adapters/vitePort.js.map +1 -0
- package/dist/appViteConfig.d.ts +4 -1
- package/dist/appViteConfig.d.ts.map +1 -1
- package/dist/appViteConfig.js +7 -3
- package/dist/appViteConfig.js.map +1 -1
- package/dist/imports/departures.d.ts +1 -1
- package/dist/imports/departures.d.ts.map +1 -1
- package/dist/imports/fences/check.d.ts +1 -1
- package/dist/imports/fences/check.d.ts.map +1 -1
- package/dist/imports/graph.d.ts +1 -1
- package/dist/imports/graph.d.ts.map +1 -1
- package/dist/rules/builtIn.d.ts +2 -2
- package/dist/rules/builtIn.d.ts.map +1 -1
- package/dist/rules/builtIn.js +8 -0
- package/dist/rules/builtIn.js.map +1 -1
- package/dist/rules/effect/rpcBoundary.d.ts +2 -0
- package/dist/rules/effect/rpcBoundary.d.ts.map +1 -0
- package/dist/rules/effect/rpcBoundary.js +9 -0
- package/dist/rules/effect/rpcBoundary.js.map +1 -0
- package/dist/rules/effect/serviceCatalog.d.ts +1 -1
- package/dist/rules/effect/serviceCatalog.d.ts.map +1 -1
- package/dist/rules/effect/serviceCatalog.js +4 -2
- package/dist/rules/effect/serviceCatalog.js.map +1 -1
- package/dist/rules/effect/serviceDefinitionAssembly.d.ts +2 -0
- package/dist/rules/effect/serviceDefinitionAssembly.d.ts.map +1 -0
- package/dist/rules/effect/serviceDefinitionAssembly.js +43 -0
- package/dist/rules/effect/serviceDefinitionAssembly.js.map +1 -0
- package/dist/rules/effect/serviceIds.js +1 -1
- package/dist/rules/effect/serviceIds.js.map +1 -1
- package/dist/rules/effect/serviceParameters.d.ts.map +1 -1
- package/dist/rules/effect/serviceParameters.js +12 -6
- package/dist/rules/effect/serviceParameters.js.map +1 -1
- package/dist/rules/effect/sqlTransact.d.ts +2 -0
- package/dist/rules/effect/sqlTransact.d.ts.map +1 -0
- package/dist/rules/effect/sqlTransact.js +9 -0
- package/dist/rules/effect/sqlTransact.js.map +1 -0
- package/dist/rules/stories/engine.d.ts.map +1 -1
- package/dist/rules/stories/engine.js +24 -7
- package/dist/rules/stories/engine.js.map +1 -1
- package/dist/rules/stories/positiveRefusals.d.ts +2 -0
- package/dist/rules/stories/positiveRefusals.d.ts.map +1 -0
- package/dist/rules/stories/positiveRefusals.js +17 -0
- package/dist/rules/stories/positiveRefusals.js.map +1 -0
- package/dist/rules/stories/sources.d.ts +1 -1
- package/dist/rules/stories/sources.d.ts.map +1 -1
- package/dist/rules/stories/usesInputs.d.ts.map +1 -1
- package/dist/rules/stories/usesInputs.js +3 -2
- package/dist/rules/stories/usesInputs.js.map +1 -1
- package/dist/testing/adapters/cli.d.ts +2 -2
- package/dist/testing/adapters/cli.d.ts.map +1 -1
- package/dist/testing/adapters/cli.js +11 -14
- package/dist/testing/adapters/cli.js.map +1 -1
- package/dist/testing/adapters/git.d.ts +10 -0
- package/dist/testing/adapters/git.d.ts.map +1 -1
- package/dist/testing/adapters/git.js +6 -2
- package/dist/testing/adapters/git.js.map +1 -1
- package/dist/testing/adapters/hookRepository.d.ts.map +1 -1
- package/dist/testing/adapters/hookRepository.js +6 -2
- package/dist/testing/adapters/hookRepository.js.map +1 -1
- package/dist/testing/ruleStory.d.ts.map +1 -1
- package/dist/testing/ruleStory.js +1 -2
- package/dist/testing/ruleStory.js.map +1 -1
- package/package.json +6 -6
- package/src/adapters/ImportAnalysisFailure.ts +6 -0
- package/src/adapters/ImportCompiler.ts +7 -20
- package/src/adapters/bodyReferences.ts +141 -0
- package/src/adapters/engineEscapes.ts +119 -0
- package/src/adapters/imports/analysisFailure.ts +5 -0
- package/src/adapters/imports/analyzeDepartures.ts +9 -0
- package/src/adapters/imports/analyzeGraph.ts +9 -0
- package/src/adapters/imports/checkBrowser.ts +5 -0
- package/src/adapters/indirectServiceReferences.ts +25 -0
- package/src/adapters/nativeTransactionFindings.ts +108 -0
- package/src/adapters/outcomeAssertions.ts +110 -0
- package/src/adapters/outsideImportFindings.ts +1 -1
- package/src/adapters/positiveRefusalFindings.ts +52 -0
- package/src/adapters/rpcBoundaryFindings.ts +98 -0
- package/src/adapters/serviceAccess.ts +38 -0
- package/src/adapters/serviceAssemblyImports.ts +93 -0
- package/src/adapters/serviceAssemblySyntax.ts +129 -0
- package/src/adapters/serviceDefinitionProblems.ts +63 -0
- package/src/adapters/serviceIdFindings.ts +16 -13
- package/src/adapters/transactionChanges.ts +85 -0
- package/src/adapters/vitePort.ts +5 -0
- package/src/appViteConfig.ts +13 -3
- package/src/rules/builtIn.ts +8 -0
- package/src/rules/effect/rpcBoundary.ts +10 -0
- package/src/rules/effect/serviceCatalog.ts +4 -2
- package/src/rules/effect/serviceDefinitionAssembly.ts +46 -0
- package/src/rules/effect/serviceIds.ts +1 -1
- package/src/rules/effect/serviceParameters.ts +12 -6
- package/src/rules/effect/sqlTransact.ts +10 -0
- package/src/rules/stories/engine.ts +25 -9
- package/src/rules/stories/positiveRefusals.ts +17 -0
- package/src/rules/stories/usesInputs.ts +3 -2
- package/src/testing/adapters/cli.ts +22 -14
- package/src/testing/adapters/git.ts +7 -2
- package/src/testing/adapters/hookRepository.ts +6 -2
- package/src/testing/ruleStory.ts +1 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.59.0 - 2026-11-04
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- `appViteConfig` accepts `{ webPort, apiPort }` as its fourth argument. Omitted ports read `VITE_PORT` and `PORT` respectively, falling back to 5173 and 3000.
|
|
8
|
+
- `tests/positive-refusals` reports negative-only `toBe` and `toEqual` checks on outcome readouts. Pair them with a positive domain reason or public response on the same outcome in the same story, including an `outcomes` row.
|
|
9
|
+
- Report `rpcBoundary` and `rpcBoundaryHandlers` outside modules that build native RPC handlers, keeping service failures typed until the handler edge.
|
|
10
|
+
- Enforce service definitions as operation inventories with imported initializers, operations and state factories, including marked generic methods.
|
|
11
|
+
|
|
12
|
+
### Breaking
|
|
13
|
+
|
|
14
|
+
- Import `ImportAnalysisFailure` from `@shivaedev/quality/adapters/ImportAnalysisFailure.ts` instead of `@shivaedev/quality/adapters/ImportCompiler.ts`.
|
|
15
|
+
|
|
16
|
+
## 0.58.0 - 2026-11-04
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
|
|
20
|
+
- Report native `sql.withTransaction` around repository writes or change announcements with `effect/sql-transact`, directing callers to begin the outer transaction with `transact(effect, { onSqlError })` before the unsupported composition runs. Native read-only and raw SQL transactions remain supported.
|
|
21
|
+
|
|
22
|
+
### Changed
|
|
23
|
+
|
|
24
|
+
- Quality fixtures use their own process lock for in-process commands, executable commands and git-hook checks.
|
|
25
|
+
|
|
26
|
+
### Breaking
|
|
27
|
+
|
|
28
|
+
- `runQuality` from `testing/adapters/cli.ts` returns an Effect that keeps the caller's clock and lifecycle. Replace `await runQuality(...)` and `Effect.promise(() => runQuality(...))` with `yield* runQuality(...)` inside an Effect. Quality story kits use the controlled test clock.
|
|
29
|
+
|
|
30
|
+
## 0.57.2 - 2026-11-03
|
|
31
|
+
|
|
32
|
+
### Fixed
|
|
33
|
+
|
|
34
|
+
- Read service-id prefixes and package ownership from workspace manifests, including nested consumer packages with their own npm scope.
|
|
35
|
+
- Discover service shapes in installed declarations from the consuming repository's package scopes as well as workspace sources.
|
|
36
|
+
|
|
3
37
|
## 0.57.1 - 2026-11-03
|
|
4
38
|
|
|
5
39
|
### Changed
|
package/README.md
CHANGED
|
@@ -66,7 +66,7 @@ ruleStory.it(
|
|
|
66
66
|
|
|
67
67
|
Seed a `quality.config.ts` that registers the custom rule to test the whole gate. `gate()` runs `quality lint`; `gateOutcome()` reads `passed`, `rejected` or `invalid`, and `gateReport()` reads its output. `writes(...)` changes fixture files and `removes(path)` deletes them. Use the kit’s `qualityInstalled()` trait when a fixture imports Quality or its tooling presets. It links the installed package into that fixture. The kit removes its temporary repository when the scope closes. Config imports are cached within the process, so use `quality` from `@shivaedev/quality/testing/adapters/cli.ts` to spawn a fresh command after changing a config.
|
|
68
68
|
|
|
69
|
-
For an existing kit, compose the lower-level helpers through its local test-support facade: `seedTree` and `removeSeededTrees` from `@shivaedev/quality/testing/adapters/tree.ts` manage fixture files; `scanned` and `findingsIn` from `@shivaedev/quality/testing/adapters/imports.ts` collect inventory and run a configured rule; `runQuality` from `@shivaedev/quality/testing/adapters/cli.ts` runs commands in process. These helpers use the same engine as the rule story kit.
|
|
69
|
+
For an existing kit, compose the lower-level helpers through its local test-support facade: `seedTree` and `removeSeededTrees` from `@shivaedev/quality/testing/adapters/tree.ts` manage fixture files; `scanned` and `findingsIn` from `@shivaedev/quality/testing/adapters/imports.ts` collect inventory and run a configured rule; `runQuality` from `@shivaedev/quality/testing/adapters/cli.ts` runs commands in process. Yield `runQuality(root, "lint")` as an Effect in the kit so it uses the story's controlled clock. These helpers use the same engine as the rule story kit.
|
|
70
70
|
|
|
71
71
|
### Effect boundaries and services
|
|
72
72
|
|
|
@@ -80,7 +80,7 @@ Only folders named `adapters/` or `test-support/`, at any depth, are exempt from
|
|
|
80
80
|
|
|
81
81
|
The `ambient-runtime` Biome plugin also reports `Effect.run*` calls whose computation contains `Clock`, `Config` or `Random`, `currentTimeMillisUnsafe`, crypto UUIDs and bytes, `performance.now`, process arguments, working directory and exit state, `globalThis.process.env`, timeouts and microtasks. Yield service computations in the caller's Effect so its environment controls them. These additional checks apply to core TypeScript code. They accept `cli.ts`, `main.ts(x)`, `entry.ts(x)`, `*-cli.ts`, modules that call `runMain`, use `NodeRuntime.runMain` or guard execution with `fileURLToPath(import.meta.url) === process.argv[1]`, tool configs, tests, `adapters/` and `test-support/`. The existing `Date.now()`, `new Date()`, `Math.random()`, console and direct `process.env` bans still apply there.
|
|
82
82
|
|
|
83
|
-
`effect/service-parameters` reports parameters carrying a service in exported functions and public methods, including returned factories. It follows service classes and tags, non-empty Contexts and service implementation shapes through aliases, interfaces, generic constraints, inferred parameters and destructuring. Read services from Effect's environment instead. An Effect or Stream requiring a service is a computation and is accepted. Methods implementing a service and functions constructing Layers may take services as parameters. Only `test-support/` folders are exempt from this rule; `adapters/` folders are checked.
|
|
83
|
+
`effect/service-parameters` reports parameters carrying a service in exported functions and public methods, including returned factories. It follows service classes and tags, non-empty Contexts and service implementation shapes through aliases, interfaces, generic constraints, inferred parameters and destructuring. Read services from Effect's environment instead. An Effect or Stream requiring a service is a computation and is accepted. Methods implementing a service and functions constructing Layers may take services as parameters. Only `test-support/` folders are exempt from this rule; `adapters/` folders are checked. Installed implementation shapes are discovered in the consuming repository's package scopes, alongside the framework service package's scope.
|
|
84
84
|
|
|
85
85
|
Both rules refuse config exceptions and inline suppressions. Record existing debt with `quality baseline write --rule effect/boundary --file src/legacy.ts` and `quality baseline write --rule effect/service-parameters --file src/legacy.ts`; the normal report and baseline burn-down apply.
|
|
86
86
|
|
|
@@ -88,9 +88,15 @@ When an upgrade expands these checks, inspect the new findings, repair the small
|
|
|
88
88
|
|
|
89
89
|
### Package service ids
|
|
90
90
|
|
|
91
|
-
`effect/service-ids` checks literal ids passed to `Context.Service`, `Context.Reference`, `defineService` and RPC middleware `Service` or `Tag` constructors in `packages
|
|
91
|
+
`effect/service-ids` checks literal ids passed to `Context.Service`, `Context.Reference`, `defineService` and RPC middleware `Service` or `Tag` constructors in workspace packages under `packages/`. Each id must start with the owning package manifest's `name`, including a trailing slash. The workspace declarations identify package folders, and the deepest matching folder owns a source file. For example, `packages/group/domain/package.json` named `@antumbra/domain` uses `@antumbra/domain/Store`. Prefix a reported id with its owning package and update any references to that id.
|
|
92
92
|
|
|
93
|
-
Import and local aliases, string literals and templates without substitutions are checked, including in adapters and tests. Computed ids and files outside `packages/` are left alone. This rule refuses config exceptions and inline suppressions.
|
|
93
|
+
Import and local aliases, string literals and templates without substitutions are checked, including in adapters and tests. Computed ids, files without a named workspace owner and files outside `packages/` are left alone. This rule refuses config exceptions and inline suppressions.
|
|
94
|
+
|
|
95
|
+
### Service assemblies
|
|
96
|
+
|
|
97
|
+
`effect/service-definition-assembly` keeps top-level `defineService` declarations as operation inventories. List `id`, `requires`, `initialize` and `methods` directly. Import a named initializer Effect or use `Effect.void`; the methods arrow returns a literal record of imported named operations or calls to imported state factories. `genericMethod` can wrap either form. Keep implementation bodies in focused files outside the assembly. Quality's existing Biome checks own `Effect.fn` span names.
|
|
98
|
+
|
|
99
|
+
The rule reports hidden configurations and method records, configuration and operation spreads, computed members, local implementations and inline bodies, including in adapters and tests. It takes no config exceptions or inline suppressions. See the [service guide](https://github.com/ShivaeDev/platform/tree/main/packages/service#1-assemble-the-service-from-focused-files) for the shape.
|
|
94
100
|
|
|
95
101
|
### Outside library imports
|
|
96
102
|
|
|
@@ -104,6 +110,10 @@ The rule refuses config exceptions and inline suppressions. For existing debt, r
|
|
|
104
110
|
|
|
105
111
|
`effect/shared-error-classes` reports a tagged error class that reuses a tag exported by `@shivaedev/errors`. Import the shared class from the module named in the finding instead. The rule reads exported class types, including source and declaration exports, and compares literal `_tag` values rather than class names. It uses the repository's installed errors package, or Quality's dependency when the repository does not yet depend on errors. It checks adapters and tests too. Subclasses retaining a shared tag are separate classes and are reported; shared declarations and imports, distinct tags and non-error classes are accepted.
|
|
106
112
|
|
|
113
|
+
### RPC handler boundaries
|
|
114
|
+
|
|
115
|
+
`effect/rpc-boundary` reports calls to `rpcBoundary` or `rpcBoundaryHandlers` outside modules that build native RPC handlers with a group's `toLayer`, `toLayerHandler`, `toHandlers` or `of`. Move the boundary to the handler module so services preserve their typed failures. Imported and local aliases are checked; unrelated functions and methods with the same names are accepted. Test-support kits and the implementation of `rpcBoundaryHandlers` are accepted. The rule refuses config exceptions and inline suppressions.
|
|
116
|
+
|
|
107
117
|
### Failure honesty
|
|
108
118
|
|
|
109
119
|
`effect/failure-honesty` checks TypeScript and JavaScript throughout the inventory, including adapters and tests. It reports four failure-hiding shapes:
|
|
@@ -247,7 +257,7 @@ Keep story kits and fixtures in `src/test-support` and keep each spec specific t
|
|
|
247
257
|
|
|
248
258
|
Quality's `tests/story-specs` rule reports a test file that declares tests without a kit's `it`, including plain Vitest `it` and `test` declarations mixed with stories. Typecheck tests are exempt, as are only the packages named `@shivaedev/test-story`, `@shivaedev/test` and `@shivaedev/types`, wherever they live in the workspace or at its root. Other dependencies of test-story, including development dependencies, remain checked.
|
|
249
259
|
|
|
250
|
-
Quality's `tests/story-engine` rule reports a kit story with no traits whose body never references its verbs, its story or its test context. Drive the engine through one of the kit's verbs or traits, or, if the code under test is pure, move it to `<stem>.unit.test.ts`, which reaches no engine and mocks nothing. The rule follows the same kit origins and prerequisite exemptions as `tests/story-specs`; unit and typecheck files are exempt.
|
|
260
|
+
Quality's `tests/story-engine` rule reports spec bodies that read raw service handles, reach through `story.engine`, or call production constructors to wire an engine outside the kit. It follows local aliases, destructuring and re-exported service tags inside the body, including nested callbacks. Move that access into verbs or traits in `test-support/` and keep expectations in the spec. A constructor can remain the subject of its colocated spec; native SQL handles used only for `withTransaction` can wrap kit verbs. Native Effect data constructors remain available. The rule also reports a kit story with no traits whose body never references its verbs, its story or its test context. Drive the engine through one of the kit's verbs or traits, or, if the code under test is pure, move it to `<stem>.unit.test.ts`, which reaches no engine and mocks nothing. The rule follows the same kit origins and prerequisite exemptions as `tests/story-specs`; unit and typecheck files are exempt.
|
|
251
261
|
|
|
252
262
|
`tests/global-retries` reports a `retry` option on a test, suite or kit story registration, including `retry: 0`. Remove the option: retries are global only and recorded by vitest-rerun so flakes stay visible. The rule follows registrar imports, aliases and modifiers, and options declared as literals, shared variables or spreads. Runner configuration and Effect retry schedules are accepted. It checks registrations throughout the inventory, including unit tests and test-support files, with no story prerequisite exemptions.
|
|
253
263
|
|
|
@@ -263,6 +273,8 @@ Specs keep expectations visible. `tests/spec-helpers` moves all module-level hel
|
|
|
263
273
|
|
|
264
274
|
Three more rules keep a spec readable as a story, as the [story-testing skill](https://github.com/ShivaeDev/platform/blob/main/packages/skills/skills/story-testing/SKILL.md) describes. Together with `tests/spec-helpers`, `tests/named-values` and `tests/no-limit-imports`, they read files whose test declarations trace to a story kit, whatever their suffix: a `.test` or `.spec` file outside `test-support` that is not a type or unit test, such as `orders.spec.ts`, `pane.dom.test.ts` or `orders.slow.test.ts`. The suffix says where a test sits under `tests/follow`, not whether it is a story, and `tests/story-specs` already holds every such file to the story kit. They exempt the same test-story prerequisites as `tests/story-specs`. `tests/domain-outcomes` reports each use of Effect's `Exit`, `Cause` or `Result` module, each `_tag` read or destructuring, and each object literal tagged `"Success"` or `"Failure"`: the kit's verb or readout returns the outcome in the domain's words, such as `"unauthorized"`, and a trait builds any failing input. A domain's own tagged value, such as `{ _tag: "Resync" }`, passes. `tests/grouped-outcomes` reports each run of two or more consecutive `expect(yield* …)` statements once, at its first statement: write the outcomes as rows of one `outcomes` call. `tests/wait-on-events` reports `Effect.sleep`, `setTimeout` and `setInterval`, calls to an imported `eventually`, Vitest's fake timers, `vi.waitFor`, and `TestClock.adjust` and `TestClock.setTime`: settle on the engine's own signal through a kit verb, and when time passing is the behaviour, advance the clock in a verb named for it.
|
|
265
275
|
|
|
276
|
+
`tests/positive-refusals` reports `.not.toBe` and `.not.toEqual` on a readout or field whose name ends in `outcome` (case insensitive), including locally stored readout aliases. In the same story, positively assert a concrete domain reason or public response on that same outcome with `toBe`, `toEqual`, `toMatchObject` or an `outcomes` row. For example, pair `expect(yield* submitOutcome()).not.toBe("saved")` with `expect(yield* submitOutcome()).toBe("unauthorized")`, or replace the negative check with the positive one. Another story, another outcome, an empty object or a boolean does not supply that evidence. The rule uses the same story-file scope and prerequisite exemptions as `tests/domain-outcomes`; it checks visible assertion syntax, while review establishes that a readout preserves unexpected failures.
|
|
277
|
+
|
|
266
278
|
`tests/queue-readouts` reports access to jobs-testing's `jobs` and `snapshot` readouts in tests and `test-support/`, including wrappers that return counts or job states. An enqueued job does not prove the work ran: assert the application's visible result instead. Worker controls and waits remain available. The check recognizes receivers named `jobsTesting`, controllers constructed with `makePgBossTesting` or annotated with the imported `PgBossTesting` type, local and imported aliases, destructuring and literal bracket access. It does not evaluate dynamic property names or arbitrary controller factories. The package named `@shivaedev/jobs` is exempt, at the repository root or wherever it lives in the workspace; nested application packages remain checked. This rule refuses config exceptions and inline suppressions.
|
|
267
279
|
|
|
268
280
|
`boundaries/queue-sql` rejects SQL mentioning the private `pgboss.` schema. Apps use their queue definitions and let workers process jobs; there is no queue-purge API by design. `boundaries/auth-sql` rejects SQL accessing Better Auth's `user`, `account`, `session` and `verification` tables. App tables reference users by foreign key: migrations may reference only `user(id)` with `ON DELETE CASCADE` or `ON DELETE SET NULL`. Import `userReference` from `@shivaedev/identity/server/better-auth/userReference.ts` and interpolate `sql(userReference.table)` and `sql(userReference.column)` in the reference. Apps use identity for account data; `options.owners` names platform's own auth implementation and its migrations. These rules inspect SQL templates, literal query calls and query variables, and inventoried `.sql` files. They do not evaluate arbitrary runtime SQL construction.
|
|
@@ -348,6 +360,7 @@ For adoption, run `quality baseline write --rule code/unused --file src/legacy.t
|
|
|
348
360
|
- **Imports:** cycles, unresolvable imports, workspace imports missing from the manifest or an entry point, relative imports that leave their folder (except a module’s client or server `registration.ts` or `registration.tsx` importing its own `./admin/` subtree), production imports of test code, runtime folders and fences, as described above.
|
|
349
361
|
- **Names and files:** the Biome preset's naming rules and plugins, and the `files/*` rules, which name a file after its main export with its folders as the prefix. `files/named-after-export` accepts a file named after its single exported constant, such as `liveQueryWindow.ts` exporting `const liveQueryWindow`. It keeps the export’s full name while the file name omits words already supplied by any folder above it. In `spaces/client/`, a component exporting `CreateSpace` lives in `Create.tsx`: `spaces/` supplies “Space” even across the intervening `client/` folder. Keep the export named `CreateSpace`; `CreateSpace.tsx` would repeat a folder name. Inside a module’s `client/admin/` or `server/admin/` subtree, file names may repeat words from above `admin/`: `src/modules/inbox/client/admin/inboxRoutes.ts` may export `inboxRoutes`. Names must still match their exports and omit words repeated by folders within the admin subtree. No naming rule renames anything; the author picks the name. A name an outside system owns, such as a query parameter or an environment variable, is written as a quoted key, which the naming rules skip. A `Schema.Struct` field stays camelCase even when quoted and maps to the outside name with `Schema.encodeKeys`. Biome's naming messages print only a pattern: spell acronyms as words (`HttpClient`, `userId`, `parseUrl`) rather than turning off `strictCase` as its hint suggests, give a type no `I` prefix, and name a type parameter `T`, `T` plus a PascalCase name (`TItem`), or Effect's `A`, `E` and `R`. No rule checks these, so review does: a boolean reads as a question (`isOpen`, `canRetry`) unless the DOM or React names it (`open`, `disabled`); a schema shares its name with its type (`type Item = typeof Item.Type`); an unused parameter is removed rather than renamed with the `_` prefix TypeScript accepts. The naming rules take repository facts: `toolOwned` lists `.gitignore` patterns whose names a tool fixes, and a configured list extends the rule's defaults, so list only repository-specific additions; `content` lists snake_case content folders and files; `tests/follow` and `tests/colocated` take `suites` for test folders with their own layout, such as a Playwright suite.
|
|
350
362
|
- **Change keys:** `boundaries/imported-change-keys` reports literal collection and bucket names in Reactivity invalidations and mutations, SQL `invalidateOnCommit`, and the `changes` key encoders. Import the owning declaration and use its name, list, item or bucket key. Literal record IDs and bucket values are accepted, as are names at their collection declaration.
|
|
363
|
+
- **SQL transactions:** `effect/sql-transact` reports native `sql.withTransaction` calls around repository writes, `transact` or `invalidateOnCommit`. Begin the outer transaction with `transact(effect, { onSqlError })` so changed keys follow its commit. The rule resolves native SQL and repository declarations and follows direct calls, pipes, local aliases and source helpers. Native read-only and raw SQL transactions and unrelated transaction methods remain supported.
|
|
351
364
|
- **React:** `react/jsx-conditionals` reports `&&` and ternaries in the JSX children a component returns, including nested decisions and returned `.map` items. Decisions in a `const` above the return, JSX built inside library callbacks and conditional attributes are accepted. A ternary with two plain string or number literal branches, such as `{on ? "On" : "Off"}`, is accepted; branches that select JSX, components or computed values still need a decision before the JSX. This rule owns the check, so the shared Biome preset leaves `noLeakedRender` off.
|
|
352
365
|
- **Tests:** `tests/follow` and `tests/colocated` keep a test beside the code it covers, named `<file>[.<modifier>].test.ts` or `<behaviour>[.<modifier>].spec.ts` with at most one modifier of `dom`, `slow`, `typecheck` and `unit`; a unit test runs without the DOM, so `.unit.dom` is rejected. `tests/colocated` always treats `__tests__/` as a test folder. It treats `test/`, `tests/` and `spec/` as test folders only when their directly contained checked files are all tests or test support; a product folder with source beside its specs is an ordinary source folder. Declared `suites` keep their own layout. Shared test support belongs in `test-support/`, the sanctioned test-only folder. A test covering a whole module may sit at its root or directly beside its folder. The story rules above keep setup in the kit.
|
|
353
366
|
- **Manifests:** `manifests/valid` decodes every repository `package.json` through one shared Schema before dependent rules run and reports each invalid manifest once with its file path. An unreadable manifest or one removed after discovery becomes a `manifests/valid` finding. Optional lookups still treat `NotFound` as absence. `manifests/sorted` keeps every `package.json` in sort-package-json order, and `manifests/source-first` puts the `source` condition first in `exports` and `imports`. `manifests/exports-shape` checks the package root and workspace members. They use one file-preserving TypeScript wildcard: for example, `./*.ts` maps to `./src/*.ts`, `./dist/*.d.ts` and `./dist/*.js` under `source`, `types` and `default`. A subtree pattern such as `./server/*.ts` keeps that same subtree in its targets. An optional root entry and exact-path non-code assets such as JSON presets and `./package.json` are allowed. Every module remains importable; `null` export entries fail with a request to remove the block. A package without modules, such as a dependency shell, exports only exact assets and needs no wildcard. Import each module at its path under `src/`; named aliases, flattened paths, per-file module lists and additional wildcards fail. When declared, the standard imports must preserve their roots: `#*.ts` maps directly to `./src/*.ts` or uses source `./src/*.ts`, types `./dist/*.d.ts` and default `./dist/*.js`; `#test/*` maps to `./src/test-support/*`. Include subfolders in specifiers, such as `#server/module.ts`. Other aliases are allowed. `manifests/application` keeps an application on its entry points, as described above.
|
|
@@ -548,7 +561,7 @@ import { appViteConfig } from "@shivaedev/quality/appViteConfig.ts";
|
|
|
548
561
|
export default appViteConfig([tailwindcss(), react()]);
|
|
549
562
|
```
|
|
550
563
|
|
|
551
|
-
Use this in `vite.config.ts`. Plugins belong to the app. The
|
|
564
|
+
Use this in `vite.config.ts`. Plugins belong to the app. The web server port defaults to `VITE_PORT`, then 5173. The API port defaults to `PORT`, then 3000. These variables come from the process environment. Pass `{ webPort: 5273, apiPort: 3100 }` as the fourth argument to override either port, for example `appViteConfig(plugins, [], ["/health"], { webPort: 5273, apiPort: 3100 })`. The shared server proxies `/api/auth` and `/rpc` to the API port on `127.0.0.1`, preserving the request Host. Pass extra host routes as the third argument to proxy them to the same host during development. It enables TypeScript path resolution. Client routes, including administration pages, stay on Vite.
|
|
552
565
|
|
|
553
566
|
```ts
|
|
554
567
|
import { appTestConfig } from "@shivaedev/quality/appTestConfig.ts";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare const ImportAnalysisFailure_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
2
|
+
readonly _tag: "ImportAnalysisFailure";
|
|
3
|
+
} & Readonly<A>;
|
|
4
|
+
export declare class ImportAnalysisFailure extends ImportAnalysisFailure_base<{
|
|
5
|
+
readonly message: string;
|
|
6
|
+
readonly root: string;
|
|
7
|
+
}> {
|
|
8
|
+
}
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=ImportAnalysisFailure.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ImportAnalysisFailure.d.ts","sourceRoot":"","sources":["../../src/adapters/ImportAnalysisFailure.ts"],"names":[],"mappings":";;;AAEA,qBAAa,qBAAsB,SAAQ,2BAA0C;IACpF,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACtB,CAAC;CAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ImportAnalysisFailure.js","sourceRoot":"","sources":["../../src/adapters/ImportAnalysisFailure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,MAAM,OAAO,qBAAsB,SAAQ,IAAI,CAAC,WAAW,CAAC,uBAAuB,CAGjF;CAAG"}
|
|
@@ -1,21 +1,10 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
2
|
import type ts from "typescript";
|
|
3
|
-
import type { WorkspacePackage } from "#imports/workspace.ts";
|
|
4
|
-
import type { RuleInputs } from "#rule.ts";
|
|
5
|
-
declare const ImportAnalysisFailure_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
6
|
-
readonly _tag: "ImportAnalysisFailure";
|
|
7
|
-
} & Readonly<A>;
|
|
8
|
-
export declare class ImportAnalysisFailure extends ImportAnalysisFailure_base<{
|
|
9
|
-
readonly message: string;
|
|
10
|
-
readonly root: string;
|
|
11
|
-
}> {
|
|
12
|
-
}
|
|
13
3
|
export declare const ImportCompiler: import("effect/Context").Service<"@shivaedev/quality/ImportCompiler", Readonly<{
|
|
14
4
|
readonly browserChecker: (source: ts.SourceFile) => Effect.Effect<ts.TypeChecker, never, never>;
|
|
15
|
-
readonly departures: (inputs: RuleInputs, packages: readonly WorkspacePackage[]) => Effect.Effect<readonly import("../imports/departures.ts").Departure[], ImportAnalysisFailure, never>;
|
|
16
|
-
readonly graph: (inputs: RuleInputs) => Effect.Effect<Pick<import("../imports/graph.ts").ImportGraph, "configFindings" | "edges" | "modules" | "unresolved">, ImportAnalysisFailure, never>;
|
|
5
|
+
readonly departures: (inputs: import("../rule.ts").RuleInputs, packages: readonly import("../imports/workspace.ts").WorkspacePackage[]) => Effect.Effect<readonly import("../imports/departures.ts").Departure[], import("./ImportAnalysisFailure.ts").ImportAnalysisFailure, never>;
|
|
6
|
+
readonly graph: (inputs: import("../rule.ts").RuleInputs) => Effect.Effect<Pick<import("../imports/graph.ts").ImportGraph, "configFindings" | "edges" | "modules" | "unresolved">, import("./ImportAnalysisFailure.ts").ImportAnalysisFailure, never>;
|
|
17
7
|
}>> & {
|
|
18
8
|
readonly layer: import("effect/Layer").Layer<"@shivaedev/quality/ImportCompiler", never, never>;
|
|
19
9
|
};
|
|
20
|
-
export {};
|
|
21
10
|
//# sourceMappingURL=ImportCompiler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImportCompiler.d.ts","sourceRoot":"","sources":["../../src/adapters/ImportCompiler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ImportCompiler.d.ts","sourceRoot":"","sources":["../../src/adapters/ImportCompiler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAMjC,eAAO,MAAM,cAAc;;;;;;CASzB,CAAC"}
|
|
@@ -1,21 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Data, Effect } from "effect";
|
|
1
|
+
import { Effect } from "effect";
|
|
3
2
|
import { defineService } from "@shivaedev/service/defineService.ts";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
export class ImportAnalysisFailure extends Data.TaggedError("ImportAnalysisFailure") {
|
|
8
|
-
}
|
|
9
|
-
function failure(root, cause) {
|
|
10
|
-
return new ImportAnalysisFailure({ message: `Cannot analyze imports in ${root}: ${cause instanceof Error ? cause.message : String(cause)}`, root });
|
|
11
|
-
}
|
|
3
|
+
import { analyzeDepartures } from "#adapters/imports/analyzeDepartures.ts";
|
|
4
|
+
import { analyzeGraph } from "#adapters/imports/analyzeGraph.ts";
|
|
5
|
+
import { checkBrowser } from "#adapters/imports/checkBrowser.ts";
|
|
12
6
|
export const ImportCompiler = defineService({
|
|
13
7
|
id: "@shivaedev/quality/ImportCompiler",
|
|
14
8
|
initialize: Effect.void,
|
|
15
9
|
methods: () => ({
|
|
16
|
-
browserChecker:
|
|
17
|
-
departures:
|
|
18
|
-
graph:
|
|
10
|
+
browserChecker: checkBrowser,
|
|
11
|
+
departures: analyzeDepartures,
|
|
12
|
+
graph: analyzeGraph,
|
|
19
13
|
}),
|
|
20
14
|
requires: [],
|
|
21
15
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImportCompiler.js","sourceRoot":"","sources":["../../src/adapters/ImportCompiler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"ImportCompiler.js","sourceRoot":"","sources":["../../src/adapters/ImportCompiler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAC3E,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAEjE,MAAM,CAAC,MAAM,cAAc,GAAG,aAAa,CAAC;IAC3C,EAAE,EAAE,mCAAmC;IACvC,UAAU,EAAE,MAAM,CAAC,IAAI;IACvB,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC;QACf,cAAc,EAAE,YAA+E;QAC/F,UAAU,EAAE,iBAAiB;QAC7B,KAAK,EAAE,YAAY;KACnB,CAAC;IACF,QAAQ,EAAE,EAAE;CACZ,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
export interface BodyReference {
|
|
3
|
+
readonly file?: string | undefined;
|
|
4
|
+
readonly kind: "data" | "import" | "service" | "told";
|
|
5
|
+
readonly module: string;
|
|
6
|
+
readonly path: readonly string[];
|
|
7
|
+
}
|
|
8
|
+
export declare function storyBody(body: ts.Expression, checker: ts.TypeChecker): ts.ArrowFunction | ts.ConstructorDeclaration | ts.FunctionDeclaration | ts.FunctionExpression | ts.GetAccessorDeclaration | ts.MethodDeclaration | ts.SetAccessorDeclaration | undefined;
|
|
9
|
+
export declare function bodyReferences(body: ts.SignatureDeclaration, checker: ts.TypeChecker): (node: ts.Node) => BodyReference | undefined;
|
|
10
|
+
//# sourceMappingURL=bodyReferences.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bodyReferences.d.ts","sourceRoot":"","sources":["../../src/adapters/bodyReferences.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAI5B,MAAM,WAAW,aAAa;IAC7B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,CAAC;IACtD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;CACjC;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,EAAE,CAAC,UAAU,EAAE,OAAO,EAAE,EAAE,CAAC,WAAW,4LAGrE;AAiBD,wBAAgB,cAAc,CAAC,IAAI,EAAE,EAAE,CAAC,oBAAoB,EAAE,OAAO,EAAE,EAAE,CAAC,WAAW,UAqF/D,EAAE,CAAC,IAAI,KAAG,aAAa,GAAG,SAAS,CAWxD"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import { importFrom } from "#rules/stories/importOrigin.ts";
|
|
3
|
+
import { memberName, unwrapped } from "#rules/stories/syntax.ts";
|
|
4
|
+
export function storyBody(body, checker) {
|
|
5
|
+
const declaration = checker.getTypeAtLocation(body).getCallSignatures()[0]?.declaration;
|
|
6
|
+
return declaration !== undefined && "body" in declaration ? declaration : undefined;
|
|
7
|
+
}
|
|
8
|
+
function importName(node) {
|
|
9
|
+
if (ts.isImportSpecifier(node)) {
|
|
10
|
+
return (node.propertyName ?? node.name).text;
|
|
11
|
+
}
|
|
12
|
+
return ts.isImportClause(node) ? "default" : undefined;
|
|
13
|
+
}
|
|
14
|
+
function wrapped(node) {
|
|
15
|
+
return ts.isParenthesizedExpression(node) || ts.isAsExpression(node) || ts.isSatisfiesExpression(node) || ts.isNonNullExpression(node);
|
|
16
|
+
}
|
|
17
|
+
function importBinding(node) {
|
|
18
|
+
return ts.isImportSpecifier(node) || ts.isNamespaceImport(node) || ts.isImportClause(node);
|
|
19
|
+
}
|
|
20
|
+
export function bodyReferences(body, checker) {
|
|
21
|
+
const known = new Map();
|
|
22
|
+
const visiting = new Set();
|
|
23
|
+
const told = body.parameters[0];
|
|
24
|
+
function symbol(value) {
|
|
25
|
+
return value?.declarations?.map(visit).find((reference) => reference !== undefined);
|
|
26
|
+
}
|
|
27
|
+
function imported(node) {
|
|
28
|
+
const name = importName(node);
|
|
29
|
+
const module = importFrom(node);
|
|
30
|
+
if (module === undefined) {
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
const value = checker.getSymbolAtLocation(node.name ?? node);
|
|
34
|
+
const target = value !== undefined && value.flags & ts.SymbolFlags.Alias ? checker.getAliasedSymbol(value) : undefined;
|
|
35
|
+
const resolved = symbol(target);
|
|
36
|
+
if (resolved?.kind === "service" || resolved?.kind === "data") {
|
|
37
|
+
return resolved;
|
|
38
|
+
}
|
|
39
|
+
const canonical = target?.declarations === undefined ? name : target.name;
|
|
40
|
+
return { file: target?.declarations?.[0]?.getSourceFile().fileName, kind: "import", module, path: name === undefined ? [] : [canonical ?? name] };
|
|
41
|
+
}
|
|
42
|
+
function member(reference, name) {
|
|
43
|
+
return reference === undefined ? undefined : { ...reference, path: [...reference.path, name] };
|
|
44
|
+
}
|
|
45
|
+
function binding(node) {
|
|
46
|
+
const name = node.propertyName ?? node.name;
|
|
47
|
+
return ts.isIdentifier(name) || ts.isStringLiteral(name) ? member(visit(node.parent.parent), name.text) : undefined;
|
|
48
|
+
}
|
|
49
|
+
function call(node) {
|
|
50
|
+
const called = visit(node.expression);
|
|
51
|
+
if ((called?.kind === "service" && called.path.length === 0) || (called?.kind === "import" && serviceFactory(called))) {
|
|
52
|
+
return { kind: "service", module: called.module, path: [] };
|
|
53
|
+
}
|
|
54
|
+
if (called?.kind === "data" || (called?.kind === "import" && dataFactory(called))) {
|
|
55
|
+
return { kind: "data", module: called.module, path: [] };
|
|
56
|
+
}
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
function property(node) {
|
|
60
|
+
const receiver = visit(node.expression);
|
|
61
|
+
if (receiver?.kind === "import" && receiver.path.length === 0) {
|
|
62
|
+
const resolved = symbol(checker.getSymbolAtLocation(ts.isPropertyAccessExpression(node) ? node.name : node));
|
|
63
|
+
if (resolved?.kind === "service" || resolved?.kind === "data") {
|
|
64
|
+
return resolved;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return member(receiver, memberName(node) ?? "");
|
|
68
|
+
}
|
|
69
|
+
function expression(node) {
|
|
70
|
+
if (ts.isIdentifier(node)) {
|
|
71
|
+
return symbol(checker.getSymbolAtLocation(node));
|
|
72
|
+
}
|
|
73
|
+
if (ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) {
|
|
74
|
+
return property(node);
|
|
75
|
+
}
|
|
76
|
+
return ts.isCallExpression(node) ? call(node) : undefined;
|
|
77
|
+
}
|
|
78
|
+
function classReference(node) {
|
|
79
|
+
return node.heritageClauses
|
|
80
|
+
?.flatMap((clause) => clause.types.map((base) => visit(base.expression)))
|
|
81
|
+
.find((value) => value?.kind === "service" || value?.kind === "data");
|
|
82
|
+
}
|
|
83
|
+
function origin(node) {
|
|
84
|
+
if (wrapped(node)) {
|
|
85
|
+
return visit(node.expression);
|
|
86
|
+
}
|
|
87
|
+
if (node === told) {
|
|
88
|
+
return { kind: "told", module: "", path: [] };
|
|
89
|
+
}
|
|
90
|
+
if (importBinding(node)) {
|
|
91
|
+
return imported(node);
|
|
92
|
+
}
|
|
93
|
+
if (ts.isVariableDeclaration(node)) {
|
|
94
|
+
return node.initializer === undefined ? undefined : visit(unwrapped(node.initializer));
|
|
95
|
+
}
|
|
96
|
+
if (ts.isBindingElement(node)) {
|
|
97
|
+
return binding(node);
|
|
98
|
+
}
|
|
99
|
+
if (ts.isClassDeclaration(node)) {
|
|
100
|
+
return classReference(node);
|
|
101
|
+
}
|
|
102
|
+
return expression(node);
|
|
103
|
+
}
|
|
104
|
+
function visit(node) {
|
|
105
|
+
if (visiting.has(node) || known.has(node)) {
|
|
106
|
+
return known.get(node);
|
|
107
|
+
}
|
|
108
|
+
visiting.add(node);
|
|
109
|
+
const value = origin(node);
|
|
110
|
+
visiting.delete(node);
|
|
111
|
+
known.set(node, value);
|
|
112
|
+
return value;
|
|
113
|
+
}
|
|
114
|
+
return visit;
|
|
115
|
+
}
|
|
116
|
+
function dataFactory({ module, path }) {
|
|
117
|
+
return (module === "effect" && (path[0] === "Schema" || path[0] === "Data")) || module === "effect/Schema" || module === "effect/Data";
|
|
118
|
+
}
|
|
119
|
+
function serviceFactory({ module, path }) {
|
|
120
|
+
return ((module === "@shivaedev/service/defineService.ts" && path[0] === "defineService")
|
|
121
|
+
|| ((module === "effect" || module === "effect/Context")
|
|
122
|
+
&& path.at(-1) !== undefined
|
|
123
|
+
&& ["Service", "Tag", "GenericTag", "Reference"].includes(path.at(-1) ?? "")));
|
|
124
|
+
}
|
|
125
|
+
//# sourceMappingURL=bodyReferences.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bodyReferences.js","sourceRoot":"","sources":["../../src/adapters/bodyReferences.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AASjE,MAAM,UAAU,SAAS,CAAC,IAAmB,EAAE,OAAuB;IACrE,MAAM,WAAW,GAAG,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,iBAAiB,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC;IACxF,OAAO,WAAW,KAAK,SAAS,IAAI,MAAM,IAAI,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC;AACrF,CAAC;AAED,SAAS,UAAU,CAAC,IAA+D;IAClF,IAAI,EAAE,CAAC,iBAAiB,CAAC,IAAI,CAAC,EAAE,CAAC;QAChC,OAAO,CAAC,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC;IAC9C,CAAC;IACD,OAAO,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC;AACxD,CAAC;AAED,SAAS,OAAO,CAAC,IAAa;IAC7B,OAAO,EAAE,CAAC,yBAAyB,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;AACxI,CAAC;AAED,SAAS,aAAa,CAAC,IAAa;IAC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AC;WAC9E,CAAC,CAAC,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,gBAAgB,CAAC;eACpD,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,SAAS;eACzB,CAAC,SAAS,EAAE,KAAK,EAAE,YAAY,EAAE,WAAW,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAC9E,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
export interface EngineEscape {
|
|
3
|
+
readonly node: ts.Node;
|
|
4
|
+
readonly reason: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function engineEscapes(body: ts.Expression, checker: ts.TypeChecker, file: string): {
|
|
7
|
+
drivesSubject: boolean;
|
|
8
|
+
escapes: EngineEscape[];
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=engineEscapes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engineEscapes.d.ts","sourceRoot":"","sources":["../../src/adapters/engineEscapes.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,YAAY,CAAC;AAO5B,MAAM,WAAW,YAAY;IAC5B,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACxB;AA0BD,wBAAgB,aAAa,CAAC,IAAI,EAAE,EAAE,CAAC,UAAU,EAAE,OAAO,EAAE,EAAE,CAAC,WAAW,EAAE,IAAI,EAAE,MAAM;;;EAiFvF"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { posix } from "node:path";
|
|
2
|
+
import ts from "typescript";
|
|
3
|
+
import { isTestSupport, testName } from "#naming/testName.ts";
|
|
4
|
+
import { engineOf } from "#rules/stories/engineOf.ts";
|
|
5
|
+
import { memberName, unwrapped } from "#rules/stories/syntax.ts";
|
|
6
|
+
import { bodyReferences, storyBody } from "./bodyReferences.js";
|
|
7
|
+
import { serviceAccess } from "./serviceAccess.js";
|
|
8
|
+
function production({ file, module }) {
|
|
9
|
+
return (!(isTestSupport(file ?? module) || module.startsWith("@shivaedev/test"))
|
|
10
|
+
&& (/^[.#/]/u.test(module)
|
|
11
|
+
|| module.startsWith("@shivaedev/")
|
|
12
|
+
|| engineOf({ kind: "external", package: module, specifier: module }) !== undefined));
|
|
13
|
+
}
|
|
14
|
+
function constructorTest(file, reference) {
|
|
15
|
+
const name = testName(file);
|
|
16
|
+
const target = reference.file ?? posix.join(posix.dirname(file), reference.module);
|
|
17
|
+
return name !== undefined && target.endsWith(`/${posix.join(name.folder, name.stem)}${name.extension}`);
|
|
18
|
+
}
|
|
19
|
+
function constructorCall(node, called) {
|
|
20
|
+
const name = called.path.at(-1) ?? "";
|
|
21
|
+
return (called.kind === "import"
|
|
22
|
+
&& production(called)
|
|
23
|
+
&& (ts.isNewExpression(node) || /^(?:(?:make|create|build)[A-Z]|make$|create$|build$|defineService$|layer(?:$|[A-Z]))/u.test(name)));
|
|
24
|
+
}
|
|
25
|
+
export function engineEscapes(body, checker, file) {
|
|
26
|
+
const declaration = storyBody(body, checker);
|
|
27
|
+
if (declaration?.body === undefined) {
|
|
28
|
+
return { drivesSubject: false, escapes: [] };
|
|
29
|
+
}
|
|
30
|
+
const reference = bodyReferences(declaration, checker);
|
|
31
|
+
const block = declaration.body;
|
|
32
|
+
const escapes = [];
|
|
33
|
+
let drivesSubject = false;
|
|
34
|
+
function transactionHandle(node, value) {
|
|
35
|
+
if (!((value.module === "effect/sql/SqlClient" || value.module === "effect/sql") && value.path.at(-1) === "SqlClient")) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
const yielded = node.parent;
|
|
39
|
+
const binding = yielded.parent;
|
|
40
|
+
if (!(ts.isYieldExpression(yielded) && ts.isVariableDeclaration(binding) && ts.isIdentifier(binding.name))) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
const name = binding.name;
|
|
44
|
+
const symbol = checker.getSymbolAtLocation(name);
|
|
45
|
+
const uses = [];
|
|
46
|
+
function collect(current) {
|
|
47
|
+
if (ts.isIdentifier(current) && current !== name && checker.getSymbolAtLocation(current) === symbol) {
|
|
48
|
+
uses.push(current);
|
|
49
|
+
}
|
|
50
|
+
ts.forEachChild(current, collect);
|
|
51
|
+
}
|
|
52
|
+
collect(block);
|
|
53
|
+
return (uses.length > 0
|
|
54
|
+
&& uses.every((use) => (ts.isPropertyAccessExpression(use.parent) || ts.isElementAccessExpression(use.parent))
|
|
55
|
+
&& use.parent.expression === use
|
|
56
|
+
&& memberName(use.parent) === "withTransaction"));
|
|
57
|
+
}
|
|
58
|
+
function accessReason(node) {
|
|
59
|
+
const value = reference(node);
|
|
60
|
+
if (value?.kind === "told" && value.path[0] === "story" && value.path[1] === "engine") {
|
|
61
|
+
return "Reads story.engine";
|
|
62
|
+
}
|
|
63
|
+
if (value === undefined || !serviceAccess(node, value, reference)) {
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
if (transactionHandle(node, value)) {
|
|
67
|
+
drivesSubject = true;
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
return "Reads a raw service handle";
|
|
71
|
+
}
|
|
72
|
+
function checkConstructor(node) {
|
|
73
|
+
const called = reference(unwrapped(node.expression));
|
|
74
|
+
if (called === undefined || !constructorCall(node, called)) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (constructorTest(file, called)) {
|
|
78
|
+
drivesSubject = true;
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
escapes.push({ node, reason: "Calls a production constructor" });
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
function visit(node) {
|
|
85
|
+
if (ts.isTypeNode(node)) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
if (ts.isIdentifier(node) || ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) {
|
|
89
|
+
const reason = accessReason(node);
|
|
90
|
+
if (reason !== undefined) {
|
|
91
|
+
escapes.push({ node, reason });
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (ts.isCallExpression(node) || ts.isNewExpression(node)) {
|
|
96
|
+
checkConstructor(node);
|
|
97
|
+
}
|
|
98
|
+
ts.forEachChild(node, visit);
|
|
99
|
+
}
|
|
100
|
+
visit(declaration.body);
|
|
101
|
+
return { drivesSubject, escapes: escapes.filter((found, index) => escapes.findIndex((other) => other.reason === found.reason) === index) };
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=engineEscapes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engineEscapes.js","sourceRoot":"","sources":["../../src/adapters/engineEscapes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAsB,cAAc,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACpF,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAOnD,SAAS,UAAU,CAAC,EAAE,IAAI,EAAE,MAAM,EAAiB;IAClD,OAAO,CACN,CAAC,CAAC,aAAa,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,MAAM,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC;WACrE,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC;eACtB,MAAM,CAAC,UAAU,CAAC,aAAa,CAAC;eAChC,QAAQ,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO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AAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAE3E,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,qBAAqB,CAEnF"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ImportAnalysisFailure } from "#adapters/ImportAnalysisFailure.ts";
|
|
2
|
+
export function analysisFailure(root, cause) {
|
|
3
|
+
return new ImportAnalysisFailure({ message: `Cannot analyze imports in ${root}: ${cause instanceof Error ? cause.message : String(cause)}`, root });
|
|
4
|
+
}
|
|
5
|
+
//# sourceMappingURL=analysisFailure.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analysisFailure.js","sourceRoot":"","sources":["../../../src/adapters/imports/analysisFailure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAE3E,MAAM,UAAU,eAAe,CAAC,IAAY,EAAE,KAAc;IAC3D,OAAO,IAAI,qBAAqB,CAAC,EAAE,OAAO,EAAE,6BAA6B,IAAI,KAAK,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;AACrJ,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import type { WorkspacePackage } from "#imports/workspace.ts";
|
|
3
|
+
import type { RuleInputs } from "#rule.ts";
|
|
4
|
+
export declare const analyzeDepartures: (inputs: RuleInputs, packages: readonly WorkspacePackage[]) => Effect.Effect<readonly import("../../imports/departures.ts").Departure[], import("../ImportAnalysisFailure.ts").ImportAnalysisFailure, never>;
|
|
5
|
+
//# sourceMappingURL=analyzeDepartures.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analyzeDepartures.d.ts","sourceRoot":"","sources":["../../../src/adapters/imports/analyzeDepartures.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAI3C,eAAO,MAAM,iBAAiB,8MAE7B,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { analysisFailure } from "./analysisFailure.js";
|
|
3
|
+
import { departures } from "./departures.js";
|
|
4
|
+
export const analyzeDepartures = Effect.fn("ImportCompiler.analyzeDepartures")((inputs, packages) => Effect.try({ catch: (cause) => analysisFailure(inputs.root, cause), try: () => departures(inputs, packages) }));
|
|
5
|
+
//# sourceMappingURL=analyzeDepartures.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analyzeDepartures.js","sourceRoot":"","sources":["../../../src/adapters/imports/analyzeDepartures.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,EAAE,CAAC,kCAAkC,CAAC,CAAC,CAAC,MAAkB,EAAE,QAAqC,EAAE,EAAE,CAC5I,MAAM,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,eAAe,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE,CAAC,CAC9G,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import type { RuleInputs } from "#rule.ts";
|
|
3
|
+
export declare const analyzeGraph: (inputs: RuleInputs) => Effect.Effect<Pick<import("../../imports/graph.ts").ImportGraph, "configFindings" | "edges" | "modules" | "unresolved">, import("../ImportAnalysisFailure.ts").ImportAnalysisFailure, never>;
|
|
4
|
+
//# sourceMappingURL=analyzeGraph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analyzeGraph.d.ts","sourceRoot":"","sources":["../../../src/adapters/imports/analyzeGraph.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAI3C,eAAO,MAAM,YAAY,sNAExB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { realpathSync } from "node:fs";
|
|
2
|
+
import { Effect } from "effect";
|
|
3
|
+
import { analysisFailure } from "./analysisFailure.js";
|
|
4
|
+
import { graph } from "./graph.js";
|
|
5
|
+
export const analyzeGraph = Effect.fn("ImportCompiler.analyzeGraph")((inputs) => Effect.try({ catch: (cause) => analysisFailure(inputs.root, cause), try: () => graph(inputs, realpathSync(inputs.root)) }));
|
|
6
|
+
//# sourceMappingURL=analyzeGraph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analyzeGraph.js","sourceRoot":"","sources":["../../../src/adapters/imports/analyzeGraph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,EAAE,CAAC,6BAA6B,CAAC,CAAC,CAAC,MAAkB,EAAE,EAAE,CAC3F,MAAM,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,eAAe,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAC1H,CAAC"}
|