@contractspec/lib.contracts 1.44.0 → 1.45.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/README.md +1 -1
- package/dist/app-config/app-config.feature.js +6 -6
- package/dist/app-config/contracts.d.ts +50 -50
- package/dist/app-config/contracts.js +13 -13
- package/dist/app-config/events.d.ts +27 -27
- package/dist/app-config/events.js +12 -12
- package/dist/app-config/lifecycle-contracts.d.ts +54 -54
- package/dist/app-config/lifecycle-contracts.js +19 -19
- package/dist/app-config/lifecycle.d.ts +2 -2
- package/dist/app-config/runtime.d.ts +3 -3
- package/dist/app-config/spec.d.ts +10 -12
- package/dist/app-config/spec.js +5 -26
- package/dist/capabilities/capabilities.d.ts +4 -11
- package/dist/capabilities/capabilities.js +3 -5
- package/dist/capabilities/openbanking.js +10 -10
- package/dist/client/react/form-render.js +1 -0
- package/dist/contract-registry/schemas.d.ts +8 -8
- package/dist/contract-registry/schemas.js +1 -1
- package/dist/contract-registry/types.d.ts +1 -1
- package/dist/data-views/data-views.js +1 -0
- package/dist/data-views/registry.d.ts +3 -37
- package/dist/data-views/registry.js +4 -66
- package/dist/data-views/runtime.d.ts +1 -1
- package/dist/data-views/runtime.js +2 -0
- package/dist/data-views/spec.d.ts +2 -2
- package/dist/docs/index.d.ts +2 -2
- package/dist/docs/index.js +2 -2
- package/dist/docs/presentations.d.ts +2 -4
- package/dist/docs/presentations.js +2 -4
- package/dist/docs/tech/contracts/ops-to-presentation-linking.docblock.js +1 -1
- package/dist/docs/tech/contracts/tests.docblock.js +1 -1
- package/dist/docs/tech/lifecycle-stage-system.docblock.js +1 -1
- package/dist/docs/tech-contracts.docs.js +1 -1
- package/dist/docs/types.d.ts +1 -1
- package/dist/events.d.ts +3 -3
- package/dist/examples/docs/examples.docblock.d.ts +6 -0
- package/dist/examples/docs/examples.docblock.js +165 -0
- package/dist/examples/index.d.ts +5 -0
- package/dist/examples/index.js +6 -0
- package/dist/examples/registry.d.ts +65 -0
- package/dist/examples/registry.js +144 -0
- package/dist/examples/schema.d.ts +282 -0
- package/dist/examples/schema.js +125 -0
- package/dist/examples/types.d.ts +167 -0
- package/dist/examples/types.js +43 -0
- package/dist/examples/validation.d.ts +65 -0
- package/dist/examples/validation.js +144 -0
- package/dist/experiments/docs/experiments.docblock.js +1 -1
- package/dist/experiments/evaluator.d.ts +1 -1
- package/dist/experiments/spec-resolver.d.ts +2 -2
- package/dist/experiments/spec.d.ts +6 -8
- package/dist/experiments/spec.js +5 -23
- package/dist/features/index.d.ts +9 -1
- package/dist/features/index.js +8 -1
- package/dist/features/install.js +2 -2
- package/dist/features/types.d.ts +7 -7
- package/dist/forms/forms.d.ts +2 -2
- package/dist/forms/forms.js +3 -6
- package/dist/index.d.ts +13 -8
- package/dist/index.js +11 -2
- package/dist/install.d.ts +9 -9
- package/dist/integrations/connection.d.ts +1 -1
- package/dist/integrations/docs/integrations.docblock.js +1 -1
- package/dist/integrations/integrations.feature.js +8 -8
- package/dist/integrations/openbanking/contracts/accounts.d.ts +66 -66
- package/dist/integrations/openbanking/contracts/accounts.js +3 -3
- package/dist/integrations/openbanking/contracts/balances.d.ts +34 -34
- package/dist/integrations/openbanking/contracts/balances.js +2 -2
- package/dist/integrations/openbanking/contracts/transactions.d.ts +48 -48
- package/dist/integrations/openbanking/contracts/transactions.js +2 -2
- package/dist/integrations/openbanking/models.d.ts +55 -55
- package/dist/integrations/openbanking/openbanking.feature.js +10 -10
- package/dist/integrations/operations.d.ts +102 -102
- package/dist/integrations/operations.js +10 -10
- package/dist/integrations/providers/elevenlabs.js +2 -2
- package/dist/integrations/providers/gcs-storage.js +2 -2
- package/dist/integrations/providers/gmail.js +3 -3
- package/dist/integrations/providers/google-calendar.js +2 -2
- package/dist/integrations/providers/mistral.js +3 -3
- package/dist/integrations/providers/postmark.js +2 -2
- package/dist/integrations/providers/powens.js +4 -4
- package/dist/integrations/providers/qdrant.js +3 -3
- package/dist/integrations/providers/stripe.js +2 -2
- package/dist/integrations/providers/twilio-sms.js +2 -2
- package/dist/integrations/runtime.d.ts +5 -5
- package/dist/integrations/spec.d.ts +3 -5
- package/dist/integrations/spec.js +5 -26
- package/dist/jobs/gcp-cloud-tasks.js +1 -1
- package/dist/jobs/gcp-pubsub.js +1 -1
- package/dist/jobs/handlers/ping-handler.d.ts +3 -3
- package/dist/jobs/handlers/ping-handler.js +2 -2
- package/dist/jobs/memory-queue.js +1 -1
- package/dist/jobs/queue.d.ts +4 -4
- package/dist/jobs/scaleway-sqs-queue.js +2 -2
- package/dist/jsonschema.d.ts +4 -4
- package/dist/knowledge/binding.d.ts +1 -1
- package/dist/knowledge/knowledge.feature.js +8 -8
- package/dist/knowledge/operations.d.ts +66 -66
- package/dist/knowledge/operations.js +12 -12
- package/dist/knowledge/source.d.ts +1 -1
- package/dist/knowledge/spaces/email-threads.js +2 -2
- package/dist/knowledge/spaces/financial-docs.js +2 -2
- package/dist/knowledge/spaces/financial-overview.js +2 -2
- package/dist/knowledge/spaces/product-canon.js +2 -2
- package/dist/knowledge/spaces/support-faq.js +2 -2
- package/dist/knowledge/spaces/uploaded-docs.js +2 -2
- package/dist/knowledge/spec.d.ts +3 -5
- package/dist/knowledge/spec.js +6 -28
- package/dist/llm/exporters.js +2 -2
- package/dist/llm/types.d.ts +4 -4
- package/dist/markdown.js +1 -1
- package/dist/migrations.d.ts +2 -2
- package/dist/migrations.js +7 -9
- package/dist/onboarding-base.d.ts +29 -29
- package/dist/onboarding-base.js +4 -4
- package/dist/openapi.js +9 -2
- package/dist/operations/operation.d.ts +3 -3
- package/dist/operations/registry.d.ts +9 -58
- package/dist/operations/registry.js +17 -93
- package/dist/ownership.d.ts +1 -1
- package/dist/policy/docs/policy.docblock.js +1 -1
- package/dist/policy/engine.js +2 -0
- package/dist/policy/spec.d.ts +1 -1
- package/dist/prompt.d.ts +6 -6
- package/dist/promptRegistry.d.ts +4 -4
- package/dist/promptRegistry.js +2 -5
- package/dist/regenerator/docs/regenerator.docblock.js +1 -1
- package/dist/regenerator/types.d.ts +1 -1
- package/dist/registry.d.ts +3 -2
- package/dist/registry.js +5 -5
- package/dist/resources.d.ts +5 -5
- package/dist/server/graphql-pothos.js +2 -2
- package/dist/server/mcp/registerTools.js +1 -1
- package/dist/server/rest-elysia.d.ts +1 -1
- package/dist/server/rest-elysia.js +1 -1
- package/dist/server/rest-express.d.ts +1 -1
- package/dist/server/rest-express.js +1 -1
- package/dist/server/rest-generic.d.ts +1 -1
- package/dist/server/rest-generic.js +1 -1
- package/dist/server/rest-next-app.d.ts +1 -1
- package/dist/server/rest-next-mcp.d.ts +1 -1
- package/dist/server/rest-next-mcp.js +1 -1
- package/dist/server/rest-next-pages.d.ts +1 -1
- package/dist/telemetry/docs/telemetry.docblock.js +1 -1
- package/dist/telemetry/spec.d.ts +7 -7
- package/dist/telemetry/spec.js +17 -44
- package/dist/telemetry/tracker.d.ts +2 -2
- package/dist/tests/runner.d.ts +1 -1
- package/dist/tests/spec.d.ts +5 -5
- package/dist/tests/spec.js +3 -5
- package/dist/themes.d.ts +4 -6
- package/dist/themes.js +5 -27
- package/dist/translations/catalog.d.ts +1 -1
- package/dist/types.d.ts +5 -5
- package/dist/workflow/adapters/db-adapter.js +3 -3
- package/dist/workflow/runner.d.ts +4 -2
- package/dist/workflow/spec.d.ts +4 -17
- package/dist/workflow/spec.js +4 -48
- package/dist/workflow/state.d.ts +1 -1
- package/dist/workflow/validation.js +1 -1
- package/dist/workspace-config/contractsrc-schema.d.ts +419 -419
- package/dist/workspace-config/contractsrc-schema.js +86 -86
- package/package.json +28 -12
package/dist/llm/exporters.js
CHANGED
|
@@ -326,7 +326,7 @@ function featureToMarkdown(feature, deps, options = {}) {
|
|
|
326
326
|
lines.push("| Name | Version | Type |");
|
|
327
327
|
lines.push("|------|---------|------|");
|
|
328
328
|
for (const op of feature.operations) {
|
|
329
|
-
const kind = (deps?.specs?.
|
|
329
|
+
const kind = (deps?.specs?.get(op.key, op.version))?.meta.kind ?? "unknown";
|
|
330
330
|
lines.push(`| ${op.key} | v${op.version} | ${kind} |`);
|
|
331
331
|
}
|
|
332
332
|
lines.push("");
|
|
@@ -334,7 +334,7 @@ function featureToMarkdown(feature, deps, options = {}) {
|
|
|
334
334
|
lines.push("### Operation Details");
|
|
335
335
|
lines.push("");
|
|
336
336
|
for (const op of feature.operations) {
|
|
337
|
-
const spec = deps.specs.
|
|
337
|
+
const spec = deps.specs.get(op.key, op.version);
|
|
338
338
|
if (spec) {
|
|
339
339
|
lines.push(`---`);
|
|
340
340
|
lines.push("");
|
package/dist/llm/types.d.ts
CHANGED
|
@@ -50,7 +50,7 @@ interface SpecExportResult {
|
|
|
50
50
|
/** Metadata about the export */
|
|
51
51
|
meta: {
|
|
52
52
|
specName: string;
|
|
53
|
-
specVersion:
|
|
53
|
+
specVersion: string;
|
|
54
54
|
exportedAt: string;
|
|
55
55
|
wordCount: number;
|
|
56
56
|
};
|
|
@@ -76,7 +76,7 @@ interface ImplementationPlan {
|
|
|
76
76
|
target: {
|
|
77
77
|
type: 'spec' | 'feature' | 'presentation';
|
|
78
78
|
key: string;
|
|
79
|
-
version:
|
|
79
|
+
version: string;
|
|
80
80
|
};
|
|
81
81
|
/** Context section */
|
|
82
82
|
context: {
|
|
@@ -155,7 +155,7 @@ interface VerificationReport {
|
|
|
155
155
|
/** Metadata about the verification */
|
|
156
156
|
meta: {
|
|
157
157
|
specName: string;
|
|
158
|
-
specVersion:
|
|
158
|
+
specVersion: string;
|
|
159
159
|
implementationPath: string;
|
|
160
160
|
verifiedAt: string;
|
|
161
161
|
duration: number;
|
|
@@ -179,7 +179,7 @@ interface AgentPrompt {
|
|
|
179
179
|
/** Input for spec lookup */
|
|
180
180
|
interface SpecLookup {
|
|
181
181
|
name: string;
|
|
182
|
-
version?:
|
|
182
|
+
version?: string;
|
|
183
183
|
}
|
|
184
184
|
/** Input for feature lookup */
|
|
185
185
|
interface FeatureLookup {
|
package/dist/markdown.js
CHANGED
|
@@ -8,7 +8,7 @@ import "./operations/index.js";
|
|
|
8
8
|
*/
|
|
9
9
|
function operationsToMarkdown(registry, _extras) {
|
|
10
10
|
const lines = [];
|
|
11
|
-
for (const spec of registry.
|
|
11
|
+
for (const spec of registry.list()) {
|
|
12
12
|
const m = spec.meta;
|
|
13
13
|
lines.push(`# ${m.key}.v${m.version}`);
|
|
14
14
|
lines.push("");
|
package/dist/migrations.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ interface MigrationMeta extends OwnerShipMeta {
|
|
|
31
31
|
/** Fully qualified migration name (e.g., "sigil.db.2025_01_add_users"). */
|
|
32
32
|
key: string;
|
|
33
33
|
/** Increment when the migration changes. */
|
|
34
|
-
version:
|
|
34
|
+
version: string;
|
|
35
35
|
}
|
|
36
36
|
interface MigrationPlan {
|
|
37
37
|
up: MigrationStep[];
|
|
@@ -46,7 +46,7 @@ declare class MigrationRegistry {
|
|
|
46
46
|
private readonly items;
|
|
47
47
|
register(spec: MigrationSpec): this;
|
|
48
48
|
list(): MigrationSpec[];
|
|
49
|
-
get(name: string, version?:
|
|
49
|
+
get(name: string, version?: string): MigrationSpec | undefined;
|
|
50
50
|
}
|
|
51
51
|
//#endregion
|
|
52
52
|
export { DataMigrationStep, MigrationCheck, MigrationMeta, MigrationPlan, MigrationRegistry, MigrationSpec, MigrationStep, MigrationStepBase, MigrationStepKind, SchemaMigrationStep, ValidationMigrationStep };
|
package/dist/migrations.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { compareVersions } from "compare-versions";
|
|
2
|
+
|
|
1
3
|
//#region src/migrations.ts
|
|
2
4
|
const migrationKey = (name, version) => `${name}.v${version}`;
|
|
3
5
|
var MigrationRegistry = class {
|
|
@@ -9,25 +11,21 @@ var MigrationRegistry = class {
|
|
|
9
11
|
return this;
|
|
10
12
|
}
|
|
11
13
|
list() {
|
|
12
|
-
return [...this.items.values()].sort((a, b) =>
|
|
14
|
+
return [...this.items.values()].sort((a, b) => {
|
|
15
|
+
const byName = a.meta.key.localeCompare(b.meta.key);
|
|
16
|
+
return byName !== 0 ? byName : compareVersions(a.meta.version, b.meta.version);
|
|
17
|
+
});
|
|
13
18
|
}
|
|
14
19
|
get(name, version) {
|
|
15
20
|
if (version != null) return this.items.get(migrationKey(name, version));
|
|
16
21
|
let candidate;
|
|
17
|
-
let max = -Infinity;
|
|
18
22
|
for (const spec of this.items.values()) {
|
|
19
23
|
if (spec.meta.key !== name) continue;
|
|
20
|
-
if (spec.meta.version >
|
|
21
|
-
max = spec.meta.version;
|
|
22
|
-
candidate = spec;
|
|
23
|
-
}
|
|
24
|
+
if (!candidate || compareVersions(spec.meta.version, candidate.meta.version) > 0) candidate = spec;
|
|
24
25
|
}
|
|
25
26
|
return candidate;
|
|
26
27
|
}
|
|
27
28
|
};
|
|
28
|
-
function compareKey(a, b) {
|
|
29
|
-
return a < b ? -1 : a > b ? 1 : 0;
|
|
30
|
-
}
|
|
31
29
|
|
|
32
30
|
//#endregion
|
|
33
31
|
export { MigrationRegistry };
|
|
@@ -1,136 +1,136 @@
|
|
|
1
1
|
import { OperationSpec } from "./operations/operation.js";
|
|
2
2
|
import "./index.js";
|
|
3
|
-
import * as
|
|
3
|
+
import * as _contractspec_lib_schema0 from "@contractspec/lib.schema";
|
|
4
4
|
import { SchemaModel } from "@contractspec/lib.schema";
|
|
5
5
|
|
|
6
6
|
//#region src/onboarding-base.d.ts
|
|
7
7
|
/** Save/update onboarding draft (auto-save during flow) */
|
|
8
8
|
declare const SaveOnboardingDraftInput: SchemaModel<{
|
|
9
9
|
data: {
|
|
10
|
-
type:
|
|
10
|
+
type: _contractspec_lib_schema0.FieldType<unknown, unknown>;
|
|
11
11
|
isOptional: false;
|
|
12
12
|
};
|
|
13
13
|
}>;
|
|
14
14
|
declare const SaveOnboardingDraftOutput: SchemaModel<{
|
|
15
15
|
id: {
|
|
16
|
-
type:
|
|
16
|
+
type: _contractspec_lib_schema0.FieldType<string, string>;
|
|
17
17
|
isOptional: false;
|
|
18
18
|
};
|
|
19
19
|
organizationId: {
|
|
20
|
-
type:
|
|
20
|
+
type: _contractspec_lib_schema0.FieldType<string, string>;
|
|
21
21
|
isOptional: false;
|
|
22
22
|
};
|
|
23
23
|
}>;
|
|
24
24
|
declare const SaveOnboardingDraftBaseSpec: OperationSpec<SchemaModel<{
|
|
25
25
|
data: {
|
|
26
|
-
type:
|
|
26
|
+
type: _contractspec_lib_schema0.FieldType<unknown, unknown>;
|
|
27
27
|
isOptional: false;
|
|
28
28
|
};
|
|
29
29
|
}>, SchemaModel<{
|
|
30
30
|
id: {
|
|
31
|
-
type:
|
|
31
|
+
type: _contractspec_lib_schema0.FieldType<string, string>;
|
|
32
32
|
isOptional: false;
|
|
33
33
|
};
|
|
34
34
|
organizationId: {
|
|
35
|
-
type:
|
|
35
|
+
type: _contractspec_lib_schema0.FieldType<string, string>;
|
|
36
36
|
isOptional: false;
|
|
37
37
|
};
|
|
38
38
|
}>, undefined>;
|
|
39
39
|
/** Get current onboarding draft (on mount/restore) */
|
|
40
40
|
declare const GetOnboardingDraftOutput: SchemaModel<{
|
|
41
41
|
id: {
|
|
42
|
-
type:
|
|
42
|
+
type: _contractspec_lib_schema0.FieldType<string, string>;
|
|
43
43
|
isOptional: true;
|
|
44
44
|
};
|
|
45
45
|
organizationId: {
|
|
46
|
-
type:
|
|
46
|
+
type: _contractspec_lib_schema0.FieldType<string, string>;
|
|
47
47
|
isOptional: true;
|
|
48
48
|
};
|
|
49
49
|
data: {
|
|
50
|
-
type:
|
|
50
|
+
type: _contractspec_lib_schema0.FieldType<unknown, unknown>;
|
|
51
51
|
isOptional: true;
|
|
52
52
|
};
|
|
53
53
|
createdAt: {
|
|
54
|
-
type:
|
|
54
|
+
type: _contractspec_lib_schema0.FieldType<Date, string>;
|
|
55
55
|
isOptional: true;
|
|
56
56
|
};
|
|
57
57
|
updatedAt: {
|
|
58
|
-
type:
|
|
58
|
+
type: _contractspec_lib_schema0.FieldType<Date, string>;
|
|
59
59
|
isOptional: true;
|
|
60
60
|
};
|
|
61
61
|
}>;
|
|
62
|
-
declare const GetOnboardingDraftBaseSpec: OperationSpec<
|
|
62
|
+
declare const GetOnboardingDraftBaseSpec: OperationSpec<_contractspec_lib_schema0.AnySchemaModel, SchemaModel<{
|
|
63
63
|
id: {
|
|
64
|
-
type:
|
|
64
|
+
type: _contractspec_lib_schema0.FieldType<string, string>;
|
|
65
65
|
isOptional: true;
|
|
66
66
|
};
|
|
67
67
|
organizationId: {
|
|
68
|
-
type:
|
|
68
|
+
type: _contractspec_lib_schema0.FieldType<string, string>;
|
|
69
69
|
isOptional: true;
|
|
70
70
|
};
|
|
71
71
|
data: {
|
|
72
|
-
type:
|
|
72
|
+
type: _contractspec_lib_schema0.FieldType<unknown, unknown>;
|
|
73
73
|
isOptional: true;
|
|
74
74
|
};
|
|
75
75
|
createdAt: {
|
|
76
|
-
type:
|
|
76
|
+
type: _contractspec_lib_schema0.FieldType<Date, string>;
|
|
77
77
|
isOptional: true;
|
|
78
78
|
};
|
|
79
79
|
updatedAt: {
|
|
80
|
-
type:
|
|
80
|
+
type: _contractspec_lib_schema0.FieldType<Date, string>;
|
|
81
81
|
isOptional: true;
|
|
82
82
|
};
|
|
83
83
|
}>, undefined>;
|
|
84
84
|
/** Delete onboarding draft (cleanup after completion or cancel) */
|
|
85
85
|
declare const DeleteOnboardingDraftOutput: SchemaModel<{
|
|
86
86
|
ok: {
|
|
87
|
-
type:
|
|
87
|
+
type: _contractspec_lib_schema0.FieldType<boolean, boolean>;
|
|
88
88
|
isOptional: false;
|
|
89
89
|
};
|
|
90
90
|
}>;
|
|
91
|
-
declare const DeleteOnboardingDraftBaseSpec: OperationSpec<
|
|
91
|
+
declare const DeleteOnboardingDraftBaseSpec: OperationSpec<_contractspec_lib_schema0.AnySchemaModel, SchemaModel<{
|
|
92
92
|
ok: {
|
|
93
|
-
type:
|
|
93
|
+
type: _contractspec_lib_schema0.FieldType<boolean, boolean>;
|
|
94
94
|
isOptional: false;
|
|
95
95
|
};
|
|
96
96
|
}>, undefined>;
|
|
97
97
|
/** Complete onboarding (final submit, creates entities) */
|
|
98
98
|
declare const CompleteOnboardingBaseInput: SchemaModel<{
|
|
99
99
|
data: {
|
|
100
|
-
type:
|
|
100
|
+
type: _contractspec_lib_schema0.FieldType<unknown, unknown>;
|
|
101
101
|
isOptional: false;
|
|
102
102
|
};
|
|
103
103
|
}>;
|
|
104
104
|
declare const CompleteOnboardingBaseOutput: SchemaModel<{
|
|
105
105
|
success: {
|
|
106
|
-
type:
|
|
106
|
+
type: _contractspec_lib_schema0.FieldType<boolean, boolean>;
|
|
107
107
|
isOptional: false;
|
|
108
108
|
};
|
|
109
109
|
userId: {
|
|
110
|
-
type:
|
|
110
|
+
type: _contractspec_lib_schema0.FieldType<string, string>;
|
|
111
111
|
isOptional: true;
|
|
112
112
|
};
|
|
113
113
|
organizationId: {
|
|
114
|
-
type:
|
|
114
|
+
type: _contractspec_lib_schema0.FieldType<string, string>;
|
|
115
115
|
isOptional: true;
|
|
116
116
|
};
|
|
117
117
|
}>;
|
|
118
118
|
declare const CompleteOnboardingBaseSpec: OperationSpec<SchemaModel<{
|
|
119
119
|
data: {
|
|
120
|
-
type:
|
|
120
|
+
type: _contractspec_lib_schema0.FieldType<unknown, unknown>;
|
|
121
121
|
isOptional: false;
|
|
122
122
|
};
|
|
123
123
|
}>, SchemaModel<{
|
|
124
124
|
success: {
|
|
125
|
-
type:
|
|
125
|
+
type: _contractspec_lib_schema0.FieldType<boolean, boolean>;
|
|
126
126
|
isOptional: false;
|
|
127
127
|
};
|
|
128
128
|
userId: {
|
|
129
|
-
type:
|
|
129
|
+
type: _contractspec_lib_schema0.FieldType<string, string>;
|
|
130
130
|
isOptional: true;
|
|
131
131
|
};
|
|
132
132
|
organizationId: {
|
|
133
|
-
type:
|
|
133
|
+
type: _contractspec_lib_schema0.FieldType<string, string>;
|
|
134
134
|
isOptional: true;
|
|
135
135
|
};
|
|
136
136
|
}>, undefined>;
|
package/dist/onboarding-base.js
CHANGED
|
@@ -34,7 +34,7 @@ const SaveOnboardingDraftOutput = new SchemaModel({
|
|
|
34
34
|
const SaveOnboardingDraftBaseSpec = defineCommand({
|
|
35
35
|
meta: {
|
|
36
36
|
key: "base.onboarding.saveDraft",
|
|
37
|
-
version: 1,
|
|
37
|
+
version: "1.0.0",
|
|
38
38
|
stability: StabilityEnum.Beta,
|
|
39
39
|
owners: [OwnersEnum.PlatformSigil],
|
|
40
40
|
tags: ["onboarding", "draft"],
|
|
@@ -85,7 +85,7 @@ const GetOnboardingDraftOutput = new SchemaModel({
|
|
|
85
85
|
const GetOnboardingDraftBaseSpec = defineQuery({
|
|
86
86
|
meta: {
|
|
87
87
|
key: "base.onboarding.getDraft",
|
|
88
|
-
version: 1,
|
|
88
|
+
version: "1.0.0",
|
|
89
89
|
stability: StabilityEnum.Beta,
|
|
90
90
|
owners: [OwnersEnum.PlatformSigil],
|
|
91
91
|
tags: ["onboarding", "draft"],
|
|
@@ -118,7 +118,7 @@ const DeleteOnboardingDraftOutput = new SchemaModel({
|
|
|
118
118
|
const DeleteOnboardingDraftBaseSpec = defineCommand({
|
|
119
119
|
meta: {
|
|
120
120
|
key: "base.onboarding.deleteDraft",
|
|
121
|
-
version: 1,
|
|
121
|
+
version: "1.0.0",
|
|
122
122
|
stability: StabilityEnum.Beta,
|
|
123
123
|
owners: [OwnersEnum.PlatformSigil],
|
|
124
124
|
tags: ["onboarding", "draft"],
|
|
@@ -169,7 +169,7 @@ const CompleteOnboardingBaseOutput = new SchemaModel({
|
|
|
169
169
|
const CompleteOnboardingBaseSpec = defineCommand({
|
|
170
170
|
meta: {
|
|
171
171
|
key: "base.onboarding.complete",
|
|
172
|
-
version: 1,
|
|
172
|
+
version: "1.0.0",
|
|
173
173
|
stability: StabilityEnum.Beta,
|
|
174
174
|
owners: [OwnersEnum.PlatformSigil],
|
|
175
175
|
tags: ["onboarding"],
|
package/dist/openapi.js
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { defaultRestPath, jsonSchemaForSpec } from "./jsonschema.js";
|
|
2
|
+
import { compareVersions } from "compare-versions";
|
|
2
3
|
|
|
3
4
|
//#region src/openapi.ts
|
|
5
|
+
/**
|
|
6
|
+
* OpenAPI export utilities.
|
|
7
|
+
*
|
|
8
|
+
* @deprecated Import from @contractspec/lib.contracts-transformers/openapi instead.
|
|
9
|
+
* This file is kept for backwards compatibility.
|
|
10
|
+
*/
|
|
4
11
|
function toOperationId(name, version) {
|
|
5
12
|
return `${name.replace(/\./g, "_")}_v${version}`;
|
|
6
13
|
}
|
|
@@ -15,9 +22,9 @@ function toRestPath(spec) {
|
|
|
15
22
|
return path.startsWith("/") ? path : `/${path}`;
|
|
16
23
|
}
|
|
17
24
|
function openApiForRegistry(registry, options = {}) {
|
|
18
|
-
const specs = registry.
|
|
25
|
+
const specs = registry.list().filter((s) => s.meta.kind === "command" || s.meta.kind === "query").slice().sort((a, b) => {
|
|
19
26
|
const byName = a.meta.key.localeCompare(b.meta.key);
|
|
20
|
-
return byName !== 0 ? byName : a.meta.version
|
|
27
|
+
return byName !== 0 ? byName : compareVersions(a.meta.version, b.meta.version);
|
|
21
28
|
});
|
|
22
29
|
const doc = {
|
|
23
30
|
openapi: "3.1.0",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { OwnerShipMeta } from "../ownership.js";
|
|
2
2
|
import { PolicyRef } from "../policy/spec.js";
|
|
3
|
-
import { ResourceRefDescriptor } from "../resources.js";
|
|
4
3
|
import { EventSpec } from "../events.js";
|
|
4
|
+
import { ResourceRefDescriptor } from "../resources.js";
|
|
5
5
|
import { TestSpecRef } from "../tests/spec.js";
|
|
6
6
|
import { AnySchemaModel } from "@contractspec/lib.schema";
|
|
7
7
|
|
|
@@ -33,7 +33,7 @@ interface EmitDeclRef {
|
|
|
33
33
|
}
|
|
34
34
|
interface EmitDeclInline {
|
|
35
35
|
key: string;
|
|
36
|
-
version:
|
|
36
|
+
version: string;
|
|
37
37
|
when: string;
|
|
38
38
|
payload: AnySchemaModel;
|
|
39
39
|
}
|
|
@@ -46,7 +46,7 @@ declare const isEmitDeclRef: (e: EmitDecl) => e is EmitDeclRef;
|
|
|
46
46
|
interface TelemetryTrigger {
|
|
47
47
|
event: {
|
|
48
48
|
key: string;
|
|
49
|
-
version?:
|
|
49
|
+
version?: string;
|
|
50
50
|
};
|
|
51
51
|
properties?: (args: {
|
|
52
52
|
input: unknown;
|
|
@@ -1,29 +1,22 @@
|
|
|
1
|
-
import { GroupKeyFn, RegistryFilter } from "../registry-utils.js";
|
|
2
1
|
import { ResourceRefDescriptor } from "../resources.js";
|
|
3
|
-
import { HandlerCtx } from "../types.js";
|
|
4
2
|
import { AnyOperationSpec, OperationSpec } from "./operation.js";
|
|
5
3
|
import { HandlerForOperationSpec } from "../install.js";
|
|
4
|
+
import { HandlerCtx } from "../types.js";
|
|
5
|
+
import { SpecContractRegistry } from "../registry.js";
|
|
6
6
|
import { AnySchemaModel } from "@contractspec/lib.schema";
|
|
7
7
|
|
|
8
8
|
//#region src/operations/registry.d.ts
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
|
|
10
|
+
type OperationKey = `${string}.v${string}`;
|
|
11
|
+
declare function opKey(key: string, version: string): OperationKey;
|
|
11
12
|
type AnyOperationHandler = (args: unknown, ctx: HandlerCtx) => Promise<unknown>;
|
|
12
13
|
/**
|
|
13
14
|
* In-memory registry for ContractSpecs and their bound handlers.
|
|
14
15
|
* Provides validation, policy enforcement, and guarded event emission at execute time.
|
|
15
16
|
*/
|
|
16
|
-
declare class OperationSpecRegistry {
|
|
17
|
-
private specs;
|
|
17
|
+
declare class OperationSpecRegistry extends SpecContractRegistry<'operation', AnyOperationSpec> {
|
|
18
18
|
private handlers;
|
|
19
|
-
|
|
20
|
-
* Registers a OperationSpec definition.
|
|
21
|
-
*
|
|
22
|
-
* @param spec - The contract specification to register.
|
|
23
|
-
* @returns The registry instance for chaining.
|
|
24
|
-
* @throws If a spec with the same name and version is already registered.
|
|
25
|
-
*/
|
|
26
|
-
register<I extends AnySchemaModel, O extends AnySchemaModel | ResourceRefDescriptor<boolean>>(spec: OperationSpec<I, O>): this;
|
|
19
|
+
constructor(items?: AnyOperationSpec[]);
|
|
27
20
|
/**
|
|
28
21
|
* Binds a runtime handler implementation to a previously registered spec.
|
|
29
22
|
*
|
|
@@ -33,57 +26,15 @@ declare class OperationSpecRegistry {
|
|
|
33
26
|
* @throws If the spec is not found or a handler is already bound.
|
|
34
27
|
*/
|
|
35
28
|
bind<I extends AnySchemaModel, O extends AnySchemaModel | ResourceRefDescriptor<boolean>>(spec: OperationSpec<I, O>, handler: HandlerForOperationSpec<OperationSpec<I, O>>): this;
|
|
36
|
-
/**
|
|
37
|
-
* Retrieves a registered spec by name and version.
|
|
38
|
-
* If version is omitted, returns the highest version found.
|
|
39
|
-
*
|
|
40
|
-
* @param name - Operation name.
|
|
41
|
-
* @param version - (Optional) Specific version.
|
|
42
|
-
*/
|
|
43
|
-
getSpec(key: string, version?: number): AnyOperationSpec | undefined;
|
|
44
29
|
/**
|
|
45
30
|
* Retrieves the bound handler for a spec.
|
|
46
31
|
*/
|
|
47
|
-
getHandler(key: string, version?:
|
|
48
|
-
/** Iterate all registered specs. */
|
|
49
|
-
listSpecs(): AnyOperationSpec[];
|
|
32
|
+
getHandler(key: string, version?: string): AnyOperationHandler | undefined;
|
|
50
33
|
/** Iterate all bound operations (spec+handler). */
|
|
51
34
|
listBound(): {
|
|
52
35
|
spec: AnyOperationSpec;
|
|
53
36
|
handler: AnyOperationHandler;
|
|
54
37
|
}[];
|
|
55
|
-
/**
|
|
56
|
-
* Filter specs by criteria.
|
|
57
|
-
*/
|
|
58
|
-
filter(criteria: RegistryFilter): AnyOperationSpec[];
|
|
59
|
-
/**
|
|
60
|
-
* List specs with specific tag.
|
|
61
|
-
*/
|
|
62
|
-
listByTag(tag: string): AnyOperationSpec[];
|
|
63
|
-
/**
|
|
64
|
-
* List specs by owner.
|
|
65
|
-
*/
|
|
66
|
-
listByOwner(owner: string): AnyOperationSpec[];
|
|
67
|
-
/**
|
|
68
|
-
* Group specs by key function.
|
|
69
|
-
*/
|
|
70
|
-
groupBy(keyFn: GroupKeyFn<AnyOperationSpec>): Map<string, AnyOperationSpec[]>;
|
|
71
|
-
/**
|
|
72
|
-
* Group by domain (first segment of name).
|
|
73
|
-
*/
|
|
74
|
-
groupByDomain(): Map<string, AnyOperationSpec[]>;
|
|
75
|
-
/**
|
|
76
|
-
* Group by tag.
|
|
77
|
-
*/
|
|
78
|
-
groupByTag(): Map<string, AnyOperationSpec[]>;
|
|
79
|
-
/**
|
|
80
|
-
* Get unique tags from all specs.
|
|
81
|
-
*/
|
|
82
|
-
getUniqueTags(): string[];
|
|
83
|
-
/**
|
|
84
|
-
* Get unique owners from all specs.
|
|
85
|
-
*/
|
|
86
|
-
getUniqueOwners(): string[];
|
|
87
38
|
/**
|
|
88
39
|
* Execute an operation by name/version with full runtime protections:
|
|
89
40
|
* 1. Validates input against Zod schema.
|
|
@@ -97,7 +48,7 @@ declare class OperationSpecRegistry {
|
|
|
97
48
|
* @param rawInput - The raw input payload (e.g. from JSON body).
|
|
98
49
|
* @param ctx - The runtime context (actor, tenant, etc.).
|
|
99
50
|
*/
|
|
100
|
-
execute(key: string, version:
|
|
51
|
+
execute(key: string, version: string | undefined, rawInput: unknown, ctx: HandlerCtx): Promise<unknown>;
|
|
101
52
|
}
|
|
102
53
|
//#endregion
|
|
103
54
|
export { OperationKey, OperationSpecRegistry, opKey };
|
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SpecContractRegistry } from "../registry.js";
|
|
2
2
|
import { eventKey } from "../events.js";
|
|
3
3
|
import { isEmitDeclRef } from "./operation.js";
|
|
4
4
|
|
|
5
5
|
//#region src/operations/registry.ts
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* OperationSpecRegistry:
|
|
8
|
+
* - Registers ContractSpecs (unique by name+version)
|
|
9
|
+
* - Binds runtime handlers to specs
|
|
10
|
+
* - Provides lookup, iteration, and a safe execute() with validation/policy/enforcement
|
|
11
|
+
*
|
|
12
|
+
* Includes a minimal OpRegistry shim for backward-compat (deprecated).
|
|
13
|
+
*/
|
|
7
14
|
function opKey(key, version) {
|
|
8
15
|
return `${key}.v${version}`;
|
|
9
16
|
}
|
|
@@ -11,21 +18,10 @@ function opKey(key, version) {
|
|
|
11
18
|
* In-memory registry for ContractSpecs and their bound handlers.
|
|
12
19
|
* Provides validation, policy enforcement, and guarded event emission at execute time.
|
|
13
20
|
*/
|
|
14
|
-
var OperationSpecRegistry = class {
|
|
15
|
-
specs = /* @__PURE__ */ new Map();
|
|
21
|
+
var OperationSpecRegistry = class extends SpecContractRegistry {
|
|
16
22
|
handlers = /* @__PURE__ */ new Map();
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
*
|
|
20
|
-
* @param spec - The contract specification to register.
|
|
21
|
-
* @returns The registry instance for chaining.
|
|
22
|
-
* @throws If a spec with the same name and version is already registered.
|
|
23
|
-
*/
|
|
24
|
-
register(spec) {
|
|
25
|
-
const key = opKey(spec.meta.key, spec.meta.version);
|
|
26
|
-
if (this.specs.has(key)) throw new Error(`Duplicate spec ${key}`);
|
|
27
|
-
this.specs.set(key, spec);
|
|
28
|
-
return this;
|
|
23
|
+
constructor(items) {
|
|
24
|
+
super("operation", items);
|
|
29
25
|
}
|
|
30
26
|
/**
|
|
31
27
|
* Binds a runtime handler implementation to a previously registered spec.
|
|
@@ -37,47 +33,23 @@ var OperationSpecRegistry = class {
|
|
|
37
33
|
*/
|
|
38
34
|
bind(spec, handler) {
|
|
39
35
|
const key = opKey(spec.meta.key, spec.meta.version);
|
|
40
|
-
if (!this.
|
|
36
|
+
if (!this.items.has(key)) throw new Error(`Cannot bind; spec not found: ${key}`);
|
|
41
37
|
if (this.handlers.has(key)) throw new Error(`Handler already bound for ${key}`);
|
|
42
38
|
this.handlers.set(key, handler);
|
|
43
39
|
return this;
|
|
44
40
|
}
|
|
45
41
|
/**
|
|
46
|
-
* Retrieves a registered spec by name and version.
|
|
47
|
-
* If version is omitted, returns the highest version found.
|
|
48
|
-
*
|
|
49
|
-
* @param name - Operation name.
|
|
50
|
-
* @param version - (Optional) Specific version.
|
|
51
|
-
*/
|
|
52
|
-
getSpec(key, version) {
|
|
53
|
-
if (version != null) return this.specs.get(opKey(key, version));
|
|
54
|
-
let found;
|
|
55
|
-
let maxV = -Infinity;
|
|
56
|
-
for (const [k, s] of this.specs.entries()) {
|
|
57
|
-
if (!k.startsWith(`${key}.v`)) continue;
|
|
58
|
-
if (s.meta.version > maxV) {
|
|
59
|
-
maxV = s.meta.version;
|
|
60
|
-
found = s;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
return found;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
42
|
* Retrieves the bound handler for a spec.
|
|
67
43
|
*/
|
|
68
44
|
getHandler(key, version) {
|
|
69
|
-
const spec = this.
|
|
45
|
+
const spec = this.get(key, version);
|
|
70
46
|
if (!spec) return void 0;
|
|
71
47
|
return this.handlers.get(opKey(spec.meta.key, spec.meta.version));
|
|
72
48
|
}
|
|
73
|
-
/** Iterate all registered specs. */
|
|
74
|
-
listSpecs() {
|
|
75
|
-
return [...this.specs.values()];
|
|
76
|
-
}
|
|
77
49
|
/** Iterate all bound operations (spec+handler). */
|
|
78
50
|
listBound() {
|
|
79
51
|
const out = [];
|
|
80
|
-
for (const [k, spec] of this.
|
|
52
|
+
for (const [k, spec] of this.items.entries()) {
|
|
81
53
|
const h = this.handlers.get(k);
|
|
82
54
|
if (h) out.push({
|
|
83
55
|
spec,
|
|
@@ -87,54 +59,6 @@ var OperationSpecRegistry = class {
|
|
|
87
59
|
return out;
|
|
88
60
|
}
|
|
89
61
|
/**
|
|
90
|
-
* Filter specs by criteria.
|
|
91
|
-
*/
|
|
92
|
-
filter(criteria) {
|
|
93
|
-
return filterBy(this.listSpecs(), criteria);
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* List specs with specific tag.
|
|
97
|
-
*/
|
|
98
|
-
listByTag(tag) {
|
|
99
|
-
return this.listSpecs().filter((s) => s.meta.tags?.includes(tag));
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* List specs by owner.
|
|
103
|
-
*/
|
|
104
|
-
listByOwner(owner) {
|
|
105
|
-
return this.listSpecs().filter((s) => s.meta.owners?.includes(owner));
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Group specs by key function.
|
|
109
|
-
*/
|
|
110
|
-
groupBy(keyFn) {
|
|
111
|
-
return groupBy(this.listSpecs(), keyFn);
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Group by domain (first segment of name).
|
|
115
|
-
*/
|
|
116
|
-
groupByDomain() {
|
|
117
|
-
return this.groupBy(GroupingStrategies.byDomain);
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Group by tag.
|
|
121
|
-
*/
|
|
122
|
-
groupByTag() {
|
|
123
|
-
return this.groupBy(GroupingStrategies.byTag);
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Get unique tags from all specs.
|
|
127
|
-
*/
|
|
128
|
-
getUniqueTags() {
|
|
129
|
-
return getUniqueTags(this.listSpecs());
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Get unique owners from all specs.
|
|
133
|
-
*/
|
|
134
|
-
getUniqueOwners() {
|
|
135
|
-
return getUniqueOwners(this.listSpecs());
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
62
|
* Execute an operation by name/version with full runtime protections:
|
|
139
63
|
* 1. Validates input against Zod schema.
|
|
140
64
|
* 2. Enforces policy (Auth, RBAC, Rate Limits) via PDP.
|
|
@@ -148,7 +72,7 @@ var OperationSpecRegistry = class {
|
|
|
148
72
|
* @param ctx - The runtime context (actor, tenant, etc.).
|
|
149
73
|
*/
|
|
150
74
|
async execute(key, version, rawInput, ctx) {
|
|
151
|
-
const baseSpec = this.
|
|
75
|
+
const baseSpec = this.get(key, version);
|
|
152
76
|
if (!baseSpec) throw new Error(`Spec not found for ${key}${version ? `.v${version}` : ""}`);
|
|
153
77
|
const spec = await ctx.specVariantResolver?.resolve({
|
|
154
78
|
name: baseSpec.meta.key,
|
|
@@ -215,7 +139,7 @@ var OperationSpecRegistry = class {
|
|
|
215
139
|
if (!telemetryContext || !trigger?.event) return;
|
|
216
140
|
try {
|
|
217
141
|
const props = trigger.properties?.(details) ?? {};
|
|
218
|
-
await telemetryContext.track(trigger.event.key, trigger.event.version ?? 1, props, {
|
|
142
|
+
await telemetryContext.track(trigger.event.key, trigger.event.version ?? "1.0.0", props, {
|
|
219
143
|
tenantId: ctx.organizationId ?? void 0,
|
|
220
144
|
organizationId: ctx.organizationId,
|
|
221
145
|
userId: ctx.userId,
|
package/dist/ownership.d.ts
CHANGED
|
@@ -63,7 +63,7 @@ declare const Tags: {
|
|
|
63
63
|
};
|
|
64
64
|
interface OwnerShipMeta {
|
|
65
65
|
/** Breaking changes => bump version */
|
|
66
|
-
version:
|
|
66
|
+
version: string;
|
|
67
67
|
/** Fully-qualified spec key (e.g., "sigil.beginSignup") */
|
|
68
68
|
key: string;
|
|
69
69
|
/** Human-friendly spec title (e.g., "Signup begin") */
|