@contractspec/lib.example-shared-ui 1.11.0 → 1.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/.turbo/turbo-build.log +86 -11
  2. package/.turbo/turbo-prebuild.log +1 -0
  3. package/CHANGELOG.md +27 -0
  4. package/dist/EvolutionDashboard.d.ts +11 -0
  5. package/dist/EvolutionDashboard.d.ts.map +1 -0
  6. package/dist/EvolutionDashboard.js +804 -0
  7. package/dist/EvolutionSidebar.d.ts +19 -0
  8. package/dist/EvolutionSidebar.d.ts.map +1 -0
  9. package/dist/EvolutionSidebar.js +532 -0
  10. package/dist/LocalDataIndicator.d.ts +2 -0
  11. package/dist/LocalDataIndicator.d.ts.map +1 -0
  12. package/dist/LocalDataIndicator.js +63 -0
  13. package/dist/MarkdownView.d.ts +20 -0
  14. package/dist/MarkdownView.d.ts.map +1 -0
  15. package/dist/MarkdownView.js +304 -0
  16. package/dist/OverlayContextProvider.d.ts +79 -0
  17. package/dist/OverlayContextProvider.d.ts.map +1 -0
  18. package/dist/OverlayContextProvider.js +203 -0
  19. package/dist/PersonalizationInsights.d.ts +14 -0
  20. package/dist/PersonalizationInsights.d.ts.map +1 -0
  21. package/dist/PersonalizationInsights.js +456 -0
  22. package/dist/SaveToStudioButton.d.ts +8 -0
  23. package/dist/SaveToStudioButton.d.ts.map +1 -0
  24. package/dist/SaveToStudioButton.js +74 -0
  25. package/dist/SpecEditorPanel.d.ts +23 -0
  26. package/dist/SpecEditorPanel.d.ts.map +1 -0
  27. package/dist/SpecEditorPanel.js +720 -0
  28. package/dist/TemplateShell.d.ts +13 -0
  29. package/dist/TemplateShell.d.ts.map +1 -0
  30. package/dist/TemplateShell.js +190 -0
  31. package/dist/browser/EvolutionDashboard.js +803 -0
  32. package/dist/browser/EvolutionSidebar.js +531 -0
  33. package/dist/browser/LocalDataIndicator.js +62 -0
  34. package/dist/browser/MarkdownView.js +303 -0
  35. package/dist/browser/OverlayContextProvider.js +202 -0
  36. package/dist/browser/PersonalizationInsights.js +455 -0
  37. package/dist/browser/SaveToStudioButton.js +73 -0
  38. package/dist/browser/SpecEditorPanel.js +719 -0
  39. package/dist/browser/TemplateShell.js +189 -0
  40. package/dist/browser/hooks/index.js +1516 -0
  41. package/dist/browser/hooks/useBehaviorTracking.js +157 -0
  42. package/dist/browser/hooks/useEvolution.js +260 -0
  43. package/dist/browser/hooks/useRegistryTemplates.js +31 -0
  44. package/dist/browser/hooks/useSpecContent.js +579 -0
  45. package/dist/browser/hooks/useWorkflowComposer.js +493 -0
  46. package/dist/browser/index.js +3497 -0
  47. package/dist/browser/lib/component-registry.js +42 -0
  48. package/dist/browser/lib/runtime-context.js +15 -0
  49. package/dist/browser/lib/types.js +0 -0
  50. package/dist/browser/overlay-types.js +0 -0
  51. package/dist/browser/utils/fetchPresentationData.js +15 -0
  52. package/dist/browser/utils/generateSpecFromTemplate.js +423 -0
  53. package/dist/browser/utils/index.js +437 -0
  54. package/dist/hooks/index.d.ts +6 -0
  55. package/dist/hooks/index.d.ts.map +1 -0
  56. package/dist/hooks/index.js +1517 -0
  57. package/dist/hooks/useBehaviorTracking.d.ts +56 -0
  58. package/dist/hooks/useBehaviorTracking.d.ts.map +1 -0
  59. package/dist/hooks/useBehaviorTracking.js +158 -0
  60. package/dist/hooks/useEvolution.d.ts +111 -0
  61. package/dist/hooks/useEvolution.d.ts.map +1 -0
  62. package/dist/hooks/useEvolution.js +261 -0
  63. package/dist/hooks/useRegistryTemplates.d.ts +10 -0
  64. package/dist/hooks/useRegistryTemplates.d.ts.map +1 -0
  65. package/dist/hooks/useRegistryTemplates.js +32 -0
  66. package/dist/hooks/useSpecContent.d.ts +41 -0
  67. package/dist/hooks/useSpecContent.d.ts.map +1 -0
  68. package/dist/hooks/useSpecContent.js +580 -0
  69. package/dist/hooks/useWorkflowComposer.d.ts +94 -0
  70. package/dist/hooks/useWorkflowComposer.d.ts.map +1 -0
  71. package/dist/hooks/useWorkflowComposer.js +494 -0
  72. package/dist/index.d.ts +16 -0
  73. package/dist/index.d.ts.map +1 -0
  74. package/dist/index.js +3498 -0
  75. package/dist/lib/component-registry.d.ts +18 -0
  76. package/dist/lib/component-registry.d.ts.map +1 -0
  77. package/dist/lib/component-registry.js +43 -0
  78. package/dist/lib/runtime-context.d.ts +29 -0
  79. package/dist/lib/runtime-context.d.ts.map +1 -0
  80. package/dist/lib/runtime-context.js +16 -0
  81. package/dist/lib/types.d.ts +69 -0
  82. package/dist/lib/types.d.ts.map +1 -0
  83. package/dist/lib/types.js +1 -0
  84. package/dist/node/EvolutionDashboard.js +803 -0
  85. package/dist/node/EvolutionSidebar.js +531 -0
  86. package/dist/node/LocalDataIndicator.js +62 -0
  87. package/dist/node/MarkdownView.js +303 -0
  88. package/dist/node/OverlayContextProvider.js +202 -0
  89. package/dist/node/PersonalizationInsights.js +455 -0
  90. package/dist/node/SaveToStudioButton.js +73 -0
  91. package/dist/node/SpecEditorPanel.js +719 -0
  92. package/dist/node/TemplateShell.js +189 -0
  93. package/dist/node/hooks/index.js +1516 -0
  94. package/dist/node/hooks/useBehaviorTracking.js +157 -0
  95. package/dist/node/hooks/useEvolution.js +260 -0
  96. package/dist/node/hooks/useRegistryTemplates.js +31 -0
  97. package/dist/node/hooks/useSpecContent.js +579 -0
  98. package/dist/node/hooks/useWorkflowComposer.js +493 -0
  99. package/dist/node/index.js +3497 -0
  100. package/dist/node/lib/component-registry.js +42 -0
  101. package/dist/node/lib/runtime-context.js +15 -0
  102. package/dist/node/lib/types.js +0 -0
  103. package/dist/node/overlay-types.js +0 -0
  104. package/dist/node/utils/fetchPresentationData.js +15 -0
  105. package/dist/node/utils/generateSpecFromTemplate.js +423 -0
  106. package/dist/node/utils/index.js +437 -0
  107. package/dist/overlay-types.d.ts +41 -0
  108. package/dist/overlay-types.d.ts.map +1 -0
  109. package/dist/overlay-types.js +1 -0
  110. package/dist/utils/fetchPresentationData.d.ts +34 -0
  111. package/dist/utils/fetchPresentationData.d.ts.map +1 -0
  112. package/dist/utils/fetchPresentationData.js +16 -0
  113. package/dist/utils/generateSpecFromTemplate.d.ts +7 -0
  114. package/dist/utils/generateSpecFromTemplate.d.ts.map +1 -0
  115. package/dist/utils/generateSpecFromTemplate.js +424 -0
  116. package/dist/utils/index.d.ts +3 -0
  117. package/dist/utils/index.d.ts.map +1 -0
  118. package/dist/utils/index.js +438 -0
  119. package/package.json +219 -14
  120. package/.turbo/turbo-build$colon$bundle.log +0 -9
  121. package/dist/index.mjs +0 -3121
@@ -0,0 +1,42 @@
1
+ // src/lib/component-registry.tsx
2
+ import { useState, useEffect } 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 templateComponentRegistry = new TemplateComponentRegistry;
23
+ function registerTemplateComponents(templateId, components) {
24
+ templateComponentRegistry.register(templateId, components);
25
+ }
26
+ function useTemplateComponents(templateId) {
27
+ const [components, setComponents] = useState(() => templateComponentRegistry.get(templateId));
28
+ useEffect(() => {
29
+ return templateComponentRegistry.subscribe((updatedId) => {
30
+ if (updatedId === templateId) {
31
+ setComponents(templateComponentRegistry.get(templateId));
32
+ }
33
+ });
34
+ }, [templateId]);
35
+ return components;
36
+ }
37
+ export {
38
+ useTemplateComponents,
39
+ templateComponentRegistry,
40
+ registerTemplateComponents,
41
+ TemplateComponentRegistry
42
+ };
@@ -0,0 +1,15 @@
1
+ // src/lib/runtime-context.tsx
2
+ import { createContext, useContext } from "react";
3
+ "use client";
4
+ var TemplateRuntimeContext = createContext(null);
5
+ function useTemplateRuntime() {
6
+ const context = useContext(TemplateRuntimeContext);
7
+ if (!context) {
8
+ throw new Error("useTemplateRuntime must be used within a TemplateRuntimeProvider");
9
+ }
10
+ return context;
11
+ }
12
+ export {
13
+ useTemplateRuntime,
14
+ TemplateRuntimeContext
15
+ };
File without changes
File without changes
@@ -0,0 +1,15 @@
1
+ // src/utils/fetchPresentationData.ts
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
+ };
@@ -0,0 +1,423 @@
1
+ // src/utils/generateSpecFromTemplate.ts
2
+ function generateSpecFromTemplate(template) {
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(", ")}
27
+
28
+ contractSpec("crm.deal.updateStage.v1", {
29
+ goal: "Move a deal to a different pipeline stage",
30
+ transport: { gql: { mutation: "updateDealStage" } },
31
+ io: {
32
+ input: {
33
+ dealId: "string",
34
+ stageId: "string",
35
+ notes: "string?"
36
+ },
37
+ output: {
38
+ deal: {
39
+ id: "string",
40
+ stage: "string",
41
+ probability: "number",
42
+ value: "number"
43
+ }
44
+ }
45
+ },
46
+ events: ["deal.stage.changed"],
47
+ policy: { auth: "user", rbac: "org:sales" }
48
+ });
49
+
50
+ contractSpec("crm.deal.create.v1", {
51
+ goal: "Create a new deal in the pipeline",
52
+ transport: { gql: { mutation: "createDeal" } },
53
+ io: {
54
+ input: {
55
+ title: "string",
56
+ value: "number",
57
+ contactId: "string",
58
+ stageId: "string",
59
+ ownerId: "string?"
60
+ },
61
+ output: {
62
+ deal: {
63
+ id: "string",
64
+ title: "string",
65
+ value: "number",
66
+ stage: "string",
67
+ createdAt: "ISO8601"
68
+ }
69
+ }
70
+ },
71
+ events: ["deal.created"]
72
+ });
73
+
74
+ contractSpec("crm.contact.list.v1", {
75
+ goal: "List contacts with filtering and pagination",
76
+ transport: { gql: { query: "listContacts" } },
77
+ io: {
78
+ input: {
79
+ filter: {
80
+ search: "string?",
81
+ companyId: "string?",
82
+ tags: "string[]?"
83
+ },
84
+ pagination: {
85
+ page: "number",
86
+ limit: "number"
87
+ }
88
+ },
89
+ output: {
90
+ contacts: "array<Contact>",
91
+ total: "number",
92
+ hasMore: "boolean"
93
+ }
94
+ }
95
+ });`;
96
+ }
97
+ function generateSaasBoilerplateSpec(contracts) {
98
+ return `// SaaS Boilerplate Specs
99
+ // Contracts: ${contracts.join(", ")}
100
+
101
+ contractSpec("saas.project.create.v1", {
102
+ goal: "Create a new project in an organization",
103
+ transport: { gql: { mutation: "createProject" } },
104
+ io: {
105
+ input: {
106
+ orgId: "string",
107
+ name: "string",
108
+ description: "string?"
109
+ },
110
+ output: {
111
+ project: {
112
+ id: "string",
113
+ name: "string",
114
+ description: "string?",
115
+ createdAt: "ISO8601"
116
+ }
117
+ }
118
+ },
119
+ policy: { auth: "user", rbac: "org:member" }
120
+ });
121
+
122
+ contractSpec("saas.billing.recordUsage.v1", {
123
+ goal: "Record usage for billing purposes",
124
+ transport: { gql: { mutation: "recordUsage" } },
125
+ io: {
126
+ input: {
127
+ orgId: "string",
128
+ metric: "enum<'api_calls'|'storage_gb'|'seats'>",
129
+ quantity: "number",
130
+ timestamp: "ISO8601?"
131
+ },
132
+ output: {
133
+ usage: {
134
+ id: "string",
135
+ metric: "string",
136
+ quantity: "number",
137
+ recordedAt: "ISO8601"
138
+ }
139
+ }
140
+ },
141
+ events: ["billing.usage.recorded"]
142
+ });
143
+
144
+ contractSpec("saas.settings.update.v1", {
145
+ goal: "Update organization or user settings",
146
+ transport: { gql: { mutation: "updateSettings" } },
147
+ io: {
148
+ input: {
149
+ scope: "enum<'org'|'user'>",
150
+ targetId: "string",
151
+ settings: "Record<string, unknown>"
152
+ },
153
+ output: {
154
+ settings: {
155
+ scope: "string",
156
+ values: "Record<string, unknown>",
157
+ updatedAt: "ISO8601"
158
+ }
159
+ }
160
+ },
161
+ events: ["settings.updated"]
162
+ });`;
163
+ }
164
+ function generateAgentConsoleSpec(contracts) {
165
+ return `// Agent Console Specs
166
+ // Contracts: ${contracts.join(", ")}
167
+
168
+ contractSpec("agent.run.execute.v1", {
169
+ goal: "Execute an agent run with specified tools",
170
+ transport: { gql: { mutation: "executeAgentRun" } },
171
+ io: {
172
+ input: {
173
+ agentId: "string",
174
+ input: "string",
175
+ tools: "string[]?",
176
+ maxSteps: "number?"
177
+ },
178
+ output: {
179
+ runId: "string",
180
+ status: "enum<'running'|'completed'|'failed'>",
181
+ steps: "number"
182
+ }
183
+ },
184
+ events: ["run.started", "run.completed", "run.failed"]
185
+ });
186
+
187
+ contractSpec("agent.tool.create.v1", {
188
+ goal: "Register a new tool in the tool registry",
189
+ transport: { gql: { mutation: "createTool" } },
190
+ io: {
191
+ input: {
192
+ name: "string",
193
+ description: "string",
194
+ category: "enum<'code'|'data'|'api'|'file'|'custom'>",
195
+ schema: "JSONSchema",
196
+ handler: "string"
197
+ },
198
+ output: {
199
+ tool: {
200
+ id: "string",
201
+ name: "string",
202
+ category: "string",
203
+ createdAt: "ISO8601"
204
+ }
205
+ }
206
+ },
207
+ events: ["tool.created"]
208
+ });
209
+
210
+ contractSpec("agent.agent.create.v1", {
211
+ goal: "Create a new AI agent configuration",
212
+ transport: { gql: { mutation: "createAgent" } },
213
+ io: {
214
+ input: {
215
+ name: "string",
216
+ description: "string",
217
+ model: "string",
218
+ systemPrompt: "string?",
219
+ tools: "string[]?"
220
+ },
221
+ output: {
222
+ agent: {
223
+ id: "string",
224
+ name: "string",
225
+ model: "string",
226
+ toolCount: "number",
227
+ createdAt: "ISO8601"
228
+ }
229
+ }
230
+ },
231
+ events: ["agent.created"]
232
+ });`;
233
+ }
234
+ function generateTodosSpec(contracts) {
235
+ return `// To-dos App Specs
236
+ // Contracts: ${contracts.join(", ")}
237
+
238
+ contractSpec("tasks.board.v1", {
239
+ goal: "Assign and approve craft work",
240
+ transport: { gql: { field: "tasksBoard" } },
241
+ io: {
242
+ input: {
243
+ tenantId: "string",
244
+ assignee: "string?",
245
+ status: "enum<'pending'|'in_progress'|'completed'>?"
246
+ },
247
+ output: {
248
+ tasks: "array<Task>",
249
+ summary: {
250
+ total: "number",
251
+ completed: "number",
252
+ overdue: "number"
253
+ }
254
+ }
255
+ }
256
+ });
257
+
258
+ contractSpec("tasks.create.v1", {
259
+ goal: "Create a new task",
260
+ transport: { gql: { mutation: "createTask" } },
261
+ io: {
262
+ input: {
263
+ title: "string",
264
+ description: "string?",
265
+ assignee: "string?",
266
+ priority: "enum<'low'|'medium'|'high'>",
267
+ dueDate: "ISO8601?"
268
+ },
269
+ output: {
270
+ task: {
271
+ id: "string",
272
+ title: "string",
273
+ status: "string",
274
+ createdAt: "ISO8601"
275
+ }
276
+ }
277
+ },
278
+ events: ["task.created"]
279
+ });
280
+
281
+ contractSpec("tasks.complete.v1", {
282
+ goal: "Mark a task as completed",
283
+ transport: { gql: { mutation: "completeTask" } },
284
+ io: {
285
+ input: { taskId: "string" },
286
+ output: {
287
+ task: {
288
+ id: "string",
289
+ status: "string",
290
+ completedAt: "ISO8601"
291
+ }
292
+ }
293
+ },
294
+ events: ["task.completed"]
295
+ });`;
296
+ }
297
+ function generateMessagingSpec(contracts) {
298
+ return `// Messaging App Specs
299
+ // Contracts: ${contracts.join(", ")}
300
+
301
+ contractSpec("messaging.send.v1", {
302
+ goal: "Deliver intent-rich updates",
303
+ io: {
304
+ input: {
305
+ conversationId: "string",
306
+ body: "richtext",
307
+ attachments: "array<Attachment>?"
308
+ },
309
+ output: {
310
+ messageId: "string",
311
+ deliveredAt: "ISO8601"
312
+ }
313
+ },
314
+ events: ["message.sent", "message.delivered"]
315
+ });
316
+
317
+ contractSpec("messaging.conversation.create.v1", {
318
+ goal: "Start a new conversation",
319
+ transport: { gql: { mutation: "createConversation" } },
320
+ io: {
321
+ input: {
322
+ participants: "string[]",
323
+ title: "string?",
324
+ type: "enum<'direct'|'group'>"
325
+ },
326
+ output: {
327
+ conversation: {
328
+ id: "string",
329
+ title: "string?",
330
+ participantCount: "number",
331
+ createdAt: "ISO8601"
332
+ }
333
+ }
334
+ },
335
+ events: ["conversation.created"]
336
+ });
337
+
338
+ contractSpec("messaging.read.v1", {
339
+ goal: "Mark messages as read",
340
+ transport: { gql: { mutation: "markRead" } },
341
+ io: {
342
+ input: {
343
+ conversationId: "string",
344
+ messageIds: "string[]"
345
+ },
346
+ output: {
347
+ readCount: "number",
348
+ readAt: "ISO8601"
349
+ }
350
+ },
351
+ events: ["message.read"]
352
+ });`;
353
+ }
354
+ function generateRecipeSpec(contracts) {
355
+ return `// Recipe App (i18n) Specs
356
+ // Contracts: ${contracts.join(", ")}
357
+
358
+ contractSpec("recipes.lookup.v1", {
359
+ goal: "Serve bilingual rituals",
360
+ io: {
361
+ input: {
362
+ locale: "enum<'EN'|'FR'>",
363
+ slug: "string"
364
+ },
365
+ output: {
366
+ title: "string",
367
+ content: "markdown",
368
+ ingredients: "array<Ingredient>",
369
+ instructions: "array<Instruction>"
370
+ }
371
+ }
372
+ });
373
+
374
+ contractSpec("recipes.list.v1", {
375
+ goal: "Browse recipes with filtering",
376
+ transport: { gql: { query: "listRecipes" } },
377
+ io: {
378
+ input: {
379
+ locale: "enum<'EN'|'FR'>",
380
+ category: "string?",
381
+ search: "string?",
382
+ favorites: "boolean?"
383
+ },
384
+ output: {
385
+ recipes: "array<RecipeSummary>",
386
+ categories: "array<Category>",
387
+ total: "number"
388
+ }
389
+ }
390
+ });
391
+
392
+ contractSpec("recipes.favorite.toggle.v1", {
393
+ goal: "Toggle recipe favorite status",
394
+ transport: { gql: { mutation: "toggleFavorite" } },
395
+ io: {
396
+ input: { recipeId: "string" },
397
+ output: {
398
+ isFavorite: "boolean",
399
+ totalFavorites: "number"
400
+ }
401
+ },
402
+ events: ["recipe.favorited", "recipe.unfavorited"]
403
+ });`;
404
+ }
405
+ function generateDefaultSpec(templateId) {
406
+ return `// ${templateId} Specs
407
+
408
+ contractSpec("${templateId}.main.v1", {
409
+ goal: "Main operation for ${templateId}",
410
+ transport: { gql: { query: "main" } },
411
+ io: {
412
+ input: {
413
+ id: "string"
414
+ },
415
+ output: {
416
+ result: "unknown"
417
+ }
418
+ }
419
+ });`;
420
+ }
421
+ export {
422
+ generateSpecFromTemplate
423
+ };