@contractspec/lib.contracts 1.44.1 → 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.
Files changed (161) hide show
  1. package/README.md +1 -1
  2. package/dist/app-config/app-config.feature.js +6 -6
  3. package/dist/app-config/contracts.d.ts +1 -1
  4. package/dist/app-config/contracts.js +13 -13
  5. package/dist/app-config/events.d.ts +8 -8
  6. package/dist/app-config/events.js +12 -12
  7. package/dist/app-config/lifecycle-contracts.d.ts +11 -11
  8. package/dist/app-config/lifecycle-contracts.js +19 -19
  9. package/dist/app-config/lifecycle.d.ts +2 -2
  10. package/dist/app-config/runtime.d.ts +3 -3
  11. package/dist/app-config/spec.d.ts +10 -12
  12. package/dist/app-config/spec.js +5 -26
  13. package/dist/capabilities/capabilities.d.ts +4 -11
  14. package/dist/capabilities/capabilities.js +3 -5
  15. package/dist/capabilities/openbanking.js +10 -10
  16. package/dist/client/react/form-render.js +1 -0
  17. package/dist/contract-registry/schemas.d.ts +8 -8
  18. package/dist/contract-registry/schemas.js +1 -1
  19. package/dist/contract-registry/types.d.ts +1 -1
  20. package/dist/data-views/data-views.js +1 -0
  21. package/dist/data-views/registry.d.ts +3 -37
  22. package/dist/data-views/registry.js +4 -66
  23. package/dist/data-views/runtime.d.ts +1 -1
  24. package/dist/data-views/runtime.js +2 -0
  25. package/dist/data-views/spec.d.ts +2 -2
  26. package/dist/docs/index.d.ts +2 -2
  27. package/dist/docs/index.js +2 -2
  28. package/dist/docs/presentations.d.ts +2 -4
  29. package/dist/docs/presentations.js +2 -4
  30. package/dist/docs/tech/contracts/ops-to-presentation-linking.docblock.js +1 -1
  31. package/dist/docs/tech/contracts/tests.docblock.js +1 -1
  32. package/dist/docs/tech-contracts.docs.js +1 -1
  33. package/dist/docs/types.d.ts +1 -1
  34. package/dist/events.d.ts +3 -3
  35. package/dist/examples/docs/examples.docblock.d.ts +6 -0
  36. package/dist/examples/docs/examples.docblock.js +165 -0
  37. package/dist/examples/index.d.ts +5 -0
  38. package/dist/examples/index.js +6 -0
  39. package/dist/examples/registry.d.ts +65 -0
  40. package/dist/examples/registry.js +144 -0
  41. package/dist/examples/schema.d.ts +282 -0
  42. package/dist/examples/schema.js +125 -0
  43. package/dist/examples/types.d.ts +167 -0
  44. package/dist/examples/types.js +43 -0
  45. package/dist/examples/validation.d.ts +65 -0
  46. package/dist/examples/validation.js +144 -0
  47. package/dist/experiments/docs/experiments.docblock.js +1 -1
  48. package/dist/experiments/evaluator.d.ts +1 -1
  49. package/dist/experiments/spec-resolver.d.ts +2 -2
  50. package/dist/experiments/spec.d.ts +6 -8
  51. package/dist/experiments/spec.js +5 -23
  52. package/dist/features/index.d.ts +9 -1
  53. package/dist/features/index.js +8 -1
  54. package/dist/features/install.js +2 -2
  55. package/dist/features/types.d.ts +7 -7
  56. package/dist/forms/forms.d.ts +2 -2
  57. package/dist/forms/forms.js +3 -6
  58. package/dist/index.d.ts +13 -8
  59. package/dist/index.js +11 -2
  60. package/dist/install.d.ts +9 -9
  61. package/dist/integrations/connection.d.ts +1 -1
  62. package/dist/integrations/integrations.feature.js +8 -8
  63. package/dist/integrations/openbanking/contracts/accounts.d.ts +66 -66
  64. package/dist/integrations/openbanking/contracts/accounts.js +3 -3
  65. package/dist/integrations/openbanking/contracts/balances.d.ts +34 -34
  66. package/dist/integrations/openbanking/contracts/balances.js +2 -2
  67. package/dist/integrations/openbanking/contracts/transactions.d.ts +48 -48
  68. package/dist/integrations/openbanking/contracts/transactions.js +2 -2
  69. package/dist/integrations/openbanking/models.d.ts +55 -55
  70. package/dist/integrations/openbanking/openbanking.feature.js +10 -10
  71. package/dist/integrations/operations.d.ts +102 -102
  72. package/dist/integrations/operations.js +10 -10
  73. package/dist/integrations/providers/elevenlabs.js +2 -2
  74. package/dist/integrations/providers/gcs-storage.js +2 -2
  75. package/dist/integrations/providers/gmail.js +3 -3
  76. package/dist/integrations/providers/google-calendar.js +2 -2
  77. package/dist/integrations/providers/mistral.js +3 -3
  78. package/dist/integrations/providers/postmark.js +2 -2
  79. package/dist/integrations/providers/powens.js +4 -4
  80. package/dist/integrations/providers/qdrant.js +3 -3
  81. package/dist/integrations/providers/stripe.js +2 -2
  82. package/dist/integrations/providers/twilio-sms.js +2 -2
  83. package/dist/integrations/runtime.d.ts +5 -5
  84. package/dist/integrations/spec.d.ts +3 -5
  85. package/dist/integrations/spec.js +5 -26
  86. package/dist/jobs/gcp-cloud-tasks.js +1 -1
  87. package/dist/jobs/gcp-pubsub.js +1 -1
  88. package/dist/jobs/handlers/ping-handler.d.ts +3 -3
  89. package/dist/jobs/handlers/ping-handler.js +2 -2
  90. package/dist/jobs/memory-queue.js +1 -1
  91. package/dist/jobs/queue.d.ts +4 -4
  92. package/dist/jobs/scaleway-sqs-queue.js +2 -2
  93. package/dist/jsonschema.d.ts +4 -4
  94. package/dist/knowledge/binding.d.ts +1 -1
  95. package/dist/knowledge/knowledge.feature.js +8 -8
  96. package/dist/knowledge/operations.d.ts +66 -66
  97. package/dist/knowledge/operations.js +12 -12
  98. package/dist/knowledge/source.d.ts +1 -1
  99. package/dist/knowledge/spaces/email-threads.js +2 -2
  100. package/dist/knowledge/spaces/financial-docs.js +2 -2
  101. package/dist/knowledge/spaces/financial-overview.js +2 -2
  102. package/dist/knowledge/spaces/product-canon.js +2 -2
  103. package/dist/knowledge/spaces/support-faq.js +2 -2
  104. package/dist/knowledge/spaces/uploaded-docs.js +2 -2
  105. package/dist/knowledge/spec.d.ts +3 -5
  106. package/dist/knowledge/spec.js +6 -28
  107. package/dist/llm/exporters.js +2 -2
  108. package/dist/llm/types.d.ts +4 -4
  109. package/dist/markdown.js +1 -1
  110. package/dist/migrations.d.ts +2 -2
  111. package/dist/migrations.js +7 -9
  112. package/dist/onboarding-base.d.ts +29 -29
  113. package/dist/onboarding-base.js +4 -4
  114. package/dist/openapi.js +9 -2
  115. package/dist/operations/operation.d.ts +3 -3
  116. package/dist/operations/registry.d.ts +9 -58
  117. package/dist/operations/registry.js +17 -93
  118. package/dist/ownership.d.ts +1 -1
  119. package/dist/policy/docs/policy.docblock.js +1 -1
  120. package/dist/policy/engine.js +2 -0
  121. package/dist/policy/spec.d.ts +1 -1
  122. package/dist/prompt.d.ts +6 -6
  123. package/dist/promptRegistry.d.ts +4 -4
  124. package/dist/promptRegistry.js +2 -5
  125. package/dist/regenerator/docs/regenerator.docblock.js +1 -1
  126. package/dist/regenerator/types.d.ts +1 -1
  127. package/dist/registry.d.ts +3 -2
  128. package/dist/registry.js +5 -5
  129. package/dist/resources.d.ts +5 -5
  130. package/dist/server/graphql-pothos.js +2 -2
  131. package/dist/server/mcp/registerTools.js +1 -1
  132. package/dist/server/rest-elysia.d.ts +1 -1
  133. package/dist/server/rest-elysia.js +1 -1
  134. package/dist/server/rest-express.d.ts +1 -1
  135. package/dist/server/rest-express.js +1 -1
  136. package/dist/server/rest-generic.d.ts +1 -1
  137. package/dist/server/rest-generic.js +1 -1
  138. package/dist/server/rest-next-app.d.ts +1 -1
  139. package/dist/server/rest-next-mcp.d.ts +1 -1
  140. package/dist/server/rest-next-mcp.js +1 -1
  141. package/dist/server/rest-next-pages.d.ts +1 -1
  142. package/dist/telemetry/docs/telemetry.docblock.js +1 -1
  143. package/dist/telemetry/spec.d.ts +7 -7
  144. package/dist/telemetry/spec.js +17 -44
  145. package/dist/telemetry/tracker.d.ts +2 -2
  146. package/dist/tests/runner.d.ts +1 -1
  147. package/dist/tests/spec.d.ts +5 -5
  148. package/dist/tests/spec.js +3 -5
  149. package/dist/themes.d.ts +4 -6
  150. package/dist/themes.js +5 -27
  151. package/dist/translations/catalog.d.ts +1 -1
  152. package/dist/types.d.ts +5 -5
  153. package/dist/workflow/adapters/db-adapter.js +3 -3
  154. package/dist/workflow/runner.d.ts +4 -2
  155. package/dist/workflow/spec.d.ts +4 -17
  156. package/dist/workflow/spec.js +4 -48
  157. package/dist/workflow/state.d.ts +1 -1
  158. package/dist/workflow/validation.js +1 -1
  159. package/dist/workspace-config/contractsrc-schema.d.ts +419 -419
  160. package/dist/workspace-config/contractsrc-schema.js +86 -86
  161. package/package.json +19 -12
@@ -0,0 +1,6 @@
1
+ import { DocBlock } from "@contractspec/lib.contracts/docs";
2
+
3
+ //#region src/examples/docs/examples.docblock.d.ts
4
+ declare const tech_contracts_examples_DocBlocks: DocBlock[];
5
+ //#endregion
6
+ export { tech_contracts_examples_DocBlocks };
@@ -0,0 +1,165 @@
1
+ import { registerDocBlocks } from "../../docs/registry.js";
2
+
3
+ //#region src/examples/docs/examples.docblock.ts
4
+ const tech_contracts_examples_DocBlocks = [{
5
+ id: "docs.tech.contracts.examples",
6
+ title: "Example Specifications",
7
+ summary: "ExampleSpec defines complete, demonstrable ContractSpec applications.",
8
+ kind: "reference",
9
+ visibility: "public",
10
+ route: "/docs/tech/contracts/examples",
11
+ tags: [
12
+ "tech",
13
+ "contracts",
14
+ "examples",
15
+ "templates"
16
+ ],
17
+ body: `## Example Specifications
18
+
19
+ ExampleSpec is a contract for defining complete, demonstrable ContractSpec applications. Examples integrate with AppBlueprintSpec and FeatureModuleSpec to provide a full application specification.
20
+
21
+ ### Overview
22
+
23
+ An \`ExampleSpec\` captures:
24
+ - **Metadata** (via \`ExampleMeta\` extending \`OwnerShipMeta\`): key, version, title, description, ownership, tags, stability
25
+ - **Example-specific fields**: kind, visibility, summary
26
+ - **Surfaces**: where the example can be used (templates, sandbox, studio, MCP)
27
+ - **Entrypoints**: package exports mapping
28
+ - **Blueprint**: optional AppBlueprintSpec or reference
29
+ - **Features**: optional FeatureModuleSpec array or references
30
+
31
+ ### Usage
32
+
33
+ \`\`\`typescript
34
+ import type { ExampleSpec } from '@contractspec/lib.contracts';
35
+ import { ExampleRegistry, validateExample } from '@contractspec/lib.contracts';
36
+
37
+ const example: ExampleSpec = {
38
+ meta: {
39
+ key: 'saas-boilerplate',
40
+ version: '1.0.0',
41
+ title: 'SaaS Boilerplate',
42
+ description: 'Multi-tenant SaaS foundation with billing and RBAC.',
43
+ kind: 'template',
44
+ visibility: 'public',
45
+ stability: 'experimental',
46
+ owners: ['@saas-team'],
47
+ tags: ['saas', 'multi-tenant', 'billing'],
48
+ summary: 'Complete SaaS starter.',
49
+ },
50
+ surfaces: {
51
+ templates: true,
52
+ sandbox: { enabled: true, modes: ['playground', 'specs', 'builder'] },
53
+ studio: { enabled: true, installable: true },
54
+ mcp: { enabled: true },
55
+ },
56
+ entrypoints: {
57
+ packageName: '@contractspec/example.saas-boilerplate',
58
+ feature: './saas-boilerplate.feature',
59
+ contracts: './contracts',
60
+ },
61
+ features: [SaasBoilerplateFeature],
62
+ };
63
+ \`\`\`
64
+
65
+ ### ExampleRegistry
66
+
67
+ Use \`ExampleRegistry\` to manage examples:
68
+
69
+ \`\`\`typescript
70
+ const registry = new ExampleRegistry();
71
+ registry.register(example);
72
+
73
+ // Query examples
74
+ registry.listByKind('template');
75
+ registry.listByVisibility('public');
76
+ registry.listBySurface('studio');
77
+ registry.listInstallable();
78
+ registry.search('billing');
79
+ \`\`\`
80
+
81
+ ### ExampleMeta
82
+
83
+ \`ExampleMeta\` extends \`OwnerShipMeta\` with example-specific fields:
84
+
85
+ | Field | Type | Description |
86
+ |-------|------|-------------|
87
+ | key | string | Unique identifier |
88
+ | version | number | Spec version |
89
+ | title | string? | Human-readable title |
90
+ | description | string | Technical description |
91
+ | kind | ExampleKind | template, workflow, integration, etc. |
92
+ | visibility | ExampleVisibility | public, internal, experimental |
93
+ | stability | Stability | idea, experimental, beta, stable, deprecated |
94
+ | owners | string[] | Owner identifiers |
95
+ | tags | string[] | Discovery tags |
96
+ | summary | string? | Marketing summary |
97
+
98
+ ### ExampleKind
99
+
100
+ | Kind | Use Case |
101
+ |------|----------|
102
+ | template | Full application template |
103
+ | workflow | Workflow automation example |
104
+ | integration | Integration showcase |
105
+ | knowledge | Knowledge base example |
106
+ | blueprint | App blueprint example |
107
+ | ui | UI component showcase |
108
+ | script | CLI/script example |
109
+ | library | Library/SDK example |
110
+
111
+ ### Surfaces
112
+
113
+ | Surface | Purpose |
114
+ |---------|---------|
115
+ | templates | Available as new project template |
116
+ | sandbox | Interactive playground support |
117
+ | studio | ContractSpec Studio support |
118
+ | mcp | Model Context Protocol support |
119
+
120
+ ### Validation
121
+
122
+ \`\`\`typescript
123
+ import { validateExample, validateExamples } from '@contractspec/lib.contracts';
124
+
125
+ const result = validateExample(example);
126
+ if (!result.valid) {
127
+ console.error(result.errors);
128
+ }
129
+
130
+ // Batch validation with duplicate detection
131
+ const batchResult = validateExamples([example1, example2]);
132
+ \`\`\`
133
+
134
+ ### Integration with Blueprints and Features
135
+
136
+ Examples can reference or embed blueprints and features:
137
+
138
+ \`\`\`typescript
139
+ const example: ExampleSpec = {
140
+ // ... meta, surfaces, entrypoints
141
+
142
+ // Inline blueprint
143
+ blueprint: myAppBlueprint,
144
+
145
+ // Or reference by pointer
146
+ blueprint: { key: 'core.app', version: '1.0.0' },
147
+
148
+ // Inline features
149
+ features: [MyFeature],
150
+
151
+ // Or reference
152
+ features: [{ key: 'my-feature' }],
153
+ };
154
+ \`\`\`
155
+
156
+ ### Related
157
+
158
+ - [App Configuration](file:///docs/tech/contracts/app-config) - AppBlueprintSpec
159
+ - [Features](file:///docs/tech/contracts/features) - FeatureModuleSpec
160
+ `
161
+ }];
162
+ registerDocBlocks(tech_contracts_examples_DocBlocks);
163
+
164
+ //#endregion
165
+ export { tech_contracts_examples_DocBlocks };
@@ -0,0 +1,5 @@
1
+ import { ExampleDocumentation, ExampleEntrypoints, ExampleKind, ExampleKindEnum, ExampleMcpSupport, ExampleMeta, ExampleSandboxMode, ExampleSandboxModeEnum, ExampleSandboxSupport, ExampleSpec, ExampleStudioSupport, ExampleSurfaces, ExampleVisibility, ExampleVisibilityEnum, isExampleKind, isExampleVisibility, isFeatureRef, isSpecPointer } from "./types.js";
2
+ import { ExampleDocumentationSchema, ExampleEntrypointsSchema, ExampleKindSchema, ExampleMetaSchema, ExampleSandboxModeSchema, ExampleSpecSchema, ExampleSurfacesSchema, ExampleVisibilitySchema, parseExampleDocumentation, parseExampleEntrypoints, parseExampleMeta, parseExampleSpec, parseExampleSurfaces, safeParseExampleSpec } from "./schema.js";
3
+ import { ExampleRegistry } from "./registry.js";
4
+ import { CrossValidationContext, ExampleValidationError, ExampleValidationWarning, ValidateExampleResult, ValidateExamplesResult, validateExample, validateExampleReferences, validateExamples } from "./validation.js";
5
+ export { type CrossValidationContext, type ExampleDocumentation, ExampleDocumentationSchema, type ExampleEntrypoints, ExampleEntrypointsSchema, type ExampleKind, ExampleKindEnum, ExampleKindSchema, type ExampleMcpSupport, type ExampleMeta, ExampleMetaSchema, ExampleRegistry, type ExampleSandboxMode, ExampleSandboxModeEnum, ExampleSandboxModeSchema, type ExampleSandboxSupport, type ExampleSpec, ExampleSpecSchema, type ExampleStudioSupport, type ExampleSurfaces, ExampleSurfacesSchema, type ExampleValidationError, type ExampleValidationWarning, type ExampleVisibility, ExampleVisibilityEnum, ExampleVisibilitySchema, type ValidateExampleResult, type ValidateExamplesResult, isExampleKind, isExampleVisibility, isFeatureRef, isSpecPointer, parseExampleDocumentation, parseExampleEntrypoints, parseExampleMeta, parseExampleSpec, parseExampleSurfaces, safeParseExampleSpec, validateExample, validateExampleReferences, validateExamples };
@@ -0,0 +1,6 @@
1
+ import { ExampleKindEnum, ExampleSandboxModeEnum, ExampleVisibilityEnum, isExampleKind, isExampleVisibility, isFeatureRef, isSpecPointer } from "./types.js";
2
+ import { ExampleDocumentationSchema, ExampleEntrypointsSchema, ExampleKindSchema, ExampleMetaSchema, ExampleSandboxModeSchema, ExampleSpecSchema, ExampleSurfacesSchema, ExampleVisibilitySchema, parseExampleDocumentation, parseExampleEntrypoints, parseExampleMeta, parseExampleSpec, parseExampleSurfaces, safeParseExampleSpec } from "./schema.js";
3
+ import { ExampleRegistry } from "./registry.js";
4
+ import { validateExample, validateExampleReferences, validateExamples } from "./validation.js";
5
+
6
+ export { ExampleDocumentationSchema, ExampleEntrypointsSchema, ExampleKindEnum, ExampleKindSchema, ExampleMetaSchema, ExampleRegistry, ExampleSandboxModeEnum, ExampleSandboxModeSchema, ExampleSpecSchema, ExampleSurfacesSchema, ExampleVisibilityEnum, ExampleVisibilitySchema, isExampleKind, isExampleVisibility, isFeatureRef, isSpecPointer, parseExampleDocumentation, parseExampleEntrypoints, parseExampleMeta, parseExampleSpec, parseExampleSurfaces, safeParseExampleSpec, validateExample, validateExampleReferences, validateExamples };
@@ -0,0 +1,65 @@
1
+ import { GroupKeyFn, RegistryFilter } from "../registry-utils.js";
2
+ import { ExampleKind, ExampleSpec, ExampleVisibility } from "./types.js";
3
+
4
+ //#region src/examples/registry.d.ts
5
+
6
+ /**
7
+ * In-memory registry for ExampleSpec.
8
+ *
9
+ * Provides methods for registering, querying, and filtering examples.
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * const registry = new ExampleRegistry();
14
+ * registry.register(saasBoilerplateExample);
15
+ * registry.register(workflowSystemExample);
16
+ *
17
+ * const templates = registry.listByKind('template');
18
+ * const publicExamples = registry.listByVisibility('public');
19
+ * ```
20
+ */
21
+ declare class ExampleRegistry {
22
+ private items;
23
+ /** Register an example. Throws when the key already exists. */
24
+ register(spec: ExampleSpec): this;
25
+ /** List all registered examples. */
26
+ list(): ExampleSpec[];
27
+ /** Get an example by its key. */
28
+ get(key: string, version?: string): ExampleSpec | undefined;
29
+ /** Check if an example with the given key exists. */
30
+ has(key: string, version?: string): boolean;
31
+ /** Get the number of registered examples. */
32
+ get size(): number;
33
+ /** Clear all registered examples. */
34
+ clear(): void;
35
+ /** Filter examples by criteria. */
36
+ filter(criteria: RegistryFilter): ExampleSpec[];
37
+ /** List examples by kind. */
38
+ listByKind(kind: ExampleKind): ExampleSpec[];
39
+ /** List examples by visibility. */
40
+ listByVisibility(visibility: ExampleVisibility): ExampleSpec[];
41
+ /** List examples with specific tag. */
42
+ listByTag(tag: string): ExampleSpec[];
43
+ /** List examples by owner. */
44
+ listByOwner(owner: string): ExampleSpec[];
45
+ /** List examples by domain. */
46
+ listByDomain(domain: string): ExampleSpec[];
47
+ /** List examples that support a specific surface. */
48
+ listBySurface(surface: 'templates' | 'sandbox' | 'studio' | 'mcp'): ExampleSpec[];
49
+ /** List examples that are installable via Studio. */
50
+ listInstallable(): ExampleSpec[];
51
+ /** Group examples by key function. */
52
+ groupBy(keyFn: GroupKeyFn<ExampleSpec>): Map<string, ExampleSpec[]>;
53
+ /** Group examples by kind. */
54
+ groupByKind(): Map<ExampleKind, ExampleSpec[]>;
55
+ /** Get unique tags from all examples. */
56
+ getUniqueTags(): string[];
57
+ /** Get unique kinds from all examples. */
58
+ getUniqueKinds(): ExampleKind[];
59
+ /** Get unique domains from all examples. */
60
+ getUniqueDomains(): string[];
61
+ /** Search examples by query (matches key, title, description, tags). */
62
+ search(query: string): ExampleSpec[];
63
+ }
64
+ //#endregion
65
+ export { ExampleRegistry };
@@ -0,0 +1,144 @@
1
+ import { filterBy, getUniqueTags, groupBy, init_registry_utils } from "../registry-utils.js";
2
+ import { compareVersions } from "compare-versions";
3
+
4
+ //#region src/examples/registry.ts
5
+ init_registry_utils();
6
+ function exampleKey(meta) {
7
+ return `${meta.key}.v${meta.version}`;
8
+ }
9
+ /**
10
+ * In-memory registry for ExampleSpec.
11
+ *
12
+ * Provides methods for registering, querying, and filtering examples.
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * const registry = new ExampleRegistry();
17
+ * registry.register(saasBoilerplateExample);
18
+ * registry.register(workflowSystemExample);
19
+ *
20
+ * const templates = registry.listByKind('template');
21
+ * const publicExamples = registry.listByVisibility('public');
22
+ * ```
23
+ */
24
+ var ExampleRegistry = class {
25
+ items = /* @__PURE__ */ new Map();
26
+ /** Register an example. Throws when the key already exists. */
27
+ register(spec) {
28
+ const key = exampleKey(spec.meta);
29
+ if (this.items.has(key)) throw new Error(`Duplicate example: ${key}`);
30
+ this.items.set(key, spec);
31
+ return this;
32
+ }
33
+ /** List all registered examples. */
34
+ list() {
35
+ return [...this.items.values()];
36
+ }
37
+ /** Get an example by its key. */
38
+ get(key, version) {
39
+ if (version != null) return this.items.get(`${key}.v${version}`);
40
+ let candidate;
41
+ for (const [_k, v] of this.items.entries()) {
42
+ if (v.meta.key !== key) continue;
43
+ if (!candidate || compareVersions(v.meta.version, candidate.meta.version) > 0) candidate = v;
44
+ }
45
+ return candidate;
46
+ }
47
+ /** Check if an example with the given key exists. */
48
+ has(key, version) {
49
+ return !!this.get(key, version);
50
+ }
51
+ /** Get the number of registered examples. */
52
+ get size() {
53
+ return this.items.size;
54
+ }
55
+ /** Clear all registered examples. */
56
+ clear() {
57
+ this.items.clear();
58
+ }
59
+ /** Filter examples by criteria. */
60
+ filter(criteria) {
61
+ return filterBy(this.list(), criteria);
62
+ }
63
+ /** List examples by kind. */
64
+ listByKind(kind) {
65
+ return this.list().filter((spec) => spec.meta.kind === kind);
66
+ }
67
+ /** List examples by visibility. */
68
+ listByVisibility(visibility) {
69
+ return this.list().filter((spec) => spec.meta.visibility === visibility);
70
+ }
71
+ /** List examples with specific tag. */
72
+ listByTag(tag) {
73
+ return this.list().filter((spec) => spec.meta.tags.includes(tag));
74
+ }
75
+ /** List examples by owner. */
76
+ listByOwner(owner) {
77
+ return this.list().filter((spec) => spec.meta.owners.includes(owner));
78
+ }
79
+ /** List examples by domain. */
80
+ listByDomain(domain) {
81
+ return this.list().filter((spec) => spec.meta.domain === domain);
82
+ }
83
+ /** List examples that support a specific surface. */
84
+ listBySurface(surface) {
85
+ return this.list().filter((spec) => {
86
+ if (surface === "templates") return spec.surfaces.templates;
87
+ if (surface === "sandbox") return spec.surfaces.sandbox.enabled;
88
+ if (surface === "studio") return spec.surfaces.studio.enabled;
89
+ if (surface === "mcp") return spec.surfaces.mcp.enabled;
90
+ return false;
91
+ });
92
+ }
93
+ /** List examples that are installable via Studio. */
94
+ listInstallable() {
95
+ return this.list().filter((spec) => spec.surfaces.studio.installable);
96
+ }
97
+ /** Group examples by key function. */
98
+ groupBy(keyFn) {
99
+ return groupBy(this.list(), keyFn);
100
+ }
101
+ /** Group examples by kind. */
102
+ groupByKind() {
103
+ const result = /* @__PURE__ */ new Map();
104
+ for (const spec of this.list()) {
105
+ const existing = result.get(spec.meta.kind) ?? [];
106
+ existing.push(spec);
107
+ result.set(spec.meta.kind, existing);
108
+ }
109
+ return result;
110
+ }
111
+ /** Get unique tags from all examples. */
112
+ getUniqueTags() {
113
+ return getUniqueTags(this.list());
114
+ }
115
+ /** Get unique kinds from all examples. */
116
+ getUniqueKinds() {
117
+ const kinds = /* @__PURE__ */ new Set();
118
+ for (const spec of this.list()) kinds.add(spec.meta.kind);
119
+ return [...kinds];
120
+ }
121
+ /** Get unique domains from all examples. */
122
+ getUniqueDomains() {
123
+ const domains = /* @__PURE__ */ new Set();
124
+ for (const spec of this.list()) if (spec.meta.domain) domains.add(spec.meta.domain);
125
+ return [...domains];
126
+ }
127
+ /** Search examples by query (matches key, title, description, tags). */
128
+ search(query) {
129
+ const q = query.toLowerCase().trim();
130
+ if (!q) return this.list();
131
+ return this.list().filter((spec) => {
132
+ return [
133
+ spec.meta.key,
134
+ spec.meta.title ?? "",
135
+ spec.meta.description,
136
+ spec.meta.summary ?? "",
137
+ ...spec.meta.tags
138
+ ].join(" ").toLowerCase().includes(q);
139
+ });
140
+ }
141
+ };
142
+
143
+ //#endregion
144
+ export { ExampleRegistry };
@@ -0,0 +1,282 @@
1
+ import { ExampleDocumentation, ExampleEntrypoints, ExampleMeta, ExampleSpec, ExampleSurfaces } from "./types.js";
2
+ import { z as z$1 } from "zod";
3
+
4
+ //#region src/examples/schema.d.ts
5
+ declare const ExampleKindSchema: z$1.ZodEnum<{
6
+ template: "template";
7
+ workflow: "workflow";
8
+ integration: "integration";
9
+ knowledge: "knowledge";
10
+ blueprint: "blueprint";
11
+ ui: "ui";
12
+ script: "script";
13
+ library: "library";
14
+ }>;
15
+ declare const ExampleVisibilitySchema: z$1.ZodEnum<{
16
+ experimental: "experimental";
17
+ public: "public";
18
+ internal: "internal";
19
+ }>;
20
+ declare const ExampleSandboxModeSchema: z$1.ZodEnum<{
21
+ playground: "playground";
22
+ specs: "specs";
23
+ builder: "builder";
24
+ markdown: "markdown";
25
+ evolution: "evolution";
26
+ }>;
27
+ declare const StabilitySchema: z$1.ZodEnum<{
28
+ deprecated: "deprecated";
29
+ idea: "idea";
30
+ in_creation: "in_creation";
31
+ experimental: "experimental";
32
+ beta: "beta";
33
+ stable: "stable";
34
+ }>;
35
+ declare const ExampleDocumentationSchema: z$1.ZodObject<{
36
+ rootDocId: z$1.ZodOptional<z$1.ZodString>;
37
+ goalDocId: z$1.ZodOptional<z$1.ZodString>;
38
+ usageDocId: z$1.ZodOptional<z$1.ZodString>;
39
+ referenceDocId: z$1.ZodOptional<z$1.ZodString>;
40
+ constraintsDocId: z$1.ZodOptional<z$1.ZodString>;
41
+ }, z$1.core.$strip>;
42
+ declare const ExampleSandboxSupportSchema: z$1.ZodObject<{
43
+ enabled: z$1.ZodBoolean;
44
+ modes: z$1.ZodArray<z$1.ZodEnum<{
45
+ playground: "playground";
46
+ specs: "specs";
47
+ builder: "builder";
48
+ markdown: "markdown";
49
+ evolution: "evolution";
50
+ }>>;
51
+ }, z$1.core.$strip>;
52
+ declare const ExampleStudioSupportSchema: z$1.ZodObject<{
53
+ enabled: z$1.ZodBoolean;
54
+ installable: z$1.ZodBoolean;
55
+ }, z$1.core.$strip>;
56
+ declare const ExampleMcpSupportSchema: z$1.ZodObject<{
57
+ enabled: z$1.ZodBoolean;
58
+ }, z$1.core.$strip>;
59
+ declare const ExampleSurfacesSchema: z$1.ZodObject<{
60
+ templates: z$1.ZodBoolean;
61
+ sandbox: z$1.ZodObject<{
62
+ enabled: z$1.ZodBoolean;
63
+ modes: z$1.ZodArray<z$1.ZodEnum<{
64
+ playground: "playground";
65
+ specs: "specs";
66
+ builder: "builder";
67
+ markdown: "markdown";
68
+ evolution: "evolution";
69
+ }>>;
70
+ }, z$1.core.$strip>;
71
+ studio: z$1.ZodObject<{
72
+ enabled: z$1.ZodBoolean;
73
+ installable: z$1.ZodBoolean;
74
+ }, z$1.core.$strip>;
75
+ mcp: z$1.ZodObject<{
76
+ enabled: z$1.ZodBoolean;
77
+ }, z$1.core.$strip>;
78
+ }, z$1.core.$strip>;
79
+ declare const ExampleEntrypointsSchema: z$1.ZodObject<{
80
+ packageName: z$1.ZodString;
81
+ feature: z$1.ZodOptional<z$1.ZodString>;
82
+ blueprint: z$1.ZodOptional<z$1.ZodString>;
83
+ presentations: z$1.ZodOptional<z$1.ZodString>;
84
+ contracts: z$1.ZodOptional<z$1.ZodString>;
85
+ handlers: z$1.ZodOptional<z$1.ZodString>;
86
+ ui: z$1.ZodOptional<z$1.ZodString>;
87
+ docs: z$1.ZodOptional<z$1.ZodString>;
88
+ }, z$1.core.$strip>;
89
+ declare const ExampleMetaSchema: z$1.ZodObject<{
90
+ version: z$1.ZodString;
91
+ key: z$1.ZodString;
92
+ title: z$1.ZodOptional<z$1.ZodString>;
93
+ description: z$1.ZodString;
94
+ domain: z$1.ZodOptional<z$1.ZodString>;
95
+ stability: z$1.ZodEnum<{
96
+ deprecated: "deprecated";
97
+ idea: "idea";
98
+ in_creation: "in_creation";
99
+ experimental: "experimental";
100
+ beta: "beta";
101
+ stable: "stable";
102
+ }>;
103
+ owners: z$1.ZodArray<z$1.ZodString>;
104
+ tags: z$1.ZodArray<z$1.ZodString>;
105
+ docId: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
106
+ kind: z$1.ZodEnum<{
107
+ template: "template";
108
+ workflow: "workflow";
109
+ integration: "integration";
110
+ knowledge: "knowledge";
111
+ blueprint: "blueprint";
112
+ ui: "ui";
113
+ script: "script";
114
+ library: "library";
115
+ }>;
116
+ visibility: z$1.ZodEnum<{
117
+ experimental: "experimental";
118
+ public: "public";
119
+ internal: "internal";
120
+ }>;
121
+ summary: z$1.ZodOptional<z$1.ZodString>;
122
+ }, z$1.core.$strip>;
123
+ declare const SpecPointerSchema: z$1.ZodObject<{
124
+ key: z$1.ZodString;
125
+ version: z$1.ZodOptional<z$1.ZodString>;
126
+ }, z$1.core.$strip>;
127
+ declare const FeatureRefSchema: z$1.ZodObject<{
128
+ key: z$1.ZodString;
129
+ }, z$1.core.$strip>;
130
+ /**
131
+ * Zod schema for validating ExampleSpec objects.
132
+ *
133
+ * Note: blueprint and features are loosely validated since they can be
134
+ * inline specs or references. Full validation requires registry lookups.
135
+ */
136
+ declare const ExampleSpecSchema: z$1.ZodObject<{
137
+ meta: z$1.ZodObject<{
138
+ version: z$1.ZodString;
139
+ key: z$1.ZodString;
140
+ title: z$1.ZodOptional<z$1.ZodString>;
141
+ description: z$1.ZodString;
142
+ domain: z$1.ZodOptional<z$1.ZodString>;
143
+ stability: z$1.ZodEnum<{
144
+ deprecated: "deprecated";
145
+ idea: "idea";
146
+ in_creation: "in_creation";
147
+ experimental: "experimental";
148
+ beta: "beta";
149
+ stable: "stable";
150
+ }>;
151
+ owners: z$1.ZodArray<z$1.ZodString>;
152
+ tags: z$1.ZodArray<z$1.ZodString>;
153
+ docId: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
154
+ kind: z$1.ZodEnum<{
155
+ template: "template";
156
+ workflow: "workflow";
157
+ integration: "integration";
158
+ knowledge: "knowledge";
159
+ blueprint: "blueprint";
160
+ ui: "ui";
161
+ script: "script";
162
+ library: "library";
163
+ }>;
164
+ visibility: z$1.ZodEnum<{
165
+ experimental: "experimental";
166
+ public: "public";
167
+ internal: "internal";
168
+ }>;
169
+ summary: z$1.ZodOptional<z$1.ZodString>;
170
+ }, z$1.core.$strip>;
171
+ docs: z$1.ZodOptional<z$1.ZodObject<{
172
+ rootDocId: z$1.ZodOptional<z$1.ZodString>;
173
+ goalDocId: z$1.ZodOptional<z$1.ZodString>;
174
+ usageDocId: z$1.ZodOptional<z$1.ZodString>;
175
+ referenceDocId: z$1.ZodOptional<z$1.ZodString>;
176
+ constraintsDocId: z$1.ZodOptional<z$1.ZodString>;
177
+ }, z$1.core.$strip>>;
178
+ surfaces: z$1.ZodObject<{
179
+ templates: z$1.ZodBoolean;
180
+ sandbox: z$1.ZodObject<{
181
+ enabled: z$1.ZodBoolean;
182
+ modes: z$1.ZodArray<z$1.ZodEnum<{
183
+ playground: "playground";
184
+ specs: "specs";
185
+ builder: "builder";
186
+ markdown: "markdown";
187
+ evolution: "evolution";
188
+ }>>;
189
+ }, z$1.core.$strip>;
190
+ studio: z$1.ZodObject<{
191
+ enabled: z$1.ZodBoolean;
192
+ installable: z$1.ZodBoolean;
193
+ }, z$1.core.$strip>;
194
+ mcp: z$1.ZodObject<{
195
+ enabled: z$1.ZodBoolean;
196
+ }, z$1.core.$strip>;
197
+ }, z$1.core.$strip>;
198
+ entrypoints: z$1.ZodObject<{
199
+ packageName: z$1.ZodString;
200
+ feature: z$1.ZodOptional<z$1.ZodString>;
201
+ blueprint: z$1.ZodOptional<z$1.ZodString>;
202
+ presentations: z$1.ZodOptional<z$1.ZodString>;
203
+ contracts: z$1.ZodOptional<z$1.ZodString>;
204
+ handlers: z$1.ZodOptional<z$1.ZodString>;
205
+ ui: z$1.ZodOptional<z$1.ZodString>;
206
+ docs: z$1.ZodOptional<z$1.ZodString>;
207
+ }, z$1.core.$strip>;
208
+ blueprint: z$1.ZodOptional<z$1.ZodUnion<readonly [z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>, z$1.ZodObject<{
209
+ key: z$1.ZodString;
210
+ version: z$1.ZodOptional<z$1.ZodString>;
211
+ }, z$1.core.$strip>]>>;
212
+ features: z$1.ZodOptional<z$1.ZodArray<z$1.ZodUnion<readonly [z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>, z$1.ZodObject<{
213
+ key: z$1.ZodString;
214
+ }, z$1.core.$strip>]>>>;
215
+ }, z$1.core.$strip>;
216
+ /** Parse and validate an ExampleSpec, throwing on failure */
217
+ declare function parseExampleSpec(data: unknown): ExampleSpec;
218
+ /** Safely parse an ExampleSpec, returning result object */
219
+ declare function safeParseExampleSpec(data: unknown): z$1.ZodSafeParseResult<{
220
+ meta: {
221
+ version: string;
222
+ key: string;
223
+ description: string;
224
+ stability: "deprecated" | "idea" | "in_creation" | "experimental" | "beta" | "stable";
225
+ owners: string[];
226
+ tags: string[];
227
+ kind: "template" | "workflow" | "integration" | "knowledge" | "blueprint" | "ui" | "script" | "library";
228
+ visibility: "experimental" | "public" | "internal";
229
+ title?: string | undefined;
230
+ domain?: string | undefined;
231
+ docId?: string[] | undefined;
232
+ summary?: string | undefined;
233
+ };
234
+ surfaces: {
235
+ templates: boolean;
236
+ sandbox: {
237
+ enabled: boolean;
238
+ modes: ("playground" | "specs" | "builder" | "markdown" | "evolution")[];
239
+ };
240
+ studio: {
241
+ enabled: boolean;
242
+ installable: boolean;
243
+ };
244
+ mcp: {
245
+ enabled: boolean;
246
+ };
247
+ };
248
+ entrypoints: {
249
+ packageName: string;
250
+ feature?: string | undefined;
251
+ blueprint?: string | undefined;
252
+ presentations?: string | undefined;
253
+ contracts?: string | undefined;
254
+ handlers?: string | undefined;
255
+ ui?: string | undefined;
256
+ docs?: string | undefined;
257
+ };
258
+ docs?: {
259
+ rootDocId?: string | undefined;
260
+ goalDocId?: string | undefined;
261
+ usageDocId?: string | undefined;
262
+ referenceDocId?: string | undefined;
263
+ constraintsDocId?: string | undefined;
264
+ } | undefined;
265
+ blueprint?: Record<string, unknown> | {
266
+ key: string;
267
+ version?: string | undefined;
268
+ } | undefined;
269
+ features?: (Record<string, unknown> | {
270
+ key: string;
271
+ })[] | undefined;
272
+ }>;
273
+ /** Parse and validate ExampleMeta */
274
+ declare function parseExampleMeta(data: unknown): ExampleMeta;
275
+ /** Parse and validate ExampleSurfaces */
276
+ declare function parseExampleSurfaces(data: unknown): ExampleSurfaces;
277
+ /** Parse and validate ExampleEntrypoints */
278
+ declare function parseExampleEntrypoints(data: unknown): ExampleEntrypoints;
279
+ /** Parse and validate ExampleDocumentation */
280
+ declare function parseExampleDocumentation(data: unknown): ExampleDocumentation;
281
+ //#endregion
282
+ export { ExampleDocumentationSchema, ExampleEntrypointsSchema, ExampleKindSchema, ExampleMcpSupportSchema, ExampleMetaSchema, ExampleSandboxModeSchema, ExampleSandboxSupportSchema, ExampleSpecSchema, ExampleStudioSupportSchema, ExampleSurfacesSchema, ExampleVisibilitySchema, FeatureRefSchema, SpecPointerSchema, StabilitySchema, parseExampleDocumentation, parseExampleEntrypoints, parseExampleMeta, parseExampleSpec, parseExampleSurfaces, safeParseExampleSpec };