@plotday/twister 0.20.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.
- package/LICENSE +21 -0
- package/README.md +261 -0
- package/bin/commands/build.js +108 -0
- package/bin/commands/build.js.map +1 -0
- package/bin/commands/create.js +230 -0
- package/bin/commands/create.js.map +1 -0
- package/bin/commands/deploy.js +292 -0
- package/bin/commands/deploy.js.map +1 -0
- package/bin/commands/generate.js +301 -0
- package/bin/commands/generate.js.map +1 -0
- package/bin/commands/lint.js +69 -0
- package/bin/commands/lint.js.map +1 -0
- package/bin/commands/login.js +140 -0
- package/bin/commands/login.js.map +1 -0
- package/bin/commands/priority-create.js +102 -0
- package/bin/commands/priority-create.js.map +1 -0
- package/bin/commands/priority-list.js +47 -0
- package/bin/commands/priority-list.js.map +1 -0
- package/bin/commands/twist-logs.js +187 -0
- package/bin/commands/twist-logs.js.map +1 -0
- package/bin/index.js +129 -0
- package/bin/index.js.map +1 -0
- package/bin/package.json +3 -0
- package/bin/plot.cjs +3 -0
- package/bin/templates/AGENTS.template.md +403 -0
- package/bin/templates/CLAUDE.template.md +1 -0
- package/bin/templates/README.template.md +189 -0
- package/bin/utils/bundle.js +106 -0
- package/bin/utils/bundle.js.map +1 -0
- package/bin/utils/output.js +133 -0
- package/bin/utils/output.js.map +1 -0
- package/bin/utils/packageManager.js +65 -0
- package/bin/utils/packageManager.js.map +1 -0
- package/bin/utils/sse.js +100 -0
- package/bin/utils/sse.js.map +1 -0
- package/bin/utils/token.js +75 -0
- package/bin/utils/token.js.map +1 -0
- package/cli/templates/AGENTS.template.md +403 -0
- package/cli/templates/CLAUDE.template.md +1 -0
- package/cli/templates/README.template.md +189 -0
- package/dist/common/calendar.d.ts +144 -0
- package/dist/common/calendar.d.ts.map +1 -0
- package/dist/common/calendar.js +2 -0
- package/dist/common/calendar.js.map +1 -0
- package/dist/common/messaging.d.ts +84 -0
- package/dist/common/messaging.d.ts.map +1 -0
- package/dist/common/messaging.js +2 -0
- package/dist/common/messaging.js.map +1 -0
- package/dist/creator-docs.d.ts +11 -0
- package/dist/creator-docs.d.ts.map +1 -0
- package/dist/creator-docs.js +27 -0
- package/dist/creator-docs.js.map +1 -0
- package/dist/docs/.nojekyll +1 -0
- package/dist/docs/assets/favicon.svg +8 -0
- package/dist/docs/assets/hierarchy.js +1 -0
- package/dist/docs/assets/highlight.css +134 -0
- package/dist/docs/assets/icons.js +18 -0
- package/dist/docs/assets/icons.svg +1 -0
- package/dist/docs/assets/main.js +60 -0
- package/dist/docs/assets/navigation.js +1 -0
- package/dist/docs/assets/search.js +1 -0
- package/dist/docs/assets/style.css +1633 -0
- package/dist/docs/classes/tool.ITool.html +4 -0
- package/dist/docs/classes/tool.Tool.html +116 -0
- package/dist/docs/classes/tools_ai.AI.html +27 -0
- package/dist/docs/classes/tools_callbacks.Callbacks.html +45 -0
- package/dist/docs/classes/tools_integrations.Integrations.html +26 -0
- package/dist/docs/classes/tools_network.Network.html +68 -0
- package/dist/docs/classes/tools_plot.Plot.html +82 -0
- package/dist/docs/classes/tools_store.Store.html +53 -0
- package/dist/docs/classes/tools_tasks.Tasks.html +39 -0
- package/dist/docs/classes/tools_twists.Twists.html +59 -0
- package/dist/docs/classes/twist.Twist.html +96 -0
- package/dist/docs/documents/Advanced.html +91 -0
- package/dist/docs/documents/Building_Custom_Tools.html +200 -0
- package/dist/docs/documents/Built-in_Tools.html +170 -0
- package/dist/docs/documents/CLI_Reference.html +193 -0
- package/dist/docs/documents/Core_Concepts.html +163 -0
- package/dist/docs/documents/Getting_Started.html +94 -0
- package/dist/docs/documents/Runtime_Environment.html +128 -0
- package/dist/docs/enums/plot.ActivityLinkType.html +12 -0
- package/dist/docs/enums/plot.ActivityType.html +10 -0
- package/dist/docs/enums/plot.ActorType.html +10 -0
- package/dist/docs/enums/plot.ConferencingProvider.html +14 -0
- package/dist/docs/enums/tag.Tag.html +45 -0
- package/dist/docs/enums/tools_ai.AIModel.html +31 -0
- package/dist/docs/enums/tools_integrations.AuthLevel.html +7 -0
- package/dist/docs/enums/tools_integrations.AuthProvider.html +24 -0
- package/dist/docs/enums/tools_plot.ActivityAccess.html +8 -0
- package/dist/docs/enums/tools_plot.ContactAccess.html +5 -0
- package/dist/docs/enums/tools_plot.PriorityAccess.html +8 -0
- package/dist/docs/hierarchy.html +1 -0
- package/dist/docs/index.html +100 -0
- package/dist/docs/interfaces/common_calendar.Calendar.html +13 -0
- package/dist/docs/interfaces/common_calendar.CalendarTool.html +49 -0
- package/dist/docs/interfaces/common_calendar.SyncOptions.html +8 -0
- package/dist/docs/interfaces/tools_ai.AIRequest.html +46 -0
- package/dist/docs/interfaces/tools_ai.AIResponse.html +19 -0
- package/dist/docs/interfaces/tools_ai.FilePart.html +14 -0
- package/dist/docs/interfaces/tools_ai.ImagePart.html +11 -0
- package/dist/docs/interfaces/tools_ai.ReasoningPart.html +7 -0
- package/dist/docs/interfaces/tools_ai.RedactedReasoningPart.html +5 -0
- package/dist/docs/interfaces/tools_ai.TextPart.html +5 -0
- package/dist/docs/interfaces/tools_ai.ToolCallPart.html +9 -0
- package/dist/docs/interfaces/tools_ai.ToolExecutionOptions.html +9 -0
- package/dist/docs/interfaces/tools_ai.ToolResultPart.html +9 -0
- package/dist/docs/interfaces/tools_twists.TwistSource.html +13 -0
- package/dist/docs/interfaces/utils_types.ToolShed.html +11 -0
- package/dist/docs/modules/common_calendar.html +1 -0
- package/dist/docs/modules/index.html +1 -0
- package/dist/docs/modules/plot.html +1 -0
- package/dist/docs/modules/tag.html +1 -0
- package/dist/docs/modules/tool.html +1 -0
- package/dist/docs/modules/tools_ai.html +1 -0
- package/dist/docs/modules/tools_callbacks.html +1 -0
- package/dist/docs/modules/tools_integrations.html +1 -0
- package/dist/docs/modules/tools_network.html +1 -0
- package/dist/docs/modules/tools_plot.html +1 -0
- package/dist/docs/modules/tools_store.html +1 -0
- package/dist/docs/modules/tools_tasks.html +1 -0
- package/dist/docs/modules/tools_twists.html +1 -0
- package/dist/docs/modules/twist.html +1 -0
- package/dist/docs/modules/utils_types.html +1 -0
- package/dist/docs/modules.html +1 -0
- package/dist/docs/types/common_calendar.CalendarAuth.html +7 -0
- package/dist/docs/types/plot.Activity.html +64 -0
- package/dist/docs/types/plot.ActivityLink.html +22 -0
- package/dist/docs/types/plot.ActivityMeta.html +11 -0
- package/dist/docs/types/plot.ActivityUpdate.html +13 -0
- package/dist/docs/types/plot.Actor.html +15 -0
- package/dist/docs/types/plot.ActorId.html +4 -0
- package/dist/docs/types/plot.NewActivity.html +16 -0
- package/dist/docs/types/plot.NewContact.html +13 -0
- package/dist/docs/types/plot.NewPriority.html +5 -0
- package/dist/docs/types/plot.NoteType.html +1 -0
- package/dist/docs/types/plot.PickPriorityConfig.html +22 -0
- package/dist/docs/types/plot.Priority.html +8 -0
- package/dist/docs/types/tools_ai.AIAssistantMessage.html +4 -0
- package/dist/docs/types/tools_ai.AIMessage.html +3 -0
- package/dist/docs/types/tools_ai.AISource.html +11 -0
- package/dist/docs/types/tools_ai.AISystemMessage.html +7 -0
- package/dist/docs/types/tools_ai.AITool.html +19 -0
- package/dist/docs/types/tools_ai.AIToolMessage.html +4 -0
- package/dist/docs/types/tools_ai.AIToolSet.html +1 -0
- package/dist/docs/types/tools_ai.AIUsage.html +10 -0
- package/dist/docs/types/tools_ai.AIUserMessage.html +4 -0
- package/dist/docs/types/tools_ai.DataContent.html +2 -0
- package/dist/docs/types/tools_ai.ModelPreferences.html +24 -0
- package/dist/docs/types/tools_callbacks.Callback.html +8 -0
- package/dist/docs/types/tools_integrations.AuthToken.html +16 -0
- package/dist/docs/types/tools_integrations.Authorization.html +10 -0
- package/dist/docs/types/tools_network.WebhookRequest.html +15 -0
- package/dist/docs/types/tools_plot.ActivityIntentHandler.html +9 -0
- package/dist/docs/types/tools_twists.Log.html +6 -0
- package/dist/docs/types/tools_twists.TwistPermissions.html +12 -0
- package/dist/docs/types/utils_types.BuiltInTools.html +5 -0
- package/dist/docs/types/utils_types.CallbackMethods.html +3 -0
- package/dist/docs/types/utils_types.ExtractBuildReturn.html +2 -0
- package/dist/docs/types/utils_types.InferOptions.html +2 -0
- package/dist/docs/types/utils_types.InferTools.html +3 -0
- package/dist/docs/types/utils_types.NoFunctions.html +3 -0
- package/dist/docs/types/utils_types.NonFunction.html +2 -0
- package/dist/docs/types/utils_types.PromiseValues.html +3 -0
- package/dist/docs/types/utils_types.ToolBuilder.html +3 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/llm-docs/common/calendar.d.ts +9 -0
- package/dist/llm-docs/common/calendar.d.ts.map +1 -0
- package/dist/llm-docs/common/calendar.js +8 -0
- package/dist/llm-docs/common/calendar.js.map +1 -0
- package/dist/llm-docs/common/messaging.d.ts +9 -0
- package/dist/llm-docs/common/messaging.d.ts.map +1 -0
- package/dist/llm-docs/common/messaging.js +8 -0
- package/dist/llm-docs/common/messaging.js.map +1 -0
- package/dist/llm-docs/creator-docs.d.ts +9 -0
- package/dist/llm-docs/creator-docs.d.ts.map +1 -0
- package/dist/llm-docs/creator-docs.js +8 -0
- package/dist/llm-docs/creator-docs.js.map +1 -0
- package/dist/llm-docs/index.d.ts +11 -0
- package/dist/llm-docs/index.d.ts.map +1 -0
- package/dist/llm-docs/index.js +42 -0
- package/dist/llm-docs/index.js.map +1 -0
- package/dist/llm-docs/plot.d.ts +9 -0
- package/dist/llm-docs/plot.d.ts.map +1 -0
- package/dist/llm-docs/plot.js +8 -0
- package/dist/llm-docs/plot.js.map +1 -0
- package/dist/llm-docs/tag.d.ts +9 -0
- package/dist/llm-docs/tag.d.ts.map +1 -0
- package/dist/llm-docs/tag.js +8 -0
- package/dist/llm-docs/tag.js.map +1 -0
- package/dist/llm-docs/tool.d.ts +9 -0
- package/dist/llm-docs/tool.d.ts.map +1 -0
- package/dist/llm-docs/tool.js +8 -0
- package/dist/llm-docs/tool.js.map +1 -0
- package/dist/llm-docs/tools/ai.d.ts +9 -0
- package/dist/llm-docs/tools/ai.d.ts.map +1 -0
- package/dist/llm-docs/tools/ai.js +8 -0
- package/dist/llm-docs/tools/ai.js.map +1 -0
- package/dist/llm-docs/tools/callbacks.d.ts +9 -0
- package/dist/llm-docs/tools/callbacks.d.ts.map +1 -0
- package/dist/llm-docs/tools/callbacks.js +8 -0
- package/dist/llm-docs/tools/callbacks.js.map +1 -0
- package/dist/llm-docs/tools/integrations.d.ts +9 -0
- package/dist/llm-docs/tools/integrations.d.ts.map +1 -0
- package/dist/llm-docs/tools/integrations.js +8 -0
- package/dist/llm-docs/tools/integrations.js.map +1 -0
- package/dist/llm-docs/tools/network.d.ts +9 -0
- package/dist/llm-docs/tools/network.d.ts.map +1 -0
- package/dist/llm-docs/tools/network.js +8 -0
- package/dist/llm-docs/tools/network.js.map +1 -0
- package/dist/llm-docs/tools/plot.d.ts +9 -0
- package/dist/llm-docs/tools/plot.d.ts.map +1 -0
- package/dist/llm-docs/tools/plot.js +8 -0
- package/dist/llm-docs/tools/plot.js.map +1 -0
- package/dist/llm-docs/tools/store.d.ts +9 -0
- package/dist/llm-docs/tools/store.d.ts.map +1 -0
- package/dist/llm-docs/tools/store.js +8 -0
- package/dist/llm-docs/tools/store.js.map +1 -0
- package/dist/llm-docs/tools/tasks.d.ts +9 -0
- package/dist/llm-docs/tools/tasks.d.ts.map +1 -0
- package/dist/llm-docs/tools/tasks.js +8 -0
- package/dist/llm-docs/tools/tasks.js.map +1 -0
- package/dist/llm-docs/tools/twists.d.ts +9 -0
- package/dist/llm-docs/tools/twists.d.ts.map +1 -0
- package/dist/llm-docs/tools/twists.js +8 -0
- package/dist/llm-docs/tools/twists.js.map +1 -0
- package/dist/llm-docs/twist-guide-template.d.ts +9 -0
- package/dist/llm-docs/twist-guide-template.d.ts.map +1 -0
- package/dist/llm-docs/twist-guide-template.js +8 -0
- package/dist/llm-docs/twist-guide-template.js.map +1 -0
- package/dist/llm-docs/twist.d.ts +9 -0
- package/dist/llm-docs/twist.d.ts.map +1 -0
- package/dist/llm-docs/twist.js +8 -0
- package/dist/llm-docs/twist.js.map +1 -0
- package/dist/plot.d.ts +463 -0
- package/dist/plot.d.ts.map +1 -0
- package/dist/plot.js +68 -0
- package/dist/plot.js.map +1 -0
- package/dist/tag.d.ts +47 -0
- package/dist/tag.d.ts.map +1 -0
- package/dist/tag.js +51 -0
- package/dist/tag.js.map +1 -0
- package/dist/tool.d.ts +242 -0
- package/dist/tool.d.ts.map +1 -0
- package/dist/tool.js +283 -0
- package/dist/tool.js.map +1 -0
- package/dist/tools/ai.d.ts +697 -0
- package/dist/tools/ai.d.ts.map +1 -0
- package/dist/tools/ai.js +104 -0
- package/dist/tools/ai.js.map +1 -0
- package/dist/tools/callbacks.d.ts +96 -0
- package/dist/tools/callbacks.d.ts.map +1 -0
- package/dist/tools/callbacks.js +40 -0
- package/dist/tools/callbacks.js.map +1 -0
- package/dist/tools/index.d.ts +9 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +9 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/integrations.d.ts +142 -0
- package/dist/tools/integrations.d.ts.map +1 -0
- package/dist/tools/integrations.js +79 -0
- package/dist/tools/integrations.js.map +1 -0
- package/dist/tools/network.d.ts +188 -0
- package/dist/tools/network.d.ts.map +1 -0
- package/dist/tools/network.js +87 -0
- package/dist/tools/network.js.map +1 -0
- package/dist/tools/plot.d.ts +252 -0
- package/dist/tools/plot.d.ts.map +1 -0
- package/dist/tools/plot.js +72 -0
- package/dist/tools/plot.js.map +1 -0
- package/dist/tools/store.d.ts +90 -0
- package/dist/tools/store.d.ts.map +1 -0
- package/dist/tools/store.js +48 -0
- package/dist/tools/store.js.map +1 -0
- package/dist/tools/tasks.d.ts +93 -0
- package/dist/tools/tasks.d.ts.map +1 -0
- package/dist/tools/tasks.js +58 -0
- package/dist/tools/tasks.js.map +1 -0
- package/dist/tools/twists.d.ts +213 -0
- package/dist/tools/twists.d.ts.map +1 -0
- package/dist/tools/twists.js +26 -0
- package/dist/tools/twists.js.map +1 -0
- package/dist/twist-guide.d.ts +2 -0
- package/dist/twist-guide.d.ts.map +1 -0
- package/dist/twist-guide.js +9 -0
- package/dist/twist-guide.js.map +1 -0
- package/dist/twist.d.ts +204 -0
- package/dist/twist.d.ts.map +1 -0
- package/dist/twist.js +216 -0
- package/dist/twist.js.map +1 -0
- package/dist/utils/types.d.ts +91 -0
- package/dist/utils/types.d.ts.map +1 -0
- package/dist/utils/types.js +2 -0
- package/dist/utils/types.js.map +1 -0
- package/package.json +206 -0
- package/tsconfig.base.json +28 -0
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
# {{displayName}} twist
|
|
2
|
+
|
|
3
|
+
A Plot twist that [describe what your twist does].
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Install dependencies
|
|
9
|
+
{{packageManager}} install
|
|
10
|
+
|
|
11
|
+
# Lint your code
|
|
12
|
+
{{packageManager}} lint
|
|
13
|
+
|
|
14
|
+
# Deploy to Plot
|
|
15
|
+
{{packageManager}} deploy
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Development
|
|
19
|
+
|
|
20
|
+
### Project Structure
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
.
|
|
24
|
+
├── src/
|
|
25
|
+
│ └── index.ts # Main twist implementation
|
|
26
|
+
├── package.json # twist metadata and dependencies
|
|
27
|
+
├── tsconfig.json # TypeScript configuration
|
|
28
|
+
└── README.md # This file
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### twist Lifecycle
|
|
32
|
+
|
|
33
|
+
Your twist implements two key lifecycle methods:
|
|
34
|
+
|
|
35
|
+
#### `activate(priority: Pick<Priority, "id">)`
|
|
36
|
+
|
|
37
|
+
Called when the twist is enabled for a priority. This is where you typically:
|
|
38
|
+
- Request authentication from external services
|
|
39
|
+
- Create initial setup activities
|
|
40
|
+
- Initialize twist state
|
|
41
|
+
|
|
42
|
+
#### `activity(activity: Activity)`
|
|
43
|
+
|
|
44
|
+
Called when an activity is routed to this twist. Use this to:
|
|
45
|
+
- Process incoming activities
|
|
46
|
+
- Create new activities based on external events
|
|
47
|
+
- Update existing activities
|
|
48
|
+
|
|
49
|
+
### Using Tools
|
|
50
|
+
|
|
51
|
+
Twists access functionality through tools. Declare tools in the `build` method:
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
build(build: ToolBuilder) {
|
|
55
|
+
return {
|
|
56
|
+
plot: build(Plot),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
// Store, Tasks, and Callbacks methods are available directly via this
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
#### Built-in Tools
|
|
63
|
+
|
|
64
|
+
- **Plot**: Create, update, and delete activities
|
|
65
|
+
- **Store**: Persist data across twist invocations
|
|
66
|
+
- **Integrations**: Request OAuth authentication from external services
|
|
67
|
+
- **Tasks**: Queue background tasks and batch operations
|
|
68
|
+
- **Callbacks**: Create persistent function references for webhooks
|
|
69
|
+
- **Network**: HTTP access permissions and webhook management
|
|
70
|
+
|
|
71
|
+
#### External Tools
|
|
72
|
+
|
|
73
|
+
Add external tool dependencies to `package.json`:
|
|
74
|
+
|
|
75
|
+
```json
|
|
76
|
+
{
|
|
77
|
+
"dependencies": {
|
|
78
|
+
"@plotday/twister": "workspace:^",
|
|
79
|
+
"@plotday/tool-google-calendar": "workspace:^"
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Then use them in your twist:
|
|
85
|
+
|
|
86
|
+
```typescript
|
|
87
|
+
import GoogleCalendarTool from "@plotday/tool-google-calendar";
|
|
88
|
+
|
|
89
|
+
build(build: ToolBuilder) {
|
|
90
|
+
return {
|
|
91
|
+
googleCalendar: build(GoogleCalendarTool),
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Activity Types
|
|
97
|
+
|
|
98
|
+
Plot supports three activity types:
|
|
99
|
+
|
|
100
|
+
- **ActivityType.Note**: Information without actionable requirements
|
|
101
|
+
- **ActivityType.Task**: Actionable items that can be completed
|
|
102
|
+
- **ActivityType.Event**: Scheduled occurrences with start/end times
|
|
103
|
+
|
|
104
|
+
### State Management
|
|
105
|
+
|
|
106
|
+
Use Store methods (available directly on twist and Tool classes) to persist data across twist invocations:
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
// Save state
|
|
110
|
+
await this.set("sync_token", token);
|
|
111
|
+
|
|
112
|
+
// Load state
|
|
113
|
+
const token = await this.get<string>("sync_token");
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
**Important**: twist instances are ephemeral. Always use Store methods for data that needs to persist.
|
|
117
|
+
|
|
118
|
+
### Runtime Limitations
|
|
119
|
+
|
|
120
|
+
**Important**: All twist and tool functions are executed in a sandboxed, ephemeral environment with limited resources:
|
|
121
|
+
|
|
122
|
+
- **Memory is temporary**: Anything stored in memory (e.g. as a variable in the twist/tool object) is lost after the function completes. Use the Store tool instead. Only use memory for temporary caching.
|
|
123
|
+
- **Limited CPU time**: Each execution has limited CPU time (typically 10 seconds) and memory (128MB)
|
|
124
|
+
- **Use the Tasks tool**: Queue separate chunks of work with `this.run(callback)`
|
|
125
|
+
- **Break long operations**: Split large operations into smaller batches that can be processed independently
|
|
126
|
+
- **Store intermediate state**: Use the Store tool to persist state between batches
|
|
127
|
+
- **Examples**: Syncing large datasets, processing many API calls, or performing batch operations
|
|
128
|
+
|
|
129
|
+
#### Pattern for Long-Running Operations
|
|
130
|
+
|
|
131
|
+
```typescript
|
|
132
|
+
async startSync(calendarId: string): Promise<void> {
|
|
133
|
+
// Initialize state in Store (persists between executions)
|
|
134
|
+
await this.set(`sync_state_${calendarId}`, {
|
|
135
|
+
nextPageToken: null,
|
|
136
|
+
batchNumber: 1,
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
// Queue first batch using run method
|
|
140
|
+
const callback = await this.callback("syncBatch", { calendarId });
|
|
141
|
+
await this.run(callback);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
async syncBatch(args: any, context: { calendarId: string }): Promise<void> {
|
|
145
|
+
// Load state from Store
|
|
146
|
+
const state = await this.get(`sync_state_${calendarId}`);
|
|
147
|
+
|
|
148
|
+
// Process one batch
|
|
149
|
+
const result = await processBatch(state.nextPageToken);
|
|
150
|
+
|
|
151
|
+
if (result.hasMore) {
|
|
152
|
+
// Update state and queue next batch
|
|
153
|
+
await this.set(`sync_state_${context.calendarId}`, {
|
|
154
|
+
nextPageToken: result.nextPageToken,
|
|
155
|
+
batchNumber: state.batchNumber + 1,
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
const nextCallback = await this.callback("syncBatch", context);
|
|
159
|
+
await this.run(nextCallback);
|
|
160
|
+
} else {
|
|
161
|
+
// Cleanup when done
|
|
162
|
+
await this.clear(`sync_state_${context.calendarId}`);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## Testing
|
|
168
|
+
|
|
169
|
+
Test your twist locally before deploying:
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
# Run linter
|
|
173
|
+
{{packageManager}} lint
|
|
174
|
+
|
|
175
|
+
# Deploy to your Plot account
|
|
176
|
+
{{packageManager}} deploy
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## Resources
|
|
180
|
+
|
|
181
|
+
- [Plot twist Builder Documentation](https://github.com/plotday/plot)
|
|
182
|
+
- [twist Examples](https://github.com/plotday/plot/tree/main/libs/twist/examples)
|
|
183
|
+
- [Tool Documentation](https://github.com/plotday/plot/tree/main/libs/twist/tools)
|
|
184
|
+
|
|
185
|
+
## Support
|
|
186
|
+
|
|
187
|
+
For help or questions:
|
|
188
|
+
- Open an issue on GitHub
|
|
189
|
+
- Contact support@plot.day
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.bundleTwist = bundleTwist;
|
|
37
|
+
const esbuild = __importStar(require("esbuild"));
|
|
38
|
+
const fs = __importStar(require("fs"));
|
|
39
|
+
const path = __importStar(require("path"));
|
|
40
|
+
/**
|
|
41
|
+
* Bundles a Plot twist using esbuild.
|
|
42
|
+
*
|
|
43
|
+
* This function is shared between the build and deploy commands to ensure
|
|
44
|
+
* consistent bundling behavior.
|
|
45
|
+
*
|
|
46
|
+
* @param twistPath - Absolute path to the twist directory
|
|
47
|
+
* @param options - Optional bundling configuration
|
|
48
|
+
* @returns Promise resolving to the bundled code and any warnings
|
|
49
|
+
* @throws Error if bundling fails
|
|
50
|
+
*/
|
|
51
|
+
async function bundleTwist(twistPath, options = {}) {
|
|
52
|
+
const { minify = false, sourcemap = true } = options;
|
|
53
|
+
// Validate twist path exists
|
|
54
|
+
if (!fs.existsSync(twistPath)) {
|
|
55
|
+
throw new Error(`Twist directory not found: ${twistPath}`);
|
|
56
|
+
}
|
|
57
|
+
// Check for entry point
|
|
58
|
+
const entryPoint = path.join(twistPath, "src", "index.ts");
|
|
59
|
+
if (!fs.existsSync(entryPoint)) {
|
|
60
|
+
throw new Error("src/index.ts not found. Your twist needs an entry point at src/index.ts");
|
|
61
|
+
}
|
|
62
|
+
// Create build directory
|
|
63
|
+
const buildDir = path.join(twistPath, "build");
|
|
64
|
+
if (fs.existsSync(buildDir)) {
|
|
65
|
+
fs.rmSync(buildDir, { recursive: true });
|
|
66
|
+
}
|
|
67
|
+
fs.mkdirSync(buildDir, { recursive: true });
|
|
68
|
+
// Bundle with esbuild
|
|
69
|
+
const result = await esbuild.build({
|
|
70
|
+
entryPoints: [entryPoint],
|
|
71
|
+
bundle: true,
|
|
72
|
+
format: "esm",
|
|
73
|
+
platform: "browser",
|
|
74
|
+
target: "esnext",
|
|
75
|
+
outfile: path.join(buildDir, "index.js"),
|
|
76
|
+
sourcemap,
|
|
77
|
+
minify,
|
|
78
|
+
logLevel: "silent",
|
|
79
|
+
});
|
|
80
|
+
// Check for errors
|
|
81
|
+
if (result.errors.length > 0) {
|
|
82
|
+
const errorMessages = result.errors
|
|
83
|
+
.map((err) => `${err.location?.file}:${err.location?.line} - ${err.text}`)
|
|
84
|
+
.join("\n");
|
|
85
|
+
throw new Error(`Build failed with errors:\n${errorMessages}`);
|
|
86
|
+
}
|
|
87
|
+
// Collect warnings
|
|
88
|
+
const warnings = result.warnings.map((warn) => `${warn.location?.file}:${warn.location?.line} - ${warn.text}`);
|
|
89
|
+
// Read the bundled code
|
|
90
|
+
const bundlePath = path.join(buildDir, "index.js");
|
|
91
|
+
const code = fs.readFileSync(bundlePath, "utf-8");
|
|
92
|
+
// Read the sourcemap if it exists
|
|
93
|
+
let sourcemapContent;
|
|
94
|
+
if (sourcemap) {
|
|
95
|
+
const sourcemapPath = path.join(buildDir, "index.js.map");
|
|
96
|
+
if (fs.existsSync(sourcemapPath)) {
|
|
97
|
+
sourcemapContent = fs.readFileSync(sourcemapPath, "utf-8");
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return {
|
|
101
|
+
code,
|
|
102
|
+
sourcemap: sourcemapContent,
|
|
103
|
+
warnings,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=bundle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundle.js","sourceRoot":"","sources":["../../cli/utils/bundle.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,kCAuEC;AAjGD,iDAAmC;AACnC,uCAAyB;AACzB,2CAA6B;AAa7B;;;;;;;;;;GAUG;AACI,KAAK,UAAU,WAAW,CAC/B,SAAiB,EACjB,UAAyB,EAAE;IAE3B,MAAM,EAAE,MAAM,GAAG,KAAK,EAAE,SAAS,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;IAErD,6BAA6B;IAC7B,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CAAC,8BAA8B,SAAS,EAAE,CAAC,CAAC;IAC7D,CAAC;IAED,wBAAwB;IACxB,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAA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IACjE,CAAC;IAED,mBAAmB;IACnB,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,CAClC,CAAC,IAAI,EAAE,EAAE,CACP,GAAG,IAAI,CAAC,QAAQ,EAAE,IAAI,IAAI,IAAI,CAAC,QAAQ,EAAE,IAAI,MAAM,IAAI,CAAC,IAAI,EAAE,CACjE,CAAC;IAEF,wBAAwB;IACxB,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IACnD,MAAM,IAAI,GAAG,EAAE,CAAC,YAAY,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAElD,kCAAkC;IAClC,IAAI,gBAAoC,CAAC;IACzC,IAAI,SAAS,EAAE,CAAC;QACd,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;QAC1D,IAAI,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE,CAAC;YACjC,gBAAgB,GAAG,EAAE,CAAC,YAAY,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;QAC7D,CAAC;IACH,CAAC;IAED,OAAO;QACL,IAAI;QACJ,SAAS,EAAE,gBAAgB;QAC3B,QAAQ;KACT,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.colors = void 0;
|
|
7
|
+
exports.success = success;
|
|
8
|
+
exports.error = error;
|
|
9
|
+
exports.info = info;
|
|
10
|
+
exports.warning = warning;
|
|
11
|
+
exports.section = section;
|
|
12
|
+
exports.progress = progress;
|
|
13
|
+
exports.listItem = listItem;
|
|
14
|
+
exports.keyValue = keyValue;
|
|
15
|
+
exports.nextSteps = nextSteps;
|
|
16
|
+
exports.header = header;
|
|
17
|
+
exports.plain = plain;
|
|
18
|
+
exports.blank = blank;
|
|
19
|
+
exports.cliHeader = cliHeader;
|
|
20
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
21
|
+
// Plot brand colors
|
|
22
|
+
exports.colors = {
|
|
23
|
+
// Brand green from logo
|
|
24
|
+
brand: (text) => chalk_1.default.hex("#2B9F7A")(text),
|
|
25
|
+
// Semantic colors
|
|
26
|
+
success: (text) => chalk_1.default.hex("#2B9F7A")(text),
|
|
27
|
+
error: (text) => chalk_1.default.red(text),
|
|
28
|
+
warning: (text) => chalk_1.default.yellow(text),
|
|
29
|
+
info: (text) => chalk_1.default.cyan(text),
|
|
30
|
+
// Style helpers
|
|
31
|
+
dim: (text) => chalk_1.default.dim(text),
|
|
32
|
+
bold: (text) => chalk_1.default.bold(text),
|
|
33
|
+
underline: (text) => chalk_1.default.underline(text),
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Print a success message with checkmark
|
|
37
|
+
*/
|
|
38
|
+
function success(message, details) {
|
|
39
|
+
console.log(exports.colors.success("✓") + " " + message);
|
|
40
|
+
if (details) {
|
|
41
|
+
details.forEach((detail) => console.log(" " + exports.colors.dim(detail)));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Print an error message with X mark
|
|
46
|
+
*/
|
|
47
|
+
function error(message, details) {
|
|
48
|
+
console.log(exports.colors.error("✗") + " " + message);
|
|
49
|
+
if (details) {
|
|
50
|
+
console.log(" " + exports.colors.dim(details));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Print an info message
|
|
55
|
+
*/
|
|
56
|
+
function info(message, details) {
|
|
57
|
+
console.log(exports.colors.info("ℹ") + " " + message);
|
|
58
|
+
if (details) {
|
|
59
|
+
details.forEach((detail) => console.log(" " + exports.colors.dim(detail)));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Print a warning message
|
|
64
|
+
*/
|
|
65
|
+
function warning(message, details) {
|
|
66
|
+
console.log(exports.colors.warning("⚠") + " " + message);
|
|
67
|
+
if (details) {
|
|
68
|
+
details.forEach((detail) => console.log(" " + exports.colors.dim(detail)));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Print a section header
|
|
73
|
+
*/
|
|
74
|
+
function section(title) {
|
|
75
|
+
console.log("\n" + exports.colors.bold(title));
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Print a progress message
|
|
79
|
+
*/
|
|
80
|
+
function progress(message) {
|
|
81
|
+
console.log(exports.colors.brand("●") + " " + message);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Print a list item
|
|
85
|
+
*/
|
|
86
|
+
function listItem(item) {
|
|
87
|
+
console.log(" " + exports.colors.dim("•") + " " + item);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Print a key-value pair
|
|
91
|
+
*/
|
|
92
|
+
function keyValue(key, value) {
|
|
93
|
+
console.log(" " + exports.colors.dim(key + ":") + " " + value);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Print next steps section
|
|
97
|
+
*/
|
|
98
|
+
function nextSteps(steps) {
|
|
99
|
+
section("Next steps");
|
|
100
|
+
steps.forEach((step) => {
|
|
101
|
+
console.log(" " + exports.colors.brand("›") + " " + step);
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Print a subtle branded header
|
|
106
|
+
*/
|
|
107
|
+
function header(text) {
|
|
108
|
+
console.log("\n" + exports.colors.brand("━".repeat(50)));
|
|
109
|
+
console.log(exports.colors.bold(" " + text));
|
|
110
|
+
console.log(exports.colors.brand("━".repeat(50)) + "\n");
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Print a simple message without formatting
|
|
114
|
+
*/
|
|
115
|
+
function plain(message) {
|
|
116
|
+
console.log(message);
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Print a blank line
|
|
120
|
+
*/
|
|
121
|
+
function blank() {
|
|
122
|
+
console.log();
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Print the CLI header with version
|
|
126
|
+
*/
|
|
127
|
+
function cliHeader(version) {
|
|
128
|
+
const title = "🌪️ Plot";
|
|
129
|
+
const subtitle = `Twister v${version}`;
|
|
130
|
+
const underline = exports.colors.brand("─".repeat(title.length + subtitle.length + 1));
|
|
131
|
+
console.log(`\n${title} ${exports.colors.dim(subtitle)}\n${underline}`);
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=output.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output.js","sourceRoot":"","sources":["../../cli/utils/output.ts"],"names":[],"mappings":";;;;;;AAoBA,0BAKC;AAKD,sBAKC;AAKD,oBAKC;AAKD,0BAKC;AAKD,0BAEC;AAKD,4BAEC;AAKD,4BAEC;AAKD,4BAEC;AAKD,8BAKC;AAKD,wBAIC;AAKD,sBAEC;AAKD,sBAEC;AAKD,8BAOC;AAhID,kDAA0B;AAE1B,oBAAoB;AACP,QAAA,MAAM,GAAG;IACpB,wBAAwB;IACxB,KAAK,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,eAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC;IACnD,kBAAkB;IAClB,OAAO,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,eAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC;IACrD,KAAK,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,eAAK,CAAC,GAAG,CAAC,IAAI,CAAC;IACxC,OAAO,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,eAAK,CAAC,MAAM,CAAC,IAAI,CAAC;IAC7C,IAAI,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,eAAK,CAAC,IAAI,CAAC,IA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2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.detectPackageManager = detectPackageManager;
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
/**
|
|
40
|
+
* Detects the package manager being used
|
|
41
|
+
* Checks for npm_config_user_twist and lock files
|
|
42
|
+
*/
|
|
43
|
+
function detectPackageManager() {
|
|
44
|
+
// Check npm_config_user_twist first (set by npm, yarn, pnpm)
|
|
45
|
+
const userTwist = process.env.npm_config_user_twist;
|
|
46
|
+
if (userTwist) {
|
|
47
|
+
if (userTwist.includes("yarn"))
|
|
48
|
+
return "yarn";
|
|
49
|
+
if (userTwist.includes("pnpm"))
|
|
50
|
+
return "pnpm";
|
|
51
|
+
if (userTwist.includes("npm"))
|
|
52
|
+
return "npm";
|
|
53
|
+
}
|
|
54
|
+
// Check for lock files in current directory
|
|
55
|
+
const cwd = process.cwd();
|
|
56
|
+
if (fs.existsSync(path.join(cwd, "pnpm-lock.yaml")))
|
|
57
|
+
return "pnpm";
|
|
58
|
+
if (fs.existsSync(path.join(cwd, "yarn.lock")))
|
|
59
|
+
return "yarn";
|
|
60
|
+
if (fs.existsSync(path.join(cwd, "package-lock.json")))
|
|
61
|
+
return "npm";
|
|
62
|
+
// Default to npm
|
|
63
|
+
return "npm";
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=packageManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"packageManager.js","sourceRoot":"","sources":["../../cli/utils/packageManager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,oDAiBC;AAxBD,uCAAyB;AACzB,2CAA6B;AAE7B;;;GAGG;AACH,SAAgB,oBAAoB;IAClC,6DAA6D;IAC7D,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC;IACpD,IAAI,SAAS,EAAE,CAAC;QACd,IAAI,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC;YAAE,OAAO,MAAM,CAAC;QAC9C,IAAI,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC;YAAE,OAAO,MAAM,CAAC;QAC9C,IAAI,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC;YAAE,OAAO,KAAK,CAAC;IAC9C,CAAC;IAED,4CAA4C;IAC5C,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAC1B,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;QAAE,OAAO,MAAM,CAAC;IACnE,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;QAAE,OAAO,MAAM,CAAC;IAC9D,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,mBAAmB,CAAC,CAAC;QAAE,OAAO,KAAK,CAAC;IAErE,iBAAiB;IACjB,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/bin/utils/sse.js
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Server-Sent Events (SSE) client utilities
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.handleSSEStream = handleSSEStream;
|
|
7
|
+
/**
|
|
8
|
+
* Parse and handle SSE response stream
|
|
9
|
+
*/
|
|
10
|
+
async function handleSSEStream(response, handlers) {
|
|
11
|
+
if (!response.body) {
|
|
12
|
+
throw new Error("Response has no body");
|
|
13
|
+
}
|
|
14
|
+
const reader = response.body.getReader();
|
|
15
|
+
const decoder = new TextDecoder();
|
|
16
|
+
let buffer = "";
|
|
17
|
+
let result = null;
|
|
18
|
+
try {
|
|
19
|
+
while (true) {
|
|
20
|
+
const { done, value } = await reader.read();
|
|
21
|
+
if (done) {
|
|
22
|
+
break;
|
|
23
|
+
}
|
|
24
|
+
// Decode chunk and add to buffer
|
|
25
|
+
buffer += decoder.decode(value, { stream: true });
|
|
26
|
+
// Process complete messages in buffer
|
|
27
|
+
const lines = buffer.split("\n");
|
|
28
|
+
// Keep incomplete message in buffer
|
|
29
|
+
buffer = lines.pop() || "";
|
|
30
|
+
let currentEvent = {};
|
|
31
|
+
for (const line of lines) {
|
|
32
|
+
// Empty line marks end of event
|
|
33
|
+
if (line.trim() === "") {
|
|
34
|
+
if (currentEvent.event && currentEvent.data !== undefined) {
|
|
35
|
+
// Parse data if it's JSON
|
|
36
|
+
let parsedData = currentEvent.data;
|
|
37
|
+
try {
|
|
38
|
+
parsedData = JSON.parse(currentEvent.data);
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
// Not JSON, use as-is
|
|
42
|
+
}
|
|
43
|
+
// Handle event based on type
|
|
44
|
+
switch (currentEvent.event) {
|
|
45
|
+
case "progress":
|
|
46
|
+
handlers.onProgress?.(parsedData.message);
|
|
47
|
+
break;
|
|
48
|
+
case "result":
|
|
49
|
+
result = parsedData;
|
|
50
|
+
handlers.onResult?.(parsedData);
|
|
51
|
+
break;
|
|
52
|
+
case "error":
|
|
53
|
+
handlers.onError?.(parsedData.error);
|
|
54
|
+
throw new Error(parsedData.error);
|
|
55
|
+
default:
|
|
56
|
+
// Handle custom events via onEvent handler
|
|
57
|
+
if (handlers.onEvent) {
|
|
58
|
+
handlers.onEvent(currentEvent.event, parsedData);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
// Reset for next event
|
|
63
|
+
currentEvent = {};
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
// Skip comment lines (lines starting with ":")
|
|
67
|
+
if (line.startsWith(":")) {
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
// Parse SSE field
|
|
71
|
+
const colonIndex = line.indexOf(":");
|
|
72
|
+
if (colonIndex === -1) {
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
const field = line.slice(0, colonIndex);
|
|
76
|
+
let value = line.slice(colonIndex + 1);
|
|
77
|
+
// Trim leading space from value (SSE spec)
|
|
78
|
+
if (value.startsWith(" ")) {
|
|
79
|
+
value = value.slice(1);
|
|
80
|
+
}
|
|
81
|
+
switch (field) {
|
|
82
|
+
case "event":
|
|
83
|
+
currentEvent.event = value;
|
|
84
|
+
break;
|
|
85
|
+
case "data":
|
|
86
|
+
currentEvent.data = value;
|
|
87
|
+
break;
|
|
88
|
+
case "id":
|
|
89
|
+
currentEvent.id = value;
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return result;
|
|
95
|
+
}
|
|
96
|
+
finally {
|
|
97
|
+
reader.releaseLock();
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=sse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sse.js","sourceRoot":"","sources":["../../cli/utils/sse.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAkBH,0CA0GC;AA7GD;;GAEG;AACI,KAAK,UAAU,eAAe,CACnC,QAAkB,EAClB,QAAqB;IAErB,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;IAC1C,CAAC;IAED,MAAM,MAAM,GAAG,QAAQ,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;IACzC,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;IAClC,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,IAAI,MAAM,GAAQ,IAAI,CAAC;IAEvB,IAAI,CAAC;QACH,OAAO,IAAI,EAAE,CAAC;YACZ,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;YAE5C,IAAI,IAAI,EAAE,CAAC;gBACT,MAAM;YACR,CAAC;YAED,iCAAiC;YACjC,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;YAElD,sCAAsC;YACtC,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAEjC,o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