@contractspec/lib.example-shared-ui 6.0.17 → 6.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +81 -81
- package/CHANGELOG.md +17 -0
- package/dist/EvolutionDashboard.js +1 -803
- package/dist/EvolutionSidebar.js +1 -531
- package/dist/LocalDataIndicator.js +1 -68
- package/dist/MarkdownView.js +1 -213
- package/dist/OverlayContextProvider.js +1 -202
- package/dist/PersonalizationInsights.js +1 -455
- package/dist/SaveToStudioButton.js +1 -79
- package/dist/SpecDrivenTemplateShell.js +1 -203
- package/dist/SpecEditorPanel.js +17 -364
- package/dist/TemplateShell.js +1 -195
- package/dist/browser/EvolutionDashboard.js +1 -803
- package/dist/browser/EvolutionSidebar.js +1 -531
- package/dist/browser/LocalDataIndicator.js +1 -68
- package/dist/browser/MarkdownView.js +1 -213
- package/dist/browser/OverlayContextProvider.js +1 -202
- package/dist/browser/PersonalizationInsights.js +1 -455
- package/dist/browser/SaveToStudioButton.js +1 -79
- package/dist/browser/SpecDrivenTemplateShell.js +1 -203
- package/dist/browser/SpecEditorPanel.js +17 -364
- package/dist/browser/TemplateShell.js +1 -195
- package/dist/browser/bundles/ExampleTemplateBundle.js +1 -85
- package/dist/browser/bundles/index.js +1 -85
- package/dist/browser/hooks/index.js +40 -1151
- package/dist/browser/hooks/useBehaviorTracking.js +1 -157
- package/dist/browser/hooks/useEvolution.js +1 -260
- package/dist/browser/hooks/useRegistryTemplates.js +1 -31
- package/dist/browser/hooks/useSpecContent.js +17 -224
- package/dist/browser/hooks/useWorkflowComposer.js +24 -483
- package/dist/browser/index.js +40 -3122
- package/dist/browser/lib/component-registry.js +1 -48
- package/dist/browser/lib/runtime-context.js +1 -21
- package/dist/browser/markdown/formatPresentationName.js +1 -9
- package/dist/browser/markdown/useMarkdownPresentation.js +1 -65
- package/dist/browser/utils/fetchPresentationData.js +1 -15
- package/dist/browser/utils/generateSpecFromTemplate.js +16 -62
- package/dist/browser/utils/index.js +16 -76
- package/dist/bundles/ExampleTemplateBundle.js +1 -85
- package/dist/bundles/index.js +1 -85
- package/dist/hooks/index.js +40 -1151
- package/dist/hooks/useBehaviorTracking.js +1 -157
- package/dist/hooks/useEvolution.js +1 -260
- package/dist/hooks/useRegistryTemplates.js +1 -31
- package/dist/hooks/useSpecContent.js +17 -224
- package/dist/hooks/useWorkflowComposer.js +24 -483
- package/dist/index.js +40 -3122
- package/dist/lib/component-registry.js +1 -48
- package/dist/lib/runtime-context.js +1 -21
- package/dist/markdown/formatPresentationName.js +1 -9
- package/dist/markdown/useMarkdownPresentation.js +1 -65
- package/dist/node/EvolutionDashboard.js +1 -803
- package/dist/node/EvolutionSidebar.js +1 -531
- package/dist/node/LocalDataIndicator.js +1 -68
- package/dist/node/MarkdownView.js +1 -213
- package/dist/node/OverlayContextProvider.js +1 -202
- package/dist/node/PersonalizationInsights.js +1 -455
- package/dist/node/SaveToStudioButton.js +1 -79
- package/dist/node/SpecDrivenTemplateShell.js +1 -203
- package/dist/node/SpecEditorPanel.js +17 -364
- package/dist/node/TemplateShell.js +1 -195
- package/dist/node/bundles/ExampleTemplateBundle.js +1 -85
- package/dist/node/bundles/index.js +1 -85
- package/dist/node/hooks/index.js +40 -1151
- package/dist/node/hooks/useBehaviorTracking.js +1 -157
- package/dist/node/hooks/useEvolution.js +1 -260
- package/dist/node/hooks/useRegistryTemplates.js +1 -31
- package/dist/node/hooks/useSpecContent.js +17 -224
- package/dist/node/hooks/useWorkflowComposer.js +24 -483
- package/dist/node/index.js +40 -3122
- package/dist/node/lib/component-registry.js +1 -48
- package/dist/node/lib/runtime-context.js +1 -21
- package/dist/node/markdown/formatPresentationName.js +1 -9
- package/dist/node/markdown/useMarkdownPresentation.js +1 -65
- package/dist/node/utils/fetchPresentationData.js +1 -15
- package/dist/node/utils/generateSpecFromTemplate.js +16 -62
- package/dist/node/utils/index.js +16 -76
- package/dist/utils/fetchPresentationData.js +1 -15
- package/dist/utils/generateSpecFromTemplate.js +16 -62
- package/dist/utils/index.js +16 -76
- package/package.json +13 -13
- package/src/lib/component-registry.tsx +2 -1
- package/src/lib/runtime-context.tsx +1 -1
- package/src/lib/singletons.test.ts +19 -22
|
@@ -1,48 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { useEffect, useState } from "react";
|
|
3
|
-
"use client";
|
|
4
|
-
|
|
5
|
-
class TemplateComponentRegistry {
|
|
6
|
-
components = new Map;
|
|
7
|
-
listeners = new Set;
|
|
8
|
-
register(templateId, registration) {
|
|
9
|
-
this.components.set(templateId, registration);
|
|
10
|
-
this.listeners.forEach((l) => l(templateId));
|
|
11
|
-
}
|
|
12
|
-
get(templateId) {
|
|
13
|
-
return this.components.get(templateId);
|
|
14
|
-
}
|
|
15
|
-
subscribe(listener) {
|
|
16
|
-
this.listeners.add(listener);
|
|
17
|
-
return () => {
|
|
18
|
-
this.listeners.delete(listener);
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
var TEMPLATE_COMPONENT_REGISTRY_KEY = Symbol.for("@contractspec/lib.example-shared-ui/template-component-registry");
|
|
23
|
-
function getTemplateComponentRegistrySingleton() {
|
|
24
|
-
const store = globalThis;
|
|
25
|
-
store[TEMPLATE_COMPONENT_REGISTRY_KEY] ??= new TemplateComponentRegistry;
|
|
26
|
-
return store[TEMPLATE_COMPONENT_REGISTRY_KEY];
|
|
27
|
-
}
|
|
28
|
-
var templateComponentRegistry = getTemplateComponentRegistrySingleton();
|
|
29
|
-
function registerTemplateComponents(templateId, components) {
|
|
30
|
-
templateComponentRegistry.register(templateId, components);
|
|
31
|
-
}
|
|
32
|
-
function useTemplateComponents(templateId) {
|
|
33
|
-
const [components, setComponents] = useState(() => templateComponentRegistry.get(templateId));
|
|
34
|
-
useEffect(() => {
|
|
35
|
-
return templateComponentRegistry.subscribe((updatedId) => {
|
|
36
|
-
if (updatedId === templateId) {
|
|
37
|
-
setComponents(templateComponentRegistry.get(templateId));
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
}, [templateId]);
|
|
41
|
-
return components;
|
|
42
|
-
}
|
|
43
|
-
export {
|
|
44
|
-
useTemplateComponents,
|
|
45
|
-
templateComponentRegistry,
|
|
46
|
-
registerTemplateComponents,
|
|
47
|
-
TemplateComponentRegistry
|
|
48
|
-
};
|
|
1
|
+
import{useEffect as w,useState as x}from"react";class q{components=new Map;listeners=new Set;register(b,f){this.components.set(b,f),this.listeners.forEach((j)=>j(b))}get(b){return this.components.get(b)}subscribe(b){return this.listeners.add(b),()=>{this.listeners.delete(b)}}}var k=Symbol.for("@contractspec/lib.example-shared-ui/template-component-registry");function z(){let b=globalThis;return b[k]??=new q,b[k]}var h=z();function F(b,f){h.register(b,f)}function H(b){let[f,j]=x(()=>h.get(b));return w(()=>{return h.subscribe((v)=>{if(v===b)j(h.get(b))})},[b]),f}export{H as useTemplateComponents,h as templateComponentRegistry,F as registerTemplateComponents,q as TemplateComponentRegistry};
|
|
@@ -1,21 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { createContext, useContext } from "react";
|
|
3
|
-
"use client";
|
|
4
|
-
var TEMPLATE_RUNTIME_CONTEXT_KEY = Symbol.for("@contractspec/lib.example-shared-ui/template-runtime-context");
|
|
5
|
-
function getTemplateRuntimeContextSingleton() {
|
|
6
|
-
const store = globalThis;
|
|
7
|
-
store[TEMPLATE_RUNTIME_CONTEXT_KEY] ??= createContext(null);
|
|
8
|
-
return store[TEMPLATE_RUNTIME_CONTEXT_KEY];
|
|
9
|
-
}
|
|
10
|
-
var TemplateRuntimeContext = getTemplateRuntimeContextSingleton();
|
|
11
|
-
function useTemplateRuntime() {
|
|
12
|
-
const context = useContext(TemplateRuntimeContext);
|
|
13
|
-
if (!context) {
|
|
14
|
-
throw new Error("useTemplateRuntime must be used within a TemplateRuntimeProvider");
|
|
15
|
-
}
|
|
16
|
-
return context;
|
|
17
|
-
}
|
|
18
|
-
export {
|
|
19
|
-
useTemplateRuntime,
|
|
20
|
-
TemplateRuntimeContext
|
|
21
|
-
};
|
|
1
|
+
import{createContext as f,useContext as h}from"react";var d=Symbol.for("@contractspec/lib.example-shared-ui/template-runtime-context");function j(){let b=globalThis;return b[d]??=f(null),b[d]}var k=j();function v(){let b=h(k);if(!b)throw Error("useTemplateRuntime must be used within a TemplateRuntimeProvider");return b}export{v as useTemplateRuntime,k as TemplateRuntimeContext};
|
|
@@ -1,9 +1 @@
|
|
|
1
|
-
|
|
2
|
-
function formatPresentationName(name) {
|
|
3
|
-
const parts = name.split(".");
|
|
4
|
-
const lastPart = parts[parts.length - 1] ?? name;
|
|
5
|
-
return lastPart.split("-").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
|
|
6
|
-
}
|
|
7
|
-
export {
|
|
8
|
-
formatPresentationName
|
|
9
|
-
};
|
|
1
|
+
function n(t){let s=t.split(".");return(s[s.length-1]??t).split("-").map((r)=>r.charAt(0).toUpperCase()+r.slice(1)).join(" ")}export{n as formatPresentationName};
|
|
@@ -1,65 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { useCallback, useEffect, useState } from "react";
|
|
3
|
-
"use client";
|
|
4
|
-
function useMarkdownPresentation({
|
|
5
|
-
engine,
|
|
6
|
-
fetchData,
|
|
7
|
-
presentationId,
|
|
8
|
-
presentations,
|
|
9
|
-
resolvePresentation,
|
|
10
|
-
templateId
|
|
11
|
-
}) {
|
|
12
|
-
const [selectedPresentation, setSelectedPresentation] = useState("");
|
|
13
|
-
const [markdownContent, setMarkdownContent] = useState("");
|
|
14
|
-
const [loading, setLoading] = useState(false);
|
|
15
|
-
const [error, setError] = useState(null);
|
|
16
|
-
useEffect(() => {
|
|
17
|
-
if (presentationId && presentations.includes(presentationId)) {
|
|
18
|
-
setSelectedPresentation(presentationId);
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
if (presentations.length === 0) {
|
|
22
|
-
setSelectedPresentation("");
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
if (!presentations.includes(selectedPresentation)) {
|
|
26
|
-
setSelectedPresentation(presentations[0] ?? "");
|
|
27
|
-
}
|
|
28
|
-
}, [presentationId, presentations, selectedPresentation, templateId]);
|
|
29
|
-
const renderMarkdown = useCallback(async () => {
|
|
30
|
-
if (!selectedPresentation || !engine)
|
|
31
|
-
return;
|
|
32
|
-
setLoading(true);
|
|
33
|
-
setError(null);
|
|
34
|
-
try {
|
|
35
|
-
if (!resolvePresentation) {
|
|
36
|
-
throw new Error("resolvePresentation not available in runtime context");
|
|
37
|
-
}
|
|
38
|
-
const descriptor = resolvePresentation(selectedPresentation);
|
|
39
|
-
if (!descriptor) {
|
|
40
|
-
throw new Error(`Presentation descriptor not found: ${selectedPresentation}`);
|
|
41
|
-
}
|
|
42
|
-
const dataResult = await fetchData(selectedPresentation);
|
|
43
|
-
const result = await engine.render("markdown", descriptor, { data: dataResult.data });
|
|
44
|
-
setMarkdownContent(result.body);
|
|
45
|
-
} catch (err) {
|
|
46
|
-
setError(err instanceof Error ? err : new Error("Failed to render markdown"));
|
|
47
|
-
} finally {
|
|
48
|
-
setLoading(false);
|
|
49
|
-
}
|
|
50
|
-
}, [engine, fetchData, resolvePresentation, selectedPresentation]);
|
|
51
|
-
useEffect(() => {
|
|
52
|
-
renderMarkdown();
|
|
53
|
-
}, [renderMarkdown]);
|
|
54
|
-
return {
|
|
55
|
-
error,
|
|
56
|
-
loading,
|
|
57
|
-
markdownContent,
|
|
58
|
-
renderMarkdown,
|
|
59
|
-
selectedPresentation,
|
|
60
|
-
setSelectedPresentation
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
export {
|
|
64
|
-
useMarkdownPresentation
|
|
65
|
-
};
|
|
1
|
+
import{useCallback as M,useEffect as f,useState as s}from"react";function b({engine:a,fetchData:c,presentationId:t,presentations:r,resolvePresentation:i,templateId:w}){let[n,o]=s(""),[m,g]=s(""),[k,l]=s(!1),[p,u]=s(null);f(()=>{if(t&&r.includes(t)){o(t);return}if(r.length===0){o("");return}if(!r.includes(n))o(r[0]??"")},[t,r,n,w]);let d=M(async()=>{if(!n||!a)return;l(!0),u(null);try{if(!i)throw Error("resolvePresentation not available in runtime context");let e=i(n);if(!e)throw Error(`Presentation descriptor not found: ${n}`);let P=await c(n),E=await a.render("markdown",e,{data:P.data});g(E.body)}catch(e){u(e instanceof Error?e:Error("Failed to render markdown"))}finally{l(!1)}},[a,c,i,n]);return f(()=>{d()},[d]),{error:p,loading:k,markdownContent:m,renderMarkdown:d,selectedPresentation:n,setSelectedPresentation:o}}export{b as useMarkdownPresentation};
|
|
@@ -1,15 +1 @@
|
|
|
1
|
-
|
|
2
|
-
async function fetchPresentationData(_presentationName, _templateId) {
|
|
3
|
-
throw new Error("fetchPresentationData is deprecated. Use fetchData from TemplateRuntimeContext.");
|
|
4
|
-
}
|
|
5
|
-
function hasPresentationDataFetcher(_presentationName) {
|
|
6
|
-
return false;
|
|
7
|
-
}
|
|
8
|
-
function getRegisteredPresentationFetchers() {
|
|
9
|
-
return [];
|
|
10
|
-
}
|
|
11
|
-
export {
|
|
12
|
-
hasPresentationDataFetcher,
|
|
13
|
-
getRegisteredPresentationFetchers,
|
|
14
|
-
fetchPresentationData
|
|
15
|
-
};
|
|
1
|
+
async function j(b,g){throw Error("fetchPresentationData is deprecated. Use fetchData from TemplateRuntimeContext.")}function k(b){return!1}function q(){return[]}export{k as hasPresentationDataFetcher,q as getRegisteredPresentationFetchers,j as fetchPresentationData};
|
|
@@ -1,29 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const templateId = template?.id ?? "unknown";
|
|
4
|
-
if (!template) {
|
|
5
|
-
return generateDefaultSpec(templateId);
|
|
6
|
-
}
|
|
7
|
-
switch (templateId) {
|
|
8
|
-
case "crm-pipeline":
|
|
9
|
-
return generateCrmPipelineSpec(template.schema.contracts);
|
|
10
|
-
case "saas-boilerplate":
|
|
11
|
-
return generateSaasBoilerplateSpec(template.schema.contracts);
|
|
12
|
-
case "agent-console":
|
|
13
|
-
return generateAgentConsoleSpec(template.schema.contracts);
|
|
14
|
-
case "todos-app":
|
|
15
|
-
return generateTodosSpec(template.schema.contracts);
|
|
16
|
-
case "messaging-app":
|
|
17
|
-
return generateMessagingSpec(template.schema.contracts);
|
|
18
|
-
case "recipe-app-i18n":
|
|
19
|
-
return generateRecipeSpec(template.schema.contracts);
|
|
20
|
-
default:
|
|
21
|
-
return generateDefaultSpec(templateId);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
function generateCrmPipelineSpec(contracts) {
|
|
25
|
-
return `// CRM Pipeline Specs
|
|
26
|
-
// Contracts: ${contracts.join(", ")}
|
|
1
|
+
function F(b){let h=b?.id??"unknown";if(!b)return j(h);switch(h){case"crm-pipeline":return q(b.schema.contracts);case"saas-boilerplate":return v(b.schema.contracts);case"agent-console":return x(b.schema.contracts);case"todos-app":return y(b.schema.contracts);case"messaging-app":return z(b.schema.contracts);case"recipe-app-i18n":return E(b.schema.contracts);default:return j(h)}}function q(b){return`// CRM Pipeline Specs
|
|
2
|
+
// Contracts: ${b.join(", ")}
|
|
27
3
|
|
|
28
4
|
contractSpec("crm.deal.updateStage.v1", {
|
|
29
5
|
goal: "Move a deal to a different pipeline stage",
|
|
@@ -92,11 +68,8 @@ contractSpec("crm.contact.list.v1", {
|
|
|
92
68
|
hasMore: "boolean"
|
|
93
69
|
}
|
|
94
70
|
}
|
|
95
|
-
})
|
|
96
|
-
}
|
|
97
|
-
function generateSaasBoilerplateSpec(contracts) {
|
|
98
|
-
return `// SaaS Boilerplate Specs
|
|
99
|
-
// Contracts: ${contracts.join(", ")}
|
|
71
|
+
});`}function v(b){return`// SaaS Boilerplate Specs
|
|
72
|
+
// Contracts: ${b.join(", ")}
|
|
100
73
|
|
|
101
74
|
contractSpec("saas.project.create.v1", {
|
|
102
75
|
goal: "Create a new project in an organization",
|
|
@@ -159,11 +132,8 @@ contractSpec("saas.settings.update.v1", {
|
|
|
159
132
|
}
|
|
160
133
|
},
|
|
161
134
|
events: ["settings.updated"]
|
|
162
|
-
})
|
|
163
|
-
}
|
|
164
|
-
function generateAgentConsoleSpec(contracts) {
|
|
165
|
-
return `// Agent Console Specs
|
|
166
|
-
// Contracts: ${contracts.join(", ")}
|
|
135
|
+
});`}function x(b){return`// Agent Console Specs
|
|
136
|
+
// Contracts: ${b.join(", ")}
|
|
167
137
|
|
|
168
138
|
contractSpec("agent.run.execute.v1", {
|
|
169
139
|
goal: "Execute an agent run with specified tools",
|
|
@@ -229,11 +199,8 @@ contractSpec("agent.agent.create.v1", {
|
|
|
229
199
|
}
|
|
230
200
|
},
|
|
231
201
|
events: ["agent.created"]
|
|
232
|
-
})
|
|
233
|
-
}
|
|
234
|
-
function generateTodosSpec(contracts) {
|
|
235
|
-
return `// To-dos App Specs
|
|
236
|
-
// Contracts: ${contracts.join(", ")}
|
|
202
|
+
});`}function y(b){return`// To-dos App Specs
|
|
203
|
+
// Contracts: ${b.join(", ")}
|
|
237
204
|
|
|
238
205
|
contractSpec("tasks.board.v1", {
|
|
239
206
|
goal: "Assign and approve craft work",
|
|
@@ -292,11 +259,8 @@ contractSpec("tasks.complete.v1", {
|
|
|
292
259
|
}
|
|
293
260
|
},
|
|
294
261
|
events: ["task.completed"]
|
|
295
|
-
})
|
|
296
|
-
}
|
|
297
|
-
function generateMessagingSpec(contracts) {
|
|
298
|
-
return `// Messaging App Specs
|
|
299
|
-
// Contracts: ${contracts.join(", ")}
|
|
262
|
+
});`}function z(b){return`// Messaging App Specs
|
|
263
|
+
// Contracts: ${b.join(", ")}
|
|
300
264
|
|
|
301
265
|
contractSpec("messaging.send.v1", {
|
|
302
266
|
goal: "Deliver intent-rich updates",
|
|
@@ -349,11 +313,8 @@ contractSpec("messaging.read.v1", {
|
|
|
349
313
|
}
|
|
350
314
|
},
|
|
351
315
|
events: ["message.read"]
|
|
352
|
-
})
|
|
353
|
-
}
|
|
354
|
-
function generateRecipeSpec(contracts) {
|
|
355
|
-
return `// Recipe App (i18n) Specs
|
|
356
|
-
// Contracts: ${contracts.join(", ")}
|
|
316
|
+
});`}function E(b){return`// Recipe App (i18n) Specs
|
|
317
|
+
// Contracts: ${b.join(", ")}
|
|
357
318
|
|
|
358
319
|
contractSpec("recipes.lookup.v1", {
|
|
359
320
|
goal: "Serve bilingual rituals",
|
|
@@ -400,13 +361,10 @@ contractSpec("recipes.favorite.toggle.v1", {
|
|
|
400
361
|
}
|
|
401
362
|
},
|
|
402
363
|
events: ["recipe.favorited", "recipe.unfavorited"]
|
|
403
|
-
})
|
|
404
|
-
}
|
|
405
|
-
function generateDefaultSpec(templateId) {
|
|
406
|
-
return `// ${templateId} Specs
|
|
364
|
+
});`}function j(b){return`// ${b} Specs
|
|
407
365
|
|
|
408
|
-
contractSpec("${
|
|
409
|
-
goal: "Main operation for ${
|
|
366
|
+
contractSpec("${b}.main.v1", {
|
|
367
|
+
goal: "Main operation for ${b}",
|
|
410
368
|
transport: { gql: { query: "main" } },
|
|
411
369
|
io: {
|
|
412
370
|
input: {
|
|
@@ -416,8 +374,4 @@ contractSpec("${templateId}.main.v1", {
|
|
|
416
374
|
result: "unknown"
|
|
417
375
|
}
|
|
418
376
|
}
|
|
419
|
-
})
|
|
420
|
-
}
|
|
421
|
-
export {
|
|
422
|
-
generateSpecFromTemplate
|
|
423
|
-
};
|
|
377
|
+
});`}export{F as generateSpecFromTemplate};
|
|
@@ -1,29 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const templateId = template?.id ?? "unknown";
|
|
4
|
-
if (!template) {
|
|
5
|
-
return generateDefaultSpec(templateId);
|
|
6
|
-
}
|
|
7
|
-
switch (templateId) {
|
|
8
|
-
case "crm-pipeline":
|
|
9
|
-
return generateCrmPipelineSpec(template.schema.contracts);
|
|
10
|
-
case "saas-boilerplate":
|
|
11
|
-
return generateSaasBoilerplateSpec(template.schema.contracts);
|
|
12
|
-
case "agent-console":
|
|
13
|
-
return generateAgentConsoleSpec(template.schema.contracts);
|
|
14
|
-
case "todos-app":
|
|
15
|
-
return generateTodosSpec(template.schema.contracts);
|
|
16
|
-
case "messaging-app":
|
|
17
|
-
return generateMessagingSpec(template.schema.contracts);
|
|
18
|
-
case "recipe-app-i18n":
|
|
19
|
-
return generateRecipeSpec(template.schema.contracts);
|
|
20
|
-
default:
|
|
21
|
-
return generateDefaultSpec(templateId);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
function generateCrmPipelineSpec(contracts) {
|
|
25
|
-
return `// CRM Pipeline Specs
|
|
26
|
-
// Contracts: ${contracts.join(", ")}
|
|
1
|
+
function G(x){let b=x?.id??"unknown";if(!x)return j(b);switch(b){case"crm-pipeline":return q(x.schema.contracts);case"saas-boilerplate":return v(x.schema.contracts);case"agent-console":return y(x.schema.contracts);case"todos-app":return z(x.schema.contracts);case"messaging-app":return E(x.schema.contracts);case"recipe-app-i18n":return F(x.schema.contracts);default:return j(b)}}function q(x){return`// CRM Pipeline Specs
|
|
2
|
+
// Contracts: ${x.join(", ")}
|
|
27
3
|
|
|
28
4
|
contractSpec("crm.deal.updateStage.v1", {
|
|
29
5
|
goal: "Move a deal to a different pipeline stage",
|
|
@@ -92,11 +68,8 @@ contractSpec("crm.contact.list.v1", {
|
|
|
92
68
|
hasMore: "boolean"
|
|
93
69
|
}
|
|
94
70
|
}
|
|
95
|
-
})
|
|
96
|
-
}
|
|
97
|
-
function generateSaasBoilerplateSpec(contracts) {
|
|
98
|
-
return `// SaaS Boilerplate Specs
|
|
99
|
-
// Contracts: ${contracts.join(", ")}
|
|
71
|
+
});`}function v(x){return`// SaaS Boilerplate Specs
|
|
72
|
+
// Contracts: ${x.join(", ")}
|
|
100
73
|
|
|
101
74
|
contractSpec("saas.project.create.v1", {
|
|
102
75
|
goal: "Create a new project in an organization",
|
|
@@ -159,11 +132,8 @@ contractSpec("saas.settings.update.v1", {
|
|
|
159
132
|
}
|
|
160
133
|
},
|
|
161
134
|
events: ["settings.updated"]
|
|
162
|
-
})
|
|
163
|
-
}
|
|
164
|
-
function generateAgentConsoleSpec(contracts) {
|
|
165
|
-
return `// Agent Console Specs
|
|
166
|
-
// Contracts: ${contracts.join(", ")}
|
|
135
|
+
});`}function y(x){return`// Agent Console Specs
|
|
136
|
+
// Contracts: ${x.join(", ")}
|
|
167
137
|
|
|
168
138
|
contractSpec("agent.run.execute.v1", {
|
|
169
139
|
goal: "Execute an agent run with specified tools",
|
|
@@ -229,11 +199,8 @@ contractSpec("agent.agent.create.v1", {
|
|
|
229
199
|
}
|
|
230
200
|
},
|
|
231
201
|
events: ["agent.created"]
|
|
232
|
-
})
|
|
233
|
-
}
|
|
234
|
-
function generateTodosSpec(contracts) {
|
|
235
|
-
return `// To-dos App Specs
|
|
236
|
-
// Contracts: ${contracts.join(", ")}
|
|
202
|
+
});`}function z(x){return`// To-dos App Specs
|
|
203
|
+
// Contracts: ${x.join(", ")}
|
|
237
204
|
|
|
238
205
|
contractSpec("tasks.board.v1", {
|
|
239
206
|
goal: "Assign and approve craft work",
|
|
@@ -292,11 +259,8 @@ contractSpec("tasks.complete.v1", {
|
|
|
292
259
|
}
|
|
293
260
|
},
|
|
294
261
|
events: ["task.completed"]
|
|
295
|
-
})
|
|
296
|
-
}
|
|
297
|
-
function generateMessagingSpec(contracts) {
|
|
298
|
-
return `// Messaging App Specs
|
|
299
|
-
// Contracts: ${contracts.join(", ")}
|
|
262
|
+
});`}function E(x){return`// Messaging App Specs
|
|
263
|
+
// Contracts: ${x.join(", ")}
|
|
300
264
|
|
|
301
265
|
contractSpec("messaging.send.v1", {
|
|
302
266
|
goal: "Deliver intent-rich updates",
|
|
@@ -349,11 +313,8 @@ contractSpec("messaging.read.v1", {
|
|
|
349
313
|
}
|
|
350
314
|
},
|
|
351
315
|
events: ["message.read"]
|
|
352
|
-
})
|
|
353
|
-
}
|
|
354
|
-
function generateRecipeSpec(contracts) {
|
|
355
|
-
return `// Recipe App (i18n) Specs
|
|
356
|
-
// Contracts: ${contracts.join(", ")}
|
|
316
|
+
});`}function F(x){return`// Recipe App (i18n) Specs
|
|
317
|
+
// Contracts: ${x.join(", ")}
|
|
357
318
|
|
|
358
319
|
contractSpec("recipes.lookup.v1", {
|
|
359
320
|
goal: "Serve bilingual rituals",
|
|
@@ -400,13 +361,10 @@ contractSpec("recipes.favorite.toggle.v1", {
|
|
|
400
361
|
}
|
|
401
362
|
},
|
|
402
363
|
events: ["recipe.favorited", "recipe.unfavorited"]
|
|
403
|
-
})
|
|
404
|
-
}
|
|
405
|
-
function generateDefaultSpec(templateId) {
|
|
406
|
-
return `// ${templateId} Specs
|
|
364
|
+
});`}function j(x){return`// ${x} Specs
|
|
407
365
|
|
|
408
|
-
contractSpec("${
|
|
409
|
-
goal: "Main operation for ${
|
|
366
|
+
contractSpec("${x}.main.v1", {
|
|
367
|
+
goal: "Main operation for ${x}",
|
|
410
368
|
transport: { gql: { query: "main" } },
|
|
411
369
|
io: {
|
|
412
370
|
input: {
|
|
@@ -416,22 +374,4 @@ contractSpec("${templateId}.main.v1", {
|
|
|
416
374
|
result: "unknown"
|
|
417
375
|
}
|
|
418
376
|
}
|
|
419
|
-
})
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
// src/utils/fetchPresentationData.ts
|
|
423
|
-
async function fetchPresentationData(_presentationName, _templateId) {
|
|
424
|
-
throw new Error("fetchPresentationData is deprecated. Use fetchData from TemplateRuntimeContext.");
|
|
425
|
-
}
|
|
426
|
-
function hasPresentationDataFetcher(_presentationName) {
|
|
427
|
-
return false;
|
|
428
|
-
}
|
|
429
|
-
function getRegisteredPresentationFetchers() {
|
|
430
|
-
return [];
|
|
431
|
-
}
|
|
432
|
-
export {
|
|
433
|
-
hasPresentationDataFetcher,
|
|
434
|
-
getRegisteredPresentationFetchers,
|
|
435
|
-
generateSpecFromTemplate,
|
|
436
|
-
fetchPresentationData
|
|
437
|
-
};
|
|
377
|
+
});`}async function J(x,b){throw Error("fetchPresentationData is deprecated. Use fetchData from TemplateRuntimeContext.")}function K(x){return!1}function L(){return[]}export{K as hasPresentationDataFetcher,L as getRegisteredPresentationFetchers,G as generateSpecFromTemplate,J as fetchPresentationData};
|
|
@@ -1,86 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
|
|
3
|
-
import { defineModuleBundle } from "@contractspec/lib.surface-runtime/spec";
|
|
4
|
-
var ExampleTemplateBundle = defineModuleBundle({
|
|
5
|
-
meta: {
|
|
6
|
-
key: "example.template",
|
|
7
|
-
version: "0.1.0",
|
|
8
|
-
title: "Example Template",
|
|
9
|
-
description: "Adaptive template shell for ContractSpec examples",
|
|
10
|
-
owners: ["team-platform"],
|
|
11
|
-
tags: ["example", "template"],
|
|
12
|
-
stability: "experimental"
|
|
13
|
-
},
|
|
14
|
-
routes: [
|
|
15
|
-
{
|
|
16
|
-
routeId: "template",
|
|
17
|
-
path: "/sandbox",
|
|
18
|
-
defaultSurface: "template-shell"
|
|
19
|
-
}
|
|
20
|
-
],
|
|
21
|
-
surfaces: {
|
|
22
|
-
"template-shell": {
|
|
23
|
-
surfaceId: "template-shell",
|
|
24
|
-
kind: "workbench",
|
|
25
|
-
title: "Template Shell",
|
|
26
|
-
slots: [
|
|
27
|
-
{
|
|
28
|
-
slotId: "header",
|
|
29
|
-
role: "header",
|
|
30
|
-
accepts: ["action-bar"],
|
|
31
|
-
cardinality: "many"
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
slotId: "primary",
|
|
35
|
-
role: "primary",
|
|
36
|
-
accepts: ["entity-section", "rich-doc", "form", "custom-widget"],
|
|
37
|
-
cardinality: "many"
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
slotId: "sidebar",
|
|
41
|
-
role: "secondary",
|
|
42
|
-
accepts: ["entity-section", "custom-widget"],
|
|
43
|
-
cardinality: "one"
|
|
44
|
-
}
|
|
45
|
-
],
|
|
46
|
-
layouts: [
|
|
47
|
-
{
|
|
48
|
-
layoutId: "main-with-sidebar",
|
|
49
|
-
title: "Main with sidebar",
|
|
50
|
-
root: {
|
|
51
|
-
type: "panel-group",
|
|
52
|
-
direction: "horizontal",
|
|
53
|
-
persistKey: "example.template.main-sidebar",
|
|
54
|
-
children: [
|
|
55
|
-
{
|
|
56
|
-
type: "panel-group",
|
|
57
|
-
direction: "vertical",
|
|
58
|
-
persistKey: "example.template.content",
|
|
59
|
-
children: [
|
|
60
|
-
{ type: "slot", slotId: "header" },
|
|
61
|
-
{ type: "slot", slotId: "primary" }
|
|
62
|
-
]
|
|
63
|
-
},
|
|
64
|
-
{ type: "slot", slotId: "sidebar" }
|
|
65
|
-
]
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
],
|
|
69
|
-
data: [],
|
|
70
|
-
verification: {
|
|
71
|
-
dimensions: {
|
|
72
|
-
guidance: "Can reveal hints and walkthrough notes.",
|
|
73
|
-
density: "Can select compact or balanced layouts.",
|
|
74
|
-
dataDepth: "Controls content depth and expansion.",
|
|
75
|
-
control: "Shows advanced options when allowed.",
|
|
76
|
-
media: "Supports text-first and hybrid modes.",
|
|
77
|
-
pace: "Maps to motion tokens and transitions.",
|
|
78
|
-
narrative: "Can order summary before or after detail."
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
export {
|
|
85
|
-
ExampleTemplateBundle
|
|
86
|
-
};
|
|
2
|
+
import{defineModuleBundle as g}from"@contractspec/lib.surface-runtime/spec";var j=g({meta:{key:"example.template",version:"0.1.0",title:"Example Template",description:"Adaptive template shell for ContractSpec examples",owners:["team-platform"],tags:["example","template"],stability:"experimental"},routes:[{routeId:"template",path:"/sandbox",defaultSurface:"template-shell"}],surfaces:{"template-shell":{surfaceId:"template-shell",kind:"workbench",title:"Template Shell",slots:[{slotId:"header",role:"header",accepts:["action-bar"],cardinality:"many"},{slotId:"primary",role:"primary",accepts:["entity-section","rich-doc","form","custom-widget"],cardinality:"many"},{slotId:"sidebar",role:"secondary",accepts:["entity-section","custom-widget"],cardinality:"one"}],layouts:[{layoutId:"main-with-sidebar",title:"Main with sidebar",root:{type:"panel-group",direction:"horizontal",persistKey:"example.template.main-sidebar",children:[{type:"panel-group",direction:"vertical",persistKey:"example.template.content",children:[{type:"slot",slotId:"header"},{type:"slot",slotId:"primary"}]},{type:"slot",slotId:"sidebar"}]}}],data:[],verification:{dimensions:{guidance:"Can reveal hints and walkthrough notes.",density:"Can select compact or balanced layouts.",dataDepth:"Controls content depth and expansion.",control:"Shows advanced options when allowed.",media:"Supports text-first and hybrid modes.",pace:"Maps to motion tokens and transitions.",narrative:"Can order summary before or after detail."}}}}});export{j as ExampleTemplateBundle};
|
package/dist/bundles/index.js
CHANGED
|
@@ -1,86 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
|
|
3
|
-
import { defineModuleBundle } from "@contractspec/lib.surface-runtime/spec";
|
|
4
|
-
var ExampleTemplateBundle = defineModuleBundle({
|
|
5
|
-
meta: {
|
|
6
|
-
key: "example.template",
|
|
7
|
-
version: "0.1.0",
|
|
8
|
-
title: "Example Template",
|
|
9
|
-
description: "Adaptive template shell for ContractSpec examples",
|
|
10
|
-
owners: ["team-platform"],
|
|
11
|
-
tags: ["example", "template"],
|
|
12
|
-
stability: "experimental"
|
|
13
|
-
},
|
|
14
|
-
routes: [
|
|
15
|
-
{
|
|
16
|
-
routeId: "template",
|
|
17
|
-
path: "/sandbox",
|
|
18
|
-
defaultSurface: "template-shell"
|
|
19
|
-
}
|
|
20
|
-
],
|
|
21
|
-
surfaces: {
|
|
22
|
-
"template-shell": {
|
|
23
|
-
surfaceId: "template-shell",
|
|
24
|
-
kind: "workbench",
|
|
25
|
-
title: "Template Shell",
|
|
26
|
-
slots: [
|
|
27
|
-
{
|
|
28
|
-
slotId: "header",
|
|
29
|
-
role: "header",
|
|
30
|
-
accepts: ["action-bar"],
|
|
31
|
-
cardinality: "many"
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
slotId: "primary",
|
|
35
|
-
role: "primary",
|
|
36
|
-
accepts: ["entity-section", "rich-doc", "form", "custom-widget"],
|
|
37
|
-
cardinality: "many"
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
slotId: "sidebar",
|
|
41
|
-
role: "secondary",
|
|
42
|
-
accepts: ["entity-section", "custom-widget"],
|
|
43
|
-
cardinality: "one"
|
|
44
|
-
}
|
|
45
|
-
],
|
|
46
|
-
layouts: [
|
|
47
|
-
{
|
|
48
|
-
layoutId: "main-with-sidebar",
|
|
49
|
-
title: "Main with sidebar",
|
|
50
|
-
root: {
|
|
51
|
-
type: "panel-group",
|
|
52
|
-
direction: "horizontal",
|
|
53
|
-
persistKey: "example.template.main-sidebar",
|
|
54
|
-
children: [
|
|
55
|
-
{
|
|
56
|
-
type: "panel-group",
|
|
57
|
-
direction: "vertical",
|
|
58
|
-
persistKey: "example.template.content",
|
|
59
|
-
children: [
|
|
60
|
-
{ type: "slot", slotId: "header" },
|
|
61
|
-
{ type: "slot", slotId: "primary" }
|
|
62
|
-
]
|
|
63
|
-
},
|
|
64
|
-
{ type: "slot", slotId: "sidebar" }
|
|
65
|
-
]
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
],
|
|
69
|
-
data: [],
|
|
70
|
-
verification: {
|
|
71
|
-
dimensions: {
|
|
72
|
-
guidance: "Can reveal hints and walkthrough notes.",
|
|
73
|
-
density: "Can select compact or balanced layouts.",
|
|
74
|
-
dataDepth: "Controls content depth and expansion.",
|
|
75
|
-
control: "Shows advanced options when allowed.",
|
|
76
|
-
media: "Supports text-first and hybrid modes.",
|
|
77
|
-
pace: "Maps to motion tokens and transitions.",
|
|
78
|
-
narrative: "Can order summary before or after detail."
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
export {
|
|
85
|
-
ExampleTemplateBundle
|
|
86
|
-
};
|
|
2
|
+
import{defineModuleBundle as m}from"@contractspec/lib.surface-runtime/spec";var x=m({meta:{key:"example.template",version:"0.1.0",title:"Example Template",description:"Adaptive template shell for ContractSpec examples",owners:["team-platform"],tags:["example","template"],stability:"experimental"},routes:[{routeId:"template",path:"/sandbox",defaultSurface:"template-shell"}],surfaces:{"template-shell":{surfaceId:"template-shell",kind:"workbench",title:"Template Shell",slots:[{slotId:"header",role:"header",accepts:["action-bar"],cardinality:"many"},{slotId:"primary",role:"primary",accepts:["entity-section","rich-doc","form","custom-widget"],cardinality:"many"},{slotId:"sidebar",role:"secondary",accepts:["entity-section","custom-widget"],cardinality:"one"}],layouts:[{layoutId:"main-with-sidebar",title:"Main with sidebar",root:{type:"panel-group",direction:"horizontal",persistKey:"example.template.main-sidebar",children:[{type:"panel-group",direction:"vertical",persistKey:"example.template.content",children:[{type:"slot",slotId:"header"},{type:"slot",slotId:"primary"}]},{type:"slot",slotId:"sidebar"}]}}],data:[],verification:{dimensions:{guidance:"Can reveal hints and walkthrough notes.",density:"Can select compact or balanced layouts.",dataDepth:"Controls content depth and expansion.",control:"Shows advanced options when allowed.",media:"Supports text-first and hybrid modes.",pace:"Maps to motion tokens and transitions.",narrative:"Can order summary before or after detail."}}}}});export{x as ExampleTemplateBundle};
|