cvx-kit 0.1.11 → 0.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/README.md +1 -0
- package/dist/contracts.d.mts +2 -1
- package/dist/contracts.mjs +1 -1
- package/dist/index.d.mts +2 -1
- package/dist/index.mjs +1 -1
- package/dist/modules/contracts/binding.d.mts +14 -0
- package/dist/modules/contracts/binding.mjs +2 -0
- package/dist/modules/contracts/binding.mjs.map +1 -0
- package/dist/modules/contracts/domain.d.mts +59 -0
- package/dist/modules/contracts/domain.mjs +2 -0
- package/dist/modules/contracts/domain.mjs.map +1 -0
- package/dist/modules/effect/command.d.mts +35 -1
- package/dist/modules/effect/command.mjs +1 -1
- package/dist/modules/effect/command.mjs.map +1 -1
- package/dist/modules/effect/crud.d.mts +6 -0
- package/dist/modules/effect/domain.d.mts +44 -0
- package/dist/modules/effect/domain.mjs +2 -0
- package/dist/modules/effect/domain.mjs.map +1 -0
- package/dist/modules/effect/operation.d.mts +4 -3
- package/dist/modules/effect/operation.mjs.map +1 -1
- package/dist/modules/effect/query.d.mts +23 -8
- package/dist/modules/effect/query.mjs +1 -1
- package/dist/modules/effect/query.mjs.map +1 -1
- package/dist/modules/foundation/foundation.d.mts +108 -0
- package/dist/modules/foundation/foundation.mjs +2 -0
- package/dist/modules/foundation/foundation.mjs.map +1 -0
- package/dist/modules/foundation/operation.d.mts +121 -0
- package/dist/modules/foundation/operation.mjs +2 -0
- package/dist/modules/foundation/operation.mjs.map +1 -0
- package/dist/oxlint/ownership.mjs +1 -1
- package/dist/oxlint/ownership.mjs.map +1 -1
- package/dist/oxlint/reserved-files.d.mts +6 -0
- package/dist/oxlint/reserved-files.mjs +2 -0
- package/dist/oxlint/reserved-files.mjs.map +1 -0
- package/dist/oxlint.d.mts +1 -1
- package/dist/oxlint.mjs +1 -1
- package/dist/oxlint.mjs.map +1 -1
- package/docs/commands-legacy.md +3 -1
- package/docs/conventions.md +7 -3
- package/docs/domain-contracts.md +115 -0
- package/docs/effect.md +2 -0
- package/docs/oxlint.md +4 -0
- package/package.json +1 -1
- package/scripts/test-packed-effect.mjs +12 -0
- package/scripts/test-packed-oxlint.mjs +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -12,6 +12,25 @@ are this file's matching section.
|
|
|
12
12
|
|
|
13
13
|
## [Unreleased]
|
|
14
14
|
|
|
15
|
+
## [0.1.12] - 2026-10-10
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
|
|
19
|
+
- Declare optional domain contracts with root errors, command classification,
|
|
20
|
+
and exact command/query implementation keys in both Effect and Promise registries (#26).
|
|
21
|
+
- Share a registry-level command audit default with per-operation overrides,
|
|
22
|
+
preserving replay bypass, schema inference, and transactional rollback.
|
|
23
|
+
- Use `createFoundation` for typed Promise registries without installing Effect.
|
|
24
|
+
- Enforce reserved domain file declarations through the packaged Oxlint plugin,
|
|
25
|
+
including constructor provenance and declarative contract ownership.
|
|
26
|
+
- Document both contract APIs with packed-compiled examples and audit guidance.
|
|
27
|
+
|
|
28
|
+
### Verified
|
|
29
|
+
|
|
30
|
+
- Cover native validation, error projection, rollback, audit selection, agent tools,
|
|
31
|
+
workflow integration, and npm/Bun consumers with and without Effect.
|
|
32
|
+
- Pass 680 runtime tests, 340 lint-rule tests, and both packed-component CI smoke tests.
|
|
33
|
+
|
|
15
34
|
## [0.1.11] - 2026-10-09
|
|
16
35
|
|
|
17
36
|
### Added
|
package/README.md
CHANGED
|
@@ -220,6 +220,7 @@ Load it in your application's `.oxlintrc.json` and select rules:
|
|
|
220
220
|
"cvx/application-orchestration": "error",
|
|
221
221
|
"cvx/internal-function-ownership": "error",
|
|
222
222
|
"cvx/domain-file-responsibilities": "error",
|
|
223
|
+
"cvx/reserved-domain-file-anatomy": "error",
|
|
223
224
|
"cvx/no-raw-builders": "error",
|
|
224
225
|
"cvx/no-handwritten-references": "error",
|
|
225
226
|
"cvx/domain-import-boundaries": "error",
|
package/dist/contracts.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ContractExecution, ContractInput, ContractOutput, ContractSchema, Decoder, LegacyParser, NeutralSchema, StandardSchema, ValidationIssue, ValidationResult, decodeContract, operationContract } from "./modules/contracts/contract.mjs";
|
|
2
2
|
import { standardContract, zodContract } from "./modules/contracts/standard.mjs";
|
|
3
3
|
import { ConvexContractValue, convexContract } from "./modules/contracts/convex.mjs";
|
|
4
|
-
|
|
4
|
+
import { DomainAuditInput, DomainCommandContract, DomainContract, DomainOperationContract, DomainQueryContract, defineDomainContract } from "./modules/contracts/domain.mjs";
|
|
5
|
+
export { type ContractExecution, type ContractInput, type ContractOutput, type ContractSchema, type ConvexContractValue, type Decoder, type DomainAuditInput, type DomainCommandContract, type DomainContract, type DomainOperationContract, type DomainQueryContract, type LegacyParser, type NeutralSchema, type StandardSchema, type ValidationIssue, type ValidationResult, convexContract, decodeContract, defineDomainContract, operationContract, standardContract, zodContract };
|
package/dist/contracts.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{decodeContract as e,operationContract as t}from"./modules/contracts/contract.mjs";import{standardContract as n,zodContract as r}from"./modules/contracts/standard.mjs";import{convexContract as i}from"./modules/contracts/convex.mjs";export{i as convexContract,e as decodeContract,t as operationContract,n as standardContract,r as zodContract};
|
|
1
|
+
import{decodeContract as e,operationContract as t}from"./modules/contracts/contract.mjs";import{standardContract as n,zodContract as r}from"./modules/contracts/standard.mjs";import{convexContract as i}from"./modules/contracts/convex.mjs";import{defineDomainContract as a}from"./modules/contracts/domain.mjs";export{i as convexContract,e as decodeContract,a as defineDomainContract,t as operationContract,n as standardContract,r as zodContract};
|
package/dist/index.d.mts
CHANGED
|
@@ -10,4 +10,5 @@ import { RateLimiterLike, rateLimit } from "./middleware.mjs";
|
|
|
10
10
|
import { WebhookBoundaryConfig, createWebhookBoundary, recordWebhookEvent, webhookEventsTable } from "./webhooks.mjs";
|
|
11
11
|
import { createStateMachine } from "./state-machine.mjs";
|
|
12
12
|
import { Change, Trigger, Triggers, appendOnly, createTriggers, noDelete, tenantOwnership, timestamps } from "./triggers.mjs";
|
|
13
|
-
|
|
13
|
+
import { FoundationRegistry, FoundationRegistryOptions, createFoundation } from "./modules/foundation/foundation.mjs";
|
|
14
|
+
export { type Actor, type AgentToolHandlers, type AgentToolRecord, type AnyCommandMiddleware, type AnyQueryMiddleware, type ApplicationCommand, type AuditEntryInput, type AuditWriter, type AuditedOperation, type AuditedRegistry, type AuthBundle, type AuthFunctions, type AuthFunctionsConfig, type Change, type CommandConstructor, type CommandDefaults, type CommandMiddleware, type CrudConfig, type DefaultRole, type ErrorFactory, Foundation, type FoundationOptions, type FoundationRegistry, type FoundationRegistryOptions, type Include, type IncludedQuery, KitError, type PermissionChecker, type QueryMiddleware, type RLSConfig, type RateLimiterLike, type Rules, type SecurityConfig, TENANT_FIELD, TIMESTAMP_FIELDS, type TableBoundaryOptions, type Trigger, Triggers, type WebhookBoundaryConfig, appendOnly, assertTenantOwned, composeRules, createAgentTools, createAuthFunctions, createCrudCommands, createFoundation, createInclude, createModule, createStateMachine, createTenantRules, createTriggers, createWebhookBoundary, defaultErrors, defaultRoleMap, jsonSafeZid, noDelete, paginated, rateLimit, recordWebhookEvent, requireTenantReference, tenantOwnership, tenantTable, timestamps, webhookEventsTable, zodTable, zodVariantTable };
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createAgentTools as e}from"./agent-tools.mjs";import{KitError as t,defaultErrors as n}from"./errors.mjs";import{TENANT_FIELD as r,assertTenantOwned as i,composeRules as a,createTenantRules as o,requireTenantReference as s}from"./tenancy.mjs";import{createAuthFunctions as c,createInclude as l,defaultRoleMap as u}from"./auth.mjs";import{createCrudCommands as d}from"./crud.mjs";import{TIMESTAMP_FIELDS as f,createModule as p,jsonSafeZid as m,paginated as h,tenantTable as g,zodTable as _,zodVariantTable as v}from"./zod-table.mjs";import{rateLimit as y}from"./middleware.mjs";import{createWebhookBoundary as b,recordWebhookEvent as x,webhookEventsTable as S}from"./webhooks.mjs";import{createStateMachine as C}from"./state-machine.mjs";import{Triggers as w,appendOnly as T,createTriggers as E,noDelete as D,tenantOwnership as O,timestamps as k}from"./triggers.mjs";import{Foundation as A}from"./components/foundation/client.mjs";export{A as Foundation,t as KitError,r as TENANT_FIELD,f as TIMESTAMP_FIELDS,w as Triggers,T as appendOnly,i as assertTenantOwned,a as composeRules,e as createAgentTools,c as createAuthFunctions,d as createCrudCommands,l as createInclude,p as createModule,C as createStateMachine,o as createTenantRules,E as createTriggers,b as createWebhookBoundary,n as defaultErrors,u as defaultRoleMap,m as jsonSafeZid,D as noDelete,h as paginated,y as rateLimit,x as recordWebhookEvent,s as requireTenantReference,O as tenantOwnership,g as tenantTable,k as timestamps,S as webhookEventsTable,_ as zodTable,v as zodVariantTable};
|
|
1
|
+
import{createAgentTools as e}from"./agent-tools.mjs";import{KitError as t,defaultErrors as n}from"./errors.mjs";import{TENANT_FIELD as r,assertTenantOwned as i,composeRules as a,createTenantRules as o,requireTenantReference as s}from"./tenancy.mjs";import{createAuthFunctions as c,createInclude as l,defaultRoleMap as u}from"./auth.mjs";import{createCrudCommands as d}from"./crud.mjs";import{TIMESTAMP_FIELDS as f,createModule as p,jsonSafeZid as m,paginated as h,tenantTable as g,zodTable as _,zodVariantTable as v}from"./zod-table.mjs";import{rateLimit as y}from"./middleware.mjs";import{createWebhookBoundary as b,recordWebhookEvent as x,webhookEventsTable as S}from"./webhooks.mjs";import{createStateMachine as C}from"./state-machine.mjs";import{Triggers as w,appendOnly as T,createTriggers as E,noDelete as D,tenantOwnership as O,timestamps as k}from"./triggers.mjs";import{Foundation as A}from"./components/foundation/client.mjs";import{createFoundation as j}from"./modules/foundation/foundation.mjs";export{A as Foundation,t as KitError,r as TENANT_FIELD,f as TIMESTAMP_FIELDS,w as Triggers,T as appendOnly,i as assertTenantOwned,a as composeRules,e as createAgentTools,c as createAuthFunctions,d as createCrudCommands,j as createFoundation,l as createInclude,p as createModule,C as createStateMachine,o as createTenantRules,E as createTriggers,b as createWebhookBoundary,n as defaultErrors,u as defaultRoleMap,m as jsonSafeZid,D as noDelete,h as paginated,y as rateLimit,x as recordWebhookEvent,s as requireTenantReference,O as tenantOwnership,g as tenantTable,k as timestamps,S as webhookEventsTable,_ as zodTable,v as zodVariantTable};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DomainContract } from "./domain.mjs";
|
|
2
|
+
//#region src/modules/contracts/binding.d.ts
|
|
3
|
+
/** Both adapters bind declarations through the same configuration boundary. */
|
|
4
|
+
export declare function domainHelpers(entries: Readonly<Record<string, object>>): {
|
|
5
|
+
[k: string]: (implementation: object) => {};
|
|
6
|
+
};
|
|
7
|
+
/** Bind only opaque schema references; never invoke user callbacks at construction. */
|
|
8
|
+
export declare function bindDomainImplementation(key: string, declaration: object, implementation: object): {};
|
|
9
|
+
/** Snapshot records and verify key ownership before the executor closes over them. */
|
|
10
|
+
export declare function snapshotOperations(operations: Readonly<Record<string, object>>, contract: DomainContract | undefined, section: 'commands' | 'queries', audit?: (resolution: never, context: never) => unknown): Readonly<{
|
|
11
|
+
[k: string]: Readonly<Record<string, unknown>>;
|
|
12
|
+
}>;
|
|
13
|
+
//#endregion
|
|
14
|
+
//# sourceMappingURL=binding.d.mts.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=[`input`,`result`,`classification`,`replayResult`,`wire`],t=/* @__PURE__ */ new WeakMap;function n(e){return Object.fromEntries(Object.keys(e).map(t=>[t,n=>r(t,e[t],n)]))}function r(n,r,i){for(let e of[`handler`,`audit`,`prepare`,`guard`,`middleware`,`context`])if(Object.prototype.hasOwnProperty.call(r,e))throw Error(`Domain contract ${n} cannot contain ${e}`);for(let t of e)if(Object.prototype.hasOwnProperty.call(i,t))throw Error(`Contracted operation ${n} cannot override ${t}`);let a={...i,...r};return t.set(a,{key:n,declaration:r}),a}function i(n,r,i,a){if(a!==void 0&&typeof a!=`function`)throw Error(`Invalid registry audit callback`);let o=r?.[i];if(r&&!o)throw Error(`Domain contract has no ${i} section`);let s=Object.keys(n);if(o&&(s.length!==Object.keys(o).length||s.some(e=>!Object.prototype.hasOwnProperty.call(o,e))))throw Error(`Contract operation keys must match exactly`);let c=s.map(r=>{let s=n[r];if(o){let n=t.get(s);if(!n||n.key!==r||n.declaration!==o[r]||e.some(e=>s[e]!==o[r][e]))throw Error(`Operation ${r} must use its own contract helper`)}let c={...s};if(c.wire&&=Object.freeze({...c.wire}),i===`commands`){let e=c.audit;if(e!==void 0&&typeof e!=`function`)throw Error(`Invalid audit for ${r}`);if(e===void 0){if(!a)throw Error(`Command ${r} requires an audit callback`);c.audit=(e,t)=>a({operation:r,input:e.command,result:e.result},t)}}return[r,Object.freeze(c)]});return Object.freeze(Object.fromEntries(c))}export{r as bindDomainImplementation,n as domainHelpers,i as snapshotOperations};
|
|
2
|
+
//# sourceMappingURL=binding.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"binding.mjs","names":["protectedFields","bindings","domainHelpers","entries","key","bindDomainImplementation","implementation","field","declaration","definition","snapshotOperations","audit","declarations","contract","section","keys","operations","original","binding","override","resolution","context"],"sources":["../../../src/modules/contracts/binding.ts"],"sourcesContent":["/* oxlint-disable anti-slop/no-object-parameters, anti-slop/no-unsafe-dictionary-type, anti-slop/no-known-value-widening, anti-slop/no-runtime-typeof, anti-slop/no-unknown-parameters, anti-slop/no-unknown-returns -- Configuration boundary validates heterogeneous own-key records and callback presence; validators remain opaque identities. */\nimport type { DomainContract } from './domain'\n\n// SAFETY: this configuration boundary compares opaque fields or restores callback slots checked by the public helpers.\nconst protectedFields = ['input', 'result', 'classification', 'replayResult', 'wire'] as const\nconst bindings = new WeakMap<object, { key: string; declaration: object }>()\n\n/** Both adapters bind declarations through the same configuration boundary. */\nexport function domainHelpers(entries: Readonly<Record<string, object>>) {\n\treturn Object.fromEntries(\n\t\tObject.keys(entries).map((key) => [\n\t\t\tkey,\n\t\t\t(implementation: object) => bindDomainImplementation(key, entries[key], implementation),\n\t\t]),\n\t)\n}\n\n/** Bind only opaque schema references; never invoke user callbacks at construction. */\nexport function bindDomainImplementation(key: string, declaration: object, implementation: object) {\n\tfor (const field of ['handler', 'audit', 'prepare', 'guard', 'middleware', 'context']) {\n\t\tif (Object.prototype.hasOwnProperty.call(declaration, field))\n\t\t\tthrow Error(`Domain contract ${key} cannot contain ${field}`)\n\t}\n\tfor (const field of protectedFields) {\n\t\tif (Object.prototype.hasOwnProperty.call(implementation, field))\n\t\t\tthrow Error(`Contracted operation ${key} cannot override ${field}`)\n\t}\n\tconst definition = { ...implementation, ...declaration }\n\tbindings.set(definition, { key, declaration })\n\treturn definition\n}\n\n/** Snapshot records and verify key ownership before the executor closes over them. */\nexport function snapshotOperations(\n\toperations: Readonly<Record<string, object>>,\n\tcontract: DomainContract | undefined,\n\tsection: 'commands' | 'queries',\n\taudit?: (resolution: never, context: never) => unknown,\n) {\n\tif (audit !== undefined && typeof audit !== 'function')\n\t\tthrow Error('Invalid registry audit callback')\n\tconst declarations = contract?.[section]\n\tif (contract && !declarations) throw Error(`Domain contract has no ${section} section`)\n\tconst keys = Object.keys(operations)\n\tif (\n\t\tdeclarations &&\n\t\t(keys.length !== Object.keys(declarations).length ||\n\t\t\tkeys.some((key) => !Object.prototype.hasOwnProperty.call(declarations, key)))\n\t)\n\t\tthrow Error('Contract operation keys must match exactly')\n\tconst entries = keys.map((key) => {\n\t\tconst original = operations[key]\n\t\tif (declarations) {\n\t\t\tconst binding = bindings.get(original)\n\t\t\tif (\n\t\t\t\t!binding ||\n\t\t\t\tbinding.key !== key ||\n\t\t\t\tbinding.declaration !== declarations[key] ||\n\t\t\t\tprotectedFields.some(\n\t\t\t\t\t(field) =>\n\t\t\t\t\t\t// SAFETY: this configuration boundary compares opaque fields or restores callback slots checked by the public helpers.\n\t\t\t\t\t\t(original as Record<string, unknown>)[field] !==\n\t\t\t\t\t\t// SAFETY: this configuration boundary compares opaque fields or restores callback slots checked by the public helpers.\n\t\t\t\t\t\t(declarations[key] as Record<string, unknown>)[field],\n\t\t\t\t)\n\t\t\t)\n\t\t\t\tthrow Error(`Operation ${key} must use its own contract helper`)\n\t\t}\n\t\t// SAFETY: this configuration boundary compares opaque fields or restores callback slots checked by the public helpers.\n\t\tconst definition = { ...original } as Record<string, unknown>\n\t\tif (definition.wire) {\n\t\t\t// SAFETY: wire is configuration, while its schema stays an opaque reference.\n\t\t\tdefinition.wire = Object.freeze({ ...(definition.wire as object) })\n\t\t}\n\t\tif (section === 'commands') {\n\t\t\tconst override = definition.audit\n\t\t\tif (override !== undefined && typeof override !== 'function')\n\t\t\t\tthrow Error(`Invalid audit for ${key}`)\n\t\t\tif (override === undefined) {\n\t\t\t\tif (!audit) throw Error(`Command ${key} requires an audit callback`)\n\t\t\t\tdefinition.audit = (resolution: { command: unknown; result: unknown }, context: unknown) =>\n\t\t\t\t\taudit(\n\t\t\t\t\t\t// SAFETY: this configuration boundary compares opaque fields or restores callback slots checked by the public helpers.\n\t\t\t\t\t\t{ operation: key, input: resolution.command, result: resolution.result } as never,\n\t\t\t\t\t\t// SAFETY: this configuration boundary compares opaque fields or restores callback slots checked by the public helpers.\n\t\t\t\t\t\tcontext as never,\n\t\t\t\t\t)\n\t\t\t}\n\t\t}\n\t\t// SAFETY: this configuration boundary compares opaque fields or restores callback slots checked by the public helpers.\n\t\treturn [key, Object.freeze(definition)] as const\n\t})\n\treturn Object.freeze(Object.fromEntries(entries))\n}\n"],"mappings":"AAIA,MAAMA,EAAkB,CAAC,QAAS,SAAU,iBAAkB,eAAgB,MAAM,EAC9EC,kBAAW,IAAI,QAGrB,SAAgBC,EAAc,EAA2C,CACxE,OAAO,OAAO,YACb,OAAO,KAAKC,CAAO,CAAC,CAAC,IAAK,GAAQ,CACjCC,EACC,GAA2BC,EAAyBD,EAAKD,EAAQC,GAAME,CAAc,CACvF,CAAC,CACF,CACD,CAGA,SAAgBD,EAAyB,EAAa,EAAqB,EAAwB,CAClG,IAAK,IAAME,IAAS,CAAC,UAAW,QAAS,UAAW,QAAS,aAAc,SAAS,EACnF,GAAI,OAAO,UAAU,eAAe,KAAKC,EAAaD,CAAK,EAC1D,MAAM,MAAM,mBAAmBH,EAAI,kBAAkBG,GAAO,EAE9D,IAAK,IAAMA,KAASP,EACnB,GAAI,OAAO,UAAU,eAAe,KAAKM,EAAgBC,CAAK,EAC7D,MAAM,MAAM,wBAAwBH,EAAI,mBAAmBG,GAAO,EAEpE,IAAME,EAAa,CAAE,GAAGH,EAAgB,GAAGE,CAAY,EAEvD,OADAP,EAAS,IAAIQ,EAAY,CAAE,MAAK,aAAY,CAAC,EACtCA,CACR,CAGA,SAAgBC,EACf,EACA,EACA,EACA,EACC,CACD,GAAIC,IAAU,IAAA,IAAa,OAAOA,GAAU,WAC3C,MAAM,MAAM,iCAAiC,EAC9C,IAAMC,EAAeC,IAAWC,GAChC,GAAID,GAAY,CAACD,EAAc,MAAM,MAAM,0BAA0BE,EAAQ,SAAS,EACtF,IAAMC,EAAO,OAAO,KAAKC,CAAU,EACnC,GACCJ,IACCG,EAAK,SAAW,OAAO,KAAKH,CAAY,CAAC,CAAC,QAC1CG,EAAK,KAAM,GAAQ,CAAC,OAAO,UAAU,eAAe,KAAKH,EAAcR,CAAG,CAAC,GAE5E,MAAM,MAAM,4CAA4C,EACzD,IAAMD,EAAUY,EAAK,IAAK,GAAQ,CACjC,IAAME,EAAWD,EAAWZ,GAC5B,GAAIQ,EAAc,CACjB,IAAMM,EAAUjB,EAAS,IAAIgB,CAAQ,EACrC,GACC,CAACC,GACDA,EAAQ,MAAQd,GAChBc,EAAQ,cAAgBN,EAAaR,IACrCJ,EAAgB,KACd,GAECiB,EAAqCV,KAErCK,EAAaR,EAAI,CAA6BG,EACjD,EAEA,MAAM,MAAM,aAAaH,EAAI,kCAAkC,CACjE,CAEA,IAAMK,EAAa,CAAE,GAAGQ,CAAS,EAKjC,GAJA,AAECR,EAAW,OAAO,OAAO,OAAO,CAAE,GAAIA,EAAW,IAAgB,CAAC,EAE/DK,IAAY,WAAY,CAC3B,IAAMK,EAAWV,EAAW,MAC5B,GAAIU,IAAa,IAAA,IAAa,OAAOA,GAAa,WACjD,MAAM,MAAM,qBAAqBf,GAAK,EACvC,GAAIe,IAAa,IAAA,GAAW,CAC3B,GAAI,CAACR,EAAO,MAAM,MAAM,WAAWP,EAAI,4BAA4B,EACnE,EAAW,OAAS,EAAmD,IACtEO,EAEC,CAAE,UAAWP,EAAK,MAAOgB,EAAW,QAAS,OAAQA,EAAW,MAAO,EAEvEC,CACD,CACF,CACD,CAEA,MAAO,CAACjB,EAAK,OAAO,OAAOK,CAAU,CAAC,CACvC,CAAC,EACD,OAAO,OAAO,OAAO,OAAO,YAAYN,CAAO,CAAC,CACjD"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { ContractInput, ContractOutput, ContractSchema } from "./contract.mjs";
|
|
2
|
+
import { ErrorContract, ErrorDefinitions } from "./errors.mjs";
|
|
3
|
+
//#region src/modules/contracts/domain.d.ts
|
|
4
|
+
/** Schema-only domain vocabulary; implementations and host policies live in registries. */
|
|
5
|
+
export type DomainOperationContract = {
|
|
6
|
+
readonly input: ContractSchema;
|
|
7
|
+
readonly result: ContractSchema;
|
|
8
|
+
readonly classification?: string;
|
|
9
|
+
readonly wire?: {
|
|
10
|
+
readonly schema: ContractSchema;
|
|
11
|
+
readonly project: Function;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export type DomainCommandContract = DomainOperationContract & {
|
|
15
|
+
readonly classification: string;
|
|
16
|
+
readonly replayResult?: ContractSchema;
|
|
17
|
+
};
|
|
18
|
+
export type DomainQueryContract = DomainOperationContract & {
|
|
19
|
+
readonly replayResult?: never;
|
|
20
|
+
};
|
|
21
|
+
export type DomainContract = {
|
|
22
|
+
readonly errors?: Pick<ErrorContract<ErrorDefinitions>, 'project'>;
|
|
23
|
+
readonly commands?: Readonly<Record<string, DomainCommandContract>>;
|
|
24
|
+
readonly queries?: Readonly<Record<string, DomainQueryContract>>;
|
|
25
|
+
};
|
|
26
|
+
type CheckedEntry<Entry extends DomainOperationContract> = {
|
|
27
|
+
readonly handler?: never;
|
|
28
|
+
readonly audit?: never;
|
|
29
|
+
readonly prepare?: never;
|
|
30
|
+
readonly guard?: never;
|
|
31
|
+
readonly middleware?: never;
|
|
32
|
+
readonly context?: never;
|
|
33
|
+
readonly wire?: Entry extends {
|
|
34
|
+
wire: {
|
|
35
|
+
schema: infer Wire;
|
|
36
|
+
};
|
|
37
|
+
} ? {
|
|
38
|
+
readonly schema: Wire;
|
|
39
|
+
readonly project: (value: ContractOutput<Entry['result']>) => ContractInput<Wire>;
|
|
40
|
+
} : never;
|
|
41
|
+
} & (Entry extends {
|
|
42
|
+
replayResult: infer Replay;
|
|
43
|
+
} ? {
|
|
44
|
+
readonly replayResult: ContractOutput<Replay> extends ContractOutput<Entry['result']> ? Replay : never;
|
|
45
|
+
} : {});
|
|
46
|
+
type CheckedSection<Section> = { readonly [Key in keyof Section]: Section[Key] extends DomainOperationContract ? CheckedEntry<Section[Key]> : never; };
|
|
47
|
+
type CheckedDomain<Definition> = { readonly [Section in Extract<keyof Definition, 'commands' | 'queries'>]: CheckedSection<Definition[Section]>; };
|
|
48
|
+
/** Preserve the declaration's literal keys and opaque validator/error-contract identities. */
|
|
49
|
+
export declare function defineDomainContract<const Definition extends DomainContract>(definition: Definition & NoInfer<CheckedDomain<Definition>>): Definition;
|
|
50
|
+
/** Exactness applies to variables as well as fresh object literals. */
|
|
51
|
+
export type ExactOperationKeys<Operations, Contracts> = Exclude<keyof Operations, keyof Contracts> extends never ? Exclude<keyof Contracts, keyof Operations> extends never ? string extends keyof Contracts ? never : unknown : never : never;
|
|
52
|
+
/** Correlated callback envelope for registry-level command audit. */
|
|
53
|
+
export type DomainAuditInput<Commands> = { [Key in Extract<keyof Commands, string>]: Commands[Key] extends DomainOperationContract ? {
|
|
54
|
+
operation: Key;
|
|
55
|
+
input: ContractOutput<Commands[Key]['input']>;
|
|
56
|
+
result: ContractOutput<Commands[Key]['result']>;
|
|
57
|
+
} : never; }[Extract<keyof Commands, string>];
|
|
58
|
+
//#endregion
|
|
59
|
+
//# sourceMappingURL=domain.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"domain.mjs","names":["defineDomainContract","definition"],"sources":["../../../src/modules/contracts/domain.ts"],"sourcesContent":["import type { ContractSchema, ContractInput, ContractOutput } from './contract'\nimport type { ErrorContract, ErrorDefinitions } from './errors'\n\n/** Schema-only domain vocabulary; implementations and host policies live in registries. */\nexport type DomainOperationContract = {\n\treadonly input: ContractSchema\n\treadonly result: ContractSchema\n\treadonly classification?: string\n\treadonly wire?: { readonly schema: ContractSchema; readonly project: Function }\n}\nexport type DomainCommandContract = DomainOperationContract & {\n\treadonly classification: string\n\treadonly replayResult?: ContractSchema\n}\nexport type DomainQueryContract = DomainOperationContract & { readonly replayResult?: never }\nexport type DomainContract = {\n\treadonly errors?: Pick<ErrorContract<ErrorDefinitions>, 'project'>\n\treadonly commands?: Readonly<Record<string, DomainCommandContract>>\n\treadonly queries?: Readonly<Record<string, DomainQueryContract>>\n}\n\ntype CheckedEntry<Entry extends DomainOperationContract> = {\n\treadonly handler?: never\n\treadonly audit?: never\n\treadonly prepare?: never\n\treadonly guard?: never\n\treadonly middleware?: never\n\treadonly context?: never\n\treadonly wire?: Entry extends { wire: { schema: infer Wire } }\n\t\t? {\n\t\t\t\treadonly schema: Wire\n\t\t\t\treadonly project: (value: ContractOutput<Entry['result']>) => ContractInput<Wire>\n\t\t\t}\n\t\t: never\n} & (Entry extends { replayResult: infer Replay }\n\t? {\n\t\t\treadonly replayResult: ContractOutput<Replay> extends ContractOutput<Entry['result']>\n\t\t\t\t? Replay\n\t\t\t\t: never\n\t\t}\n\t: {})\ntype CheckedSection<Section> = {\n\treadonly [Key in keyof Section]: Section[Key] extends DomainOperationContract\n\t\t? CheckedEntry<Section[Key]>\n\t\t: never\n}\ntype CheckedDomain<Definition> = {\n\treadonly [Section in Extract<keyof Definition, 'commands' | 'queries'>]: CheckedSection<\n\t\tDefinition[Section]\n\t>\n}\n\n/** Preserve the declaration's literal keys and opaque validator/error-contract identities. */\nexport function defineDomainContract<const Definition extends DomainContract>(\n\tdefinition: Definition & NoInfer<CheckedDomain<Definition>>,\n): Definition {\n\treturn definition\n}\n\n/** Exactness applies to variables as well as fresh object literals. */\nexport type ExactOperationKeys<Operations, Contracts> =\n\tExclude<keyof Operations, keyof Contracts> extends never\n\t\t? Exclude<keyof Contracts, keyof Operations> extends never\n\t\t\t? string extends keyof Contracts\n\t\t\t\t? never\n\t\t\t\t: unknown\n\t\t\t: never\n\t\t: never\n\n/** Correlated callback envelope for registry-level command audit. */\nexport type DomainAuditInput<Commands> = {\n\t[Key in Extract<keyof Commands, string>]: Commands[Key] extends DomainOperationContract\n\t\t? {\n\t\t\t\toperation: Key\n\t\t\t\tinput: ContractOutput<Commands[Key]['input']>\n\t\t\t\tresult: ContractOutput<Commands[Key]['result']>\n\t\t\t}\n\t\t: never\n}[Extract<keyof Commands, string>]\n"],"mappings":"AAqDA,SAAgBA,EACf,EACa,CACb,OAAOC,CACR"}
|
|
@@ -2,7 +2,9 @@ import { ContractOutput, ContractSchema } from "../contracts/contract.mjs";
|
|
|
2
2
|
import { OperationPublicResult, SelectedOperation } from "../contracts/exposure.mjs";
|
|
3
3
|
import { Observability } from "../../components/foundation/modules/observability/observability.mjs";
|
|
4
4
|
import { AuditEntryInput } from "../../components/foundation/client.mjs";
|
|
5
|
+
import { DomainAuditInput, DomainCommandContract, DomainContract } from "../contracts/domain.mjs";
|
|
5
6
|
import { CallbackError, CallbackRequirements, CheckedEffectOperation, EffectOperationArgument, EffectOperationError, EffectOperationRequirements, EffectOperationResult, EffectValue, UnwrappedDefaultError, UnwrappedDefaultRequirements, ValidatedEffectOperations, effectOperationFactory } from "./operation.mjs";
|
|
7
|
+
import { AuditValue, AuditedOperations, DomainEffectFactory, ExactDomainOperations, SharedEffectFactory } from "./domain.mjs";
|
|
6
8
|
import { Effect } from "effect";
|
|
7
9
|
//#region src/modules/effect/command.d.ts
|
|
8
10
|
type Supported<Value> = Value | PromiseLike<Value> | Effect.Effect<Value, unknown, unknown>;
|
|
@@ -57,6 +59,38 @@ export declare function createEffectCommand<Resolve extends Resolver, const Oper
|
|
|
57
59
|
exec: <Key extends Extract<keyof Operations, string>>(operation: Key, input: EffectOperationArgument<Operations[Key]>, host: HostOf<Resolve>) => Effect.Effect<EffectOperationResult<Operations[Key]>, ErrorOf<Operations[Key], Resolve, Dependencies, Guard>, RequirementsOf<Operations[Key], Resolve, Dependencies, Guard>>;
|
|
58
60
|
};
|
|
59
61
|
/** Bind trusted application policies without exposing a loose public command kernel. */
|
|
60
|
-
export declare function bindEffectCommand<const Dependencies extends EffectCommandDependencies>(dependencies: Dependencies):
|
|
62
|
+
export declare function bindEffectCommand<const Dependencies extends EffectCommandDependencies>(dependencies: Dependencies): {
|
|
63
|
+
<Resolve extends Resolver, const Contract extends DomainContract & {
|
|
64
|
+
commands: Readonly<Record<string, DomainCommandContract>>;
|
|
65
|
+
}, const Operations extends Registry<DomainOf<Resolve>>, Mode extends true, Guard = never>(configuration: {
|
|
66
|
+
contract: Contract;
|
|
67
|
+
context: Resolve;
|
|
68
|
+
audit?: never;
|
|
69
|
+
operations: (define: DomainEffectFactory<DomainOf<Resolve>, Contract['commands'], Mode, never, NoInfer<CallbackError<Guard>>, NoInfer<CallbackRequirements<Guard>>>) => Operations & NoInfer<ExactDomainOperations<Operations, Contract['commands']>> & NoInfer<ValidatedEffectOperations<Operations>>;
|
|
70
|
+
defaults?: {
|
|
71
|
+
guard?: (context: DomainOf<Resolve>) => Guard;
|
|
72
|
+
};
|
|
73
|
+
} & HostCompatible<Resolve, Dependencies>): ReturnType<typeof createEffectCommand<Resolve, Operations, Dependencies, Guard>>;
|
|
74
|
+
<Resolve extends Resolver, const Contract extends DomainContract & {
|
|
75
|
+
commands: Readonly<Record<string, DomainCommandContract>>;
|
|
76
|
+
}, const Operations extends Readonly<Record<string, Pick<Operation, "classification" | "handler" | "input" | "result"> & CheckedEffectOperation<EffectValue<ReturnType<Resolve>>>>>, Returned extends AuditValue, Guard = never>(configuration: {
|
|
77
|
+
contract: Contract;
|
|
78
|
+
context: Resolve;
|
|
79
|
+
audit: (resolution: DomainAuditInput<Contract['commands']>, context: DomainOf<Resolve>) => Returned;
|
|
80
|
+
operations: (define: DomainEffectFactory<DomainOf<Resolve>, Contract['commands'], true, [Returned] extends [never] ? never : (resolution: never, context: never) => Returned, NoInfer<CallbackError<Guard>>, NoInfer<CallbackRequirements<Guard>>>) => Operations & NoInfer<ExactDomainOperations<Operations, Contract['commands']>> & NoInfer<ValidatedEffectOperations<Operations>>;
|
|
81
|
+
defaults?: {
|
|
82
|
+
guard?: (context: DomainOf<Resolve>) => Guard;
|
|
83
|
+
};
|
|
84
|
+
} & HostCompatible<Resolve, Dependencies>): ReturnType<typeof createEffectCommand<Resolve, AuditedOperations<Operations, (resolution: never, context: never) => Returned>, Dependencies, Guard>>;
|
|
85
|
+
<Resolve extends Resolver, const Operations extends Readonly<Record<string, Pick<Operation, "classification" | "handler" | "input" | "result"> & CheckedEffectOperation<EffectValue<ReturnType<Resolve>>>>>, Returned extends AuditValue, Guard>(configuration: {
|
|
86
|
+
context: Resolve;
|
|
87
|
+
audit: (resolution: DomainAuditInput<Operations>, context: DomainOf<Resolve>) => Returned;
|
|
88
|
+
operations: (define: SharedEffectFactory<DomainOf<Resolve>, Guard>) => Operations & NoInfer<ValidatedEffectOperations<Operations>>;
|
|
89
|
+
defaults?: {
|
|
90
|
+
guard?: (context: DomainOf<Resolve>) => Guard;
|
|
91
|
+
};
|
|
92
|
+
} & HostCompatible<Resolve, Dependencies>): ReturnType<typeof createEffectCommand<Resolve, AuditedOperations<Operations, (resolution: never, context: never) => Returned>, Dependencies, Guard>>;
|
|
93
|
+
<Resolve extends Resolver, const Operations extends Registry<DomainOf<Resolve>>, Guard = never>(configuration: EffectCommandConfiguration<Resolve, Operations, Guard> & HostCompatible<Resolve, Dependencies>): ReturnType<typeof createEffectCommand<Resolve, Operations, Dependencies, Guard>>;
|
|
94
|
+
};
|
|
61
95
|
//#endregion
|
|
62
96
|
//# sourceMappingURL=command.d.mts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{selectOperation as e}from"../contracts/exposure.mjs";import{normalizeEffect as t,observationFailure as n}from"./normalize.mjs";import{effectOperationFactory as r}from"./operation.mjs";import{decodeEffectContract as i}from"./schema.mjs";import{CommandPermissionError as a,executeCommandLifecycle as o}from"../../components/foundation/modules/command/lifecycle.mjs";import{Effect as
|
|
1
|
+
import{selectOperation as e}from"../contracts/exposure.mjs";import{normalizeEffect as t,observationFailure as n}from"./normalize.mjs";import{effectOperationFactory as r}from"./operation.mjs";import{decodeEffectContract as i}from"./schema.mjs";import{CommandPermissionError as a,executeCommandLifecycle as o}from"../../components/foundation/modules/command/lifecycle.mjs";import{snapshotOperations as s}from"../contracts/binding.mjs";import{domainEffectFactory as c}from"./domain.mjs";import{Effect as l,Exit as u}from"effect";const d={succeed:l.succeed,suspend:l.suspend,flatMap:l.flatMap};function f(s){let c=s.operations(r()),f=(e,r,f)=>l.suspend(()=>{if(!Object.prototype.hasOwnProperty.call(c,e))throw Error(`The selected command operation is not configured`);let p=c[e];return l.flatMap(i(p.input,r),r=>{let c=r,h=s.observability.start({operation:e,classification:p.classification}),g=s.context;return t(()=>g(f)).pipe(l.flatMap(n=>o(d,{operation:e,classification:p.classification,context:n,command:c,permission:p.permission===void 0?void 0:()=>t(()=>{if(!s.checkPermission)throw new a(e);return s.checkPermission(f,{permission:p.permission,operation:e})}).pipe(l.asVoid),prepare:()=>t(()=>p.prepare?.(n,c)).pipe(l.map(e=>e?.kind===`execute`?{kind:`execute`,complete:e.complete?n=>t(()=>e.complete(n)).pipe(l.asVoid):void 0}:e)),decodeReplay:e=>i(p.replayResult??p.result,e),middleware:p.middleware?[e=>m(()=>p.middleware({...e,input:c}))]:[],defaultGuard:e=>t(()=>s.defaults?.guard?.(e)).pipe(l.asVoid),guard:e=>t(()=>p.guard?.(e,c)).pipe(l.asVoid),run:e=>m(()=>p.handler(c,e)),decodeResult:e=>i(p.result,e),audit:e=>t(()=>p.audit({command:c,result:e},n)),writeAudit:e=>t(()=>s.writeAudit(f,e)),aggregates:p.aggregates})),l.onExit(e=>l.sync(()=>{u.isSuccess(e)?h.completed():h.failed(n(e.cause))})))})});return{withContext(e){return{exec:(t,n)=>f(t,n,e)}},expose(t,n){if(!Object.hasOwn(c,n))throw Error(`The selected command operation is not configured`);return e(t,`mutation`,n,c[n])},exec:f}}function p(e){function t(t){let n=t.contract?c(t.contract.commands??{},!0):r(),i=s(t.operations(n),t.contract,`commands`,t.audit);return f({...t,...e,operations:()=>i})}return t}function m(e){return t(e)}export{p as bindEffectCommand,f as createEffectCommand};
|
|
2
2
|
//# sourceMappingURL=command.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.mjs","names":["effectLifecycle","Effect","createEffectCommand","operations","configuration","effectOperationFactory","exec","operation","definition","decodeEffectContract","input","command","decoded","observation","resolve","normalizeEffect","host","executeCommandLifecycle","CommandPermissionError","context","preparation","result","value","normalizeCommandResult","input_","enriched","entry","Exit","exit","observationFailure","selectOperation","owner","bindEffectCommand","dependencies","invoke"],"sources":["../../../src/modules/effect/command.ts"],"sourcesContent":["import { Effect, Exit } from 'effect'\nimport type { AuditEntryInput } from '../../components/foundation/client'\nimport type { ContractSchema } from '../contracts/contract'\nimport {\n\tselectOperation,\n\ttype SelectedOperation,\n\ttype OperationPublicResult,\n} from '../contracts/exposure'\nimport { decodeEffectContract } from './schema'\n// oxlint-disable-next-line cvx/component-boundaries -- SAFETY: Internal optional adapter shares the Effect-free Foundation lifecycle and types without entering the Convex component deployment graph.\nimport {\n\tCommandPermissionError,\n\texecuteCommandLifecycle,\n\ttype ExecutionKind,\n\ttype LifecycleAlgebra,\n\ttype LifecyclePreparation,\n} from '../../components/foundation/modules/command/lifecycle'\n// oxlint-disable-next-line cvx/component-boundaries -- SAFETY: Internal optional adapter shares the Effect-free Foundation lifecycle and types without entering the Convex component deployment graph.\nimport type { Observability } from '../../components/foundation/modules/observability/observability'\nimport { normalizeEffect, observationFailure } from './normalize'\nimport {\n\teffectOperationFactory,\n\ttype CallbackError,\n\ttype CallbackRequirements,\n\ttype EffectValue,\n\ttype EffectOperationArgument,\n\ttype EffectOperationInput,\n\ttype EffectOperationHandlerResult,\n\ttype EffectPreparation,\n\ttype EffectOperationResult,\n\ttype EffectOperationError,\n\ttype EffectOperationRequirements,\n\ttype CheckedEffectOperation,\n\ttype UnwrappedDefaultError,\n\ttype UnwrappedDefaultRequirements,\n\ttype ValidatedEffectOperations,\n} from './operation'\n\ntype Supported<Value> = Value | PromiseLike<Value> | Effect.Effect<Value, unknown, unknown>\n// Heterogeneous storage constraints preserve concrete callbacks in inferred definitions.\n// oxlint-disable-next-line anti-slop/no-unknown-returns -- Internal callback storage; selected definitions retain concrete return contracts.\ntype Callback = (...arguments_: never[]) => Supported<unknown>\n// oxlint-disable-next-line anti-slop/no-unknown-returns -- Resolver constraint captures its concrete return in Resolve; it never exposes this storage type at exec.\ntype Resolver = (host: never) => Supported<unknown>\ntype HostOf<Resolve extends Resolver> = Parameters<Resolve>[0]\ntype DomainOf<Resolve extends Resolver> = EffectValue<ReturnType<Resolve>>\ntype Operation = {\n\tinput: ContractSchema\n\tresult: ContractSchema\n\tclassification: string\n\thandler: Callback\n\taudit: Callback\n\tguard?: Callback\n\tprepare?: Callback\n\tmiddleware?: Callback\n\tpermission?: string\n\taggregates?: readonly string[]\n\treplayResult?: ContractSchema\n}\ntype Registry<Context> = Readonly<\n\tRecord<\n\t\tstring,\n\t\tPick<Operation, 'input' | 'result' | 'classification' | 'handler' | 'audit'> &\n\t\t\tCheckedEffectOperation<Context>\n\t>\n>\nexport type EffectCommandDependencies = {\n\tobservability: Observability\n\tcheckPermission?: (\n\t\thost: never,\n\t\tinput: { permission: string; operation: string },\n\t) => Supported<void>\n\t// oxlint-disable-next-line anti-slop/no-unknown-returns -- Audit writer storage; its concrete return/error/services remain in Dependencies.\n\twriteAudit: (host: never, entry: AuditEntryInput) => Supported<unknown>\n}\ntype HostParameter<Policy> = [Exclude<Policy, undefined>] extends [never]\n\t? unknown\n\t: // oxlint-disable-next-line anti-slop/no-unknown-returns -- Conditional parameter-extraction predicate, not an executable callback contract.\n\t\tExclude<Policy, undefined> extends (...arguments_: infer Arguments) => Supported<unknown>\n\t\t? Arguments extends []\n\t\t\t? unknown\n\t\t\t: Arguments[0]\n\t\t: unknown\ntype PolicyHost<Dependencies extends EffectCommandDependencies> = HostParameter<\n\tDependencies['writeAudit']\n> &\n\tHostParameter<Dependencies['checkPermission']>\ntype HostCompatible<Resolve extends Resolver, Dependencies extends EffectCommandDependencies> = [\n\tHostOf<Resolve>,\n] extends [PolicyHost<Dependencies>]\n\t? unknown\n\t: { context: never }\ntype Factory<Resolve extends Resolver, Guard> = ReturnType<\n\ttypeof effectOperationFactory<\n\t\tDomainOf<Resolve>,\n\t\tRecord<never, never>,\n\t\tNoInfer<CallbackError<Guard>>,\n\t\tNoInfer<CallbackRequirements<Guard>>\n\t>\n>\nexport type EffectCommandConfiguration<\n\tResolve extends Resolver,\n\tOperations extends Registry<DomainOf<Resolve>>,\n\tGuard,\n> = {\n\tcontext: Resolve\n\toperations: (\n\t\tdefine: Factory<Resolve, Guard>,\n\t) => Operations & NoInfer<ValidatedEffectOperations<Operations>>\n\tdefaults?: { guard?: (context: DomainOf<Resolve>) => Guard }\n}\ntype ErrorOf<Definition, Resolve, Dependencies, Guard> =\n\t| EffectOperationError<Definition>\n\t| CallbackError<Resolve | Dependencies[keyof Dependencies]>\n\t| UnwrappedDefaultError<Definition, Guard>\ntype RequirementsOf<Definition, Resolve, Dependencies, Guard> =\n\t| EffectOperationRequirements<Definition>\n\t| CallbackRequirements<Resolve | Dependencies[keyof Dependencies]>\n\t| UnwrappedDefaultRequirements<Definition, Guard>\ninterface EffectExecution extends ExecutionKind {\n\treadonly type: Effect.Effect<this['value'], unknown, unknown>\n}\nconst effectLifecycle: LifecycleAlgebra<EffectExecution> = {\n\tsucceed: Effect.succeed,\n\tsuspend: Effect.suspend,\n\tflatMap: Effect.flatMap,\n}\ntype RuntimeOperation<Context, Input, Raw, Result> = {\n\tinput: ContractSchema\n\tresult: ContractSchema\n\tclassification: string\n\tpermission?: string\n\taggregates?: readonly string[]\n\treplayResult?: ContractSchema\n\thandler: (input: Input, context: Context) => Supported<Raw>\n\tguard?: (context: Context, input: Input) => Supported<void>\n\tprepare?: (\n\t\tcontext: Context,\n\t\tinput: Input,\n\t) => Supported<EffectPreparation<Result, unknown, unknown>>\n\taudit: (\n\t\tresolution: { command: Input; result: Result },\n\t\tcontext: Context,\n\t) => Supported<Omit<AuditEntryInput, 'classification'> | null>\n\tmiddleware?: (input: {\n\t\toperation: string\n\t\tcommand: Input\n\t\tinput: Input\n\t\tcontext: Context\n\t\tnext: (options?: { context?: object }) => Effect.Effect<Raw, unknown, unknown>\n\t}) => Supported<Raw>\n}\n\n/** Internal registry constructor: the public Foundation binds host policies once. */\nexport function createEffectCommand<\n\tResolve extends Resolver,\n\tconst Operations extends Registry<DomainOf<Resolve>>,\n\tconst Dependencies extends EffectCommandDependencies,\n\tGuard = never,\n>(\n\tconfiguration: EffectCommandConfiguration<Resolve, Operations, Guard> &\n\t\tDependencies &\n\t\tHostCompatible<Resolve, Dependencies>,\n) {\n\tconst operations: Operations =\n\t\tconfiguration.operations(\n\t\t\teffectOperationFactory<\n\t\t\t\tDomainOf<Resolve>,\n\t\t\t\tRecord<never, never>,\n\t\t\t\tCallbackError<Guard>,\n\t\t\t\tCallbackRequirements<Guard>\n\t\t\t>(),\n\t\t)\n\tconst exec = <Key extends Extract<keyof Operations, string>>(\n\t\toperation: Key,\n\t\tinput: EffectOperationArgument<Operations[Key]>,\n\t\thost: HostOf<Resolve>,\n\t): Effect.Effect<\n\t\tEffectOperationResult<Operations[Key]>,\n\t\tErrorOf<Operations[Key], Resolve, Dependencies, Guard>,\n\t\tRequirementsOf<Operations[Key], Resolve, Dependencies, Guard>\n\t> => {\n\t\tconst execution = Effect.suspend(() => {\n\t\t\tif (!Object.prototype.hasOwnProperty.call(operations, operation))\n\t\t\t\tthrow Error('The selected command operation is not configured')\n\t\t\t// SAFETY: this helper checked selected callbacks against their parsed schemas and domain context.\n\t\t\tconst definition = operations[operation] as Operations[Key] &\n\t\t\t\tRuntimeOperation<\n\t\t\t\t\tDomainOf<Resolve>,\n\t\t\t\t\tEffectOperationInput<Operations[Key]>,\n\t\t\t\t\tEffectOperationHandlerResult<Operations[Key]>,\n\t\t\t\t\tEffectOperationResult<Operations[Key]>\n\t\t\t\t>\n\t\t\t// SAFETY: selected command input was parsed by its own paired schema.\n\t\t\treturn Effect.flatMap(decodeEffectContract(definition.input, input), (decoded) => {\n\t\t\t\t// SAFETY: the selected operation's decoder owns this concrete domain input.\n\t\t\t\tconst command = decoded as EffectOperationInput<Operations[Key]>\n\t\t\t\tconst observation = configuration.observability.start({\n\t\t\t\t\toperation,\n\t\t\t\t\tclassification: definition.classification,\n\t\t\t\t})\n\t\t\t\t// SAFETY: resolver identity owns its concrete invocation return and host parameter.\n\t\t\t\tconst resolve = configuration.context as (host: HostOf<Resolve>) => ReturnType<Resolve>\n\t\t\t\treturn normalizeEffect(() => resolve(host)).pipe(\n\t\t\t\t\tEffect.flatMap((context) => {\n\t\t\t\t\t\tconst lifecycle = executeCommandLifecycle<\n\t\t\t\t\t\t\tEffectExecution,\n\t\t\t\t\t\t\tDomainOf<Resolve>,\n\t\t\t\t\t\t\tEffectOperationInput<Operations[Key]>,\n\t\t\t\t\t\t\tEffectOperationHandlerResult<Operations[Key]>,\n\t\t\t\t\t\t\tEffectOperationResult<Operations[Key]>\n\t\t\t\t\t\t>(effectLifecycle, {\n\t\t\t\t\t\t\toperation,\n\t\t\t\t\t\t\tclassification: definition.classification,\n\t\t\t\t\t\t\tcontext,\n\t\t\t\t\t\t\tcommand,\n\t\t\t\t\t\t\tpermission:\n\t\t\t\t\t\t\t\tdefinition.permission === undefined\n\t\t\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t\t\t: () =>\n\t\t\t\t\t\t\t\t\t\t\tnormalizeEffect(() => {\n\t\t\t\t\t\t\t\t\t\t\t\tif (!configuration.checkPermission)\n\t\t\t\t\t\t\t\t\t\t\t\t\tthrow new CommandPermissionError(operation)\n\t\t\t\t\t\t\t\t\t\t\t\t// SAFETY: HostCompatible proves this invocation satisfies the configured policy host.\n\t\t\t\t\t\t\t\t\t\t\t\treturn configuration.checkPermission(host as never, {\n\t\t\t\t\t\t\t\t\t\t\t\t\tpermission: definition.permission!,\n\t\t\t\t\t\t\t\t\t\t\t\t\toperation,\n\t\t\t\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t\t\t\t}).pipe(Effect.asVoid),\n\t\t\t\t\t\t\tprepare: () =>\n\t\t\t\t\t\t\t\tnormalizeEffect(() => definition.prepare?.(context, command)).pipe(\n\t\t\t\t\t\t\t\t\tEffect.map((preparation) => {\n\t\t\t\t\t\t\t\t\t\tif (preparation?.kind !== 'execute') return preparation\n\t\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\t\tkind: 'execute',\n\t\t\t\t\t\t\t\t\t\t\tcomplete: preparation.complete\n\t\t\t\t\t\t\t\t\t\t\t\t? (result) =>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tnormalizeEffect(() => preparation.complete!(result)).pipe(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tEffect.asVoid,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t\t\t\t\t} satisfies LifecyclePreparation<\n\t\t\t\t\t\t\t\t\t\t\tEffectExecution,\n\t\t\t\t\t\t\t\t\t\t\tEffectOperationResult<Operations[Key]>\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t// SAFETY: the selected final replay contract owns this result; operation types retain its E/R.\n\t\t\t\t\t\t\tdecodeReplay: (value) =>\n\t\t\t\t\t\t\t\tdecodeEffectContract(\n\t\t\t\t\t\t\t\t\tdefinition.replayResult ?? definition.result,\n\t\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t\t) as Effect.Effect<EffectOperationResult<Operations[Key]>, unknown, unknown>,\n\t\t\t\t\t\t\tmiddleware: definition.middleware\n\t\t\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\t\t\t(input_) =>\n\t\t\t\t\t\t\t\t\t\t\tnormalizeCommandResult(() =>\n\t\t\t\t\t\t\t\t\t\t\t\tdefinition.middleware!({ ...input_, input: command }),\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t: [],\n\t\t\t\t\t\t\tdefaultGuard: (enriched) =>\n\t\t\t\t\t\t\t\tnormalizeEffect(() => configuration.defaults?.guard?.(enriched)).pipe(\n\t\t\t\t\t\t\t\t\tEffect.asVoid,\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tguard: (enriched) =>\n\t\t\t\t\t\t\t\tnormalizeEffect(() => definition.guard?.(enriched, command)).pipe(Effect.asVoid),\n\t\t\t\t\t\t\trun: (enriched) =>\n\t\t\t\t\t\t\t\tnormalizeCommandResult(() => definition.handler(command, enriched)),\n\t\t\t\t\t\t\t// SAFETY: the selected contract owns the decoded result; the public operation retains decoder E/R.\n\t\t\t\t\t\t\tdecodeResult: (value) =>\n\t\t\t\t\t\t\t\tdecodeEffectContract(definition.result, value) as Effect.Effect<\n\t\t\t\t\t\t\t\t\tEffectOperationResult<Operations[Key]>,\n\t\t\t\t\t\t\t\t\tunknown,\n\t\t\t\t\t\t\t\t\tunknown\n\t\t\t\t\t\t\t\t>,\n\t\t\t\t\t\t\taudit: (result) =>\n\t\t\t\t\t\t\t\tnormalizeEffect(() => definition.audit({ command, result }, context)),\n\t\t\t\t\t\t\twriteAudit: (entry) =>\n\t\t\t\t\t\t\t\tnormalizeEffect(() => {\n\t\t\t\t\t\t\t\t\t// SAFETY: HostCompatible proves this invocation satisfies the configured writer host.\n\t\t\t\t\t\t\t\t\treturn configuration.writeAudit(host as never, entry)\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\taggregates: definition.aggregates,\n\t\t\t\t\t\t})\n\t\t\t\t\t\treturn lifecycle\n\t\t\t\t\t}),\n\t\t\t\t\tEffect.onExit((exit) =>\n\t\t\t\t\t\tEffect.sync(() => {\n\t\t\t\t\t\t\tif (Exit.isSuccess(exit)) observation.completed()\n\t\t\t\t\t\t\telse observation.failed(observationFailure(exit.cause))\n\t\t\t\t\t\t}),\n\t\t\t\t\t),\n\t\t\t\t)\n\t\t\t})\n\t\t})\n\t\t// SAFETY: dispatch selects exactly this operation; callbacks preserve the concrete definition/policy E/R.\n\t\treturn execution as Effect.Effect<\n\t\t\tEffectOperationResult<Operations[Key]>,\n\t\t\tErrorOf<Operations[Key], Resolve, Dependencies, Guard>,\n\t\t\tRequirementsOf<Operations[Key], Resolve, Dependencies, Guard>\n\t\t>\n\t}\n\treturn {\n\t\t/** Bind invocation context without resolving it or running an operation. */\n\t\twithContext(context: HostOf<Resolve>) {\n\t\t\treturn {\n\t\t\t\texec: <Key extends Extract<keyof Operations, string>>(\n\t\t\t\t\toperation: Key,\n\t\t\t\t\tinput: EffectOperationArgument<Operations[Key]>,\n\t\t\t\t) => exec(operation, input, context),\n\t\t\t}\n\t\t},\n\t\texpose<const Owner extends symbol, const Key extends Extract<keyof Operations, string>>(\n\t\t\towner: Owner,\n\t\t\toperation: Key,\n\t\t): SelectedOperation<\n\t\t\tOwner,\n\t\t\tKey,\n\t\t\tOperations[Key]['input'],\n\t\t\tOperationPublicResult<Operations[Key]>\n\t\t> {\n\t\t\tif (!Object.hasOwn(operations, operation))\n\t\t\t\tthrow Error('The selected command operation is not configured')\n\t\t\treturn selectOperation(owner, 'mutation', operation, operations[operation])\n\t\t},\n\t\texec,\n\t}\n}\n\n/** Bind trusted application policies without exposing a loose public command kernel. */\nexport function bindEffectCommand<const Dependencies extends EffectCommandDependencies>(\n\tdependencies: Dependencies,\n) {\n\treturn function command<\n\t\tResolve extends Resolver,\n\t\tconst Operations extends Registry<DomainOf<Resolve>>,\n\t\tGuard = never,\n\t>(\n\t\tconfiguration: EffectCommandConfiguration<Resolve, Operations, Guard> &\n\t\t\tHostCompatible<Resolve, Dependencies>,\n\t): ReturnType<typeof createEffectCommand<Resolve, Operations, Dependencies, Guard>> {\n\t\treturn createEffectCommand<Resolve, Operations, Dependencies, Guard>({\n\t\t\t...configuration,\n\t\t\t...dependencies,\n\t\t})\n\t}\n}\n\nfunction normalizeCommandResult<Value>(\n\tinvoke: () => Supported<Value>,\n): Effect.Effect<Value, unknown, unknown> {\n\t// SAFETY: selected definition helper checks the callback's normalized success against the schema input.\n\treturn normalizeEffect(invoke) as Effect.Effect<Value, unknown, unknown>\n}\n"],"mappings":"6ZA0HA,MAAMA,EAAqD,CAC1D,QAASC,EAAO,QAChB,QAASA,EAAO,QAChB,QAASA,EAAO,OACjB,EA4BA,SAAgBC,EAMf,EAGC,CACD,IAAMC,EACLC,EAAc,WACbC,EAKE,CACH,EACKC,GACL,EACA,EACA,IAMkBL,EAAO,YAAc,CACtC,GAAI,CAAC,OAAO,UAAU,eAAe,KAAKE,EAAYI,CAAS,EAC9D,MAAM,MAAM,kDAAkD,EAE/D,IAAMC,EAAaL,EAAWI,GAQ9B,OAAON,EAAO,QAAQQ,EAAqBD,EAAW,MAAOE,CAAK,EAAI,GAAY,CAEjF,IAAMC,EAAUC,EACVC,EAAcT,EAAc,cAAc,MAAM,CACrD,YACA,eAAgBI,EAAW,cAC5B,CAAC,EAEKM,EAAUV,EAAc,QAC9B,OAAOW,MAAsBD,EAAQE,CAAI,CAAC,CAAC,CAAC,KAC3Cf,EAAO,QAAS,GACGgB,EAMhBjB,EAAiB,CAClB,YACA,eAAgBQ,EAAW,eAC3B,UACA,UACA,WACCA,EAAW,aAAe,IAAA,GACvB,IAAA,OAEAO,MAAsB,CACrB,GAAI,CAACX,EAAc,gBAClB,MAAM,IAAIc,EAAuBX,CAAS,EAE3C,OAAOH,EAAc,gBAAgBY,EAAe,CACnD,WAAYR,EAAW,WACvB,WACD,CAAC,CACF,CAAC,CAAC,CAAC,KAAKP,EAAO,MAAM,EACzB,YACCc,MAAsBP,EAAW,UAAUW,EAASR,CAAO,CAAC,CAAC,CAAC,KAC7DV,EAAO,IAAK,GACPmB,GAAa,OAAS,UACnB,CACN,KAAM,UACN,SAAUA,EAAY,SAClB,GACDL,MAAsBK,EAAY,SAAUC,CAAM,CAAC,CAAC,CAAC,KACpDpB,EAAO,MACR,EACA,IAAA,EACJ,EAT4CmB,CAa5C,CACF,EAED,aAAe,GACdX,EACCD,EAAW,cAAgBA,EAAW,OACtCc,CACD,EACD,WAAYd,EAAW,WACpB,CACC,GACAe,MACCf,EAAW,WAAY,CAAE,GAAGgB,EAAQ,MAAOb,CAAQ,CAAC,CACrD,CACF,EACC,CAAC,EACJ,aAAe,GACdI,MAAsBX,EAAc,UAAU,QAAQqB,CAAQ,CAAC,CAAC,CAAC,KAChExB,EAAO,MACR,EACD,MAAQ,GACPc,MAAsBP,EAAW,QAAQiB,EAAUd,CAAO,CAAC,CAAC,CAAC,KAAKV,EAAO,MAAM,EAChF,IAAM,GACLsB,MAA6Bf,EAAW,QAAQG,EAASc,CAAQ,CAAC,EAEnE,aAAe,GACdhB,EAAqBD,EAAW,OAAQc,CAAK,EAK9C,MAAQ,GACPP,MAAsBP,EAAW,MAAM,CAAE,UAAS,QAAO,EAAGW,CAAO,CAAC,EACrE,WAAa,GACZJ,MAEQX,EAAc,WAAWY,EAAeU,CAAK,CACpD,EACF,WAAYlB,EAAW,UACxB,CACe,CACf,EACDP,EAAO,OAAQ,GACdA,EAAO,SAAW,CACb0B,EAAK,UAAUC,CAAI,EAAGf,EAAY,UAAU,EAC3CA,EAAY,OAAOgB,EAAmBD,EAAK,KAAK,CAAC,CACvD,CAAC,CACF,CACD,CACD,CAAC,CACF,CAEe,EAMhB,MAAO,CAEN,YAAY,EAA0B,CACrC,MAAO,CACN,MACC,EACA,IACItB,EAAKC,EAAWG,EAAOS,CAAO,CACpC,CACD,EACA,OACC,EACA,EAMC,CACD,GAAI,CAAC,OAAO,OAAOhB,EAAYI,CAAS,EACvC,MAAM,MAAM,kDAAkD,EAC/D,OAAOuB,EAAgBC,EAAO,WAAYxB,EAAWJ,EAAWI,EAAU,CAC3E,EACA,MACD,CACD,CAGA,SAAgByB,EACf,EACC,CACD,OAAO,SAKN,EAEmF,CACnF,OAAO9B,EAA8D,CACpE,GAAGE,EACH,GAAG6B,CACJ,CAAC,CACF,CACD,CAEA,SAASV,EACR,EACyC,CAEzC,OAAOR,EAAgBmB,CAAM,CAC9B"}
|
|
1
|
+
{"version":3,"file":"command.mjs","names":["effectLifecycle","Effect","createEffectCommand","operations","configuration","effectOperationFactory","exec","operation","definition","decodeEffectContract","input","command","decoded","observation","resolve","normalizeEffect","host","executeCommandLifecycle","CommandPermissionError","context","preparation","result","value","normalizeCommandResult","input_","enriched","entry","Exit","exit","observationFailure","selectOperation","owner","bindEffectCommand","definitions","domainEffectFactory","snapshotOperations","dependencies","invoke"],"sources":["../../../src/modules/effect/command.ts"],"sourcesContent":["/* oxlint-disable anti-slop/no-unknown-returns, anti-slop/no-unsafe-dictionary-type -- Overload implementation storage is erased; public signatures retain concrete values, errors and services. */\nimport { Effect, Exit } from 'effect'\nimport type { AuditEntryInput } from '../../components/foundation/client'\nimport type { ContractSchema } from '../contracts/contract'\nimport {\n\tselectOperation,\n\ttype SelectedOperation,\n\ttype OperationPublicResult,\n} from '../contracts/exposure'\nimport { decodeEffectContract } from './schema'\n// oxlint-disable-next-line cvx/component-boundaries -- SAFETY: Internal optional adapter shares the Effect-free Foundation lifecycle and types without entering the Convex component deployment graph.\nimport {\n\tCommandPermissionError,\n\texecuteCommandLifecycle,\n\ttype ExecutionKind,\n\ttype LifecycleAlgebra,\n\ttype LifecyclePreparation,\n} from '../../components/foundation/modules/command/lifecycle'\n// oxlint-disable-next-line cvx/component-boundaries -- SAFETY: Internal optional adapter shares the Effect-free Foundation lifecycle and types without entering the Convex component deployment graph.\nimport type { Observability } from '../../components/foundation/modules/observability/observability'\nimport { normalizeEffect, observationFailure } from './normalize'\nimport {\n\teffectOperationFactory,\n\ttype CallbackError,\n\ttype CallbackRequirements,\n\ttype EffectValue,\n\ttype EffectOperationArgument,\n\ttype EffectOperationInput,\n\ttype EffectOperationHandlerResult,\n\ttype EffectPreparation,\n\ttype EffectOperationResult,\n\ttype EffectOperationError,\n\ttype EffectOperationRequirements,\n\ttype CheckedEffectOperation,\n\ttype UnwrappedDefaultError,\n\ttype UnwrappedDefaultRequirements,\n\ttype ValidatedEffectOperations,\n} from './operation'\n\nimport type { DomainContract, DomainCommandContract, DomainAuditInput } from '../contracts/domain'\nimport { snapshotOperations } from '../contracts/binding'\nimport {\n\tdomainEffectFactory,\n\ttype DomainEffectFactory,\n\ttype ExactDomainOperations,\n\ttype AuditedOperations,\n\ttype SharedEffectFactory,\n\ttype AuditValue,\n} from './domain'\n\ntype Supported<Value> = Value | PromiseLike<Value> | Effect.Effect<Value, unknown, unknown>\n// Heterogeneous storage constraints preserve concrete callbacks in inferred definitions.\n// oxlint-disable-next-line anti-slop/no-unknown-returns -- Internal callback storage; selected definitions retain concrete return contracts.\ntype Callback = (...arguments_: never[]) => Supported<unknown>\n// oxlint-disable-next-line anti-slop/no-unknown-returns -- Resolver constraint captures its concrete return in Resolve; it never exposes this storage type at exec.\ntype Resolver = (host: never) => Supported<unknown>\ntype HostOf<Resolve extends Resolver> = Parameters<Resolve>[0]\ntype DomainOf<Resolve extends Resolver> = EffectValue<ReturnType<Resolve>>\ntype Operation = {\n\tinput: ContractSchema\n\tresult: ContractSchema\n\tclassification: string\n\thandler: Callback\n\taudit: Callback\n\tguard?: Callback\n\tprepare?: Callback\n\tmiddleware?: Callback\n\tpermission?: string\n\taggregates?: readonly string[]\n\treplayResult?: ContractSchema\n}\ntype Registry<Context> = Readonly<\n\tRecord<\n\t\tstring,\n\t\tPick<Operation, 'input' | 'result' | 'classification' | 'handler' | 'audit'> &\n\t\t\tCheckedEffectOperation<Context>\n\t>\n>\nexport type EffectCommandDependencies = {\n\tobservability: Observability\n\tcheckPermission?: (\n\t\thost: never,\n\t\tinput: { permission: string; operation: string },\n\t) => Supported<void>\n\t// oxlint-disable-next-line anti-slop/no-unknown-returns -- Audit writer storage; its concrete return/error/services remain in Dependencies.\n\twriteAudit: (host: never, entry: AuditEntryInput) => Supported<unknown>\n}\ntype HostParameter<Policy> = [Exclude<Policy, undefined>] extends [never]\n\t? unknown\n\t: // oxlint-disable-next-line anti-slop/no-unknown-returns -- Conditional parameter-extraction predicate, not an executable callback contract.\n\t\tExclude<Policy, undefined> extends (...arguments_: infer Arguments) => Supported<unknown>\n\t\t? Arguments extends []\n\t\t\t? unknown\n\t\t\t: Arguments[0]\n\t\t: unknown\ntype PolicyHost<Dependencies extends EffectCommandDependencies> = HostParameter<\n\tDependencies['writeAudit']\n> &\n\tHostParameter<Dependencies['checkPermission']>\ntype HostCompatible<Resolve extends Resolver, Dependencies extends EffectCommandDependencies> = [\n\tHostOf<Resolve>,\n] extends [PolicyHost<Dependencies>]\n\t? unknown\n\t: { context: never }\ntype Factory<Resolve extends Resolver, Guard> = ReturnType<\n\ttypeof effectOperationFactory<\n\t\tDomainOf<Resolve>,\n\t\tRecord<never, never>,\n\t\tNoInfer<CallbackError<Guard>>,\n\t\tNoInfer<CallbackRequirements<Guard>>\n\t>\n>\nexport type EffectCommandConfiguration<\n\tResolve extends Resolver,\n\tOperations extends Registry<DomainOf<Resolve>>,\n\tGuard,\n> = {\n\tcontext: Resolve\n\toperations: (\n\t\tdefine: Factory<Resolve, Guard>,\n\t) => Operations & NoInfer<ValidatedEffectOperations<Operations>>\n\tdefaults?: { guard?: (context: DomainOf<Resolve>) => Guard }\n}\ntype ErrorOf<Definition, Resolve, Dependencies, Guard> =\n\t| EffectOperationError<Definition>\n\t| CallbackError<Resolve | Dependencies[keyof Dependencies]>\n\t| UnwrappedDefaultError<Definition, Guard>\ntype RequirementsOf<Definition, Resolve, Dependencies, Guard> =\n\t| EffectOperationRequirements<Definition>\n\t| CallbackRequirements<Resolve | Dependencies[keyof Dependencies]>\n\t| UnwrappedDefaultRequirements<Definition, Guard>\ninterface EffectExecution extends ExecutionKind {\n\treadonly type: Effect.Effect<this['value'], unknown, unknown>\n}\nconst effectLifecycle: LifecycleAlgebra<EffectExecution> = {\n\tsucceed: Effect.succeed,\n\tsuspend: Effect.suspend,\n\tflatMap: Effect.flatMap,\n}\ntype RuntimeOperation<Context, Input, Raw, Result> = {\n\tinput: ContractSchema\n\tresult: ContractSchema\n\tclassification: string\n\tpermission?: string\n\taggregates?: readonly string[]\n\treplayResult?: ContractSchema\n\thandler: (input: Input, context: Context) => Supported<Raw>\n\tguard?: (context: Context, input: Input) => Supported<void>\n\tprepare?: (\n\t\tcontext: Context,\n\t\tinput: Input,\n\t) => Supported<EffectPreparation<Result, unknown, unknown>>\n\taudit: (\n\t\tresolution: { command: Input; result: Result },\n\t\tcontext: Context,\n\t) => Supported<Omit<AuditEntryInput, 'classification'> | null>\n\tmiddleware?: (input: {\n\t\toperation: string\n\t\tcommand: Input\n\t\tinput: Input\n\t\tcontext: Context\n\t\tnext: (options?: { context?: object }) => Effect.Effect<Raw, unknown, unknown>\n\t}) => Supported<Raw>\n}\n\n/** Internal registry constructor: the public Foundation binds host policies once. */\nexport function createEffectCommand<\n\tResolve extends Resolver,\n\tconst Operations extends Registry<DomainOf<Resolve>>,\n\tconst Dependencies extends EffectCommandDependencies,\n\tGuard = never,\n>(\n\tconfiguration: EffectCommandConfiguration<Resolve, Operations, Guard> &\n\t\tDependencies &\n\t\tHostCompatible<Resolve, Dependencies>,\n) {\n\tconst operations: Operations =\n\t\tconfiguration.operations(\n\t\t\teffectOperationFactory<\n\t\t\t\tDomainOf<Resolve>,\n\t\t\t\tRecord<never, never>,\n\t\t\t\tCallbackError<Guard>,\n\t\t\t\tCallbackRequirements<Guard>\n\t\t\t>(),\n\t\t)\n\tconst exec = <Key extends Extract<keyof Operations, string>>(\n\t\toperation: Key,\n\t\tinput: EffectOperationArgument<Operations[Key]>,\n\t\thost: HostOf<Resolve>,\n\t): Effect.Effect<\n\t\tEffectOperationResult<Operations[Key]>,\n\t\tErrorOf<Operations[Key], Resolve, Dependencies, Guard>,\n\t\tRequirementsOf<Operations[Key], Resolve, Dependencies, Guard>\n\t> => {\n\t\tconst execution = Effect.suspend(() => {\n\t\t\tif (!Object.prototype.hasOwnProperty.call(operations, operation))\n\t\t\t\tthrow Error('The selected command operation is not configured')\n\t\t\t// SAFETY: this helper checked selected callbacks against their parsed schemas and domain context.\n\t\t\tconst definition = operations[operation] as Operations[Key] &\n\t\t\t\tRuntimeOperation<\n\t\t\t\t\tDomainOf<Resolve>,\n\t\t\t\t\tEffectOperationInput<Operations[Key]>,\n\t\t\t\t\tEffectOperationHandlerResult<Operations[Key]>,\n\t\t\t\t\tEffectOperationResult<Operations[Key]>\n\t\t\t\t>\n\t\t\t// SAFETY: selected command input was parsed by its own paired schema.\n\t\t\treturn Effect.flatMap(decodeEffectContract(definition.input, input), (decoded) => {\n\t\t\t\t// SAFETY: the selected operation's decoder owns this concrete domain input.\n\t\t\t\tconst command = decoded as EffectOperationInput<Operations[Key]>\n\t\t\t\tconst observation = configuration.observability.start({\n\t\t\t\t\toperation,\n\t\t\t\t\tclassification: definition.classification,\n\t\t\t\t})\n\t\t\t\t// SAFETY: resolver identity owns its concrete invocation return and host parameter.\n\t\t\t\tconst resolve = configuration.context as (host: HostOf<Resolve>) => ReturnType<Resolve>\n\t\t\t\treturn normalizeEffect(() => resolve(host)).pipe(\n\t\t\t\t\tEffect.flatMap((context) => {\n\t\t\t\t\t\tconst lifecycle = executeCommandLifecycle<\n\t\t\t\t\t\t\tEffectExecution,\n\t\t\t\t\t\t\tDomainOf<Resolve>,\n\t\t\t\t\t\t\tEffectOperationInput<Operations[Key]>,\n\t\t\t\t\t\t\tEffectOperationHandlerResult<Operations[Key]>,\n\t\t\t\t\t\t\tEffectOperationResult<Operations[Key]>\n\t\t\t\t\t\t>(effectLifecycle, {\n\t\t\t\t\t\t\toperation,\n\t\t\t\t\t\t\tclassification: definition.classification,\n\t\t\t\t\t\t\tcontext,\n\t\t\t\t\t\t\tcommand,\n\t\t\t\t\t\t\tpermission:\n\t\t\t\t\t\t\t\tdefinition.permission === undefined\n\t\t\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t\t\t: () =>\n\t\t\t\t\t\t\t\t\t\t\tnormalizeEffect(() => {\n\t\t\t\t\t\t\t\t\t\t\t\tif (!configuration.checkPermission)\n\t\t\t\t\t\t\t\t\t\t\t\t\tthrow new CommandPermissionError(operation)\n\t\t\t\t\t\t\t\t\t\t\t\t// SAFETY: HostCompatible proves this invocation satisfies the configured policy host.\n\t\t\t\t\t\t\t\t\t\t\t\treturn configuration.checkPermission(host as never, {\n\t\t\t\t\t\t\t\t\t\t\t\t\tpermission: definition.permission!,\n\t\t\t\t\t\t\t\t\t\t\t\t\toperation,\n\t\t\t\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t\t\t\t}).pipe(Effect.asVoid),\n\t\t\t\t\t\t\tprepare: () =>\n\t\t\t\t\t\t\t\tnormalizeEffect(() => definition.prepare?.(context, command)).pipe(\n\t\t\t\t\t\t\t\t\tEffect.map((preparation) => {\n\t\t\t\t\t\t\t\t\t\tif (preparation?.kind !== 'execute') return preparation\n\t\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\t\tkind: 'execute',\n\t\t\t\t\t\t\t\t\t\t\tcomplete: preparation.complete\n\t\t\t\t\t\t\t\t\t\t\t\t? (result) =>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tnormalizeEffect(() => preparation.complete!(result)).pipe(Effect.asVoid)\n\t\t\t\t\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t\t\t\t\t} satisfies LifecyclePreparation<\n\t\t\t\t\t\t\t\t\t\t\tEffectExecution,\n\t\t\t\t\t\t\t\t\t\t\tEffectOperationResult<Operations[Key]>\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t// SAFETY: the selected final replay contract owns this result; operation types retain its E/R.\n\t\t\t\t\t\t\tdecodeReplay: (value) =>\n\t\t\t\t\t\t\t\tdecodeEffectContract(\n\t\t\t\t\t\t\t\t\tdefinition.replayResult ?? definition.result,\n\t\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t\t) as Effect.Effect<EffectOperationResult<Operations[Key]>, unknown, unknown>,\n\t\t\t\t\t\t\tmiddleware: definition.middleware\n\t\t\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\t\t\t(input_) =>\n\t\t\t\t\t\t\t\t\t\t\tnormalizeCommandResult(() =>\n\t\t\t\t\t\t\t\t\t\t\t\tdefinition.middleware!({ ...input_, input: command }),\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t: [],\n\t\t\t\t\t\t\tdefaultGuard: (enriched) =>\n\t\t\t\t\t\t\t\tnormalizeEffect(() => configuration.defaults?.guard?.(enriched)).pipe(\n\t\t\t\t\t\t\t\t\tEffect.asVoid,\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tguard: (enriched) =>\n\t\t\t\t\t\t\t\tnormalizeEffect(() => definition.guard?.(enriched, command)).pipe(Effect.asVoid),\n\t\t\t\t\t\t\trun: (enriched) =>\n\t\t\t\t\t\t\t\tnormalizeCommandResult(() => definition.handler(command, enriched)),\n\t\t\t\t\t\t\t// SAFETY: the selected contract owns the decoded result; the public operation retains decoder E/R.\n\t\t\t\t\t\t\tdecodeResult: (value) =>\n\t\t\t\t\t\t\t\tdecodeEffectContract(definition.result, value) as Effect.Effect<\n\t\t\t\t\t\t\t\t\tEffectOperationResult<Operations[Key]>,\n\t\t\t\t\t\t\t\t\tunknown,\n\t\t\t\t\t\t\t\t\tunknown\n\t\t\t\t\t\t\t\t>,\n\t\t\t\t\t\t\taudit: (result) =>\n\t\t\t\t\t\t\t\tnormalizeEffect(() => definition.audit({ command, result }, context)),\n\t\t\t\t\t\t\twriteAudit: (entry) =>\n\t\t\t\t\t\t\t\tnormalizeEffect(() => {\n\t\t\t\t\t\t\t\t\t// SAFETY: HostCompatible proves this invocation satisfies the configured writer host.\n\t\t\t\t\t\t\t\t\treturn configuration.writeAudit(host as never, entry)\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\taggregates: definition.aggregates,\n\t\t\t\t\t\t})\n\t\t\t\t\t\treturn lifecycle\n\t\t\t\t\t}),\n\t\t\t\t\tEffect.onExit((exit) =>\n\t\t\t\t\t\tEffect.sync(() => {\n\t\t\t\t\t\t\tif (Exit.isSuccess(exit)) observation.completed()\n\t\t\t\t\t\t\telse observation.failed(observationFailure(exit.cause))\n\t\t\t\t\t\t}),\n\t\t\t\t\t),\n\t\t\t\t)\n\t\t\t})\n\t\t})\n\t\t// SAFETY: dispatch selects exactly this operation; callbacks preserve the concrete definition/policy E/R.\n\t\treturn execution as Effect.Effect<\n\t\t\tEffectOperationResult<Operations[Key]>,\n\t\t\tErrorOf<Operations[Key], Resolve, Dependencies, Guard>,\n\t\t\tRequirementsOf<Operations[Key], Resolve, Dependencies, Guard>\n\t\t>\n\t}\n\treturn {\n\t\t/** Bind invocation context without resolving it or running an operation. */\n\t\twithContext(context: HostOf<Resolve>) {\n\t\t\treturn {\n\t\t\t\texec: <Key extends Extract<keyof Operations, string>>(\n\t\t\t\t\toperation: Key,\n\t\t\t\t\tinput: EffectOperationArgument<Operations[Key]>,\n\t\t\t\t) => exec(operation, input, context),\n\t\t\t}\n\t\t},\n\t\texpose<const Owner extends symbol, const Key extends Extract<keyof Operations, string>>(\n\t\t\towner: Owner,\n\t\t\toperation: Key,\n\t\t): SelectedOperation<\n\t\t\tOwner,\n\t\t\tKey,\n\t\t\tOperations[Key]['input'],\n\t\t\tOperationPublicResult<Operations[Key]>\n\t\t> {\n\t\t\tif (!Object.hasOwn(operations, operation))\n\t\t\t\tthrow Error('The selected command operation is not configured')\n\t\t\treturn selectOperation(owner, 'mutation', operation, operations[operation])\n\t\t},\n\t\texec,\n\t}\n}\n\n/** Bind trusted application policies without exposing a loose public command kernel. */\nexport function bindEffectCommand<const Dependencies extends EffectCommandDependencies>(\n\tdependencies: Dependencies,\n) {\n\ttype LooseRegistry<Context> = Readonly<\n\t\tRecord<\n\t\t\tstring,\n\t\t\tPick<Operation, 'input' | 'result' | 'classification' | 'handler'> &\n\t\t\t\tCheckedEffectOperation<Context>\n\t\t>\n\t>\n\n\tfunction command<\n\t\tResolve extends Resolver,\n\t\tconst Contract extends DomainContract & {\n\t\t\tcommands: Readonly<Record<string, DomainCommandContract>>\n\t\t},\n\t\tconst Operations extends Registry<DomainOf<Resolve>>,\n\t\tMode extends true,\n\t\tGuard = never,\n\t>(\n\t\tconfiguration: {\n\t\t\tcontract: Contract\n\t\t\tcontext: Resolve\n\t\t\taudit?: never\n\t\t\toperations: (\n\t\t\t\tdefine: DomainEffectFactory<\n\t\t\t\t\tDomainOf<Resolve>,\n\t\t\t\t\tContract['commands'],\n\t\t\t\t\tMode,\n\t\t\t\t\tnever,\n\t\t\t\t\tNoInfer<CallbackError<Guard>>,\n\t\t\t\t\tNoInfer<CallbackRequirements<Guard>>\n\t\t\t\t>,\n\t\t\t) => Operations &\n\t\t\t\tNoInfer<ExactDomainOperations<Operations, Contract['commands']>> &\n\t\t\t\tNoInfer<ValidatedEffectOperations<Operations>>\n\t\t\tdefaults?: { guard?: (context: DomainOf<Resolve>) => Guard }\n\t\t} & HostCompatible<Resolve, Dependencies>,\n\t): ReturnType<typeof createEffectCommand<Resolve, Operations, Dependencies, Guard>>\n\tfunction command<\n\t\tResolve extends Resolver,\n\t\tconst Contract extends DomainContract & {\n\t\t\tcommands: Readonly<Record<string, DomainCommandContract>>\n\t\t},\n\t\tconst Operations extends LooseRegistry<DomainOf<Resolve>>,\n\t\tReturned extends AuditValue,\n\t\tGuard = never,\n\t>(\n\t\tconfiguration: {\n\t\t\tcontract: Contract\n\t\t\tcontext: Resolve\n\t\t\taudit: (\n\t\t\t\tresolution: DomainAuditInput<Contract['commands']>,\n\t\t\t\tcontext: DomainOf<Resolve>,\n\t\t\t) => Returned\n\t\t\toperations: (\n\t\t\t\tdefine: DomainEffectFactory<\n\t\t\t\t\tDomainOf<Resolve>,\n\t\t\t\t\tContract['commands'],\n\t\t\t\t\ttrue,\n\t\t\t\t\t[Returned] extends [never] ? never : (resolution: never, context: never) => Returned,\n\t\t\t\t\tNoInfer<CallbackError<Guard>>,\n\t\t\t\t\tNoInfer<CallbackRequirements<Guard>>\n\t\t\t\t>,\n\t\t\t) => Operations &\n\t\t\t\tNoInfer<ExactDomainOperations<Operations, Contract['commands']>> &\n\t\t\t\tNoInfer<ValidatedEffectOperations<Operations>>\n\t\t\tdefaults?: { guard?: (context: DomainOf<Resolve>) => Guard }\n\t\t} & HostCompatible<Resolve, Dependencies>,\n\t): ReturnType<\n\t\ttypeof createEffectCommand<\n\t\t\tResolve,\n\t\t\tAuditedOperations<Operations, (resolution: never, context: never) => Returned>,\n\t\t\tDependencies,\n\t\t\tGuard\n\t\t>\n\t>\n\tfunction command<\n\t\tResolve extends Resolver,\n\t\tconst Operations extends LooseRegistry<DomainOf<Resolve>>,\n\t\tReturned extends AuditValue,\n\t\tGuard,\n\t>(\n\t\tconfiguration: {\n\t\t\tcontext: Resolve\n\t\t\taudit: (resolution: DomainAuditInput<Operations>, context: DomainOf<Resolve>) => Returned\n\t\t\toperations: (\n\t\t\t\tdefine: SharedEffectFactory<DomainOf<Resolve>, Guard>,\n\t\t\t) => Operations & NoInfer<ValidatedEffectOperations<Operations>>\n\t\t\tdefaults?: { guard?: (context: DomainOf<Resolve>) => Guard }\n\t\t} & HostCompatible<Resolve, Dependencies>,\n\t): ReturnType<\n\t\ttypeof createEffectCommand<\n\t\t\tResolve,\n\t\t\tAuditedOperations<Operations, (resolution: never, context: never) => Returned>,\n\t\t\tDependencies,\n\t\t\tGuard\n\t\t>\n\t>\n\n\tfunction command<\n\t\tResolve extends Resolver,\n\t\tconst Operations extends Registry<DomainOf<Resolve>>,\n\t\tGuard = never,\n\t>(\n\t\tconfiguration: EffectCommandConfiguration<Resolve, Operations, Guard> &\n\t\t\tHostCompatible<Resolve, Dependencies>,\n\t): ReturnType<typeof createEffectCommand<Resolve, Operations, Dependencies, Guard>>\n\tfunction command(configuration: {\n\t\tcontext: Resolver\n\t\tcontract?: DomainContract\n\t\taudit?: (resolution: never, context: never) => AuditValue\n\t\toperations: (define: never) => Readonly<Record<string, object>>\n\t\tdefaults?: { guard?: (context: never) => unknown }\n\t}): unknown {\n\t\tconst definitions = configuration.contract\n\t\t\t? domainEffectFactory(configuration.contract.commands ?? {}, true)\n\t\t\t: effectOperationFactory()\n\t\tconst operations = snapshotOperations(\n\t\t\tconfiguration.operations(\n\t\t\t\t// SAFETY: the overload chooses this exact inline or contracted helper factory.\n\t\t\t\tdefinitions as never,\n\t\t\t),\n\t\t\tconfiguration.contract,\n\t\t\t'commands',\n\t\t\tconfiguration.audit,\n\t\t)\n\t\t// SAFETY: overloads check callbacks and schemas; binding validates exact keys and snapshots runtime records.\n\t\treturn createEffectCommand({\n\t\t\t...configuration,\n\t\t\t...dependencies,\n\t\t\toperations: () => operations,\n\t\t} as never)\n\t}\n\treturn command\n}\n\nfunction normalizeCommandResult<Value>(\n\tinvoke: () => Supported<Value>,\n): Effect.Effect<Value, unknown, unknown> {\n\t// SAFETY: selected definition helper checks the callback's normalized success against the schema input.\n\treturn normalizeEffect(invoke) as Effect.Effect<Value, unknown, unknown>\n}\n"],"mappings":"8gBAsIA,MAAMA,EAAqD,CAC1D,QAASC,EAAO,QAChB,QAASA,EAAO,QAChB,QAASA,EAAO,OACjB,EA4BA,SAAgBC,EAMf,EAGC,CACD,IAAMC,EACLC,EAAc,WACbC,EAKE,CACH,EACKC,GACL,EACA,EACA,IAMkBL,EAAO,YAAc,CACtC,GAAI,CAAC,OAAO,UAAU,eAAe,KAAKE,EAAYI,CAAS,EAC9D,MAAM,MAAM,kDAAkD,EAE/D,IAAMC,EAAaL,EAAWI,GAQ9B,OAAON,EAAO,QAAQQ,EAAqBD,EAAW,MAAOE,CAAK,EAAI,GAAY,CAEjF,IAAMC,EAAUC,EACVC,EAAcT,EAAc,cAAc,MAAM,CACrD,YACA,eAAgBI,EAAW,cAC5B,CAAC,EAEKM,EAAUV,EAAc,QAC9B,OAAOW,MAAsBD,EAAQE,CAAI,CAAC,CAAC,CAAC,KAC3Cf,EAAO,QAAS,GACGgB,EAMhBjB,EAAiB,CAClB,YACA,eAAgBQ,EAAW,eAC3B,UACA,UACA,WACCA,EAAW,aAAe,IAAA,GACvB,IAAA,OAEAO,MAAsB,CACrB,GAAI,CAACX,EAAc,gBAClB,MAAM,IAAIc,EAAuBX,CAAS,EAE3C,OAAOH,EAAc,gBAAgBY,EAAe,CACnD,WAAYR,EAAW,WACvB,WACD,CAAC,CACF,CAAC,CAAC,CAAC,KAAKP,EAAO,MAAM,EACzB,YACCc,MAAsBP,EAAW,UAAUW,EAASR,CAAO,CAAC,CAAC,CAAC,KAC7DV,EAAO,IAAK,GACPmB,GAAa,OAAS,UACnB,CACN,KAAM,UACN,SAAUA,EAAY,SAClB,GACDL,MAAsBK,EAAY,SAAUC,CAAM,CAAC,CAAC,CAAC,KAAKpB,EAAO,MAAM,EACvE,IAAA,EACJ,EAP4CmB,CAW5C,CACF,EAED,aAAe,GACdX,EACCD,EAAW,cAAgBA,EAAW,OACtCc,CACD,EACD,WAAYd,EAAW,WACpB,CACC,GACAe,MACCf,EAAW,WAAY,CAAE,GAAGgB,EAAQ,MAAOb,CAAQ,CAAC,CACrD,CACF,EACC,CAAC,EACJ,aAAe,GACdI,MAAsBX,EAAc,UAAU,QAAQqB,CAAQ,CAAC,CAAC,CAAC,KAChExB,EAAO,MACR,EACD,MAAQ,GACPc,MAAsBP,EAAW,QAAQiB,EAAUd,CAAO,CAAC,CAAC,CAAC,KAAKV,EAAO,MAAM,EAChF,IAAM,GACLsB,MAA6Bf,EAAW,QAAQG,EAASc,CAAQ,CAAC,EAEnE,aAAe,GACdhB,EAAqBD,EAAW,OAAQc,CAAK,EAK9C,MAAQ,GACPP,MAAsBP,EAAW,MAAM,CAAE,UAAS,QAAO,EAAGW,CAAO,CAAC,EACrE,WAAa,GACZJ,MAEQX,EAAc,WAAWY,EAAeU,CAAK,CACpD,EACF,WAAYlB,EAAW,UACxB,CACe,CACf,EACDP,EAAO,OAAQ,GACdA,EAAO,SAAW,CACb0B,EAAK,UAAUC,CAAI,EAAGf,EAAY,UAAU,EAC3CA,EAAY,OAAOgB,EAAmBD,EAAK,KAAK,CAAC,CACvD,CAAC,CACF,CACD,CACD,CAAC,CACF,CAEe,EAMhB,MAAO,CAEN,YAAY,EAA0B,CACrC,MAAO,CACN,MACC,EACA,IACItB,EAAKC,EAAWG,EAAOS,CAAO,CACpC,CACD,EACA,OACC,EACA,EAMC,CACD,GAAI,CAAC,OAAO,OAAOhB,EAAYI,CAAS,EACvC,MAAM,MAAM,kDAAkD,EAC/D,OAAOuB,EAAgBC,EAAO,WAAYxB,EAAWJ,EAAWI,EAAU,CAC3E,EACA,MACD,CACD,CAGA,SAAgByB,EACf,EACC,CA0GD,SAASrB,EAAQ,EAML,CACX,IAAMsB,EAAc7B,EAAc,SAC/B8B,EAAoB9B,EAAc,SAAS,UAAY,CAAC,EAAG,EAAI,EAC/DC,EAAuB,EACpBF,EAAagC,EAClB/B,EAAc,WAEb6B,CACD,EACA7B,EAAc,SACd,WACAA,EAAc,KACf,EAEA,OAAOF,EAAoB,CAC1B,GAAGE,EACH,GAAGgC,EACH,eAAkBjC,CACnB,CAAU,CACX,CACA,OAAOQ,CACR,CAEA,SAASY,EACR,EACyC,CAEzC,OAAOR,EAAgBsB,CAAM,CAC9B"}
|
|
@@ -177,6 +177,7 @@ export declare function createEffectCrud<const Options extends EffectFoundationO
|
|
|
177
177
|
}, [Effect.Effect<EffectValue<Insert>, CallbackError<Insert>, CallbackRequirements<Insert>> | Effect.Effect<Partial<z.core.input<Table["storage"]>> | undefined, CallbackError<Enrich>, CallbackRequirements<Enrich>> | Effect.Effect<Id<Table>, never, never>] extends [Effect.Effect<infer _A, infer E, infer _R>] ? E : never, [Effect.Effect<EffectValue<Insert>, CallbackError<Insert>, CallbackRequirements<Insert>> | Effect.Effect<Partial<z.core.input<Table["storage"]>> | undefined, CallbackError<Enrich>, CallbackRequirements<Enrich>> | Effect.Effect<Id<Table>, never, never>] extends [Effect.Effect<infer _A_1, infer _E, infer R>] ? R : never>, RequiredOverride<Configuration, "create">>>>) => never) | undefined;
|
|
178
178
|
} & {
|
|
179
179
|
classification: string;
|
|
180
|
+
} & {
|
|
180
181
|
audit: (resolution: {
|
|
181
182
|
command: z.infer<Table["commandInput"]>;
|
|
182
183
|
result: {
|
|
@@ -242,6 +243,7 @@ export declare function createEffectCrud<const Options extends EffectFoundationO
|
|
|
242
243
|
}, CallbackError<Patch>, CallbackRequirements<Patch>>, RequiredOverride<Configuration, "update">>>>>) => never) | undefined;
|
|
243
244
|
} & {
|
|
244
245
|
classification: string;
|
|
246
|
+
} & {
|
|
245
247
|
audit: (resolution: {
|
|
246
248
|
command: z.infer<Table["tools"]["update"]>;
|
|
247
249
|
result: {
|
|
@@ -307,6 +309,7 @@ export declare function createEffectCrud<const Options extends EffectFoundationO
|
|
|
307
309
|
}, CallbackError<Patch>, CallbackRequirements<Patch>>, RequiredOverride<Configuration, "archive">>>>>) => never) | undefined;
|
|
308
310
|
} & {
|
|
309
311
|
classification: string;
|
|
312
|
+
} & {
|
|
310
313
|
audit: (resolution: {
|
|
311
314
|
command: z.infer<Table["tools"]["id"]>;
|
|
312
315
|
result: {
|
|
@@ -499,6 +502,7 @@ export declare function createEffectCrud<const Options extends EffectFoundationO
|
|
|
499
502
|
}, [Effect.Effect<EffectValue<Insert>, CallbackError<Insert>, CallbackRequirements<Insert>> | Effect.Effect<Partial<z.core.input<Table["storage"]>> | undefined, CallbackError<Enrich>, CallbackRequirements<Enrich>> | Effect.Effect<Id<Table>, never, never>] extends [Effect.Effect<infer _A, infer E, infer _R>] ? E : never, [Effect.Effect<EffectValue<Insert>, CallbackError<Insert>, CallbackRequirements<Insert>> | Effect.Effect<Partial<z.core.input<Table["storage"]>> | undefined, CallbackError<Enrich>, CallbackRequirements<Enrich>> | Effect.Effect<Id<Table>, never, never>] extends [Effect.Effect<infer _A_1, infer _E, infer R>] ? R : never>, RequiredOverride<Configuration, "create">>>>) => never) | undefined;
|
|
500
503
|
} & {
|
|
501
504
|
classification: string;
|
|
505
|
+
} & {
|
|
502
506
|
audit: (resolution: {
|
|
503
507
|
command: z.infer<Table["commandInput"]>;
|
|
504
508
|
result: {
|
|
@@ -564,6 +568,7 @@ export declare function createEffectCrud<const Options extends EffectFoundationO
|
|
|
564
568
|
}, CallbackError<Patch>, CallbackRequirements<Patch>>, RequiredOverride<Configuration, "update">>>>>) => never) | undefined;
|
|
565
569
|
} & {
|
|
566
570
|
classification: string;
|
|
571
|
+
} & {
|
|
567
572
|
audit: (resolution: {
|
|
568
573
|
command: z.infer<Table["tools"]["update"]>;
|
|
569
574
|
result: {
|
|
@@ -629,6 +634,7 @@ export declare function createEffectCrud<const Options extends EffectFoundationO
|
|
|
629
634
|
}, CallbackError<Patch>, CallbackRequirements<Patch>>, RequiredOverride<Configuration, "archive">>>>>) => never) | undefined;
|
|
630
635
|
} & {
|
|
631
636
|
classification: string;
|
|
637
|
+
} & {
|
|
632
638
|
audit: (resolution: {
|
|
633
639
|
command: z.infer<Table["tools"]["id"]>;
|
|
634
640
|
result: {
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ContractInput, ContractOutput, ContractSchema } from "../contracts/contract.mjs";
|
|
2
|
+
import { AuditEntryInput } from "../../components/foundation/client.mjs";
|
|
3
|
+
import { DomainOperationContract, ExactOperationKeys } from "../contracts/domain.mjs";
|
|
4
|
+
import { CallbackError, CallbackRequirements, CheckedEffectDefinition, EffectPreparation, OperationDefinition, effectOperationFactory } from "./operation.mjs";
|
|
5
|
+
import { Effect } from "effect";
|
|
6
|
+
//#region src/modules/effect/domain.d.ts
|
|
7
|
+
type Supported<A> = A | PromiseLike<A> | Effect.Effect<A, unknown, unknown>;
|
|
8
|
+
type Audit = Omit<AuditEntryInput, 'classification'> | null;
|
|
9
|
+
declare const domainKey: unique symbol;
|
|
10
|
+
type BoundKey<Key> = {
|
|
11
|
+
readonly [domainKey]: Key;
|
|
12
|
+
};
|
|
13
|
+
type Schemas<Entry extends DomainOperationContract> = Pick<Entry, 'input' | 'result'> & Omit<Entry, 'input' | 'result'>;
|
|
14
|
+
type Forbidden = {
|
|
15
|
+
input?: never;
|
|
16
|
+
result?: never;
|
|
17
|
+
classification?: never;
|
|
18
|
+
replayResult?: never;
|
|
19
|
+
wire?: never;
|
|
20
|
+
};
|
|
21
|
+
type AuditCallback<Context, Entry extends DomainOperationContract, Value> = (resolution: {
|
|
22
|
+
command: ContractOutput<Entry['input']>;
|
|
23
|
+
result: ContractOutput<Entry['result']>;
|
|
24
|
+
}, context: Context) => Value;
|
|
25
|
+
export type SelectedAudit<Definition, Default> = Definition extends {
|
|
26
|
+
audit: infer Override;
|
|
27
|
+
} ? Override : 'audit' extends keyof Definition ? Exclude<Definition['audit' & keyof Definition], undefined> | Default : Default;
|
|
28
|
+
export type AuditedOperations<Operations, Default> = { [Key in keyof Operations]: Omit<Operations[Key], 'audit'> & {
|
|
29
|
+
audit: SelectedAudit<Operations[Key], Default>;
|
|
30
|
+
}; };
|
|
31
|
+
export type ExactDomainOperations<Operations, Contracts> = ExactOperationKeys<Operations, Contracts> & { [Key in keyof Operations]: Operations[Key] extends BoundKey<Key> ? Operations[Key] : never; };
|
|
32
|
+
type Helper<Context, Entry extends DomainOperationContract, Key, Command extends boolean, Default, BaseError, BaseRequirements> = <Handler extends Supported<ContractInput<Entry['result']>>, Guard extends Supported<void> = never, Preparation extends Supported<EffectPreparation<ContractOutput<Entry['result']>, unknown, unknown>> = never, const Aggregates extends readonly string[] = readonly string[], AuditReturned extends Supported<Audit> = never, Middleware extends Supported<ContractInput<Entry['result']>> = never, const Metadata extends object = Record<never, never>, const Definition extends object = object>(implementation: Definition & Forbidden & Omit<OperationDefinition<Context, Entry['input'], Entry['result'], Record<never, never>, Aggregates, Handler, Guard, Preparation, AuditReturned, Middleware, Metadata, BaseError, BaseRequirements, ContractSchema, never>, 'input' | 'result' | 'classification' | 'replayResult' | 'wire'> & (Command extends true ? [Default] extends [never] ? {
|
|
33
|
+
audit: AuditCallback<Context, Entry, AuditReturned>;
|
|
34
|
+
} : {} : {
|
|
35
|
+
audit?: never;
|
|
36
|
+
prepare?: never;
|
|
37
|
+
aggregates?: never;
|
|
38
|
+
})) => CheckedEffectDefinition<Context, Schemas<Entry> & Definition & BoundKey<Key>, BaseError, BaseRequirements>;
|
|
39
|
+
export type DomainEffectFactory<Context, Entries extends Readonly<Record<string, DomainOperationContract>>, Command extends boolean, Default = never, BaseError = never, BaseRequirements = never> = { [Kind in Command extends true ? 'command' : 'query']: { readonly [Key in keyof Entries]: Helper<Context, Entries[Key], Key, Command, Default, BaseError, BaseRequirements>; }; };
|
|
40
|
+
export declare function domainEffectFactory<Context, Entries extends Readonly<Record<string, DomainOperationContract>>, Command extends boolean, Default, Guard>(entries: Entries, command: Command): DomainEffectFactory<Context, Entries, Command, Default, CallbackError<Guard>, CallbackRequirements<Guard>>;
|
|
41
|
+
export type SharedEffectFactory<Context, Guard> = ReturnType<typeof effectOperationFactory<Context, Record<never, never>, NoInfer<CallbackError<Guard>>, NoInfer<CallbackRequirements<Guard>>, false>>;
|
|
42
|
+
export type AuditValue = Supported<Audit>;
|
|
43
|
+
//#endregion
|
|
44
|
+
//# sourceMappingURL=domain.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"domain.mjs","names":["domainEffectFactory","helpers","domainHelpers","entries","command"],"sources":["../../../src/modules/effect/domain.ts"],"sourcesContent":["/* oxlint-disable anti-slop/no-object-parameters -- Internal helper storage is heterogeneous; the exported mapped signatures validate the schema-paired implementation. */\nimport type { Effect } from 'effect'\nimport type { AuditEntryInput } from '../../components/foundation/client'\nimport type { ContractInput, ContractOutput, ContractSchema } from '../contracts/contract'\nimport type { DomainOperationContract, ExactOperationKeys } from '../contracts/domain'\nimport { domainHelpers } from '../contracts/binding'\nimport {\n\teffectOperationFactory,\n\ttype OperationDefinition,\n\ttype CheckedEffectDefinition,\n\ttype CallbackError,\n\ttype CallbackRequirements,\n\ttype EffectPreparation,\n} from './operation'\n\ntype Supported<A> = A | PromiseLike<A> | Effect.Effect<A, unknown, unknown>\ntype Audit = Omit<AuditEntryInput, 'classification'> | null\ndeclare const domainKey: unique symbol\ntype BoundKey<Key> = { readonly [domainKey]: Key }\ntype Schemas<Entry extends DomainOperationContract> = Pick<Entry, 'input' | 'result'> &\n\tOmit<Entry, 'input' | 'result'>\ntype Forbidden = {\n\tinput?: never\n\tresult?: never\n\tclassification?: never\n\treplayResult?: never\n\twire?: never\n}\ntype AuditCallback<Context, Entry extends DomainOperationContract, Value> = (\n\tresolution: { command: ContractOutput<Entry['input']>; result: ContractOutput<Entry['result']> },\n\tcontext: Context,\n) => Value\nexport type SelectedAudit<Definition, Default> = Definition extends { audit: infer Override }\n\t? Override\n\t: 'audit' extends keyof Definition\n\t\t? Exclude<Definition['audit' & keyof Definition], undefined> | Default\n\t\t: Default\nexport type AuditedOperations<Operations, Default> = {\n\t[Key in keyof Operations]: Omit<Operations[Key], 'audit'> & {\n\t\taudit: SelectedAudit<Operations[Key], Default>\n\t}\n}\nexport type ExactDomainOperations<Operations, Contracts> = ExactOperationKeys<\n\tOperations,\n\tContracts\n> & {\n\t[Key in keyof Operations]: Operations[Key] extends BoundKey<Key> ? Operations[Key] : never\n}\n\ntype Helper<\n\tContext,\n\tEntry extends DomainOperationContract,\n\tKey,\n\tCommand extends boolean,\n\tDefault,\n\tBaseError,\n\tBaseRequirements,\n> = <\n\tHandler extends Supported<ContractInput<Entry['result']>>,\n\tGuard extends Supported<void> = never,\n\tPreparation extends Supported<\n\t\tEffectPreparation<ContractOutput<Entry['result']>, unknown, unknown>\n\t> = never,\n\tconst Aggregates extends readonly string[] = readonly string[],\n\tAuditReturned extends Supported<Audit> = never,\n\tMiddleware extends Supported<ContractInput<Entry['result']>> = never,\n\tconst Metadata extends object = Record<never, never>,\n\tconst Definition extends object = object,\n>(\n\timplementation: Definition &\n\t\tForbidden &\n\t\tOmit<\n\t\t\tOperationDefinition<\n\t\t\t\tContext,\n\t\t\t\tEntry['input'],\n\t\t\t\tEntry['result'],\n\t\t\t\tRecord<never, never>,\n\t\t\t\tAggregates,\n\t\t\t\tHandler,\n\t\t\t\tGuard,\n\t\t\t\tPreparation,\n\t\t\t\tAuditReturned,\n\t\t\t\tMiddleware,\n\t\t\t\tMetadata,\n\t\t\t\tBaseError,\n\t\t\t\tBaseRequirements,\n\t\t\t\tContractSchema,\n\t\t\t\tnever\n\t\t\t>,\n\t\t\t'input' | 'result' | 'classification' | 'replayResult' | 'wire'\n\t\t> &\n\t\t(Command extends true\n\t\t\t? [Default] extends [never]\n\t\t\t\t? { audit: AuditCallback<Context, Entry, AuditReturned> }\n\t\t\t\t: {}\n\t\t\t: { audit?: never; prepare?: never; aggregates?: never }),\n) => CheckedEffectDefinition<\n\tContext,\n\tSchemas<Entry> & Definition & BoundKey<Key>,\n\tBaseError,\n\tBaseRequirements\n>\n\nexport type DomainEffectFactory<\n\tContext,\n\tEntries extends Readonly<Record<string, DomainOperationContract>>,\n\tCommand extends boolean,\n\tDefault = never,\n\tBaseError = never,\n\tBaseRequirements = never,\n> = {\n\t[Kind in Command extends true ? 'command' : 'query']: {\n\t\treadonly [Key in keyof Entries]: Helper<\n\t\t\tContext,\n\t\t\tEntries[Key],\n\t\t\tKey,\n\t\t\tCommand,\n\t\t\tDefault,\n\t\t\tBaseError,\n\t\t\tBaseRequirements\n\t\t>\n\t}\n}\n\nexport function domainEffectFactory<\n\tContext,\n\tEntries extends Readonly<Record<string, DomainOperationContract>>,\n\tCommand extends boolean,\n\tDefault,\n\tGuard,\n>(\n\tentries: Entries,\n\tcommand: Command,\n): DomainEffectFactory<\n\tContext,\n\tEntries,\n\tCommand,\n\tDefault,\n\tCallbackError<Guard>,\n\tCallbackRequirements<Guard>\n> {\n\tconst helpers = domainHelpers(entries)\n\t// SAFETY: each named helper installs its exact declaration; the public signatures check all callbacks.\n\treturn { [command ? 'command' : 'query']: helpers } as DomainEffectFactory<\n\t\tContext,\n\t\tEntries,\n\t\tCommand,\n\t\tDefault,\n\t\tCallbackError<Guard>,\n\t\tCallbackRequirements<Guard>\n\t>\n}\n\nexport type SharedEffectFactory<Context, Guard> = ReturnType<\n\ttypeof effectOperationFactory<\n\t\tContext,\n\t\tRecord<never, never>,\n\t\tNoInfer<CallbackError<Guard>>,\n\t\tNoInfer<CallbackRequirements<Guard>>,\n\t\tfalse\n\t>\n>\nexport type AuditValue = Supported<Audit>\n"],"mappings":"yDA4HA,SAAgBA,EAOf,EACA,EAQC,CACD,IAAMC,EAAUC,EAAcC,CAAO,EAErC,MAAO,EAAGC,EAAU,UAAY,SAAUH,CAAQ,CAQnD"}
|
|
@@ -90,7 +90,7 @@ type Audit<Aggregates extends readonly string[]> = Omit<AuditEntryInput, 'classi
|
|
|
90
90
|
id: string;
|
|
91
91
|
};
|
|
92
92
|
};
|
|
93
|
-
type OperationDefinition<Context, Input extends ContractSchema, Output extends ContractSchema, Extension, Aggregates extends readonly string[], Handler, Guard, Preparation, AuditResult, Middleware, Metadata, BaseError, BaseRequirements, Wire extends ContractSchema, Replay extends ContractSchema> = {
|
|
93
|
+
export type OperationDefinition<Context, Input extends ContractSchema, Output extends ContractSchema, Extension, Aggregates extends readonly string[], Handler, Guard, Preparation, AuditResult, Middleware, Metadata, BaseError, BaseRequirements, Wire extends ContractSchema, Replay extends ContractSchema> = {
|
|
94
94
|
input: Input;
|
|
95
95
|
result: Output;
|
|
96
96
|
handler: (input: ContractOutput<Input>, context: Context & Extension) => Handler;
|
|
@@ -120,15 +120,16 @@ type OperationDefinition<Context, Input extends ContractSchema, Output extends C
|
|
|
120
120
|
* and returned Effect channels when middleware comes first. TypeScript processes
|
|
121
121
|
* context-sensitive object callbacks in declaration order.
|
|
122
122
|
*/
|
|
123
|
-
export declare function effectOperationFactory<Context, Extension extends Record<string, unknown> = Record<never, never>, BaseError = never, BaseRequirements = never>(): {
|
|
123
|
+
export declare function effectOperationFactory<Context, Extension extends Record<string, unknown> = Record<never, never>, BaseError = never, BaseRequirements = never, AuditRequired extends boolean = true>(): {
|
|
124
124
|
operation: <const Input extends ContractSchema, const Output extends ContractSchema, Handler extends Supported<ContractInput<Output>>, Guard extends Supported<void> = never, Preparation extends Supported<EffectPreparation<ContractOutput<Output>, unknown, unknown>> = never, const Aggregates extends readonly string[] = readonly string[], AuditResult extends Supported<Audit<Aggregates> | null> = never, Middleware extends Supported<ContractInput<Output>> = never, const Metadata extends object = Record<never, never>, const Wire extends ContractSchema = ContractSchema, const Replay extends ContractSchema = never, const Definition extends object = object>(definition: Definition & OperationDefinition<Context, Input, Output, Extension, Aggregates, Handler, Guard, Preparation, AuditResult, Middleware, Metadata, BaseError, BaseRequirements, Wire, Replay>) => CheckedEffectDefinition<Context, typeof definition, BaseError, BaseRequirements>;
|
|
125
125
|
command: <const Input extends ContractSchema, const Output extends ContractSchema, Handler extends Supported<ContractInput<Output>>, Guard extends Supported<void> = never, Preparation extends Supported<EffectPreparation<ContractOutput<Output>, unknown, unknown>> = never, const Aggregates extends readonly string[] = readonly string[], AuditResult extends Supported<Audit<Aggregates> | null> = never, Middleware extends Supported<ContractInput<Output>> = never, const Metadata extends object = Record<never, never>, const Wire extends ContractSchema = ContractSchema, const Replay extends ContractSchema = never, const Definition extends object = object>(definition: Definition & OperationDefinition<Context, Input, Output, Extension, Aggregates, Handler, Guard, Preparation, AuditResult, Middleware, Metadata, BaseError, BaseRequirements, Wire, Replay> & {
|
|
126
126
|
classification: string;
|
|
127
|
+
} & (AuditRequired extends true ? {
|
|
127
128
|
audit: (resolution: {
|
|
128
129
|
command: ContractOutput<Input>;
|
|
129
130
|
result: ContractOutput<Output>;
|
|
130
131
|
}, context: Context) => AuditResult;
|
|
131
|
-
}) => CheckedEffectDefinition<Context, typeof definition, BaseError, BaseRequirements>;
|
|
132
|
+
} : {})) => CheckedEffectDefinition<Context, typeof definition, BaseError, BaseRequirements>;
|
|
132
133
|
query: <const Input extends ContractSchema, const Output extends ContractSchema, Handler extends Supported<ContractInput<Output>>, Guard extends Supported<void> = never, Middleware extends Supported<ContractInput<Output>> = never, const Metadata extends object = Record<never, never>, const Wire extends ContractSchema = ContractSchema, const Replay extends ContractSchema = never, const Definition extends object = object>(definition: Definition & OperationDefinition<Context, Input, Output, Extension, readonly string[], Handler, Guard, never, never, Middleware, Metadata, BaseError, BaseRequirements, Wire, Replay> & {
|
|
133
134
|
prepare?: never;
|
|
134
135
|
audit?: never;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation.mjs","names":["effectOperationFactory","operation","definition","command","query"],"sources":["../../../src/modules/effect/operation.ts"],"sourcesContent":["import type { Effect } from 'effect'\nimport type { ContractSchema, ContractInput, ContractOutput } from '../contracts/contract'\nimport type { ContractDecoderError, ContractDecoderRequirements } from './schema'\nimport type { AuditEntryInput } from '../../components/foundation/client'\n\n/** Ordinary failures are defects; only an explicit Effect supplies a typed error. */\nexport type CallbackError<Value> = Value extends (...arguments_: never[]) => infer Returned\n\t? CallbackError<Returned>\n\t: Value extends Effect.Effect<infer Success, infer Error, unknown>\n\t\t? Error | CallbackError<Success>\n\t\t: Value extends PromiseLike<infer Awaited>\n\t\t\t? CallbackError<Awaited>\n\t\t\t: Value extends readonly (infer Item)[]\n\t\t\t\t? CallbackError<Item>\n\t\t\t\t: Value extends { kind: 'execute'; complete?: infer Complete }\n\t\t\t\t\t? CallbackError<Complete>\n\t\t\t\t\t: never\n\nexport type CallbackRequirements<Value> = Value extends (...arguments_: never[]) => infer Returned\n\t? CallbackRequirements<Returned>\n\t: Value extends Effect.Effect<infer Success, unknown, infer Requirements>\n\t\t? Requirements | CallbackRequirements<Success>\n\t\t: Value extends PromiseLike<infer Awaited>\n\t\t\t? CallbackRequirements<Awaited>\n\t\t\t: Value extends readonly (infer Item)[]\n\t\t\t\t? CallbackRequirements<Item>\n\t\t\t\t: Value extends { kind: 'execute'; complete?: infer Complete }\n\t\t\t\t\t? CallbackRequirements<Complete>\n\t\t\t\t\t: never\n\nexport type EffectValue<Value> =\n\tValue extends Effect.Effect<infer Success, unknown, unknown>\n\t\t? EffectValue<Success>\n\t\t: Value extends PromiseLike<infer Awaited>\n\t\t\t? EffectValue<Awaited>\n\t\t\t: Value\n\ndeclare const checkedOperation: unique symbol\n/** Type-only evidence that the helper checked callbacks against the base context and schemas. */\nexport type CheckedEffectOperation<Context> = {\n\treadonly [checkedOperation]: {\n\t\tcontext: (context: Context) => void\n\t\terror: unknown\n\t\trequirements: unknown\n\t\tdefinition: unknown\n\t}\n}\ntype CheckedChannels<Context, Error, Requirements, Definition> = {\n\treadonly [checkedOperation]: {\n\t\tcontext: (context: Context) => void\n\t\terror: Error\n\t\trequirements: Requirements\n\t\tdefinition: Definition\n\t}\n}\n/** Named checked-definition boundary keeps the private evidence marker inside this module's declarations. */\nexport type CheckedEffectDefinition<\n\tContext,\n\tDefinition,\n\tError = never,\n\tRequirements = never,\n> = NoInfer<Omit<Definition, typeof checkedOperation>> &\n\tCheckedChannels<Context, Error, Requirements, Omit<Definition, typeof checkedOperation>>\n/** Reject stale helper evidence after callbacks or schemas are replaced. */\nexport type ValidatedEffectOperations<Operations> = {\n\t[Key in keyof Operations]: Operations[Key] extends {\n\t\treadonly [checkedOperation]: { definition: infer Definition }\n\t}\n\t\t? Operations[Key] extends Definition\n\t\t\t? Operations[Key]\n\t\t\t: never\n\t\t: never\n}\n/** Only middleware whose next contract captured a default policy can discharge its channels. */\nexport type UnwrappedDefaultError<Definition, Guard> = Definition extends { middleware: Function }\n\t? Definition extends CheckedChannels<never, infer Error, unknown, unknown>\n\t\t? Exclude<CallbackError<Guard>, Error>\n\t\t: CallbackError<Guard>\n\t: CallbackError<Guard>\nexport type UnwrappedDefaultRequirements<Definition, Guard> = Definition extends {\n\tmiddleware: Function\n}\n\t? Definition extends CheckedChannels<never, unknown, infer Requirements, unknown>\n\t\t? Exclude<CallbackRequirements<Guard>, Requirements>\n\t\t: CallbackRequirements<Guard>\n\t: CallbackRequirements<Guard>\nexport type EffectOperationArgument<Definition extends { input: ContractSchema }> = ContractInput<\n\tDefinition['input']\n>\nexport type EffectOperationInput<Definition extends { input: ContractSchema }> = ContractOutput<\n\tDefinition['input']\n>\nexport type EffectOperationHandlerResult<Definition extends { result: ContractSchema }> =\n\tContractInput<Definition['result']>\nexport type EffectOperationResult<Definition extends { result: ContractSchema }> = ContractOutput<\n\tDefinition['result']\n>\n\ntype Hook<Definition, Key extends PropertyKey> = Key extends keyof Definition\n\t? Definition[Key]\n\t: never\ntype Returned<Callback> = Callback extends (...arguments_: never[]) => infer Value ? Value : never\n/** A conditional wrapper must retain the unwrapped channels for its absent branch. */\ntype CoreValue<Definition> = [Returned<Hook<Definition, 'middleware'>>] extends [never]\n\t? Returned<Hook<Definition, 'handler'>> | Returned<Hook<Definition, 'guard'>>\n\t: undefined extends Hook<Definition, 'middleware'>\n\t\t?\n\t\t\t\t| Returned<Hook<Definition, 'handler'>>\n\t\t\t\t| Returned<Hook<Definition, 'guard'>>\n\t\t\t\t| Returned<Hook<Definition, 'middleware'>>\n\t\t: Returned<Hook<Definition, 'middleware'>>\ntype OutsideHooks = 'prepare' | 'audit' | 'checkPermission' | 'writeAudit'\nexport type EffectOperationError<Definition> =\n\t| ContractDecoderError<Hook<Definition, 'input'>>\n\t| ContractDecoderError<Hook<Definition, 'result'>>\n\t| ContractDecoderError<Hook<Definition, 'replayResult'>>\n\t| CallbackError<CoreValue<Definition>>\n\t| CallbackError<Definition[Extract<keyof Definition, OutsideHooks>]>\nexport type EffectOperationRequirements<Definition> =\n\t| ContractDecoderRequirements<Hook<Definition, 'input'>>\n\t| ContractDecoderRequirements<Hook<Definition, 'result'>>\n\t| ContractDecoderRequirements<Hook<Definition, 'replayResult'>>\n\t| CallbackRequirements<CoreValue<Definition>>\n\t| CallbackRequirements<Definition[Extract<keyof Definition, OutsideHooks>]>\n\ntype Supported<Value, Error = unknown, Requirements = unknown> =\n\t| Value\n\t| PromiseLike<Value>\n\t| Effect.Effect<Value, Error, Requirements>\nexport type EffectPreparation<Result, Error = never, Requirements = never> =\n\t| { kind: 'replay'; result: unknown }\n\t| { kind: 'execute'; complete?: (result: Result) => Supported<void, Error, Requirements> }\nexport type EffectMiddlewareInput<\n\tContext,\n\tInput,\n\tResult,\n\tExtension,\n\tError = never,\n\tRequirements = never,\n> = {\n\toperation: string\n\tcontext: Context\n\tcommand: Input\n\tinput: Input\n\tnext: keyof Extension extends never\n\t\t? (options?: { context?: Extension }) => Effect.Effect<Result, Error, Requirements>\n\t\t: (options: { context: Extension }) => Effect.Effect<Result, Error, Requirements>\n}\ntype Audit<Aggregates extends readonly string[]> = Omit<\n\tAuditEntryInput,\n\t'classification' | 'aggregate'\n> & {\n\taggregate: { type: Aggregates[number]; id: string }\n}\ntype OperationDefinition<\n\tContext,\n\tInput extends ContractSchema,\n\tOutput extends ContractSchema,\n\tExtension,\n\tAggregates extends readonly string[],\n\tHandler,\n\tGuard,\n\tPreparation,\n\tAuditResult,\n\tMiddleware,\n\tMetadata,\n\tBaseError,\n\tBaseRequirements,\n\tWire extends ContractSchema,\n\tReplay extends ContractSchema,\n> = {\n\tinput: Input\n\tresult: Output\n\thandler: (input: ContractOutput<Input>, context: Context & Extension) => Handler\n\tclassification?: string\n\tpermission?: string\n\tmetadata?: Metadata\n\taggregates?: Aggregates\n\treplayResult?: Replay & (ContractOutput<Replay> extends ContractOutput<Output> ? unknown : never)\n\twire?: { schema: Wire; project: (value: ContractOutput<Output>) => ContractInput<Wire> }\n\tguard?: (context: Context & Extension, input: ContractOutput<Input>) => Guard\n\tprepare?: (context: Context, input: ContractOutput<Input>) => Preparation\n\taudit?: (\n\t\tresolution: { command: ContractOutput<Input>; result: ContractOutput<Output> },\n\t\tcontext: Context,\n\t) => AuditResult\n} & (keyof Extension extends never\n\t? {\n\t\t\tmiddleware?: (\n\t\t\t\tinput: EffectMiddlewareInput<\n\t\t\t\t\tContext,\n\t\t\t\t\tContractOutput<Input>,\n\t\t\t\t\tContractInput<Output>,\n\t\t\t\t\tExtension,\n\t\t\t\t\tBaseError | CallbackError<Handler | Guard>,\n\t\t\t\t\tBaseRequirements | CallbackRequirements<Handler | Guard>\n\t\t\t\t>,\n\t\t\t) => Middleware\n\t\t}\n\t: {\n\t\t\tmiddleware: (\n\t\t\t\tinput: EffectMiddlewareInput<\n\t\t\t\t\tContext,\n\t\t\t\t\tContractOutput<Input>,\n\t\t\t\t\tContractInput<Output>,\n\t\t\t\t\tExtension,\n\t\t\t\t\tBaseError | CallbackError<Handler | Guard>,\n\t\t\t\t\tBaseRequirements | CallbackRequirements<Handler | Guard>\n\t\t\t\t>,\n\t\t\t) => Middleware\n\t\t})\n\n/**\n * Bind context once; middleware wraps the handler/guard channels and may discharge them.\n * Declare contextual guards/handlers before middleware, or annotate their parameters\n * and returned Effect channels when middleware comes first. TypeScript processes\n * context-sensitive object callbacks in declaration order.\n */\nexport function effectOperationFactory<\n\tContext,\n\tExtension extends Record<string, unknown> = Record<never, never>,\n\tBaseError = never,\n\tBaseRequirements = never,\n>() {\n\tfunction operation<\n\t\tconst Input extends ContractSchema,\n\t\tconst Output extends ContractSchema,\n\t\tHandler extends Supported<ContractInput<Output>>,\n\t\tGuard extends Supported<void> = never,\n\t\tPreparation extends Supported<EffectPreparation<ContractOutput<Output>, unknown, unknown>> =\n\t\t\tnever,\n\t\tconst Aggregates extends readonly string[] = readonly string[],\n\t\tAuditResult extends Supported<Audit<Aggregates> | null> = never,\n\t\tMiddleware extends Supported<ContractInput<Output>> = never,\n\t\tconst Metadata extends object = Record<never, never>,\n\t\t// Retain whether middleware is guaranteed, conditional, or omitted.\n\t\tconst Wire extends ContractSchema = ContractSchema,\n\t\tconst Replay extends ContractSchema = never,\n\t\tconst Definition extends object = object,\n\t>(\n\t\tdefinition: Definition &\n\t\t\tOperationDefinition<\n\t\t\t\tContext,\n\t\t\t\tInput,\n\t\t\t\tOutput,\n\t\t\t\tExtension,\n\t\t\t\tAggregates,\n\t\t\t\tHandler,\n\t\t\t\tGuard,\n\t\t\t\tPreparation,\n\t\t\t\tAuditResult,\n\t\t\t\tMiddleware,\n\t\t\t\tMetadata,\n\t\t\t\tBaseError,\n\t\t\t\tBaseRequirements,\n\t\t\t\tWire,\n\t\t\t\tReplay\n\t\t\t>,\n\t) {\n\t\t// SAFETY: the marker is type-only proof of the helper's checked callback contract.\n\t\treturn definition as CheckedEffectDefinition<\n\t\t\tContext,\n\t\t\ttypeof definition,\n\t\t\tBaseError,\n\t\t\tBaseRequirements\n\t\t>\n\t}\n\tfunction command<\n\t\tconst Input extends ContractSchema,\n\t\tconst Output extends ContractSchema,\n\t\tHandler extends Supported<ContractInput<Output>>,\n\t\tGuard extends Supported<void> = never,\n\t\tPreparation extends Supported<EffectPreparation<ContractOutput<Output>, unknown, unknown>> =\n\t\t\tnever,\n\t\tconst Aggregates extends readonly string[] = readonly string[],\n\t\tAuditResult extends Supported<Audit<Aggregates> | null> = never,\n\t\tMiddleware extends Supported<ContractInput<Output>> = never,\n\t\tconst Metadata extends object = Record<never, never>,\n\t\t// Retain whether middleware is guaranteed, conditional, or omitted.\n\t\tconst Wire extends ContractSchema = ContractSchema,\n\t\tconst Replay extends ContractSchema = never,\n\t\tconst Definition extends object = object,\n\t>(\n\t\tdefinition: Definition &\n\t\t\tOperationDefinition<\n\t\t\t\tContext,\n\t\t\t\tInput,\n\t\t\t\tOutput,\n\t\t\t\tExtension,\n\t\t\t\tAggregates,\n\t\t\t\tHandler,\n\t\t\t\tGuard,\n\t\t\t\tPreparation,\n\t\t\t\tAuditResult,\n\t\t\t\tMiddleware,\n\t\t\t\tMetadata,\n\t\t\t\tBaseError,\n\t\t\t\tBaseRequirements,\n\t\t\t\tWire,\n\t\t\t\tReplay\n\t\t\t> & {\n\t\t\t\tclassification: string\n\t\t\t\taudit: (\n\t\t\t\t\tresolution: { command: ContractOutput<Input>; result: ContractOutput<Output> },\n\t\t\t\t\tcontext: Context,\n\t\t\t\t) => AuditResult\n\t\t\t},\n\t) {\n\t\t// SAFETY: the marker is type-only proof of the helper's checked callback contract.\n\t\treturn definition as CheckedEffectDefinition<\n\t\t\tContext,\n\t\t\ttypeof definition,\n\t\t\tBaseError,\n\t\t\tBaseRequirements\n\t\t>\n\t}\n\tfunction query<\n\t\tconst Input extends ContractSchema,\n\t\tconst Output extends ContractSchema,\n\t\tHandler extends Supported<ContractInput<Output>>,\n\t\tGuard extends Supported<void> = never,\n\t\tMiddleware extends Supported<ContractInput<Output>> = never,\n\t\tconst Metadata extends object = Record<never, never>,\n\t\tconst Wire extends ContractSchema = ContractSchema,\n\t\tconst Replay extends ContractSchema = never,\n\t\tconst Definition extends object = object,\n\t>(\n\t\tdefinition: Definition &\n\t\t\tOperationDefinition<\n\t\t\t\tContext,\n\t\t\t\tInput,\n\t\t\t\tOutput,\n\t\t\t\tExtension,\n\t\t\t\treadonly string[],\n\t\t\t\tHandler,\n\t\t\t\tGuard,\n\t\t\t\tnever,\n\t\t\t\tnever,\n\t\t\t\tMiddleware,\n\t\t\t\tMetadata,\n\t\t\t\tBaseError,\n\t\t\t\tBaseRequirements,\n\t\t\t\tWire,\n\t\t\t\tReplay\n\t\t\t> & {\n\t\t\t\tprepare?: never\n\t\t\t\taudit?: never\n\t\t\t\taggregates?: never\n\t\t\t\treplayResult?: never\n\t\t\t},\n\t) {\n\t\t// SAFETY: the marker is type-only proof of the helper's checked callback contract.\n\t\treturn definition as CheckedEffectDefinition<\n\t\t\tContext,\n\t\t\ttypeof definition,\n\t\t\tBaseError,\n\t\t\tBaseRequirements\n\t\t>\n\t}\n\treturn { operation, command, query }\n}\n"],"mappings":"AA0NA,SAAgBA,GAKZ,CACH,SAASC,EAgBR,EAkBC,CAED,OAAOC,CAMR,CACA,SAASC,EAgBR,EAwBC,CAED,OAAOD,CAMR,CACA,SAASE,EAWR,EAuBC,CAED,OAAOF,CAMR,CACA,MAAO,CAAE,YAAW,UAAS,OAAM,CACpC"}
|
|
1
|
+
{"version":3,"file":"operation.mjs","names":["effectOperationFactory","operation","definition","command","query"],"sources":["../../../src/modules/effect/operation.ts"],"sourcesContent":["import type { Effect } from 'effect'\nimport type { ContractSchema, ContractInput, ContractOutput } from '../contracts/contract'\nimport type { ContractDecoderError, ContractDecoderRequirements } from './schema'\nimport type { AuditEntryInput } from '../../components/foundation/client'\n\n/** Ordinary failures are defects; only an explicit Effect supplies a typed error. */\nexport type CallbackError<Value> = Value extends (...arguments_: never[]) => infer Returned\n\t? CallbackError<Returned>\n\t: Value extends Effect.Effect<infer Success, infer Error, unknown>\n\t\t? Error | CallbackError<Success>\n\t\t: Value extends PromiseLike<infer Awaited>\n\t\t\t? CallbackError<Awaited>\n\t\t\t: Value extends readonly (infer Item)[]\n\t\t\t\t? CallbackError<Item>\n\t\t\t\t: Value extends { kind: 'execute'; complete?: infer Complete }\n\t\t\t\t\t? CallbackError<Complete>\n\t\t\t\t\t: never\n\nexport type CallbackRequirements<Value> = Value extends (...arguments_: never[]) => infer Returned\n\t? CallbackRequirements<Returned>\n\t: Value extends Effect.Effect<infer Success, unknown, infer Requirements>\n\t\t? Requirements | CallbackRequirements<Success>\n\t\t: Value extends PromiseLike<infer Awaited>\n\t\t\t? CallbackRequirements<Awaited>\n\t\t\t: Value extends readonly (infer Item)[]\n\t\t\t\t? CallbackRequirements<Item>\n\t\t\t\t: Value extends { kind: 'execute'; complete?: infer Complete }\n\t\t\t\t\t? CallbackRequirements<Complete>\n\t\t\t\t\t: never\n\nexport type EffectValue<Value> =\n\tValue extends Effect.Effect<infer Success, unknown, unknown>\n\t\t? EffectValue<Success>\n\t\t: Value extends PromiseLike<infer Awaited>\n\t\t\t? EffectValue<Awaited>\n\t\t\t: Value\n\ndeclare const checkedOperation: unique symbol\n/** Type-only evidence that the helper checked callbacks against the base context and schemas. */\nexport type CheckedEffectOperation<Context> = {\n\treadonly [checkedOperation]: {\n\t\tcontext: (context: Context) => void\n\t\terror: unknown\n\t\trequirements: unknown\n\t\tdefinition: unknown\n\t}\n}\ntype CheckedChannels<Context, Error, Requirements, Definition> = {\n\treadonly [checkedOperation]: {\n\t\tcontext: (context: Context) => void\n\t\terror: Error\n\t\trequirements: Requirements\n\t\tdefinition: Definition\n\t}\n}\n/** Named checked-definition boundary keeps the private evidence marker inside this module's declarations. */\nexport type CheckedEffectDefinition<\n\tContext,\n\tDefinition,\n\tError = never,\n\tRequirements = never,\n> = NoInfer<Omit<Definition, typeof checkedOperation>> &\n\tCheckedChannels<Context, Error, Requirements, Omit<Definition, typeof checkedOperation>>\n/** Reject stale helper evidence after callbacks or schemas are replaced. */\nexport type ValidatedEffectOperations<Operations> = {\n\t[Key in keyof Operations]: Operations[Key] extends {\n\t\treadonly [checkedOperation]: { definition: infer Definition }\n\t}\n\t\t? Operations[Key] extends Definition\n\t\t\t? Operations[Key]\n\t\t\t: never\n\t\t: never\n}\n/** Only middleware whose next contract captured a default policy can discharge its channels. */\nexport type UnwrappedDefaultError<Definition, Guard> = Definition extends { middleware: Function }\n\t? Definition extends CheckedChannels<never, infer Error, unknown, unknown>\n\t\t? Exclude<CallbackError<Guard>, Error>\n\t\t: CallbackError<Guard>\n\t: CallbackError<Guard>\nexport type UnwrappedDefaultRequirements<Definition, Guard> = Definition extends {\n\tmiddleware: Function\n}\n\t? Definition extends CheckedChannels<never, unknown, infer Requirements, unknown>\n\t\t? Exclude<CallbackRequirements<Guard>, Requirements>\n\t\t: CallbackRequirements<Guard>\n\t: CallbackRequirements<Guard>\nexport type EffectOperationArgument<Definition extends { input: ContractSchema }> = ContractInput<\n\tDefinition['input']\n>\nexport type EffectOperationInput<Definition extends { input: ContractSchema }> = ContractOutput<\n\tDefinition['input']\n>\nexport type EffectOperationHandlerResult<Definition extends { result: ContractSchema }> =\n\tContractInput<Definition['result']>\nexport type EffectOperationResult<Definition extends { result: ContractSchema }> = ContractOutput<\n\tDefinition['result']\n>\n\ntype Hook<Definition, Key extends PropertyKey> = Key extends keyof Definition\n\t? Definition[Key]\n\t: never\ntype Returned<Callback> = Callback extends (...arguments_: never[]) => infer Value ? Value : never\n/** A conditional wrapper must retain the unwrapped channels for its absent branch. */\ntype CoreValue<Definition> = [Returned<Hook<Definition, 'middleware'>>] extends [never]\n\t? Returned<Hook<Definition, 'handler'>> | Returned<Hook<Definition, 'guard'>>\n\t: undefined extends Hook<Definition, 'middleware'>\n\t\t?\n\t\t\t\t| Returned<Hook<Definition, 'handler'>>\n\t\t\t\t| Returned<Hook<Definition, 'guard'>>\n\t\t\t\t| Returned<Hook<Definition, 'middleware'>>\n\t\t: Returned<Hook<Definition, 'middleware'>>\ntype OutsideHooks = 'prepare' | 'audit' | 'checkPermission' | 'writeAudit'\nexport type EffectOperationError<Definition> =\n\t| ContractDecoderError<Hook<Definition, 'input'>>\n\t| ContractDecoderError<Hook<Definition, 'result'>>\n\t| ContractDecoderError<Hook<Definition, 'replayResult'>>\n\t| CallbackError<CoreValue<Definition>>\n\t| CallbackError<Definition[Extract<keyof Definition, OutsideHooks>]>\nexport type EffectOperationRequirements<Definition> =\n\t| ContractDecoderRequirements<Hook<Definition, 'input'>>\n\t| ContractDecoderRequirements<Hook<Definition, 'result'>>\n\t| ContractDecoderRequirements<Hook<Definition, 'replayResult'>>\n\t| CallbackRequirements<CoreValue<Definition>>\n\t| CallbackRequirements<Definition[Extract<keyof Definition, OutsideHooks>]>\n\ntype Supported<Value, Error = unknown, Requirements = unknown> =\n\t| Value\n\t| PromiseLike<Value>\n\t| Effect.Effect<Value, Error, Requirements>\nexport type EffectPreparation<Result, Error = never, Requirements = never> =\n\t| { kind: 'replay'; result: unknown }\n\t| { kind: 'execute'; complete?: (result: Result) => Supported<void, Error, Requirements> }\nexport type EffectMiddlewareInput<\n\tContext,\n\tInput,\n\tResult,\n\tExtension,\n\tError = never,\n\tRequirements = never,\n> = {\n\toperation: string\n\tcontext: Context\n\tcommand: Input\n\tinput: Input\n\tnext: keyof Extension extends never\n\t\t? (options?: { context?: Extension }) => Effect.Effect<Result, Error, Requirements>\n\t\t: (options: { context: Extension }) => Effect.Effect<Result, Error, Requirements>\n}\ntype Audit<Aggregates extends readonly string[]> = Omit<\n\tAuditEntryInput,\n\t'classification' | 'aggregate'\n> & {\n\taggregate: { type: Aggregates[number]; id: string }\n}\nexport type OperationDefinition<\n\tContext,\n\tInput extends ContractSchema,\n\tOutput extends ContractSchema,\n\tExtension,\n\tAggregates extends readonly string[],\n\tHandler,\n\tGuard,\n\tPreparation,\n\tAuditResult,\n\tMiddleware,\n\tMetadata,\n\tBaseError,\n\tBaseRequirements,\n\tWire extends ContractSchema,\n\tReplay extends ContractSchema,\n> = {\n\tinput: Input\n\tresult: Output\n\thandler: (input: ContractOutput<Input>, context: Context & Extension) => Handler\n\tclassification?: string\n\tpermission?: string\n\tmetadata?: Metadata\n\taggregates?: Aggregates\n\treplayResult?: Replay & (ContractOutput<Replay> extends ContractOutput<Output> ? unknown : never)\n\twire?: { schema: Wire; project: (value: ContractOutput<Output>) => ContractInput<Wire> }\n\tguard?: (context: Context & Extension, input: ContractOutput<Input>) => Guard\n\tprepare?: (context: Context, input: ContractOutput<Input>) => Preparation\n\taudit?: (\n\t\tresolution: { command: ContractOutput<Input>; result: ContractOutput<Output> },\n\t\tcontext: Context,\n\t) => AuditResult\n} & (keyof Extension extends never\n\t? {\n\t\t\tmiddleware?: (\n\t\t\t\tinput: EffectMiddlewareInput<\n\t\t\t\t\tContext,\n\t\t\t\t\tContractOutput<Input>,\n\t\t\t\t\tContractInput<Output>,\n\t\t\t\t\tExtension,\n\t\t\t\t\tBaseError | CallbackError<Handler | Guard>,\n\t\t\t\t\tBaseRequirements | CallbackRequirements<Handler | Guard>\n\t\t\t\t>,\n\t\t\t) => Middleware\n\t\t}\n\t: {\n\t\t\tmiddleware: (\n\t\t\t\tinput: EffectMiddlewareInput<\n\t\t\t\t\tContext,\n\t\t\t\t\tContractOutput<Input>,\n\t\t\t\t\tContractInput<Output>,\n\t\t\t\t\tExtension,\n\t\t\t\t\tBaseError | CallbackError<Handler | Guard>,\n\t\t\t\t\tBaseRequirements | CallbackRequirements<Handler | Guard>\n\t\t\t\t>,\n\t\t\t) => Middleware\n\t\t})\n\n/**\n * Bind context once; middleware wraps the handler/guard channels and may discharge them.\n * Declare contextual guards/handlers before middleware, or annotate their parameters\n * and returned Effect channels when middleware comes first. TypeScript processes\n * context-sensitive object callbacks in declaration order.\n */\nexport function effectOperationFactory<\n\tContext,\n\tExtension extends Record<string, unknown> = Record<never, never>,\n\tBaseError = never,\n\tBaseRequirements = never,\n\tAuditRequired extends boolean = true,\n>() {\n\tfunction operation<\n\t\tconst Input extends ContractSchema,\n\t\tconst Output extends ContractSchema,\n\t\tHandler extends Supported<ContractInput<Output>>,\n\t\tGuard extends Supported<void> = never,\n\t\tPreparation extends Supported<EffectPreparation<ContractOutput<Output>, unknown, unknown>> =\n\t\t\tnever,\n\t\tconst Aggregates extends readonly string[] = readonly string[],\n\t\tAuditResult extends Supported<Audit<Aggregates> | null> = never,\n\t\tMiddleware extends Supported<ContractInput<Output>> = never,\n\t\tconst Metadata extends object = Record<never, never>,\n\t\t// Retain whether middleware is guaranteed, conditional, or omitted.\n\t\tconst Wire extends ContractSchema = ContractSchema,\n\t\tconst Replay extends ContractSchema = never,\n\t\tconst Definition extends object = object,\n\t>(\n\t\tdefinition: Definition &\n\t\t\tOperationDefinition<\n\t\t\t\tContext,\n\t\t\t\tInput,\n\t\t\t\tOutput,\n\t\t\t\tExtension,\n\t\t\t\tAggregates,\n\t\t\t\tHandler,\n\t\t\t\tGuard,\n\t\t\t\tPreparation,\n\t\t\t\tAuditResult,\n\t\t\t\tMiddleware,\n\t\t\t\tMetadata,\n\t\t\t\tBaseError,\n\t\t\t\tBaseRequirements,\n\t\t\t\tWire,\n\t\t\t\tReplay\n\t\t\t>,\n\t) {\n\t\t// SAFETY: the marker is type-only proof of the helper's checked callback contract.\n\t\treturn definition as CheckedEffectDefinition<\n\t\t\tContext,\n\t\t\ttypeof definition,\n\t\t\tBaseError,\n\t\t\tBaseRequirements\n\t\t>\n\t}\n\tfunction command<\n\t\tconst Input extends ContractSchema,\n\t\tconst Output extends ContractSchema,\n\t\tHandler extends Supported<ContractInput<Output>>,\n\t\tGuard extends Supported<void> = never,\n\t\tPreparation extends Supported<EffectPreparation<ContractOutput<Output>, unknown, unknown>> =\n\t\t\tnever,\n\t\tconst Aggregates extends readonly string[] = readonly string[],\n\t\tAuditResult extends Supported<Audit<Aggregates> | null> = never,\n\t\tMiddleware extends Supported<ContractInput<Output>> = never,\n\t\tconst Metadata extends object = Record<never, never>,\n\t\t// Retain whether middleware is guaranteed, conditional, or omitted.\n\t\tconst Wire extends ContractSchema = ContractSchema,\n\t\tconst Replay extends ContractSchema = never,\n\t\tconst Definition extends object = object,\n\t>(\n\t\tdefinition: Definition &\n\t\t\tOperationDefinition<\n\t\t\t\tContext,\n\t\t\t\tInput,\n\t\t\t\tOutput,\n\t\t\t\tExtension,\n\t\t\t\tAggregates,\n\t\t\t\tHandler,\n\t\t\t\tGuard,\n\t\t\t\tPreparation,\n\t\t\t\tAuditResult,\n\t\t\t\tMiddleware,\n\t\t\t\tMetadata,\n\t\t\t\tBaseError,\n\t\t\t\tBaseRequirements,\n\t\t\t\tWire,\n\t\t\t\tReplay\n\t\t\t> & {\n\t\t\t\tclassification: string\n\t\t\t} & (AuditRequired extends true\n\t\t\t\t? {\n\t\t\t\t\t\taudit: (\n\t\t\t\t\t\t\tresolution: { command: ContractOutput<Input>; result: ContractOutput<Output> },\n\t\t\t\t\t\t\tcontext: Context,\n\t\t\t\t\t\t) => AuditResult\n\t\t\t\t\t}\n\t\t\t\t: {}),\n\t) {\n\t\t// SAFETY: the marker is type-only proof of the helper's checked callback contract.\n\t\t// oxlint-disable-next-line anti-slop/no-chained-type-assertions -- SAFETY: The private marker is type-only callback evidence, not a runtime field.\n\t\treturn definition as unknown as CheckedEffectDefinition<\n\t\t\tContext,\n\t\t\ttypeof definition,\n\t\t\tBaseError,\n\t\t\tBaseRequirements\n\t\t>\n\t}\n\tfunction query<\n\t\tconst Input extends ContractSchema,\n\t\tconst Output extends ContractSchema,\n\t\tHandler extends Supported<ContractInput<Output>>,\n\t\tGuard extends Supported<void> = never,\n\t\tMiddleware extends Supported<ContractInput<Output>> = never,\n\t\tconst Metadata extends object = Record<never, never>,\n\t\tconst Wire extends ContractSchema = ContractSchema,\n\t\tconst Replay extends ContractSchema = never,\n\t\tconst Definition extends object = object,\n\t>(\n\t\tdefinition: Definition &\n\t\t\tOperationDefinition<\n\t\t\t\tContext,\n\t\t\t\tInput,\n\t\t\t\tOutput,\n\t\t\t\tExtension,\n\t\t\t\treadonly string[],\n\t\t\t\tHandler,\n\t\t\t\tGuard,\n\t\t\t\tnever,\n\t\t\t\tnever,\n\t\t\t\tMiddleware,\n\t\t\t\tMetadata,\n\t\t\t\tBaseError,\n\t\t\t\tBaseRequirements,\n\t\t\t\tWire,\n\t\t\t\tReplay\n\t\t\t> & {\n\t\t\t\tprepare?: never\n\t\t\t\taudit?: never\n\t\t\t\taggregates?: never\n\t\t\t\treplayResult?: never\n\t\t\t},\n\t) {\n\t\t// SAFETY: the marker is type-only proof of the helper's checked callback contract.\n\t\treturn definition as CheckedEffectDefinition<\n\t\t\tContext,\n\t\t\ttypeof definition,\n\t\t\tBaseError,\n\t\t\tBaseRequirements\n\t\t>\n\t}\n\treturn { operation, command, query }\n}\n"],"mappings":"AA0NA,SAAgBA,GAMZ,CACH,SAASC,EAgBR,EAkBC,CAED,OAAOC,CAMR,CACA,SAASC,EAgBR,EA2BC,CAGD,OAAOD,CAMR,CACA,SAASE,EAWR,EAuBC,CAED,OAAOF,CAMR,CACA,MAAO,CAAE,YAAW,UAAS,OAAM,CACpC"}
|