@contractspec/lib.contracts 1.49.0 → 1.50.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app-config/contracts.d.ts +50 -50
- package/dist/app-config/events.d.ts +27 -27
- package/dist/app-config/lifecycle-contracts.d.ts +54 -54
- package/dist/capabilities/capabilities.d.ts +27 -4
- package/dist/contract-registry/schemas.d.ts +2 -2
- package/dist/events.d.ts +73 -13
- package/dist/events.js +33 -3
- package/dist/examples/schema.d.ts +8 -8
- package/dist/experiments/spec.d.ts +7 -4
- package/dist/features/types.d.ts +25 -29
- package/dist/index.d.ts +4 -3
- package/dist/index.js +2 -1
- package/dist/integrations/openbanking/contracts/accounts.d.ts +66 -66
- package/dist/integrations/openbanking/contracts/balances.d.ts +34 -34
- package/dist/integrations/openbanking/contracts/transactions.d.ts +48 -48
- package/dist/integrations/openbanking/models.d.ts +55 -55
- package/dist/integrations/operations.d.ts +102 -102
- package/dist/knowledge/operations.d.ts +66 -66
- package/dist/onboarding-base.d.ts +29 -29
- package/dist/ownership.d.ts +133 -8
- package/dist/ownership.js +25 -0
- package/dist/policy/spec.d.ts +7 -4
- package/dist/tests/spec.d.ts +17 -12
- package/dist/themes.d.ts +7 -4
- package/dist/types.d.ts +140 -14
- package/dist/versioning/index.d.ts +2 -1
- package/dist/versioning/index.js +2 -1
- package/dist/versioning/refs.d.ts +179 -0
- package/dist/versioning/refs.js +161 -0
- package/package.json +6 -5
package/dist/ownership.d.ts
CHANGED
|
@@ -2,82 +2,207 @@ import { DocId } from "./docs/registry.js";
|
|
|
2
2
|
import "./docs/index.js";
|
|
3
3
|
|
|
4
4
|
//#region src/ownership.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Lifecycle stability stages for specs.
|
|
8
|
+
*
|
|
9
|
+
* Specs progress through these stages as they mature:
|
|
10
|
+
* - `idea`: Initial concept, not implemented
|
|
11
|
+
* - `in_creation`: Currently being built
|
|
12
|
+
* - `experimental`: Working but may change significantly
|
|
13
|
+
* - `beta`: Feature-complete, seeking feedback
|
|
14
|
+
* - `stable`: Production-ready, breaking changes require major version bump
|
|
15
|
+
* - `deprecated`: Scheduled for removal, use alternatives
|
|
16
|
+
*/
|
|
5
17
|
declare const StabilityEnum: {
|
|
18
|
+
/** Initial concept, not yet implemented. */
|
|
6
19
|
readonly Idea: "idea";
|
|
20
|
+
/** Currently being built, not ready for use. */
|
|
7
21
|
readonly InCreation: "in_creation";
|
|
22
|
+
/** Working but unstable, may change significantly. */
|
|
8
23
|
readonly Experimental: "experimental";
|
|
24
|
+
/** Feature-complete, seeking feedback before stabilization. */
|
|
9
25
|
readonly Beta: "beta";
|
|
26
|
+
/** Production-ready, follows semantic versioning. */
|
|
10
27
|
readonly Stable: "stable";
|
|
28
|
+
/** Scheduled for removal, use alternatives. */
|
|
11
29
|
readonly Deprecated: "deprecated";
|
|
12
30
|
};
|
|
31
|
+
/** Stability level for a spec's lifecycle stage. */
|
|
13
32
|
type Stability = (typeof StabilityEnum)[keyof typeof StabilityEnum];
|
|
33
|
+
/**
|
|
34
|
+
* Curated owner identifiers for business/product ownership.
|
|
35
|
+
*
|
|
36
|
+
* Used for CODEOWNERS, on-call routing, and approval workflows.
|
|
37
|
+
* Custom owner strings are also allowed for flexibility.
|
|
38
|
+
*/
|
|
14
39
|
declare const OwnersEnum: {
|
|
40
|
+
/** Core platform team. */
|
|
15
41
|
readonly PlatformCore: "platform.core";
|
|
42
|
+
/** Sigil/auth team. */
|
|
16
43
|
readonly PlatformSigil: "platform.sigil";
|
|
44
|
+
/** Marketplace team. */
|
|
17
45
|
readonly PlatformMarketplace: "platform.marketplace";
|
|
46
|
+
/** Messaging/notifications team. */
|
|
18
47
|
readonly PlatformMessaging: "platform.messaging";
|
|
48
|
+
/** Content/CMS team. */
|
|
19
49
|
readonly PlatformContent: "platform.content";
|
|
50
|
+
/** Feature flags team. */
|
|
20
51
|
readonly PlatformFeatureFlags: "platform.featureflags";
|
|
52
|
+
/** Finance/billing team. */
|
|
21
53
|
readonly PlatformFinance: "platform.finance";
|
|
22
54
|
};
|
|
55
|
+
/**
|
|
56
|
+
* Owner identifier for a spec.
|
|
57
|
+
* Can be a predefined OwnersEnum value or any custom string.
|
|
58
|
+
*/
|
|
23
59
|
type Owner = (typeof OwnersEnum)[keyof typeof OwnersEnum] | (string & {});
|
|
60
|
+
/** @deprecated Use OwnersEnum instead. */
|
|
24
61
|
declare const Owners: {
|
|
62
|
+
/** Core platform team. */
|
|
25
63
|
readonly PlatformCore: "platform.core";
|
|
64
|
+
/** Sigil/auth team. */
|
|
26
65
|
readonly PlatformSigil: "platform.sigil";
|
|
66
|
+
/** Marketplace team. */
|
|
27
67
|
readonly PlatformMarketplace: "platform.marketplace";
|
|
68
|
+
/** Messaging/notifications team. */
|
|
28
69
|
readonly PlatformMessaging: "platform.messaging";
|
|
70
|
+
/** Content/CMS team. */
|
|
29
71
|
readonly PlatformContent: "platform.content";
|
|
72
|
+
/** Feature flags team. */
|
|
30
73
|
readonly PlatformFeatureFlags: "platform.featureflags";
|
|
74
|
+
/** Finance/billing team. */
|
|
31
75
|
readonly PlatformFinance: "platform.finance";
|
|
32
76
|
};
|
|
77
|
+
/**
|
|
78
|
+
* Common tags for categorizing specs.
|
|
79
|
+
*
|
|
80
|
+
* Used for search, grouping, and documentation navigation.
|
|
81
|
+
* Custom tag strings are also allowed for flexibility.
|
|
82
|
+
*/
|
|
33
83
|
declare const TagsEnum: {
|
|
84
|
+
/** Spots/locations domain. */
|
|
34
85
|
readonly Spots: "spots";
|
|
86
|
+
/** Collectivity/community domain. */
|
|
35
87
|
readonly Collectivity: "collectivity";
|
|
88
|
+
/** Marketplace domain. */
|
|
36
89
|
readonly Marketplace: "marketplace";
|
|
90
|
+
/** Seller-related features. */
|
|
37
91
|
readonly Sellers: "sellers";
|
|
92
|
+
/** Authentication features. */
|
|
38
93
|
readonly Auth: "auth";
|
|
94
|
+
/** Login flows. */
|
|
39
95
|
readonly Login: "login";
|
|
96
|
+
/** Signup flows. */
|
|
40
97
|
readonly Signup: "signup";
|
|
98
|
+
/** Onboarding/guides. */
|
|
41
99
|
readonly Guide: "guide";
|
|
100
|
+
/** Documentation. */
|
|
42
101
|
readonly Docs: "docs";
|
|
102
|
+
/** Internationalization. */
|
|
43
103
|
readonly I18n: "i18n";
|
|
104
|
+
/** Incident management. */
|
|
44
105
|
readonly Incident: "incident";
|
|
106
|
+
/** Automation/workflows. */
|
|
45
107
|
readonly Automation: "automation";
|
|
108
|
+
/** Code hygiene/maintenance. */
|
|
46
109
|
readonly Hygiene: "hygiene";
|
|
47
110
|
};
|
|
111
|
+
/**
|
|
112
|
+
* Tag for categorizing a spec.
|
|
113
|
+
* Can be a predefined TagsEnum value or any custom string.
|
|
114
|
+
*/
|
|
48
115
|
type Tag = (typeof TagsEnum)[keyof typeof TagsEnum] | (string & {});
|
|
116
|
+
/** @deprecated Use TagsEnum instead. */
|
|
49
117
|
declare const Tags: {
|
|
118
|
+
/** Spots/locations domain. */
|
|
50
119
|
readonly Spots: "spots";
|
|
120
|
+
/** Collectivity/community domain. */
|
|
51
121
|
readonly Collectivity: "collectivity";
|
|
122
|
+
/** Marketplace domain. */
|
|
52
123
|
readonly Marketplace: "marketplace";
|
|
124
|
+
/** Seller-related features. */
|
|
53
125
|
readonly Sellers: "sellers";
|
|
126
|
+
/** Authentication features. */
|
|
54
127
|
readonly Auth: "auth";
|
|
128
|
+
/** Login flows. */
|
|
55
129
|
readonly Login: "login";
|
|
130
|
+
/** Signup flows. */
|
|
56
131
|
readonly Signup: "signup";
|
|
132
|
+
/** Onboarding/guides. */
|
|
57
133
|
readonly Guide: "guide";
|
|
134
|
+
/** Documentation. */
|
|
58
135
|
readonly Docs: "docs";
|
|
136
|
+
/** Internationalization. */
|
|
59
137
|
readonly I18n: "i18n";
|
|
138
|
+
/** Incident management. */
|
|
60
139
|
readonly Incident: "incident";
|
|
140
|
+
/** Automation/workflows. */
|
|
61
141
|
readonly Automation: "automation";
|
|
142
|
+
/** Code hygiene/maintenance. */
|
|
62
143
|
readonly Hygiene: "hygiene";
|
|
63
144
|
};
|
|
145
|
+
/**
|
|
146
|
+
* Common metadata interface for all ContractSpec specifications.
|
|
147
|
+
*
|
|
148
|
+
* Every spec type (operations, events, presentations, etc.) extends this
|
|
149
|
+
* interface to provide consistent ownership, versioning, and discoverability.
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* ```typescript
|
|
153
|
+
* const meta: OwnerShipMeta = {
|
|
154
|
+
* key: 'auth.login',
|
|
155
|
+
* version: '1.0.0',
|
|
156
|
+
* description: 'Authenticates a user with email and password',
|
|
157
|
+
* stability: StabilityEnum.Stable,
|
|
158
|
+
* owners: [OwnersEnum.PlatformSigil],
|
|
159
|
+
* tags: [TagsEnum.Auth, TagsEnum.Login],
|
|
160
|
+
* };
|
|
161
|
+
* ```
|
|
162
|
+
*/
|
|
64
163
|
interface OwnerShipMeta {
|
|
65
|
-
/**
|
|
164
|
+
/**
|
|
165
|
+
* Semantic version string (e.g., "1.0.0").
|
|
166
|
+
* Bump for breaking changes according to semver rules.
|
|
167
|
+
*/
|
|
66
168
|
version: string;
|
|
67
|
-
/**
|
|
169
|
+
/**
|
|
170
|
+
* Fully-qualified spec key (e.g., "sigil.beginSignup", "user.created").
|
|
171
|
+
* Must be unique within the spec type.
|
|
172
|
+
*/
|
|
68
173
|
key: string;
|
|
69
|
-
/**
|
|
174
|
+
/**
|
|
175
|
+
* Human-friendly title (e.g., "Begin Signup").
|
|
176
|
+
* Used in documentation and UI.
|
|
177
|
+
*/
|
|
70
178
|
title?: string;
|
|
71
|
-
/**
|
|
179
|
+
/**
|
|
180
|
+
* Short human-friendly summary of what this spec does.
|
|
181
|
+
* Should be concise (1-2 sentences).
|
|
182
|
+
*/
|
|
72
183
|
description: string;
|
|
184
|
+
/**
|
|
185
|
+
* Business domain this spec belongs to (e.g., "auth", "marketplace").
|
|
186
|
+
* Used for grouping and discovery.
|
|
187
|
+
*/
|
|
73
188
|
domain?: string;
|
|
74
|
-
/**
|
|
189
|
+
/**
|
|
190
|
+
* Lifecycle stability marker.
|
|
191
|
+
* Indicates maturity level and change expectations.
|
|
192
|
+
*/
|
|
75
193
|
stability: Stability;
|
|
76
|
-
/**
|
|
194
|
+
/**
|
|
195
|
+
* Team/individual owners responsible for this spec.
|
|
196
|
+
* Used for CODEOWNERS, on-call routing, and approvals.
|
|
197
|
+
*/
|
|
77
198
|
owners: Owner[];
|
|
78
|
-
/**
|
|
199
|
+
/**
|
|
200
|
+
* Tags for search, grouping, and documentation navigation.
|
|
201
|
+
*/
|
|
79
202
|
tags: Tag[];
|
|
80
|
-
/**
|
|
203
|
+
/**
|
|
204
|
+
* Associated DocBlock identifiers for documentation linkage.
|
|
205
|
+
*/
|
|
81
206
|
docId?: DocId[];
|
|
82
207
|
}
|
|
83
208
|
//#endregion
|
package/dist/ownership.js
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
//#region src/ownership.ts
|
|
2
|
+
/**
|
|
3
|
+
* Lifecycle stability stages for specs.
|
|
4
|
+
*
|
|
5
|
+
* Specs progress through these stages as they mature:
|
|
6
|
+
* - `idea`: Initial concept, not implemented
|
|
7
|
+
* - `in_creation`: Currently being built
|
|
8
|
+
* - `experimental`: Working but may change significantly
|
|
9
|
+
* - `beta`: Feature-complete, seeking feedback
|
|
10
|
+
* - `stable`: Production-ready, breaking changes require major version bump
|
|
11
|
+
* - `deprecated`: Scheduled for removal, use alternatives
|
|
12
|
+
*/
|
|
2
13
|
const StabilityEnum = {
|
|
3
14
|
Idea: "idea",
|
|
4
15
|
InCreation: "in_creation",
|
|
@@ -7,6 +18,12 @@ const StabilityEnum = {
|
|
|
7
18
|
Stable: "stable",
|
|
8
19
|
Deprecated: "deprecated"
|
|
9
20
|
};
|
|
21
|
+
/**
|
|
22
|
+
* Curated owner identifiers for business/product ownership.
|
|
23
|
+
*
|
|
24
|
+
* Used for CODEOWNERS, on-call routing, and approval workflows.
|
|
25
|
+
* Custom owner strings are also allowed for flexibility.
|
|
26
|
+
*/
|
|
10
27
|
const OwnersEnum = {
|
|
11
28
|
PlatformCore: "platform.core",
|
|
12
29
|
PlatformSigil: "platform.sigil",
|
|
@@ -16,7 +33,14 @@ const OwnersEnum = {
|
|
|
16
33
|
PlatformFeatureFlags: "platform.featureflags",
|
|
17
34
|
PlatformFinance: "platform.finance"
|
|
18
35
|
};
|
|
36
|
+
/** @deprecated Use OwnersEnum instead. */
|
|
19
37
|
const Owners = OwnersEnum;
|
|
38
|
+
/**
|
|
39
|
+
* Common tags for categorizing specs.
|
|
40
|
+
*
|
|
41
|
+
* Used for search, grouping, and documentation navigation.
|
|
42
|
+
* Custom tag strings are also allowed for flexibility.
|
|
43
|
+
*/
|
|
20
44
|
const TagsEnum = {
|
|
21
45
|
Spots: "spots",
|
|
22
46
|
Collectivity: "collectivity",
|
|
@@ -32,6 +56,7 @@ const TagsEnum = {
|
|
|
32
56
|
Automation: "automation",
|
|
33
57
|
Hygiene: "hygiene"
|
|
34
58
|
};
|
|
59
|
+
/** @deprecated Use TagsEnum instead. */
|
|
35
60
|
const Tags = TagsEnum;
|
|
36
61
|
|
|
37
62
|
//#endregion
|
package/dist/policy/spec.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { OwnerShipMeta } from "../ownership.js";
|
|
2
|
+
import { VersionedSpecRef } from "../versioning/refs.js";
|
|
2
3
|
|
|
3
4
|
//#region src/policy/spec.d.ts
|
|
5
|
+
/** Effect of a policy rule: allow or deny access. */
|
|
4
6
|
type PolicyEffect = 'allow' | 'deny';
|
|
5
7
|
interface RelationshipDefinition {
|
|
6
8
|
subjectType: string;
|
|
@@ -95,9 +97,10 @@ interface PolicySpec {
|
|
|
95
97
|
rateLimits?: RateLimitDefinition[];
|
|
96
98
|
opa?: PolicyOPAConfig;
|
|
97
99
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
/**
|
|
101
|
+
* Reference to a policy spec.
|
|
102
|
+
* Uses key and version to identify a specific policy.
|
|
103
|
+
*/
|
|
104
|
+
type PolicyRef = VersionedSpecRef;
|
|
102
105
|
//#endregion
|
|
103
106
|
export { AttributeMatcher, ConsentDefinition, FieldPolicyRule, PIIPolicy, PolicyCondition, PolicyEffect, PolicyMeta, PolicyOPAConfig, PolicyRef, PolicyRule, PolicySpec, RateLimitDefinition, RelationshipDefinition, RelationshipMatcher, ResourceMatcher, SubjectMatcher };
|
package/dist/tests/spec.d.ts
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import { OwnerShipMeta } from "../ownership.js";
|
|
2
|
+
import { OptionalVersionedSpecRef } from "../versioning/refs.js";
|
|
2
3
|
|
|
3
4
|
//#region src/tests/spec.d.ts
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Reference to an operation to be tested.
|
|
8
|
+
* Version is optional; when omitted, refers to the latest version.
|
|
9
|
+
*/
|
|
10
|
+
type OperationTargetRef = OptionalVersionedSpecRef;
|
|
11
|
+
/**
|
|
12
|
+
* Reference to a workflow to be tested.
|
|
13
|
+
* Version is optional; when omitted, refers to the latest version.
|
|
14
|
+
*/
|
|
15
|
+
type WorkflowTargetRef = OptionalVersionedSpecRef;
|
|
12
16
|
type TestTarget = {
|
|
13
17
|
type: 'operation';
|
|
14
18
|
operation: OperationTargetRef;
|
|
@@ -66,10 +70,11 @@ interface TestSpec {
|
|
|
66
70
|
scenarios: TestScenario[];
|
|
67
71
|
coverage?: CoverageRequirement;
|
|
68
72
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
+
/**
|
|
74
|
+
* Reference to a test spec.
|
|
75
|
+
* Version is optional; when omitted, refers to the latest version.
|
|
76
|
+
*/
|
|
77
|
+
type TestSpecRef = OptionalVersionedSpecRef;
|
|
73
78
|
declare class TestRegistry {
|
|
74
79
|
private readonly items;
|
|
75
80
|
register(spec: TestSpec): this;
|
package/dist/themes.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { OwnerShipMeta } from "./ownership.js";
|
|
2
|
+
import { VersionedSpecRef } from "./versioning/refs.js";
|
|
2
3
|
import { SpecContractRegistry } from "./registry.js";
|
|
3
4
|
|
|
4
5
|
//#region src/themes.d.ts
|
|
6
|
+
/** Scope at which a theme can be applied. */
|
|
5
7
|
type ThemeScope = 'global' | 'tenant' | 'user';
|
|
6
8
|
interface ThemeToken<T> {
|
|
7
9
|
value: T;
|
|
@@ -39,10 +41,11 @@ interface ThemeSpec {
|
|
|
39
41
|
components?: ComponentVariantSpec[];
|
|
40
42
|
overrides?: ThemeOverride[];
|
|
41
43
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
/**
|
|
45
|
+
* Reference to a theme spec.
|
|
46
|
+
* Uses key and version to identify a specific theme.
|
|
47
|
+
*/
|
|
48
|
+
type ThemeRef = VersionedSpecRef;
|
|
46
49
|
declare class ThemeRegistry extends SpecContractRegistry<'theme', ThemeSpec> {
|
|
47
50
|
constructor(items?: ThemeSpec[]);
|
|
48
51
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -9,83 +9,209 @@ import { SpecVariantResolver } from "./experiments/spec-resolver.js";
|
|
|
9
9
|
import { EventRegistry } from "./events.js";
|
|
10
10
|
|
|
11
11
|
//#region src/types.d.ts
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Common runtime types for ContractSpec execution.
|
|
15
|
+
*
|
|
16
|
+
* Provides types for execution context, policy decisions, event emission,
|
|
17
|
+
* and handler context passed through the contracts runtime.
|
|
18
|
+
*
|
|
19
|
+
* @module types
|
|
20
|
+
*/
|
|
12
21
|
/**
|
|
13
|
-
*
|
|
22
|
+
* Actor type representing the entity making a request.
|
|
23
|
+
*
|
|
24
|
+
* - `anonymous`: Unauthenticated request
|
|
25
|
+
* - `user`: Authenticated end-user
|
|
26
|
+
* - `admin`: Administrative/system user with elevated privileges
|
|
14
27
|
*/
|
|
15
28
|
type Actor = 'anonymous' | 'user' | 'admin';
|
|
29
|
+
/**
|
|
30
|
+
* Channel through which a request originates.
|
|
31
|
+
*
|
|
32
|
+
* - `web`: Browser/web application
|
|
33
|
+
* - `mobile`: Native mobile application
|
|
34
|
+
* - `job`: Background job/scheduled task
|
|
35
|
+
* - `agent`: AI agent or automated system
|
|
36
|
+
*/
|
|
16
37
|
type Channel = 'web' | 'mobile' | 'job' | 'agent';
|
|
38
|
+
/**
|
|
39
|
+
* Discriminator for all ContractSpec specification types.
|
|
40
|
+
*
|
|
41
|
+
* Used to identify the kind of spec in registries and runtime operations.
|
|
42
|
+
*/
|
|
17
43
|
type ContractSpecType = 'app-config' | 'agent' | 'operation' | 'example' | 'event' | 'presentation' | 'capability' | 'integration' | 'data-view' | 'feature' | 'workflow' | 'policy' | 'theme' | 'telemetry' | 'experiment' | 'knowledge-space';
|
|
44
|
+
/**
|
|
45
|
+
* Decision for a specific field access.
|
|
46
|
+
* Used for fine-grained field-level authorization.
|
|
47
|
+
*/
|
|
18
48
|
interface FieldLevelDecision {
|
|
49
|
+
/** The field path being evaluated. */
|
|
19
50
|
field: string;
|
|
51
|
+
/** Whether access is allowed or denied. */
|
|
20
52
|
effect: 'allow' | 'deny';
|
|
53
|
+
/** Human-readable reason for the decision. */
|
|
21
54
|
reason?: string;
|
|
22
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* Result of a policy evaluation.
|
|
58
|
+
*
|
|
59
|
+
* Contains the access decision and any applicable constraints
|
|
60
|
+
* like rate limits, escalation requirements, or consent needs.
|
|
61
|
+
*/
|
|
23
62
|
interface PolicyDecision {
|
|
63
|
+
/** Overall access decision: allow or deny. */
|
|
24
64
|
effect: 'allow' | 'deny';
|
|
65
|
+
/** Human-readable reason for the decision. */
|
|
25
66
|
reason?: string;
|
|
67
|
+
/** Rate limit constraints to apply if allowed. */
|
|
26
68
|
rateLimit?: Pick<RateLimitDefinition, 'rpm' | 'key' | 'windowSeconds' | 'burst'>;
|
|
69
|
+
/** Escalation requirement for manual review. */
|
|
27
70
|
escalate?: 'human_review' | null;
|
|
71
|
+
/** Per-field access decisions. */
|
|
28
72
|
fieldDecisions?: FieldLevelDecision[];
|
|
73
|
+
/** PII handling policy. */
|
|
29
74
|
pii?: PolicySpec['pii'];
|
|
75
|
+
/** Consents required before proceeding. */
|
|
30
76
|
requiredConsents?: ConsentDefinition[];
|
|
77
|
+
/** Which engine produced this decision. */
|
|
31
78
|
evaluatedBy?: 'engine' | 'opa';
|
|
32
79
|
}
|
|
80
|
+
/**
|
|
81
|
+
* Input for policy evaluation.
|
|
82
|
+
* Contains context about the request being authorized.
|
|
83
|
+
*/
|
|
33
84
|
interface PolicyDeciderInput {
|
|
85
|
+
/** Service name (e.g., "sigil"). */
|
|
34
86
|
service: string;
|
|
87
|
+
/** Command/operation name (e.g., "beginSignup"). */
|
|
35
88
|
command: string;
|
|
89
|
+
/** Operation version. */
|
|
36
90
|
version: string;
|
|
91
|
+
/** Actor type making the request. */
|
|
37
92
|
actor: Actor;
|
|
93
|
+
/** Channel the request came from. */
|
|
38
94
|
channel?: Channel;
|
|
95
|
+
/** Roles assigned to the actor. */
|
|
39
96
|
roles?: string[];
|
|
97
|
+
/** Organization context if applicable. */
|
|
40
98
|
organizationId?: string | null;
|
|
99
|
+
/** User context if authenticated. */
|
|
41
100
|
userId?: string | null;
|
|
101
|
+
/** Active feature flags. */
|
|
42
102
|
flags?: string[];
|
|
43
103
|
}
|
|
104
|
+
/**
|
|
105
|
+
* Function that evaluates policy rules and returns a decision.
|
|
106
|
+
*/
|
|
44
107
|
type PolicyDecider = (input: PolicyDeciderInput) => Promise<PolicyDecision>;
|
|
108
|
+
/**
|
|
109
|
+
* Function that enforces rate limits.
|
|
110
|
+
*
|
|
111
|
+
* @param key - The rate limit key (e.g., user ID, IP)
|
|
112
|
+
* @param cost - Cost of this request (usually 1)
|
|
113
|
+
* @param rpm - Requests per minute limit
|
|
114
|
+
* @throws When rate limit is exceeded
|
|
115
|
+
*/
|
|
45
116
|
type RateLimiter = (key: string, cost: number, rpm: number) => Promise<void>;
|
|
117
|
+
/**
|
|
118
|
+
* Function that resolves translation keys to localized strings.
|
|
119
|
+
*/
|
|
46
120
|
type TranslationResolver = (key: MessageKey, locale?: Locale) => Promise<string | null> | string | null;
|
|
47
|
-
/**
|
|
121
|
+
/**
|
|
122
|
+
* Function that publishes events to the outbox/message bus.
|
|
123
|
+
* Called after validation and guard checks pass.
|
|
124
|
+
*/
|
|
48
125
|
type EventPublisher = (envelope: {
|
|
126
|
+
/** Event key (e.g., "user.created"). */
|
|
49
127
|
key: string;
|
|
128
|
+
/** Event version. */
|
|
50
129
|
version: string;
|
|
130
|
+
/** Validated event payload. */
|
|
51
131
|
payload: unknown;
|
|
132
|
+
/** Trace ID for correlation. */
|
|
52
133
|
traceId?: string;
|
|
53
134
|
}) => Promise<void>;
|
|
135
|
+
/**
|
|
136
|
+
* Execution context passed to operation handlers.
|
|
137
|
+
*
|
|
138
|
+
* Contains all contextual information and service hooks needed
|
|
139
|
+
* during operation execution, including auth context, policy evaluation,
|
|
140
|
+
* telemetry, event publishing, and resolved configurations.
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* ```typescript
|
|
144
|
+
* async function loginHandler(input: LoginInput, ctx: HandlerCtx) {
|
|
145
|
+
* // Check policy
|
|
146
|
+
* const decision = await ctx.decide?.({
|
|
147
|
+
* service: 'auth',
|
|
148
|
+
* command: 'login',
|
|
149
|
+
* version: '1.0.0',
|
|
150
|
+
* actor: ctx.actor ?? 'anonymous',
|
|
151
|
+
* });
|
|
152
|
+
*
|
|
153
|
+
* // Track telemetry
|
|
154
|
+
* ctx.telemetry?.track('login_attempt', { userId: ctx.userId });
|
|
155
|
+
*
|
|
156
|
+
* // Publish event
|
|
157
|
+
* await ctx.eventPublisher?.({
|
|
158
|
+
* key: 'user.loggedIn',
|
|
159
|
+
* version: '1.0.0',
|
|
160
|
+
* payload: { userId: input.email },
|
|
161
|
+
* traceId: ctx.traceId,
|
|
162
|
+
* });
|
|
163
|
+
* }
|
|
164
|
+
* ```
|
|
165
|
+
*/
|
|
54
166
|
interface HandlerCtx {
|
|
167
|
+
/** Distributed trace identifier for request correlation. */
|
|
55
168
|
traceId?: string;
|
|
169
|
+
/** Idempotency key for deduplication. */
|
|
56
170
|
idemKey?: string;
|
|
171
|
+
/** Organization context for multi-tenant operations. */
|
|
57
172
|
organizationId?: string | null;
|
|
173
|
+
/** Authenticated user ID. */
|
|
58
174
|
userId?: string | null;
|
|
175
|
+
/** Actor type making the request. */
|
|
59
176
|
actor?: Actor;
|
|
177
|
+
/** Channel the request originated from. */
|
|
60
178
|
channel?: Channel;
|
|
179
|
+
/** Roles assigned to the authenticated user. */
|
|
61
180
|
roles?: string[];
|
|
62
|
-
/** Policy engine
|
|
181
|
+
/** Policy engine for authorization decisions. */
|
|
63
182
|
decide?: PolicyDecider;
|
|
64
|
-
/** Rate limiter (e.g., Redis) */
|
|
183
|
+
/** Rate limiter service (e.g., Redis-backed). */
|
|
65
184
|
rateLimit?: RateLimiter;
|
|
66
|
-
/** Telemetry tracker */
|
|
185
|
+
/** Telemetry tracker for metrics and events. */
|
|
67
186
|
telemetry?: TelemetryTracker;
|
|
68
|
-
/** Event publisher (outbox
|
|
187
|
+
/** Event publisher for domain events (outbox/bus). */
|
|
69
188
|
eventPublisher?: EventPublisher;
|
|
70
|
-
/** Secret provider for secure
|
|
189
|
+
/** Secret provider for secure credential access. */
|
|
71
190
|
secretProvider?: SecretProvider;
|
|
72
|
-
/**
|
|
191
|
+
/**
|
|
192
|
+
* Internal emit guard for enforcing declared event emissions.
|
|
193
|
+
* Populated by the executor runtime.
|
|
194
|
+
* @internal
|
|
195
|
+
*/
|
|
73
196
|
__emitGuard__?: (key: string, version: string, payload: unknown) => Promise<void>;
|
|
74
|
-
/** Resolved application configuration for
|
|
197
|
+
/** Resolved application configuration for this execution. */
|
|
75
198
|
appConfig?: ResolvedAppConfig;
|
|
76
|
-
/** Resolved integration connections available to this execution */
|
|
199
|
+
/** Resolved integration connections available to this execution. */
|
|
77
200
|
integrations?: ResolvedIntegration[];
|
|
78
|
-
/** Resolved knowledge spaces available to this execution */
|
|
201
|
+
/** Resolved knowledge spaces available to this execution. */
|
|
79
202
|
knowledge?: ResolvedKnowledge[];
|
|
80
|
-
/** Resolved branding context */
|
|
203
|
+
/** Resolved branding context (logos, colors, etc.). */
|
|
81
204
|
branding?: ResolvedBranding;
|
|
82
|
-
/** Translation context */
|
|
205
|
+
/** Translation context with config and resolver. */
|
|
83
206
|
translation?: {
|
|
207
|
+
/** Resolved translation configuration. */
|
|
84
208
|
config: ResolvedTranslation;
|
|
209
|
+
/** Function to resolve translation keys. */
|
|
85
210
|
resolve?: TranslationResolver;
|
|
86
211
|
};
|
|
87
|
-
/**
|
|
212
|
+
/** Spec variant resolver for A/B testing and experiments. */
|
|
88
213
|
specVariantResolver?: SpecVariantResolver;
|
|
214
|
+
/** Event registry for runtime event spec lookup. */
|
|
89
215
|
eventSpecResolver?: EventRegistry;
|
|
90
216
|
}
|
|
91
217
|
//#endregion
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { OptionalVersionedSpecRef, SpecKeyRef, VersionedSpecRef, createKeyRef, createOptionalRef, createVersionedRef, formatVersionedRefKey, isOptionalVersionedSpecRef, isSpecKeyRef, isVersionedSpecRef, parseVersionedRefKey } from "./refs.js";
|
|
1
2
|
import { ChangeEntry, ChangeType, ChangelogDocBlock, ChangelogEntry, ChangelogJsonExport, ChangelogResult, SemanticVersion, VersionAnalysis, VersionAnalysisResult, VersionBumpType, isChangeType, isChangelogDocBlock, isVersionBumpType } from "./types.js";
|
|
2
3
|
import { bumpVersion, compareVersions, determineBumpType, formatVersion, getBumpTypePriority, getMaxBumpType, isValidVersion, isVersionEqual, isVersionGreater, isVersionLess, parseVersion, parseVersionStrict, validateVersion } from "./utils.js";
|
|
3
|
-
export { ChangeEntry, ChangeType, ChangelogDocBlock, ChangelogEntry, ChangelogJsonExport, ChangelogResult, SemanticVersion, VersionAnalysis, VersionAnalysisResult, VersionBumpType, bumpVersion, compareVersions, determineBumpType, formatVersion, getBumpTypePriority, getMaxBumpType, isChangeType, isChangelogDocBlock, isValidVersion, isVersionBumpType, isVersionEqual, isVersionGreater, isVersionLess, parseVersion, parseVersionStrict, validateVersion };
|
|
4
|
+
export { ChangeEntry, ChangeType, ChangelogDocBlock, ChangelogEntry, ChangelogJsonExport, ChangelogResult, OptionalVersionedSpecRef, SemanticVersion, SpecKeyRef, VersionAnalysis, VersionAnalysisResult, VersionBumpType, VersionedSpecRef, bumpVersion, compareVersions, createKeyRef, createOptionalRef, createVersionedRef, determineBumpType, formatVersion, formatVersionedRefKey, getBumpTypePriority, getMaxBumpType, isChangeType, isChangelogDocBlock, isOptionalVersionedSpecRef, isSpecKeyRef, isValidVersion, isVersionBumpType, isVersionEqual, isVersionGreater, isVersionLess, isVersionedSpecRef, parseVersion, parseVersionStrict, parseVersionedRefKey, validateVersion };
|
package/dist/versioning/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
import { createKeyRef, createOptionalRef, createVersionedRef, formatVersionedRefKey, isOptionalVersionedSpecRef, isSpecKeyRef, isVersionedSpecRef, parseVersionedRefKey } from "./refs.js";
|
|
1
2
|
import { isChangeType, isChangelogDocBlock, isVersionBumpType } from "./types.js";
|
|
2
3
|
import { bumpVersion, compareVersions, determineBumpType, formatVersion, getBumpTypePriority, getMaxBumpType, isValidVersion, isVersionEqual, isVersionGreater, isVersionLess, parseVersion, parseVersionStrict, validateVersion } from "./utils.js";
|
|
3
4
|
|
|
4
|
-
export { bumpVersion, compareVersions, determineBumpType, formatVersion, getBumpTypePriority, getMaxBumpType, isChangeType, isChangelogDocBlock, isValidVersion, isVersionBumpType, isVersionEqual, isVersionGreater, isVersionLess, parseVersion, parseVersionStrict, validateVersion };
|
|
5
|
+
export { bumpVersion, compareVersions, createKeyRef, createOptionalRef, createVersionedRef, determineBumpType, formatVersion, formatVersionedRefKey, getBumpTypePriority, getMaxBumpType, isChangeType, isChangelogDocBlock, isOptionalVersionedSpecRef, isSpecKeyRef, isValidVersion, isVersionBumpType, isVersionEqual, isVersionGreater, isVersionLess, isVersionedSpecRef, parseVersion, parseVersionStrict, parseVersionedRefKey, validateVersion };
|