@trigora/sdk 0.8.0 → 0.9.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/README.md +16 -1
- package/dist/defineFlow.d.ts +7 -1
- package/dist/index.d.ts +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -123,23 +123,28 @@ export default defineFlow({
|
|
|
123
123
|
|
|
124
124
|
Use queue triggers to consume workspace-scoped queue messages. Deploy auto-provisions and binds the named queue to the flow.
|
|
125
125
|
|
|
126
|
+
Optional `retry` configures how many times a failed message may be redelivered. Omitted `retry` means a single attempt. `attempts > 1` is supported for queue flows only.
|
|
127
|
+
|
|
126
128
|
```ts
|
|
127
129
|
import { defineFlow } from '@trigora/sdk';
|
|
128
130
|
|
|
129
131
|
export default defineFlow({
|
|
130
132
|
id: 'process-image',
|
|
131
133
|
trigger: { type: 'queue', queue: 'image-processing' },
|
|
134
|
+
retry: { attempts: 5, backoff: 'exponential' },
|
|
132
135
|
async run(event, ctx) {
|
|
133
136
|
await ctx.log.info('Processing message', {
|
|
134
137
|
queue: event.queue,
|
|
135
138
|
messageId: event.messageId,
|
|
139
|
+
attempt: event.attempt,
|
|
140
|
+
maxAttempts: event.maxAttempts,
|
|
136
141
|
payload: event.payload,
|
|
137
142
|
});
|
|
138
143
|
},
|
|
139
144
|
});
|
|
140
145
|
```
|
|
141
146
|
|
|
142
|
-
Locally, `trigora trigger` and `trigora dev` invoke queue flows with a synthetic `QueueFlowEvent` (`messageId` starts with `local_`). Hosted runs use the real message id.
|
|
147
|
+
Locally, `trigora trigger` and `trigora dev` invoke queue flows with a synthetic `QueueFlowEvent` (`messageId` starts with `local_`, `attempt` is `1`, and `maxAttempts` comes from `retry.attempts` or `1`). Local runs do not actually retry. Hosted runs use the real message id and attempt count.
|
|
143
148
|
|
|
144
149
|
## Return Types
|
|
145
150
|
|
|
@@ -204,6 +209,15 @@ type FlowEvent<TPayload = JsonValue> = {
|
|
|
204
209
|
};
|
|
205
210
|
```
|
|
206
211
|
|
|
212
|
+
Queue events also include:
|
|
213
|
+
|
|
214
|
+
```ts
|
|
215
|
+
queue: string;
|
|
216
|
+
messageId: string;
|
|
217
|
+
attempt: number; // 1-based delivery count
|
|
218
|
+
maxAttempts: number; // from retry.attempts, or 1 when omitted
|
|
219
|
+
```
|
|
220
|
+
|
|
207
221
|
In local manual runs, the payload comes from your JSON payload file when one is provided. In local webhook dev and deployed webhook flows, the payload is the parsed JSON request body.
|
|
208
222
|
|
|
209
223
|
If you do not provide your own payload type, `event.payload` defaults to `JsonValue`.
|
|
@@ -283,6 +297,7 @@ The exact exported type is `FlowContext<TEnv>`.
|
|
|
283
297
|
- `FlowEvent`
|
|
284
298
|
- `FlowRunFn`
|
|
285
299
|
- `JsonValue`
|
|
300
|
+
- `RetryPolicy`
|
|
286
301
|
- `Trigger`
|
|
287
302
|
- `WebhookFlowResult`
|
|
288
303
|
|
package/dist/defineFlow.d.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import type { CronEventPayload, CronFlowDefinition, FlowDefinition, FlowRunFn, JsonValue, ManualFlowDefinition, ManualTrigger, QueueFlowDefinition, QueueTrigger, Trigger, WebhookTrigger, WebhookFlowDefinition, CronTrigger } from '@trigora/contracts';
|
|
1
|
+
import type { CronEventPayload, CronFlowDefinition, FlowDefinition, FlowRunFn, JsonValue, ManualFlowDefinition, ManualTrigger, QueueFlowDefinition, QueueTrigger, RetryPolicy, Trigger, WebhookTrigger, WebhookFlowDefinition, CronTrigger } from '@trigora/contracts';
|
|
2
2
|
type DefineFlowInput<TPayload, TEnv extends Record<string, string>, TTrigger extends Trigger> = {
|
|
3
3
|
id: string;
|
|
4
4
|
trigger: TTrigger;
|
|
5
|
+
/**
|
|
6
|
+
* Optional retry policy. Omitted means a single attempt.
|
|
7
|
+
* `attempts > 1` is supported for queue flows only (enforced at deploy time).
|
|
8
|
+
*/
|
|
9
|
+
retry?: RetryPolicy;
|
|
5
10
|
run: TTrigger extends ManualTrigger ? FlowRunFn<TPayload, TEnv, ManualTrigger> : TTrigger extends WebhookTrigger ? FlowRunFn<TPayload, TEnv, WebhookTrigger> : TTrigger extends CronTrigger ? FlowRunFn<CronEventPayload, TEnv, CronTrigger> : TTrigger extends QueueTrigger ? FlowRunFn<TPayload, TEnv, QueueTrigger> : never;
|
|
6
11
|
};
|
|
7
12
|
type DefineFlowOutput<TPayload, TEnv extends Record<string, string>, TTrigger extends Trigger> = TTrigger extends ManualTrigger ? ManualFlowDefinition<TPayload, TEnv> : TTrigger extends WebhookTrigger ? WebhookFlowDefinition<TPayload, TEnv> : TTrigger extends CronTrigger ? CronFlowDefinition<TEnv> : TTrigger extends QueueTrigger ? QueueFlowDefinition<TPayload, TEnv> : FlowDefinition<TPayload, TEnv, TTrigger>;
|
|
@@ -12,6 +17,7 @@ type DefineFlowOutput<TPayload, TEnv extends Record<string, string>, TTrigger ex
|
|
|
12
17
|
* - `id`: the internal identifier for the flow in your project
|
|
13
18
|
* - `trigger`: how the flow is invoked
|
|
14
19
|
* - `run`: the function that executes when the flow is triggered
|
|
20
|
+
* - `retry`: optional retry policy (queue flows may use `attempts > 1`)
|
|
15
21
|
*
|
|
16
22
|
* `run` receives the incoming `event` and a `ctx` object with logging and environment access.
|
|
17
23
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { defineFlow } from './defineFlow';
|
|
2
|
-
export type { CronEventPayload, CronFlowEvent, FlowContext, FlowDefinition, FlowEvent, FlowRunFn, JsonValue, ManualFlowEvent, QueueFlowEvent, Trigger, WebhookFlowEvent, WebhookFlowResult, } from '@trigora/contracts';
|
|
2
|
+
export type { CronEventPayload, CronFlowEvent, FlowContext, FlowDefinition, FlowEvent, FlowRunFn, JsonValue, ManualFlowEvent, QueueFlowEvent, RetryBackoff, RetryPolicy, Trigger, WebhookFlowEvent, WebhookFlowResult, } from '@trigora/contracts';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trigora/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/trigora-dev/trigora"
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"access": "public"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@trigora/contracts": "0.
|
|
49
|
+
"@trigora/contracts": "^0.9.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"tsup": "^8.5.1"
|