@trigora/sdk 0.5.0 → 0.6.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 CHANGED
@@ -86,18 +86,21 @@ Use webhook triggers for hosted HTTP entrypoints.
86
86
  import { defineFlow } from '@trigora/sdk';
87
87
 
88
88
  export default defineFlow({
89
- id: 'ping',
90
- trigger: { type: 'webhook' },
89
+ id: 'stripe-webhook',
90
+ trigger: { type: 'webhook', route: '/hooks/stripe' },
91
91
  async run() {
92
92
  return 'pong';
93
93
  },
94
94
  });
95
95
  ```
96
96
 
97
+ `id` is the internal flow identifier used by the CLI. `route` is the optional public hosted webhook path.
98
+ When `route` is omitted, hosted ingress defaults to `/${id}`.
99
+
97
100
  You can also include an optional event name:
98
101
 
99
102
  ```ts
100
- trigger: { type: 'webhook', event: 'orders.created' }
103
+ trigger: { type: 'webhook', event: 'orders.created', route: '/hooks/orders' }
101
104
  ```
102
105
 
103
106
  ### Cron
@@ -139,7 +142,7 @@ import { defineFlow } from '@trigora/sdk';
139
142
 
140
143
  export default defineFlow({
141
144
  id: 'status',
142
- trigger: { type: 'webhook' },
145
+ trigger: { type: 'webhook', route: '/status' },
143
146
  async run() {
144
147
  return {
145
148
  ok: true,
@@ -189,10 +192,19 @@ For webhook flows, request metadata may also be available on `event.request`, in
189
192
  Trigora includes a small helper for verifying Stripe webhook signatures:
190
193
 
191
194
  ```ts
195
+ import { defineFlow } from '@trigora/sdk';
192
196
  import { verifyStripeWebhook } from '@trigora/sdk/stripe';
193
197
 
194
- const stripeEvent = await verifyStripeWebhook(event, {
195
- secret: ctx.env.STRIPE_WEBHOOK_SECRET,
198
+ export default defineFlow({
199
+ id: 'stripe-webhook',
200
+ trigger: { type: 'webhook', route: '/hooks/stripe' },
201
+ async run(event, ctx) {
202
+ await verifyStripeWebhook(event, {
203
+ secret: ctx.env.STRIPE_WEBHOOK_SECRET,
204
+ });
205
+
206
+ return { ok: true };
207
+ },
196
208
  });
197
209
  ```
198
210
 
@@ -205,10 +217,19 @@ Production Stripe webhooks should verify signatures before trusting payloads.
205
217
  Trigora includes a small helper for verifying GitHub webhook signatures:
206
218
 
207
219
  ```ts
220
+ import { defineFlow } from '@trigora/sdk';
208
221
  import { verifyGitHubWebhook } from '@trigora/sdk/github';
209
222
 
210
- const githubEvent = await verifyGitHubWebhook(event, {
211
- secret: ctx.env.GITHUB_WEBHOOK_SECRET,
223
+ export default defineFlow({
224
+ id: 'github-webhook',
225
+ trigger: { type: 'webhook', route: '/hooks/github' },
226
+ async run(event, ctx) {
227
+ await verifyGitHubWebhook(event, {
228
+ secret: ctx.env.GITHUB_WEBHOOK_SECRET,
229
+ });
230
+
231
+ return { ok: true };
232
+ },
212
233
  });
213
234
  ```
214
235
 
@@ -9,12 +9,16 @@ type DefineFlowOutput<TPayload, TEnv extends Record<string, string>, TTrigger ex
9
9
  * Define a Trigora flow.
10
10
  *
11
11
  * Flows are plain TypeScript modules with three core parts:
12
- * - `id`: the source identifier for the flow in your project
12
+ * - `id`: the internal identifier for the flow in your project
13
13
  * - `trigger`: how the flow is invoked
14
14
  * - `run`: the function that executes when the flow is triggered
15
15
  *
16
16
  * `run` receives the incoming `event` and a `ctx` object with logging and environment access.
17
17
  *
18
+ * For webhook flows, `trigger.route` controls the public hosted path and defaults to `/${id}`.
19
+ * This is separate from the flow `id`, which is still what the CLI uses for commands like
20
+ * `trigora deploy hello` or `trigora flows inspect hello`.
21
+ *
18
22
  * Webhook flows can return HTTP-friendly values:
19
23
  * - `Response`
20
24
  * - plain objects / arrays / numbers / booleans
@@ -26,8 +30,8 @@ type DefineFlowOutput<TPayload, TEnv extends Record<string, string>, TTrigger ex
26
30
  * @example
27
31
  * ```ts
28
32
  * export default defineFlow({
29
- * id: 'hello',
30
- * trigger: { type: 'webhook' },
33
+ * id: 'stripe-webhook',
34
+ * trigger: { type: 'webhook', route: '/hooks/stripe' },
31
35
  * async run(event, ctx) {
32
36
  * await ctx.log.info('Received event', event.payload);
33
37
  * return { ok: true };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trigora/sdk",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/trigora-dev/trigora"
@@ -45,7 +45,7 @@
45
45
  "access": "public"
46
46
  },
47
47
  "dependencies": {
48
- "@trigora/contracts": "0.5.5"
48
+ "@trigora/contracts": "0.6.5"
49
49
  },
50
50
  "devDependencies": {
51
51
  "tsup": "^8.5.1"