viborm 1.3.0 → 1.3.2
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/{adapter-namespace-BpMbLKpL.mjs → adapter-namespace-B8XWzCev.mjs} +1 -1
- package/dist/{adapter-namespace-BpMbLKpL.mjs.map → adapter-namespace-B8XWzCev.mjs.map} +1 -1
- package/dist/adapters.d.mts +1 -1
- package/dist/adapters.mjs +1 -1
- package/dist/{batch-refs-B4zn-FAu.mjs → batch-refs-DoWlPD2h.mjs} +1 -1
- package/dist/{batch-refs-B4zn-FAu.mjs.map → batch-refs-DoWlPD2h.mjs.map} +1 -1
- package/dist/{builder-Df24l2Bd.mjs → builder-DhxaVYP2.mjs} +2 -2
- package/dist/{builder-Df24l2Bd.mjs.map → builder-DhxaVYP2.mjs.map} +1 -1
- package/dist/bun-sql.d.mts +1 -1
- package/dist/bun-sql.mjs +1 -1
- package/dist/bun-sqlite.d.mts +1 -1
- package/dist/bun-sqlite.mjs +1 -1
- package/dist/cache/cloudflare-kv.d.mts +1 -1
- package/dist/cache/cloudflare-kv.mjs +1 -1
- package/dist/cache/memory.d.mts +1 -1
- package/dist/cache/memory.mjs +1 -1
- package/dist/cache.d.mts +1 -1
- package/dist/cache.mjs +1 -1
- package/dist/cache.mjs.map +1 -1
- package/dist/chain-BjJ_M7EE.mjs +2 -0
- package/dist/chain-BjJ_M7EE.mjs.map +1 -0
- package/dist/cli.mjs +1 -1
- package/dist/client-BCgMXn6N.mjs +2 -0
- package/dist/client-BCgMXn6N.mjs.map +1 -0
- package/dist/{client-70MrTq1E.d.mts → client-Df81J4oB.d.mts} +1 -1
- package/dist/{client-DM1UHfYG.mjs → client-q6ccRgdO.mjs} +2 -2
- package/dist/{client-DM1UHfYG.mjs.map → client-q6ccRgdO.mjs.map} +1 -1
- package/dist/client.d.mts +1 -1
- package/dist/client.mjs +1 -1
- package/dist/{clock-C24RcpwO.mjs → clock-YTLtjLFS.mjs} +1 -1
- package/dist/{clock-C24RcpwO.mjs.map → clock-YTLtjLFS.mjs.map} +1 -1
- package/dist/config.d.mts +1 -1
- package/dist/config.mjs +1 -1
- package/dist/d1.d.mts +1 -1
- package/dist/d1.mjs +1 -1
- package/dist/{driver-CPD0Xxw2.mjs → driver-D6_Ik58x.mjs} +2 -2
- package/dist/{driver-CPD0Xxw2.mjs.map → driver-D6_Ik58x.mjs.map} +1 -1
- package/dist/{driver-B9fIori_.mjs → driver-Ddt147dK.mjs} +2 -2
- package/dist/{driver-B9fIori_.mjs.map → driver-Ddt147dK.mjs.map} +1 -1
- package/dist/driver.d.mts +1 -1
- package/dist/driver.mjs +1 -1
- package/dist/every-dpzVDwzu.mjs +2 -0
- package/dist/{every-1pKZteeB.mjs.map → every-dpzVDwzu.mjs.map} +1 -1
- package/dist/{fs-estate-i8Zlr1OQ.mjs → fs-estate-azK36i9V.mjs} +2 -2
- package/dist/{fs-estate-i8Zlr1OQ.mjs.map → fs-estate-azK36i9V.mjs.map} +1 -1
- package/dist/{hydration-DsyHNSDS.mjs → hydration-C2uXmJy6.mjs} +2 -2
- package/dist/{hydration-DsyHNSDS.mjs.map → hydration-C2uXmJy6.mjs.map} +1 -1
- package/dist/{identifier-conversion-DaZ9yNpv.mjs → identifier-conversion-C2pwwFOS.mjs} +2 -2
- package/dist/{identifier-conversion-DaZ9yNpv.mjs.map → identifier-conversion-C2pwwFOS.mjs.map} +1 -1
- package/dist/identity-Bj2EN6Ss.mjs +2 -0
- package/dist/identity-Bj2EN6Ss.mjs.map +1 -0
- package/dist/{index-VsM29vYN.d.mts → index-D4O0Twvs.d.mts} +16 -8
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/instrumentation.d.mts +1 -1
- package/dist/instrumentation.mjs +1 -1
- package/dist/{key-D_kagnFv.mjs → key-B7vuAYPG.mjs} +2 -2
- package/dist/{key-D_kagnFv.mjs.map → key-B7vuAYPG.mjs.map} +1 -1
- package/dist/{libsql-DFAoHXrI.mjs → libsql-DUO6vHad.mjs} +2 -2
- package/dist/{libsql-DFAoHXrI.mjs.map → libsql-DUO6vHad.mjs.map} +1 -1
- package/dist/libsql.d.mts +1 -1
- package/dist/libsql.mjs +1 -1
- package/dist/{memory-GTWgeDNY.mjs → memory-BApsTkt1.mjs} +2 -2
- package/dist/{memory-GTWgeDNY.mjs.map → memory-BApsTkt1.mjs.map} +1 -1
- package/dist/migrations/mysql.d.mts +4 -4
- package/dist/migrations/mysql.mjs +1 -1
- package/dist/migrations/postgres.d.mts +4 -4
- package/dist/migrations/postgres.mjs +1 -1
- package/dist/migrations/sqlite.d.mts +4 -4
- package/dist/migrations/sqlite.mjs +1 -1
- package/dist/migrations/storage/durable-object.mjs +1 -1
- package/dist/migrations/storage/fs.mjs +1 -1
- package/dist/migrations/storage/r2.mjs +1 -1
- package/dist/migrations/tenant.d.mts +2 -2
- package/dist/migrations/tenant.mjs +1 -1
- package/dist/migrations.d.mts +4 -4
- package/dist/migrations.mjs +1 -1
- package/dist/{mysql-xChEivOe.mjs → mysql-D1GlcktG.mjs} +2 -2
- package/dist/{mysql-xChEivOe.mjs.map → mysql-D1GlcktG.mjs.map} +1 -1
- package/dist/{mysql-adapter-C6c5govr.mjs → mysql-adapter-ClOoHKpn.mjs} +2 -2
- package/dist/{mysql-adapter-C6c5govr.mjs.map → mysql-adapter-ClOoHKpn.mjs.map} +1 -1
- package/dist/mysql2.d.mts +1 -1
- package/dist/mysql2.mjs +1 -1
- package/dist/neon-http.d.mts +1 -1
- package/dist/neon-http.mjs +1 -1
- package/dist/{object-store-D9mvOHP4.d.mts → object-store-BN64q8Zn.d.mts} +3 -3
- package/dist/{object-store-ChYHlOMD.mjs → object-store-CZADAv4c.mjs} +2 -2
- package/dist/{object-store-ChYHlOMD.mjs.map → object-store-CZADAv4c.mjs.map} +1 -1
- package/dist/permissions.d.mts +2 -2
- package/dist/permissions.mjs +1 -1
- package/dist/permissions.mjs.map +1 -1
- package/dist/pg.d.mts +1 -1
- package/dist/pg.mjs +1 -1
- package/dist/pglite.d.mts +1 -1
- package/dist/pglite.mjs +1 -1
- package/dist/{pinned-session-BTplL3iZ.mjs → pinned-session-CjvR0Ge2.mjs} +2 -2
- package/dist/{pinned-session-BTplL3iZ.mjs.map → pinned-session-CjvR0Ge2.mjs.map} +1 -1
- package/dist/planetscale.d.mts +1 -1
- package/dist/planetscale.mjs +1 -1
- package/dist/{planner-C1NzLBge.d.mts → planner-8smxUOt9.d.mts} +1 -1
- package/dist/{postgres-BqAxDWTQ.mjs → postgres-Be0jMJWI.mjs} +2 -2
- package/dist/{postgres-BqAxDWTQ.mjs.map → postgres-Be0jMJWI.mjs.map} +1 -1
- package/dist/{postgres-adapter-CxEit2-v.mjs → postgres-adapter-BoQ4RRwr.mjs} +2 -2
- package/dist/{postgres-adapter-CxEit2-v.mjs.map → postgres-adapter-BoQ4RRwr.mjs.map} +1 -1
- package/dist/{postgres-adapter-CGthb5yh.mjs → postgres-adapter-C_Mt8lVC.mjs} +2 -2
- package/dist/{postgres-adapter-CGthb5yh.mjs.map → postgres-adapter-C_Mt8lVC.mjs.map} +1 -1
- package/dist/{postgres-result-KyBKBNJr.mjs → postgres-result-CYu1dyI_.mjs} +1 -1
- package/dist/{postgres-result-KyBKBNJr.mjs.map → postgres-result-CYu1dyI_.mjs.map} +1 -1
- package/dist/postgres.d.mts +1 -1
- package/dist/postgres.mjs +1 -1
- package/dist/result-shape-DQc-tDJ5.mjs +2 -0
- package/dist/{result-shape-CDgX_vzn.mjs.map → result-shape-DQc-tDJ5.mjs.map} +1 -1
- package/dist/rows-JXjhWwyb.mjs +2 -0
- package/dist/rows-JXjhWwyb.mjs.map +1 -0
- package/dist/{scalar-S8yMvdmx.mjs → scalar-CqqZ6jWd.mjs} +2 -2
- package/dist/{scalar-S8yMvdmx.mjs.map → scalar-CqqZ6jWd.mjs.map} +1 -1
- package/dist/schema/json.d.mts +1 -1
- package/dist/schema/json.mjs +1 -1
- package/dist/{schema-9N9jQlVL.mjs → schema-Cv-hhpl5.mjs} +2 -2
- package/dist/{schema-9N9jQlVL.mjs.map → schema-Cv-hhpl5.mjs.map} +1 -1
- package/dist/{schema-introspection-CyXKReK1.mjs → schema-introspection-B2Rvqgut.mjs} +3 -3
- package/dist/{schema-introspection-CyXKReK1.mjs.map → schema-introspection-B2Rvqgut.mjs.map} +1 -1
- package/dist/schema.d.mts +1 -1
- package/dist/schema.mjs +1 -1
- package/dist/{select-assembly-CkGe2ABs.mjs → select-assembly-BxtETbG9.mjs} +1 -1
- package/dist/{select-assembly-CkGe2ABs.mjs.map → select-assembly-BxtETbG9.mjs.map} +1 -1
- package/dist/{settle-CS_k6Ztm.mjs → settle-etgtP1WM.mjs} +2 -2
- package/dist/{settle-CS_k6Ztm.mjs.map → settle-etgtP1WM.mjs.map} +1 -1
- package/dist/sha256-CEYo7k7R.mjs +2 -0
- package/dist/sha256-CEYo7k7R.mjs.map +1 -0
- package/dist/soft-delete.d.mts +1 -1
- package/dist/{sql-statement-tokens-CFi1y3bK.mjs → sql-statement-tokens-BW7Q-rF-.mjs} +1 -1
- package/dist/{sql-statement-tokens-CFi1y3bK.mjs.map → sql-statement-tokens-BW7Q-rF-.mjs.map} +1 -1
- package/dist/{sqlite-adapter-BXAJy3mI.mjs → sqlite-adapter-B_LNxPA0.mjs} +2 -2
- package/dist/{sqlite-adapter-BXAJy3mI.mjs.map → sqlite-adapter-B_LNxPA0.mjs.map} +1 -1
- package/dist/{sqlite-utils-D_cypcyW.mjs → sqlite-utils-DIOll4P7.mjs} +1 -1
- package/dist/{sqlite-utils-D_cypcyW.mjs.map → sqlite-utils-DIOll4P7.mjs.map} +1 -1
- package/dist/sqlite3.d.mts +1 -1
- package/dist/sqlite3.mjs +1 -1
- package/dist/{standard-sql-CoGqv-iX.mjs → standard-sql-mJt0RHHE.mjs} +1 -1
- package/dist/{standard-sql-CoGqv-iX.mjs.map → standard-sql-mJt0RHHE.mjs.map} +1 -1
- package/dist/{to-many-C1PuFIpf.mjs → to-many-BSipkSbK.mjs} +2 -2
- package/dist/{to-many-C1PuFIpf.mjs.map → to-many-BSipkSbK.mjs.map} +1 -1
- package/dist/{utils-CtFUE8UN.mjs → utils-DjXObbUK.mjs} +2 -2
- package/dist/{utils-CtFUE8UN.mjs.map → utils-DjXObbUK.mjs.map} +1 -1
- package/dist/v-CrJYqdzu.mjs +2 -0
- package/dist/v-CrJYqdzu.mjs.map +1 -0
- package/dist/validation.d.mts +1 -1
- package/dist/validation.mjs +1 -1
- package/dist/{validator-DgffZq9C.mjs → validator-BqzpyNmt.mjs} +2 -2
- package/dist/{validator-DgffZq9C.mjs.map → validator-BqzpyNmt.mjs.map} +1 -1
- package/dist/version-Dus3if78.mjs +2 -0
- package/dist/{version-CXuJzC-q.mjs.map → version-Dus3if78.mjs.map} +1 -1
- package/package.json +16 -15
- package/dist/chain-C7c1YTXD.mjs +0 -2
- package/dist/chain-C7c1YTXD.mjs.map +0 -1
- package/dist/client-_WKrPNmm.mjs +0 -2
- package/dist/client-_WKrPNmm.mjs.map +0 -1
- package/dist/controls-Da-efekX.mjs +0 -2
- package/dist/controls-Da-efekX.mjs.map +0 -1
- package/dist/every-1pKZteeB.mjs +0 -2
- package/dist/identity-oQvIe7u8.mjs +0 -2
- package/dist/identity-oQvIe7u8.mjs.map +0 -1
- package/dist/result-shape-CDgX_vzn.mjs +0 -2
- package/dist/v-CYTUI0H5.mjs +0 -2
- package/dist/v-CYTUI0H5.mjs.map +0 -1
- package/dist/version-CXuJzC-q.mjs +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version-
|
|
1
|
+
{"version":3,"file":"version-Dus3if78.mjs","names":["packageMetadata.version"],"sources":["../package.json","../src/version.ts"],"sourcesContent":["","import packageMetadata from \"../package.json\";\n\n/** Package version shared by runtime surfaces and bundled from package.json. */\nexport const VIBORM_VERSION = packageMetadata.version;\n"],"mappings":"ACGA,MAAa"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "viborm",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"description": "Type-safe ORM for PostgreSQL, MySQL, and SQLite with a Prisma-inspired API",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -208,6 +208,7 @@
|
|
|
208
208
|
"build": "node scripts/run-typecheck.mjs",
|
|
209
209
|
"dev": "node node_modules/typescript/bin/tsc --watch",
|
|
210
210
|
"test": "pnpm test:types && pnpm test:core",
|
|
211
|
+
"test:dst": "node scripts/run-manual-dst.mjs",
|
|
211
212
|
"test:raptor3": "node scripts/run-raptor3.mjs g0",
|
|
212
213
|
"test:raptor3:compare": "node scripts/run-raptor3.mjs g1-compare",
|
|
213
214
|
"test:raptor3:contracts": "node scripts/run-raptor3.mjs g1-contracts",
|
|
@@ -389,29 +390,29 @@
|
|
|
389
390
|
"name": "D1 Worker (viborm/d1)",
|
|
390
391
|
"path": "node_modules/.cache/viborm-size/d1-worker.mjs",
|
|
391
392
|
"gzip": true,
|
|
392
|
-
"limit": "
|
|
393
|
-
"message": "Raised 170 → 171.9 kB by the measured +1,868 B of RBAC M1 wave 1 (OD-17): rows predicates admitted, layered and parameterized, numbered binds, bound views. Raised 171.9 → 177.6 kB by the measured +5,630 B (177.29 kB) of RBAC M2 wave 4 (K4 produced rows judged in the statement, K5 evidence and read-gated fields; OD-17, measured + 0.3 kB headroom). Raised 177.6 → 179 kB by the measured +1,355 B (178.65 kB) of RBAC M2 wave 5 (E5: shared relation bodies, D1 balanced conjunctions, the judged write's own sentinel, the allocation fixes; the uncacheable control, OD-10; OD-17, measured + 0.3 kB headroom). Raised 179 → 179.7 kB by the measured 179.37 kB of the RBAC second review's fixes (2026-10-17): per-dialect produced rows for a judged createMany (ENG-3, setOperations.typedRows), caller SQL kept out of shared-body keys (ENG-4, Sql.peekRuns), isolated nesting levels where deepExpressions is false (ENG-6, subqueries.isolated) (OD-17, measured rounded up to 0.1 kB + 0.3 kB)."
|
|
393
|
+
"limit": "183.1 kB",
|
|
394
|
+
"message": "Raised 170 → 171.9 kB by the measured +1,868 B of RBAC M1 wave 1 (OD-17): rows predicates admitted, layered and parameterized, numbered binds, bound views. Raised 171.9 → 177.6 kB by the measured +5,630 B (177.29 kB) of RBAC M2 wave 4 (K4 produced rows judged in the statement, K5 evidence and read-gated fields; OD-17, measured + 0.3 kB headroom). Raised 177.6 → 179 kB by the measured +1,355 B (178.65 kB) of RBAC M2 wave 5 (E5: shared relation bodies, D1 balanced conjunctions, the judged write's own sentinel, the allocation fixes; the uncacheable control, OD-10; OD-17, measured + 0.3 kB headroom). Raised 179 → 179.7 kB by the measured 179.37 kB of the RBAC second review's fixes (2026-10-17): per-dialect produced rows for a judged createMany (ENG-3, setOperations.typedRows), caller SQL kept out of shared-body keys (ENG-4, Sql.peekRuns), isolated nesting levels where deepExpressions is false (ENG-6, subqueries.isolated) (OD-17, measured rounded up to 0.1 kB + 0.3 kB). Permissions application reuse (2026-10-18) measures 179,947 B: private policy-definition caching, immutable row admission and control-reference reuse. Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. 1.3.2 (2026-10-19) measures 182,905 B: per-model policy compilation (lazy rows.verbs entries admitted on first use, lazy acyclic, per-chain reference checks), $exists and { $row, up } in row predicates (admission, preparation and lowering frames, shared or correlated bodies, the write re-judgement that reads them), and repeated bodies shared in UPDATE and DELETE statements. Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged."
|
|
394
395
|
},
|
|
395
396
|
{
|
|
396
397
|
"name": "pg + migrations Worker (viborm/pg + viborm/migrations/postgres)",
|
|
397
398
|
"path": "node_modules/.cache/viborm-size/pg-migrations-worker.mjs",
|
|
398
399
|
"gzip": true,
|
|
399
|
-
"limit": "
|
|
400
|
-
"message": "Raised 273 → 274.4 kB by the measured +1,392 B of RBAC M1 wave 2 (K3, OD-17): rows verbs, written fields, write judgements and the clear premise; it held wave 1's +1,819 B inside its headroom. Raised 274.4 → 279.5 kB by the measured +5,720 B (279.12 kB) of RBAC M2 wave 4 (K4 produced rows judged in the statement, K5 evidence and read-gated fields; OD-17, measured + 0.3 kB headroom). Raised 279.5 → 280.8 kB by the measured +1,340 B (280.46 kB) of RBAC M2 wave 5 (E5: shared relation bodies, D1 balanced conjunctions, the judged write's own sentinel, the allocation fixes; the uncacheable control, OD-10; OD-17, measured + 0.3 kB headroom). Raised 280.8 → 281.6 kB by the measured 281.27 kB of the RBAC second review's fixes (2026-10-17): per-dialect produced rows for a judged createMany (ENG-3, setOperations.typedRows), caller SQL kept out of shared-body keys (ENG-4, Sql.peekRuns), isolated nesting levels where deepExpressions is false (ENG-6, subqueries.isolated), and createClient forwarding sharedRelationBodies (ENG-5) (OD-17, measured rounded up to 0.1 kB + 0.3 kB)."
|
|
400
|
+
"limit": "284.9 kB",
|
|
401
|
+
"message": "Raised 273 → 274.4 kB by the measured +1,392 B of RBAC M1 wave 2 (K3, OD-17): rows verbs, written fields, write judgements and the clear premise; it held wave 1's +1,819 B inside its headroom. Raised 274.4 → 279.5 kB by the measured +5,720 B (279.12 kB) of RBAC M2 wave 4 (K4 produced rows judged in the statement, K5 evidence and read-gated fields; OD-17, measured + 0.3 kB headroom). Raised 279.5 → 280.8 kB by the measured +1,340 B (280.46 kB) of RBAC M2 wave 5 (E5: shared relation bodies, D1 balanced conjunctions, the judged write's own sentinel, the allocation fixes; the uncacheable control, OD-10; OD-17, measured + 0.3 kB headroom). Raised 280.8 → 281.6 kB by the measured 281.27 kB of the RBAC second review's fixes (2026-10-17): per-dialect produced rows for a judged createMany (ENG-3, setOperations.typedRows), caller SQL kept out of shared-body keys (ENG-4, Sql.peekRuns), isolated nesting levels where deepExpressions is false (ENG-6, subqueries.isolated), and createClient forwarding sharedRelationBodies (ENG-5) (OD-17, measured rounded up to 0.1 kB + 0.3 kB). Permissions application reuse (2026-10-18) measures 281,876 B: private policy-definition caching, immutable row admission and control-reference reuse. Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. 1.3.2 (2026-10-19) measures 284,679 B: per-model policy compilation (lazy rows.verbs entries admitted on first use, lazy acyclic, per-chain reference checks), $exists and { $row, up } in row predicates (admission, preparation and lowering frames, shared or correlated bodies, the write re-judgement that reads them), and repeated bodies shared in UPDATE and DELETE statements. Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged."
|
|
401
402
|
},
|
|
402
403
|
{
|
|
403
404
|
"name": "pg application (viborm/pg)",
|
|
404
405
|
"path": "node_modules/.cache/viborm-size/pg-representative.mjs",
|
|
405
406
|
"gzip": true,
|
|
406
|
-
"limit": "
|
|
407
|
-
"message": "Raised 170 → 171.9 kB by the measured +1,900 B of RBAC M1 wave 1 (OD-17): rows predicates admitted, layered and parameterized, numbered binds, bound views. Raised 171.9 → 173.34 kB by the measured +1,440 B of RBAC M1 wave 2 (K3, OD-17): rows verbs, written fields, write judgements and the clear premise. Raised 173.34 → 178.2 kB by the measured +5,650 B (177.84 kB) of RBAC M2 wave 4 (K4 produced rows judged in the statement, K5 evidence and read-gated fields; OD-17, measured + 0.3 kB headroom). Raised 178.2 → 179.5 kB by the measured +1,278 B (179.12 kB) of RBAC M2 wave 5 (E5: shared relation bodies, D1 balanced conjunctions, the judged write's own sentinel, the allocation fixes; the uncacheable control, OD-10; OD-17, measured + 0.3 kB headroom). Raised 179.5 → 180.3 kB by the measured 179.99 kB of the RBAC second review's fixes (2026-10-17): per-dialect produced rows for a judged createMany (ENG-3, setOperations.typedRows), caller SQL kept out of shared-body keys (ENG-4, Sql.peekRuns), isolated nesting levels where deepExpressions is false (ENG-6, subqueries.isolated), and createClient forwarding sharedRelationBodies (ENG-5) (OD-17, measured rounded up to 0.1 kB + 0.3 kB)."
|
|
407
|
+
"limit": "183.6 kB",
|
|
408
|
+
"message": "Raised 170 → 171.9 kB by the measured +1,900 B of RBAC M1 wave 1 (OD-17): rows predicates admitted, layered and parameterized, numbered binds, bound views. Raised 171.9 → 173.34 kB by the measured +1,440 B of RBAC M1 wave 2 (K3, OD-17): rows verbs, written fields, write judgements and the clear premise. Raised 173.34 → 178.2 kB by the measured +5,650 B (177.84 kB) of RBAC M2 wave 4 (K4 produced rows judged in the statement, K5 evidence and read-gated fields; OD-17, measured + 0.3 kB headroom). Raised 178.2 → 179.5 kB by the measured +1,278 B (179.12 kB) of RBAC M2 wave 5 (E5: shared relation bodies, D1 balanced conjunctions, the judged write's own sentinel, the allocation fixes; the uncacheable control, OD-10; OD-17, measured + 0.3 kB headroom). Raised 179.5 → 180.3 kB by the measured 179.99 kB of the RBAC second review's fixes (2026-10-17): per-dialect produced rows for a judged createMany (ENG-3, setOperations.typedRows), caller SQL kept out of shared-body keys (ENG-4, Sql.peekRuns), isolated nesting levels where deepExpressions is false (ENG-6, subqueries.isolated), and createClient forwarding sharedRelationBodies (ENG-5) (OD-17, measured rounded up to 0.1 kB + 0.3 kB). Permissions application reuse (2026-10-18) measures 180,567 B: private policy-definition caching, immutable row admission and control-reference reuse. Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. 1.3.2 (2026-10-19) measures 183,392 B: per-model policy compilation (lazy rows.verbs entries admitted on first use, lazy acyclic, per-chain reference checks), $exists and { $row, up } in row predicates (admission, preparation and lowering frames, shared or correlated bodies, the write re-judgement that reads them), and repeated bodies shared in UPDATE and DELETE statements. Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged."
|
|
408
409
|
},
|
|
409
410
|
{
|
|
410
411
|
"name": "pg application + soft delete",
|
|
411
412
|
"path": "node_modules/.cache/viborm-size/pg-soft-delete.mjs",
|
|
412
413
|
"gzip": true,
|
|
413
|
-
"limit": "
|
|
414
|
-
"message": "Raised 173.5 → 178.6 kB by the measured +5,670 B (178.24 kB) of RBAC M2 wave 4 (K4 produced rows judged in the statement, K5 evidence and read-gated fields; OD-17, measured + 0.3 kB headroom). Raised 178.6 → 179.9 kB by the measured +1,270 B (179.51 kB) of RBAC M2 wave 5 (E5: shared relation bodies, D1 balanced conjunctions, the judged write's own sentinel, the allocation fixes; the uncacheable control, OD-10; OD-17, measured + 0.3 kB headroom). Raised 179.9 → 180.7 kB by the measured 180.39 kB of the RBAC second review's fixes (2026-10-17): per-dialect produced rows for a judged createMany (ENG-3, setOperations.typedRows), caller SQL kept out of shared-body keys (ENG-4, Sql.peekRuns), isolated nesting levels where deepExpressions is false (ENG-6, subqueries.isolated), createClient forwarding sharedRelationBodies (ENG-5), and soft delete's module-level steps (COST-1, COST-2) (OD-17, measured rounded up to 0.1 kB + 0.3 kB)."
|
|
414
|
+
"limit": "184.0 kB",
|
|
415
|
+
"message": "Raised 173.5 → 178.6 kB by the measured +5,670 B (178.24 kB) of RBAC M2 wave 4 (K4 produced rows judged in the statement, K5 evidence and read-gated fields; OD-17, measured + 0.3 kB headroom). Raised 178.6 → 179.9 kB by the measured +1,270 B (179.51 kB) of RBAC M2 wave 5 (E5: shared relation bodies, D1 balanced conjunctions, the judged write's own sentinel, the allocation fixes; the uncacheable control, OD-10; OD-17, measured + 0.3 kB headroom). Raised 179.9 → 180.7 kB by the measured 180.39 kB of the RBAC second review's fixes (2026-10-17): per-dialect produced rows for a judged createMany (ENG-3, setOperations.typedRows), caller SQL kept out of shared-body keys (ENG-4, Sql.peekRuns), isolated nesting levels where deepExpressions is false (ENG-6, subqueries.isolated), createClient forwarding sharedRelationBodies (ENG-5), and soft delete's module-level steps (COST-1, COST-2) (OD-17, measured rounded up to 0.1 kB + 0.3 kB). Permissions application reuse (2026-10-18) measures 180,978 B: private policy-definition caching, immutable row admission and control-reference reuse. Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. 1.3.2 (2026-10-19) measures 183,799 B: per-model policy compilation (lazy rows.verbs entries admitted on first use, lazy acyclic, per-chain reference checks), $exists and { $row, up } in row predicates (admission, preparation and lowering frames, shared or correlated bodies, the write re-judgement that reads them), and repeated bodies shared in UPDATE and DELETE statements. Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged."
|
|
415
416
|
},
|
|
416
417
|
{
|
|
417
418
|
"name": "soft-delete extension entry",
|
|
@@ -424,15 +425,15 @@
|
|
|
424
425
|
"name": "pg application + permissions",
|
|
425
426
|
"path": "node_modules/.cache/viborm-size/pg-permissions.mjs",
|
|
426
427
|
"gzip": true,
|
|
427
|
-
"limit": "
|
|
428
|
-
"message": "The pg application with viborm/permissions applied (the guide's blog policy: an actor schema, an explicit authorId predicate and an actor condition, $as per request, one read, one create, one can): measured 184,652 B at the M2 exit (wave 5), +5,534 B over the pg application row (the entry's compiler with placement, moves, acyclic relations and evidence, can/assert through $access). First measured 181,404 B at c7d1951cd (U10). Limit = measured rounded up to 0.1 kB + 0.3 kB (OD-17). Raised 185 → 185.8 kB by the measured +488 B (185.49 kB) of the independent review's fixes (2026-10-16): refusals of unknown policy, model and field-entry keys, mistyped declaration keys, keyLimit models and undeclared ceilings; can/assert over findUnique with one ask per level; the prover's structural equality and R6 safeguard (OD-17). Comma-separated action keys measure 185,861 B (2026-10-16): normalized bindings and rejection of empty, repeated, overlapping and reserved members. Limit 186.2 kB follows the same rounding plus 0.3 kB rule (OD-17). CRUD permissions and complementary credential scopes measure 186,347 B (2026-10-17); limit 186.7 kB follows the approved measured rounding plus 0.3 kB rule (OD-17). Conditional parameter-read preservation and the permissions rename measure 187,685 B (2026-10-17), +1,338 B from the last recorded application measurement; limit 188 kB follows OD-17 rounding plus 0.3 kB. The simplifier preserves missing/null and whole-list refusals while retaining compact inherited predicates. Raised by the second review's fixes (2026-10-17: typed VALUES rows for judged inserts, caller-text runs in shared-body keys, isolated nesting levels on D1), measured 188.19 kB after the permissions rename; limit = measured rounded up to 0.1 kB + 0.3 kB (OD-17). Actor admission and polymorphic projection consistency (2026-10-18) measure 189,787 B: required native actor validation, per-grant availability and variant projection admission. Limit follows OD-17 rounding to 0.1 kB plus 0.3 kB."
|
|
428
|
+
"limit": "196.3 kB",
|
|
429
|
+
"message": "The pg application with viborm/permissions applied (the guide's blog policy: an actor schema, an explicit authorId predicate and an actor condition, $as per request, one read, one create, one can): measured 184,652 B at the M2 exit (wave 5), +5,534 B over the pg application row (the entry's compiler with placement, moves, acyclic relations and evidence, can/assert through $access). First measured 181,404 B at c7d1951cd (U10). Limit = measured rounded up to 0.1 kB + 0.3 kB (OD-17). Raised 185 → 185.8 kB by the measured +488 B (185.49 kB) of the independent review's fixes (2026-10-16): refusals of unknown policy, model and field-entry keys, mistyped declaration keys, keyLimit models and undeclared ceilings; can/assert over findUnique with one ask per level; the prover's structural equality and R6 safeguard (OD-17). Comma-separated action keys measure 185,861 B (2026-10-16): normalized bindings and rejection of empty, repeated, overlapping and reserved members. Limit 186.2 kB follows the same rounding plus 0.3 kB rule (OD-17). CRUD permissions and complementary credential scopes measure 186,347 B (2026-10-17); limit 186.7 kB follows the approved measured rounding plus 0.3 kB rule (OD-17). Conditional parameter-read preservation and the permissions rename measure 187,685 B (2026-10-17), +1,338 B from the last recorded application measurement; limit 188 kB follows OD-17 rounding plus 0.3 kB. The simplifier preserves missing/null and whole-list refusals while retaining compact inherited predicates. Raised by the second review's fixes (2026-10-17: typed VALUES rows for judged inserts, caller-text runs in shared-body keys, isolated nesting levels on D1), measured 188.19 kB after the permissions rename; limit = measured rounded up to 0.1 kB + 0.3 kB (OD-17). Actor admission and polymorphic projection consistency (2026-10-18) measure 189,787 B: required native actor validation, per-grant availability and variant projection admission. Limit follows OD-17 rounding to 0.1 kB plus 0.3 kB. Permissions application reuse (2026-10-18) measures 190,939 B: private policy-definition caching, immutable row admission and control-reference reuse. Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. Cold compilation sharing (2026-10-18) measures 191,498 B: compilation-local structural keys and shared guards in the policy simplifier, and admission that parses and walks each shared sub-predicate once. Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. 1.3.2 (2026-10-19) measures 196,216 B: per-model compilation (the policy compiler, the declaration snapshot, frozen lazy entries), $exists and { $row, up } in rules, and the refusal of field references and empty actor conditions. Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged."
|
|
429
430
|
},
|
|
430
431
|
{
|
|
431
432
|
"name": "permissions extension entry",
|
|
432
433
|
"path": "node_modules/.cache/viborm-size/permissions-entry.mjs",
|
|
433
434
|
"gzip": true,
|
|
434
|
-
"limit": "
|
|
435
|
-
"message": "viborm/permissions alone: permissions(), its policy compiler (placement, moves, acyclic relations, evidence and the implication that drops what administering already says), $as, can/assert through $access with explicit application predicates, and the error classes it raises from the root's shared chunks (VibORMError and its code table, ClientInitializationError, ForbiddenError), which an application already holds. Measured 13,061 B at the M2 exit (wave 5); 11,188 B at c7d1951cd. Limit = measured rounded up to 0.1 kB + 0.3 kB (OD-17). Raised 13.4 → 14.3 kB by the measured +509 B (13.91 kB) of the independent review's fixes (2026-10-16), the same code as the pg + rbac row (OD-17). Actor admission (2026-10-18) measures 29,230 B. The isolated entry now includes the public native validation factories used to require actor fields while preserving defaults, transforms and sparse output; ordinary ORM applications already share those factories (the pg + permissions application measures 189,787 B). Per-grant availability is compiled through existing public conditions. Limit follows OD-17 rounding to 0.1 kB plus 0.3 kB."
|
|
435
|
+
"limit": "32.3 kB",
|
|
436
|
+
"message": "viborm/permissions alone: permissions(), its policy compiler (placement, moves, acyclic relations, evidence and the implication that drops what administering already says), $as, can/assert through $access with explicit application predicates, and the error classes it raises from the root's shared chunks (VibORMError and its code table, ClientInitializationError, ForbiddenError), which an application already holds. Measured 13,061 B at the M2 exit (wave 5); 11,188 B at c7d1951cd. Limit = measured rounded up to 0.1 kB + 0.3 kB (OD-17). Raised 13.4 → 14.3 kB by the measured +509 B (13.91 kB) of the independent review's fixes (2026-10-16), the same code as the pg + rbac row (OD-17). Actor admission (2026-10-18) measures 29,230 B. The isolated entry now includes the public native validation factories used to require actor fields while preserving defaults, transforms and sparse output; ordinary ORM applications already share those factories (the pg + permissions application measures 189,787 B). Per-grant availability is compiled through existing public conditions. Limit follows OD-17 rounding to 0.1 kB plus 0.3 kB. Permissions application reuse (2026-10-18) measures 30,020 B: private policy-definition caching, immutable row admission and control-reference reuse. Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. Cold compilation sharing (2026-10-18) measures 30,407 B: compilation-local structural keys and shared guards in the policy simplifier, and admission that parses and walks each shared sub-predicate once. Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. 1.3.2 (2026-10-19) measures 32,160 B: per-model compilation (the policy compiler, the declaration snapshot, frozen lazy entries), $exists and { $row, up } in rules, and the refusal of field references and empty actor conditions. Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged."
|
|
436
437
|
},
|
|
437
438
|
{
|
|
438
439
|
"name": "identifier generators only",
|
|
@@ -450,8 +451,8 @@
|
|
|
450
451
|
"name": "every public entry",
|
|
451
452
|
"path": "node_modules/.cache/viborm-size/full.mjs",
|
|
452
453
|
"gzip": true,
|
|
453
|
-
"limit": "
|
|
454
|
-
"message": "Raised 394 → 398.1 kB by the measured +5,700 B (397.74 kB) of RBAC M2 wave 4 (K4 produced rows judged in the statement, K5 evidence and read-gated fields; OD-17, measured + 0.3 kB headroom). Raised 398.1 → 405.9 kB by the measured +7,818 B (405.56 kB) of RBAC M2 wave 5: the fixture now exports viborm/rbac (U10), the entry's placement, moves and evidence (U9), and the core growth of E5 and OD-10 (OD-17, measured + 0.3 kB headroom). Raised 405.9 → 406.9 kB by the measured +692 B (406.59 kB) of the independent review's fixes (2026-10-16): the rbac entry's refusals and prover fixes, and the marker judgement in core (OD-17). The permissions rename and conditional-read simplification fixes measure 407,193 B (2026-10-17); limit 407.5 kB follows OD-17 rounding plus 0.3 kB. Raised by the second review's fixes (2026-10-17: typed VALUES rows for judged inserts, caller-text runs in shared-body keys, isolated nesting levels on D1), measured 407.81 kB after the permissions rename; limit = measured rounded up to 0.1 kB + 0.3 kB (OD-17). Actor admission and polymorphic projection consistency (2026-10-18) measure 409,474 B; limit follows OD-17 rounding to 0.1 kB plus 0.3 kB."
|
|
454
|
+
"limit": "416.1 kB",
|
|
455
|
+
"message": "Raised 394 → 398.1 kB by the measured +5,700 B (397.74 kB) of RBAC M2 wave 4 (K4 produced rows judged in the statement, K5 evidence and read-gated fields; OD-17, measured + 0.3 kB headroom). Raised 398.1 → 405.9 kB by the measured +7,818 B (405.56 kB) of RBAC M2 wave 5: the fixture now exports viborm/rbac (U10), the entry's placement, moves and evidence (U9), and the core growth of E5 and OD-10 (OD-17, measured + 0.3 kB headroom). Raised 405.9 → 406.9 kB by the measured +692 B (406.59 kB) of the independent review's fixes (2026-10-16): the rbac entry's refusals and prover fixes, and the marker judgement in core (OD-17). The permissions rename and conditional-read simplification fixes measure 407,193 B (2026-10-17); limit 407.5 kB follows OD-17 rounding plus 0.3 kB. Raised by the second review's fixes (2026-10-17: typed VALUES rows for judged inserts, caller-text runs in shared-body keys, isolated nesting levels on D1), measured 407.81 kB after the permissions rename; limit = measured rounded up to 0.1 kB + 0.3 kB (OD-17). Actor admission and polymorphic projection consistency (2026-10-18) measure 409,474 B; limit follows OD-17 rounding to 0.1 kB plus 0.3 kB. Permissions application reuse (2026-10-18) measures 410,754 B: private policy-definition caching, immutable row admission and control-reference reuse. Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. Cold compilation sharing (2026-10-18) measures 411,254 B: compilation-local structural keys and shared guards in the policy simplifier, and admission that parses and walks each shared sub-predicate once. Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged. 1.3.2 (2026-10-19) measures 415,968 B: per-model policy compilation (lazy rows.verbs entries admitted on first use, lazy acyclic, per-chain reference checks), $exists and { $row, up } in row predicates (admission, preparation and lowering frames, shared or correlated bodies, the write re-judgement that reads them), and repeated bodies shared in UPDATE and DELETE statements. Limit follows the approved OD-17 measured rounding to 0.1 kB plus 0.3 kB; resource and coverage limits are unchanged."
|
|
455
456
|
}
|
|
456
457
|
]
|
|
457
458
|
}
|
package/dist/chain-C7c1YTXD.mjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{n as e}from"./chunk-BuuaeEvq.mjs";import{i as t,o as n}from"./value-guards-CK9guf2Z.mjs";import{a as r,c as i,f as a,g as o,h as s,o as c,x as l,y as u}from"./controls-Da-efekX.mjs";import{b as d}from"./base-D3m1S7Uc.mjs";import{r as f}from"./validation-BamBwne9.mjs";import{_ as p,a as m}from"./v-CYTUI0H5.mjs";import{B as h,rt as g}from"./geo-point-codec-DyEHMdJg.mjs";import{n as _}from"./builder-Df24l2Bd.mjs";import{l as v,n as y,t as b}from"./observation-Co72iCd1.mjs";function readDriverIdentity(e){try{let t=e.adapter.namespace;return Object.freeze({dialect:e.dialect,driverName:e.driverName,...t===void 0?{}:{namespace:t}})}catch{return}}const x=`viborm.defaultOmit`,S=new WeakMap,C=new WeakMap;function configurationError(e,t){throw new f(e,{cause:t===void 0?void 0:d(t)})}function ownKeys(e,t){try{return Reflect.ownKeys(e)}catch(e){configurationError(`Default omit ${t} members could not be inspected.`,e)}}function readOwn$1(e,t,n){try{return e[t]}catch(e){configurationError(`Default omit ${n} member "${t}" could not be read.`,e)}}e(readOwn$1,`readOwn`);function isConfigurationRecord(e,t){try{return n(e)}catch(e){configurationError(`Default omit ${t} could not be inspected.`,e)}}function snapshotConfig(e){isConfigurationRecord(e,`configuration`)||configurationError(`Default omit configuration must be an object.`);let t=Object.create(null);for(let n of ownKeys(e,`configuration`)){typeof n!=`string`&&configurationError(`Default omit configuration contains a non-string model key.`);let r=readOwn$1(e,n,`configuration`);isConfigurationRecord(r,`configuration.${n}`)||configurationError(`Default omit configuration member "${n}" must be an object.`);let i=Object.create(null);for(let e of ownKeys(r,`configuration.${n}`))typeof e!=`string`&&configurationError(`Default omit configuration member "${n}" contains a non-string field key.`),readOwn$1(r,e,`configuration.${n}`)!==!0&&configurationError(`Default omit configuration member "${n}.${e}" must be true.`),i[e]=!0;t[n]=Object.freeze(i)}return Object.freeze(t)}function defaultOmit(){return e=>{let t=Object.freeze({config:snapshotConfig(e)}),request=()=>({});return S.set(request,t),Object.freeze({name:x,request})}}function getOfficialDefaultOmitRequestCapability(e){return t(e)?S.get(e):void 0}function getOfficialDefaultOmitChainCapability(e){return e===void 0?void 0:C.get(e)}function registerOfficialDefaultOmitChain(e,t){C.set(e,t)}const parseStamped=(e,t)=>h((t,n)=>e.get(t)?.create?.[n]!==void 0,t);var Parameter=class{control;path;now;#e;constructor(e,t){e===void 0?this.now=!0:this.control=e,t!==void 0&&(this.path=t),this.#e=t===void 0?[]:t.split(`.`),Object.freeze(this)}read(e,t){if(this.control===void 0)return t();let n=e?.controls[this.control];for(let e of this.#e){if(typeof n!=`object`||!n)return;n=Object.hasOwn(n,e)?n[e]:void 0}return n??void 0}},Condition=class{parameter;test;constructor(e,t){this.parameter=e,this.test=t,Object.freeze(this)}holds(e,t){let n=this.parameter.read(e,t),r=this.test;return`exists`in r?n!==void 0===r.exists:n===void 0?!1:`equals`in r?Object.is(n,r.equals):`in`in r?r.in.includes(n):Array.isArray(n)?`has`in r?n.includes(r.has):r.hasSome.some(e=>n.includes(e)):!1}};const w=new WeakMap;function standaloneRegistry(e){let t=w.get(e);return t===void 0&&(t=_(e),w.set(e,t)),t}const T={predicates:!0,read:!0,update:!0,delete:!0,writes:!0,place:!0,moves:!0,acyclic:!0,evidence:!0,reads:!0},E=/^\$[a-zA-Z_][a-zA-Z0-9_]*$/;function keyFields(e){return new Set([...Object.entries(e.scalars).filter(([,e])=>e[`~`].state.isId===!0).map(([e])=>e),...Object.keys(e.uniques),...[...Object.values(e.compoundId??{}),...Object.values(e.compoundUniques??{})].flatMap(({entries:e})=>Object.keys(e)),...Object.values(e.relations).flatMap(e=>e[`~`].state.foreignKey?.fields??[])])}const D=[`exists`,`equals`,`in`,`has`,`hasSome`];function isReference(e){return p(e)&&typeof e.control==`string`&&Object.keys(e).every(e=>e===`control`||e===`path`)&&(e.path===void 0||typeof e.path==`string`)}const isInstant=e=>p(e)&&e.now===!0&&Object.keys(e).length===1,O=`a condition names one control and exactly one of ${D.join(`, `)}`;function conditionOf(e){if(!p(e))return O;let{control:t,path:n,...r}=e,[i,...a]=Object.keys(r),o=r[i];return typeof t!=`string`||n!==void 0&&typeof n!=`string`||!D.includes(i)||a.length>0||i===`exists`&&typeof o!=`boolean`||(i===`in`||i===`hasSome`)&&!Array.isArray(o)?O:new Condition(new Parameter(t,n),Object.freeze({[i]:o}))}const k={value:e=>isReference(e)?new Parameter(e.control,e.path):isInstant(e)?new Parameter:void 0,condition:conditionOf};function cyclePath(e,t=new Set,n=[]){if(!(typeof e!=`object`||!e)){if(t.has(e))return n.join(`.`);t.add(e);for(let[r,i]of Object.entries(e)){n.push(r);let e=cyclePath(i,t,n);if(e!==void 0)return e;n.pop()}t.delete(e)}}function admitRows(e,t,n,r=standaloneRegistry(t)){let refuse=(e,t,r,i)=>{throw new f(`Extension "${n}" rows.${t} at "${r}": ${i}.`,{meta:{extension:n,model:e}})},admit=(e,n,i)=>{let a=cyclePath(i);a!==void 0&&refuse(e,n,a,`contains itself`);let o=r.getModelSchemas(t[e]).core.where,s=m(k,()=>g(o,i));if(!s.issues)return s.value;let[c]=s.issues;return refuse(e,n,c.path?.map(String).join(`.`)||`root`,c.message)},i={};for(let[n,r]of Object.entries(e.verbs??{})){let e=`verbs.${n}`;Object.hasOwn(t,n)||refuse(n,e,`root`,`names an unknown model`);for(let t of Object.keys(r))Object.hasOwn(T,t)||refuse(n,e,t,`is not one of ${Object.keys(T).join(`, `)}`);let{state:a}=t[n][`~`],o=Object.fromEntries(Object.entries(r.predicates).map(([t,r])=>[t,admit(n,`${e}.predicates.${t}`,r)])),known=(t,r)=>{r!==void 0&&!Object.hasOwn(o,r)&&refuse(n,e,t,`names unknown predicate "${r}"`)};known(`read`,r.read),known(`update`,r.update),known(`delete`,r.delete),known(`place`,r.place);for(let t of[`writes`,`moves`])for(let[i,o]of Object.entries(r[t]??{}))Object.hasOwn(a.scalars,i)||Object.hasOwn(a.relations,i)||refuse(n,e,`${t}.${i}`,`names an unknown field`),known(`${t}.${i}`,o);for(let i of r.acyclic??[]){let r=Object.hasOwn(a.relations,i)?a.relations[i][`~`]:void 0;(r?.state.foreignKey===void 0||r.settleTarget()!==t[n])&&refuse(n,e,`acyclic.${i}`,`names no to-one relation of the model to itself holding its key`)}let{evidence:s}=r;if(s!==void 0){E.test(s.as)||refuse(n,e,`evidence.as`,"is not `$` and an identifier");for(let[e,t]of s.names.entries())known(`evidence.names.${e}`,t)}let c=r.reads===void 0?void 0:keyFields(a);for(let[t,i]of Object.entries(r.reads??{}))Object.hasOwn(a.scalars,t)||refuse(n,e,`reads.${t}`,`names no scalar of the model`),c.has(t)&&refuse(n,e,`reads.${t}`,`names a key, a unique or a foreign key field`),known(`reads.${t}`,i);i[n]=Object.freeze({...r,predicates:Object.freeze(o)})}let a={};for(let[t,n]of Object.entries(e.models)){let e=new Map;for(let[r,a]of Object.entries(n)){let n={};for(let e of[`root`,`related`]){let o=a[e];if(o===void 0)continue;let s=`${t}.${r}.${e}`;typeof o==`string`?Object.hasOwn(i[t]?.predicates??{},o)?n[e]=i[t].predicates[o]:refuse(t,s,`root`,`names unknown predicate "${o}"`):n[e]=admit(t,s,o)}e.set(r,Object.freeze(n))}a[t]=Object.freeze(Object.fromEntries(e))}return Object.freeze({...e,models:Object.freeze(a),...e.verbs&&{verbs:Object.freeze(i)}})}const A=new Set([`name`,`request`,`query`,`statement`,`observe`,`client`,`model`,`controls`,`rows`,`deletion`,`data`]);function extensionError(e,t){throw new f(e,{meta:t?{extension:t}:void 0})}function readOwnKeys(e,t){try{return Reflect.ownKeys(e)}catch(e){throw new f(t?`Extension "${t}" members could not be inspected.`:`Client extension members could not be inspected.`,{cause:d(e),meta:t?{extension:t}:void 0})}}function readOwn(e,t,n){try{return e[t]}catch(e){throw new f(n?`Extension "${n}" member "${t}" could not be read.`:`Client extension member "${t}" could not be read.`,{cause:d(e),meta:n?{extension:n}:void 0})}}function requireFunction(e,n,r){return t(e)||extensionError(`Extension "${r}" ${n} must be a function.`,r),e}function snapshotOperationMap(e,r,a,o){if(t(e))return e;n(e)||extensionError(`Extension "${a}" ${r} must be a function or model map.`,a);let s=Object.create(null);for(let t of readOwnKeys(e,a)){typeof t!=`string`&&extensionError(`Extension "${a}" ${r} contains a non-string model key.`,a),o&&!Object.hasOwn(o,t)&&extensionError(`Extension "${a}" ${r} names unknown model "${t}".`,a);let c=readOwn(e,t,a);n(c)||extensionError(`Extension "${a}" ${r}.${t} must be an operation map.`,a);let l=Object.create(null);for(let e of readOwnKeys(c,a))typeof e!=`string`&&extensionError(`Extension "${a}" ${r}.${t} contains a non-string operation key.`,a),i.has(e)||extensionError(`Extension "${a}" ${r}.${t} names unknown operation "${e}".`,a),l[e]=requireFunction(readOwn(c,e,a),`${r}.${t}.${e}`,a);s[t]=Object.freeze(l)}return Object.freeze(s)}function snapshotModelFactories(e,t,r){n(e)||extensionError(`Extension "${t}" model must be a model map.`,t);let i=Object.create(null);for(let n of readOwnKeys(e,t))typeof n!=`string`&&extensionError(`Extension "${t}" model contains a non-string model key.`,t),r&&!Object.hasOwn(r,n)&&extensionError(`Extension "${t}" model names unknown model "${n}".`,t),i[n]=requireFunction(readOwn(e,n,t),`model.${n}`,t);return Object.freeze(i)}function validateNamedPolicies(e,t,r){if(t)for(let i of[`rows`,`data`,`deletion`]){let a=readOwn(e,i,r);if(a===void 0)continue;n(a)||extensionError(`Extension "${r}" ${i} must be an object.`,r);let o=readOwn(a,`models`,r);n(o)||extensionError(`Extension "${r}" ${i}.models must be an object.`,r);let s,c=i===`rows`?readOwn(a,`default`,r):void 0;for(let e of readOwnKeys(o,r)){(typeof e!=`string`||!Object.hasOwn(t,e))&&extensionError(`Extension "${r}" ${i} names unknown model "${String(e)}".`,r);let a=t[e],l=readOwn(o,e,r);n(l)||extensionError(`Extension "${r}" ${i}.${e} must be an object.`,r);let fields=t=>{if(t!==void 0){n(t)||extensionError(`Extension "${r}" ${i}.${e} fields must be an object.`,r);for(let n of readOwnKeys(t,r))(typeof n!=`string`||!Object.hasOwn(a[`~`].state.scalars,n))&&extensionError(`Extension "${r}" ${i}.${e} names unknown field "${String(n)}".`,r)}};if(i===`rows`){let e=readOwnKeys(l,r).filter(e=>typeof e==`string`),t=s;(typeof c!=`string`||!e.includes(c)||t&&(t.length!==e.length||e.some(e=>!t.includes(e))))&&extensionError(`Extension "${r}" row models must share mode names and include the default mode.`,r),s??=e;for(let e of readOwnKeys(l,r))typeof e!=`string`&&extensionError(`Extension "${r}" row mode must be a string.`,r),n(readOwn(l,e,r))||extensionError(`Extension "${r}" row mode must be an object.`,r)}else if(i===`data`)fields(readOwn(l,`create`,r)),fields(readOwn(l,`update`,r));else{let t=readOwn(l,`at`,r);t!==void 0&&(typeof t!=`string`||!Object.hasOwn(a[`~`].state.scalars,t))&&extensionError(`Extension "${r}" deletion.${e}.at names unknown scalar.`,r),fields(readOwn(l,`assign`,r))}}}}function normalizeExtensionDefinition(e,t,r){n(e)||extensionError(`Client extension must be an object.`);let i=readOwnKeys(e);i.includes(`name`)||extensionError(`Client extension name must be a non-empty string.`);let a=readOwn(e,`name`);(typeof a!=`string`||a.trim().length===0)&&extensionError(`Client extension name must be a non-empty string.`);let o=a;for(let e of i)(typeof e!=`string`||!A.has(e))&&extensionError(`Extension "${o}" has unknown member "${String(e)}".`,o);let s=i.includes(`request`)?readOwn(e,`request`,o):void 0,c=s===void 0?void 0:snapshotOperationMap(s,`request`,o,t),l=i.includes(`query`)?readOwn(e,`query`,o):void 0,u=l===void 0?void 0:snapshotOperationMap(l,`query`,o,t),d=i.includes(`statement`)?readOwn(e,`statement`,o):void 0,f=d===void 0?void 0:requireFunction(d,`statement`,o),p=i.includes(`observe`)?readOwn(e,`observe`,o):void 0,m=p===void 0?void 0:requireFunction(p,`observe`,o),h=i.includes(`client`)?readOwn(e,`client`,o):void 0,g=h===void 0?void 0:requireFunction(h,`client`,o),_=i.includes(`model`)?readOwn(e,`model`,o):void 0,v=_===void 0?void 0:snapshotModelFactories(_,o,t),{controls:y,deletion:b,data:x}=e;validateNamedPolicies({rows:e.rows,deletion:b,data:x},t,o);let S=t&&e.rows?admitRows(e.rows,t,o,r):e.rows;return Object.freeze({name:o,...c?{request:c}:{},...u?{query:u}:{},...f?{statement:f}:{},...m?{observe:m}:{},...g?{client:g}:{},...v?{model:v}:{},...y?{controls:y}:{},...S?{rows:S}:{},...b?{deletion:b}:{},...x?{data:x}:{}})}function defineExtension(...e){return e.length===0?e=>normalizeExtensionDefinition(e):normalizeExtensionDefinition(e[0])}const NEVER_REQUIRED=()=>!1,j=Object.freeze(Object.create(null)),M=Object.freeze({}),N=Symbol(`absent`);function collectReferences(e,t){let n=e instanceof Condition?e.parameter:e;if(n instanceof Parameter)n.control!==void 0&&t.add(n.control);else if(isReference(e))t.add(e.control);else if(Array.isArray(e)||p(e))for(let n of Object.values(e))collectReferences(n,t)}function collectStampReferences(e,t){for(let n of Object.values(e??{}))collectReferences(n,t)}function undeclaredControlReferencesOf(e){let t=new Set(Object.keys(e.controls??{}));e.rows&&t.add(e.rows.control);let n=new Set;for(let t of Object.values(e.rows?.models??{}))for(let e of Object.values(t))collectReferences(e.root,n),collectReferences(e.related,n);for(let t of Object.values(e.rows?.verbs??{}))collectReferences(t.predicates,n);for(let t of Object.values(e.data?.models??{}))collectStampReferences(t.create,n),collectStampReferences(t.update,n);for(let t of Object.keys(e.deletion?.removeWhen??{}))n.add(t);return[...n].filter(e=>!t.has(e))}function readsCall(e){return e instanceof Parameter||e instanceof Condition?!0:Array.isArray(e)?e.some(readsCall):p(e)&&Object.values(e).some(readsCall)}function stampValue(e,t){if(isReference(e)){let n=t?.[e.control],{path:r}=e;for(let e of r===void 0?[]:r.split(`.`))n=p(n)&&Object.hasOwn(n,e)?n[e]:void 0;return n===void 0?N:n}if(Array.isArray(e)){let n=e.map(e=>stampValue(e,t));return n.includes(N)?N:n.every((t,n)=>t===e[n])?e:n}if(!p(e))return e;let n;for(let[r,i]of Object.entries(e)){let a=stampValue(i,t);if(a===N)return N;a!==i&&((n??={...e})[r]=a)}return n??e}function boundStamp(e,t){if(e===void 0)return;let n={},r=!1;for(let[i,a]of Object.entries(e)){let e=stampValue(a,t);r||=e!==a,e!==N&&(n[i]=e)}return r?Object.freeze(n):e}function boundStamps(e,t){let n=new Map;for(let[r,i]of e){let e=boundStamp(i.create,t),a=boundStamp(i.update,t);n.set(r,e===i.create&&a===i.update?i:Object.freeze({create:e,update:a}))}return n}const P=new Parameter;function withInstants(e){let t;for(let[n,r]of Object.entries(e??{}))isInstant(r)&&((t??={...e})[n]=P);return t===void 0?e:Object.freeze(t)}function requiredOn(e){let t=new Map;for(let n of e?.all??[])n.required!==void 0&&t.set(n.name,n.required);return t.size===0?NEVER_REQUIRED:(e,n)=>{let r=t.get(e);return r===!0||r?.has(n)===!0}}function modelDomain(e,t,n){let r=new Map;for(let[i,a]of e.entries())for(let[e,o]of Object.entries(a.models)){let a=o[t[i]]?.[n];if(a===void 0)continue;let s=r.get(e)??[];s[i]=a,r.set(e,s)}return r}const F=Object.freeze({OR:Object.freeze([])}),fieldsOf=(e,t)=>new Map(Object.entries(e??{}).map(([e,n])=>[e,t(n)]));function modelVerbs(e){let t=new Map,n=new Set;for(let[r,i]of e.entries())for(let[e,a]of Object.entries(i.verbs??{})){let i=a.evidence&&`${e}.${a.evidence.as}`;if(i!==void 0&&n.has(i))throw new f(`rows.verbs.${e}.evidence.as "${a.evidence.as}" is declared by two extensions of the chain.`,{meta:{model:e}});i!==void 0&&n.add(i);let named=e=>e===void 0?F:a.predicates[e],o=t.get(e)??[];o[r]=Object.freeze({read:named(a.read),update:named(a.update),delete:named(a.delete),writes:fieldsOf(a.writes,named),...a.place!==void 0&&{place:named(a.place)},moves:fieldsOf(a.moves,named),acyclic:Object.freeze([...a.acyclic??[]]),...a.evidence&&{evidence:Object.freeze({as:a.evidence.as,names:Object.freeze(a.evidence.names.map(e=>Object.freeze([e,named(e)]))),ordered:a.evidence.ordered===!0})},reads:fieldsOf(a.reads,named)}),t.set(e,o)}return t.size===0?void 0:t}function bindRows(e,t,n,r){let i=e??[],a=1,o=i.map(e=>{let t=c(e),n={control:e.control,names:t,modes:new Map(t.map((e,t)=>[e,t])),fallback:t.indexOf(e.default),stride:a};return a*=t.length,n}),s=[],l=modelVerbs(i);for(let e=0;e<a;e++){let t=o.map(t=>t.names[Math.floor(e/t.stride)%t.names.length]);s.push(Object.freeze({root:modelDomain(i,t,`root`),related:modelDomain(i,t,`related`),...l&&{verbs:l}}))}let u=s[o.reduce((e,t)=>e+t.fallback*t.stride,0)],d=t===void 0?void 0:new Map(Object.entries(t)),f=n===void 0?void 0:new Map(Object.entries(n).map(([e,t])=>{let n=withInstants(t.create),r=withInstants(t.update);return[e,n===t.create&&r===t.update?t:Object.freeze({create:n,update:r})]})),p=new Set;for(let e of f?.values()??[])collectStampReferences(e.create,p),collectStampReferences(e.update,p);let m=s.map(e=>Object.freeze({domain:e,defaults:u,...f&&{stamps:f}})),h=i.some(e=>Object.values(e.verbs??{}).some(e=>readsCall(e.predicates))),reads=e=>h||[e.root,e.related].some(e=>[...e.values()].some(readsCall));return Object.freeze({members:o,deletion:t??j,physical:m,tombstoning:d===void 0?m:m.map(e=>Object.freeze({...e,tombstones:d})),parametric:s.map(e=>reads(e)||reads(u)),bindsStamps:p.size>0,required:requiredOn(r)})}function callRows(e,t,n){let r=0;for(let t of e.members)r+=t.stride*(t.modes.get(n?.[t.control])??t.fallback);let i=e.deletion[t]?.removeWhen,a=(i!==void 0&&Object.entries(i).every(([e,t])=>n?.[e]===t)?e.physical:e.tombstoning)[r],o=e.parametric[r];return o||e.bindsStamps?Object.freeze({...a,...o&&{values:Object.freeze({controls:n??M,required:e.required})},...e.bindsStamps&&{stamps:boundStamps(a.stamps,n)}}):a}const I=`viborm.instrumentation`;function lookupResolvedExtensionHandlers(e,t,n,r){if(e===void 0)return;let i=e[t],a=i.global.length===0?void 0:i.global;return n===void 0?t===`query`?a:void 0:i.models[n]?.[r]??a}function lookupPlacedControls(e,t,n){return e?.controls?.placed(t,n)??L}const L=Object.freeze([]);function resolvedHandler(e,t){return Object.freeze({extension:e.name,handler:t})}function resolvedOperationHandler(e,t){return Object.freeze(e.controls===void 0?{extension:e.name,handler:t}:{extension:e.name,handler:t,controls:e.controls})}function appendModelHandler(e,t,n,r,i){let a=e[t]??=Object.create(null);(a[n]??=[...i]).push(r)}function appendGlobalHandler(e,t){for(let n of Object.values(e))for(let e of Object.values(n))e.push(t)}function appendOperationHandlers(e,n,r){if(r===void 0&&e!==void 0)return e;let i=Object.create(null),a=e?[...e.global]:[];if(e)for(let[t,n]of Object.entries(e.models)){let e=Object.create(null);for(let[t,r]of Object.entries(n))e[t]=[...r];i[t]=e}if(r)if(t(r)){let e=resolvedOperationHandler(n,r);a.push(e),appendGlobalHandler(i,e)}else for(let[e,t]of Object.entries(r))for(let[r,o]of Object.entries(t))appendModelHandler(i,e,r,resolvedOperationHandler(n,o),a);let o=Object.create(null);for(let[e,t]of Object.entries(i)){let n=Object.create(null);for(let[e,r]of Object.entries(t))n[e]=Object.freeze(r);o[e]=Object.freeze(n)}return Object.freeze({global:Object.freeze(a),models:Object.freeze(o)})}function hasCompiledHandlers(e){if(e.global.length>0)return!0;for(let t of Object.values(e.models))if(Object.keys(t).length>0)return!0;return!1}function appendFlatHandler(e,t,n){if(n===void 0)return e??Object.freeze([]);let r=e?[...e]:[];return r.push(resolvedHandler(t,n)),Object.freeze(r)}function appendObserver(e,t,n){if(n===void 0)return e??Object.freeze([]);let r=y(n);return r!==void 0&&!r.observesLifecycle?e??Object.freeze([]):appendFlatHandler(e,t,n)}function appendControls(e,t){let n=new Set(e?.names);for(let{name:r,extension:i}of t){if(n.has(r)){let n=[...e?.all??[],...t].find(e=>e.name===r).extension;extensionError(`Extension "${i}" declares control "${r}", which extension "${n}" already declares.`,i)}n.add(r)}let r=Object.freeze([...e?.all??[],...t.map(e=>Object.freeze(e))]),i=new Map,placed=(e,t)=>{let n=`${e}\u0000${t}`,a=i.get(n);if(a===void 0){let o=r.filter(n=>n.operations.has(t)&&(n.models===void 0||n.models.has(e)));a=o.length===0?L:Object.freeze(o),i.set(n,a)}return a};return Object.freeze({names:n,all:r,placed})}const R=Object.freeze({});function appendDeletion(e,t,n){let r=Object.create(null);Object.assign(r,e);for(let[e,i]of Object.entries(n.models))r[e]=Object.freeze({extension:t,...i,assign:i.assign??R,...n.removeWhen===void 0?{}:{removeWhen:n.removeWhen}});return Object.freeze(r)}function withStamp(e,t){return t===void 0?e:Object.freeze({...e,...t})}function appendData(e,t){let n=Object.create(null);Object.assign(n,e);for(let[e,r]of Object.entries(t.models)){let t=n[e];n[e]=Object.freeze({create:withStamp(t?.create,r.create),update:withStamp(t?.update,r.update)})}return Object.freeze(n)}function asOfficialCacheDefinition(e){let{query:t,...n}=e;return Object.freeze({...n,controls:u})}function stripOfficialDefaultOmitRequest(e){let{request:t,...n}=e;return Object.freeze(n)}function consumesOperationResults(e){return e.query!==void 0&&!t(e.query)||e.client!==void 0||e.model!==void 0}function assertOfficialExtensionAdmission(e){e.hasIdentity&&e.isAlreadyPresent&&extensionError(e.duplicateMessage,e.definitionName),e.hasIdentity&&e.definitionName!==e.officialName&&extensionError(`The official ${e.label} extension name must be "${e.officialName}".`,e.definitionName),!e.hasIdentity&&e.definitionName===e.officialName&&extensionError(`Extension name "${e.officialName}" is reserved for the official ${e.label} extension.`,e.definitionName)}function appendResolvedExtension(e,t,n,i){let c=normalizeExtensionDefinition(t,n,i),u=o(c.query),d=s(e),f=getOfficialDefaultOmitRequestCapability(c.request),p=getOfficialDefaultOmitChainCapability(e);assertOfficialExtensionAdmission({definitionName:c.name,officialName:a,label:`cache`,hasIdentity:u!==void 0,isAlreadyPresent:d!==void 0,duplicateMessage:`The official cache extension is already present on this client.`}),assertOfficialExtensionAdmission({definitionName:c.name,officialName:x,label:`default omit`,hasIdentity:f!==void 0,isAlreadyPresent:!1,duplicateMessage:`Extension "${x}" is already present on this client.`}),f!==void 0&&e?.hasResultConsumers===!0&&extensionError(`The default omit extension cannot follow an extension that defines model-mapped query, client, or model behavior.`,c.name),c.rows!==void 0&&e?.hasResultConsumers===!0&&extensionError(`Extension "${c.name}" declares rows, which cannot follow an extension that defines model-mapped query, client, or model behavior.`,c.name);let m=y(c.observe),h=b(e);assertOfficialExtensionAdmission({definitionName:c.name,officialName:I,label:`instrumentation`,hasIdentity:m!==void 0,isAlreadyPresent:h!==void 0,duplicateMessage:`The official instrumentation extension is already present on this client.`}),e?.extensions.some(e=>e.name===c.name)&&extensionError(`Extension "${c.name}" is already present on this client.`,c.name);let g=u===void 0?f===void 0?c:stripOfficialDefaultOmitRequest(c):asOfficialCacheDefinition(c),_=g.controls===void 0&&g.rows===void 0?void 0:r(g);for(let t of undeclaredControlReferencesOf(g))e?.controls?.names.has(t)!==!0&&extensionError(`Extension "${c.name}" references undeclared control "${t}".`,c.name);let S=Object.freeze({name:c.name,...g.client===void 0?{}:{client:g.client},...g.model===void 0?{}:{model:g.model}}),C=_===void 0?S:{name:c.name,controls:Object.freeze(_.map(e=>e.name))},w=Object.freeze(e?[...e.extensions,S]:[S]),T=appendOperationHandlers(e?.request,C,g.request),E=appendOperationHandlers(e?.query,C,g.query),D=_===void 0?e?.controls:appendControls(e?.controls,_),O=g.rows===void 0?e?.rows:Object.freeze([...e?.rows??[],g.rows]),k=g.deletion===void 0?e?.deletion:appendDeletion(e?.deletion,c.name,g.deletion),A=g.data===void 0?e?.data:appendData(e?.data,g.data),j=O===e?.rows&&k===e?.deletion&&A===e?.data?e?.callRows:bindRows(O,k,A,D),M=Object.freeze({...D===void 0?{}:{controls:D},...O===void 0?{}:{rows:O},...k===void 0?{}:{deletion:k},...A===void 0?{}:{data:A},...j===void 0?{}:{callRows:j},extensions:w,hasCache:u!==void 0||e?.hasCache===!0,hasRequestHandlers:hasCompiledHandlers(T),hasQueryHandlers:hasCompiledHandlers(E),hasResultConsumers:e?.hasResultConsumers===!0||consumesOperationResults(g),request:T,query:E,statement:appendFlatHandler(e?.statement,S,g.statement),observe:appendObserver(e?.observe,S,g.observe)}),N=m??h;N!==void 0&&v(M,N);let P=u??d;P!==void 0&&l(M,P);let F=f??p;return F!==void 0&®isterOfficialDefaultOmitChain(M,F),M}export{callRows as a,Condition as c,defaultOmit as d,getOfficialDefaultOmitChainCapability as f,lookupResolvedExtensionHandlers as i,Parameter as l,appendResolvedExtension as n,defineExtension as o,readDriverIdentity as p,lookupPlacedControls as r,extensionError as s,I as t,parseStamped as u};
|
|
2
|
-
//# sourceMappingURL=chain-C7c1YTXD.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"chain-C7c1YTXD.mjs","names":["readOwn","#keys","ownKeys","NO_CONTROLS","callRows"],"sources":["../src/drivers/driver-identity.ts","../src/client/default-omit-extension.ts","../src/query-engine/raptor3/shared/row-scope.ts","../src/extensions/admission.ts","../src/extensions/definition.ts","../src/extensions/rows.ts","../src/extensions/chain.ts"],"sourcesContent":["import type { Dialect } from \"./types\";\n\n/**\n * The configuration facts that name one driver in presented telemetry. No\n * package entry exports this module.\n *\n * `namespace` is the adapter's one normalized SQL qualifier and is absent when\n * the adapter is unqualified. `adapter.namespace` is installed non-writable,\n * so a snapshot taken once (the cached read's, at `$withCache`) cannot go\n * stale. This is the one reader of that property for presentation.\n */\nexport interface DriverIdentity {\n readonly dialect: Dialect;\n readonly driverName: string;\n readonly namespace?: string;\n}\n\n/** The public readonly driver fields an identity is read from. */\nexport interface DriverIdentitySource {\n readonly dialect: Dialect;\n readonly driverName: string;\n readonly adapter: { readonly namespace?: string };\n}\n\n/**\n * Read one driver's identity from its public readonly configuration, or\n * `undefined` when that read throws (a custom adapter's `namespace` getter):\n * every presenter then omits the driver attributes and presents the rest.\n */\nexport function readDriverIdentity(\n driver: DriverIdentitySource\n): DriverIdentity | undefined {\n try {\n const namespace = driver.adapter.namespace;\n return Object.freeze({\n dialect: driver.dialect,\n driverName: driver.driverName,\n ...(namespace === undefined ? {} : { namespace }),\n });\n } catch {\n // The operation's facts, its spans and a cached read's revalidation\n // identity survive a driver that cannot name itself.\n return undefined;\n }\n}\n","import { ClientInitializationError } from \"@errors\";\nimport type { ResolvedExtensionChain } from \"@extensions/chain\";\nimport type {\n GenericRequestHandler,\n OfficialGenericRequestHandler,\n} from \"@extensions/request\";\nimport { isFunction, isRecord } from \"@validation/value-guards\";\nimport { errorCause } from \"../errors/diagnostic-safety\";\nimport type { ClientOmitConfig, ExactClientOmitConfig } from \"./omit\";\nimport type { Schema } from \"./types\";\n\nexport const OFFICIAL_DEFAULT_OMIT_NAME = \"viborm.defaultOmit\";\n\ndeclare const officialDefaultOmitConfig: unique symbol;\n\n/** The authenticated request identity carrying one exact static omit witness. */\nexport type OfficialDefaultOmitRequestContribution<Config> =\n OfficialGenericRequestHandler & {\n readonly [officialDefaultOmitConfig]: Config;\n bind(thisArg: unknown): GenericRequestHandler;\n };\n\n/** The official value accepted by the dedicated `$extends` admission branch. */\nexport type OfficialDefaultOmitExtension<Config extends object = object> = {\n readonly name: typeof OFFICIAL_DEFAULT_OMIT_NAME;\n readonly request: OfficialDefaultOmitRequestContribution<Config>;\n};\n\nexport interface OfficialDefaultOmitCapability {\n readonly config: ClientOmitConfig<Schema>;\n}\n\nconst capabilitiesByRequest = new WeakMap<\n CallableFunction,\n OfficialDefaultOmitCapability\n>();\nconst capabilitiesByChain = new WeakMap<\n ResolvedExtensionChain,\n OfficialDefaultOmitCapability\n>();\n\nfunction configurationError(message: string, cause?: unknown): never {\n throw new ClientInitializationError(message, {\n cause: cause === undefined ? undefined : errorCause(cause),\n });\n}\n\nfunction ownKeys(value: object, label: string): PropertyKey[] {\n try {\n return Reflect.ownKeys(value);\n } catch (cause) {\n configurationError(\n `Default omit ${label} members could not be inspected.`,\n cause\n );\n }\n}\n\nfunction readOwn(\n value: Record<string, unknown>,\n key: string,\n label: string\n): unknown {\n try {\n return value[key];\n } catch (cause) {\n configurationError(\n `Default omit ${label} member \"${key}\" could not be read.`,\n cause\n );\n }\n}\n\nfunction isConfigurationRecord(\n value: unknown,\n label: string\n): value is Record<string, unknown> {\n try {\n return isRecord(value);\n } catch (cause) {\n configurationError(`Default omit ${label} could not be inspected.`, cause);\n }\n}\n\nfunction snapshotConfig(value: unknown): ClientOmitConfig<Schema> {\n if (!isConfigurationRecord(value, \"configuration\")) {\n configurationError(\"Default omit configuration must be an object.\");\n }\n const snapshot: Record<\n string,\n Readonly<Record<string, true>>\n > = Object.create(null);\n for (const modelKey of ownKeys(value, \"configuration\")) {\n if (typeof modelKey !== \"string\") {\n configurationError(\n \"Default omit configuration contains a non-string model key.\"\n );\n }\n const entry = readOwn(value, modelKey, \"configuration\");\n if (!isConfigurationRecord(entry, `configuration.${modelKey}`)) {\n configurationError(\n `Default omit configuration member \"${modelKey}\" must be an object.`\n );\n }\n const fields: Record<string, true> = Object.create(null);\n for (const fieldKey of ownKeys(entry, `configuration.${modelKey}`)) {\n if (typeof fieldKey !== \"string\") {\n configurationError(\n `Default omit configuration member \"${modelKey}\" contains a non-string field key.`\n );\n }\n if (readOwn(entry, fieldKey, `configuration.${modelKey}`) !== true) {\n configurationError(\n `Default omit configuration member \"${modelKey}.${fieldKey}\" must be true.`\n );\n }\n fields[fieldKey] = true;\n }\n snapshot[modelKey] = Object.freeze(fields);\n }\n return Object.freeze(snapshot);\n}\n\nexport type DefaultOmitBinder<S extends Schema> = <\n const Config extends ClientOmitConfig<S>,\n>(\n config: Config & NoInfer<ExactClientOmitConfig<Config, S>>\n) => OfficialDefaultOmitExtension<Config & object>;\n\n/** Create VibORM's fixed-name schema-bound default-omit extension. */\nexport function defaultOmit<S extends Schema>(): DefaultOmitBinder<S>;\nexport function defaultOmit(): unknown {\n return (config: unknown): unknown => {\n const capability = Object.freeze({ config: snapshotConfig(config) });\n const request: GenericRequestHandler = () => ({});\n capabilitiesByRequest.set(request, capability);\n return Object.freeze({\n name: OFFICIAL_DEFAULT_OMIT_NAME,\n request,\n });\n };\n}\n\nexport function getOfficialDefaultOmitRequestCapability(\n request: unknown\n): OfficialDefaultOmitCapability | undefined {\n return isFunction(request) ? capabilitiesByRequest.get(request) : undefined;\n}\n\nexport function getOfficialDefaultOmitChainCapability(\n chain: ResolvedExtensionChain | undefined\n): OfficialDefaultOmitCapability | undefined {\n return chain === undefined ? undefined : capabilitiesByChain.get(chain);\n}\n\nexport function registerOfficialDefaultOmitChain(\n chain: ResolvedExtensionChain,\n capability: OfficialDefaultOmitCapability\n): void {\n capabilitiesByChain.set(chain, capability);\n}\n","import { parseProviding } from \"@validation/primitives/object\";\nimport type { PreparedDomain } from \"./query\";\nimport type { Input } from \"./schema\";\n\n/**\n * `where` inputs per model (its TS name), as admission left them: a value the\n * call supplies is a {@link Parameter}, a test of one a {@link Condition}. They\n * AND with each other; a model with none is not narrowed. Each list is\n * indexed by layer, the declaring `rows` member's place in the chain, so a\n * layer stating nothing for the model leaves a hole.\n */\nexport type ModelDomain = ReadonlyMap<string, readonly Input[]>;\n\n/**\n * The rows an operation may take, by purpose: its own candidates (`root`) and\n * rows it reaches through a relation (`related`).\n */\nexport interface RowDomain {\n readonly root: ModelDomain;\n readonly related: ModelDomain;\n /**\n * Per model (its TS name), indexed by layer as {@link ModelDomain} is, the\n * predicates of the model's verbs. A model absent here judges a write by\n * its purpose's predicates alone.\n */\n readonly verbs?: ReadonlyMap<string, readonly (ModelVerbs | undefined)[]>;\n}\n\n/**\n * One layer's predicates for one model's verbs, as admission left them: `read`\n * ANDs with the layer's predicate at every purpose, a write's verb with its\n * candidates beside them (R2). An update takes, per field its data writes,\n * that field's predicate, else `update`'s. The row a write produces is\n * judged as a value (R4): a created row at `place`, absent where the layer\n * does not judge creates; an updated row at the predicates that judged its\n * old row and, per field it writes, that field's `moves` predicate.\n */\nexport interface ModelVerbs {\n readonly read: Input;\n readonly update: Input;\n readonly delete: Input;\n readonly writes: ReadonlyMap<string, Input>;\n readonly place?: Input;\n readonly moves: ReadonlyMap<string, Input>;\n /**\n * Self relations, each held by this model's key, whose links stay\n * acyclic: an update writing one is refused where its new target is the\n * row itself or a row below it.\n */\n readonly acyclic: readonly string[];\n /** The projection key the layer declares on the model (K5). */\n readonly evidence?: ModelEvidence;\n /**\n * Per read-gated field, the predicate a row holds, beside `read`, where it\n * carries the field (K5).\n */\n readonly reads: ReadonlyMap<string, Input>;\n}\n\n/**\n * A projection key and what it reports per row, each name with its admitted\n * predicate in declared order: whether each holds beside `read`, or, when\n * `ordered`, the last that does.\n */\nexport interface ModelEvidence {\n readonly as: string;\n readonly names: readonly (readonly [string, Input])[];\n readonly ordered: boolean;\n}\n\n/**\n * The verb a write lookup takes beside its purpose (R3): `delete`, or `update`\n * with the fields the occurrence's data writes, none when it writes only\n * stamps and generated values.\n */\nexport interface RowJudgement {\n readonly verb: \"update\" | \"delete\";\n readonly writes: readonly string[];\n /**\n * The caller writes a field the model's tombstone manages (sets or clears\n * a marker by hand, a restore): the row is also judged at `delete`, as the\n * tombstone the extension writes is.\n */\n readonly marks?: true;\n}\n\n/**\n * Which rows a candidate lookup takes: the call's own (`root`) or rows reached\n * through a relation (`related`). A lookup that names no purpose is a premise\n * or physical: it takes exactly the selector it is handed.\n */\nexport type RowPurpose = \"root\" | \"related\";\n\n/** What a delete of one model writes instead of removing the row. */\nexport interface Tombstone {\n /** The DateTime field that receives the call's one instant. */\n readonly at?: string;\n /** Constant scalar data, written beside it. */\n readonly assign: Input;\n}\n\n/**\n * A model's stamps: what the call's extensions write on every create, and on\n * every update, tombstones too. Each is scalar `data` input, as declared with\n * the call's control values put in: constants and, on an update, the field's\n * update operators.\n */\nexport interface ModelStamps {\n readonly create?: Input;\n readonly update?: Input;\n}\n\n/**\n * Parse the caller's data where validation knows what the call's create\n * stamps write ({@link parseProviding}, by the model's TS name): a required\n * field a stamp writes may be left out, as the stamp writes it after\n * admission. A field whose control the call left out is not written, so it\n * is still asked for. `parse` is synchronous; a call without stamps never\n * comes here.\n */\nexport const parseStamped = <T>(\n stamps: ReadonlyMap<string, ModelStamps>,\n parse: () => T\n): T =>\n parseProviding(\n (model, field) => stamps.get(model)?.create?.[field] !== undefined,\n parse\n );\n\n/**\n * One root call's row facts, resolved from its controls outside the engine:\n * the engine never sees a mode or an extension's name, and a control's only\n * as the key a parameter reads its value under ({@link CallValues}). Its domains\n * are shared by every call that resolves to the same ones; stamps that name a\n * control are the call's own.\n */\nexport interface CallRows {\n /** The domain the call's own controls select. */\n readonly domain: RowDomain;\n /**\n * The domain an absent control selects: what a tombstoning delete takes,\n * and every other layer a layer's own traversals read (R5).\n */\n readonly defaults: RowDomain;\n /**\n * Per managed model, what its deletes write; absent when the call deletes\n * physically (its controls match the declaration's `removeWhen`).\n */\n readonly tombstones?: ReadonlyMap<string, Tombstone>;\n /** Per model (its TS name), the fields its creates and updates write. */\n readonly stamps?: ReadonlyMap<string, ModelStamps>;\n /** What the domains' parameters read; absent when no predicate names one. */\n readonly values?: CallValues;\n}\n\n/** A call's admitted controls, and how an absent value resolves (R6). */\nexport interface CallValues {\n readonly controls: Readonly<Record<string, unknown>>;\n /** An absent value of `control` on `model` matches nothing; else it drops. */\n readonly required: (control: string, model: string) => boolean;\n}\n\n/**\n * A value a domain predicate reads from its call, prepared once and read at\n * lowering: a control's value, or a field of it along `path`; with no\n * control, the call's one instant. `null` is absent: a parameter never lowers\n * to `IS NULL`. Its own fields are its spelling (`{ control, path }` or\n * `{ now: true }`), which no literal of a declaration can be, so a cache key\n * over declarations tells the two apart.\n */\nexport class Parameter {\n readonly control?: string;\n readonly path?: string;\n readonly now?: true;\n readonly #keys: readonly string[];\n constructor(control?: string, path?: string) {\n if (control === undefined) this.now = true;\n else this.control = control;\n if (path !== undefined) this.path = path;\n this.#keys = path === undefined ? [] : path.split(\".\");\n Object.freeze(this);\n }\n /** The call's value, `undefined` when absent. */\n read(values: CallValues | undefined, instant: () => Date): unknown {\n if (this.control === undefined) return instant();\n let value = values?.controls[this.control];\n for (const key of this.#keys) {\n if (value === null || typeof value !== \"object\") return undefined;\n value = Object.hasOwn(value, key) ? (value as Input)[key] : undefined;\n }\n return value ?? undefined;\n }\n}\n\n/** What a {@link Condition} asks of its value, in the filter vocabulary. */\nexport type ConditionTest =\n | { readonly exists: boolean }\n | { readonly equals: unknown }\n | { readonly in: readonly unknown[] }\n | { readonly has: unknown }\n | { readonly hasSome: readonly unknown[] };\n\n/** A test of a call value that reads no column: folded per call. */\nexport class Condition {\n readonly parameter: Parameter;\n readonly test: ConditionTest;\n constructor(parameter: Parameter, test: ConditionTest) {\n this.parameter = parameter;\n this.test = test;\n Object.freeze(this);\n }\n holds(values: CallValues | undefined, instant: () => Date): boolean {\n const value = this.parameter.read(values, instant);\n const test = this.test;\n if (\"exists\" in test) return (value !== undefined) === test.exists;\n if (value === undefined) return false;\n if (\"equals\" in test) return Object.is(value, test.equals);\n if (\"in\" in test) return test.in.includes(value);\n if (!Array.isArray(value)) return false;\n if (\"has\" in test) return value.includes(test.has);\n return test.hasSome.some((member) => value.includes(member));\n }\n}\n\n/** The row facts one prepared call carries, and its one instant. */\nexport interface CallScope {\n readonly rows: CallRows;\n /** The call's domain, prepared once per engine view. */\n readonly domain: PreparedDomain;\n /** The default domain, prepared once per engine view. */\n readonly defaults: PreparedDomain;\n /**\n * The call's one instant (a tombstone's, and `{ now: true }`'s): sampled at\n * its first use and kept for the prepared call's lifetime, so every\n * occurrence of every attempt shares it.\n */\n instant(): Date;\n}\n","import type { Schema } from \"@client/types\";\nimport { ClientInitializationError } from \"@errors\";\nimport {\n Condition,\n type ConditionTest,\n Parameter,\n} from \"@query-engine/raptor3/shared/row-scope\";\nimport type { ModelState } from \"@schema/model\";\nimport { isPlainRecord } from \"@schema/relation/terminal\";\nimport { createSchemaRegistry } from \"@validation/builder\";\nimport { validateSchema } from \"@validation/primitives/helpers\";\nimport {\n admittingDomainPredicate,\n type DomainMarkers,\n} from \"@validation/primitives/parameter\";\nimport type { SchemaRegistryLookup } from \"@validation/types\";\nimport type { RowsContribution, RowsVerbs } from \"./controls\";\n\n/**\n * Each domain predicate admitted once, when its extension is applied, through\n * its model's `where` schema: a misspelt key fails here, never at the first\n * read, and the engine prepares what a caller's `where` would be (K1(a)).\n */\n\n/**\n * The where schemas of a schema no client prepared (a definition read on its\n * own), built once; a client hands admission its own.\n */\nconst registries = new WeakMap<Schema, SchemaRegistryLookup<Schema>>();\n\nfunction standaloneRegistry(schema: Schema): SchemaRegistryLookup<Schema> {\n let registry = registries.get(schema);\n if (registry === undefined) {\n registry = createSchemaRegistry(schema);\n registries.set(schema, registry);\n }\n return registry;\n}\n\n/** A model's `rows.verbs` entry, key by key. */\nconst VERBS_KEYS: Record<keyof RowsVerbs, true> = {\n predicates: true,\n read: true,\n update: true,\n delete: true,\n writes: true,\n place: true,\n moves: true,\n acyclic: true,\n evidence: true,\n reads: true,\n};\n\n/**\n * A declared projection key's spelling: `$` and an identifier. No model\n * member and no engine carrier is spelled so, so a key never hides either,\n * whatever the schema later adds.\n */\nconst PROJECTION_KEY = /^\\$[a-zA-Z_][a-zA-Z0-9_]*$/;\n\n/**\n * A model's key, unique and foreign-key fields: what identity and every join\n * read, and what a unique constraint answers for on a write, so none of them\n * is ever read-gated.\n */\nfunction keyFields(state: ModelState): ReadonlySet<string> {\n return new Set([\n ...Object.entries(state.scalars)\n .filter(([, scalar]) => scalar[\"~\"].state.isId === true)\n .map(([field]) => field),\n // A write of a guessed value fails on the constraint exactly when some\n // row holds it: a gate on a unique field would be confirmed by it.\n ...Object.keys(state.uniques),\n ...[\n ...Object.values(state.compoundId ?? {}),\n ...Object.values(state.compoundUniques ?? {}),\n ].flatMap(({ entries }) => Object.keys(entries)),\n ...Object.values(state.relations).flatMap(\n (relation) => relation[\"~\"].state.foreignKey?.fields ?? []\n ),\n ]);\n}\n\n/** A condition's tests, the filter vocabulary's own words (OD-12). */\nconst TESTS = [\"exists\", \"equals\", \"in\", \"has\", \"hasSome\"] as const;\n\n/** `{ control, path? }`: a control's value, or a field of it. */\nexport function isReference(\n value: unknown\n): value is { readonly control: string; readonly path?: string } {\n return (\n isPlainRecord(value) &&\n typeof value.control === \"string\" &&\n Object.keys(value).every((key) => key === \"control\" || key === \"path\") &&\n (value.path === undefined || typeof value.path === \"string\")\n );\n}\n\n/** `{ now: true }`: the call's one instant. */\nexport const isInstant = (value: unknown): boolean =>\n isPlainRecord(value) && value.now === true && Object.keys(value).length === 1;\n\nconst REFUSED_CONDITION = `a condition names one control and exactly one of ${TESTS.join(\", \")}`;\n\n/** `$if`'s `{ control, path?, <one test> }` as a condition, or the refusal. */\nfunction conditionOf(spec: unknown): Condition | string {\n if (!isPlainRecord(spec)) return REFUSED_CONDITION;\n const { control, path, ...tests } = spec;\n const [test, ...others] = Object.keys(tests);\n const operand = tests[test!];\n if (\n typeof control !== \"string\" ||\n (path !== undefined && typeof path !== \"string\") ||\n !TESTS.includes(test as (typeof TESTS)[number]) ||\n others.length > 0 ||\n (test === \"exists\" && typeof operand !== \"boolean\") ||\n ((test === \"in\" || test === \"hasSome\") && !Array.isArray(operand))\n )\n return REFUSED_CONDITION;\n return new Condition(\n new Parameter(control, path),\n Object.freeze({ [test!]: operand }) as unknown as ConditionTest\n );\n}\n\n/** The nodes a predicate's markers stand for, as its `where` meets them. */\nconst MARKERS: DomainMarkers = {\n value: (value) => {\n if (isReference(value)) return new Parameter(value.control, value.path);\n return isInstant(value) ? new Parameter() : undefined;\n },\n condition: conditionOf,\n};\n\n/**\n * The path at which `value` contains itself, `undefined` where it does not.\n * Only an object inside its own descendants is refused: a predicate may share\n * sub-objects freely.\n */\nfunction cyclePath(\n value: unknown,\n ancestors = new Set<object>(),\n path: string[] = []\n): string | undefined {\n if (typeof value !== \"object\" || value === null) return undefined;\n // The root has no ancestor: a path is never empty here.\n if (ancestors.has(value)) return path.join(\".\");\n ancestors.add(value);\n for (const [key, item] of Object.entries(value)) {\n path.push(key);\n const found = cyclePath(item, ancestors, path);\n if (found !== undefined) return found;\n path.pop();\n }\n ancestors.delete(value);\n return undefined;\n}\n\n/**\n * One definition's `rows` with every predicate admitted, each named predicate\n * once and a mode naming one given its admitted object: refusals are\n * `ClientInitializationError`s naming the extension, the model, the\n * predicate's place in `rows` and the path inside it.\n */\nexport function admitRows(\n rows: RowsContribution,\n schema: Schema,\n extension: string,\n registry: SchemaRegistryLookup<Schema> = standaloneRegistry(schema)\n): RowsContribution {\n const refuse = (\n name: string,\n place: string,\n at: string,\n reason: string\n ): never => {\n throw new ClientInitializationError(\n `Extension \"${extension}\" rows.${place} at \"${at}\": ${reason}.`,\n { meta: { extension, model: name } }\n );\n };\n const admit = (\n name: string,\n place: string,\n predicate: unknown\n ): Record<string, unknown> => {\n const cycle = cyclePath(predicate);\n if (cycle !== undefined) refuse(name, place, cycle, \"contains itself\");\n const where = registry.getModelSchemas(schema[name]!).core.where;\n const result = admittingDomainPredicate(MARKERS, () =>\n validateSchema(where, predicate)\n );\n if (!result.issues) return result.value as Record<string, unknown>;\n const [issue] = result.issues;\n return refuse(\n name,\n place,\n issue!.path?.map(String).join(\".\") || \"root\",\n issue!.message\n );\n };\n const verbs: Record<string, RowsVerbs> = {};\n for (const [name, entry] of Object.entries(rows.verbs ?? {})) {\n const place = `verbs.${name}`;\n if (!Object.hasOwn(schema, name))\n refuse(name, place, \"root\", \"names an unknown model\");\n // Policies may be data built at runtime: a misspelt `writes` would leave\n // its field judged at `update`, which widens the write.\n for (const key of Object.keys(entry))\n if (!Object.hasOwn(VERBS_KEYS, key))\n refuse(\n name,\n place,\n key,\n `is not one of ${Object.keys(VERBS_KEYS).join(\", \")}`\n );\n const { state } = schema[name]![\"~\"];\n const predicates = Object.fromEntries(\n Object.entries(entry.predicates).map(([key, predicate]) => [\n key,\n admit(name, `${place}.predicates.${key}`, predicate),\n ])\n );\n const known = (at: string, predicate: string | undefined) => {\n if (predicate !== undefined && !Object.hasOwn(predicates, predicate))\n refuse(name, place, at, `names unknown predicate \"${predicate}\"`);\n };\n known(\"read\", entry.read);\n known(\"update\", entry.update);\n known(\"delete\", entry.delete);\n known(\"place\", entry.place);\n for (const key of [\"writes\", \"moves\"] as const)\n for (const [field, predicate] of Object.entries(entry[key] ?? {})) {\n if (\n !(\n Object.hasOwn(state.scalars, field) ||\n Object.hasOwn(state.relations, field)\n )\n )\n refuse(name, place, `${key}.${field}`, \"names an unknown field\");\n known(`${key}.${field}`, predicate);\n }\n for (const relation of entry.acyclic ?? []) {\n const held = Object.hasOwn(state.relations, relation)\n ? state.relations[relation]![\"~\"]\n : undefined;\n if (\n held?.state.foreignKey === undefined ||\n held.settleTarget() !== schema[name]\n )\n refuse(\n name,\n place,\n `acyclic.${relation}`,\n \"names no to-one relation of the model to itself holding its key\"\n );\n }\n const { evidence } = entry;\n if (evidence !== undefined) {\n if (!PROJECTION_KEY.test(evidence.as))\n refuse(name, place, \"evidence.as\", \"is not `$` and an identifier\");\n for (const [index, predicate] of evidence.names.entries())\n known(`evidence.names.${index}`, predicate);\n }\n const keys = entry.reads === undefined ? undefined : keyFields(state);\n for (const [field, predicate] of Object.entries(entry.reads ?? {})) {\n if (!Object.hasOwn(state.scalars, field))\n refuse(name, place, `reads.${field}`, \"names no scalar of the model\");\n // Masked in a caller's operands while identity and joins read it raw,\n // a key would answer through a relation what a filter hides.\n if (keys!.has(field))\n refuse(\n name,\n place,\n `reads.${field}`,\n \"names a key, a unique or a foreign key field\"\n );\n known(`reads.${field}`, predicate);\n }\n verbs[name] = Object.freeze({\n ...entry,\n predicates: Object.freeze(predicates),\n });\n }\n const models: Record<string, Record<string, object>> = {};\n for (const [name, modes] of Object.entries(rows.models)) {\n const admitted = new Map<string, object>();\n for (const [mode, purposes] of Object.entries(modes)) {\n const out: Record<string, unknown> = {};\n for (const purpose of [\"root\", \"related\"] as const) {\n const predicate = purposes[purpose];\n if (predicate === undefined) continue;\n const place = `${name}.${mode}.${purpose}`;\n if (typeof predicate !== \"string\")\n out[purpose] = admit(name, place, predicate);\n else if (Object.hasOwn(verbs[name]?.predicates ?? {}, predicate))\n out[purpose] = verbs[name]!.predicates[predicate];\n else\n refuse(name, place, \"root\", `names unknown predicate \"${predicate}\"`);\n }\n admitted.set(mode, Object.freeze(out));\n }\n models[name] = Object.freeze(Object.fromEntries(admitted));\n }\n return Object.freeze({\n ...rows,\n models: Object.freeze(models),\n ...(rows.verbs && { verbs: Object.freeze(verbs) }),\n });\n}\n","import type { VibORMConfig } from \"@client/client\";\nimport type { ClientSchema } from \"@client/schema-links\";\nimport type { Operations, Schema } from \"@client/types\";\nimport type { AnyDriver } from \"@drivers/exports\";\nimport { ClientInitializationError } from \"@errors\";\nimport { ROUTED_OPERATIONS } from \"@query-engine/routed-operations\";\nimport type { SchemaRegistryLookup } from \"@validation/types\";\nimport { isFunction, isRecord } from \"@validation/value-guards\";\nimport { errorCause } from \"../errors/diagnostic-safety\";\nimport { admitRows } from \"./admission\";\nimport type {\n ControlsContribution,\n DataContribution,\n DeletionContribution,\n RowsContribution,\n} from \"./controls\";\nimport type {\n EmptyClientExtensionState,\n ExtensionClientScope,\n ExtensionMethodDefinitionGuard,\n ExtensionMethodRecord,\n ExtensionModelDelegate,\n ExtensionStateConstraint,\n ResultConsumerContextOf,\n RuntimeClientMethodContribution,\n RuntimeModelMethodContribution,\n} from \"./methods\";\nimport type { ObserveHandler } from \"./observation\";\nimport type {\n GenericQueryHandler,\n QueryHandlerMap,\n RuntimeQueryContribution,\n} from \"./query\";\nimport type {\n GenericRequestHandler,\n RequestHandlerMap,\n RuntimeRequestContribution,\n} from \"./request\";\nimport type { StatementHandler } from \"./statement\";\n\ntype RuntimeExtensionFunction = (...args: never[]) => unknown;\n\n/**\n * One extension definition as the chain binds it: a host-owned frozen\n * snapshot of the six handler members, `rows` as admission left it (against\n * a schema), and `controls`, `deletion` and `data` as the definition wrote\n * them.\n */\nexport interface RuntimeExtensionDefinition {\n readonly name: string;\n readonly request?: RuntimeRequestContribution;\n readonly query?: RuntimeQueryContribution;\n readonly statement?: RuntimeExtensionFunction;\n readonly observe?: RuntimeExtensionFunction;\n readonly client?: RuntimeClientMethodContribution;\n readonly model?: RuntimeModelMethodContribution;\n readonly controls?: ControlsContribution;\n readonly rows?: RowsContribution;\n readonly deletion?: DeletionContribution;\n readonly data?: DataContribution;\n}\n\nexport type ControlLiteral = string | number | boolean;\n\n/**\n * What `$extends` hands the chain. Schema-bound row/data/deletion model and\n * field names are checked before they can silently bind to no policy.\n * Handler members retain the hostile-definition boundary below.\n */\nexport type ExtensionDefinitionInput = Readonly<Record<string, unknown>> & {\n readonly controls?: ControlsContribution;\n readonly rows?: RowsContribution;\n readonly deletion?: DeletionContribution;\n readonly data?: DataContribution;\n};\n\nconst DEFINITION_KEYS = new Set([\n \"name\",\n \"request\",\n \"query\",\n \"statement\",\n \"observe\",\n \"client\",\n \"model\",\n \"controls\",\n \"rows\",\n \"deletion\",\n \"data\",\n]);\n\nexport function extensionError(message: string, extension?: string): never {\n throw new ClientInitializationError(message, {\n meta: extension ? { extension } : undefined,\n });\n}\n\nfunction readOwnKeys(\n value: Record<string, unknown>,\n extension?: string\n): PropertyKey[] {\n try {\n return Reflect.ownKeys(value);\n } catch (cause) {\n throw new ClientInitializationError(\n extension\n ? `Extension \"${extension}\" members could not be inspected.`\n : \"Client extension members could not be inspected.\",\n {\n cause: errorCause(cause),\n meta: extension ? { extension } : undefined,\n }\n );\n }\n}\n\nfunction readOwn(\n value: Record<string, unknown>,\n key: string,\n extension?: string\n): unknown {\n try {\n return value[key];\n } catch (cause) {\n throw new ClientInitializationError(\n extension\n ? `Extension \"${extension}\" member \"${key}\" could not be read.`\n : `Client extension member \"${key}\" could not be read.`,\n {\n cause: errorCause(cause),\n meta: extension ? { extension } : undefined,\n }\n );\n }\n}\n\nfunction requireFunction(\n value: unknown,\n label: string,\n extension: string\n): RuntimeExtensionFunction {\n if (!isFunction(value)) {\n extensionError(\n `Extension \"${extension}\" ${label} must be a function.`,\n extension\n );\n }\n return value;\n}\n\nfunction snapshotOperationMap(\n component: unknown,\n label: \"request\" | \"query\",\n extension: string,\n schema?: Schema\n): RuntimeExtensionDefinition[\"request\"] {\n if (isFunction(component)) return component;\n if (!isRecord(component)) {\n extensionError(\n `Extension \"${extension}\" ${label} must be a function or model map.`,\n extension\n );\n }\n\n const models: Record<\n string,\n Readonly<Record<string, RuntimeExtensionFunction>>\n > = Object.create(null);\n for (const modelKey of readOwnKeys(component, extension)) {\n if (typeof modelKey !== \"string\") {\n extensionError(\n `Extension \"${extension}\" ${label} contains a non-string model key.`,\n extension\n );\n }\n if (schema && !Object.hasOwn(schema, modelKey)) {\n extensionError(\n `Extension \"${extension}\" ${label} names unknown model \"${modelKey}\".`,\n extension\n );\n }\n const handlers = readOwn(component, modelKey, extension);\n if (!isRecord(handlers)) {\n extensionError(\n `Extension \"${extension}\" ${label}.${modelKey} must be an operation map.`,\n extension\n );\n }\n const operations: Record<string, RuntimeExtensionFunction> =\n Object.create(null);\n for (const operationKey of readOwnKeys(handlers, extension)) {\n if (typeof operationKey !== \"string\") {\n extensionError(\n `Extension \"${extension}\" ${label}.${modelKey} contains a non-string operation key.`,\n extension\n );\n }\n if (!ROUTED_OPERATIONS.has(operationKey)) {\n extensionError(\n `Extension \"${extension}\" ${label}.${modelKey} names unknown operation \"${operationKey}\".`,\n extension\n );\n }\n operations[operationKey] = requireFunction(\n readOwn(handlers, operationKey, extension),\n `${label}.${modelKey}.${operationKey}`,\n extension\n );\n }\n models[modelKey] = Object.freeze(operations);\n }\n return Object.freeze(models);\n}\n\nfunction snapshotModelFactories(\n component: unknown,\n extension: string,\n schema?: Schema\n): RuntimeExtensionDefinition[\"model\"] {\n if (!isRecord(component)) {\n extensionError(\n `Extension \"${extension}\" model must be a model map.`,\n extension\n );\n }\n const factories: Record<string, RuntimeExtensionFunction> =\n Object.create(null);\n for (const modelKey of readOwnKeys(component, extension)) {\n if (typeof modelKey !== \"string\") {\n extensionError(\n `Extension \"${extension}\" model contains a non-string model key.`,\n extension\n );\n }\n if (schema && !Object.hasOwn(schema, modelKey)) {\n extensionError(\n `Extension \"${extension}\" model names unknown model \"${modelKey}\".`,\n extension\n );\n }\n factories[modelKey] = requireFunction(\n readOwn(component, modelKey, extension),\n `model.${modelKey}`,\n extension\n );\n }\n return Object.freeze(factories);\n}\n\n/** Refuse named policy facts that could otherwise silently bind to nothing. */\nfunction validateNamedPolicies(\n value: ExtensionDefinitionInput,\n schema: Schema | undefined,\n name: string\n): void {\n if (!schema) return;\n const components: (\"rows\" | \"data\" | \"deletion\")[] = [\n \"rows\",\n \"data\",\n \"deletion\",\n ];\n for (const component of components) {\n const declaration = readOwn(value, component, name);\n if (declaration === undefined) continue;\n if (!isRecord(declaration))\n extensionError(\n `Extension \"${name}\" ${component} must be an object.`,\n name\n );\n const models = readOwn(declaration, \"models\", name);\n if (!isRecord(models))\n extensionError(\n `Extension \"${name}\" ${component}.models must be an object.`,\n name\n );\n let expectedModes: readonly string[] | undefined;\n const defaultMode =\n component === \"rows\" ? readOwn(declaration, \"default\", name) : undefined;\n for (const modelName of readOwnKeys(models, name)) {\n if (typeof modelName !== \"string\" || !Object.hasOwn(schema, modelName))\n extensionError(\n `Extension \"${name}\" ${component} names unknown model \"${String(modelName)}\".`,\n name\n );\n const model = schema[modelName]!;\n const entry = readOwn(models, modelName, name);\n if (!isRecord(entry))\n extensionError(\n `Extension \"${name}\" ${component}.${modelName} must be an object.`,\n name\n );\n // A row predicate's fields are its admission's (`admission.ts`).\n const fields = (input: unknown): void => {\n if (input === undefined) return;\n if (!isRecord(input))\n extensionError(\n `Extension \"${name}\" ${component}.${modelName} fields must be an object.`,\n name\n );\n for (const key of readOwnKeys(input, name)) {\n if (\n typeof key !== \"string\" ||\n !Object.hasOwn(model[\"~\"].state.scalars, key)\n )\n extensionError(\n `Extension \"${name}\" ${component}.${modelName} names unknown field \"${String(key)}\".`,\n name\n );\n }\n };\n if (component === \"rows\") {\n const modes = readOwnKeys(entry, name).filter(\n (key): key is string => typeof key === \"string\"\n );\n const priorModes = expectedModes;\n if (\n typeof defaultMode !== \"string\" ||\n !modes.includes(defaultMode) ||\n (priorModes &&\n (priorModes.length !== modes.length ||\n modes.some((mode) => !priorModes.includes(mode))))\n )\n extensionError(\n `Extension \"${name}\" row models must share mode names and include the default mode.`,\n name\n );\n expectedModes ??= modes;\n for (const modeName of readOwnKeys(entry, name)) {\n if (typeof modeName !== \"string\")\n extensionError(\n `Extension \"${name}\" row mode must be a string.`,\n name\n );\n const mode = readOwn(entry, modeName, name);\n if (!isRecord(mode))\n extensionError(\n `Extension \"${name}\" row mode must be an object.`,\n name\n );\n }\n } else if (component === \"data\") {\n fields(readOwn(entry, \"create\", name));\n fields(readOwn(entry, \"update\", name));\n } else {\n const at = readOwn(entry, \"at\", name);\n if (\n at !== undefined &&\n (typeof at !== \"string\" ||\n !Object.hasOwn(model[\"~\"].state.scalars, at))\n )\n extensionError(\n `Extension \"${name}\" deletion.${modelName}.at names unknown scalar.`,\n name\n );\n fields(readOwn(entry, \"assign\", name));\n }\n }\n }\n}\n\n/**\n * Read a caller-owned definition once. The six handler members are validated\n * and frozen as host-owned snapshots, so a failed application cannot mutate\n * the supplied value; against a schema, every `rows` predicate is admitted\n * through its model's `where` schema; `controls`, `deletion` and `data` are\n * bound as written.\n */\nexport function normalizeExtensionDefinition(\n value: ExtensionDefinitionInput,\n schema?: Schema,\n registry?: SchemaRegistryLookup<Schema>\n): RuntimeExtensionDefinition {\n if (!isRecord(value)) {\n extensionError(\"Client extension must be an object.\");\n }\n const ownKeys = readOwnKeys(value);\n if (!ownKeys.includes(\"name\")) {\n extensionError(\"Client extension name must be a non-empty string.\");\n }\n const rawName = readOwn(value, \"name\");\n if (typeof rawName !== \"string\" || rawName.trim().length === 0) {\n extensionError(\"Client extension name must be a non-empty string.\");\n }\n const name = rawName;\n for (const key of ownKeys) {\n if (typeof key !== \"string\" || !DEFINITION_KEYS.has(key)) {\n extensionError(\n `Extension \"${name}\" has unknown member \"${String(key)}\".`,\n name\n );\n }\n }\n\n const rawRequest = ownKeys.includes(\"request\")\n ? readOwn(value, \"request\", name)\n : undefined;\n const request =\n rawRequest === undefined\n ? undefined\n : snapshotOperationMap(rawRequest, \"request\", name, schema);\n const rawQuery = ownKeys.includes(\"query\")\n ? readOwn(value, \"query\", name)\n : undefined;\n const query =\n rawQuery === undefined\n ? undefined\n : snapshotOperationMap(rawQuery, \"query\", name, schema);\n const rawStatement = ownKeys.includes(\"statement\")\n ? readOwn(value, \"statement\", name)\n : undefined;\n const statement =\n rawStatement === undefined\n ? undefined\n : requireFunction(rawStatement, \"statement\", name);\n const rawObserve = ownKeys.includes(\"observe\")\n ? readOwn(value, \"observe\", name)\n : undefined;\n const observe =\n rawObserve === undefined\n ? undefined\n : requireFunction(rawObserve, \"observe\", name);\n const rawClient = ownKeys.includes(\"client\")\n ? readOwn(value, \"client\", name)\n : undefined;\n const client =\n rawClient === undefined\n ? undefined\n : requireFunction(rawClient, \"client\", name);\n const rawModel = ownKeys.includes(\"model\")\n ? readOwn(value, \"model\", name)\n : undefined;\n const model =\n rawModel === undefined\n ? undefined\n : snapshotModelFactories(rawModel, name, schema);\n const { controls, deletion, data } = value;\n validateNamedPolicies({ rows: value.rows, deletion, data }, schema, name);\n const rows =\n schema && value.rows\n ? admitRows(value.rows, schema, name, registry)\n : value.rows;\n\n return Object.freeze({\n name,\n ...(request ? { request } : {}),\n ...(query ? { query } : {}),\n ...(statement ? { statement } : {}),\n ...(observe ? { observe } : {}),\n ...(client ? { client } : {}),\n ...(model ? { model } : {}),\n ...(controls ? { controls } : {}),\n ...(rows ? { rows } : {}),\n ...(deletion ? { deletion } : {}),\n ...(data ? { data } : {}),\n });\n}\n\ntype ExtensionConfig<S extends Schema> = {\n readonly schema: S;\n readonly driver: AnyDriver;\n};\n\n/**\n * A model factory, declared as a method so a factory typed against the client\n * it extends (`(delegate: M[K & keyof M]) => …`, generic over that client) is\n * compared in either direction rather than only contravariantly.\n */\ntype ModelMethodFactory<Delegate> = {\n factory(delegate: Delegate): ExtensionMethodRecord;\n}[\"factory\"];\n\n/**\n * One factory per schema model. A definition's model key is looked up here by\n * index, never by a conditional: a key outside the schema reads `never` (the\n * factory is refused where it is written), and a key set generic over the\n * client is substituted rather than deferred, so a plugin generic over `C`\n * type-checks and meets the schema check when it is applied.\n */\ntype ModelFactoryTable<\n C extends VibORMConfig,\n X extends ExtensionStateConstraint,\n> = {\n readonly [ModelName in keyof ClientSchema<C>]: ModelMethodFactory<\n ExtensionModelDelegate<C, X, ModelName>\n >;\n};\n\n/** The model keys a definition's own `model` map names. */\ntype DefinitionModelKeys<Self> = Self extends {\n readonly model?: infer Factories;\n}\n ? keyof Factories\n : never;\n\n/**\n * `Self` is the definition itself when `$extends` checks it (F-bounded), so\n * its model keys come from the definition; otherwise every schema model.\n */\nexport type ContextualExtensionDefinition<\n C extends VibORMConfig,\n X extends ExtensionStateConstraint,\n Self = unknown,\n> = ExtensionMembers<C, X> & {\n readonly model?: unknown extends Self\n ? {\n readonly [ModelName in keyof ClientSchema<C>]?: ModelMethodFactory<\n ExtensionModelDelegate<C, X, ModelName>\n >;\n }\n : {\n readonly [ModelName in DefinitionModelKeys<Self>]?: ModelFactoryTable<\n C,\n X\n >[ModelName & keyof ClientSchema<C>];\n };\n};\n\ntype ExtensionMembers<\n C extends VibORMConfig,\n X extends ExtensionStateConstraint,\n> = {\n readonly name: string;\n readonly request?: GenericRequestHandler | RequestHandlerMap<ClientSchema<C>>;\n readonly query?: GenericQueryHandler | QueryHandlerMap<C, X[\"rows\"]>;\n readonly statement?: StatementHandler;\n readonly observe?: ObserveHandler;\n readonly controls?: ControlsContribution;\n readonly rows?: RowsContribution;\n readonly deletion?: DeletionContribution;\n readonly data?: DataContribution;\n readonly client?: (\n scope: ExtensionClientScope<C, X>\n ) => ExtensionMethodRecord;\n};\n\ntype SchemaGenericExtensionDefinition = Omit<\n ContextualExtensionDefinition<\n ExtensionConfig<Schema>,\n EmptyClientExtensionState\n >,\n \"request\" | \"query\"\n> & {\n readonly request?: GenericRequestHandler;\n readonly query?: GenericQueryHandler;\n};\n\n/**\n * Public reusable extension definition.\n *\n * A schema with a string index has no exact model vocabulary, so its reusable\n * request/query contributions must use the polymorphic all-operation form.\n * Supplying a concrete schema retains its exact model and operation maps.\n */\nexport type ClientExtension<S extends Schema = Schema> = string extends keyof S\n ? SchemaGenericExtensionDefinition\n : ContextualExtensionDefinition<\n ExtensionConfig<S>,\n EmptyClientExtensionState\n >;\n\ntype DefinitionKeys = keyof ContextualExtensionDefinition<\n VibORMConfig,\n EmptyClientExtensionState\n>;\n\ndeclare const schemaBoundExtensionContext: unique symbol;\n\ntype SchemaBoundExtension<Definition> = Definition & {\n readonly [schemaBoundExtensionContext]: ResultConsumerContextOf<Definition>;\n};\n\ntype UnknownDefinitionKeys<Definition> = Record<\n Exclude<\n keyof Definition,\n DefinitionKeys | typeof schemaBoundExtensionContext\n >,\n never\n>;\n\ntype ConfigOmit<C extends VibORMConfig> = \"omit\" extends keyof C\n ? C[Extract<\"omit\", keyof C>]\n : undefined;\n\nexport type HasNamedClientOmit<C extends VibORMConfig> =\n string extends keyof NonNullable<ConfigOmit<C>>\n ? false\n : [Exclude<ConfigOmit<C>, undefined>] extends [never]\n ? false\n : true;\n\n/** Refuse replaying a schema-bound result consumer into an omitted client. */\nexport type SchemaBoundExtensionAdmission<\n Definition,\n C extends VibORMConfig,\n> = Definition extends {\n readonly [schemaBoundExtensionContext]: infer Context;\n}\n ? Context extends \"result-consuming\"\n ? HasNamedClientOmit<C> extends true\n ? { readonly [schemaBoundExtensionContext]: never }\n : unknown\n : unknown\n : unknown;\n\ntype OperationMapGuard<Map, S extends Schema> = Map extends CallableFunction\n ? unknown\n : Map extends object\n ? Record<Exclude<keyof Map, keyof S>, never> & {\n readonly [ModelName in keyof Map]: ModelName extends keyof S\n ? Map[ModelName] extends object\n ? Record<Exclude<keyof Map[ModelName], Operations>, never>\n : never\n : never;\n }\n : never;\n\ntype ComponentMapGuard<\n Definition,\n Key extends \"request\" | \"query\",\n S extends Schema,\n> = Definition extends { readonly [K in Key]: infer Component }\n ? { readonly [K in Key]: OperationMapGuard<Component, S> }\n : unknown;\n\n/** Policy model keys must be a subset of a concrete bound schema. */\ntype PolicyModelsGuard<\n Definition,\n S extends Schema,\n Key extends \"data\" | \"rows\" | \"deletion\",\n> = Definition extends {\n readonly [K in Key]: { readonly models: infer Models };\n}\n ? string extends keyof S\n ? unknown\n : [keyof Models] extends [keyof S]\n ? unknown\n : {\n readonly [K in Key]: { readonly models: Record<keyof Models, never> };\n }\n : unknown;\n\n/** Structural refusal for non-fresh extension definitions and contributions. */\nexport type ExactExtensionDefinition<\n Definition,\n C extends VibORMConfig,\n X extends ExtensionStateConstraint,\n> = UnknownDefinitionKeys<Definition> &\n ComponentMapGuard<Definition, \"request\", C[\"schema\"]> &\n ComponentMapGuard<Definition, \"query\", C[\"schema\"]> &\n PolicyModelsGuard<Definition, C[\"schema\"], \"data\"> &\n PolicyModelsGuard<Definition, C[\"schema\"], \"rows\"> &\n PolicyModelsGuard<Definition, C[\"schema\"], \"deletion\"> &\n ExtensionMethodDefinitionGuard<Definition, C, X>;\n\n// The definition is inferred from its declaration, never from a receiving\n// `$extends` overload's return context (which may be a client factory).\nexport type DefineExtensionBinder<S extends Schema> = <const Definition>(\n definition: Definition &\n ContextualExtensionDefinition<\n ExtensionConfig<S>,\n EmptyClientExtensionState\n > &\n ExactExtensionDefinition<\n Definition,\n ExtensionConfig<S>,\n EmptyClientExtensionState\n >\n) => SchemaBoundExtension<NoInfer<Definition>>;\n\nexport function defineExtension<\n const Definition extends SchemaGenericExtensionDefinition,\n>(\n definition: Definition &\n ExactExtensionDefinition<\n Definition,\n ExtensionConfig<Schema>,\n EmptyClientExtensionState\n >\n): NoInfer<Definition>;\nexport function defineExtension<S extends Schema>(): DefineExtensionBinder<S>;\nexport function defineExtension(\n ...definitions: [] | [definition: ClientExtension]\n): unknown {\n if (definitions.length === 0) {\n return (schemaDefinition: ExtensionDefinitionInput) =>\n normalizeExtensionDefinition(schemaDefinition);\n }\n return normalizeExtensionDefinition(definitions[0]);\n}\n","import { ClientInitializationError } from \"@errors\";\nimport {\n type CallRows,\n Condition,\n type ModelDomain,\n type ModelStamps,\n type ModelVerbs,\n Parameter,\n type RowDomain,\n} from \"@query-engine/raptor3/shared/row-scope\";\nimport type { Input } from \"@query-engine/raptor3/shared/schema\";\nimport { isPlainRecord } from \"@schema/relation/terminal\";\nimport { isInstant, isReference } from \"./admission\";\nimport type { ResolvedControls, ResolvedDeletion } from \"./chain\";\nimport {\n type AdmittedControls,\n type RowsContribution,\n rowsModes,\n} from \"./controls\";\nimport type { RuntimeExtensionDefinition } from \"./definition\";\n\ntype Predicates = RowsContribution[\"models\"][string][string];\n\n/** One `rows` member: its control, and where each of its modes sits. */\ninterface BoundRowsMember {\n readonly control: string;\n readonly names: readonly string[];\n readonly modes: ReadonlyMap<unknown, number>;\n readonly fallback: number;\n /** How far one step of this member's mode moves the combination index. */\n readonly stride: number;\n}\n\n/**\n * A chain's row facts, resolved once when an extension is applied: one\n * {@link CallRows} per combination of its `rows` members' modes, with and\n * without the tombstones, each with the chain's `data` stamps, so a call only\n * looks its facts up. The predicates hold the values they read as\n * parameters, prepared once for every call: a call whose combination reads\n * one carries its values beside the shared domains. When a stamp names a\n * control, the call's values are put in its stamps for that call alone.\n */\nexport interface RowsBinding {\n readonly members: readonly BoundRowsMember[];\n readonly deletion: Readonly<Record<string, ResolvedDeletion>>;\n /** Indexed by mode combination: the call writes tombstones. */\n readonly tombstoning: readonly CallRows[];\n /** Indexed by mode combination: the call deletes physically. */\n readonly physical: readonly CallRows[];\n /**\n * Indexed by mode combination: its domain or the default one reads a call\n * value, so its calls carry their values.\n */\n readonly parametric: readonly boolean[];\n /** A stamp names a control: each call puts its values in the stamps. */\n readonly bindsStamps: boolean;\n /** Whether a call must pass a control to touch a model directly. */\n readonly required: RequiredOn;\n}\n\ntype RequiredOn = (control: string, model: string) => boolean;\n\nconst NEVER_REQUIRED: RequiredOn = () => false;\n\nconst NO_DELETION: Readonly<Record<string, ResolvedDeletion>> = Object.freeze(\n Object.create(null)\n);\n\nconst NO_CONTROLS: AdmittedControls = Object.freeze({});\n\n/** A named control the call did not pass. */\nconst ABSENT = Symbol(\"absent\");\n\n/**\n * Every control a definition's values name, at any depth: an admitted\n * predicate's parameters and conditions, and a stamp's references.\n */\nfunction collectReferences(value: unknown, names: Set<string>): void {\n const parameter = value instanceof Condition ? value.parameter : value;\n if (parameter instanceof Parameter) {\n if (parameter.control !== undefined) names.add(parameter.control);\n } else if (isReference(value)) names.add(value.control);\n else if (Array.isArray(value) || isPlainRecord(value)) {\n for (const item of Object.values(value)) collectReferences(item, names);\n }\n}\n\n/** The controls a stamp's fields name: its own keys are fields, never values. */\nfunction collectStampReferences(\n stamp: Input | undefined,\n names: Set<string>\n): void {\n for (const value of Object.values(stamp ?? {}))\n collectReferences(value, names);\n}\n\n/**\n * The controls a definition names but does not declare; the chain admits\n * those an earlier extension declares.\n */\nexport function undeclaredControlReferencesOf(\n definition: RuntimeExtensionDefinition\n): readonly string[] {\n const declared = new Set(Object.keys(definition.controls ?? {}));\n if (definition.rows) declared.add(definition.rows.control);\n const references = new Set<string>();\n for (const modes of Object.values(definition.rows?.models ?? {}))\n for (const mode of Object.values(modes)) {\n collectReferences(mode.root, references);\n collectReferences(mode.related, references);\n }\n for (const entry of Object.values(definition.rows?.verbs ?? {}))\n collectReferences(entry.predicates, references);\n for (const entry of Object.values(definition.data?.models ?? {})) {\n collectStampReferences(entry.create, references);\n collectStampReferences(entry.update, references);\n }\n for (const name of Object.keys(definition.deletion?.removeWhen ?? {}))\n references.add(name);\n return [...references].filter((name) => !declared.has(name));\n}\n\n/** Whether a domain's predicates read a call value (admission's nodes). */\nfunction readsCall(value: unknown): boolean {\n if (value instanceof Parameter || value instanceof Condition) return true;\n if (Array.isArray(value)) return value.some(readsCall);\n return isPlainRecord(value) && Object.values(value).some(readsCall);\n}\n\n/** A stamp's value with the call's put in: itself when it names none. */\nfunction stampValue(\n value: unknown,\n controls: AdmittedControls | undefined\n): unknown {\n if (isReference(value)) {\n let given = controls?.[value.control];\n const { path } = value;\n for (const key of path === undefined ? [] : path.split(\".\")) {\n given =\n isPlainRecord(given) && Object.hasOwn(given, key)\n ? given[key]\n : undefined;\n }\n return given === undefined ? ABSENT : given;\n }\n if (Array.isArray(value)) {\n const items = value.map((item) => stampValue(item, controls));\n if (items.includes(ABSENT)) return ABSENT;\n return items.every((item, index) => item === value[index]) ? value : items;\n }\n if (!isPlainRecord(value)) return value;\n let copy: Record<string, unknown> | undefined;\n for (const [key, item] of Object.entries(value)) {\n const bound = stampValue(item, controls);\n if (bound === ABSENT) return ABSENT;\n if (bound !== item) (copy ??= { ...value })[key] = bound;\n }\n return copy ?? value;\n}\n\n/**\n * A stamp bound: a field whose value names a control the call did not pass is\n * not written. The same object when no field names a control.\n */\nfunction boundStamp(\n stamp: Input | undefined,\n controls: AdmittedControls | undefined\n): Input | undefined {\n if (stamp === undefined) return undefined;\n const values: Record<string, unknown> = {};\n let changed = false;\n for (const [field, value] of Object.entries(stamp)) {\n const bound = stampValue(value, controls);\n changed ||= bound !== value;\n if (bound !== ABSENT) values[field] = bound;\n }\n return changed ? Object.freeze(values) : stamp;\n}\n\n/** Each model's stamps bound; an entry naming no control is kept as is. */\nfunction boundStamps(\n stamps: ReadonlyMap<string, ModelStamps>,\n controls: AdmittedControls | undefined\n): ReadonlyMap<string, ModelStamps> {\n const bound = new Map<string, ModelStamps>();\n for (const [model, entry] of stamps) {\n const create = boundStamp(entry.create, controls);\n const update = boundStamp(entry.update, controls);\n bound.set(\n model,\n create === entry.create && update === entry.update\n ? entry\n : Object.freeze({ create, update })\n );\n }\n return bound;\n}\n\n/** The call's one instant, where a stamp's field writes `{ now: true }`. */\nconst NOW = new Parameter();\n\n/** A stamp with each `{ now: true }` field as {@link NOW}: itself without one. */\nfunction withInstants(stamp: Input | undefined): Input | undefined {\n let copy: Record<string, unknown> | undefined;\n for (const [field, value] of Object.entries(stamp ?? {}))\n if (isInstant(value)) (copy ??= { ...stamp })[field] = NOW;\n return copy === undefined ? stamp : Object.freeze(copy);\n}\n\n/** The chain's `required` declarations as one test, by control and model. */\nfunction requiredOn(controls: ResolvedControls | undefined): RequiredOn {\n const required = new Map<string, true | ReadonlySet<string>>();\n for (const control of controls?.all ?? []) {\n if (control.required !== undefined)\n required.set(control.name, control.required);\n }\n if (required.size === 0) return NEVER_REQUIRED;\n return (control, model) => {\n const on = required.get(control);\n return on === true || on?.has(model) === true;\n };\n}\n\n/**\n * One purpose's predicates per model, for one mode of every member, each at\n * its member's place in the chain: the layer the engine reads it as. A mode\n * that named a predicate holds its admitted object.\n */\nfunction modelDomain(\n rows: readonly RowsContribution[],\n modes: readonly string[],\n purpose: keyof Predicates\n): ModelDomain {\n const domain = new Map<string, Input[]>();\n for (const [layer, member] of rows.entries()) {\n for (const [model, entry] of Object.entries(member.models)) {\n const where = entry[modes[layer]!]?.[purpose];\n if (where === undefined) continue;\n const list = domain.get(model) ?? [];\n list[layer] = where as Input;\n domain.set(model, list);\n }\n }\n return domain;\n}\n\n/** `{ OR: [] }`, false: what a verb a model's `verbs` leaves out takes. */\nconst NOTHING: Input = Object.freeze({ OR: Object.freeze([]) });\n\n/** A `writes` or `moves` entry, its names resolved. */\nconst fieldsOf = (\n entry: { readonly [field: string]: string } | undefined,\n named: (name: string) => Input\n): ReadonlyMap<string, Input> =>\n new Map(\n Object.entries(entry ?? {}).map(([field, name]) => [field, named(name)])\n );\n\n/**\n * Every member's verbs per model, each at its member's layer, their names\n * resolved to the admitted predicates: the same for every mode combination.\n */\nfunction modelVerbs(\n rows: readonly RowsContribution[]\n): ReadonlyMap<string, readonly (ModelVerbs | undefined)[]> | undefined {\n const verbs = new Map<string, (ModelVerbs | undefined)[]>();\n const keys = new Set<string>();\n for (const [layer, member] of rows.entries()) {\n for (const [model, entry] of Object.entries(member.verbs ?? {})) {\n // One projection key, one layer: a second would hide the first.\n const key = entry.evidence && `${model}.${entry.evidence.as}`;\n if (key !== undefined && keys.has(key))\n throw new ClientInitializationError(\n `rows.verbs.${model}.evidence.as \"${entry.evidence!.as}\" is declared by two extensions of the chain.`,\n { meta: { model } }\n );\n if (key !== undefined) keys.add(key);\n const named = (name: string | undefined): Input =>\n name === undefined ? NOTHING : entry.predicates[name]!;\n const list = verbs.get(model) ?? [];\n list[layer] = Object.freeze({\n read: named(entry.read),\n update: named(entry.update),\n delete: named(entry.delete),\n writes: fieldsOf(entry.writes, named),\n ...(entry.place !== undefined && { place: named(entry.place) }),\n moves: fieldsOf(entry.moves, named),\n acyclic: Object.freeze([...(entry.acyclic ?? [])]),\n ...(entry.evidence && {\n evidence: Object.freeze({\n as: entry.evidence.as,\n names: Object.freeze(\n entry.evidence.names.map((name) =>\n Object.freeze([name, named(name)] as const)\n )\n ),\n ordered: entry.evidence.ordered === true,\n }),\n }),\n reads: fieldsOf(entry.reads, named),\n });\n verbs.set(model, list);\n }\n }\n return verbs.size === 0 ? undefined : verbs;\n}\n\nexport function bindRows(\n rows: readonly RowsContribution[] | undefined,\n deletion: Readonly<Record<string, ResolvedDeletion>> | undefined,\n data?: Readonly<Record<string, ModelStamps>>,\n controls?: ResolvedControls\n): RowsBinding {\n const declared = rows ?? [];\n let stride = 1;\n const members = declared.map((member): BoundRowsMember => {\n const modes = rowsModes(member);\n const bound = {\n control: member.control,\n names: modes,\n modes: new Map<unknown, number>(\n modes.map((mode, index) => [mode, index])\n ),\n fallback: modes.indexOf(member.default),\n stride,\n };\n stride *= modes.length;\n return bound;\n });\n const domains: RowDomain[] = [];\n const verbs = modelVerbs(declared);\n for (let combination = 0; combination < stride; combination++) {\n const modes = members.map(\n (member) =>\n member.names[\n Math.floor(combination / member.stride) % member.names.length\n ]!\n );\n domains.push(\n Object.freeze({\n root: modelDomain(declared, modes, \"root\"),\n related: modelDomain(declared, modes, \"related\"),\n ...(verbs && { verbs }),\n })\n );\n }\n const defaults =\n domains[\n members.reduce(\n (index, member) => index + member.fallback * member.stride,\n 0\n )\n ]!;\n const tombstones =\n deletion === undefined ? undefined : new Map(Object.entries(deletion));\n const stamps =\n data === undefined\n ? undefined\n : new Map(\n Object.entries(data).map(([model, entry]) => {\n const create = withInstants(entry.create);\n const update = withInstants(entry.update);\n return [\n model,\n create === entry.create && update === entry.update\n ? entry\n : Object.freeze({ create, update }),\n ] as const;\n })\n );\n const stampReferences = new Set<string>();\n for (const entry of stamps?.values() ?? []) {\n collectStampReferences(entry.create, stampReferences);\n collectStampReferences(entry.update, stampReferences);\n }\n const physical = domains.map((domain) =>\n Object.freeze({ domain, defaults, ...(stamps && { stamps }) })\n );\n const verbsRead = declared.some((member) =>\n Object.values(member.verbs ?? {}).some((entry) =>\n readsCall(entry.predicates)\n )\n );\n const reads = (domain: RowDomain) =>\n verbsRead ||\n [domain.root, domain.related].some((models) =>\n [...models.values()].some(readsCall)\n );\n return Object.freeze({\n members,\n deletion: deletion ?? NO_DELETION,\n physical,\n tombstoning:\n tombstones === undefined\n ? physical\n : physical.map((facts) => Object.freeze({ ...facts, tombstones })),\n parametric: domains.map((domain) => reads(domain) || reads(defaults)),\n bindsStamps: stampReferences.size > 0,\n required: requiredOn(controls),\n });\n}\n\n/**\n * One call's row facts, from the controls it admitted: the modes its `rows`\n * controls chose (an absent one reads as its default), and whether it deletes\n * physically — its model's `deletion` entry names a `removeWhen` the call's\n * controls match. That control is placed only on the deletes of the models\n * the entry manages, so no other call can match it. When its predicates read\n * a call value, the call carries its controls; when a stamp names a control,\n * the call's values are put in.\n */\nexport function callRows(\n binding: RowsBinding,\n model: string,\n controls: AdmittedControls | undefined\n): CallRows {\n let combination = 0;\n for (const member of binding.members) {\n combination +=\n member.stride *\n (member.modes.get(controls?.[member.control]) ?? member.fallback);\n }\n const removeWhen = binding.deletion[model]?.removeWhen;\n const physical =\n removeWhen !== undefined &&\n Object.entries(removeWhen).every(\n ([control, value]) => controls?.[control] === value\n );\n const facts = (physical ? binding.physical : binding.tombstoning)[\n combination\n ]!;\n const parametric = binding.parametric[combination]!;\n if (!(parametric || binding.bindsStamps)) return facts;\n return Object.freeze({\n ...facts,\n ...(parametric && {\n values: Object.freeze({\n controls: controls ?? NO_CONTROLS,\n required: binding.required,\n }),\n }),\n ...(binding.bindsStamps && {\n stamps: boundStamps(facts.stamps!, controls),\n }),\n });\n}\n","import {\n getOfficialCacheChainDefinition,\n getOfficialCacheQueryCapability,\n OFFICIAL_CACHE_NAME,\n officialCacheControls,\n registerOfficialCacheChain,\n} from \"@cache/capability\";\nimport {\n getOfficialDefaultOmitChainCapability,\n getOfficialDefaultOmitRequestCapability,\n OFFICIAL_DEFAULT_OMIT_NAME,\n registerOfficialDefaultOmitChain,\n} from \"@client/default-omit-extension\";\nimport type { Schema } from \"@client/types\";\nimport type { ModelStamps } from \"@query-engine/raptor3/shared/row-scope\";\nimport type { Input } from \"@query-engine/raptor3/shared/schema\";\nimport type { SchemaRegistryLookup } from \"@validation/types\";\nimport { isFunction } from \"@validation/value-guards\";\nimport {\n type DataContribution,\n type DeletionContribution,\n placeControls,\n type ResolvedControl,\n type RowsContribution,\n} from \"./controls\";\nimport {\n type ControlLiteral,\n type ExtensionDefinitionInput,\n extensionError,\n normalizeExtensionDefinition,\n type RuntimeExtensionDefinition,\n} from \"./definition\";\nimport type {\n RuntimeClientMethodContribution,\n RuntimeModelMethodContribution,\n} from \"./methods\";\nimport {\n getOfficialInstrumentationChainCapability,\n getTrustedProtectedObserverCapability,\n registerOfficialInstrumentationChain,\n} from \"./observation\";\nimport {\n bindRows,\n type RowsBinding,\n undeclaredControlReferencesOf,\n} from \"./rows\";\n\n/** The fixed name admission reserves for the official instrumentation extension. */\nexport const OFFICIAL_INSTRUMENTATION_NAME = \"viborm.instrumentation\";\n\nexport interface ResolvedExtensionHandler<\n Handler extends CallableFunction = CallableFunction,\n> {\n readonly extension: string;\n readonly handler: Handler;\n}\n\n/**\n * A request or query handler. The controls its extension declares travel\n * with it: the only ones its `context.controls` shows.\n */\nexport interface ResolvedOperationHandler<\n Handler extends CallableFunction = CallableFunction,\n> extends ResolvedExtensionHandler<Handler> {\n readonly controls?: readonly string[];\n}\n\n/** One precompiled handler array for each exact execution target. */\nexport interface ResolvedExtensionOperationLookup {\n readonly global: readonly ResolvedOperationHandler[];\n readonly models: Readonly<\n Record<\n string,\n Readonly<Record<string, readonly ResolvedOperationHandler[]>>\n >\n >;\n}\n\nexport interface ResolvedExtension {\n readonly name: string;\n readonly client?: RuntimeClientMethodContribution;\n readonly model?: RuntimeModelMethodContribution;\n}\n\n/** Who owns a request or query handler: its extension and that one's controls. */\ninterface OperationHandlerOwner {\n readonly name: string;\n readonly controls?: readonly string[];\n}\n\n/** A chain's controls, and the list one (model, operation) accepts. */\nexport interface ResolvedControls {\n /** Every control name on the chain: one name space. */\n readonly names: ReadonlySet<string>;\n /** Every control on the chain, in application order: the lists' one source. */\n readonly all: readonly ResolvedControl[];\n /**\n * The controls placed on one model's operation, in application order. Each\n * list is built the first time it is asked for and kept for the chain: a\n * client created per request asks for the one its call needs, never for\n * every operation of every model.\n */\n readonly placed: (\n model: string,\n operation: string\n ) => readonly ResolvedControl[];\n}\n\n/** What a delete of one managed model writes, and who declared it. */\nexport interface ResolvedDeletion {\n readonly extension: string;\n readonly at?: string;\n readonly assign: Readonly<Record<string, unknown>>;\n readonly removeWhen?: Readonly<Record<string, ControlLiteral>>;\n}\n\n/**\n * Absent on an unextended client; frozen whenever it exists, except the\n * `controls`, `rows`, `deletion` and `data` values a definition wrote, held\n * as written.\n */\nexport interface ResolvedExtensionChain {\n readonly controls?: ResolvedControls;\n /**\n * Every `rows` member, as declared (plain data): also a cached read's key,\n * so two chains whose `rows` differ never share an entry and two that\n * declare the same always do.\n */\n readonly rows?: readonly RowsContribution[];\n readonly deletion?: Readonly<Record<string, ResolvedDeletion>>;\n /** Per model, every extension's `data` fields: a later one wins a field. */\n readonly data?: Readonly<Record<string, ModelStamps>>;\n /**\n * Derived from `rows`, `deletion` and `data`: what each call's controls\n * resolve to.\n */\n readonly callRows?: RowsBinding;\n readonly extensions: readonly ResolvedExtension[];\n readonly hasCache: boolean;\n readonly hasRequestHandlers: boolean;\n readonly hasQueryHandlers: boolean;\n readonly hasResultConsumers: boolean;\n readonly request: ResolvedExtensionOperationLookup;\n readonly query: ResolvedExtensionOperationLookup;\n readonly statement: readonly ResolvedExtensionHandler[];\n readonly observe: readonly ResolvedExtensionHandler[];\n}\n\n/** Return the precompiled array itself; lookup scans and merges nothing. */\nexport function lookupResolvedExtensionHandlers(\n chain: ResolvedExtensionChain | undefined,\n component: \"request\" | \"query\",\n model: string | undefined,\n operation: string\n): readonly ResolvedOperationHandler[] | undefined {\n if (chain === undefined) return undefined;\n const lookup = chain[component];\n const global = lookup.global.length === 0 ? undefined : lookup.global;\n if (model === undefined) {\n return component === \"query\" ? global : undefined;\n }\n return lookup.models[model]?.[operation] ?? global;\n}\n\n/** The controls one (model, operation) accepts; the shared empty list when none. */\nexport function lookupPlacedControls(\n chain: ResolvedExtensionChain | undefined,\n model: string,\n operation: string\n): readonly ResolvedControl[] {\n return chain?.controls?.placed(model, operation) ?? NO_CONTROLS;\n}\n\nconst NO_CONTROLS: readonly ResolvedControl[] = Object.freeze([]);\n\nfunction resolvedHandler(\n extension: Pick<ResolvedExtension, \"name\">,\n handler: CallableFunction\n): ResolvedExtensionHandler {\n return Object.freeze({ extension: extension.name, handler });\n}\n\nfunction resolvedOperationHandler(\n extension: OperationHandlerOwner,\n handler: CallableFunction\n): ResolvedOperationHandler {\n return Object.freeze(\n extension.controls === undefined\n ? { extension: extension.name, handler }\n : { extension: extension.name, handler, controls: extension.controls }\n );\n}\n\nfunction appendModelHandler(\n models: Record<string, Record<string, ResolvedOperationHandler[]>>,\n model: string,\n operation: string,\n handler: ResolvedOperationHandler,\n global: readonly ResolvedOperationHandler[]\n): void {\n const operations = (models[model] ??= Object.create(null));\n const handlers = (operations[operation] ??= [...global]);\n handlers.push(handler);\n}\n\nfunction appendGlobalHandler(\n models: Record<string, Record<string, ResolvedOperationHandler[]>>,\n handler: ResolvedOperationHandler\n): void {\n for (const operations of Object.values(models)) {\n for (const handlers of Object.values(operations)) handlers.push(handler);\n }\n}\n\nfunction appendOperationHandlers(\n previous: ResolvedExtensionOperationLookup | undefined,\n extension: OperationHandlerOwner,\n contribution: RuntimeExtensionDefinition[\"request\"]\n): ResolvedExtensionOperationLookup {\n if (contribution === undefined && previous !== undefined) return previous;\n\n const models: Record<\n string,\n Record<string, ResolvedOperationHandler[]>\n > = Object.create(null);\n const global: ResolvedOperationHandler[] = previous\n ? [...previous.global]\n : [];\n\n if (previous) {\n for (const [modelName, operationMap] of Object.entries(previous.models)) {\n const operations: Record<string, ResolvedOperationHandler[]> =\n Object.create(null);\n for (const [operation, handlers] of Object.entries(operationMap)) {\n operations[operation] = [...handlers];\n }\n models[modelName] = operations;\n }\n }\n\n if (contribution) {\n if (isFunction(contribution)) {\n const handler = resolvedOperationHandler(extension, contribution);\n global.push(handler);\n appendGlobalHandler(models, handler);\n } else {\n for (const [modelName, operationMap] of Object.entries(contribution)) {\n for (const [operation, handler] of Object.entries(operationMap)) {\n appendModelHandler(\n models,\n modelName,\n operation,\n resolvedOperationHandler(extension, handler),\n global\n );\n }\n }\n }\n }\n\n const frozenModels: Record<\n string,\n Readonly<Record<string, readonly ResolvedOperationHandler[]>>\n > = Object.create(null);\n for (const [modelName, operationMap] of Object.entries(models)) {\n const frozenOperations: Record<\n string,\n readonly ResolvedOperationHandler[]\n > = Object.create(null);\n for (const [operation, handlers] of Object.entries(operationMap)) {\n frozenOperations[operation] = Object.freeze(handlers);\n }\n frozenModels[modelName] = Object.freeze(frozenOperations);\n }\n return Object.freeze({\n global: Object.freeze(global),\n models: Object.freeze(frozenModels),\n });\n}\n\nfunction hasCompiledHandlers(\n lookup: ResolvedExtensionOperationLookup\n): boolean {\n if (lookup.global.length > 0) return true;\n for (const operations of Object.values(lookup.models)) {\n if (Object.keys(operations).length > 0) return true;\n }\n return false;\n}\n\nfunction appendFlatHandler(\n previous: readonly ResolvedExtensionHandler[] | undefined,\n extension: Pick<ResolvedExtension, \"name\">,\n handler: CallableFunction | undefined\n): readonly ResolvedExtensionHandler[] {\n if (handler === undefined) return previous ?? Object.freeze([]);\n const handlers = previous ? [...previous] : [];\n handlers.push(resolvedHandler(extension, handler));\n return Object.freeze(handlers);\n}\n\nfunction appendObserver(\n previous: readonly ResolvedExtensionHandler[] | undefined,\n extension: Pick<ResolvedExtension, \"name\">,\n handler: CallableFunction | undefined\n): readonly ResolvedExtensionHandler[] {\n if (handler === undefined) return previous ?? Object.freeze([]);\n const official = getTrustedProtectedObserverCapability(handler);\n if (official !== undefined && !official.observesLifecycle) {\n return previous ?? Object.freeze([]);\n }\n return appendFlatHandler(previous, extension, handler);\n}\n\n/**\n * Add one definition's controls to the chain's name space, then index every\n * control of the chain by operation, for every model and for each model some\n * control names. One name, one control: a call's argument is read once and\n * admitted against one declaration, so a second declaration of a name\n * (another extension's, or this one's `rows` control beside its own\n * `controls`) would refuse every call that passes either value, and a\n * binding would answer for both.\n */\nfunction appendControls(\n previous: ResolvedControls | undefined,\n declarations: readonly ResolvedControl[]\n): ResolvedControls {\n const names = new Set(previous?.names);\n for (const { name, extension } of declarations) {\n if (names.has(name)) {\n const owner = [...(previous?.all ?? []), ...declarations].find(\n (control) => control.name === name\n )!.extension;\n extensionError(\n `Extension \"${extension}\" declares control \"${name}\", which extension \"${owner}\" already declares.`,\n extension\n );\n }\n names.add(name);\n }\n const all = Object.freeze([\n ...(previous?.all ?? []),\n ...declarations.map((control) => Object.freeze(control)),\n ]);\n const lists = new Map<string, readonly ResolvedControl[]>();\n const placed = (\n model: string,\n operation: string\n ): readonly ResolvedControl[] => {\n const key = `${model}\\u0000${operation}`;\n let list = lists.get(key);\n if (list === undefined) {\n const found = all.filter(\n (control) =>\n control.operations.has(operation) &&\n (control.models === undefined || control.models.has(model))\n );\n list = found.length === 0 ? NO_CONTROLS : Object.freeze(found);\n lists.set(key, list);\n }\n return list;\n };\n return Object.freeze({ names, all, placed });\n}\n\nconst NO_ASSIGN: Readonly<Record<string, unknown>> = Object.freeze({});\n\n/** One entry per managed model on the chain: a later entry replaces one. */\nfunction appendDeletion(\n previous: Readonly<Record<string, ResolvedDeletion>> | undefined,\n extension: string,\n deletion: DeletionContribution\n): Readonly<Record<string, ResolvedDeletion>> {\n const entries: Record<string, ResolvedDeletion> = Object.create(null);\n Object.assign(entries, previous);\n for (const [model, entry] of Object.entries(deletion.models)) {\n entries[model] = Object.freeze({\n extension,\n ...entry,\n assign: entry.assign ?? NO_ASSIGN,\n ...(deletion.removeWhen === undefined\n ? {}\n : { removeWhen: deletion.removeWhen }),\n });\n }\n return Object.freeze(entries);\n}\n\n/** One kind's fields with an extension's own merged in: it wins a field. */\nfunction withStamp(\n previous: Input | undefined,\n fields: Readonly<Record<string, unknown>> | undefined\n): Input | undefined {\n return fields === undefined\n ? previous\n : Object.freeze({ ...previous, ...fields });\n}\n\nfunction appendData(\n previous: Readonly<Record<string, ModelStamps>> | undefined,\n data: DataContribution\n): Readonly<Record<string, ModelStamps>> {\n const entries: Record<string, ModelStamps> = Object.create(null);\n Object.assign(entries, previous);\n for (const [model, entry] of Object.entries(data.models)) {\n const known = entries[model];\n entries[model] = Object.freeze({\n create: withStamp(known?.create, entry.create),\n update: withStamp(known?.update, entry.update),\n });\n }\n return Object.freeze(entries);\n}\n\n/** The cache's query leaves the chain's handlers; its control is its own. */\nfunction asOfficialCacheDefinition(\n definition: RuntimeExtensionDefinition\n): RuntimeExtensionDefinition {\n const { query: _officialCacheQuery, ...ordinaryDefinition } = definition;\n return Object.freeze({\n ...ordinaryDefinition,\n controls: officialCacheControls,\n });\n}\n\nfunction stripOfficialDefaultOmitRequest(\n definition: RuntimeExtensionDefinition\n): RuntimeExtensionDefinition {\n const { request: _officialDefaultOmitRequest, ...ordinaryDefinition } =\n definition;\n return Object.freeze(ordinaryDefinition);\n}\n\nfunction consumesOperationResults(\n definition: RuntimeExtensionDefinition\n): boolean {\n return (\n (definition.query !== undefined && !isFunction(definition.query)) ||\n definition.client !== undefined ||\n definition.model !== undefined\n );\n}\n\nfunction assertOfficialExtensionAdmission(options: {\n readonly definitionName: string;\n readonly officialName: string;\n readonly label: string;\n readonly hasIdentity: boolean;\n readonly isAlreadyPresent: boolean;\n readonly duplicateMessage: string;\n}): void {\n if (options.hasIdentity && options.isAlreadyPresent) {\n extensionError(options.duplicateMessage, options.definitionName);\n }\n if (options.hasIdentity && options.definitionName !== options.officialName) {\n extensionError(\n `The official ${options.label} extension name must be \"${options.officialName}\".`,\n options.definitionName\n );\n }\n if (!options.hasIdentity && options.definitionName === options.officialName) {\n extensionError(\n `Extension name \"${options.officialName}\" is reserved for the official ${options.label} extension.`,\n options.definitionName\n );\n }\n}\n\nexport function appendResolvedExtension(\n chain: ResolvedExtensionChain | undefined,\n value: ExtensionDefinitionInput,\n schema: Schema,\n registry?: SchemaRegistryLookup<Schema>\n): ResolvedExtensionChain {\n const definition = normalizeExtensionDefinition(value, schema, registry);\n const incomingCache = getOfficialCacheQueryCapability(definition.query);\n const existingOfficialCache = getOfficialCacheChainDefinition(chain);\n const incomingDefaultOmit = getOfficialDefaultOmitRequestCapability(\n definition.request\n );\n const existingDefaultOmit = getOfficialDefaultOmitChainCapability(chain);\n assertOfficialExtensionAdmission({\n definitionName: definition.name,\n officialName: OFFICIAL_CACHE_NAME,\n label: \"cache\",\n hasIdentity: incomingCache !== undefined,\n isAlreadyPresent: existingOfficialCache !== undefined,\n duplicateMessage:\n \"The official cache extension is already present on this client.\",\n });\n assertOfficialExtensionAdmission({\n definitionName: definition.name,\n officialName: OFFICIAL_DEFAULT_OMIT_NAME,\n label: \"default omit\",\n hasIdentity: incomingDefaultOmit !== undefined,\n // The generic duplicate-name check owns default-omit duplication after\n // instrumentation admission, preserving hostile hybrid error precedence.\n isAlreadyPresent: false,\n duplicateMessage: `Extension \"${OFFICIAL_DEFAULT_OMIT_NAME}\" is already present on this client.`,\n });\n if (incomingDefaultOmit !== undefined && chain?.hasResultConsumers === true) {\n extensionError(\n \"The default omit extension cannot follow an extension that defines model-mapped query, client, or model behavior.\",\n definition.name\n );\n }\n if (definition.rows !== undefined && chain?.hasResultConsumers === true) {\n extensionError(\n `Extension \"${definition.name}\" declares rows, which cannot follow an extension that defines model-mapped query, client, or model behavior.`,\n definition.name\n );\n }\n const incomingOfficial = getTrustedProtectedObserverCapability(\n definition.observe\n );\n const existingOfficial = getOfficialInstrumentationChainCapability(chain);\n assertOfficialExtensionAdmission({\n definitionName: definition.name,\n officialName: OFFICIAL_INSTRUMENTATION_NAME,\n label: \"instrumentation\",\n hasIdentity: incomingOfficial !== undefined,\n isAlreadyPresent: existingOfficial !== undefined,\n duplicateMessage:\n \"The official instrumentation extension is already present on this client.\",\n });\n if (\n chain?.extensions.some((extension) => extension.name === definition.name)\n ) {\n extensionError(\n `Extension \"${definition.name}\" is already present on this client.`,\n definition.name\n );\n }\n const effectiveDefinition =\n incomingCache === undefined\n ? incomingDefaultOmit === undefined\n ? definition\n : stripOfficialDefaultOmitRequest(definition)\n : asOfficialCacheDefinition(definition);\n const declaredControls =\n effectiveDefinition.controls === undefined &&\n effectiveDefinition.rows === undefined\n ? undefined\n : placeControls(effectiveDefinition);\n // A definition may name its own controls and those an earlier extension\n // declares: order owns a reference, so one value serves every extension.\n for (const control of undeclaredControlReferencesOf(effectiveDefinition)) {\n if (chain?.controls?.names.has(control) !== true) {\n extensionError(\n `Extension \"${definition.name}\" references undeclared control \"${control}\".`,\n definition.name\n );\n }\n }\n const resolved: ResolvedExtension = Object.freeze({\n name: definition.name,\n ...(effectiveDefinition.client === undefined\n ? {}\n : { client: effectiveDefinition.client }),\n ...(effectiveDefinition.model === undefined\n ? {}\n : { model: effectiveDefinition.model }),\n });\n const handlerOwner: OperationHandlerOwner =\n declaredControls === undefined\n ? resolved\n : {\n name: definition.name,\n controls: Object.freeze(\n declaredControls.map((control) => control.name)\n ),\n };\n const extensions = Object.freeze(\n chain ? [...chain.extensions, resolved] : [resolved]\n );\n const request = appendOperationHandlers(\n chain?.request,\n handlerOwner,\n effectiveDefinition.request\n );\n const query = appendOperationHandlers(\n chain?.query,\n handlerOwner,\n effectiveDefinition.query\n );\n const controls =\n declaredControls === undefined\n ? chain?.controls\n : appendControls(chain?.controls, declaredControls);\n const rows =\n effectiveDefinition.rows === undefined\n ? chain?.rows\n : Object.freeze([...(chain?.rows ?? []), effectiveDefinition.rows]);\n const deletion =\n effectiveDefinition.deletion === undefined\n ? chain?.deletion\n : appendDeletion(\n chain?.deletion,\n definition.name,\n effectiveDefinition.deletion\n );\n const data =\n effectiveDefinition.data === undefined\n ? chain?.data\n : appendData(chain?.data, effectiveDefinition.data);\n // The binding reads `required` from the controls, already appended: a\n // filter names only controls its own or an earlier extension declares, so\n // a later definition that declares only controls changes nothing it binds.\n const callRows =\n rows === chain?.rows && deletion === chain?.deletion && data === chain?.data\n ? chain?.callRows\n : bindRows(rows, deletion, data, controls);\n const resolvedChain = Object.freeze({\n ...(controls === undefined ? {} : { controls }),\n ...(rows === undefined ? {} : { rows }),\n ...(deletion === undefined ? {} : { deletion }),\n ...(data === undefined ? {} : { data }),\n ...(callRows === undefined ? {} : { callRows }),\n extensions,\n hasCache: incomingCache !== undefined || chain?.hasCache === true,\n hasRequestHandlers: hasCompiledHandlers(request),\n hasQueryHandlers: hasCompiledHandlers(query),\n hasResultConsumers:\n chain?.hasResultConsumers === true ||\n consumesOperationResults(effectiveDefinition),\n request,\n query,\n statement: appendFlatHandler(\n chain?.statement,\n resolved,\n effectiveDefinition.statement\n ),\n observe: appendObserver(\n chain?.observe,\n resolved,\n effectiveDefinition.observe\n ),\n });\n const official = incomingOfficial ?? existingOfficial;\n if (official !== undefined) {\n registerOfficialInstrumentationChain(resolvedChain, official);\n }\n const officialCache = incomingCache ?? existingOfficialCache;\n if (officialCache !== undefined) {\n registerOfficialCacheChain(resolvedChain, officialCache);\n }\n const officialDefaultOmit = incomingDefaultOmit ?? existingDefaultOmit;\n if (officialDefaultOmit !== undefined) {\n registerOfficialDefaultOmitChain(resolvedChain, officialDefaultOmit);\n }\n return resolvedChain;\n}\n"],"mappings":"keA6BA,SAAgB,mBACd,EAC4B,CAC5B,GAAI,CACF,IAAM,EAAY,EAAO,QAAQ,UACjC,OAAO,OAAO,OAAO,CACnB,QAAS,EAAO,QAChB,WAAY,EAAO,WACnB,GAAI,IAAc,IAAA,GAAY,EAAE,CAAG,CAAE,YAAW,CACjD,CAAC,MACI,CAGN,QC/BJ,MAAa,EAA6B,qBAqBpC,EAAwB,IAAI,QAI5B,EAAsB,IAAI,QAKhC,SAAS,mBAAmB,EAAiB,EAAwB,CACnE,MAAM,IAAI,EAA0B,EAAS,CAC3C,MAAO,IAAU,IAAA,GAAY,IAAA,GAAY,EAAW,EAAM,CAC3D,CAAC,CAGJ,SAAS,QAAQ,EAAe,EAA8B,CAC5D,GAAI,CACF,OAAO,QAAQ,QAAQ,EAAM,OACtB,EAAO,CACd,mBACE,gBAAgB,EAAM,kCACtB,EACD,EAIL,SAASA,UACP,EACA,EACA,EACS,CACT,GAAI,CACF,OAAO,EAAM,SACN,EAAO,CACd,mBACE,gBAAgB,EAAM,WAAW,EAAI,sBACrC,EACD,yBAIL,SAAS,sBACP,EACA,EACkC,CAClC,GAAI,CACF,OAAO,EAAS,EAAM,OACf,EAAO,CACd,mBAAmB,gBAAgB,EAAM,0BAA2B,EAAM,EAI9E,SAAS,eAAe,EAA0C,CAC3D,sBAAsB,EAAO,gBAAgB,EAChD,mBAAmB,gDAAgD,CAErE,IAAM,EAGF,OAAO,OAAO,KAAK,CACvB,IAAK,IAAM,KAAY,QAAQ,EAAO,gBAAgB,CAAE,CAClD,OAAO,GAAa,UACtB,mBACE,8DACD,CAEH,IAAM,EAAQA,UAAQ,EAAO,EAAU,gBAAgB,CAClD,sBAAsB,EAAO,iBAAiB,IAAW,EAC5D,mBACE,sCAAsC,EAAS,sBA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