@fuzdev/fuz_app 0.132.1 → 0.134.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/dist/db/CLAUDE.md +11 -8
- package/dist/db/create_db.d.ts +8 -6
- package/dist/db/create_db.d.ts.map +1 -1
- package/dist/db/create_db.js +11 -10
- package/dist/db/db.d.ts +9 -7
- package/dist/db/db.d.ts.map +1 -1
- package/dist/db/db.js +5 -4
- package/dist/db/db_pglet.d.ts +43 -0
- package/dist/db/db_pglet.d.ts.map +1 -0
- package/dist/db/db_pglet.js +55 -0
- package/dist/db/fact_disk_storage.d.ts +3 -3
- package/dist/db/fact_disk_storage.d.ts.map +1 -1
- package/dist/db/fact_disk_storage.js +11 -11
- package/dist/db/fact_store.d.ts +4 -4
- package/dist/db/fact_store.js +3 -3
- package/dist/db/fact_store_errors.d.ts +3 -3
- package/dist/db/fact_store_errors.d.ts.map +1 -1
- package/dist/db/fact_store_errors.js +5 -5
- package/dist/testing/CLAUDE.md +17 -18
- package/dist/testing/app_server.d.ts +5 -5
- package/dist/testing/app_server.d.ts.map +1 -1
- package/dist/testing/app_server.js +21 -20
- package/dist/testing/cross_backend/default_backend_configs.d.ts +5 -5
- package/dist/testing/cross_backend/default_backend_configs.d.ts.map +1 -1
- package/dist/testing/cross_backend/default_backend_configs.js +1 -1
- package/dist/testing/cross_backend/in_process_setup.d.ts +2 -2
- package/dist/testing/cross_backend/in_process_setup.js +3 -3
- package/dist/testing/cross_backend/test_cell_gated_create_authorize.js +1 -1
- package/dist/testing/cross_backend/testing_reset_actions.d.ts +2 -2
- package/dist/testing/cross_backend/testing_reset_actions.js +1 -1
- package/dist/testing/cross_backend/ts_spine_backend_config.d.ts +2 -2
- package/dist/testing/cross_backend/ts_spine_backend_config.d.ts.map +1 -1
- package/dist/testing/db.d.ts +49 -60
- package/dist/testing/db.d.ts.map +1 -1
- package/dist/testing/db.js +104 -101
- package/dist/testing/rate_limiting.d.ts +2 -1
- package/dist/testing/rate_limiting.d.ts.map +1 -1
- package/dist/testing/rate_limiting.js +2 -2
- package/dist/testing/sse_round_trip.d.ts +1 -1
- package/dist/testing/sse_round_trip.d.ts.map +1 -1
- package/dist/testing/sse_round_trip.js +2 -2
- package/dist/testing/stubs.js +1 -1
- package/package.json +8 -3
package/dist/testing/CLAUDE.md
CHANGED
|
@@ -116,24 +116,23 @@ Factory builders for parameterized DB tests. Consumer projects pass their
|
|
|
116
116
|
`init_schema` callback (which calls `run_migrations(db, [auth_migration_ns, ...app_migrations])`);
|
|
117
117
|
factories accept any migration namespace set.
|
|
118
118
|
|
|
119
|
-
- `IS_CI` — `process.env.CI === 'true'`.
|
|
120
119
|
- `DbFactory` — `{name, create, close, skip, skip_reason?}`.
|
|
121
|
-
- `
|
|
122
|
-
- `
|
|
123
|
-
- `
|
|
124
|
-
- `
|
|
120
|
+
- `reset_public_schema(db)` — `DROP SCHEMA public CASCADE; CREATE SCHEMA public`, in plain SQL, so it resets every driver. Every factory calls it per `create()`, so `init_schema` only migrates. Drift-proof — no drop list to maintain.
|
|
121
|
+
- `create_default_db_factory(init_schema)` — the default in-memory factory: pglet-wasm, or the builder `set_default_db_factory` installed before it was built. What fuz_app's own helpers fall back to (`create_test_app_server`, `describe_rate_limiting_tests`, `describe_sse_route_tests`).
|
|
122
|
+
- `create_pglet_wasm_factory(init_schema)` / `create_pglite_factory(init_schema)` — pin pglet-wasm (`@fuzdev/pglet-wasm`, created with `PGLET_COERCION`) or PGlite; each needs its optional peer installed; `skip: false`. See WASM caching below.
|
|
123
|
+
- `set_default_db_factory(create_factory | null)` — install a `DbFactoryBuilder` for `create_default_db_factory`, so suites written against the default run on another driver without being edited (`create_pglite_factory` to run them on PGlite); returns the builder it replaced, so a caller can put it back. Install from a `db`-project `setupFiles` entry, before any factory is built (../../../docs/testing.md §Switching the default driver). Injected rather than selected here: a driver it can wrap may live in test-side code this shipped module can't import (fuz_app's `pglet-server`). fuz_app's own switch is `src/test/db_default.ts` (`FUZ_TEST_DB_DEFAULT`).
|
|
124
|
+
- `create_pg_factory(init_schema, test_url?)` — PostgreSQL; `skip: true` when `test_url` missing. Each `create()` opens a pool and resets the `public` schema before `init_schema`, like every other factory, so a persistent test database carries no stale DDL; a missing database (`3D000`) gets a `createdb` hint. Pool reused + cleaned up across `create()` calls.
|
|
125
125
|
- `auth_truncate_tables` — `['invite', 'api_token', 'auth_session', 'role_grant', 'role_grant_offer', 'actor', 'account']` in FK-safe order. Excludes `audit_log` — unit DB tests don't need to truncate it.
|
|
126
126
|
- `auth_integration_truncate_tables` — `auth_truncate_tables + ['audit_log']` for integration suites that exercise the audit path.
|
|
127
|
-
- `drop_auth_schema(db)` — `DROP SCHEMA public CASCADE; CREATE SCHEMA public`; call at the top of `init_schema` on persistent pg databases that may hold stale DDL from previous fuz_app versions. Drift-proof full-schema reset (despite the name, not auth-scoped) — same mechanism as `reset_pglite`.
|
|
128
127
|
- `create_describe_db(factories, truncate_tables)` — returns `describe_db(name, fn)` running `fn(get_db)` once per factory inside a `describe` with shared `beforeAll(create)` + `beforeEach(TRUNCATE)` + `afterAll(close)`. Skipped factories use `describe.skip`.
|
|
129
128
|
- `log_db_factory_status(factories)` — console summary of enabled / skipped factories.
|
|
130
129
|
- `assert_columns_match_live(db, table, columns)` — the named-projection drift guard: asserts a `*_COLUMNS` const (`ACCOUNT_COLUMNS`, `CELL_COLUMNS`, a consumer's own) names exactly the live `public`-schema columns of `table`, via `query_public_columns(db, {table})`. Per module, or iterated from a table → const registry (fuz_app's own: `src/test/db/column_projections.db.test.ts`).
|
|
131
130
|
|
|
132
|
-
**
|
|
133
|
-
instance in a module-level
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
reset. The `db` vitest project (opted into by the `.db.test.ts` suffix) runs
|
|
131
|
+
**WASM caching.** `create_pglite_factory` and `create_pglet_wasm_factory` each
|
|
132
|
+
share a single instance of their driver, held in a module-level promise, across the
|
|
133
|
+
factories they build. Every `create()` calls `DROP SCHEMA public CASCADE` and
|
|
134
|
+
re-runs its `init_schema` instead of paying the WASM cold start again, so suites
|
|
135
|
+
share state until the next reset. The `db` vitest project (opted into by the `.db.test.ts` suffix) runs
|
|
137
136
|
with `isolate: false` + `fileParallelism: false` to amortize WASM boot across
|
|
138
137
|
every DB test file — which also makes that one instance the whole run's; a
|
|
139
138
|
project that isolates its files gets one per worker instead.
|
|
@@ -152,7 +151,7 @@ Key module-scope values:
|
|
|
152
151
|
- `stub_password_deps` — `PasswordHashDeps` hashing via `stub_hash_${password}` and verifying by equality. Deterministic, no Argon2 cost — use for every test not specifically exercising password hashing.
|
|
153
152
|
- `create_loopback_app_server_options()` — the loopback `create_app_server` options an in-process test server takes (`localhost` origins, the loopback proxy trusted, an empty env schema), fresh per call; `create_test_app` and `create_test_app_for_bootstrap` spread it under their own defaults (`rate_limiters: 'disabled_for_testing'`, `await_pending_effects: true`).
|
|
154
153
|
- `TEST_COOKIE_SECRET` — 64-hex-char deterministic cookie secret. Produces a valid `Keyring` via `create_validated_keyring`. Never used in production — the stub guard plus fixed value is the contract.
|
|
155
|
-
- `
|
|
154
|
+
- `fallback_db_factory` — module-level auth-only default factory (`create_default_db_factory`) `create_test_app_server` uses when no `db` is passed, reusing its driver's WASM cache. When `migration_namespaces` is supplied, a memoized sibling factory (keyed by namespace set) migrating `[auth_migration_ns, ...migration_namespaces]` is used instead — same shared WASM, extra tables.
|
|
156
155
|
|
|
157
156
|
Two helpers share the "insert account + actor + roles + API token + session +
|
|
158
157
|
cookie" flow, split by intent:
|
|
@@ -170,7 +169,7 @@ pre-keeper, lock unflipped), use `create_test_app_for_bootstrap` — pair with
|
|
|
170
169
|
Types:
|
|
171
170
|
|
|
172
171
|
- `TestAppServer extends AppBackend` — adds `account`, `actor`, `api_token`, `session_cookie`, `keyring`, `cleanup()`.
|
|
173
|
-
- `TestAppServerOptions` — `session_options` (required), optional `db`, `db_type`, `migration_namespaces`, `password`, `username`, `password_value`, `roles`, `audit_factory`. `migration_namespaces` runs extra namespaces after auth in the auto-created
|
|
172
|
+
- `TestAppServerOptions` — `session_options` (required), optional `db`, `db_type`, `migration_namespaces`, `password`, `username`, `password_value`, `roles`, `audit_factory`. `migration_namespaces` runs extra namespaces after auth in the auto-created in-memory database (mirrors `create_app_backend`); mutually exclusive with `db` (caller-migrated) — passing both throws. The optional `audit_factory` defaults to `default_audit_factory` (no-listener `create_audit_emitter` over the test backend's `{db, log}`); pass a custom factory to compose `on_audit_event` / `audit_log_config`, instrument `emit` with `emit_decorator`, or otherwise replace the emitter. Mirrors `CreateAppBackendOptions` end-to-end — the previous `on_audit_event` / `audit_log_config` sugar was removed alongside the production rename.
|
|
174
173
|
- `CreateTestAppOptions extends TestAppServerOptions` — adds `create_route_specs` (required), `rpc_endpoints?: RpcEndpointsSuiteOption` (top-level only — single source of truth, symmetric with the suite-level option), `bootstrap?: BootstrapServerOptions` (top-level only — same precedent as `rpc_endpoints`), and `app_options?: SuiteAppOptions` (`Partial<AppServerOptions>` excluding the five fields the helper manages: `backend`, `session_options`, `create_route_specs`, `rpc_endpoints`, `bootstrap`).
|
|
175
174
|
- `TestAccount` — `{account, actor, session_cookie, api_token, create_session_headers, create_bearer_headers}`.
|
|
176
175
|
- `TestApp` — `{app, backend, server, surface_spec, surface, route_specs, create_session_headers, create_bearer_headers, create_daemon_token_headers, create_account, cleanup}`. `server` is the assembled `AppServer`, for what `create_app_server` built beyond the lifted fields — `require_audit_sse(test_app.server)` with `audit_log_sse` in `app_options`, `test_app.server.ws_endpoints[path]` — instead of capturing them from a `create_route_specs` closure.
|
|
@@ -199,7 +198,7 @@ schedule stopped by `cleanup()`, which is the assembled server's `close`.
|
|
|
199
198
|
|
|
200
199
|
A fresh Hono app is created on every call because middleware closures bind
|
|
201
200
|
to the server's deps (db, keyring). Hono assembly is cheap (~10–50ms);
|
|
202
|
-
|
|
201
|
+
the WASM caching in `db.ts` is where the real savings are.
|
|
203
202
|
|
|
204
203
|
### `auth_apps.ts` — adversarial-auth app factories
|
|
205
204
|
|
|
@@ -624,7 +623,7 @@ the spread are ignored by the suite.
|
|
|
624
623
|
|
|
625
624
|
### `integration.ts` — `describe_standard_integration_tests`
|
|
626
625
|
|
|
627
|
-
Exercises the full stack against real
|
|
626
|
+
Exercises the full stack against a real in-memory database + auth middleware + session
|
|
628
627
|
cookies + bearer tokens. The suite has ~19 `describe` blocks grouped under
|
|
629
628
|
these thematic areas:
|
|
630
629
|
|
|
@@ -1469,7 +1468,7 @@ are `src/test/auth/cell_crud_parity.db.test.ts`
|
|
|
1469
1468
|
passed the **transactional** `Db` the auth wipe ran on, so DB-domain
|
|
1470
1469
|
consumers (e.g. fuz_forge truncating its cell / fact / file tables) reset
|
|
1471
1470
|
on the same connection rather than a separately-pooled one that would
|
|
1472
|
-
deadlock against this open transaction under
|
|
1471
|
+
deadlock against this open transaction under the in-memory drivers. Auth
|
|
1473
1472
|
gates on `credential_types: ['daemon_token']` — effectively keeper-only
|
|
1474
1473
|
without forcing the `actor: 'required'` ⟺ `acting?: ActingActor`
|
|
1475
1474
|
biconditional. No free-form runtime grant action exists — see the
|
|
@@ -1857,7 +1856,7 @@ re-roll the serve / daemon-info / WS-attach / drain boilerplate:
|
|
|
1857
1856
|
- `testing/cross_backend/testing_server_bun.ts` — `create_bun_testing_adapter()` (`Bun.serve` + `@hono/bun`'s module-level `getConnInfo`, `upgradeWebSocket`, and `websocket`; `Bun.serve` declared locally so it typechecks under the Node toolchain). Needs the optional `@hono/bun` peer dep (the counterpart to Node's `@hono/node-server` + `@hono/node-ws`; `Bun.serve` is built in), and Bun resolves `.js`→`.ts` natively (no flag, unlike Deno). Reuses `create_node_runtime` (Bun implements the `node:fs`/`node:process` surface). WS is module-level + stateless (like Deno) — the `websocket` handler is threaded into `serve`, where `Bun.serve` wants it, so no post-serve attach. It carries `maxPayloadLength` at twice `max_message_bytes` rather than Bun's 16 MiB default: past its cap Bun drops the socket without a close frame (1006), so the headroom leaves a message just over the limit to the per-message check (`WS_CLOSE_MESSAGE_TOO_BIG`, as on Node), while a grossly oversized one is refused before Bun buffers it whole.
|
|
1858
1857
|
- `testing/cross_backend/default_spine_surface.ts` — the canonical no-domain spine surface (account/admin/audit/signup + bootstrap): `spine_session_options`, `spine_roles`, `create_spine_route_specs`, `spine_rpc_endpoints`, `create_spine_surface_spec`. This is the **declared** surface — the `create_standard_rpc_actions` bundle the spec-derived suites auto-enumerate. It passes `daemon_token: true` (both spine binaries mount the daemon-token layer) and leaves `GET /api/surface` at its default, off — the TS spine binary does too, and the Rust `testing_spine_stub` serves none. Shared by the spine_stub cross test, the TS cross tests, and the binary.
|
|
1859
1858
|
- `testing/cross_backend/full_spine_mount.ts` — `build_full_spine_rpc_actions(deps, options)` — the **full** live RPC mount: the declared bundle **plus** the off-declared-surface families the binary live-mounts (`_testing_*` backdoors, the cell verb set, the opt-in `actor_lookup` / `actor_search` resolvers). `build_full_spine_mount(deps, options)` builds it once for both of the binary's endpoints, returning `FullSpineMount` (`{rpc_actions, ws_actions}`): the WS list is `protocol_actions` plus every RPC action not already among them, twinning the Rust `testing_spine_stub`, which serves one registry on RPC and WS (the one difference is `cancel` — a registered protocol action on TS, owned by the read loop on Rust). Single-sources the mount so the binary and the `spine_method_coverage` reconciliation test build the same list.
|
|
1860
|
-
- `testing/cross_backend/ts_spine_backend_config.ts` — `ts_spine_node_backend_config()` / `ts_spine_deno_backend_config()` / `ts_spine_bun_backend_config()` presets (in-memory
|
|
1859
|
+
- `testing/cross_backend/ts_spine_backend_config.ts` — `ts_spine_node_backend_config()` / `ts_spine_deno_backend_config()` / `ts_spine_bun_backend_config()` presets (in-memory pglet, no external infra), the TS analog of `rust_spine_stub_backend_config()`.
|
|
1861
1860
|
|
|
1862
1861
|
fuz_app's own binary wiring (`src/test/cross_backend/testing_spine_server{,_node,_deno,_bun}.ts`) is the worked example: ~one `build_app` over `create_app_backend` + `create_app_server` (`rate_limiters: 'disabled_for_testing'` plus whichever login / action limiters its env toggles built, `build_full_spine_mount`'s two lists on one `rpc_endpoints` entry and one `ws_endpoints` entry, whose `transport` is also the role-grant-offer `notification_sender`), reusing `default_spine_surface`. `src/test/cross_backend/testing_spine_server.db.test.ts` builds it with the Node adapter in-process and asserts its surface lists `/api/ws` and passes the surface invariants. The `_node`/`_deno`/`_bun` entries differ only in which adapter they wire — `build_spine_app` is runtime-agnostic. It leaves `create_app_server`'s `auth_cleanup` off, as the Rust `testing_spine_stub` leaves its twin unscheduled: a background pass would delete rows and write audit rows under a running suite. A consumer's cross-process test binary may schedule it when nothing its suites seed is already expired (the conformance table's `expired_session` principal seeds a backdated session row); an in-process harness leaves it off.
|
|
1863
1862
|
|
|
@@ -1925,7 +1924,7 @@ fuz_app also ships its **own** `npm run benchmark:cross-impl`
|
|
|
1925
1924
|
(`src/benchmarks/cross_impl.bench.ts`) on the back of its TS spine binary —
|
|
1926
1925
|
ts-node + ts-deno + ts-bun (+ the Rust `spine_stub` when `FUZ_TESTING_RUST_SPINE_STUB_BIN`
|
|
1927
1926
|
is set). The three TS runtimes are apples-to-apples with each other (same
|
|
1928
|
-
|
|
1927
|
+
in-memory pglet driver); TS-vs-Rust carries the pglet-vs-Postgres DB-layer caveat
|
|
1929
1928
|
(documented in the run). The artifact (`*.latest.json`) is gitignored.
|
|
1930
1929
|
|
|
1931
1930
|
- `bench/scenario.ts` — `BenchScenario` (`{name, requires?, run}`) +
|
|
@@ -3,7 +3,7 @@ import './assert_dev_env.js';
|
|
|
3
3
|
* Bootstrapped app server factory for integration tests.
|
|
4
4
|
*
|
|
5
5
|
* Creates a keeper account, API token, and signed session cookie on a
|
|
6
|
-
* database. By default uses a cached in-memory
|
|
6
|
+
* database. By default uses a cached in-memory pglet (one shared WASM instance
|
|
7
7
|
* per loaded copy of `testing/db.ts` — once per run under the `db` project's
|
|
8
8
|
* `isolate: false` + `fileParallelism: false`); pass `db` to use
|
|
9
9
|
* an existing database (any driver) instead.
|
|
@@ -168,11 +168,11 @@ export interface TestAppServerOptions {
|
|
|
168
168
|
session_options: SessionOptions<string>;
|
|
169
169
|
/** Existing database — skips internal DB creation when provided. Caller owns the DB lifecycle. */
|
|
170
170
|
db?: Db;
|
|
171
|
-
/** Database driver type — only used when `db` is provided. Default: `'
|
|
171
|
+
/** Database driver type — only used when `db` is provided. Default: `'pglet-memory'`. */
|
|
172
172
|
db_type?: DbType;
|
|
173
173
|
/**
|
|
174
174
|
* Extra migration namespaces run after the builtin auth namespace in the
|
|
175
|
-
* auto-created in-memory
|
|
175
|
+
* auto-created in-memory database, mirroring `create_app_backend`'s
|
|
176
176
|
* `migration_namespaces`. For suites whose backend needs tables beyond
|
|
177
177
|
* auth — the cell parity suite passes `[CELL_MIGRATION_NS]`. The harness
|
|
178
178
|
* builds + caches a fresh-per-test factory migrating
|
|
@@ -209,7 +209,7 @@ export interface TestAppServerOptions {
|
|
|
209
209
|
* Create an app server with a bootstrapped account for testing.
|
|
210
210
|
*
|
|
211
211
|
* Sets up:
|
|
212
|
-
* - Auth tables (via cached
|
|
212
|
+
* - Auth tables (via the cached default factory, or reuses existing `db`)
|
|
213
213
|
* - A keeper account with hashed password
|
|
214
214
|
* - Role role_grants for each role in `options.roles`
|
|
215
215
|
* - An API token for Bearer auth
|
|
@@ -348,7 +348,7 @@ export declare const create_loopback_app_server_options: () => Pick<AppServerOpt
|
|
|
348
348
|
*
|
|
349
349
|
* A fresh Hono app is created each call — middleware closures bind to the
|
|
350
350
|
* server's deps (db, keyring), so reuse across servers is unsafe.
|
|
351
|
-
* The expensive resource (
|
|
351
|
+
* The expensive resource (the WASM database) is cached separately in `testing/db.ts`.
|
|
352
352
|
*
|
|
353
353
|
* @param options - test app configuration
|
|
354
354
|
* @returns a `TestApp` ready for HTTP testing
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app_server.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/app_server.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAE7B;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,IA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AE,CAAC,EAAE,EAAE,CAAC;IACR,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAC5B,aAAa,CAAC,EAAE,YAAY,CAAC;CAC7B;AAED;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IACnC,GAAG,EAAE,IAAI,CAAC;IACV,OAAO,EAAE,UAAU,CAAC;IACpB,mHAAmH;IACnH,MAAM,EAAE,SAAS,CAAC;IAClB,YAAY,EAAE,cAAc,CAAC;IAC7B,OAAO,EAAE,UAAU,CAAC;IACpB,WAAW,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;IAC9B,0EAA0E;IAC1E,sBAAsB,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnF,yJAAyJ;IACzJ,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,6BAA6B,GACzC,SAAS,gCAAgC,KACvC,OAAO,CAAC,mBAAmB,CAqE7B,CAAC"}
|
|
@@ -16,7 +16,7 @@ import { create_realtime_closer } from '../actions/connection_closer.js';
|
|
|
16
16
|
import { default_audit_factory } from '../server/app_backend.js';
|
|
17
17
|
import { create_app_server } from '../server/app_server.js';
|
|
18
18
|
import { generate_daemon_token, DAEMON_TOKEN_HEADER } from '../auth/daemon_token.js';
|
|
19
|
-
import {
|
|
19
|
+
import { create_default_db_factory } from './db.js';
|
|
20
20
|
import { token_scope_full } from '../auth/token_scope.js';
|
|
21
21
|
/**
|
|
22
22
|
* Fast password stub for tests that don't exercise login/password flows.
|
|
@@ -31,21 +31,22 @@ export const stub_password_deps = {
|
|
|
31
31
|
};
|
|
32
32
|
/** 64-hex-char test cookie secret — deterministic, never used in production. */
|
|
33
33
|
export const TEST_COOKIE_SECRET = 'a'.repeat(64);
|
|
34
|
-
// Module-level
|
|
35
|
-
//
|
|
36
|
-
//
|
|
37
|
-
|
|
34
|
+
// Module-level default factory (pglet-wasm unless `set_default_db_factory` installed
|
|
35
|
+
// another) for create_test_app_server when no db is provided. Shares the WASM instance
|
|
36
|
+
// cache from `testing/db.ts`, avoiding redundant cold starts within one loaded copy of
|
|
37
|
+
// that module. Schema is reset on each create() call.
|
|
38
|
+
const fallback_db_factory = create_default_db_factory(async (db) => {
|
|
38
39
|
await run_migrations(db, [auth_migration_ns]);
|
|
39
40
|
});
|
|
40
|
-
// Auto-created
|
|
41
|
+
// Auto-created default factories keyed by extra-namespace identity. Suites
|
|
41
42
|
// whose backend needs tables beyond auth (e.g. the cell layer) share one
|
|
42
43
|
// factory per distinct namespace set — and the worker-cached WASM instance —
|
|
43
44
|
// rather than each hand-building its own. The cell parity suite is the first
|
|
44
45
|
// user.
|
|
45
46
|
const fallback_factories_by_namespaces = new Map();
|
|
46
47
|
/**
|
|
47
|
-
* Resolve the no-`db`
|
|
48
|
-
* namespaces. Empty / omitted → the shared auth-only `
|
|
48
|
+
* Resolve the no-`db` default factory for the requested extra migration
|
|
49
|
+
* namespaces. Empty / omitted → the shared auth-only `fallback_db_factory`;
|
|
49
50
|
* otherwise a memoized factory whose `init` runs
|
|
50
51
|
* `[auth_migration_ns, ...migration_namespaces]` on each reset. The
|
|
51
52
|
* reset-on-`create` gives the same fresh-db-per-test isolation as the
|
|
@@ -54,12 +55,12 @@ const fallback_factories_by_namespaces = new Map();
|
|
|
54
55
|
*/
|
|
55
56
|
const resolve_fallback_factory = (migration_namespaces) => {
|
|
56
57
|
if (!migration_namespaces || migration_namespaces.length === 0) {
|
|
57
|
-
return
|
|
58
|
+
return fallback_db_factory;
|
|
58
59
|
}
|
|
59
60
|
const key = migration_namespaces.map((ns) => ns.namespace).join(',');
|
|
60
61
|
let factory = fallback_factories_by_namespaces.get(key);
|
|
61
62
|
if (!factory) {
|
|
62
|
-
factory =
|
|
63
|
+
factory = create_default_db_factory(async (db) => {
|
|
63
64
|
await run_migrations(db, [auth_migration_ns, ...migration_namespaces]);
|
|
64
65
|
});
|
|
65
66
|
fallback_factories_by_namespaces.set(key, factory);
|
|
@@ -176,7 +177,7 @@ const default_test_fs_stubs = {
|
|
|
176
177
|
* resets it to false before this runs).
|
|
177
178
|
*/
|
|
178
179
|
const _build_test_backend = async (options) => {
|
|
179
|
-
const { db: existing_db, db_type = '
|
|
180
|
+
const { db: existing_db, db_type = 'pglet-memory', password = stub_password_deps, audit_factory = default_audit_factory, fs_stubs = default_test_fs_stubs, migration_namespaces } = options;
|
|
180
181
|
if (existing_db && migration_namespaces && migration_namespaces.length > 0) {
|
|
181
182
|
throw new Error('test app setup: pass either `db` (caller owns migrations) or `migration_namespaces` ' +
|
|
182
183
|
'(harness migrates), not both');
|
|
@@ -188,14 +189,14 @@ const _build_test_backend = async (options) => {
|
|
|
188
189
|
let db;
|
|
189
190
|
let db_name;
|
|
190
191
|
if (existing_db) {
|
|
191
|
-
// Reset singleton config row from a previous test (harmless on fresh
|
|
192
|
+
// Reset singleton config row from a previous test (harmless on a fresh database).
|
|
192
193
|
await existing_db.query('UPDATE app_settings SET open_signup = false, updated_at = NULL, updated_by = NULL WHERE open_signup = true OR updated_at IS NOT NULL');
|
|
193
194
|
db = existing_db;
|
|
194
195
|
db_name = 'test';
|
|
195
196
|
}
|
|
196
197
|
else {
|
|
197
|
-
// In-memory
|
|
198
|
-
// instead of creating a new
|
|
198
|
+
// In-memory default driver via cached factory — reuses the WASM instance from
|
|
199
|
+
// `testing/db.ts` instead of creating a new instance each time. Schema is reset and migrations re-run
|
|
199
200
|
// on each call, but the expensive WASM cold start only happens once per loaded
|
|
200
201
|
// copy of `testing/db.ts` — under the `db` project's `isolate: false` +
|
|
201
202
|
// `fileParallelism: false` that is once for the whole run.
|
|
@@ -205,11 +206,11 @@ const _build_test_backend = async (options) => {
|
|
|
205
206
|
}
|
|
206
207
|
const backend = {
|
|
207
208
|
// a supplied `db` reports the caller's `db_type`; the auto-created one names
|
|
208
|
-
//
|
|
209
|
-
// (`
|
|
209
|
+
// pglet unconditionally — a run that installs another default factory
|
|
210
|
+
// (`set_default_db_factory`) before this module loads gets that driver
|
|
210
211
|
// here, and no caller reads this field to pick behavior: it is reported,
|
|
211
212
|
// not dispatched on
|
|
212
|
-
db_type: existing_db ? db_type : '
|
|
213
|
+
db_type: existing_db ? db_type : 'pglet-memory',
|
|
213
214
|
db_name,
|
|
214
215
|
// the factory's init ran the migrations, for a supplied `db` and the auto-created one alike
|
|
215
216
|
migration_results: [],
|
|
@@ -230,7 +231,7 @@ const _build_test_backend = async (options) => {
|
|
|
230
231
|
* Create an app server with a bootstrapped account for testing.
|
|
231
232
|
*
|
|
232
233
|
* Sets up:
|
|
233
|
-
* - Auth tables (via cached
|
|
234
|
+
* - Auth tables (via the cached default factory, or reuses existing `db`)
|
|
234
235
|
* - A keeper account with hashed password
|
|
235
236
|
* - Role role_grants for each role in `options.roles`
|
|
236
237
|
* - An API token for Bearer auth
|
|
@@ -310,7 +311,7 @@ const create_bearer_headers_builder = (api_token) => (extra) => ({
|
|
|
310
311
|
*
|
|
311
312
|
* A fresh Hono app is created each call — middleware closures bind to the
|
|
312
313
|
* server's deps (db, keyring), so reuse across servers is unsafe.
|
|
313
|
-
* The expensive resource (
|
|
314
|
+
* The expensive resource (the WASM database) is cached separately in `testing/db.ts`.
|
|
314
315
|
*
|
|
315
316
|
* @param options - test app configuration
|
|
316
317
|
* @returns a `TestApp` ready for HTTP testing
|
|
@@ -408,7 +409,7 @@ export const create_test_app_for_bootstrap = async (options) => {
|
|
|
408
409
|
const { session_options, bootstrap, bootstrap_token } = options;
|
|
409
410
|
// Caller-supplied DB may carry lock state from a prior test — reset to false
|
|
410
411
|
// before `_build_test_backend` runs (which doesn't touch the lock itself).
|
|
411
|
-
//
|
|
412
|
+
// A fresh database already starts at false (factory init).
|
|
412
413
|
if (options.db) {
|
|
413
414
|
await options.db.query('UPDATE bootstrap_lock SET bootstrapped = false WHERE bootstrapped = true');
|
|
414
415
|
}
|
|
@@ -11,11 +11,11 @@ import '../assert_dev_env.js';
|
|
|
11
11
|
*
|
|
12
12
|
* Defaults baked in by family:
|
|
13
13
|
*
|
|
14
|
-
* - **TS** — `'memory://'`
|
|
14
|
+
* - **TS** — `'memory://'` (in-memory pglet), 30s startup window. Its shape notes
|
|
15
15
|
* (`ts_default_shape_notes`) record `trusted_proxy: false` /
|
|
16
16
|
* `login_rate_limit: false` — the TS canonical path leaves those limiters
|
|
17
17
|
* null in test mode.
|
|
18
|
-
* - **Rust** — caller-supplied real Postgres URL (
|
|
18
|
+
* - **Rust** — caller-supplied real Postgres URL (an in-process WASM database isn't reachable
|
|
19
19
|
* from `tokio-postgres`), 120s startup window (cargo first-build cost), the
|
|
20
20
|
* `FUZ_TESTING_RESET_DB_ON_STARTUP=true` self-wipe gate, and shape notes
|
|
21
21
|
* (`rust_default_shape_notes`) recording `trusted_proxy: true` +
|
|
@@ -82,7 +82,7 @@ export interface MakeDefaultTsBackendConfigOptions {
|
|
|
82
82
|
readonly port: number;
|
|
83
83
|
/** argv passed to the spawn (first entry is the binary). */
|
|
84
84
|
readonly start_command: ReadonlyArray<string>;
|
|
85
|
-
/** Defaults to `'memory://'` (in-memory
|
|
85
|
+
/** Defaults to `'memory://'` (in-memory pglet). */
|
|
86
86
|
readonly database_url?: string;
|
|
87
87
|
/** Merged on top of the generic env baseline; later keys win. */
|
|
88
88
|
readonly extra_env?: Readonly<Record<string, string>>;
|
|
@@ -109,7 +109,7 @@ export interface MakeDefaultTsBackendConfigOptions {
|
|
|
109
109
|
}
|
|
110
110
|
/**
|
|
111
111
|
* Shared builder for TS-family backends (Deno + Node). Owns the common
|
|
112
|
-
* env baseline (NODE_ENV, HOST, PORT, in-memory
|
|
112
|
+
* env baseline (NODE_ENV, HOST, PORT, in-memory pglet, cookie keys,
|
|
113
113
|
* bootstrap token path) so per-backend factories only declare what
|
|
114
114
|
* genuinely differs.
|
|
115
115
|
*/
|
|
@@ -122,7 +122,7 @@ export interface MakeDefaultRustBackendConfigOptions {
|
|
|
122
122
|
/** argv passed to the spawn (first entry is the binary). */
|
|
123
123
|
readonly start_command: ReadonlyArray<string>;
|
|
124
124
|
/**
|
|
125
|
-
* Required — Rust needs real Postgres (
|
|
125
|
+
* Required — Rust needs real Postgres (an in-process WASM database isn't reachable from
|
|
126
126
|
* `tokio-postgres`). Consumers typically supply
|
|
127
127
|
* `'postgres://localhost/{repo}_test_{name}'`.
|
|
128
128
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default_backend_configs.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/default_backend_configs.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAE9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACjF,OAAO,KAAK,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAChF,OAAO,EAA4B,KAAK,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAYhG,2CAA2C;AAC3C,MAAM,WAAW,yBAAyB;IACzC,QAAQ,CAAC,wBAAwB,CAAC,EAAE,OAAO,CAAC;IAC5C,QAAQ,CAAC,8BAA8B,CAAC,EAAE,MAAM,CAAC;CACjD;AAED;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,GACjC,SAAS,yBAAyB,KAChC,MAAM,CAAC,MAAM,EAAE,MAAM,CAKtB,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,EAAE,mBAsCpC,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,EAAE,mBAgCtC,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,EAAE,iBAInC,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,EAAE,iBAIrC,CAAC;AAeH,MAAM,WAAW,iCAAiC;IACjD,gFAAgF;IAChF,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,sCAAsC;IACtC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,4DAA4D;IAC5D,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC9C,
|
|
1
|
+
{"version":3,"file":"default_backend_configs.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/default_backend_configs.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAE9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACjF,OAAO,KAAK,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAChF,OAAO,EAA4B,KAAK,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAYhG,2CAA2C;AAC3C,MAAM,WAAW,yBAAyB;IACzC,QAAQ,CAAC,wBAAwB,CAAC,EAAE,OAAO,CAAC;IAC5C,QAAQ,CAAC,8BAA8B,CAAC,EAAE,MAAM,CAAC;CACjD;AAED;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,GACjC,SAAS,yBAAyB,KAChC,MAAM,CAAC,MAAM,EAAE,MAAM,CAKtB,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,EAAE,mBAsCpC,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,EAAE,mBAgCtC,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,EAAE,iBAInC,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,EAAE,iBAIrC,CAAC;AAeH,MAAM,WAAW,iCAAiC;IACjD,gFAAgF;IAChF,QAAQ,CAAC,IAAI,EAA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AC5C,wEAAwE;IACxE,QAAQ,CAAC,KAAK,CAAC,EAAE,gBAAgB,CAAC;IAClC,sEAAsE;IACtE,QAAQ,CAAC,mBAAmB,CAAC,EAAE,OAAO,CAAC,sBAAsB,CAAC,CAAC;IAC/D;;;;OAIG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B;;;OAGG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED;;;;;GAKG;AACH,eAAO,MAAM,gCAAgC,GAC5C,MAAM,mCAAmC,KACvC,aA4CF,CAAC"}
|
|
@@ -131,7 +131,7 @@ const build_default_bootstrap = (paths, overrides) => ({
|
|
|
131
131
|
});
|
|
132
132
|
/**
|
|
133
133
|
* Shared builder for TS-family backends (Deno + Node). Owns the common
|
|
134
|
-
* env baseline (NODE_ENV, HOST, PORT, in-memory
|
|
134
|
+
* env baseline (NODE_ENV, HOST, PORT, in-memory pglet, cookie keys,
|
|
135
135
|
* bootstrap token path) so per-backend factories only declare what
|
|
136
136
|
* genuinely differs.
|
|
137
137
|
*/
|
|
@@ -44,8 +44,8 @@ export interface InProcessSetupOptions extends CreateTestAppOptions {
|
|
|
44
44
|
* `_testing_reset` cradle so suite bodies read
|
|
45
45
|
* `fixture.extra_accounts[username]` uniformly regardless of transport.
|
|
46
46
|
*
|
|
47
|
-
* The describe-level `auth_integration_truncate_tables` /
|
|
48
|
-
* cache lifecycle stays in `
|
|
47
|
+
* The describe-level `auth_integration_truncate_tables` / WASM database
|
|
48
|
+
* cache lifecycle stays in `create_default_db_factory` / `create_describe_db`
|
|
49
49
|
* (`testing/db.ts`) — `default_in_process_setup` doesn't manage db state
|
|
50
50
|
* beyond what `create_test_app` already does.
|
|
51
51
|
*/
|
|
@@ -32,14 +32,14 @@ const in_process_fetch_transport = (app) => {
|
|
|
32
32
|
* `_testing_reset` cradle so suite bodies read
|
|
33
33
|
* `fixture.extra_accounts[username]` uniformly regardless of transport.
|
|
34
34
|
*
|
|
35
|
-
* The describe-level `auth_integration_truncate_tables` /
|
|
36
|
-
* cache lifecycle stays in `
|
|
35
|
+
* The describe-level `auth_integration_truncate_tables` / WASM database
|
|
36
|
+
* cache lifecycle stays in `create_default_db_factory` / `create_describe_db`
|
|
37
37
|
* (`testing/db.ts`) — `default_in_process_setup` doesn't manage db state
|
|
38
38
|
* beyond what `create_test_app` already does.
|
|
39
39
|
*/
|
|
40
40
|
export const default_in_process_setup = (options) => async () => {
|
|
41
41
|
// Per-test fresh db. When `options.migration_namespaces` is set,
|
|
42
|
-
// `create_test_app` provisions an auth+extras
|
|
42
|
+
// `create_test_app` provisions an auth+extras database (e.g. the cell
|
|
43
43
|
// layer); otherwise the auth-only default. Either way the factory
|
|
44
44
|
// resets + re-migrates on each `create`, so the per-test keeper
|
|
45
45
|
// bootstrap below lands on a clean DB.
|
|
@@ -18,7 +18,7 @@ import '../assert_dev_env.js';
|
|
|
18
18
|
* admits with the entry's `moderation_required` folded into the verdict. The
|
|
19
19
|
* root's `data` arrives in `input.root_data` (the handler read it in-tx), so
|
|
20
20
|
* the predicate is **pure** — no DB read of its own (which also dodges the
|
|
21
|
-
* single-connection
|
|
21
|
+
* single-connection in-memory deadlock a separate handle would hit — pglet, PGlite).
|
|
22
22
|
*
|
|
23
23
|
* @module
|
|
24
24
|
*/
|
|
@@ -482,8 +482,8 @@ export interface CreateTestingActionsOptions {
|
|
|
482
482
|
* Consumer-supplied callback invoked after the auth-table reset, passed
|
|
483
483
|
* the same transactional `Db` the auth wipes ran on. DB-domain consumers
|
|
484
484
|
* (e.g. fuz_forge truncating its cell / fact / file tables) MUST use this
|
|
485
|
-
* `db` rather than a separately-pooled connection — under
|
|
486
|
-
* connection a second connection deadlocks against this still-open
|
|
485
|
+
* `db` rather than a separately-pooled connection — under the in-memory
|
|
486
|
+
* drivers' single connection (pglet, PGlite) a second connection deadlocks against this still-open
|
|
487
487
|
* transaction. `testing_zzz_server` clears in-memory workspace registry +
|
|
488
488
|
* terminals + scoped-FS scratch (ignores `db`); `testing_spine_stub` has
|
|
489
489
|
* no domain layer and omits the option. Runs inside the same RPC dispatch
|
|
@@ -527,7 +527,7 @@ export const create_testing_actions = (deps, options) => {
|
|
|
527
527
|
// fuz_forge cell/fact/file truncation, or no-op for spine_stub).
|
|
528
528
|
// Pass the transactional `ctx.db` so DB-domain truncation runs
|
|
529
529
|
// on the same connection — a separate pool connection deadlocks
|
|
530
|
-
// against this open transaction under
|
|
530
|
+
// against this open transaction under the in-memory drivers.
|
|
531
531
|
if (reset_state)
|
|
532
532
|
await reset_state(ctx.db);
|
|
533
533
|
return { ...keeper, extra_accounts: extras, extra_actors };
|
|
@@ -7,7 +7,7 @@ import '../assert_dev_env.js';
|
|
|
7
7
|
* these spawn fuz_app's own TS impl over real HTTP with no domain layer, so
|
|
8
8
|
* the `cross_backend_ts_node` / `cross_backend_ts_deno` / `cross_backend_ts_bun`
|
|
9
9
|
* self-test projects verify fuz_app's wire path in its own repo across all
|
|
10
|
-
* three JS runtimes. All run against in-memory
|
|
10
|
+
* three JS runtimes. All run against in-memory pglet (`memory://`) — no
|
|
11
11
|
* external Postgres, unlike the Rust path.
|
|
12
12
|
*
|
|
13
13
|
* The binary writes its daemon token to `{FUZ_TESTING_TS_SPINE_DIR}/run/daemon_token`;
|
|
@@ -32,7 +32,7 @@ export declare const TS_SPINE_BUN_ENTRY = "src/test/cross_backend/testing_spine_
|
|
|
32
32
|
export interface TsSpineBackendConfigOptions {
|
|
33
33
|
/** Listening port. Defaults per runtime (`1178` Node, `1179` Deno, `1180` Bun). */
|
|
34
34
|
readonly port?: number;
|
|
35
|
-
/** Database URL. Default `'memory://'` (in-memory
|
|
35
|
+
/** Database URL. Default `'memory://'` (in-memory pglet). */
|
|
36
36
|
readonly database_url?: string;
|
|
37
37
|
/**
|
|
38
38
|
* Enable the per-IP + per-account login rate limiters on the spawned binary
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ts_spine_backend_config.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/ts_spine_backend_config.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAE9B;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAsDzD,6FAA6F;AAC7F,eAAO,MAAM,0BAA0B,OAAO,CAAC;AAE/C,iDAAiD;AACjD,eAAO,MAAM,0BAA0B,OAAO,CAAC;AAE/C,gDAAgD;AAChD,eAAO,MAAM,yBAAyB,OAAO,CAAC;AAE9C,yDAAyD;AACzD,eAAO,MAAM,mBAAmB,wDAAwD,CAAC;AAEzF,yDAAyD;AACzD,eAAO,MAAM,mBAAmB,wDAAwD,CAAC;AAEzF,wDAAwD;AACxD,eAAO,MAAM,kBAAkB,uDAAuD,CAAC;AAEvF,MAAM,WAAW,2BAA2B;IAC3C,mFAAmF;IACnF,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,
|
|
1
|
+
{"version":3,"file":"ts_spine_backend_config.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/ts_spine_backend_config.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAE9B;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAsDzD,6FAA6F;AAC7F,eAAO,MAAM,0BAA0B,OAAO,CAAC;AAE/C,iDAAiD;AACjD,eAAO,MAAM,0BAA0B,OAAO,CAAC;AAE/C,gDAAgD;AAChD,eAAO,MAAM,yBAAyB,OAAO,CAAC;AAE9C,yDAAyD;AACzD,eAAO,MAAM,mBAAmB,wDAAwD,CAAC;AAEzF,yDAAyD;AACzD,eAAO,MAAM,mBAAmB,wDAAwD,CAAC;AAEzF,wDAAwD;AACxD,eAAO,MAAM,kBAAkB,uDAAuD,CAAC;AAEvF,MAAM,WAAW,2BAA2B;IAC3C,mFAAmF;IACnF,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,6DAA6D;IAC7D,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B;;;;;;;;;OASG;IACH,QAAQ,CAAC,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAC3C;;;;;;OAMG;IACH,QAAQ,CAAC,wBAAwB,CAAC,EAAE,OAAO,CAAC;IAC5C;;;;;OAKG;IACH,QAAQ,CAAC,8BAA8B,CAAC,EAAE,MAAM,CAAC;CACjD;AAWD;;;GAGG;AACH,eAAO,MAAM,4BAA4B,GACxC,UAAS,2BAAgC,KACvC,aAoBF,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,2BAA2B,GACvC,UAAS,2BAAgC,KACvC,aAoBF,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,4BAA4B,GACxC,UAAS,2BAAgC,KACvC,aAiCF,CAAC"}
|