@contractspec/lib.contracts 1.48.1 → 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 +4 -4
- package/dist/data-views/data-views.d.ts +2 -1
- package/dist/data-views/index.d.ts +2 -1
- package/dist/data-views/spec.d.ts +2 -8
- package/dist/events.d.ts +73 -13
- package/dist/events.js +33 -3
- package/dist/examples/schema.d.ts +14 -14
- package/dist/experiments/spec.d.ts +7 -4
- package/dist/features/index.d.ts +2 -2
- package/dist/features/types.d.ts +25 -29
- package/dist/index.d.ts +10 -6
- package/dist/index.js +3 -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/serialization/index.d.ts +3 -0
- package/dist/serialization/index.js +3 -0
- package/dist/serialization/serializers.d.ts +40 -0
- package/dist/serialization/serializers.js +148 -0
- package/dist/serialization/types.d.ts +103 -0
- package/dist/serialization/types.js +0 -0
- 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/dist/workflow/index.d.ts +2 -1
- package/dist/workflow/spec.d.ts +2 -9
- package/package.json +9 -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 };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { SerializedDataViewSpec, SerializedEventSpec, SerializedFieldConfig, SerializedFormSpec, SerializedOperationSpec, SerializedPresentationSpec, SerializedSchemaModel } from "./types.js";
|
|
2
|
+
import { serializeDataViewSpec, serializeEventSpec, serializeFormSpec, serializeOperationSpec, serializePresentationSpec, serializeSchemaModel } from "./serializers.js";
|
|
3
|
+
export { SerializedDataViewSpec, SerializedEventSpec, SerializedFieldConfig, SerializedFormSpec, SerializedOperationSpec, SerializedPresentationSpec, SerializedSchemaModel, serializeDataViewSpec, serializeEventSpec, serializeFormSpec, serializeOperationSpec, serializePresentationSpec, serializeSchemaModel };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { serializeDataViewSpec, serializeEventSpec, serializeFormSpec, serializeOperationSpec, serializePresentationSpec, serializeSchemaModel } from "./serializers.js";
|
|
2
|
+
|
|
3
|
+
export { serializeDataViewSpec, serializeEventSpec, serializeFormSpec, serializeOperationSpec, serializePresentationSpec, serializeSchemaModel };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { PresentationSpec } from "../presentations/presentations.js";
|
|
2
|
+
import { ResourceRefDescriptor } from "../resources.js";
|
|
3
|
+
import { AnyOperationSpec } from "../operations/operation.js";
|
|
4
|
+
import "../operations/index.js";
|
|
5
|
+
import "../presentations/index.js";
|
|
6
|
+
import { DataViewSpec } from "../data-views/spec.js";
|
|
7
|
+
import "../data-views/index.js";
|
|
8
|
+
import { AnyEventSpec } from "../events.js";
|
|
9
|
+
import { FormSpec } from "../forms/forms.js";
|
|
10
|
+
import "../forms/index.js";
|
|
11
|
+
import { SerializedDataViewSpec, SerializedEventSpec, SerializedFormSpec, SerializedOperationSpec, SerializedPresentationSpec, SerializedSchemaModel } from "./types.js";
|
|
12
|
+
import { AnySchemaModel } from "@contractspec/lib.schema";
|
|
13
|
+
|
|
14
|
+
//#region src/serialization/serializers.d.ts
|
|
15
|
+
/**
|
|
16
|
+
* Serialize a SchemaModel to a plain JSON object.
|
|
17
|
+
*/
|
|
18
|
+
declare function serializeSchemaModel(model: AnySchemaModel | ResourceRefDescriptor<boolean> | null | undefined): SerializedSchemaModel | null;
|
|
19
|
+
/**
|
|
20
|
+
* Serialize an OperationSpec to a plain JSON object.
|
|
21
|
+
*/
|
|
22
|
+
declare function serializeOperationSpec(spec: AnyOperationSpec | null | undefined): SerializedOperationSpec | null;
|
|
23
|
+
/**
|
|
24
|
+
* Serialize an EventSpec to a plain JSON object.
|
|
25
|
+
*/
|
|
26
|
+
declare function serializeEventSpec(spec: AnyEventSpec | null | undefined): SerializedEventSpec | null;
|
|
27
|
+
/**
|
|
28
|
+
* Serialize a PresentationSpec to a plain JSON object.
|
|
29
|
+
*/
|
|
30
|
+
declare function serializePresentationSpec(spec: PresentationSpec | null | undefined): SerializedPresentationSpec | null;
|
|
31
|
+
/**
|
|
32
|
+
* Serialize a DataViewSpec to a plain JSON object.
|
|
33
|
+
*/
|
|
34
|
+
declare function serializeDataViewSpec(spec: DataViewSpec | null | undefined): SerializedDataViewSpec | null;
|
|
35
|
+
/**
|
|
36
|
+
* Serialize a FormSpec to a plain JSON object.
|
|
37
|
+
*/
|
|
38
|
+
declare function serializeFormSpec(spec: FormSpec | null | undefined): SerializedFormSpec | null;
|
|
39
|
+
//#endregion
|
|
40
|
+
export { serializeDataViewSpec, serializeEventSpec, serializeFormSpec, serializeOperationSpec, serializePresentationSpec, serializeSchemaModel };
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
//#region src/serialization/serializers.ts
|
|
2
|
+
/**
|
|
3
|
+
* Type guard to check if a value is a ResourceRefDescriptor.
|
|
4
|
+
*/
|
|
5
|
+
function isResourceRefDescriptor(value) {
|
|
6
|
+
return typeof value === "object" && value !== null && "kind" in value && value.kind === "resource_ref";
|
|
7
|
+
}
|
|
8
|
+
function getTypeName(type) {
|
|
9
|
+
if (!type) return "unknown";
|
|
10
|
+
if (typeof type === "string") return type;
|
|
11
|
+
if (typeof type === "object") {
|
|
12
|
+
if ("config" in type && type.config?.name) return type.config.name;
|
|
13
|
+
if ("name" in type && typeof type.name === "string") return type.name;
|
|
14
|
+
}
|
|
15
|
+
return "unknown";
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Serialize a SchemaModel to a plain JSON object.
|
|
19
|
+
*/
|
|
20
|
+
function serializeSchemaModel(model) {
|
|
21
|
+
if (!model) return null;
|
|
22
|
+
if (isResourceRefDescriptor(model)) return {
|
|
23
|
+
name: `ResourceRef<${model.graphQLType}>`,
|
|
24
|
+
description: `Reference to ${model.graphQLType} resource (${model.uriTemplate})`,
|
|
25
|
+
fields: {}
|
|
26
|
+
};
|
|
27
|
+
if ("config" in model && model.config) {
|
|
28
|
+
const config = model.config;
|
|
29
|
+
return {
|
|
30
|
+
name: config.name,
|
|
31
|
+
description: config.description,
|
|
32
|
+
fields: Object.fromEntries(Object.entries(config.fields).map(([key, field]) => [key, {
|
|
33
|
+
typeName: getTypeName(field.type),
|
|
34
|
+
isOptional: field.isOptional,
|
|
35
|
+
isArray: field.isArray
|
|
36
|
+
}]))
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
name: "unknown",
|
|
41
|
+
fields: {}
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Serialize an OperationSpec to a plain JSON object.
|
|
46
|
+
*/
|
|
47
|
+
function serializeOperationSpec(spec) {
|
|
48
|
+
if (!spec) return null;
|
|
49
|
+
return {
|
|
50
|
+
meta: {
|
|
51
|
+
key: spec.meta.key,
|
|
52
|
+
version: spec.meta.version,
|
|
53
|
+
stability: spec.meta.stability,
|
|
54
|
+
owners: spec.meta.owners,
|
|
55
|
+
tags: spec.meta.tags,
|
|
56
|
+
description: spec.meta.description,
|
|
57
|
+
goal: spec.meta.goal,
|
|
58
|
+
context: spec.meta.context
|
|
59
|
+
},
|
|
60
|
+
io: {
|
|
61
|
+
input: serializeSchemaModel(spec.io.input),
|
|
62
|
+
output: serializeSchemaModel(spec.io.output)
|
|
63
|
+
},
|
|
64
|
+
policy: spec.policy ? { auth: spec.policy.auth } : void 0
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Serialize an EventSpec to a plain JSON object.
|
|
69
|
+
*/
|
|
70
|
+
function serializeEventSpec(spec) {
|
|
71
|
+
if (!spec) return null;
|
|
72
|
+
return {
|
|
73
|
+
meta: {
|
|
74
|
+
key: spec.meta.key,
|
|
75
|
+
version: spec.meta.version,
|
|
76
|
+
stability: spec.meta.stability,
|
|
77
|
+
owners: spec.meta.owners,
|
|
78
|
+
tags: spec.meta.tags,
|
|
79
|
+
description: spec.meta.description
|
|
80
|
+
},
|
|
81
|
+
payload: serializeSchemaModel(spec.payload)
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Serialize a PresentationSpec to a plain JSON object.
|
|
86
|
+
*/
|
|
87
|
+
function serializePresentationSpec(spec) {
|
|
88
|
+
if (!spec) return null;
|
|
89
|
+
return {
|
|
90
|
+
meta: {
|
|
91
|
+
key: spec.meta.key,
|
|
92
|
+
version: spec.meta.version,
|
|
93
|
+
stability: spec.meta.stability,
|
|
94
|
+
owners: spec.meta.owners,
|
|
95
|
+
tags: spec.meta.tags,
|
|
96
|
+
description: spec.meta.description,
|
|
97
|
+
goal: spec.meta.goal,
|
|
98
|
+
context: spec.meta.context
|
|
99
|
+
},
|
|
100
|
+
source: {
|
|
101
|
+
type: spec.source.type,
|
|
102
|
+
framework: spec.source.type === "component" ? spec.source.framework : void 0,
|
|
103
|
+
componentKey: spec.source.type === "component" ? spec.source.componentKey : void 0
|
|
104
|
+
},
|
|
105
|
+
targets: spec.targets
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Serialize a DataViewSpec to a plain JSON object.
|
|
110
|
+
*/
|
|
111
|
+
function serializeDataViewSpec(spec) {
|
|
112
|
+
if (!spec) return null;
|
|
113
|
+
return {
|
|
114
|
+
meta: {
|
|
115
|
+
key: spec.meta.key,
|
|
116
|
+
version: spec.meta.version,
|
|
117
|
+
stability: spec.meta.stability,
|
|
118
|
+
owners: spec.meta.owners,
|
|
119
|
+
tags: spec.meta.tags,
|
|
120
|
+
description: spec.meta.description,
|
|
121
|
+
title: spec.meta.title
|
|
122
|
+
},
|
|
123
|
+
source: spec.source,
|
|
124
|
+
view: spec.view
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Serialize a FormSpec to a plain JSON object.
|
|
129
|
+
*/
|
|
130
|
+
function serializeFormSpec(spec) {
|
|
131
|
+
if (!spec) return null;
|
|
132
|
+
return {
|
|
133
|
+
meta: {
|
|
134
|
+
key: spec.meta.key,
|
|
135
|
+
version: spec.meta.version,
|
|
136
|
+
stability: spec.meta.stability,
|
|
137
|
+
owners: spec.meta.owners,
|
|
138
|
+
tags: spec.meta.tags,
|
|
139
|
+
description: spec.meta.description,
|
|
140
|
+
title: spec.meta.title
|
|
141
|
+
},
|
|
142
|
+
fields: spec.fields,
|
|
143
|
+
actions: spec.actions
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
//#endregion
|
|
148
|
+
export { serializeDataViewSpec, serializeEventSpec, serializeFormSpec, serializeOperationSpec, serializePresentationSpec, serializeSchemaModel };
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
//#region src/serialization/types.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Serialized types for Server -> Client Component transfer.
|
|
4
|
+
*
|
|
5
|
+
* These are plain JSON-serializable versions of spec types that can be
|
|
6
|
+
* safely passed from Server Components to Client Components in Next.js.
|
|
7
|
+
*/
|
|
8
|
+
/** Serialized schema model that can be passed to client components */
|
|
9
|
+
interface SerializedSchemaModel {
|
|
10
|
+
name: string;
|
|
11
|
+
description?: string | null;
|
|
12
|
+
fields: Record<string, SerializedFieldConfig>;
|
|
13
|
+
}
|
|
14
|
+
interface SerializedFieldConfig {
|
|
15
|
+
typeName: string;
|
|
16
|
+
isOptional: boolean;
|
|
17
|
+
isArray?: boolean;
|
|
18
|
+
}
|
|
19
|
+
/** Serialized operation spec for client components */
|
|
20
|
+
interface SerializedOperationSpec {
|
|
21
|
+
meta: {
|
|
22
|
+
key: string;
|
|
23
|
+
version: string;
|
|
24
|
+
stability?: string;
|
|
25
|
+
owners?: string[];
|
|
26
|
+
tags?: string[];
|
|
27
|
+
description?: string;
|
|
28
|
+
goal?: string;
|
|
29
|
+
context?: string;
|
|
30
|
+
};
|
|
31
|
+
io: {
|
|
32
|
+
input: SerializedSchemaModel | null;
|
|
33
|
+
output: SerializedSchemaModel | null;
|
|
34
|
+
};
|
|
35
|
+
policy?: {
|
|
36
|
+
auth?: string;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/** Serialized event spec for client components */
|
|
40
|
+
interface SerializedEventSpec {
|
|
41
|
+
meta: {
|
|
42
|
+
key: string;
|
|
43
|
+
version: string;
|
|
44
|
+
stability?: string;
|
|
45
|
+
owners?: string[];
|
|
46
|
+
tags?: string[];
|
|
47
|
+
description?: string;
|
|
48
|
+
};
|
|
49
|
+
payload: SerializedSchemaModel | null;
|
|
50
|
+
}
|
|
51
|
+
/** Serialized presentation spec for client components */
|
|
52
|
+
interface SerializedPresentationSpec {
|
|
53
|
+
meta: {
|
|
54
|
+
key: string;
|
|
55
|
+
version: string;
|
|
56
|
+
stability?: string;
|
|
57
|
+
owners?: string[];
|
|
58
|
+
tags?: string[];
|
|
59
|
+
description?: string;
|
|
60
|
+
goal?: string;
|
|
61
|
+
context?: string;
|
|
62
|
+
};
|
|
63
|
+
source: {
|
|
64
|
+
type: string;
|
|
65
|
+
framework?: string;
|
|
66
|
+
componentKey?: string;
|
|
67
|
+
};
|
|
68
|
+
targets?: string[];
|
|
69
|
+
}
|
|
70
|
+
/** Serialized data view spec for client components */
|
|
71
|
+
interface SerializedDataViewSpec {
|
|
72
|
+
meta: {
|
|
73
|
+
key: string;
|
|
74
|
+
version: string;
|
|
75
|
+
stability?: string;
|
|
76
|
+
owners?: string[];
|
|
77
|
+
tags?: string[];
|
|
78
|
+
description?: string;
|
|
79
|
+
title?: string;
|
|
80
|
+
};
|
|
81
|
+
/** Serialized source configuration */
|
|
82
|
+
source?: unknown;
|
|
83
|
+
/** Serialized view configuration */
|
|
84
|
+
view?: unknown;
|
|
85
|
+
}
|
|
86
|
+
/** Serialized form spec for client components */
|
|
87
|
+
interface SerializedFormSpec {
|
|
88
|
+
meta: {
|
|
89
|
+
key: string;
|
|
90
|
+
version?: string;
|
|
91
|
+
stability?: string;
|
|
92
|
+
owners?: string[];
|
|
93
|
+
tags?: string[];
|
|
94
|
+
description?: string;
|
|
95
|
+
title?: string;
|
|
96
|
+
};
|
|
97
|
+
/** Serialized form fields (passed through for display) */
|
|
98
|
+
fields?: unknown;
|
|
99
|
+
/** Serialized form actions (passed through for display) */
|
|
100
|
+
actions?: unknown;
|
|
101
|
+
}
|
|
102
|
+
//#endregion
|
|
103
|
+
export { SerializedDataViewSpec, SerializedEventSpec, SerializedFieldConfig, SerializedFormSpec, SerializedOperationSpec, SerializedPresentationSpec, SerializedSchemaModel };
|
|
File without changes
|
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
|
}
|