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