@lssm/lib.contracts 0.0.0-canary-20251220030446 → 0.0.0-canary-20251221114240

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/README.md +4 -4
  2. package/dist/app-config/contracts.d.ts +60 -60
  3. package/dist/app-config/contracts.js +1 -1
  4. package/dist/app-config/events.d.ts +27 -27
  5. package/dist/app-config/lifecycle-contracts.d.ts +10 -10
  6. package/dist/app-config/lifecycle-contracts.js +1 -1
  7. package/dist/docs/tech/contracts/README.docblock.js +2 -2
  8. package/dist/docs/tech/contracts/openapi-export.docblock.js +6 -6
  9. package/dist/docs/tech/contracts/ops-to-presentation-linking.docblock.js +2 -2
  10. package/dist/docs/tech/contracts/tests.docblock.js +2 -2
  11. package/dist/experiments/spec-resolver.d.ts +2 -2
  12. package/dist/features.d.ts +5 -5
  13. package/dist/index.d.ts +6 -4
  14. package/dist/index.js +5 -3
  15. package/dist/install.d.ts +16 -16
  16. package/dist/integrations/contracts.d.ts +9 -9
  17. package/dist/integrations/contracts.js +1 -1
  18. package/dist/integrations/openbanking/contracts/accounts.d.ts +73 -73
  19. package/dist/integrations/openbanking/contracts/accounts.js +1 -1
  20. package/dist/integrations/openbanking/contracts/balances.d.ts +40 -40
  21. package/dist/integrations/openbanking/contracts/balances.js +1 -1
  22. package/dist/integrations/openbanking/contracts/index.d.ts +2 -2
  23. package/dist/integrations/openbanking/contracts/transactions.d.ts +54 -54
  24. package/dist/integrations/openbanking/contracts/transactions.js +1 -1
  25. package/dist/jsonschema.d.ts +5 -5
  26. package/dist/knowledge/contracts.d.ts +9 -9
  27. package/dist/knowledge/contracts.js +1 -1
  28. package/dist/llm/exporters.d.ts +8 -8
  29. package/dist/llm/exporters.js +1 -1
  30. package/dist/llm/prompts.d.ts +7 -7
  31. package/dist/llm/types.d.ts +3 -3
  32. package/dist/markdown.d.ts +3 -3
  33. package/dist/markdown.js +1 -1
  34. package/dist/onboarding-base.d.ts +32 -32
  35. package/dist/onboarding-base.js +1 -1
  36. package/dist/openapi.d.ts +2 -2
  37. package/dist/{spec.d.ts → operation.d.ts} +12 -12
  38. package/dist/{spec.js → operation.js} +1 -1
  39. package/dist/policy/docs/policy.docblock.js +1 -1
  40. package/dist/presentations.d.ts +3 -3
  41. package/dist/registry.d.ts +13 -14
  42. package/dist/registry.js +5 -5
  43. package/dist/server/graphql-pothos.d.ts +6 -6
  44. package/dist/server/graphql-pothos.js +4 -4
  45. package/dist/server/mcp/createMcpServer.d.ts +3 -3
  46. package/dist/server/mcp/createMcpServer.js +1 -1
  47. package/dist/server/mcp/registerTools.d.ts +2 -2
  48. package/dist/server/rest-elysia.d.ts +2 -2
  49. package/dist/server/rest-express.d.ts +2 -2
  50. package/dist/server/rest-generic.d.ts +3 -3
  51. package/dist/server/rest-generic.js +1 -1
  52. package/dist/server/rest-next-app.d.ts +4 -4
  53. package/dist/server/rest-next-app.js +2 -2
  54. package/dist/server/rest-next-mcp.d.ts +2 -2
  55. package/dist/server/rest-next-pages.d.ts +2 -2
  56. package/dist/telemetry/docs/telemetry.docblock.js +1 -1
  57. package/dist/tests/runner.d.ts +2 -2
  58. package/dist/types/all.d.ts +2 -2
  59. package/dist/workflow/validation.d.ts +2 -2
  60. package/dist/workspace-config/contractsrc-schema.d.ts +188 -0
  61. package/dist/workspace-config/contractsrc-schema.js +114 -0
  62. package/dist/workspace-config/index.d.ts +2 -0
  63. package/dist/workspace-config/index.js +3 -0
  64. package/package.json +13 -11
@@ -1,135 +1,135 @@
1
- import { ContractSpec } from "./spec.js";
2
- import * as _lssm_lib_schema289 from "@lssm/lib.schema";
1
+ import { OperationSpec } from "./operation.js";
2
+ import * as _lssm_lib_schema61 from "@lssm/lib.schema";
3
3
  import { SchemaModel } from "@lssm/lib.schema";
4
4
 
5
5
  //#region src/onboarding-base.d.ts
6
6
  /** Save/update onboarding draft (auto-save during flow) */
7
7
  declare const SaveOnboardingDraftInput: SchemaModel<{
8
8
  data: {
9
- type: _lssm_lib_schema289.FieldType<unknown, unknown>;
9
+ type: _lssm_lib_schema61.FieldType<unknown, unknown>;
10
10
  isOptional: false;
11
11
  };
12
12
  }>;
13
13
  declare const SaveOnboardingDraftOutput: SchemaModel<{
14
14
  id: {
15
- type: _lssm_lib_schema289.FieldType<string, string>;
15
+ type: _lssm_lib_schema61.FieldType<string, string>;
16
16
  isOptional: false;
17
17
  };
18
18
  organizationId: {
19
- type: _lssm_lib_schema289.FieldType<string, string>;
19
+ type: _lssm_lib_schema61.FieldType<string, string>;
20
20
  isOptional: false;
21
21
  };
22
22
  }>;
23
- declare const SaveOnboardingDraftBaseSpec: ContractSpec<SchemaModel<{
23
+ declare const SaveOnboardingDraftBaseSpec: OperationSpec<SchemaModel<{
24
24
  data: {
25
- type: _lssm_lib_schema289.FieldType<unknown, unknown>;
25
+ type: _lssm_lib_schema61.FieldType<unknown, unknown>;
26
26
  isOptional: false;
27
27
  };
28
28
  }>, SchemaModel<{
29
29
  id: {
30
- type: _lssm_lib_schema289.FieldType<string, string>;
30
+ type: _lssm_lib_schema61.FieldType<string, string>;
31
31
  isOptional: false;
32
32
  };
33
33
  organizationId: {
34
- type: _lssm_lib_schema289.FieldType<string, string>;
34
+ type: _lssm_lib_schema61.FieldType<string, string>;
35
35
  isOptional: false;
36
36
  };
37
37
  }>, undefined>;
38
38
  /** Get current onboarding draft (on mount/restore) */
39
39
  declare const GetOnboardingDraftOutput: SchemaModel<{
40
40
  id: {
41
- type: _lssm_lib_schema289.FieldType<string, string>;
41
+ type: _lssm_lib_schema61.FieldType<string, string>;
42
42
  isOptional: true;
43
43
  };
44
44
  organizationId: {
45
- type: _lssm_lib_schema289.FieldType<string, string>;
45
+ type: _lssm_lib_schema61.FieldType<string, string>;
46
46
  isOptional: true;
47
47
  };
48
48
  data: {
49
- type: _lssm_lib_schema289.FieldType<unknown, unknown>;
49
+ type: _lssm_lib_schema61.FieldType<unknown, unknown>;
50
50
  isOptional: true;
51
51
  };
52
52
  createdAt: {
53
- type: _lssm_lib_schema289.FieldType<Date, string>;
53
+ type: _lssm_lib_schema61.FieldType<Date, string>;
54
54
  isOptional: true;
55
55
  };
56
56
  updatedAt: {
57
- type: _lssm_lib_schema289.FieldType<Date, string>;
57
+ type: _lssm_lib_schema61.FieldType<Date, string>;
58
58
  isOptional: true;
59
59
  };
60
60
  }>;
61
- declare const GetOnboardingDraftBaseSpec: ContractSpec<_lssm_lib_schema289.AnySchemaModel, SchemaModel<{
61
+ declare const GetOnboardingDraftBaseSpec: OperationSpec<_lssm_lib_schema61.AnySchemaModel, SchemaModel<{
62
62
  id: {
63
- type: _lssm_lib_schema289.FieldType<string, string>;
63
+ type: _lssm_lib_schema61.FieldType<string, string>;
64
64
  isOptional: true;
65
65
  };
66
66
  organizationId: {
67
- type: _lssm_lib_schema289.FieldType<string, string>;
67
+ type: _lssm_lib_schema61.FieldType<string, string>;
68
68
  isOptional: true;
69
69
  };
70
70
  data: {
71
- type: _lssm_lib_schema289.FieldType<unknown, unknown>;
71
+ type: _lssm_lib_schema61.FieldType<unknown, unknown>;
72
72
  isOptional: true;
73
73
  };
74
74
  createdAt: {
75
- type: _lssm_lib_schema289.FieldType<Date, string>;
75
+ type: _lssm_lib_schema61.FieldType<Date, string>;
76
76
  isOptional: true;
77
77
  };
78
78
  updatedAt: {
79
- type: _lssm_lib_schema289.FieldType<Date, string>;
79
+ type: _lssm_lib_schema61.FieldType<Date, string>;
80
80
  isOptional: true;
81
81
  };
82
82
  }>, undefined>;
83
83
  /** Delete onboarding draft (cleanup after completion or cancel) */
84
84
  declare const DeleteOnboardingDraftOutput: SchemaModel<{
85
85
  ok: {
86
- type: _lssm_lib_schema289.FieldType<boolean, boolean>;
86
+ type: _lssm_lib_schema61.FieldType<boolean, boolean>;
87
87
  isOptional: false;
88
88
  };
89
89
  }>;
90
- declare const DeleteOnboardingDraftBaseSpec: ContractSpec<_lssm_lib_schema289.AnySchemaModel, SchemaModel<{
90
+ declare const DeleteOnboardingDraftBaseSpec: OperationSpec<_lssm_lib_schema61.AnySchemaModel, SchemaModel<{
91
91
  ok: {
92
- type: _lssm_lib_schema289.FieldType<boolean, boolean>;
92
+ type: _lssm_lib_schema61.FieldType<boolean, boolean>;
93
93
  isOptional: false;
94
94
  };
95
95
  }>, undefined>;
96
96
  /** Complete onboarding (final submit, creates entities) */
97
97
  declare const CompleteOnboardingBaseInput: SchemaModel<{
98
98
  data: {
99
- type: _lssm_lib_schema289.FieldType<unknown, unknown>;
99
+ type: _lssm_lib_schema61.FieldType<unknown, unknown>;
100
100
  isOptional: false;
101
101
  };
102
102
  }>;
103
103
  declare const CompleteOnboardingBaseOutput: SchemaModel<{
104
104
  success: {
105
- type: _lssm_lib_schema289.FieldType<boolean, boolean>;
105
+ type: _lssm_lib_schema61.FieldType<boolean, boolean>;
106
106
  isOptional: false;
107
107
  };
108
108
  userId: {
109
- type: _lssm_lib_schema289.FieldType<string, string>;
109
+ type: _lssm_lib_schema61.FieldType<string, string>;
110
110
  isOptional: true;
111
111
  };
112
112
  organizationId: {
113
- type: _lssm_lib_schema289.FieldType<string, string>;
113
+ type: _lssm_lib_schema61.FieldType<string, string>;
114
114
  isOptional: true;
115
115
  };
116
116
  }>;
117
- declare const CompleteOnboardingBaseSpec: ContractSpec<SchemaModel<{
117
+ declare const CompleteOnboardingBaseSpec: OperationSpec<SchemaModel<{
118
118
  data: {
119
- type: _lssm_lib_schema289.FieldType<unknown, unknown>;
119
+ type: _lssm_lib_schema61.FieldType<unknown, unknown>;
120
120
  isOptional: false;
121
121
  };
122
122
  }>, SchemaModel<{
123
123
  success: {
124
- type: _lssm_lib_schema289.FieldType<boolean, boolean>;
124
+ type: _lssm_lib_schema61.FieldType<boolean, boolean>;
125
125
  isOptional: false;
126
126
  };
127
127
  userId: {
128
- type: _lssm_lib_schema289.FieldType<string, string>;
128
+ type: _lssm_lib_schema61.FieldType<string, string>;
129
129
  isOptional: true;
130
130
  };
131
131
  organizationId: {
132
- type: _lssm_lib_schema289.FieldType<string, string>;
132
+ type: _lssm_lib_schema61.FieldType<string, string>;
133
133
  isOptional: true;
134
134
  };
135
135
  }>, undefined>;
@@ -1,5 +1,5 @@
1
1
  import { E5, x8 } from "./schema/dist/index.js";
2
- import { defineCommand, defineQuery } from "./spec.js";
2
+ import { defineCommand, defineQuery } from "./operation.js";
3
3
  import { OwnersEnum, StabilityEnum } from "./ownership.js";
4
4
 
5
5
  //#region src/onboarding-base.ts
package/dist/openapi.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { SpecRegistry } from "./registry.js";
1
+ import { OperationSpecRegistry } from "./registry.js";
2
2
 
3
3
  //#region src/openapi.d.ts
4
4
 
@@ -26,6 +26,6 @@ interface OpenApiDocument {
26
26
  schemas: Record<string, OpenApiSchemaObject>;
27
27
  };
28
28
  }
29
- declare function openApiForRegistry(registry: SpecRegistry, options?: OpenApiExportOptions): OpenApiDocument;
29
+ declare function openApiForRegistry(registry: OperationSpecRegistry, options?: OpenApiExportOptions): OpenApiDocument;
30
30
  //#endregion
31
31
  export { OpenApiDocument, OpenApiExportOptions, OpenApiServer, openApiForRegistry };
@@ -6,7 +6,7 @@ import { PolicyRef } from "./policy/spec.js";
6
6
  import { TestSpecRef } from "./tests/spec.js";
7
7
  import { AnySchemaModel } from "@lssm/lib.schema";
8
8
 
9
- //#region src/spec.d.ts
9
+ //#region src/operation.d.ts
10
10
 
11
11
  /**
12
12
  * Distinguishes between state-changing operations (command) and read-only operations (query).
@@ -62,7 +62,7 @@ interface TelemetryTrigger {
62
62
  * @template Output - The Zod-backed schema model for the output payload, or a resource reference.
63
63
  * @template Events - Tuple of events that this operation may emit.
64
64
  */
65
- interface ContractSpec<Input extends AnySchemaModel, Output extends AnySchemaModel | ResourceRefDescriptor<boolean>, Events extends readonly EmitDecl[] | undefined = readonly EmitDecl[] | undefined> {
65
+ interface OperationSpec<Input extends AnySchemaModel, Output extends AnySchemaModel | ResourceRefDescriptor<boolean>, Events extends readonly EmitDecl[] | undefined = readonly EmitDecl[] | undefined> {
66
66
  meta: {
67
67
  /** Fully-qualified op name (e.g., "sigil.beginSignup") */
68
68
  name: string;
@@ -174,22 +174,22 @@ interface ContractSpec<Input extends AnySchemaModel, Output extends AnySchemaMod
174
174
  */
175
175
  implementations?: ImplementationRef[];
176
176
  }
177
- type AnyContractSpec = ContractSpec<AnySchemaModel, AnySchemaModel | ResourceRefDescriptor<boolean>>;
177
+ type AnyOperationSpec = OperationSpec<AnySchemaModel, AnySchemaModel | ResourceRefDescriptor<boolean>>;
178
178
  /**
179
179
  * Helper to define a Command (write operation).
180
180
  * Sets `kind: 'command'` and defaults `idempotent: false`.
181
181
  */
182
- declare const defineCommand: <I extends AnySchemaModel, O extends AnySchemaModel | ResourceRefDescriptor<boolean>, E extends readonly EmitDecl[] | undefined = undefined>(spec: Omit<ContractSpec<I, O, E>, "meta" | "policy"> & {
183
- meta: Omit<ContractSpec<I, O, E>["meta"], "kind">;
184
- policy: Omit<ContractSpec<I, O, E>["policy"], "idempotent">;
185
- }) => ContractSpec<I, O, E>;
182
+ declare const defineCommand: <I extends AnySchemaModel, O extends AnySchemaModel | ResourceRefDescriptor<boolean>, E extends readonly EmitDecl[] | undefined = undefined>(spec: Omit<OperationSpec<I, O, E>, "meta" | "policy"> & {
183
+ meta: Omit<OperationSpec<I, O, E>["meta"], "kind">;
184
+ policy: Omit<OperationSpec<I, O, E>["policy"], "idempotent">;
185
+ }) => OperationSpec<I, O, E>;
186
186
  /**
187
187
  * Helper to define a Query (read-only operation).
188
188
  * Sets `kind: 'query'` and forces `idempotent: true`.
189
189
  */
190
- declare const defineQuery: <I extends AnySchemaModel, O extends AnySchemaModel | ResourceRefDescriptor<boolean>, E extends readonly EmitDecl[] | undefined = undefined>(spec: Omit<ContractSpec<I, O, E>, "meta" | "policy"> & {
191
- meta: Omit<ContractSpec<I, O, E>["meta"], "kind">;
192
- policy: Omit<ContractSpec<I, O, E>["policy"], "idempotent">;
193
- }) => ContractSpec<I, O, E>;
190
+ declare const defineQuery: <I extends AnySchemaModel, O extends AnySchemaModel | ResourceRefDescriptor<boolean>, E extends readonly EmitDecl[] | undefined = undefined>(spec: Omit<OperationSpec<I, O, E>, "meta" | "policy"> & {
191
+ meta: Omit<OperationSpec<I, O, E>["meta"], "kind">;
192
+ policy: Omit<OperationSpec<I, O, E>["policy"], "idempotent">;
193
+ }) => OperationSpec<I, O, E>;
194
194
  //#endregion
195
- export { AnyContractSpec, ContractSpec, EmitDecl, EmitDeclInline, EmitDeclRef, ImplementationRef, ImplementationType, OpKind, TelemetryTrigger, defineCommand, defineQuery, isEmitDeclRef };
195
+ export { AnyOperationSpec, EmitDecl, EmitDeclInline, EmitDeclRef, ImplementationRef, ImplementationType, OpKind, OperationSpec, TelemetryTrigger, defineCommand, defineQuery, isEmitDeclRef };
@@ -1,4 +1,4 @@
1
- //#region src/spec.ts
1
+ //#region src/operation.ts
2
2
  const isEmitDeclRef = (e) => "ref" in e;
3
3
  /**
4
4
  * Helper to define a Command (write operation).
@@ -14,7 +14,7 @@ const tech_contracts_policy_DocBlocks = [{
14
14
  "contracts",
15
15
  "policy"
16
16
  ],
17
- body: "# PolicySpec & PolicyEngine\n\n## Purpose\n\n`PolicySpec` gives a declarative, typed home for access-control logic covering:\n- **Who** can perform an action (ABAC/ReBAC style rules)\n- **What** they can access (resources + optional field-level overrides)\n- **When** special conditions apply (contextual expressions)\n- **How** PII should be handled (consent/retention hints)\n\n`PolicyEngine` evaluates one or more policies and returns an `allow`/`deny` decision, field-level outcomes, and PII metadata suitable for downstream enforcement (`SpecRegistry` → `ctx.decide`).\n\n## Location\n\n- Types & registry: `packages/libs/contracts/src/policy/spec.ts`\n- Runtime evaluation: `packages/libs/contracts/src/policy/engine.ts`\n- Tests: `packages/.../policy/engine.test.ts`\n\n## `PolicySpec`\n\n```ts\nexport interface PolicySpec {\n meta: PolicyMeta; // ownership metadata + { name, version, scope? }\n rules: PolicyRule[]; // allow/deny rules for actions\n fieldPolicies?: FieldPolicyRule[];\n pii?: { fields: string[]; consentRequired?: boolean; retentionDays?: number };\n relationships?: RelationshipDefinition[];\n consents?: ConsentDefinition[];\n rateLimits?: RateLimitDefinition[];\n opa?: { package: string; decision?: string };\n}\n```\n\n- `PolicyRule`\n - `effect`: `'allow' | 'deny'`\n - `actions`: e.g., `['read', 'write', 'delete']` (string namespace is flexible)\n - `subject`: `{ roles?: string[]; attributes?: { attr: matcher } }`\n - `resource`: `{ type: string; fields?: string[]; attributes?: {...} }`\n - `relationships`: `{ relation, objectId?, objectType? }[]` → ReBAC checks (use `objectId: '$resource'` to target the current resource)\n - `requiresConsent`: `['consent_id']` → references spec-level consent definitions\n - `flags`: feature flags that must be enabled (`DecisionContext.flags`)\n - `rateLimit`: string reference to `rateLimits` entry or inline object `{ rpm, key?, windowSeconds?, burst? }`\n - `escalate`: `'human_review' | null` to indicate manual approval\n - `conditions`: optional expression snippets evaluated against `{ subject, resource, context }`\n- `FieldPolicyRule`\n - `field`: dot-path string (e.g., `contact.email`)\n - `actions`: subset of `['read', 'write']`\n - Same `subject` / `resource` / `conditions` shape\n - Useful for redacting specific fields, even when the global action is allowed\n- `RelationshipDefinition`\n - Canonical tuples for relationship graph (`subjectType`, `relation`, `objectType`, `transitive?`)\n- `ConsentDefinition`\n - `{ id, scope, purpose, lawfulBasis?, expiresInDays?, required? }`\n- `RateLimitDefinition`\n - `{ id, rpm, key?, windowSeconds?, burst? }`\n- `PolicyRef`\n - `{ name: string; version: number }` → attach to contract specs / workflows\n\n## Registry\n\n```ts\nconst registry = new PolicyRegistry();\nregistry.register(CorePolicySpec);\nconst spec = registry.get('core.default', 1);\n```\n\nGuarantees uniqueness per `(name, version)` and exposes helpers to resolve highest versions.\n\n## Engine\n\n```ts\nconst engine = new PolicyEngine(policyRegistry);\n\nconst decision = engine.decide({\n action: 'read',\n subject: { roles: ['admin'] },\n resource: { type: 'resident', fields: ['contact.email'] },\n policies: [{ name: 'core.default', version: 1 }],\n});\n/*\n{\n effect: 'allow',\n reason: 'core.default',\n fieldDecisions: [{ field: 'contact.email', effect: 'allow' }],\n pii: { fields: ['contact.email'], consentRequired: true }\n}\n*/\n```\n\n- First matching **deny** wins; otherwise the first **allow** is returned.\n- Field policies are aggregated across referenced policies:\n - Later denies override earlier allows for a given field.\n - Returned as `fieldDecisions` to simplify downstream masking.\n- PII metadata is surfaced when defined to help adapt logging/telemetry.\n\n### Expression Support\n\nConditions accept small JS snippets (e.g., `subject.attributes.orgId === context.orgId`). The engine runs them in a constrained scope (`subject`, `resource`, `context`) without access to global state.\n\n### ReBAC & Relationships\n\n- Provide relationship tuples via `PolicySpec.relationships` for documentation/validation.\n- Reference them inside rules with `relationships: [{ relation: 'manager_of', objectType: 'resident', objectId: '$resource' }]`.\n- The execution context must populate `subject.relationships` (`[{ relation, object, objectType }]`) for the engine to evaluate ReBAC guards.\n\n### Consent & Rate Limits\n\n- Declare reusable consent definitions under `consents`. Rules list the IDs they require; if a user session lacks the consent (`DecisionContext.consents`), the engine returns `effect: 'deny'` with `reason: 'consent_required'` and enumerates missing consents.\n- Attach rate limits either inline or via `rateLimits` references. When a rule matches, the engine surfaces `{ rpm, key, windowSeconds?, burst? }` so callers can feed it to shared limiters.\n\n### OPA Adapter\n\n- `OPAPolicyAdapter` bridges engine decisions to Open Policy Agent (OPA). It forwards the evaluation context + policies to OPA and merges any override result (`effect`, `reason`, `fieldDecisions`, `requiredConsents`).\n- Use when migrating to OPA policies or running defense-in-depth: call `engine.decide()`, then pass the preliminary decision to `adapter.evaluate(...)`. The adapter marks merged decisions with `evaluatedBy: 'opa'`.\n- OPA inputs include meta, rules, relationships, rate limits, and consent catalogs to simplify policy authoring on the OPA side.\n\n## Contract Integration\n\n`ContractSpec.policy` now supports:\n\n```ts\npolicy: {\n auth: 'anonymous' | 'user' | 'admin';\n ...\n policies?: PolicyRef[]; // policies evaluated before execution\n fieldPolicies?: { // field hints (read/write) per policy\n field: string;\n actions: ('read' | 'write')[];\n policy?: PolicyRef;\n }[];\n}\n```\n\nAdapters can resolve refs through a shared `PolicyEngine` and populate `ctx.decide` so `SpecRegistry.execute` benefits from centralized enforcement.\n\n## Authoring Guidelines\n\n1. Prefer **allow-by-default** policies but explicitly deny sensitive flows (defense-in-depth).\n2. Keep rule scopes narrow (per feature/operation) and compose multiple `PolicyRef`s when necessary.\n3. Store PII field lists here to avoid duplication across logs/telemetry.\n4. Use explicit rule reasons for auditability and better developer feedback.\n5. Treat versioning seriously; bump `meta.version` whenever behavior changes.\n\n## Future Enhancements\n\n- Richer expression language (composable predicates, time-based conditions).\n- Multi-tenant relationship graph services (store/resolve relationships at scale).\n- Tooling that auto-generates docs/tests for policies referenced in specs.\n\n"
17
+ body: "# PolicySpec & PolicyEngine\n\n## Purpose\n\n`PolicySpec` gives a declarative, typed home for access-control logic covering:\n- **Who** can perform an action (ABAC/ReBAC style rules)\n- **What** they can access (resources + optional field-level overrides)\n- **When** special conditions apply (contextual expressions)\n- **How** PII should be handled (consent/retention hints)\n\n`PolicyEngine` evaluates one or more policies and returns an `allow`/`deny` decision, field-level outcomes, and PII metadata suitable for downstream enforcement (`OperationSpecRegistry` → `ctx.decide`).\n\n## Location\n\n- Types & registry: `packages/libs/contracts/src/policy/spec.ts`\n- Runtime evaluation: `packages/libs/contracts/src/policy/engine.ts`\n- Tests: `packages/.../policy/engine.test.ts`\n\n## `PolicySpec`\n\n```ts\nexport interface PolicySpec {\n meta: PolicyMeta; // ownership metadata + { name, version, scope? }\n rules: PolicyRule[]; // allow/deny rules for actions\n fieldPolicies?: FieldPolicyRule[];\n pii?: { fields: string[]; consentRequired?: boolean; retentionDays?: number };\n relationships?: RelationshipDefinition[];\n consents?: ConsentDefinition[];\n rateLimits?: RateLimitDefinition[];\n opa?: { package: string; decision?: string };\n}\n```\n\n- `PolicyRule`\n - `effect`: `'allow' | 'deny'`\n - `actions`: e.g., `['read', 'write', 'delete']` (string namespace is flexible)\n - `subject`: `{ roles?: string[]; attributes?: { attr: matcher } }`\n - `resource`: `{ type: string; fields?: string[]; attributes?: {...} }`\n - `relationships`: `{ relation, objectId?, objectType? }[]` → ReBAC checks (use `objectId: '$resource'` to target the current resource)\n - `requiresConsent`: `['consent_id']` → references spec-level consent definitions\n - `flags`: feature flags that must be enabled (`DecisionContext.flags`)\n - `rateLimit`: string reference to `rateLimits` entry or inline object `{ rpm, key?, windowSeconds?, burst? }`\n - `escalate`: `'human_review' | null` to indicate manual approval\n - `conditions`: optional expression snippets evaluated against `{ subject, resource, context }`\n- `FieldPolicyRule`\n - `field`: dot-path string (e.g., `contact.email`)\n - `actions`: subset of `['read', 'write']`\n - Same `subject` / `resource` / `conditions` shape\n - Useful for redacting specific fields, even when the global action is allowed\n- `RelationshipDefinition`\n - Canonical tuples for relationship graph (`subjectType`, `relation`, `objectType`, `transitive?`)\n- `ConsentDefinition`\n - `{ id, scope, purpose, lawfulBasis?, expiresInDays?, required? }`\n- `RateLimitDefinition`\n - `{ id, rpm, key?, windowSeconds?, burst? }`\n- `PolicyRef`\n - `{ name: string; version: number }` → attach to contract specs / workflows\n\n## Registry\n\n```ts\nconst registry = new PolicyRegistry();\nregistry.register(CorePolicySpec);\nconst spec = registry.get('core.default', 1);\n```\n\nGuarantees uniqueness per `(name, version)` and exposes helpers to resolve highest versions.\n\n## Engine\n\n```ts\nconst engine = new PolicyEngine(policyRegistry);\n\nconst decision = engine.decide({\n action: 'read',\n subject: { roles: ['admin'] },\n resource: { type: 'resident', fields: ['contact.email'] },\n policies: [{ name: 'core.default', version: 1 }],\n});\n/*\n{\n effect: 'allow',\n reason: 'core.default',\n fieldDecisions: [{ field: 'contact.email', effect: 'allow' }],\n pii: { fields: ['contact.email'], consentRequired: true }\n}\n*/\n```\n\n- First matching **deny** wins; otherwise the first **allow** is returned.\n- Field policies are aggregated across referenced policies:\n - Later denies override earlier allows for a given field.\n - Returned as `fieldDecisions` to simplify downstream masking.\n- PII metadata is surfaced when defined to help adapt logging/telemetry.\n\n### Expression Support\n\nConditions accept small JS snippets (e.g., `subject.attributes.orgId === context.orgId`). The engine runs them in a constrained scope (`subject`, `resource`, `context`) without access to global state.\n\n### ReBAC & Relationships\n\n- Provide relationship tuples via `PolicySpec.relationships` for documentation/validation.\n- Reference them inside rules with `relationships: [{ relation: 'manager_of', objectType: 'resident', objectId: '$resource' }]`.\n- The execution context must populate `subject.relationships` (`[{ relation, object, objectType }]`) for the engine to evaluate ReBAC guards.\n\n### Consent & Rate Limits\n\n- Declare reusable consent definitions under `consents`. Rules list the IDs they require; if a user session lacks the consent (`DecisionContext.consents`), the engine returns `effect: 'deny'` with `reason: 'consent_required'` and enumerates missing consents.\n- Attach rate limits either inline or via `rateLimits` references. When a rule matches, the engine surfaces `{ rpm, key, windowSeconds?, burst? }` so callers can feed it to shared limiters.\n\n### OPA Adapter\n\n- `OPAPolicyAdapter` bridges engine decisions to Open Policy Agent (OPA). It forwards the evaluation context + policies to OPA and merges any override result (`effect`, `reason`, `fieldDecisions`, `requiredConsents`).\n- Use when migrating to OPA policies or running defense-in-depth: call `engine.decide()`, then pass the preliminary decision to `adapter.evaluate(...)`. The adapter marks merged decisions with `evaluatedBy: 'opa'`.\n- OPA inputs include meta, rules, relationships, rate limits, and consent catalogs to simplify policy authoring on the OPA side.\n\n## Contract Integration\n\n`ContractSpec.policy` now supports:\n\n```ts\npolicy: {\n auth: 'anonymous' | 'user' | 'admin';\n ...\n policies?: PolicyRef[]; // policies evaluated before execution\n fieldPolicies?: { // field hints (read/write) per policy\n field: string;\n actions: ('read' | 'write')[];\n policy?: PolicyRef;\n }[];\n}\n```\n\nAdapters can resolve refs through a shared `PolicyEngine` and populate `ctx.decide` so `OperationSpecRegistry.execute` benefits from centralized enforcement.\n\n## Authoring Guidelines\n\n1. Prefer **allow-by-default** policies but explicitly deny sensitive flows (defense-in-depth).\n2. Keep rule scopes narrow (per feature/operation) and compose multiple `PolicyRef`s when necessary.\n3. Store PII field lists here to avoid duplication across logs/telemetry.\n4. Use explicit rule reasons for auditability and better developer feedback.\n5. Treat versioning seriously; bump `meta.version` whenever behavior changes.\n\n## Future Enhancements\n\n- Richer expression language (composable predicates, time-based conditions).\n- Multi-tenant relationship graph services (store/resolve relationships at scale).\n- Tooling that auto-generates docs/tests for policies referenced in specs.\n\n"
18
18
  }];
19
19
  registerDocBlocks(tech_contracts_policy_DocBlocks);
20
20
 
@@ -1,6 +1,6 @@
1
1
  import { Stability } from "./ownership.js";
2
2
  import z from "zod";
3
- import * as _lssm_lib_schema53 from "@lssm/lib.schema";
3
+ import * as _lssm_lib_schema234 from "@lssm/lib.schema";
4
4
  import { AnySchemaModel } from "@lssm/lib.schema";
5
5
 
6
6
  //#region src/presentations.d.ts
@@ -62,7 +62,7 @@ declare class PresentationRegistry {
62
62
  declare function jsonSchemaForPresentation(p: PresentationSpec): {
63
63
  framework: "react";
64
64
  componentKey: string;
65
- props: z.core.ZodStandardJSONSchemaPayload<_lssm_lib_schema53.TopLevelZodFromModel<_lssm_lib_schema53.SchemaModelFieldsAnyConfig<_lssm_lib_schema53.AnyFieldType | _lssm_lib_schema53.AnyEnumType | AnySchemaModel>>>;
65
+ props: z.core.ZodStandardJSONSchemaPayload<_lssm_lib_schema234.TopLevelZodFromModel<_lssm_lib_schema234.SchemaModelFieldsAnyConfig<AnySchemaModel | _lssm_lib_schema234.AnyFieldType | _lssm_lib_schema234.AnyEnumType>>>;
66
66
  meta: {
67
67
  readonly name: string;
68
68
  readonly version: number;
@@ -84,7 +84,7 @@ declare function jsonSchemaForPresentation(p: PresentationSpec): {
84
84
  kind: PresentationKind;
85
85
  } | {
86
86
  mimeType: string;
87
- model: z.core.ZodStandardJSONSchemaPayload<_lssm_lib_schema53.TopLevelZodFromModel<_lssm_lib_schema53.SchemaModelFieldsAnyConfig<_lssm_lib_schema53.AnyFieldType | _lssm_lib_schema53.AnyEnumType | AnySchemaModel>>>;
87
+ model: z.core.ZodStandardJSONSchemaPayload<_lssm_lib_schema234.TopLevelZodFromModel<_lssm_lib_schema234.SchemaModelFieldsAnyConfig<AnySchemaModel | _lssm_lib_schema234.AnyFieldType | _lssm_lib_schema234.AnyEnumType>>>;
88
88
  meta: {
89
89
  readonly name: string;
90
90
  readonly version: number;
@@ -1,31 +1,30 @@
1
1
  import { defaultDocRegistry, docId, registerDocBlocks } from "./docs/registry.js";
2
2
  import { ResourceRefDescriptor } from "./resources.js";
3
- import { ContractSpec } from "./spec.js";
3
+ import { AnyOperationSpec, OperationSpec } from "./operation.js";
4
4
  import { HandlerCtx } from "./types.js";
5
- import { HandlerFor } from "./install.js";
5
+ import { HandlerForOperationSpec } from "./install.js";
6
6
  import { AnySchemaModel } from "@lssm/lib.schema";
7
7
 
8
8
  //#region src/registry.d.ts
9
9
 
10
10
  type OperationKey = `${string}.v${number}`;
11
11
  declare function opKey(name: string, version: number): OperationKey;
12
- type AnySpec = ContractSpec<AnySchemaModel, AnySchemaModel | ResourceRefDescriptor<boolean>>;
13
- type AnyHandler = (args: unknown, ctx: HandlerCtx) => Promise<unknown>;
12
+ type AnyOperationHandler = (args: unknown, ctx: HandlerCtx) => Promise<unknown>;
14
13
  /**
15
14
  * In-memory registry for ContractSpecs and their bound handlers.
16
15
  * Provides validation, policy enforcement, and guarded event emission at execute time.
17
16
  */
18
- declare class SpecRegistry {
17
+ declare class OperationSpecRegistry {
19
18
  private specs;
20
19
  private handlers;
21
20
  /**
22
- * Registers a ContractSpec definition.
21
+ * Registers a OperationSpec definition.
23
22
  *
24
23
  * @param spec - The contract specification to register.
25
24
  * @returns The registry instance for chaining.
26
25
  * @throws If a spec with the same name and version is already registered.
27
26
  */
28
- register<I extends AnySchemaModel, O extends AnySchemaModel | ResourceRefDescriptor<boolean>>(spec: ContractSpec<I, O>): this;
27
+ register<I extends AnySchemaModel, O extends AnySchemaModel | ResourceRefDescriptor<boolean>>(spec: OperationSpec<I, O>): this;
29
28
  /**
30
29
  * Binds a runtime handler implementation to a previously registered spec.
31
30
  *
@@ -34,7 +33,7 @@ declare class SpecRegistry {
34
33
  * @returns The registry instance for chaining.
35
34
  * @throws If the spec is not found or a handler is already bound.
36
35
  */
37
- bind<I extends AnySchemaModel, O extends AnySchemaModel | ResourceRefDescriptor<boolean>>(spec: ContractSpec<I, O>, handler: HandlerFor<ContractSpec<I, O>>): this;
36
+ bind<I extends AnySchemaModel, O extends AnySchemaModel | ResourceRefDescriptor<boolean>>(spec: OperationSpec<I, O>, handler: HandlerForOperationSpec<OperationSpec<I, O>>): this;
38
37
  /**
39
38
  * Retrieves a registered spec by name and version.
40
39
  * If version is omitted, returns the highest version found.
@@ -42,17 +41,17 @@ declare class SpecRegistry {
42
41
  * @param name - Operation name.
43
42
  * @param version - (Optional) Specific version.
44
43
  */
45
- getSpec(name: string, version?: number): AnySpec | undefined;
44
+ getSpec(name: string, version?: number): AnyOperationSpec | undefined;
46
45
  /**
47
46
  * Retrieves the bound handler for a spec.
48
47
  */
49
- getHandler(name: string, version?: number): AnyHandler | undefined;
48
+ getHandler(name: string, version?: number): AnyOperationHandler | undefined;
50
49
  /** Iterate all registered specs. */
51
- listSpecs(): AnySpec[];
50
+ listSpecs(): AnyOperationSpec[];
52
51
  /** Iterate all bound operations (spec+handler). */
53
52
  listBound(): {
54
- spec: AnySpec;
55
- handler: AnyHandler;
53
+ spec: AnyOperationSpec;
54
+ handler: AnyOperationHandler;
56
55
  }[];
57
56
  /**
58
57
  * Execute an operation by name/version with full runtime protections:
@@ -70,4 +69,4 @@ declare class SpecRegistry {
70
69
  execute(name: string, version: number | undefined, rawInput: unknown, ctx: HandlerCtx): Promise<unknown>;
71
70
  }
72
71
  //#endregion
73
- export { OperationKey, SpecRegistry, defaultDocRegistry, docId, opKey, registerDocBlocks };
72
+ export { OperationKey, OperationSpecRegistry, defaultDocRegistry, docId, opKey, registerDocBlocks };
package/dist/registry.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { eventKey } from "./events.js";
2
- import { isEmitDeclRef } from "./spec.js";
2
+ import { isEmitDeclRef } from "./operation.js";
3
3
  import { defaultDocRegistry, docId, registerDocBlocks } from "./docs/registry.js";
4
4
 
5
5
  //#region src/registry.ts
6
6
  /**
7
- * SpecRegistry:
7
+ * OperationSpecRegistry:
8
8
  * - Registers ContractSpecs (unique by name+version)
9
9
  * - Binds runtime handlers to specs
10
10
  * - Provides lookup, iteration, and a safe execute() with validation/policy/enforcement
@@ -18,11 +18,11 @@ function opKey(name, version) {
18
18
  * In-memory registry for ContractSpecs and their bound handlers.
19
19
  * Provides validation, policy enforcement, and guarded event emission at execute time.
20
20
  */
21
- var SpecRegistry = class {
21
+ var OperationSpecRegistry = class {
22
22
  specs = /* @__PURE__ */ new Map();
23
23
  handlers = /* @__PURE__ */ new Map();
24
24
  /**
25
- * Registers a ContractSpec definition.
25
+ * Registers a OperationSpec definition.
26
26
  *
27
27
  * @param spec - The contract specification to register.
28
28
  * @returns The registry instance for chaining.
@@ -206,4 +206,4 @@ var SpecRegistry = class {
206
206
  };
207
207
 
208
208
  //#endregion
209
- export { SpecRegistry, defaultDocRegistry, docId, opKey, registerDocBlocks };
209
+ export { OperationSpecRegistry, defaultDocRegistry, docId, opKey, registerDocBlocks };
@@ -1,5 +1,5 @@
1
1
  import { ResourceRegistry } from "../resources.js";
2
- import { SpecRegistry } from "../registry.js";
2
+ import { OperationSpecRegistry } from "../registry.js";
3
3
  import "@pothos/plugin-prisma";
4
4
  import "@pothos/plugin-complexity";
5
5
  import "@pothos/plugin-relay";
@@ -10,22 +10,22 @@ import { SchemaTypes } from "@pothos/core";
10
10
  //#region src/server/graphql-pothos.d.ts
11
11
 
12
12
  /**
13
- * Registers all ContractSpecs from a SpecRegistry onto a Pothos SchemaBuilder.
13
+ * Registers all ContractSpecs from a OperationSpecRegistry onto a Pothos SchemaBuilder.
14
14
  *
15
15
  * This adapter:
16
16
  * 1. Discovers output types from specs and registers them as Pothos object types.
17
- * 2. Maps `ContractSpec` inputs to Pothos input types.
17
+ * 2. Maps `ContractSpec` (OperationSpec) inputs to Pothos input types.
18
18
  * 3. Mounts `query` specs as `Query` fields and `command` specs as `Mutation` fields.
19
19
  * 4. Wraps the resolver to:
20
20
  * - Enforce auth policies (basic check).
21
21
  * - Build a `HandlerCtx`.
22
- * - Execute via `SpecRegistry`.
22
+ * - Execute via `OperationSpecRegistry`.
23
23
  * - Hydrate resource references if applicable.
24
24
  *
25
25
  * @param builder - The Pothos SchemaBuilder instance.
26
- * @param reg - The SpecRegistry containing operations.
26
+ * @param reg - The OperationSpecRegistry containing operations.
27
27
  * @param resources - (Optional) ResourceRegistry for hydrating resource references.
28
28
  */
29
- declare function registerContractsOnBuilder<T extends SchemaTypes>(builder: PothosSchemaTypes.SchemaBuilder<T>, reg: SpecRegistry, resources?: ResourceRegistry): void;
29
+ declare function registerContractsOnBuilder<T extends SchemaTypes>(builder: PothosSchemaTypes.SchemaBuilder<T>, reg: OperationSpecRegistry, resources?: ResourceRegistry): void;
30
30
  //#endregion
31
31
  export { registerContractsOnBuilder };
@@ -9,20 +9,20 @@ import "@pothos/plugin-tracing";
9
9
 
10
10
  //#region src/server/graphql-pothos.ts
11
11
  /**
12
- * Registers all ContractSpecs from a SpecRegistry onto a Pothos SchemaBuilder.
12
+ * Registers all ContractSpecs from a OperationSpecRegistry onto a Pothos SchemaBuilder.
13
13
  *
14
14
  * This adapter:
15
15
  * 1. Discovers output types from specs and registers them as Pothos object types.
16
- * 2. Maps `ContractSpec` inputs to Pothos input types.
16
+ * 2. Maps `ContractSpec` (OperationSpec) inputs to Pothos input types.
17
17
  * 3. Mounts `query` specs as `Query` fields and `command` specs as `Mutation` fields.
18
18
  * 4. Wraps the resolver to:
19
19
  * - Enforce auth policies (basic check).
20
20
  * - Build a `HandlerCtx`.
21
- * - Execute via `SpecRegistry`.
21
+ * - Execute via `OperationSpecRegistry`.
22
22
  * - Hydrate resource references if applicable.
23
23
  *
24
24
  * @param builder - The Pothos SchemaBuilder instance.
25
- * @param reg - The SpecRegistry containing operations.
25
+ * @param reg - The OperationSpecRegistry containing operations.
26
26
  * @param resources - (Optional) ResourceRegistry for hydrating resource references.
27
27
  */
28
28
  function registerContractsOnBuilder(builder, reg, resources) {
@@ -1,5 +1,5 @@
1
1
  import { ResourceRegistry } from "../../resources.js";
2
- import { SpecRegistry } from "../../registry.js";
2
+ import { OperationSpecRegistry } from "../../registry.js";
3
3
  import { PromptRegistry } from "../../promptRegistry.js";
4
4
  import { McpCtxFactories } from "./mcpTypes.js";
5
5
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
@@ -9,7 +9,7 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
9
9
  /**
10
10
  * Creates a unified Model Context Protocol (MCP) server exposing operations, resources, prompts,
11
11
  * and (optionally) presentations.\n+ *
12
- * ContractSpec exposes:\n+ * - Tools: `command` operations from `SpecRegistry`.\n+ * - Resources: templates from `ResourceRegistry`.\n+ * - Prompts: templates from `PromptRegistry`.\n+ * - Presentations: V1 registry and/or V2 descriptors as read-only resources.\n+ */
13
- declare function createMcpServer(server: McpServer, ops: SpecRegistry, resources: ResourceRegistry, prompts: PromptRegistry, ctxFactories: McpCtxFactories): McpServer;
12
+ * ContractSpec exposes:\n+ * - Tools: `command` operations from `OperationSpecRegistry`.\n+ * - Resources: templates from `ResourceRegistry`.\n+ * - Prompts: templates from `PromptRegistry`.\n+ * - Presentations: V1 registry and/or V2 descriptors as read-only resources.\n+ */
13
+ declare function createMcpServer(server: McpServer, ops: OperationSpecRegistry, resources: ResourceRegistry, prompts: PromptRegistry, ctxFactories: McpCtxFactories): McpServer;
14
14
  //#endregion
15
15
  export { createMcpServer };
@@ -7,7 +7,7 @@ import { registerMcpPresentations } from "./registerPresentations.js";
7
7
  /**
8
8
  * Creates a unified Model Context Protocol (MCP) server exposing operations, resources, prompts,
9
9
  * and (optionally) presentations.\n+ *
10
- * ContractSpec exposes:\n+ * - Tools: `command` operations from `SpecRegistry`.\n+ * - Resources: templates from `ResourceRegistry`.\n+ * - Prompts: templates from `PromptRegistry`.\n+ * - Presentations: V1 registry and/or V2 descriptors as read-only resources.\n+ */
10
+ * ContractSpec exposes:\n+ * - Tools: `command` operations from `OperationSpecRegistry`.\n+ * - Resources: templates from `ResourceRegistry`.\n+ * - Prompts: templates from `PromptRegistry`.\n+ * - Presentations: V1 registry and/or V2 descriptors as read-only resources.\n+ */
11
11
  function createMcpServer(server, ops, resources, prompts, ctxFactories) {
12
12
  ctxFactories.logger.info("Creating MCP server");
13
13
  registerMcpTools(server, ops, { toolCtx: ctxFactories.toolCtx });
@@ -1,8 +1,8 @@
1
- import { SpecRegistry } from "../../registry.js";
1
+ import { OperationSpecRegistry } from "../../registry.js";
2
2
  import { McpCtxFactories } from "./mcpTypes.js";
3
3
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
4
4
 
5
5
  //#region src/server/mcp/registerTools.d.ts
6
- declare function registerMcpTools(server: McpServer, ops: SpecRegistry, ctx: Pick<McpCtxFactories, 'toolCtx'>): void;
6
+ declare function registerMcpTools(server: McpServer, ops: OperationSpecRegistry, ctx: Pick<McpCtxFactories, 'toolCtx'>): void;
7
7
  //#endregion
8
8
  export { registerMcpTools };
@@ -1,11 +1,11 @@
1
1
  import { HandlerCtx } from "../types.js";
2
- import { SpecRegistry } from "../registry.js";
2
+ import { OperationSpecRegistry } from "../registry.js";
3
3
  import { RestOptions } from "./rest-generic.js";
4
4
  import { Elysia } from "elysia";
5
5
 
6
6
  //#region src/server/rest-elysia.d.ts
7
7
  /** Mount routes on an Elysia instance */
8
- declare function elysiaPlugin(app: Elysia, reg: SpecRegistry, ctxFactory: (c: {
8
+ declare function elysiaPlugin(app: Elysia, reg: OperationSpecRegistry, ctxFactory: (c: {
9
9
  request: Request;
10
10
  store: unknown;
11
11
  }) => HandlerCtx, options?: RestOptions): Elysia<"", {
@@ -1,5 +1,5 @@
1
1
  import { HandlerCtx } from "../types.js";
2
- import { SpecRegistry } from "../registry.js";
2
+ import { OperationSpecRegistry } from "../registry.js";
3
3
  import { RestOptions } from "./rest-generic.js";
4
4
  import { Request, Router } from "express";
5
5
 
@@ -11,6 +11,6 @@ import { Request, Router } from "express";
11
11
  */
12
12
  declare function expressRouter(express: {
13
13
  Router: () => Router;
14
- }, reg: SpecRegistry, ctxFactory: (req: Request) => HandlerCtx, options?: RestOptions): Router;
14
+ }, reg: OperationSpecRegistry, ctxFactory: (req: Request) => HandlerCtx, options?: RestOptions): Router;
15
15
  //#endregion
16
16
  export { expressRouter };
@@ -1,5 +1,5 @@
1
1
  import { HandlerCtx } from "../types.js";
2
- import { SpecRegistry } from "../registry.js";
2
+ import { OperationSpecRegistry } from "../registry.js";
3
3
 
4
4
  //#region src/server/rest-generic.d.ts
5
5
  interface RestOptions {
@@ -23,10 +23,10 @@ interface RestOptions {
23
23
  }
24
24
  /**
25
25
  * Build a single Fetch-style handler: (req) => Response
26
- * - Discovers routes from SpecRegistry
26
+ * - Discovers routes from OperationSpecRegistry
27
27
  * - Validates with zod via registry.execute()
28
28
  * - Handles CORS (optional)
29
29
  */
30
- declare function createFetchHandler(reg: SpecRegistry, ctxFactory: (req: Request) => HandlerCtx, options?: RestOptions): (req: Request) => Promise<Response>;
30
+ declare function createFetchHandler(reg: OperationSpecRegistry, ctxFactory: (req: Request) => HandlerCtx, options?: RestOptions): (req: Request) => Promise<Response>;
31
31
  //#endregion
32
32
  export { RestOptions, createFetchHandler };
@@ -22,7 +22,7 @@ function joinPath(a, b) {
22
22
  }
23
23
  /**
24
24
  * Build a single Fetch-style handler: (req) => Response
25
- * - Discovers routes from SpecRegistry
25
+ * - Discovers routes from OperationSpecRegistry
26
26
  * - Validates with zod via registry.execute()
27
27
  * - Handles CORS (optional)
28
28
  */
@@ -1,5 +1,5 @@
1
1
  import { HandlerCtx } from "../types.js";
2
- import { SpecRegistry } from "../registry.js";
2
+ import { OperationSpecRegistry } from "../registry.js";
3
3
  import { RestOptions } from "./rest-generic.js";
4
4
 
5
5
  //#region src/server/rest-next-app.d.ts
@@ -12,10 +12,10 @@ import { RestOptions } from "./rest-generic.js";
12
12
  * - Path parsing to determine the operation name and version.
13
13
  * - Body parsing (JSON).
14
14
  * - Context creation via `ctxFactory`.
15
- * - Execution via `SpecRegistry`.
15
+ * - Execution via `OperationSpecRegistry`.
16
16
  * - Response formatting (JSON success/error).
17
17
  *
18
- * @param reg - The SpecRegistry containing the operations.
18
+ * @param reg - The OperationSpecRegistry containing the operations.
19
19
  * @param ctxFactory - A factory function to build the `HandlerCtx` (e.g., auth, tenant) from the request.
20
20
  * @param options - Optional configuration for the REST handler.
21
21
  * @returns A function `(req: Request) => Promise<Response>`.
@@ -30,6 +30,6 @@ import { RestOptions } from "./rest-generic.js";
30
30
  * export { handler as GET, handler as POST };
31
31
  * ```
32
32
  */
33
- declare function makeNextAppHandler(reg: SpecRegistry, ctxFactory: (req: Request) => HandlerCtx, options?: RestOptions): (req: Request) => Promise<Response>;
33
+ declare function makeNextAppHandler(reg: OperationSpecRegistry, ctxFactory: (req: Request) => HandlerCtx, options?: RestOptions): (req: Request) => Promise<Response>;
34
34
  //#endregion
35
35
  export { makeNextAppHandler };
@@ -9,10 +9,10 @@ import { createFetchHandler } from "./rest-generic.js";
9
9
  * - Path parsing to determine the operation name and version.
10
10
  * - Body parsing (JSON).
11
11
  * - Context creation via `ctxFactory`.
12
- * - Execution via `SpecRegistry`.
12
+ * - Execution via `OperationSpecRegistry`.
13
13
  * - Response formatting (JSON success/error).
14
14
  *
15
- * @param reg - The SpecRegistry containing the operations.
15
+ * @param reg - The OperationSpecRegistry containing the operations.
16
16
  * @param ctxFactory - A factory function to build the `HandlerCtx` (e.g., auth, tenant) from the request.
17
17
  * @param options - Optional configuration for the REST handler.
18
18
  * @returns A function `(req: Request) => Promise<Response>`.