@contractspec/module.examples 1.46.1 → 1.47.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.
@@ -1 +1 @@
1
- {"version":3,"file":"builtins.js","names":["EXAMPLE_REGISTRY: readonly ExampleSpec[]"],"sources":["../src/builtins.ts"],"sourcesContent":["import type { ExampleSpec } from '@contractspec/lib.contracts';\n\n// Import manifests ONLY via the side-effect-free `/example` entrypoints.\nimport AgentConsole from '@contractspec/example.agent-console/example';\nimport AiSupportBot from '@contractspec/example.ai-support-bot/example';\nimport AnalyticsDashboard from '@contractspec/example.analytics-dashboard/example';\nimport ContentGeneration from '@contractspec/example.content-generation/example';\nimport CrmPipeline from '@contractspec/example.crm-pipeline/example';\nimport IntegrationHub from '@contractspec/example.integration-hub/example';\nimport IntegrationStripe from '@contractspec/example.integration-stripe/example';\nimport KbUpdatePipeline from '@contractspec/example.kb-update-pipeline/example';\nimport KnowledgeCanon from '@contractspec/example.knowledge-canon/example';\nimport LearningPatterns from '@contractspec/example.learning-patterns/example';\nimport LearningJourneyAmbientCoach from '@contractspec/example.learning-journey-ambient-coach/example';\nimport LearningJourneyCrmOnboarding from '@contractspec/example.learning-journey-crm-onboarding/example';\nimport LearningJourneyDuoDrills from '@contractspec/example.learning-journey-duo-drills/example';\nimport LearningJourneyPlatformTour from '@contractspec/example.learning-journey-platform-tour/example';\nimport LearningJourneyQuestChallenges from '@contractspec/example.learning-journey-quest-challenges/example';\nimport LearningJourneyRegistry from '@contractspec/example.learning-journey-registry/example';\nimport LearningJourneyStudioOnboarding from '@contractspec/example.learning-journey-studio-onboarding/example';\nimport LearningJourneyUiCoaching from '@contractspec/example.learning-journey-ui-coaching/example';\nimport LearningJourneyUiGamified from '@contractspec/example.learning-journey-ui-gamified/example';\nimport LearningJourneyUiOnboarding from '@contractspec/example.learning-journey-ui-onboarding/example';\nimport LearningJourneyUiShared from '@contractspec/example.learning-journey-ui-shared/example';\nimport LifecycleCli from '@contractspec/example.lifecycle-cli/example';\nimport LifecycleDashboard from '@contractspec/example.lifecycle-dashboard/example';\nimport LocaleJurisdictionGate from '@contractspec/example.locale-jurisdiction-gate/example';\nimport Marketplace from '@contractspec/example.marketplace/example';\nimport OpenbankingPowens from '@contractspec/example.openbanking-powens/example';\nimport Personalization from '@contractspec/example.personalization/example';\nimport PolicySafeKnowledgeAssistant from '@contractspec/example.policy-safe-knowledge-assistant/example';\nimport SaasBoilerplate from '@contractspec/example.saas-boilerplate/example';\nimport ServiceBusinessOs from '@contractspec/example.service-business-os/example';\nimport TeamHub from '@contractspec/example.team-hub/example';\nimport VersionedKnowledgeBase from '@contractspec/example.versioned-knowledge-base/example';\nimport WealthSnapshot from '@contractspec/example.wealth-snapshot/example';\nimport WorkflowSystem from '@contractspec/example.workflow-system/example';\n\nexport const EXAMPLE_REGISTRY: readonly ExampleSpec[] = [\n AgentConsole,\n AiSupportBot,\n AnalyticsDashboard,\n ContentGeneration,\n CrmPipeline,\n IntegrationHub,\n IntegrationStripe,\n KbUpdatePipeline,\n KnowledgeCanon,\n LearningPatterns,\n LearningJourneyAmbientCoach,\n LearningJourneyCrmOnboarding,\n LearningJourneyDuoDrills,\n LearningJourneyPlatformTour,\n LearningJourneyQuestChallenges,\n LearningJourneyRegistry,\n LearningJourneyStudioOnboarding,\n LearningJourneyUiCoaching,\n LearningJourneyUiGamified,\n LearningJourneyUiOnboarding,\n LearningJourneyUiShared,\n LifecycleCli,\n LifecycleDashboard,\n LocaleJurisdictionGate,\n Marketplace,\n OpenbankingPowens,\n Personalization,\n PolicySafeKnowledgeAssistant,\n SaasBoilerplate,\n ServiceBusinessOs,\n TeamHub,\n VersionedKnowledgeBase,\n WealthSnapshot,\n WorkflowSystem,\n];\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,MAAaA,mBAA2C;CACtD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD"}
1
+ {"version":3,"file":"builtins.js","names":[],"sources":["../src/builtins.ts"],"sourcesContent":["import type { ExampleSpec } from '@contractspec/lib.contracts';\n\n// Import manifests ONLY via the side-effect-free `/example` entrypoints.\nimport AgentConsole from '@contractspec/example.agent-console/example';\nimport AiSupportBot from '@contractspec/example.ai-support-bot/example';\nimport AnalyticsDashboard from '@contractspec/example.analytics-dashboard/example';\nimport ContentGeneration from '@contractspec/example.content-generation/example';\nimport CrmPipeline from '@contractspec/example.crm-pipeline/example';\nimport IntegrationHub from '@contractspec/example.integration-hub/example';\nimport IntegrationStripe from '@contractspec/example.integration-stripe/example';\nimport KbUpdatePipeline from '@contractspec/example.kb-update-pipeline/example';\nimport KnowledgeCanon from '@contractspec/example.knowledge-canon/example';\nimport LearningPatterns from '@contractspec/example.learning-patterns/example';\nimport LearningJourneyAmbientCoach from '@contractspec/example.learning-journey-ambient-coach/example';\nimport LearningJourneyCrmOnboarding from '@contractspec/example.learning-journey-crm-onboarding/example';\nimport LearningJourneyDuoDrills from '@contractspec/example.learning-journey-duo-drills/example';\nimport LearningJourneyPlatformTour from '@contractspec/example.learning-journey-platform-tour/example';\nimport LearningJourneyQuestChallenges from '@contractspec/example.learning-journey-quest-challenges/example';\nimport LearningJourneyRegistry from '@contractspec/example.learning-journey-registry/example';\nimport LearningJourneyStudioOnboarding from '@contractspec/example.learning-journey-studio-onboarding/example';\nimport LearningJourneyUiCoaching from '@contractspec/example.learning-journey-ui-coaching/example';\nimport LearningJourneyUiGamified from '@contractspec/example.learning-journey-ui-gamified/example';\nimport LearningJourneyUiOnboarding from '@contractspec/example.learning-journey-ui-onboarding/example';\nimport LearningJourneyUiShared from '@contractspec/example.learning-journey-ui-shared/example';\nimport LifecycleCli from '@contractspec/example.lifecycle-cli/example';\nimport LifecycleDashboard from '@contractspec/example.lifecycle-dashboard/example';\nimport LocaleJurisdictionGate from '@contractspec/example.locale-jurisdiction-gate/example';\nimport Marketplace from '@contractspec/example.marketplace/example';\nimport OpenbankingPowens from '@contractspec/example.openbanking-powens/example';\nimport Personalization from '@contractspec/example.personalization/example';\nimport PolicySafeKnowledgeAssistant from '@contractspec/example.policy-safe-knowledge-assistant/example';\nimport SaasBoilerplate from '@contractspec/example.saas-boilerplate/example';\nimport ServiceBusinessOs from '@contractspec/example.service-business-os/example';\nimport TeamHub from '@contractspec/example.team-hub/example';\nimport VersionedKnowledgeBase from '@contractspec/example.versioned-knowledge-base/example';\nimport WealthSnapshot from '@contractspec/example.wealth-snapshot/example';\nimport WorkflowSystem from '@contractspec/example.workflow-system/example';\n\nexport const EXAMPLE_REGISTRY: readonly ExampleSpec[] = [\n AgentConsole,\n AiSupportBot,\n AnalyticsDashboard,\n ContentGeneration,\n CrmPipeline,\n IntegrationHub,\n IntegrationStripe,\n KbUpdatePipeline,\n KnowledgeCanon,\n LearningPatterns,\n LearningJourneyAmbientCoach,\n LearningJourneyCrmOnboarding,\n LearningJourneyDuoDrills,\n LearningJourneyPlatformTour,\n LearningJourneyQuestChallenges,\n LearningJourneyRegistry,\n LearningJourneyStudioOnboarding,\n LearningJourneyUiCoaching,\n LearningJourneyUiGamified,\n LearningJourneyUiOnboarding,\n LearningJourneyUiShared,\n LifecycleCli,\n LifecycleDashboard,\n LocaleJurisdictionGate,\n Marketplace,\n OpenbankingPowens,\n Personalization,\n PolicySafeKnowledgeAssistant,\n SaasBoilerplate,\n ServiceBusinessOs,\n TeamHub,\n VersionedKnowledgeBase,\n WealthSnapshot,\n WorkflowSystem,\n];\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,MAAa,mBAA2C;CACtD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD"}
package/dist/index.d.ts CHANGED
@@ -1,2 +1,6 @@
1
1
  import { EXAMPLE_REGISTRY, ExampleRegistry, getExample, listExamples, searchExamples } from "./registry.js";
2
- export { EXAMPLE_REGISTRY, ExampleRegistry, getExample, listExamples, searchExamples };
2
+ import { createTemplateTransformEngine, getTemplateEngine, resetTemplateEngine } from "./runtime/engine.js";
3
+ import { TemplateInstaller, TemplateInstallerOptions } from "./runtime/installer.js";
4
+ import { TEMPLATE_REGISTRY, getClonableTemplates, getTemplate, getTemplatesByModule, listTemplates } from "./runtime/registry.js";
5
+ import { TemplateHandlers, TemplateRuntimeProvider, useAgentHandlers, useAnalyticsHandlers, useCrmHandlers, useIntegrationHandlers, useMarketplaceHandlers, useSaasHandlers, useTemplateEngine, useTemplateHandlers, useWorkflowHandlers } from "./runtime/context.js";
6
+ export { EXAMPLE_REGISTRY, ExampleRegistry, TEMPLATE_REGISTRY, TemplateHandlers, TemplateInstaller, TemplateInstallerOptions, TemplateRuntimeProvider, createTemplateTransformEngine, getClonableTemplates, getExample, getTemplate, getTemplateEngine, getTemplatesByModule, listExamples, listTemplates, resetTemplateEngine, searchExamples, useAgentHandlers, useAnalyticsHandlers, useCrmHandlers, useIntegrationHandlers, useMarketplaceHandlers, useSaasHandlers, useTemplateEngine, useTemplateHandlers, useWorkflowHandlers };
package/dist/index.js CHANGED
@@ -1,3 +1,7 @@
1
1
  import { EXAMPLE_REGISTRY, ExampleRegistry, getExample, listExamples, searchExamples } from "./registry.js";
2
+ import { createTemplateTransformEngine, getTemplateEngine, resetTemplateEngine } from "./runtime/engine.js";
3
+ import { TEMPLATE_REGISTRY, getClonableTemplates, getTemplate, getTemplatesByModule, listTemplates } from "./runtime/registry.js";
4
+ import { TemplateInstaller } from "./runtime/installer.js";
5
+ import { TemplateHandlers, TemplateRuntimeProvider, useAgentHandlers, useAnalyticsHandlers, useCrmHandlers, useIntegrationHandlers, useMarketplaceHandlers, useSaasHandlers, useTemplateEngine, useTemplateHandlers, useWorkflowHandlers } from "./runtime/context.js";
2
6
 
3
- export { EXAMPLE_REGISTRY, ExampleRegistry, getExample, listExamples, searchExamples };
7
+ export { EXAMPLE_REGISTRY, ExampleRegistry, TEMPLATE_REGISTRY, TemplateHandlers, TemplateInstaller, TemplateRuntimeProvider, createTemplateTransformEngine, getClonableTemplates, getExample, getTemplate, getTemplateEngine, getTemplatesByModule, listExamples, listTemplates, resetTemplateEngine, searchExamples, useAgentHandlers, useAnalyticsHandlers, useCrmHandlers, useIntegrationHandlers, useMarketplaceHandlers, useSaasHandlers, useTemplateEngine, useTemplateHandlers, useWorkflowHandlers };
@@ -1 +1 @@
1
- {"version":3,"file":"registry.js","names":["BUILTIN_EXAMPLES","EXAMPLE_REGISTRY: readonly ExampleSpec[]"],"sources":["../src/registry.ts"],"sourcesContent":["import { ExampleRegistry } from '@contractspec/lib.contracts';\nimport type { ExampleSpec } from '@contractspec/lib.contracts';\nimport { EXAMPLE_REGISTRY as BUILTIN_EXAMPLES } from './builtins';\n\n// Export the ExampleRegistry class from contracts\nexport { ExampleRegistry } from '@contractspec/lib.contracts';\n\n// Create a global registry instance populated with builtins\nconst globalRegistry = new ExampleRegistry();\n\n// Register all builtin examples\nfor (const example of BUILTIN_EXAMPLES) {\n globalRegistry.register(example);\n}\n\n/**\n * Global registry containing all builtin ContractSpec examples.\n * @deprecated Prefer using ExampleRegistry directly for custom registrations.\n */\nexport const EXAMPLE_REGISTRY: readonly ExampleSpec[] = globalRegistry.list();\n\n/**\n * List all registered examples.\n */\nexport function listExamples(): readonly ExampleSpec[] {\n return globalRegistry.list();\n}\n\n/**\n * Get an example by its key.\n */\nexport function getExample(key: string): ExampleSpec | undefined {\n return globalRegistry.get(key);\n}\n\n/**\n * Search examples by query (matches key, title, description, tags).\n */\nexport function searchExamples(query: string): ExampleSpec[] {\n return globalRegistry.search(query);\n}\n"],"mappings":";;;;AAQA,MAAM,iBAAiB,IAAI,iBAAiB;AAG5C,KAAK,MAAM,WAAWA,mBACpB,gBAAe,SAAS,QAAQ;;;;;AAOlC,MAAaC,mBAA2C,eAAe,MAAM;;;;AAK7E,SAAgB,eAAuC;AACrD,QAAO,eAAe,MAAM;;;;;AAM9B,SAAgB,WAAW,KAAsC;AAC/D,QAAO,eAAe,IAAI,IAAI;;;;;AAMhC,SAAgB,eAAe,OAA8B;AAC3D,QAAO,eAAe,OAAO,MAAM"}
1
+ {"version":3,"file":"registry.js","names":["BUILTIN_EXAMPLES"],"sources":["../src/registry.ts"],"sourcesContent":["import { ExampleRegistry } from '@contractspec/lib.contracts';\nimport type { ExampleSpec } from '@contractspec/lib.contracts';\nimport { EXAMPLE_REGISTRY as BUILTIN_EXAMPLES } from './builtins';\n\n// Export the ExampleRegistry class from contracts\nexport { ExampleRegistry } from '@contractspec/lib.contracts';\n\n// Create a global registry instance populated with builtins\nconst globalRegistry = new ExampleRegistry();\n\n// Register all builtin examples\nfor (const example of BUILTIN_EXAMPLES) {\n globalRegistry.register(example);\n}\n\n/**\n * Global registry containing all builtin ContractSpec examples.\n * @deprecated Prefer using ExampleRegistry directly for custom registrations.\n */\nexport const EXAMPLE_REGISTRY: readonly ExampleSpec[] = globalRegistry.list();\n\n/**\n * List all registered examples.\n */\nexport function listExamples(): readonly ExampleSpec[] {\n return globalRegistry.list();\n}\n\n/**\n * Get an example by its key.\n */\nexport function getExample(key: string): ExampleSpec | undefined {\n return globalRegistry.get(key);\n}\n\n/**\n * Search examples by query (matches key, title, description, tags).\n */\nexport function searchExamples(query: string): ExampleSpec[] {\n return globalRegistry.search(query);\n}\n"],"mappings":";;;;AAQA,MAAM,iBAAiB,IAAI,iBAAiB;AAG5C,KAAK,MAAM,WAAWA,mBACpB,gBAAe,SAAS,QAAQ;;;;;AAOlC,MAAa,mBAA2C,eAAe,MAAM;;;;AAK7E,SAAgB,eAAuC;AACrD,QAAO,eAAe,MAAM;;;;;AAM9B,SAAgB,WAAW,KAAsC;AAC/D,QAAO,eAAe,IAAI,IAAI;;;;;AAMhC,SAAgB,eAAe,OAA8B;AAC3D,QAAO,eAAe,OAAO,MAAM"}
@@ -0,0 +1,45 @@
1
+ import { TransformEngine } from "@contractspec/lib.contracts/presentations";
2
+ import { AgentHandlers } from "@contractspec/example.agent-console";
3
+ import { SaasHandlers } from "@contractspec/example.saas-boilerplate";
4
+ import { CrmHandlers } from "@contractspec/example.crm-pipeline";
5
+ import { WorkflowHandlers } from "@contractspec/example.workflow-system";
6
+ import { MarketplaceHandlers } from "@contractspec/example.marketplace";
7
+ import { IntegrationHandlers } from "@contractspec/example.integration-hub";
8
+ import { AnalyticsHandlers } from "@contractspec/example.analytics-dashboard";
9
+ import { PropsWithChildren } from "react";
10
+ import * as react_jsx_runtime0 from "react/jsx-runtime";
11
+ import { PolicySafeKnowledgeAssistantHandlers } from "@contractspec/example.policy-safe-knowledge-assistant";
12
+ import { TemplateRuntimeProviderProps } from "@contractspec/lib.example-shared-ui";
13
+
14
+ //#region src/runtime/context.d.ts
15
+ /**
16
+ * Template-specific handlers created from the runtime database
17
+ */
18
+ declare class TemplateHandlers {
19
+ crm: CrmHandlers;
20
+ saas: SaasHandlers;
21
+ agent: AgentHandlers;
22
+ workflow: WorkflowHandlers;
23
+ marketplace: MarketplaceHandlers;
24
+ integration: IntegrationHandlers;
25
+ analytics: AnalyticsHandlers;
26
+ policySafeKnowledgeAssistant: PolicySafeKnowledgeAssistantHandlers;
27
+ }
28
+ declare function TemplateRuntimeProvider({
29
+ templateId,
30
+ projectId,
31
+ lazy,
32
+ children
33
+ }: PropsWithChildren<TemplateRuntimeProviderProps>): react_jsx_runtime0.JSX.Element;
34
+ declare function useTemplateEngine(): TransformEngine;
35
+ declare function useTemplateHandlers(): TemplateHandlers;
36
+ declare function useCrmHandlers(): CrmHandlers;
37
+ declare function useSaasHandlers(): SaasHandlers;
38
+ declare function useAgentHandlers(): AgentHandlers;
39
+ declare function useWorkflowHandlers(): WorkflowHandlers;
40
+ declare function useMarketplaceHandlers(): MarketplaceHandlers;
41
+ declare function useIntegrationHandlers(): IntegrationHandlers;
42
+ declare function useAnalyticsHandlers(): AnalyticsHandlers;
43
+ //#endregion
44
+ export { TemplateHandlers, TemplateRuntimeProvider, useAgentHandlers, useAnalyticsHandlers, useCrmHandlers, useIntegrationHandlers, useMarketplaceHandlers, useSaasHandlers, useTemplateEngine, useTemplateHandlers, useWorkflowHandlers };
45
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","names":[],"sources":["../../src/runtime/context.tsx"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;AA4Ea,cAAA,gBAAA,CAAgB;EACrB,GAAA,EAAA,WAAA;EACC,IAAA,EAAA,YAAA;EACC,KAAA,EAAA,aAAA;EACG,QAAA,EAAA,gBAAA;EACG,WAAA,EAAA,mBAAA;EACA,WAAA,EAAA,mBAAA;EACF,SAAA,EAAA,iBAAA;EACmB,4BAAA,EAAA,oCAAA;;AAGjB,iBAAA,uBAAA,CAAuB;EAAA,UAAA;EAAA,SAAA;EAAA,IAAA;EAAA;AAAA,CAAA,EAKpC,iBALoC,CAKlB,4BALkB,CAAA,CAAA,EAKW,kBAAA,CAAA,GAAA,CAAA,OALX;AACrC,iBA6Sc,iBAAA,CAAA,CA7Sd,EA6SmC,eA7SnC;AACA,iBAiTc,mBAAA,CAAA,CAjTd,EAiTqC,gBAjTrC;AACA,iBAqTc,cAAA,CAAA,CArTd,EAqTgC,WArThC;AACA,iBAyTc,eAAA,CAAA,CAzTd,EAyTiC,YAzTjC;AACmB,iBA6TL,gBAAA,CAAA,CA7TK,EA6Te,aA7Tf;AAAlB,iBAkUa,mBAAA,CAAA,CAlUb,EAkUoC,gBAlUpC;AAA+C,iBAuUlC,sBAAA,CAAA,CAvUkC,EAuUR,mBAvUQ;AAAA,iBA4UlC,sBAAA,CAAA,CA5UkC,EA4UR,mBA5UQ;AAySlC,iBAwCA,oBAAA,CAAA,CAxCqB,EAwCG,iBAxCY"}
@@ -0,0 +1,328 @@
1
+ 'use client';
2
+
3
+ import { getTemplateEngine } from "./engine.js";
4
+ import { getTemplate } from "./registry.js";
5
+ import { TemplateInstaller } from "./installer.js";
6
+ import "@contractspec/lib.contracts/presentations";
7
+ import { createAgentHandlers } from "@contractspec/example.agent-console";
8
+ import { createSaasHandlers } from "@contractspec/example.saas-boilerplate";
9
+ import { createCrmHandlers } from "@contractspec/example.crm-pipeline";
10
+ import { createWorkflowHandlers } from "@contractspec/example.workflow-system";
11
+ import { createMarketplaceHandlers } from "@contractspec/example.marketplace";
12
+ import { createIntegrationHandlers } from "@contractspec/example.integration-hub";
13
+ import { createAnalyticsHandlers } from "@contractspec/example.analytics-dashboard";
14
+ import { web } from "@contractspec/lib.runtime-sandbox";
15
+ import { useEffect, useMemo, useState } from "react";
16
+ import { ApolloProvider } from "@apollo/client/react";
17
+ import { jsx, jsxs } from "react/jsx-runtime";
18
+ import { createPolicySafeKnowledgeAssistantHandlers } from "@contractspec/example.policy-safe-knowledge-assistant";
19
+ import { TemplateRuntimeContext, useTemplateComponents, useTemplateRuntime } from "@contractspec/lib.example-shared-ui";
20
+
21
+ //#region src/runtime/context.tsx
22
+ const { LocalRuntimeServices } = web;
23
+ function logBootstrapFailure(error) {
24
+ console.error(`
25
+ [TemplateRuntime] Bootstrap Failed
26
+ ==================================
27
+
28
+ The runtime failed to initialize. This usually happens because:
29
+ 1. The PostgreSQL Web environment (pglite) failed to load
30
+ 2. The schema migration failed
31
+ 3. The initial seed data could not be inserted
32
+
33
+ Check the console for specific database errors.
34
+ `.trim(), error);
35
+ }
36
+ /**
37
+ * Template-specific handlers created from the runtime database
38
+ */
39
+ var TemplateHandlers = class {
40
+ crm;
41
+ saas;
42
+ agent;
43
+ workflow;
44
+ marketplace;
45
+ integration;
46
+ analytics;
47
+ policySafeKnowledgeAssistant;
48
+ };
49
+ function TemplateRuntimeProvider({ templateId, projectId = "default-project", lazy = false, children }) {
50
+ const [context, setContext] = useState(null);
51
+ const [error, setError] = useState(null);
52
+ useEffect(() => {
53
+ let mounted = true;
54
+ async function bootstrap() {
55
+ try {
56
+ if (lazy) return;
57
+ const template = getTemplate(templateId);
58
+ if (!template) throw new Error(`Template not found: ${templateId}`);
59
+ const runtime = new LocalRuntimeServices();
60
+ await runtime.init({});
61
+ const installer = new TemplateInstaller({ runtime });
62
+ await installer.install(templateId, { projectId });
63
+ const client = web.createLocalGraphqlClient(runtime);
64
+ const engine = await getTemplateEngine();
65
+ const handlers = new TemplateHandlers();
66
+ handlers.crm = createCrmHandlers(runtime.db);
67
+ handlers.saas = createSaasHandlers(runtime.db);
68
+ handlers.agent = createAgentHandlers(runtime.db);
69
+ handlers.workflow = createWorkflowHandlers(runtime.db);
70
+ handlers.marketplace = createMarketplaceHandlers(runtime.db);
71
+ handlers.integration = createIntegrationHandlers(runtime.db);
72
+ handlers.analytics = createAnalyticsHandlers(runtime.db);
73
+ handlers.policySafeKnowledgeAssistant = createPolicySafeKnowledgeAssistantHandlers(runtime.db);
74
+ const fetchData = async (presentationName) => {
75
+ if (presentationName === "crm-pipeline.dashboard") {
76
+ const [dealsResult, stages] = await Promise.all([handlers.crm.listDeals({
77
+ projectId,
78
+ pipelineId: "pipeline-1",
79
+ limit: 50
80
+ }), handlers.crm.getPipelineStages({ pipelineId: "pipeline-1" })]);
81
+ return {
82
+ data: {
83
+ deals: dealsResult.deals,
84
+ stages,
85
+ summary: {
86
+ total: dealsResult.total,
87
+ totalValue: dealsResult.totalValue
88
+ }
89
+ },
90
+ metadata: {
91
+ total: dealsResult.total,
92
+ timestamp: /* @__PURE__ */ new Date(),
93
+ source: "crm-pipeline"
94
+ }
95
+ };
96
+ }
97
+ if (presentationName === "crm-pipeline.deal.pipeline") {
98
+ const [dealsResult, stages] = await Promise.all([handlers.crm.listDeals({
99
+ projectId,
100
+ pipelineId: "pipeline-1",
101
+ limit: 100
102
+ }), handlers.crm.getPipelineStages({ pipelineId: "pipeline-1" })]);
103
+ return {
104
+ data: {
105
+ deals: dealsResult.deals,
106
+ stages,
107
+ total: dealsResult.total,
108
+ totalValue: dealsResult.totalValue
109
+ },
110
+ metadata: {
111
+ total: dealsResult.total,
112
+ timestamp: /* @__PURE__ */ new Date(),
113
+ source: "crm-pipeline"
114
+ }
115
+ };
116
+ }
117
+ if (presentationName === "saas-boilerplate.dashboard") {
118
+ const [projectsResult, subscription] = await Promise.all([handlers.saas.listProjects({
119
+ projectId,
120
+ limit: 10
121
+ }), handlers.saas.getSubscription({ projectId })]);
122
+ return {
123
+ data: {
124
+ projects: projectsResult.items,
125
+ subscription,
126
+ summary: { totalProjects: projectsResult.total }
127
+ },
128
+ metadata: {
129
+ total: projectsResult.total,
130
+ timestamp: /* @__PURE__ */ new Date(),
131
+ source: "saas-boilerplate"
132
+ }
133
+ };
134
+ }
135
+ if (presentationName === "saas-boilerplate.project.list") {
136
+ const result = await handlers.saas.listProjects({
137
+ projectId,
138
+ limit: 50
139
+ });
140
+ return {
141
+ data: result.items,
142
+ metadata: {
143
+ total: result.total,
144
+ timestamp: /* @__PURE__ */ new Date(),
145
+ source: "saas-boilerplate"
146
+ }
147
+ };
148
+ }
149
+ if (presentationName === "saas-boilerplate.billing.settings") return {
150
+ data: await handlers.saas.getSubscription({ projectId }),
151
+ metadata: {
152
+ timestamp: /* @__PURE__ */ new Date(),
153
+ source: "saas-boilerplate"
154
+ }
155
+ };
156
+ if (presentationName === "agent-console.dashboard") {
157
+ const [agentsResult, runsResult, toolsResult] = await Promise.all([
158
+ handlers.agent.listAgents({
159
+ projectId,
160
+ organizationId: "demo-org",
161
+ limit: 10
162
+ }),
163
+ handlers.agent.listRuns({
164
+ projectId,
165
+ limit: 10
166
+ }),
167
+ handlers.agent.listTools({
168
+ projectId,
169
+ organizationId: "demo-org",
170
+ limit: 10
171
+ })
172
+ ]);
173
+ return {
174
+ data: {
175
+ agents: agentsResult.items,
176
+ runs: runsResult.items,
177
+ tools: toolsResult.items,
178
+ summary: {
179
+ totalAgents: agentsResult.total,
180
+ totalRuns: runsResult.total,
181
+ totalTools: toolsResult.total
182
+ }
183
+ },
184
+ metadata: {
185
+ timestamp: /* @__PURE__ */ new Date(),
186
+ source: "agent-console"
187
+ }
188
+ };
189
+ }
190
+ if (presentationName === "agent-console.agent.list") {
191
+ const result = await handlers.agent.listAgents({
192
+ projectId,
193
+ organizationId: "demo-org",
194
+ limit: 50
195
+ });
196
+ return {
197
+ data: result.items,
198
+ metadata: {
199
+ total: result.total,
200
+ timestamp: /* @__PURE__ */ new Date(),
201
+ source: "agent-console"
202
+ }
203
+ };
204
+ }
205
+ if (presentationName === "agent-console.run.list") {
206
+ const result = await handlers.agent.listRuns({
207
+ projectId,
208
+ limit: 50
209
+ });
210
+ return {
211
+ data: result.items,
212
+ metadata: {
213
+ total: result.total,
214
+ timestamp: /* @__PURE__ */ new Date(),
215
+ source: "agent-console"
216
+ }
217
+ };
218
+ }
219
+ if (presentationName === "agent-console.tool.registry") {
220
+ const result = await handlers.agent.listTools({
221
+ projectId,
222
+ organizationId: "demo-org",
223
+ limit: 50
224
+ });
225
+ return {
226
+ data: result.items,
227
+ metadata: {
228
+ total: result.total,
229
+ timestamp: /* @__PURE__ */ new Date(),
230
+ source: "agent-console"
231
+ }
232
+ };
233
+ }
234
+ console.warn(`No data fetcher found for presentation: ${presentationName}`);
235
+ return {
236
+ data: null,
237
+ metadata: {
238
+ timestamp: /* @__PURE__ */ new Date(),
239
+ source: "unknown"
240
+ }
241
+ };
242
+ };
243
+ if (mounted) setContext({
244
+ template,
245
+ runtime,
246
+ installer,
247
+ client,
248
+ templateId,
249
+ projectId,
250
+ engine,
251
+ handlers,
252
+ fetchData
253
+ });
254
+ } catch (err) {
255
+ logBootstrapFailure(err);
256
+ if (mounted) setError(err instanceof Error ? err : /* @__PURE__ */ new Error("Unknown runtime error"));
257
+ }
258
+ }
259
+ bootstrap();
260
+ return () => {
261
+ mounted = false;
262
+ };
263
+ }, [
264
+ templateId,
265
+ projectId,
266
+ lazy
267
+ ]);
268
+ const components = useTemplateComponents(templateId);
269
+ const contextValue = useMemo(() => {
270
+ if (!context) return null;
271
+ return {
272
+ ...context,
273
+ components
274
+ };
275
+ }, [context, components]);
276
+ if (error) return /* @__PURE__ */ jsxs("div", {
277
+ className: "rounded border border-red-200 bg-red-50 p-4 text-red-500",
278
+ children: [/* @__PURE__ */ jsx("h3", {
279
+ className: "font-bold",
280
+ children: "Runtime Error"
281
+ }), /* @__PURE__ */ jsx("pre", {
282
+ className: "mt-2 overflow-auto text-xs",
283
+ children: error.message
284
+ })]
285
+ });
286
+ if (!contextValue) return /* @__PURE__ */ jsx("div", {
287
+ className: "animate-pulse p-12 text-center text-gray-400",
288
+ children: "Initializing runtime environment..."
289
+ });
290
+ return /* @__PURE__ */ jsx(ApolloProvider, {
291
+ client: contextValue.client,
292
+ children: /* @__PURE__ */ jsx(TemplateRuntimeContext.Provider, {
293
+ value: contextValue,
294
+ children
295
+ })
296
+ });
297
+ }
298
+ function useTemplateEngine() {
299
+ return useTemplateRuntime().engine;
300
+ }
301
+ function useTemplateHandlers() {
302
+ return useTemplateRuntime().handlers;
303
+ }
304
+ function useCrmHandlers() {
305
+ return useTemplateHandlers().crm;
306
+ }
307
+ function useSaasHandlers() {
308
+ return useTemplateHandlers().saas;
309
+ }
310
+ function useAgentHandlers() {
311
+ return useTemplateHandlers().agent;
312
+ }
313
+ function useWorkflowHandlers() {
314
+ return useTemplateHandlers().workflow;
315
+ }
316
+ function useMarketplaceHandlers() {
317
+ return useTemplateHandlers().marketplace;
318
+ }
319
+ function useIntegrationHandlers() {
320
+ return useTemplateHandlers().integration;
321
+ }
322
+ function useAnalyticsHandlers() {
323
+ return useTemplateHandlers().analytics;
324
+ }
325
+
326
+ //#endregion
327
+ export { TemplateHandlers, TemplateRuntimeProvider, useAgentHandlers, useAnalyticsHandlers, useCrmHandlers, useIntegrationHandlers, useMarketplaceHandlers, useSaasHandlers, useTemplateEngine, useTemplateHandlers, useWorkflowHandlers };
328
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","names":[],"sources":["../../src/runtime/context.tsx"],"sourcesContent":["'use client';\n\nimport { type PropsWithChildren, useEffect, useMemo, useState } from 'react';\nimport { ApolloProvider } from '@apollo/client/react';\nimport { web } from '@contractspec/lib.runtime-sandbox';\n\nconst { LocalRuntimeServices } = web;\n\nimport { type TransformEngine } from '@contractspec/lib.contracts/presentations';\n\n// Import handlers from example packages\nimport {\n createCrmHandlers,\n type CrmHandlers,\n} from '@contractspec/example.crm-pipeline';\nimport {\n createSaasHandlers,\n type SaasHandlers,\n} from '@contractspec/example.saas-boilerplate';\nimport {\n createAgentHandlers,\n type AgentHandlers,\n} from '@contractspec/example.agent-console';\nimport {\n createWorkflowHandlers,\n type WorkflowHandlers,\n} from '@contractspec/example.workflow-system';\nimport {\n createMarketplaceHandlers,\n type MarketplaceHandlers,\n} from '@contractspec/example.marketplace';\nimport {\n createIntegrationHandlers,\n type IntegrationHandlers,\n} from '@contractspec/example.integration-hub';\nimport {\n createAnalyticsHandlers,\n type AnalyticsHandlers,\n} from '@contractspec/example.analytics-dashboard';\nimport {\n createPolicySafeKnowledgeAssistantHandlers,\n type PolicySafeKnowledgeAssistantHandlers,\n} from '@contractspec/example.policy-safe-knowledge-assistant';\n\nimport { TemplateInstaller } from './installer';\nimport { getTemplate } from './registry';\nimport { getTemplateEngine } from './engine';\n\nimport {\n TemplateRuntimeContext,\n type TemplateRuntimeContextValue,\n type TemplateRuntimeProviderProps,\n useTemplateRuntime,\n useTemplateComponents,\n} from '@contractspec/lib.example-shared-ui';\n\nfunction logBootstrapFailure(error: unknown) {\n console.error(\n `\n[TemplateRuntime] Bootstrap Failed\n==================================\n\nThe runtime failed to initialize. This usually happens because:\n1. The PostgreSQL Web environment (pglite) failed to load\n2. The schema migration failed\n3. The initial seed data could not be inserted\n\nCheck the console for specific database errors.\n `.trim(),\n error\n );\n}\n\n/**\n * Template-specific handlers created from the runtime database\n */\nexport class TemplateHandlers {\n crm!: CrmHandlers;\n saas!: SaasHandlers;\n agent!: AgentHandlers;\n workflow!: WorkflowHandlers;\n marketplace!: MarketplaceHandlers;\n integration!: IntegrationHandlers;\n analytics!: AnalyticsHandlers;\n policySafeKnowledgeAssistant!: PolicySafeKnowledgeAssistantHandlers;\n}\n\nexport function TemplateRuntimeProvider({\n templateId,\n projectId = 'default-project',\n lazy = false,\n children,\n}: PropsWithChildren<TemplateRuntimeProviderProps>) {\n const [context, setContext] = useState<TemplateRuntimeContextValue | null>(\n null\n );\n const [error, setError] = useState<Error | null>(null);\n\n useEffect(() => {\n let mounted = true;\n\n async function bootstrap() {\n try {\n if (lazy) return;\n\n // Load definition\n const template = getTemplate(templateId);\n if (!template) {\n throw new Error(`Template not found: ${templateId}`);\n }\n\n // Initialize runtime\n const runtime = new LocalRuntimeServices();\n await runtime.init({\n // In real app, we might persist to IndexedDB\n // dataDir: projectId // If persistence needed\n });\n\n // Initialize installer and run migrations/seeds\n const installer = new TemplateInstaller({ runtime });\n await installer.install(templateId, { projectId });\n\n // Create Apollo Client linked to local schema\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const client = (web as any).createLocalGraphqlClient(runtime);\n\n // Get or create transform engine\n const engine = await getTemplateEngine();\n\n // Initialize Handlers\n const handlers = new TemplateHandlers();\n handlers.crm = createCrmHandlers(runtime.db);\n handlers.saas = createSaasHandlers(runtime.db);\n handlers.agent = createAgentHandlers(runtime.db);\n handlers.workflow = createWorkflowHandlers(runtime.db);\n handlers.marketplace = createMarketplaceHandlers(runtime.db);\n handlers.integration = createIntegrationHandlers(runtime.db);\n handlers.analytics = createAnalyticsHandlers(runtime.db);\n handlers.policySafeKnowledgeAssistant =\n createPolicySafeKnowledgeAssistantHandlers(runtime.db);\n\n // Create data fetcher using the initialized handlers\n const fetchData = async (presentationName: string) => {\n // CRM Pipeline\n if (presentationName === 'crm-pipeline.dashboard') {\n const [dealsResult, stages] = await Promise.all([\n handlers.crm.listDeals({\n projectId,\n pipelineId: 'pipeline-1',\n limit: 50,\n }),\n handlers.crm.getPipelineStages({ pipelineId: 'pipeline-1' }),\n ]);\n return {\n data: {\n deals: dealsResult.deals,\n stages,\n summary: {\n total: dealsResult.total,\n totalValue: dealsResult.totalValue,\n },\n },\n metadata: {\n total: dealsResult.total,\n timestamp: new Date(),\n source: 'crm-pipeline',\n },\n };\n }\n if (presentationName === 'crm-pipeline.deal.pipeline') {\n const [dealsResult, stages] = await Promise.all([\n handlers.crm.listDeals({\n projectId,\n pipelineId: 'pipeline-1',\n limit: 100,\n }),\n handlers.crm.getPipelineStages({ pipelineId: 'pipeline-1' }),\n ]);\n return {\n data: {\n deals: dealsResult.deals,\n stages,\n total: dealsResult.total,\n totalValue: dealsResult.totalValue,\n },\n metadata: {\n total: dealsResult.total,\n timestamp: new Date(),\n source: 'crm-pipeline',\n },\n };\n }\n\n // SaaS Boilerplate\n if (presentationName === 'saas-boilerplate.dashboard') {\n const [projectsResult, subscription] = await Promise.all([\n handlers.saas.listProjects({ projectId, limit: 10 }),\n handlers.saas.getSubscription({ projectId }),\n ]);\n return {\n data: {\n projects: projectsResult.items,\n subscription,\n summary: { totalProjects: projectsResult.total },\n },\n metadata: {\n total: projectsResult.total,\n timestamp: new Date(),\n source: 'saas-boilerplate',\n },\n };\n }\n if (presentationName === 'saas-boilerplate.project.list') {\n const result = await handlers.saas.listProjects({\n projectId,\n limit: 50,\n });\n return {\n data: result.items,\n metadata: {\n total: result.total,\n timestamp: new Date(),\n source: 'saas-boilerplate',\n },\n };\n }\n if (presentationName === 'saas-boilerplate.billing.settings') {\n const subscription = await handlers.saas.getSubscription({\n projectId,\n });\n return {\n data: subscription,\n metadata: { timestamp: new Date(), source: 'saas-boilerplate' },\n };\n }\n\n // Agent Console\n if (presentationName === 'agent-console.dashboard') {\n const [agentsResult, runsResult, toolsResult] = await Promise.all([\n handlers.agent.listAgents({\n projectId,\n organizationId: 'demo-org',\n limit: 10,\n }),\n handlers.agent.listRuns({ projectId, limit: 10 }),\n handlers.agent.listTools({\n projectId,\n organizationId: 'demo-org',\n limit: 10,\n }),\n ]);\n return {\n data: {\n agents: agentsResult.items,\n runs: runsResult.items,\n tools: toolsResult.items,\n summary: {\n totalAgents: agentsResult.total,\n totalRuns: runsResult.total,\n totalTools: toolsResult.total,\n },\n },\n metadata: { timestamp: new Date(), source: 'agent-console' },\n };\n }\n if (presentationName === 'agent-console.agent.list') {\n const result = await handlers.agent.listAgents({\n projectId,\n organizationId: 'demo-org',\n limit: 50,\n });\n return {\n data: result.items,\n metadata: {\n total: result.total,\n timestamp: new Date(),\n source: 'agent-console',\n },\n };\n }\n if (presentationName === 'agent-console.run.list') {\n const result = await handlers.agent.listRuns({\n projectId,\n limit: 50,\n });\n return {\n data: result.items,\n metadata: {\n total: result.total,\n timestamp: new Date(),\n source: 'agent-console',\n },\n };\n }\n if (presentationName === 'agent-console.tool.registry') {\n const result = await handlers.agent.listTools({\n projectId,\n organizationId: 'demo-org',\n limit: 50,\n });\n return {\n data: result.items,\n metadata: {\n total: result.total,\n timestamp: new Date(),\n source: 'agent-console',\n },\n };\n }\n\n // Default fallback\n console.warn(\n `No data fetcher found for presentation: ${presentationName}`\n );\n return {\n data: null,\n metadata: { timestamp: new Date(), source: 'unknown' },\n };\n };\n\n if (mounted) {\n setContext({\n template,\n runtime,\n installer,\n client,\n templateId,\n projectId,\n engine,\n handlers,\n fetchData,\n });\n }\n } catch (err) {\n logBootstrapFailure(err);\n if (mounted) {\n setError(\n err instanceof Error ? err : new Error('Unknown runtime error')\n );\n }\n }\n }\n\n bootstrap();\n\n return () => {\n mounted = false;\n };\n }, [templateId, projectId, lazy]);\n\n // Load registered components\n const components = useTemplateComponents(templateId);\n\n // Combine context with components\n const contextValue = useMemo(() => {\n if (!context) return null;\n return {\n ...context,\n components,\n };\n }, [context, components]);\n\n if (error) {\n return (\n <div className=\"rounded border border-red-200 bg-red-50 p-4 text-red-500\">\n <h3 className=\"font-bold\">Runtime Error</h3>\n <pre className=\"mt-2 overflow-auto text-xs\">{error.message}</pre>\n </div>\n );\n }\n\n if (!contextValue) {\n return (\n <div className=\"animate-pulse p-12 text-center text-gray-400\">\n Initializing runtime environment...\n </div>\n );\n }\n\n return (\n <ApolloProvider client={contextValue.client}>\n <TemplateRuntimeContext.Provider value={contextValue}>\n {children}\n </TemplateRuntimeContext.Provider>\n </ApolloProvider>\n );\n}\n\n// Hook to access the TransformEngine for rendering presentations\nexport function useTemplateEngine(): TransformEngine {\n return useTemplateRuntime().engine;\n}\n\n// Hook to access the database-backed template handlers\nexport function useTemplateHandlers(): TemplateHandlers {\n return useTemplateRuntime<TemplateHandlers>().handlers;\n}\n\n// Hook to access CRM-specific handlers\nexport function useCrmHandlers(): CrmHandlers {\n return useTemplateHandlers().crm;\n}\n\n// Hook to access SaaS-specific handlers\nexport function useSaasHandlers(): SaasHandlers {\n return useTemplateHandlers().saas;\n}\n\n// Hook to access Agent Console-specific handlers\nexport function useAgentHandlers(): AgentHandlers {\n return useTemplateHandlers().agent;\n}\n\n// Hook to access Workflow-specific handlers\nexport function useWorkflowHandlers(): WorkflowHandlers {\n return useTemplateHandlers().workflow;\n}\n\n// Hook to access Marketplace-specific handlers\nexport function useMarketplaceHandlers(): MarketplaceHandlers {\n return useTemplateHandlers().marketplace;\n}\n\n// Hook to access Integration Hub-specific handlers\nexport function useIntegrationHandlers(): IntegrationHandlers {\n return useTemplateHandlers().integration;\n}\n\n// Hook to access Analytics Dashboard-specific handlers\nexport function useAnalyticsHandlers(): AnalyticsHandlers {\n return useTemplateHandlers().analytics;\n}\n\n// End of file\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAMA,MAAM,EAAE,yBAAyB;AAkDjC,SAAS,oBAAoB,OAAgB;AAC3C,SAAQ,MACN;;;;;;;;;;MAUE,MAAM,EACR,MACD;;;;;AAMH,IAAa,mBAAb,MAA8B;CAC5B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;AAGF,SAAgB,wBAAwB,EACtC,YACA,YAAY,mBACZ,OAAO,OACP,YACkD;CAClD,MAAM,CAAC,SAAS,cAAc,SAC5B,KACD;CACD,MAAM,CAAC,OAAO,YAAY,SAAuB,KAAK;AAEtD,iBAAgB;EACd,IAAI,UAAU;EAEd,eAAe,YAAY;AACzB,OAAI;AACF,QAAI,KAAM;IAGV,MAAM,WAAW,YAAY,WAAW;AACxC,QAAI,CAAC,SACH,OAAM,IAAI,MAAM,uBAAuB,aAAa;IAItD,MAAM,UAAU,IAAI,sBAAsB;AAC1C,UAAM,QAAQ,KAAK,EAGlB,CAAC;IAGF,MAAM,YAAY,IAAI,kBAAkB,EAAE,SAAS,CAAC;AACpD,UAAM,UAAU,QAAQ,YAAY,EAAE,WAAW,CAAC;IAIlD,MAAM,SAAU,IAAY,yBAAyB,QAAQ;IAG7D,MAAM,SAAS,MAAM,mBAAmB;IAGxC,MAAM,WAAW,IAAI,kBAAkB;AACvC,aAAS,MAAM,kBAAkB,QAAQ,GAAG;AAC5C,aAAS,OAAO,mBAAmB,QAAQ,GAAG;AAC9C,aAAS,QAAQ,oBAAoB,QAAQ,GAAG;AAChD,aAAS,WAAW,uBAAuB,QAAQ,GAAG;AACtD,aAAS,cAAc,0BAA0B,QAAQ,GAAG;AAC5D,aAAS,cAAc,0BAA0B,QAAQ,GAAG;AAC5D,aAAS,YAAY,wBAAwB,QAAQ,GAAG;AACxD,aAAS,+BACP,2CAA2C,QAAQ,GAAG;IAGxD,MAAM,YAAY,OAAO,qBAA6B;AAEpD,SAAI,qBAAqB,0BAA0B;MACjD,MAAM,CAAC,aAAa,UAAU,MAAM,QAAQ,IAAI,CAC9C,SAAS,IAAI,UAAU;OACrB;OACA,YAAY;OACZ,OAAO;OACR,CAAC,EACF,SAAS,IAAI,kBAAkB,EAAE,YAAY,cAAc,CAAC,CAC7D,CAAC;AACF,aAAO;OACL,MAAM;QACJ,OAAO,YAAY;QACnB;QACA,SAAS;SACP,OAAO,YAAY;SACnB,YAAY,YAAY;SACzB;QACF;OACD,UAAU;QACR,OAAO,YAAY;QACnB,2BAAW,IAAI,MAAM;QACrB,QAAQ;QACT;OACF;;AAEH,SAAI,qBAAqB,8BAA8B;MACrD,MAAM,CAAC,aAAa,UAAU,MAAM,QAAQ,IAAI,CAC9C,SAAS,IAAI,UAAU;OACrB;OACA,YAAY;OACZ,OAAO;OACR,CAAC,EACF,SAAS,IAAI,kBAAkB,EAAE,YAAY,cAAc,CAAC,CAC7D,CAAC;AACF,aAAO;OACL,MAAM;QACJ,OAAO,YAAY;QACnB;QACA,OAAO,YAAY;QACnB,YAAY,YAAY;QACzB;OACD,UAAU;QACR,OAAO,YAAY;QACnB,2BAAW,IAAI,MAAM;QACrB,QAAQ;QACT;OACF;;AAIH,SAAI,qBAAqB,8BAA8B;MACrD,MAAM,CAAC,gBAAgB,gBAAgB,MAAM,QAAQ,IAAI,CACvD,SAAS,KAAK,aAAa;OAAE;OAAW,OAAO;OAAI,CAAC,EACpD,SAAS,KAAK,gBAAgB,EAAE,WAAW,CAAC,CAC7C,CAAC;AACF,aAAO;OACL,MAAM;QACJ,UAAU,eAAe;QACzB;QACA,SAAS,EAAE,eAAe,eAAe,OAAO;QACjD;OACD,UAAU;QACR,OAAO,eAAe;QACtB,2BAAW,IAAI,MAAM;QACrB,QAAQ;QACT;OACF;;AAEH,SAAI,qBAAqB,iCAAiC;MACxD,MAAM,SAAS,MAAM,SAAS,KAAK,aAAa;OAC9C;OACA,OAAO;OACR,CAAC;AACF,aAAO;OACL,MAAM,OAAO;OACb,UAAU;QACR,OAAO,OAAO;QACd,2BAAW,IAAI,MAAM;QACrB,QAAQ;QACT;OACF;;AAEH,SAAI,qBAAqB,oCAIvB,QAAO;MACL,MAJmB,MAAM,SAAS,KAAK,gBAAgB,EACvD,WACD,CAAC;MAGA,UAAU;OAAE,2BAAW,IAAI,MAAM;OAAE,QAAQ;OAAoB;MAChE;AAIH,SAAI,qBAAqB,2BAA2B;MAClD,MAAM,CAAC,cAAc,YAAY,eAAe,MAAM,QAAQ,IAAI;OAChE,SAAS,MAAM,WAAW;QACxB;QACA,gBAAgB;QAChB,OAAO;QACR,CAAC;OACF,SAAS,MAAM,SAAS;QAAE;QAAW,OAAO;QAAI,CAAC;OACjD,SAAS,MAAM,UAAU;QACvB;QACA,gBAAgB;QAChB,OAAO;QACR,CAAC;OACH,CAAC;AACF,aAAO;OACL,MAAM;QACJ,QAAQ,aAAa;QACrB,MAAM,WAAW;QACjB,OAAO,YAAY;QACnB,SAAS;SACP,aAAa,aAAa;SAC1B,WAAW,WAAW;SACtB,YAAY,YAAY;SACzB;QACF;OACD,UAAU;QAAE,2BAAW,IAAI,MAAM;QAAE,QAAQ;QAAiB;OAC7D;;AAEH,SAAI,qBAAqB,4BAA4B;MACnD,MAAM,SAAS,MAAM,SAAS,MAAM,WAAW;OAC7C;OACA,gBAAgB;OAChB,OAAO;OACR,CAAC;AACF,aAAO;OACL,MAAM,OAAO;OACb,UAAU;QACR,OAAO,OAAO;QACd,2BAAW,IAAI,MAAM;QACrB,QAAQ;QACT;OACF;;AAEH,SAAI,qBAAqB,0BAA0B;MACjD,MAAM,SAAS,MAAM,SAAS,MAAM,SAAS;OAC3C;OACA,OAAO;OACR,CAAC;AACF,aAAO;OACL,MAAM,OAAO;OACb,UAAU;QACR,OAAO,OAAO;QACd,2BAAW,IAAI,MAAM;QACrB,QAAQ;QACT;OACF;;AAEH,SAAI,qBAAqB,+BAA+B;MACtD,MAAM,SAAS,MAAM,SAAS,MAAM,UAAU;OAC5C;OACA,gBAAgB;OAChB,OAAO;OACR,CAAC;AACF,aAAO;OACL,MAAM,OAAO;OACb,UAAU;QACR,OAAO,OAAO;QACd,2BAAW,IAAI,MAAM;QACrB,QAAQ;QACT;OACF;;AAIH,aAAQ,KACN,2CAA2C,mBAC5C;AACD,YAAO;MACL,MAAM;MACN,UAAU;OAAE,2BAAW,IAAI,MAAM;OAAE,QAAQ;OAAW;MACvD;;AAGH,QAAI,QACF,YAAW;KACT;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACD,CAAC;YAEG,KAAK;AACZ,wBAAoB,IAAI;AACxB,QAAI,QACF,UACE,eAAe,QAAQ,sBAAM,IAAI,MAAM,wBAAwB,CAChE;;;AAKP,aAAW;AAEX,eAAa;AACX,aAAU;;IAEX;EAAC;EAAY;EAAW;EAAK,CAAC;CAGjC,MAAM,aAAa,sBAAsB,WAAW;CAGpD,MAAM,eAAe,cAAc;AACjC,MAAI,CAAC,QAAS,QAAO;AACrB,SAAO;GACL,GAAG;GACH;GACD;IACA,CAAC,SAAS,WAAW,CAAC;AAEzB,KAAI,MACF,QACE,qBAAC;EAAI,WAAU;aACb,oBAAC;GAAG,WAAU;aAAY;IAAkB,EAC5C,oBAAC;GAAI,WAAU;aAA8B,MAAM;IAAc;GAC7D;AAIV,KAAI,CAAC,aACH,QACE,oBAAC;EAAI,WAAU;YAA+C;GAExD;AAIV,QACE,oBAAC;EAAe,QAAQ,aAAa;YACnC,oBAAC,uBAAuB;GAAS,OAAO;GACrC;IAC+B;GACnB;;AAKrB,SAAgB,oBAAqC;AACnD,QAAO,oBAAoB,CAAC;;AAI9B,SAAgB,sBAAwC;AACtD,QAAO,oBAAsC,CAAC;;AAIhD,SAAgB,iBAA8B;AAC5C,QAAO,qBAAqB,CAAC;;AAI/B,SAAgB,kBAAgC;AAC9C,QAAO,qBAAqB,CAAC;;AAI/B,SAAgB,mBAAkC;AAChD,QAAO,qBAAqB,CAAC;;AAI/B,SAAgB,sBAAwC;AACtD,QAAO,qBAAqB,CAAC;;AAI/B,SAAgB,yBAA8C;AAC5D,QAAO,qBAAqB,CAAC;;AAI/B,SAAgB,yBAA8C;AAC5D,QAAO,qBAAqB,CAAC;;AAI/B,SAAgB,uBAA0C;AACxD,QAAO,qBAAqB,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { TransformEngine } from "@contractspec/lib.contracts/presentations";
2
+
3
+ //#region src/runtime/engine.d.ts
4
+
5
+ /**
6
+ * Create a TransformEngine configured for template rendering
7
+ */
8
+ declare function createTemplateTransformEngine(): TransformEngine;
9
+ /**
10
+ * Get or create the shared template engine instance
11
+ */
12
+ declare function getTemplateEngine(): TransformEngine;
13
+ /**
14
+ * Reset the shared engine (useful for testing)
15
+ */
16
+ declare function resetTemplateEngine(): void;
17
+ //#endregion
18
+ export { createTemplateTransformEngine, getTemplateEngine, resetTemplateEngine };
19
+ //# sourceMappingURL=engine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engine.d.ts","names":[],"sources":["../../src/runtime/engine.ts"],"sourcesContent":[],"mappings":";;;;;;;iBA8DgB,6BAAA,CAAA,GAAiC;;;;iBAqEjC,iBAAA,CAAA,GAAqB;;;;iBAUrB,mBAAA,CAAA"}
@@ -0,0 +1,81 @@
1
+ import { createDefaultTransformEngine, registerBasicValidation, registerDefaultReactRenderer } from "@contractspec/lib.contracts/presentations";
2
+ import { agentDashboardMarkdownRenderer, agentListMarkdownRenderer, agentListReactRenderer, runListMarkdownRenderer, toolRegistryMarkdownRenderer } from "@contractspec/example.agent-console";
3
+ import { projectListMarkdownRenderer, projectListReactRenderer, saasBillingMarkdownRenderer, saasDashboardMarkdownRenderer } from "@contractspec/example.saas-boilerplate";
4
+ import { crmDashboardMarkdownRenderer, crmPipelineMarkdownRenderer, crmPipelineReactRenderer } from "@contractspec/example.crm-pipeline";
5
+ import { workflowDashboardMarkdownRenderer, workflowDefinitionListMarkdownRenderer, workflowInstanceDetailMarkdownRenderer } from "@contractspec/example.workflow-system";
6
+ import { marketplaceDashboardMarkdownRenderer, orderListMarkdownRenderer, productCatalogMarkdownRenderer } from "@contractspec/example.marketplace";
7
+ import { connectionListMarkdownRenderer, integrationDashboardMarkdownRenderer, syncConfigMarkdownRenderer } from "@contractspec/example.integration-hub";
8
+ import { analyticsDashboardMarkdownRenderer, dashboardListMarkdownRenderer, queryBuilderMarkdownRenderer } from "@contractspec/example.analytics-dashboard";
9
+
10
+ //#region src/runtime/engine.ts
11
+ /**
12
+ * Template TransformEngine Setup
13
+ *
14
+ * Creates and configures a TransformEngine instance with all template-specific
15
+ * renderers for React and Markdown targets.
16
+ */
17
+ /**
18
+ * Create a TransformEngine configured for template rendering
19
+ */
20
+ function createTemplateTransformEngine() {
21
+ const engine = createDefaultTransformEngine();
22
+ registerDefaultReactRenderer(engine);
23
+ registerBasicValidation(engine);
24
+ registerTemplateRenderers(engine);
25
+ return engine;
26
+ }
27
+ /**
28
+ * Register all template-specific renderers
29
+ *
30
+ * Custom markdown renderers are registered here and will be tried AFTER
31
+ * the default schema-driven renderer. Each custom renderer is responsible
32
+ * for checking if it handles the specific presentation (via componentKey)
33
+ * and throwing if not, allowing the next renderer in the chain to try.
34
+ */
35
+ function registerTemplateRenderers(engine) {
36
+ engine.register(agentListReactRenderer);
37
+ engine.register(agentListMarkdownRenderer);
38
+ engine.register(runListMarkdownRenderer);
39
+ engine.register(toolRegistryMarkdownRenderer);
40
+ engine.register(agentDashboardMarkdownRenderer);
41
+ engine.register(projectListReactRenderer);
42
+ engine.register(projectListMarkdownRenderer);
43
+ engine.register(saasDashboardMarkdownRenderer);
44
+ engine.register(saasBillingMarkdownRenderer);
45
+ engine.register(crmPipelineReactRenderer);
46
+ engine.register(crmPipelineMarkdownRenderer);
47
+ engine.register(crmDashboardMarkdownRenderer);
48
+ engine.register(workflowDashboardMarkdownRenderer);
49
+ engine.register(workflowDefinitionListMarkdownRenderer);
50
+ engine.register(workflowInstanceDetailMarkdownRenderer);
51
+ engine.register(marketplaceDashboardMarkdownRenderer);
52
+ engine.register(productCatalogMarkdownRenderer);
53
+ engine.register(orderListMarkdownRenderer);
54
+ engine.register(integrationDashboardMarkdownRenderer);
55
+ engine.register(connectionListMarkdownRenderer);
56
+ engine.register(syncConfigMarkdownRenderer);
57
+ engine.register(analyticsDashboardMarkdownRenderer);
58
+ engine.register(dashboardListMarkdownRenderer);
59
+ engine.register(queryBuilderMarkdownRenderer);
60
+ }
61
+ /**
62
+ * Singleton instance for shared engine
63
+ */
64
+ let templateEngine = null;
65
+ /**
66
+ * Get or create the shared template engine instance
67
+ */
68
+ function getTemplateEngine() {
69
+ if (!templateEngine) templateEngine = createTemplateTransformEngine();
70
+ return templateEngine;
71
+ }
72
+ /**
73
+ * Reset the shared engine (useful for testing)
74
+ */
75
+ function resetTemplateEngine() {
76
+ templateEngine = null;
77
+ }
78
+
79
+ //#endregion
80
+ export { createTemplateTransformEngine, getTemplateEngine, resetTemplateEngine };
81
+ //# sourceMappingURL=engine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engine.js","names":[],"sources":["../../src/runtime/engine.ts"],"sourcesContent":["/**\n * Template TransformEngine Setup\n *\n * Creates and configures a TransformEngine instance with all template-specific\n * renderers for React and Markdown targets.\n */\nimport {\n createDefaultTransformEngine,\n registerBasicValidation,\n registerDefaultReactRenderer,\n type TransformEngine,\n} from '@contractspec/lib.contracts/presentations';\n\n// Import template renderers from example packages\nimport {\n agentDashboardMarkdownRenderer,\n agentListMarkdownRenderer,\n agentListReactRenderer,\n runListMarkdownRenderer,\n toolRegistryMarkdownRenderer,\n} from '@contractspec/example.agent-console';\n\nimport {\n projectListMarkdownRenderer,\n projectListReactRenderer,\n saasBillingMarkdownRenderer,\n saasDashboardMarkdownRenderer,\n} from '@contractspec/example.saas-boilerplate';\n\nimport {\n crmDashboardMarkdownRenderer,\n crmPipelineMarkdownRenderer,\n crmPipelineReactRenderer,\n} from '@contractspec/example.crm-pipeline';\n\nimport {\n workflowDashboardMarkdownRenderer,\n workflowDefinitionListMarkdownRenderer,\n workflowInstanceDetailMarkdownRenderer,\n} from '@contractspec/example.workflow-system';\n\nimport {\n marketplaceDashboardMarkdownRenderer,\n orderListMarkdownRenderer,\n productCatalogMarkdownRenderer,\n} from '@contractspec/example.marketplace';\n\nimport {\n connectionListMarkdownRenderer,\n integrationDashboardMarkdownRenderer,\n syncConfigMarkdownRenderer,\n} from '@contractspec/example.integration-hub';\n\nimport {\n analyticsDashboardMarkdownRenderer,\n dashboardListMarkdownRenderer,\n queryBuilderMarkdownRenderer,\n} from '@contractspec/example.analytics-dashboard';\n\n/**\n * Create a TransformEngine configured for template rendering\n */\nexport function createTemplateTransformEngine(): TransformEngine {\n const engine = createDefaultTransformEngine();\n\n // Register default renderers\n registerDefaultReactRenderer(engine);\n registerBasicValidation(engine);\n\n // Register template-specific renderers\n registerTemplateRenderers(engine);\n\n return engine;\n}\n\n/**\n * Register all template-specific renderers\n *\n * Custom markdown renderers are registered here and will be tried AFTER\n * the default schema-driven renderer. Each custom renderer is responsible\n * for checking if it handles the specific presentation (via componentKey)\n * and throwing if not, allowing the next renderer in the chain to try.\n */\nfunction registerTemplateRenderers(engine: TransformEngine): void {\n // Agent Console renderers\n engine.register(agentListReactRenderer);\n engine.register(agentListMarkdownRenderer);\n engine.register(runListMarkdownRenderer);\n engine.register(toolRegistryMarkdownRenderer);\n engine.register(agentDashboardMarkdownRenderer);\n\n // SaaS Boilerplate renderers\n engine.register(projectListReactRenderer);\n engine.register(projectListMarkdownRenderer);\n engine.register(saasDashboardMarkdownRenderer);\n engine.register(saasBillingMarkdownRenderer);\n\n // CRM Pipeline renderers\n engine.register(crmPipelineReactRenderer);\n engine.register(crmPipelineMarkdownRenderer);\n engine.register(crmDashboardMarkdownRenderer);\n\n // Workflow System renderers\n engine.register(workflowDashboardMarkdownRenderer);\n engine.register(workflowDefinitionListMarkdownRenderer);\n engine.register(workflowInstanceDetailMarkdownRenderer);\n\n // Marketplace renderers\n engine.register(marketplaceDashboardMarkdownRenderer);\n engine.register(productCatalogMarkdownRenderer);\n engine.register(orderListMarkdownRenderer);\n\n // Integration Hub renderers\n engine.register(integrationDashboardMarkdownRenderer);\n engine.register(connectionListMarkdownRenderer);\n engine.register(syncConfigMarkdownRenderer);\n\n // Analytics Dashboard renderers\n engine.register(analyticsDashboardMarkdownRenderer);\n engine.register(dashboardListMarkdownRenderer);\n engine.register(queryBuilderMarkdownRenderer);\n}\n\n/**\n * Singleton instance for shared engine\n */\nlet templateEngine: TransformEngine | null = null;\n\n/**\n * Get or create the shared template engine instance\n */\nexport function getTemplateEngine(): TransformEngine {\n if (!templateEngine) {\n templateEngine = createTemplateTransformEngine();\n }\n return templateEngine;\n}\n\n/**\n * Reset the shared engine (useful for testing)\n */\nexport function resetTemplateEngine(): void {\n templateEngine = null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA8DA,SAAgB,gCAAiD;CAC/D,MAAM,SAAS,8BAA8B;AAG7C,8BAA6B,OAAO;AACpC,yBAAwB,OAAO;AAG/B,2BAA0B,OAAO;AAEjC,QAAO;;;;;;;;;;AAWT,SAAS,0BAA0B,QAA+B;AAEhE,QAAO,SAAS,uBAAuB;AACvC,QAAO,SAAS,0BAA0B;AAC1C,QAAO,SAAS,wBAAwB;AACxC,QAAO,SAAS,6BAA6B;AAC7C,QAAO,SAAS,+BAA+B;AAG/C,QAAO,SAAS,yBAAyB;AACzC,QAAO,SAAS,4BAA4B;AAC5C,QAAO,SAAS,8BAA8B;AAC9C,QAAO,SAAS,4BAA4B;AAG5C,QAAO,SAAS,yBAAyB;AACzC,QAAO,SAAS,4BAA4B;AAC5C,QAAO,SAAS,6BAA6B;AAG7C,QAAO,SAAS,kCAAkC;AAClD,QAAO,SAAS,uCAAuC;AACvD,QAAO,SAAS,uCAAuC;AAGvD,QAAO,SAAS,qCAAqC;AACrD,QAAO,SAAS,+BAA+B;AAC/C,QAAO,SAAS,0BAA0B;AAG1C,QAAO,SAAS,qCAAqC;AACrD,QAAO,SAAS,+BAA+B;AAC/C,QAAO,SAAS,2BAA2B;AAG3C,QAAO,SAAS,mCAAmC;AACnD,QAAO,SAAS,8BAA8B;AAC9C,QAAO,SAAS,6BAA6B;;;;;AAM/C,IAAI,iBAAyC;;;;AAK7C,SAAgB,oBAAqC;AACnD,KAAI,CAAC,eACH,kBAAiB,+BAA+B;AAElD,QAAO;;;;;AAMT,SAAgB,sBAA4B;AAC1C,kBAAiB"}
@@ -0,0 +1,40 @@
1
+ import { RegistryTemplateSummary } from "./registry-client.js";
2
+ import { web } from "@contractspec/lib.runtime-sandbox";
3
+ import { InstallTemplateOptions, SaveTemplateOptions, SaveTemplateResult, TemplateDefinition, TemplateFilter, TemplateId } from "@contractspec/lib.example-shared-ui";
4
+
5
+ //#region src/runtime/installer.d.ts
6
+ declare const LocalRuntimeServices: typeof web.LocalRuntimeServices;
7
+ type LocalRuntimeServices = InstanceType<typeof LocalRuntimeServices>;
8
+ interface TemplateInstallerOptions {
9
+ runtime?: LocalRuntimeServices;
10
+ endpoint?: string;
11
+ /** Optional registry server base URL (enables listing remote/community templates) */
12
+ registryUrl?: string;
13
+ fetchImpl?: typeof fetch;
14
+ }
15
+ declare class TemplateInstaller {
16
+ private readonly runtime;
17
+ private readonly endpoint;
18
+ private readonly registryUrl;
19
+ private readonly fetchImpl;
20
+ constructor(options?: TemplateInstallerOptions);
21
+ init(): Promise<void>;
22
+ list(filter?: TemplateFilter): TemplateDefinition[];
23
+ /**
24
+ * List templates published to the ContractSpec Registry.
25
+ *
26
+ * Note: this returns *metadata* only. Installing still requires a local template
27
+ * implementation unless/until we support seeding templates from registry payloads.
28
+ */
29
+ listRemoteTemplates(): Promise<RegistryTemplateSummary[]>;
30
+ /**
31
+ * Resolve a registry template id to a local TemplateId if available.
32
+ */
33
+ resolveLocalTemplateId(id: string): TemplateId | null;
34
+ get(templateId: TemplateId): TemplateDefinition | undefined;
35
+ install(templateId: TemplateId, options?: InstallTemplateOptions): Promise<void>;
36
+ saveToStudio(options: SaveTemplateOptions): Promise<SaveTemplateResult>;
37
+ }
38
+ //#endregion
39
+ export { TemplateInstaller, TemplateInstallerOptions };
40
+ //# sourceMappingURL=installer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"installer.d.ts","names":[],"sources":["../../src/runtime/installer.ts"],"sourcesContent":[],"mappings":";;;;;cAiBQ,6BAAoB,GAAA,CAAA;KACvB,oBAAA,GAAuB,oBAAoB;AADxC,UAYS,wBAAA,CAZW;EACvB,OAAA,CAAA,EAYO,oBAZa;EAWR,QAAA,CAAA,EAAA,MAAA;EAQJ;EAMU,WAAA,CAAA,EAAA,MAAA;EASP,SAAA,CAAA,EAAA,OAlBK,KAkBL;;AAIiB,cAnBpB,iBAAA,CAmBoB;EAuBM,iBAAA,OAAA;EAAR,iBAAA,QAAA;EAYO,iBAAA,WAAA;EAKpB,iBAAA,SAAA;EAAa,WAAA,CAAA,OAAA,CAAA,EArDR,wBAqDQ;EAKf,IAAA,CAAA,CAAA,EAjDA,OAiDA,CAAA,IAAA,CAAA;EACH,IAAA,CAAA,MAAA,CAAA,EA9CG,cA8CH,CAAA,EA9CoB,kBA8CpB,EAAA;EACR;;;;;;yBAxB0B,QAAQ;;;;sCAYD;kBAKpB,aAAa;sBAKf,sBACH,yBACR;wBAQQ,sBACR,QAAQ"}
@@ -0,0 +1,103 @@
1
+ 'use client';
2
+
3
+ import { TEMPLATE_REGISTRY, getTemplate } from "./registry.js";
4
+ import { ContractSpecRegistryClient } from "./registry-client.js";
5
+ import { web } from "@contractspec/lib.runtime-sandbox";
6
+
7
+ //#region src/runtime/installer.ts
8
+ const { LocalRuntimeServices } = web;
9
+ const SAVE_TEMPLATE_MUTATION = `
10
+ mutation SaveTemplateToStudio($input: SaveTemplateInput!) {
11
+ saveTemplateToStudio(input: $input) {
12
+ projectId
13
+ status
14
+ }
15
+ }
16
+ `;
17
+ var TemplateInstaller = class {
18
+ runtime;
19
+ endpoint;
20
+ registryUrl;
21
+ fetchImpl;
22
+ constructor(options = {}) {
23
+ this.runtime = options.runtime ?? new LocalRuntimeServices();
24
+ this.endpoint = options.endpoint ?? "/api/graphql";
25
+ this.registryUrl = options.registryUrl ? options.registryUrl.replace(/\/+$/, "") : null;
26
+ this.fetchImpl = options.fetchImpl ?? fetch;
27
+ }
28
+ async init() {
29
+ await this.runtime.init();
30
+ }
31
+ list(filter) {
32
+ return filter ? TEMPLATE_REGISTRY.filter((template) => {
33
+ if (filter.category && filter.category !== template.category) return false;
34
+ if (filter.complexity && filter.complexity !== template.complexity) return false;
35
+ if (filter.tag && !template.tags.includes(filter.tag)) return false;
36
+ return true;
37
+ }) : TEMPLATE_REGISTRY;
38
+ }
39
+ /**
40
+ * List templates published to the ContractSpec Registry.
41
+ *
42
+ * Note: this returns *metadata* only. Installing still requires a local template
43
+ * implementation unless/until we support seeding templates from registry payloads.
44
+ */
45
+ async listRemoteTemplates() {
46
+ if (!this.registryUrl) return [];
47
+ return await new ContractSpecRegistryClient({
48
+ registryUrl: this.registryUrl,
49
+ fetchImpl: this.fetchImpl
50
+ }).listTemplateSummaries();
51
+ }
52
+ /**
53
+ * Resolve a registry template id to a local TemplateId if available.
54
+ */
55
+ resolveLocalTemplateId(id) {
56
+ return getTemplate(id) ? id : null;
57
+ }
58
+ get(templateId) {
59
+ return getTemplate(templateId);
60
+ }
61
+ async install(templateId, options = {}) {
62
+ await this.runtime.seedTemplate({
63
+ templateId,
64
+ projectId: options.projectId
65
+ });
66
+ }
67
+ async saveToStudio(options) {
68
+ const payload = toBase64(await this.runtime.db.export());
69
+ const response = await this.fetchImpl(options.endpoint ?? this.endpoint, {
70
+ method: "POST",
71
+ headers: {
72
+ "Content-Type": "application/json",
73
+ ...options.token ? { Authorization: `Bearer ${options.token}` } : {}
74
+ },
75
+ body: JSON.stringify({
76
+ query: SAVE_TEMPLATE_MUTATION,
77
+ variables: { input: {
78
+ templateId: options.templateId,
79
+ projectName: options.projectName,
80
+ organizationId: options.organizationId,
81
+ payload
82
+ } }
83
+ })
84
+ });
85
+ if (!response.ok) throw new Error(`Failed to save template: ${response.status} ${response.statusText}`);
86
+ const json = await response.json();
87
+ if (json.errors?.length) throw new Error(json.errors[0]?.message ?? "Unknown error");
88
+ if (!json.data?.saveTemplateToStudio) throw new Error("Invalid response from Studio API");
89
+ return json.data.saveTemplateToStudio;
90
+ }
91
+ };
92
+ function toBase64(bytes) {
93
+ if (typeof Buffer !== "undefined") return Buffer.from(bytes).toString("base64");
94
+ let binary = "";
95
+ bytes.forEach((value) => {
96
+ binary += String.fromCharCode(value);
97
+ });
98
+ return btoa(binary);
99
+ }
100
+
101
+ //#endregion
102
+ export { TemplateInstaller };
103
+ //# sourceMappingURL=installer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"installer.js","names":[],"sources":["../../src/runtime/installer.ts"],"sourcesContent":["'use client';\n\nimport { getTemplate, TEMPLATE_REGISTRY } from './registry';\nimport type {\n TemplateDefinition,\n TemplateFilter,\n TemplateId,\n InstallTemplateOptions,\n SaveTemplateOptions,\n SaveTemplateResult,\n} from '@contractspec/lib.example-shared-ui';\nimport {\n ContractSpecRegistryClient,\n type RegistryTemplateSummary,\n} from './registry-client';\nimport { web } from '@contractspec/lib.runtime-sandbox';\n\nconst { LocalRuntimeServices } = web;\ntype LocalRuntimeServices = InstanceType<typeof LocalRuntimeServices>;\n\nconst SAVE_TEMPLATE_MUTATION = `\n mutation SaveTemplateToStudio($input: SaveTemplateInput!) {\n saveTemplateToStudio(input: $input) {\n projectId\n status\n }\n }\n`;\n\nexport interface TemplateInstallerOptions {\n runtime?: LocalRuntimeServices;\n endpoint?: string;\n /** Optional registry server base URL (enables listing remote/community templates) */\n registryUrl?: string;\n fetchImpl?: typeof fetch;\n}\n\nexport class TemplateInstaller {\n private readonly runtime: LocalRuntimeServices;\n private readonly endpoint: string;\n private readonly registryUrl: string | null;\n private readonly fetchImpl: typeof fetch;\n\n constructor(options: TemplateInstallerOptions = {}) {\n this.runtime = options.runtime ?? new LocalRuntimeServices();\n this.endpoint = options.endpoint ?? '/api/graphql';\n this.registryUrl = options.registryUrl\n ? options.registryUrl.replace(/\\/+$/, '')\n : null;\n this.fetchImpl = options.fetchImpl ?? fetch;\n }\n\n async init(): Promise<void> {\n await this.runtime.init();\n }\n\n list(filter?: TemplateFilter): TemplateDefinition[] {\n return filter\n ? TEMPLATE_REGISTRY.filter((template) => {\n if (filter.category && filter.category !== template.category) {\n return false;\n }\n if (filter.complexity && filter.complexity !== template.complexity) {\n return false;\n }\n if (filter.tag && !template.tags.includes(filter.tag)) {\n return false;\n }\n return true;\n })\n : TEMPLATE_REGISTRY;\n }\n\n /**\n * List templates published to the ContractSpec Registry.\n *\n * Note: this returns *metadata* only. Installing still requires a local template\n * implementation unless/until we support seeding templates from registry payloads.\n */\n async listRemoteTemplates(): Promise<RegistryTemplateSummary[]> {\n if (!this.registryUrl) return [];\n const client = new ContractSpecRegistryClient({\n registryUrl: this.registryUrl,\n fetchImpl: this.fetchImpl,\n });\n return await client.listTemplateSummaries();\n }\n\n /**\n * Resolve a registry template id to a local TemplateId if available.\n */\n resolveLocalTemplateId(id: string): TemplateId | null {\n const found = getTemplate(id as TemplateId);\n return found ? (id as TemplateId) : null;\n }\n\n get(templateId: TemplateId): TemplateDefinition | undefined {\n return getTemplate(templateId);\n }\n\n async install(\n templateId: TemplateId,\n options: InstallTemplateOptions = {}\n ): Promise<void> {\n await this.runtime.seedTemplate({\n templateId,\n projectId: options.projectId,\n });\n }\n\n async saveToStudio(\n options: SaveTemplateOptions\n ): Promise<SaveTemplateResult> {\n const snapshot = await this.runtime.db.export();\n const payload = toBase64(snapshot);\n const response = await this.fetchImpl(options.endpoint ?? this.endpoint, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n ...(options.token ? { Authorization: `Bearer ${options.token}` } : {}),\n },\n body: JSON.stringify({\n query: SAVE_TEMPLATE_MUTATION,\n variables: {\n input: {\n templateId: options.templateId,\n projectName: options.projectName,\n organizationId: options.organizationId,\n payload,\n },\n },\n }),\n });\n\n if (!response.ok) {\n throw new Error(\n `Failed to save template: ${response.status} ${response.statusText}`\n );\n }\n\n const json = (await response.json()) as {\n data?: {\n saveTemplateToStudio: SaveTemplateResult;\n };\n errors?: { message: string }[];\n };\n\n if (json.errors?.length) {\n throw new Error(json.errors[0]?.message ?? 'Unknown error');\n }\n\n if (!json.data?.saveTemplateToStudio) {\n throw new Error('Invalid response from Studio API');\n }\n\n return json.data.saveTemplateToStudio;\n }\n}\n\nfunction toBase64(bytes: Uint8Array): string {\n if (typeof Buffer !== 'undefined') {\n return Buffer.from(bytes).toString('base64');\n }\n let binary = '';\n bytes.forEach((value) => {\n binary += String.fromCharCode(value);\n });\n return btoa(binary);\n}\n"],"mappings":";;;;;;;AAiBA,MAAM,EAAE,yBAAyB;AAGjC,MAAM,yBAAyB;;;;;;;;AAiB/B,IAAa,oBAAb,MAA+B;CAC7B,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CAEjB,YAAY,UAAoC,EAAE,EAAE;AAClD,OAAK,UAAU,QAAQ,WAAW,IAAI,sBAAsB;AAC5D,OAAK,WAAW,QAAQ,YAAY;AACpC,OAAK,cAAc,QAAQ,cACvB,QAAQ,YAAY,QAAQ,QAAQ,GAAG,GACvC;AACJ,OAAK,YAAY,QAAQ,aAAa;;CAGxC,MAAM,OAAsB;AAC1B,QAAM,KAAK,QAAQ,MAAM;;CAG3B,KAAK,QAA+C;AAClD,SAAO,SACH,kBAAkB,QAAQ,aAAa;AACrC,OAAI,OAAO,YAAY,OAAO,aAAa,SAAS,SAClD,QAAO;AAET,OAAI,OAAO,cAAc,OAAO,eAAe,SAAS,WACtD,QAAO;AAET,OAAI,OAAO,OAAO,CAAC,SAAS,KAAK,SAAS,OAAO,IAAI,CACnD,QAAO;AAET,UAAO;IACP,GACF;;;;;;;;CASN,MAAM,sBAA0D;AAC9D,MAAI,CAAC,KAAK,YAAa,QAAO,EAAE;AAKhC,SAAO,MAJQ,IAAI,2BAA2B;GAC5C,aAAa,KAAK;GAClB,WAAW,KAAK;GACjB,CAAC,CACkB,uBAAuB;;;;;CAM7C,uBAAuB,IAA+B;AAEpD,SADc,YAAY,GAAiB,GAC3B,KAAoB;;CAGtC,IAAI,YAAwD;AAC1D,SAAO,YAAY,WAAW;;CAGhC,MAAM,QACJ,YACA,UAAkC,EAAE,EACrB;AACf,QAAM,KAAK,QAAQ,aAAa;GAC9B;GACA,WAAW,QAAQ;GACpB,CAAC;;CAGJ,MAAM,aACJ,SAC6B;EAE7B,MAAM,UAAU,SADC,MAAM,KAAK,QAAQ,GAAG,QAAQ,CACb;EAClC,MAAM,WAAW,MAAM,KAAK,UAAU,QAAQ,YAAY,KAAK,UAAU;GACvE,QAAQ;GACR,SAAS;IACP,gBAAgB;IAChB,GAAI,QAAQ,QAAQ,EAAE,eAAe,UAAU,QAAQ,SAAS,GAAG,EAAE;IACtE;GACD,MAAM,KAAK,UAAU;IACnB,OAAO;IACP,WAAW,EACT,OAAO;KACL,YAAY,QAAQ;KACpB,aAAa,QAAQ;KACrB,gBAAgB,QAAQ;KACxB;KACD,EACF;IACF,CAAC;GACH,CAAC;AAEF,MAAI,CAAC,SAAS,GACZ,OAAM,IAAI,MACR,4BAA4B,SAAS,OAAO,GAAG,SAAS,aACzD;EAGH,MAAM,OAAQ,MAAM,SAAS,MAAM;AAOnC,MAAI,KAAK,QAAQ,OACf,OAAM,IAAI,MAAM,KAAK,OAAO,IAAI,WAAW,gBAAgB;AAG7D,MAAI,CAAC,KAAK,MAAM,qBACd,OAAM,IAAI,MAAM,mCAAmC;AAGrD,SAAO,KAAK,KAAK;;;AAIrB,SAAS,SAAS,OAA2B;AAC3C,KAAI,OAAO,WAAW,YACpB,QAAO,OAAO,KAAK,MAAM,CAAC,SAAS,SAAS;CAE9C,IAAI,SAAS;AACb,OAAM,SAAS,UAAU;AACvB,YAAU,OAAO,aAAa,MAAM;GACpC;AACF,QAAO,KAAK,OAAO"}
@@ -0,0 +1,14 @@
1
+ import "@contractspec/lib.contracts";
2
+
3
+ //#region src/runtime/registry-client.d.ts
4
+ interface RegistryTemplateSummary {
5
+ id: string;
6
+ title: string;
7
+ description: string;
8
+ version: string;
9
+ tags: string[];
10
+ source: 'registry';
11
+ }
12
+ //#endregion
13
+ export { RegistryTemplateSummary };
14
+ //# sourceMappingURL=registry-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry-client.d.ts","names":[],"sources":["../../src/runtime/registry-client.ts"],"sourcesContent":[],"mappings":";;;UAMiB,uBAAA;;EAAA,KAAA,EAAA,MAAA"}
@@ -0,0 +1,42 @@
1
+ //#region src/runtime/registry-client.ts
2
+ var ContractSpecRegistryClient = class {
3
+ baseUrl;
4
+ fetchImpl;
5
+ constructor(options) {
6
+ this.baseUrl = options.registryUrl.replace(/\/+$/, "");
7
+ this.fetchImpl = options.fetchImpl ?? fetch;
8
+ }
9
+ async getManifest() {
10
+ const res = await this.fetchImpl(`${this.baseUrl}/r/contractspec.json`, {
11
+ method: "GET",
12
+ headers: { Accept: "application/json" }
13
+ });
14
+ if (!res.ok) throw new Error(`Registry manifest fetch failed: ${res.status} ${res.statusText}`);
15
+ return await res.json();
16
+ }
17
+ async listByType(type) {
18
+ return (await this.getManifest()).items.filter((i) => i.type === type);
19
+ }
20
+ async listTemplateSummaries() {
21
+ return (await this.listByType("contractspec:template")).map((t) => ({
22
+ id: t.key,
23
+ title: t.title,
24
+ description: t.description,
25
+ version: t.version,
26
+ tags: t.meta.tags,
27
+ source: "registry"
28
+ }));
29
+ }
30
+ async getItem(typeSegment, name) {
31
+ const res = await this.fetchImpl(`${this.baseUrl}/r/contractspec/${typeSegment}/${name}.json`, {
32
+ method: "GET",
33
+ headers: { Accept: "application/json" }
34
+ });
35
+ if (!res.ok) throw new Error(`Registry item fetch failed: ${res.status} ${res.statusText}`);
36
+ return await res.json();
37
+ }
38
+ };
39
+
40
+ //#endregion
41
+ export { ContractSpecRegistryClient };
42
+ //# sourceMappingURL=registry-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry-client.js","names":[],"sources":["../../src/runtime/registry-client.ts"],"sourcesContent":["import type {\n ContractRegistryItem,\n ContractRegistryItemType,\n ContractRegistryManifest,\n} from '@contractspec/lib.contracts';\n\nexport interface RegistryTemplateSummary {\n id: string;\n title: string;\n description: string;\n version: string;\n tags: string[];\n source: 'registry';\n}\n\nexport interface RegistryClientOptions {\n registryUrl: string;\n fetchImpl?: typeof fetch;\n}\n\nexport class ContractSpecRegistryClient {\n private readonly baseUrl: string;\n private readonly fetchImpl: typeof fetch;\n\n constructor(options: RegistryClientOptions) {\n this.baseUrl = options.registryUrl.replace(/\\/+$/, '');\n this.fetchImpl = options.fetchImpl ?? fetch;\n }\n\n async getManifest(): Promise<ContractRegistryManifest> {\n const res = await this.fetchImpl(`${this.baseUrl}/r/contractspec.json`, {\n method: 'GET',\n headers: { Accept: 'application/json' },\n });\n if (!res.ok) {\n throw new Error(\n `Registry manifest fetch failed: ${res.status} ${res.statusText}`\n );\n }\n return (await res.json()) as ContractRegistryManifest;\n }\n\n async listByType(\n type: ContractRegistryItemType\n ): Promise<ContractRegistryItem[]> {\n const manifest = await this.getManifest();\n return manifest.items.filter((i) => i.type === type);\n }\n\n async listTemplateSummaries(): Promise<RegistryTemplateSummary[]> {\n const templates = await this.listByType('contractspec:template');\n return templates.map((t) => ({\n id: t.key,\n title: t.title,\n description: t.description,\n version: t.version,\n tags: t.meta.tags,\n source: 'registry',\n }));\n }\n\n async getItem(\n typeSegment: string,\n name: string\n ): Promise<ContractRegistryItem> {\n const res = await this.fetchImpl(\n `${this.baseUrl}/r/contractspec/${typeSegment}/${name}.json`,\n {\n method: 'GET',\n headers: { Accept: 'application/json' },\n }\n );\n if (!res.ok) {\n throw new Error(\n `Registry item fetch failed: ${res.status} ${res.statusText}`\n );\n }\n return (await res.json()) as ContractRegistryItem;\n }\n}\n"],"mappings":";AAoBA,IAAa,6BAAb,MAAwC;CACtC,AAAiB;CACjB,AAAiB;CAEjB,YAAY,SAAgC;AAC1C,OAAK,UAAU,QAAQ,YAAY,QAAQ,QAAQ,GAAG;AACtD,OAAK,YAAY,QAAQ,aAAa;;CAGxC,MAAM,cAAiD;EACrD,MAAM,MAAM,MAAM,KAAK,UAAU,GAAG,KAAK,QAAQ,uBAAuB;GACtE,QAAQ;GACR,SAAS,EAAE,QAAQ,oBAAoB;GACxC,CAAC;AACF,MAAI,CAAC,IAAI,GACP,OAAM,IAAI,MACR,mCAAmC,IAAI,OAAO,GAAG,IAAI,aACtD;AAEH,SAAQ,MAAM,IAAI,MAAM;;CAG1B,MAAM,WACJ,MACiC;AAEjC,UADiB,MAAM,KAAK,aAAa,EACzB,MAAM,QAAQ,MAAM,EAAE,SAAS,KAAK;;CAGtD,MAAM,wBAA4D;AAEhE,UADkB,MAAM,KAAK,WAAW,wBAAwB,EAC/C,KAAK,OAAO;GAC3B,IAAI,EAAE;GACN,OAAO,EAAE;GACT,aAAa,EAAE;GACf,SAAS,EAAE;GACX,MAAM,EAAE,KAAK;GACb,QAAQ;GACT,EAAE;;CAGL,MAAM,QACJ,aACA,MAC+B;EAC/B,MAAM,MAAM,MAAM,KAAK,UACrB,GAAG,KAAK,QAAQ,kBAAkB,YAAY,GAAG,KAAK,QACtD;GACE,QAAQ;GACR,SAAS,EAAE,QAAQ,oBAAoB;GACxC,CACF;AACD,MAAI,CAAC,IAAI,GACP,OAAM,IAAI,MACR,+BAA+B,IAAI,OAAO,GAAG,IAAI,aAClD;AAEH,SAAQ,MAAM,IAAI,MAAM"}
@@ -0,0 +1,17 @@
1
+ import { TemplateDefinition, TemplateFilter, TemplateId } from "@contractspec/lib.example-shared-ui";
2
+
3
+ //#region src/runtime/registry.d.ts
4
+ declare const TEMPLATE_REGISTRY: TemplateDefinition[];
5
+ declare function listTemplates(filter?: TemplateFilter): TemplateDefinition[];
6
+ declare function getTemplate(id: TemplateId): TemplateDefinition | undefined;
7
+ /**
8
+ * Get templates that use a specific cross-cutting module
9
+ */
10
+ declare function getTemplatesByModule(modulePackage: string): TemplateDefinition[];
11
+ /**
12
+ * Get all templates with external packages (clonable via Git)
13
+ */
14
+ declare function getClonableTemplates(): TemplateDefinition[];
15
+ //#endregion
16
+ export { TEMPLATE_REGISTRY, getClonableTemplates, getTemplate, getTemplatesByModule, listTemplates };
17
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","names":[],"sources":["../../src/runtime/registry.ts"],"sourcesContent":[],"mappings":";;;cA2Ea,mBAAmB;iBA4HhB,aAAA,UAAuB,iBAAiB;AA5H3C,iBAiJG,WAAA,CAjJgB,EAAA,EAiJA,UAjJA,CAAA,EAiJa,kBAjJK,GAAA,SAAA;AA4HlD;AAqBA;AAOA;AAWgB,iBAXA,oBAAA,CAWwB,aAAkB,EAAA,MAAA,CAAA,EATvD,kBASuD,EAAA;;;;iBAA1C,oBAAA,CAAA,GAAwB"}
@@ -0,0 +1,225 @@
1
+ import { listExamples } from "../registry.js";
2
+
3
+ //#region src/runtime/registry.ts
4
+ const PRESENTATIONS_BY_TEMPLATE = {
5
+ "saas-boilerplate": [
6
+ "saas-boilerplate.dashboard",
7
+ "saas-boilerplate.project.list",
8
+ "saas-boilerplate.billing.settings"
9
+ ],
10
+ "crm-pipeline": ["crm-pipeline.dashboard", "crm-pipeline.deal.pipeline"],
11
+ "agent-console": [
12
+ "agent-console.dashboard",
13
+ "agent-console.agent.list",
14
+ "agent-console.run.list",
15
+ "agent-console.tool.registry"
16
+ ],
17
+ "workflow-system": [
18
+ "workflow-system.dashboard",
19
+ "workflow-system.definition.list",
20
+ "workflow-system.instance.detail"
21
+ ],
22
+ marketplace: [
23
+ "marketplace.dashboard",
24
+ "marketplace.product.catalog",
25
+ "marketplace.order.list",
26
+ "marketplace.store.manage"
27
+ ],
28
+ "integration-hub": [
29
+ "integration-hub.dashboard",
30
+ "integration-hub.connection.list",
31
+ "integration-hub.sync.config"
32
+ ],
33
+ "analytics-dashboard": [
34
+ "analytics-dashboard.dashboard",
35
+ "analytics-dashboard.list",
36
+ "analytics-dashboard.query.builder"
37
+ ],
38
+ "learning-journey-studio-onboarding": [
39
+ "learning.journey.track_list",
40
+ "learning.journey.track_detail",
41
+ "learning.journey.progress_widget"
42
+ ],
43
+ "learning-journey-platform-tour": [
44
+ "learning.journey.track_list",
45
+ "learning.journey.track_detail",
46
+ "learning.journey.progress_widget"
47
+ ],
48
+ "learning-journey-crm-onboarding": [
49
+ "learning.journey.track_list",
50
+ "learning.journey.track_detail",
51
+ "learning.journey.progress_widget"
52
+ ],
53
+ "learning-journey-duo-drills": [
54
+ "learning.journey.track_list",
55
+ "learning.journey.track_detail",
56
+ "learning.journey.progress_widget"
57
+ ],
58
+ "learning-journey-ambient-coach": [
59
+ "learning.journey.track_list",
60
+ "learning.journey.track_detail",
61
+ "learning.journey.progress_widget"
62
+ ],
63
+ "learning-journey-quest-challenges": [
64
+ "learning.journey.track_list",
65
+ "learning.journey.track_detail",
66
+ "learning.journey.progress_widget"
67
+ ]
68
+ };
69
+ const TEMPLATE_REGISTRY = [
70
+ {
71
+ id: "todos-app",
72
+ name: "To-dos List App",
73
+ description: "CRUD flows, filtering, priorities, and ceremonies for handing off work across crews.",
74
+ category: "productivity",
75
+ complexity: "beginner",
76
+ icon: "✅",
77
+ features: [
78
+ "CRUD tasks",
79
+ "Filters",
80
+ "Categories",
81
+ "Search",
82
+ "Priorities"
83
+ ],
84
+ tags: [
85
+ "tasks",
86
+ "ops",
87
+ "starter"
88
+ ],
89
+ schema: {
90
+ models: ["Task", "TaskCategory"],
91
+ contracts: ["template.todos.crud"]
92
+ },
93
+ components: {
94
+ list: "TaskList",
95
+ detail: "TaskDetailPanel",
96
+ form: "TaskForm"
97
+ },
98
+ preview: { demoUrl: "/sandbox?template=todos-app" },
99
+ docs: { quickstart: "/docs/templates/todos-app" }
100
+ },
101
+ {
102
+ id: "messaging-app",
103
+ name: "Messaging Application",
104
+ description: "Conversation roster, optimistic sending, typing indicators, and delivery telemetry.",
105
+ category: "communication",
106
+ complexity: "intermediate",
107
+ icon: "💬",
108
+ features: [
109
+ "Conversations",
110
+ "Real-time feed",
111
+ "Typing indicators",
112
+ "Read receipts"
113
+ ],
114
+ tags: [
115
+ "messaging",
116
+ "realtime",
117
+ "ws"
118
+ ],
119
+ schema: {
120
+ models: [
121
+ "Conversation",
122
+ "ConversationParticipant",
123
+ "Message"
124
+ ],
125
+ contracts: ["template.messaging.core"]
126
+ },
127
+ components: {
128
+ list: "ConversationList",
129
+ detail: "MessageThread",
130
+ form: "MessageComposer"
131
+ },
132
+ preview: { demoUrl: "/sandbox?template=messaging-app" },
133
+ docs: { quickstart: "/docs/templates/messaging-app" }
134
+ },
135
+ {
136
+ id: "recipe-app-i18n",
137
+ name: "Recipe App (i18n)",
138
+ description: "Localized browsing experience with bilingual content, categories, and favorites.",
139
+ category: "content",
140
+ complexity: "intermediate",
141
+ icon: "🍲",
142
+ features: [
143
+ "i18n",
144
+ "Favorites",
145
+ "Categories",
146
+ "Search",
147
+ "RTL-ready"
148
+ ],
149
+ tags: [
150
+ "content",
151
+ "i18n",
152
+ "localization"
153
+ ],
154
+ schema: {
155
+ models: [
156
+ "RecipeCategory",
157
+ "Recipe",
158
+ "RecipeIngredient",
159
+ "RecipeInstruction"
160
+ ],
161
+ contracts: ["template.recipes.browse"]
162
+ },
163
+ components: {
164
+ list: "RecipeList",
165
+ detail: "RecipeDetail",
166
+ form: "RecipeForm"
167
+ },
168
+ preview: { demoUrl: "/sandbox?template=recipe-app-i18n" },
169
+ docs: { quickstart: "/docs/templates/recipe-app-i18n" }
170
+ },
171
+ ...listExamples().map((example) => {
172
+ const tags = example.meta.keywords ?? [];
173
+ const category = tags.some((t) => t.toLowerCase() === "ai") || tags.some((t) => t.toLowerCase() === "assistant") ? "ai" : "business";
174
+ return {
175
+ id: example.meta.key,
176
+ name: example.meta.title ?? example.meta.key,
177
+ description: example.meta.description ?? "",
178
+ category,
179
+ complexity: "beginner",
180
+ icon: "📦",
181
+ features: [],
182
+ tags: [...tags],
183
+ schema: {
184
+ models: [],
185
+ contracts: []
186
+ },
187
+ components: {
188
+ list: "ExampleList",
189
+ detail: "ExampleDetail"
190
+ },
191
+ preview: { demoUrl: `/sandbox?template=${encodeURIComponent(example.meta.key)}` },
192
+ package: example.entrypoints.packageName,
193
+ presentations: PRESENTATIONS_BY_TEMPLATE[example.meta.key] ?? [],
194
+ renderTargets: ["react", "markdown"]
195
+ };
196
+ })
197
+ ];
198
+ function listTemplates(filter) {
199
+ if (!filter) return TEMPLATE_REGISTRY;
200
+ return TEMPLATE_REGISTRY.filter((template) => {
201
+ if (filter.category && template.category !== filter.category) return false;
202
+ if (filter.complexity && template.complexity !== filter.complexity) return false;
203
+ if (filter.tag && !template.tags.some((tag) => tag.toLowerCase() === filter.tag?.toLowerCase())) return false;
204
+ return true;
205
+ });
206
+ }
207
+ function getTemplate(id) {
208
+ return TEMPLATE_REGISTRY.find((template) => template.id === id);
209
+ }
210
+ /**
211
+ * Get templates that use a specific cross-cutting module
212
+ */
213
+ function getTemplatesByModule(modulePackage) {
214
+ return TEMPLATE_REGISTRY.filter((template) => template.usesModules?.includes(modulePackage));
215
+ }
216
+ /**
217
+ * Get all templates with external packages (clonable via Git)
218
+ */
219
+ function getClonableTemplates() {
220
+ return TEMPLATE_REGISTRY.filter((template) => !!template.package);
221
+ }
222
+
223
+ //#endregion
224
+ export { TEMPLATE_REGISTRY, getClonableTemplates, getTemplate, getTemplatesByModule, listTemplates };
225
+ //# sourceMappingURL=registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.js","names":[],"sources":["../../src/runtime/registry.ts"],"sourcesContent":["import { listExamples } from '../registry';\nimport type {\n TemplateCategory,\n TemplateComplexity,\n TemplateDefinition,\n TemplateId,\n TemplateFilter,\n} from '@contractspec/lib.example-shared-ui';\n\nconst PRESENTATIONS_BY_TEMPLATE: Record<string, string[]> = {\n 'saas-boilerplate': [\n 'saas-boilerplate.dashboard',\n 'saas-boilerplate.project.list',\n 'saas-boilerplate.billing.settings',\n ],\n 'crm-pipeline': ['crm-pipeline.dashboard', 'crm-pipeline.deal.pipeline'],\n 'agent-console': [\n 'agent-console.dashboard',\n 'agent-console.agent.list',\n 'agent-console.run.list',\n 'agent-console.tool.registry',\n ],\n 'workflow-system': [\n 'workflow-system.dashboard',\n 'workflow-system.definition.list',\n 'workflow-system.instance.detail',\n ],\n marketplace: [\n 'marketplace.dashboard',\n 'marketplace.product.catalog',\n 'marketplace.order.list',\n 'marketplace.store.manage',\n ],\n 'integration-hub': [\n 'integration-hub.dashboard',\n 'integration-hub.connection.list',\n 'integration-hub.sync.config',\n ],\n 'analytics-dashboard': [\n 'analytics-dashboard.dashboard',\n 'analytics-dashboard.list',\n 'analytics-dashboard.query.builder',\n ],\n 'learning-journey-studio-onboarding': [\n 'learning.journey.track_list',\n 'learning.journey.track_detail',\n 'learning.journey.progress_widget',\n ],\n 'learning-journey-platform-tour': [\n 'learning.journey.track_list',\n 'learning.journey.track_detail',\n 'learning.journey.progress_widget',\n ],\n 'learning-journey-crm-onboarding': [\n 'learning.journey.track_list',\n 'learning.journey.track_detail',\n 'learning.journey.progress_widget',\n ],\n 'learning-journey-duo-drills': [\n 'learning.journey.track_list',\n 'learning.journey.track_detail',\n 'learning.journey.progress_widget',\n ],\n 'learning-journey-ambient-coach': [\n 'learning.journey.track_list',\n 'learning.journey.track_detail',\n 'learning.journey.progress_widget',\n ],\n 'learning-journey-quest-challenges': [\n 'learning.journey.track_list',\n 'learning.journey.track_detail',\n 'learning.journey.progress_widget',\n ],\n};\n\nexport const TEMPLATE_REGISTRY: TemplateDefinition[] = [\n {\n id: 'todos-app',\n name: 'To-dos List App',\n description:\n 'CRUD flows, filtering, priorities, and ceremonies for handing off work across crews.',\n category: 'productivity',\n complexity: 'beginner',\n icon: '✅',\n features: ['CRUD tasks', 'Filters', 'Categories', 'Search', 'Priorities'],\n tags: ['tasks', 'ops', 'starter'],\n schema: {\n models: ['Task', 'TaskCategory'],\n contracts: ['template.todos.crud'],\n },\n components: {\n list: 'TaskList',\n detail: 'TaskDetailPanel',\n form: 'TaskForm',\n },\n preview: {\n demoUrl: '/sandbox?template=todos-app',\n },\n docs: {\n quickstart: '/docs/templates/todos-app',\n },\n },\n {\n id: 'messaging-app',\n name: 'Messaging Application',\n description:\n 'Conversation roster, optimistic sending, typing indicators, and delivery telemetry.',\n category: 'communication',\n complexity: 'intermediate',\n icon: '💬',\n features: [\n 'Conversations',\n 'Real-time feed',\n 'Typing indicators',\n 'Read receipts',\n ],\n tags: ['messaging', 'realtime', 'ws'],\n schema: {\n models: ['Conversation', 'ConversationParticipant', 'Message'],\n contracts: ['template.messaging.core'],\n },\n components: {\n list: 'ConversationList',\n detail: 'MessageThread',\n form: 'MessageComposer',\n },\n preview: {\n demoUrl: '/sandbox?template=messaging-app',\n },\n docs: {\n quickstart: '/docs/templates/messaging-app',\n },\n },\n {\n id: 'recipe-app-i18n',\n name: 'Recipe App (i18n)',\n description:\n 'Localized browsing experience with bilingual content, categories, and favorites.',\n category: 'content',\n complexity: 'intermediate',\n icon: '🍲',\n features: ['i18n', 'Favorites', 'Categories', 'Search', 'RTL-ready'],\n tags: ['content', 'i18n', 'localization'],\n schema: {\n models: [\n 'RecipeCategory',\n 'Recipe',\n 'RecipeIngredient',\n 'RecipeInstruction',\n ],\n contracts: ['template.recipes.browse'],\n },\n components: {\n list: 'RecipeList',\n detail: 'RecipeDetail',\n form: 'RecipeForm',\n },\n preview: {\n demoUrl: '/sandbox?template=recipe-app-i18n',\n },\n docs: {\n quickstart: '/docs/templates/recipe-app-i18n',\n },\n },\n ...listExamples().map((example) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- meta.keywords fallback if tags missing\n const tags = (example.meta as any).keywords ?? [];\n\n const category: TemplateCategory =\n tags.some((t: string) => t.toLowerCase() === 'ai') ||\n tags.some((t: string) => t.toLowerCase() === 'assistant')\n ? 'ai'\n : 'business';\n\n const complexity: TemplateComplexity = 'beginner';\n\n const icon = '📦';\n\n return {\n id: example.meta.key,\n name: example.meta.title ?? example.meta.key,\n description: example.meta.description ?? '',\n category,\n complexity,\n icon,\n features: [],\n tags: [...tags],\n schema: { models: [], contracts: [] },\n components: { list: 'ExampleList', detail: 'ExampleDetail' },\n preview: {\n demoUrl: `/sandbox?template=${encodeURIComponent(example.meta.key)}`,\n },\n package: example.entrypoints.packageName,\n presentations: PRESENTATIONS_BY_TEMPLATE[example.meta.key] ?? [],\n renderTargets: ['react', 'markdown'],\n } satisfies TemplateDefinition;\n }),\n];\n\nexport function listTemplates(filter?: TemplateFilter): TemplateDefinition[] {\n if (!filter) return TEMPLATE_REGISTRY;\n return TEMPLATE_REGISTRY.filter((template) => {\n if (filter.category && template.category !== filter.category) {\n return false;\n }\n if (filter.complexity && template.complexity !== filter.complexity) {\n return false;\n }\n if (\n filter.tag &&\n !template.tags.some(\n (tag: string) => tag.toLowerCase() === filter.tag?.toLowerCase()\n )\n ) {\n return false;\n }\n return true;\n });\n}\n\nexport function getTemplate(id: TemplateId): TemplateDefinition | undefined {\n return TEMPLATE_REGISTRY.find((template) => template.id === id);\n}\n\n/**\n * Get templates that use a specific cross-cutting module\n */\nexport function getTemplatesByModule(\n modulePackage: string\n): TemplateDefinition[] {\n return TEMPLATE_REGISTRY.filter((template) =>\n template.usesModules?.includes(modulePackage)\n );\n}\n\n/**\n * Get all templates with external packages (clonable via Git)\n */\nexport function getClonableTemplates(): TemplateDefinition[] {\n return TEMPLATE_REGISTRY.filter((template) => !!template.package);\n}\n"],"mappings":";;;AASA,MAAM,4BAAsD;CAC1D,oBAAoB;EAClB;EACA;EACA;EACD;CACD,gBAAgB,CAAC,0BAA0B,6BAA6B;CACxE,iBAAiB;EACf;EACA;EACA;EACA;EACD;CACD,mBAAmB;EACjB;EACA;EACA;EACD;CACD,aAAa;EACX;EACA;EACA;EACA;EACD;CACD,mBAAmB;EACjB;EACA;EACA;EACD;CACD,uBAAuB;EACrB;EACA;EACA;EACD;CACD,sCAAsC;EACpC;EACA;EACA;EACD;CACD,kCAAkC;EAChC;EACA;EACA;EACD;CACD,mCAAmC;EACjC;EACA;EACA;EACD;CACD,+BAA+B;EAC7B;EACA;EACA;EACD;CACD,kCAAkC;EAChC;EACA;EACA;EACD;CACD,qCAAqC;EACnC;EACA;EACA;EACD;CACF;AAED,MAAa,oBAA0C;CACrD;EACE,IAAI;EACJ,MAAM;EACN,aACE;EACF,UAAU;EACV,YAAY;EACZ,MAAM;EACN,UAAU;GAAC;GAAc;GAAW;GAAc;GAAU;GAAa;EACzE,MAAM;GAAC;GAAS;GAAO;GAAU;EACjC,QAAQ;GACN,QAAQ,CAAC,QAAQ,eAAe;GAChC,WAAW,CAAC,sBAAsB;GACnC;EACD,YAAY;GACV,MAAM;GACN,QAAQ;GACR,MAAM;GACP;EACD,SAAS,EACP,SAAS,+BACV;EACD,MAAM,EACJ,YAAY,6BACb;EACF;CACD;EACE,IAAI;EACJ,MAAM;EACN,aACE;EACF,UAAU;EACV,YAAY;EACZ,MAAM;EACN,UAAU;GACR;GACA;GACA;GACA;GACD;EACD,MAAM;GAAC;GAAa;GAAY;GAAK;EACrC,QAAQ;GACN,QAAQ;IAAC;IAAgB;IAA2B;IAAU;GAC9D,WAAW,CAAC,0BAA0B;GACvC;EACD,YAAY;GACV,MAAM;GACN,QAAQ;GACR,MAAM;GACP;EACD,SAAS,EACP,SAAS,mCACV;EACD,MAAM,EACJ,YAAY,iCACb;EACF;CACD;EACE,IAAI;EACJ,MAAM;EACN,aACE;EACF,UAAU;EACV,YAAY;EACZ,MAAM;EACN,UAAU;GAAC;GAAQ;GAAa;GAAc;GAAU;GAAY;EACpE,MAAM;GAAC;GAAW;GAAQ;GAAe;EACzC,QAAQ;GACN,QAAQ;IACN;IACA;IACA;IACA;IACD;GACD,WAAW,CAAC,0BAA0B;GACvC;EACD,YAAY;GACV,MAAM;GACN,QAAQ;GACR,MAAM;GACP;EACD,SAAS,EACP,SAAS,qCACV;EACD,MAAM,EACJ,YAAY,mCACb;EACF;CACD,GAAG,cAAc,CAAC,KAAK,YAAY;EAEjC,MAAM,OAAQ,QAAQ,KAAa,YAAY,EAAE;EAEjD,MAAM,WACJ,KAAK,MAAM,MAAc,EAAE,aAAa,KAAK,KAAK,IAClD,KAAK,MAAM,MAAc,EAAE,aAAa,KAAK,YAAY,GACrD,OACA;AAMN,SAAO;GACL,IAAI,QAAQ,KAAK;GACjB,MAAM,QAAQ,KAAK,SAAS,QAAQ,KAAK;GACzC,aAAa,QAAQ,KAAK,eAAe;GACzC;GACA,YATqC;GAUrC,MARW;GASX,UAAU,EAAE;GACZ,MAAM,CAAC,GAAG,KAAK;GACf,QAAQ;IAAE,QAAQ,EAAE;IAAE,WAAW,EAAE;IAAE;GACrC,YAAY;IAAE,MAAM;IAAe,QAAQ;IAAiB;GAC5D,SAAS,EACP,SAAS,qBAAqB,mBAAmB,QAAQ,KAAK,IAAI,IACnE;GACD,SAAS,QAAQ,YAAY;GAC7B,eAAe,0BAA0B,QAAQ,KAAK,QAAQ,EAAE;GAChE,eAAe,CAAC,SAAS,WAAW;GACrC;GACD;CACH;AAED,SAAgB,cAAc,QAA+C;AAC3E,KAAI,CAAC,OAAQ,QAAO;AACpB,QAAO,kBAAkB,QAAQ,aAAa;AAC5C,MAAI,OAAO,YAAY,SAAS,aAAa,OAAO,SAClD,QAAO;AAET,MAAI,OAAO,cAAc,SAAS,eAAe,OAAO,WACtD,QAAO;AAET,MACE,OAAO,OACP,CAAC,SAAS,KAAK,MACZ,QAAgB,IAAI,aAAa,KAAK,OAAO,KAAK,aAAa,CACjE,CAED,QAAO;AAET,SAAO;GACP;;AAGJ,SAAgB,YAAY,IAAgD;AAC1E,QAAO,kBAAkB,MAAM,aAAa,SAAS,OAAO,GAAG;;;;;AAMjE,SAAgB,qBACd,eACsB;AACtB,QAAO,kBAAkB,QAAQ,aAC/B,SAAS,aAAa,SAAS,cAAc,CAC9C;;;;;AAMH,SAAgB,uBAA6C;AAC3D,QAAO,kBAAkB,QAAQ,aAAa,CAAC,CAAC,SAAS,QAAQ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contractspec/module.examples",
3
- "version": "1.46.1",
3
+ "version": "1.47.0",
4
4
  "description": "Example contract specifications collection",
5
5
  "keywords": [
6
6
  "contractspec",
@@ -10,8 +10,6 @@
10
10
  "typescript"
11
11
  ],
12
12
  "type": "module",
13
- "main": "./dist/index.js",
14
- "module": "./dist/index.js",
15
13
  "types": "./dist/index.d.ts",
16
14
  "files": [
17
15
  "dist",
@@ -28,50 +26,53 @@
28
26
  "lint": "bun lint:fix",
29
27
  "lint:fix": "eslint src --fix",
30
28
  "lint:check": "eslint src",
31
- "test": "bun run"
29
+ "test": "bun test"
32
30
  },
33
31
  "dependencies": {
34
- "@contractspec/lib.contracts": "1.46.1",
35
- "@contractspec/example.agent-console": "1.46.1",
36
- "@contractspec/example.ai-support-bot": "1.46.1",
37
- "@contractspec/example.analytics-dashboard": "1.46.1",
38
- "@contractspec/example.content-generation": "1.46.1",
39
- "@contractspec/example.crm-pipeline": "1.46.1",
40
- "@contractspec/example.integration-hub": "1.46.1",
41
- "@contractspec/example.integration-stripe": "1.46.1",
42
- "@contractspec/example.kb-update-pipeline": "1.46.1",
43
- "@contractspec/example.knowledge-canon": "1.46.1",
44
- "@contractspec/example.learning-patterns": "1.46.1",
45
- "@contractspec/example.learning-journey-ambient-coach": "1.46.1",
46
- "@contractspec/example.learning-journey-crm-onboarding": "1.46.1",
47
- "@contractspec/example.learning-journey-duo-drills": "1.46.1",
48
- "@contractspec/example.learning-journey-platform-tour": "1.46.1",
49
- "@contractspec/example.learning-journey-quest-challenges": "1.46.1",
50
- "@contractspec/example.learning-journey-registry": "1.46.1",
51
- "@contractspec/example.learning-journey-studio-onboarding": "1.46.1",
52
- "@contractspec/example.learning-journey-ui-coaching": "1.46.1",
53
- "@contractspec/example.learning-journey-ui-gamified": "1.46.1",
54
- "@contractspec/example.learning-journey-ui-onboarding": "1.46.1",
55
- "@contractspec/example.learning-journey-ui-shared": "1.46.1",
56
- "@contractspec/example.lifecycle-cli": "1.46.1",
57
- "@contractspec/example.lifecycle-dashboard": "1.46.1",
58
- "@contractspec/example.locale-jurisdiction-gate": "1.46.1",
59
- "@contractspec/example.marketplace": "1.46.1",
60
- "@contractspec/example.openbanking-powens": "1.46.1",
61
- "@contractspec/example.personalization": "1.46.1",
62
- "@contractspec/example.policy-safe-knowledge-assistant": "1.46.1",
63
- "@contractspec/example.saas-boilerplate": "1.46.1",
64
- "@contractspec/example.service-business-os": "1.46.1",
65
- "@contractspec/example.versioned-knowledge-base": "1.46.1",
66
- "@contractspec/example.team-hub": "1.46.1",
67
- "@contractspec/example.wealth-snapshot": "1.46.1",
68
- "@contractspec/example.workflow-system": "1.46.1",
69
- "zod": "^4.1.13"
32
+ "@apollo/client": "^4.0.12",
33
+ "@contractspec/example.agent-console": "1.47.0",
34
+ "@contractspec/example.ai-support-bot": "1.47.0",
35
+ "@contractspec/example.analytics-dashboard": "1.47.0",
36
+ "@contractspec/example.content-generation": "1.47.0",
37
+ "@contractspec/example.crm-pipeline": "1.47.0",
38
+ "@contractspec/example.integration-hub": "1.47.0",
39
+ "@contractspec/example.integration-stripe": "1.47.0",
40
+ "@contractspec/example.kb-update-pipeline": "1.47.0",
41
+ "@contractspec/example.knowledge-canon": "1.47.0",
42
+ "@contractspec/example.learning-journey-ambient-coach": "1.47.0",
43
+ "@contractspec/example.learning-journey-crm-onboarding": "1.47.0",
44
+ "@contractspec/example.learning-journey-duo-drills": "1.47.0",
45
+ "@contractspec/example.learning-journey-platform-tour": "1.47.0",
46
+ "@contractspec/example.learning-journey-quest-challenges": "1.47.0",
47
+ "@contractspec/example.learning-journey-registry": "1.47.0",
48
+ "@contractspec/example.learning-journey-studio-onboarding": "1.47.0",
49
+ "@contractspec/example.learning-journey-ui-coaching": "1.47.0",
50
+ "@contractspec/example.learning-journey-ui-gamified": "1.47.0",
51
+ "@contractspec/example.learning-journey-ui-onboarding": "1.47.0",
52
+ "@contractspec/example.learning-journey-ui-shared": "1.47.0",
53
+ "@contractspec/example.learning-patterns": "1.47.0",
54
+ "@contractspec/example.lifecycle-cli": "1.47.0",
55
+ "@contractspec/example.lifecycle-dashboard": "1.47.0",
56
+ "@contractspec/example.locale-jurisdiction-gate": "1.47.0",
57
+ "@contractspec/example.marketplace": "1.47.0",
58
+ "@contractspec/example.openbanking-powens": "1.47.0",
59
+ "@contractspec/example.personalization": "1.47.0",
60
+ "@contractspec/example.policy-safe-knowledge-assistant": "1.47.0",
61
+ "@contractspec/example.saas-boilerplate": "1.47.0",
62
+ "@contractspec/example.service-business-os": "1.47.0",
63
+ "@contractspec/example.team-hub": "1.47.0",
64
+ "@contractspec/example.versioned-knowledge-base": "1.47.0",
65
+ "@contractspec/example.wealth-snapshot": "1.47.0",
66
+ "@contractspec/example.workflow-system": "1.47.0",
67
+ "@contractspec/lib.contracts": "1.47.0",
68
+ "@contractspec/lib.example-shared-ui": "1.1.0",
69
+ "@contractspec/lib.runtime-sandbox": "0.2.0",
70
+ "zod": "^4.3.5"
70
71
  },
71
72
  "devDependencies": {
72
- "@contractspec/tool.tsdown": "1.46.1",
73
- "@contractspec/tool.typescript": "1.46.1",
74
- "tsdown": "^0.18.3",
73
+ "@contractspec/tool.tsdown": "1.47.0",
74
+ "@contractspec/tool.typescript": "1.47.0",
75
+ "tsdown": "^0.19.0",
75
76
  "typescript": "^5.9.3"
76
77
  },
77
78
  "exports": {