@slates/test 1.0.0-rc.10 → 1.0.0-rc.11

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/dist/index.cjs CHANGED
@@ -242,7 +242,8 @@ var handleSlateTriggerWebhook = async (d) => d.client.handleTriggerWebhook({
242
242
  method: d.method ?? "POST",
243
243
  headers: d.headers,
244
244
  body: d.body,
245
- state: d.state
245
+ state: d.state,
246
+ registrationDetails: d.registrationDetails
246
247
  });
247
248
  var unregisterSlateTriggerWebhook = async (d) => d.client.unregisterTriggerWebhook({
248
249
  actionId: d.triggerId,
package/dist/index.d.cts CHANGED
@@ -149,6 +149,26 @@ declare let getSlateContract: (client: SlatesTestClient) => Promise<{
149
149
  type: "webhook";
150
150
  autoRegistration: boolean;
151
151
  autoUnregistration: boolean;
152
+ http?: {
153
+ methods?: ("GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS")[] | undefined;
154
+ sync?: {
155
+ mode: "match" | "never" | "always";
156
+ match?: {
157
+ method?: string | undefined;
158
+ hasQueryParam?: string | undefined;
159
+ hasHeader?: string | undefined;
160
+ jsonBodyField?: {
161
+ path: string;
162
+ equals?: string | undefined;
163
+ } | undefined;
164
+ formBodyField?: {
165
+ path: string;
166
+ equals?: string | undefined;
167
+ } | undefined;
168
+ }[] | undefined;
169
+ timeoutMs?: number | undefined;
170
+ } | undefined;
171
+ } | undefined;
152
172
  };
153
173
  description?: string | undefined;
154
174
  instructions?: string[] | undefined;
@@ -211,6 +231,26 @@ declare let getSlateContract: (client: SlatesTestClient) => Promise<{
211
231
  type: "webhook";
212
232
  autoRegistration: boolean;
213
233
  autoUnregistration: boolean;
234
+ http?: {
235
+ methods?: ("GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS")[] | undefined;
236
+ sync?: {
237
+ mode: "match" | "never" | "always";
238
+ match?: {
239
+ method?: string | undefined;
240
+ hasQueryParam?: string | undefined;
241
+ hasHeader?: string | undefined;
242
+ jsonBodyField?: {
243
+ path: string;
244
+ equals?: string | undefined;
245
+ } | undefined;
246
+ formBodyField?: {
247
+ path: string;
248
+ equals?: string | undefined;
249
+ } | undefined;
250
+ }[] | undefined;
251
+ timeoutMs?: number | undefined;
252
+ } | undefined;
253
+ } | undefined;
214
254
  };
215
255
  description?: string | undefined;
216
256
  instructions?: string[] | undefined;
@@ -326,6 +366,26 @@ declare let expectSlateContract: (d: {
326
366
  type: "webhook";
327
367
  autoRegistration: boolean;
328
368
  autoUnregistration: boolean;
369
+ http?: {
370
+ methods?: ("GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS")[] | undefined;
371
+ sync?: {
372
+ mode: "match" | "never" | "always";
373
+ match?: {
374
+ method?: string | undefined;
375
+ hasQueryParam?: string | undefined;
376
+ hasHeader?: string | undefined;
377
+ jsonBodyField?: {
378
+ path: string;
379
+ equals?: string | undefined;
380
+ } | undefined;
381
+ formBodyField?: {
382
+ path: string;
383
+ equals?: string | undefined;
384
+ } | undefined;
385
+ }[] | undefined;
386
+ timeoutMs?: number | undefined;
387
+ } | undefined;
388
+ } | undefined;
329
389
  };
330
390
  description?: string | undefined;
331
391
  instructions?: string[] | undefined;
@@ -388,6 +448,26 @@ declare let expectSlateContract: (d: {
388
448
  type: "webhook";
389
449
  autoRegistration: boolean;
390
450
  autoUnregistration: boolean;
451
+ http?: {
452
+ methods?: ("GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS")[] | undefined;
453
+ sync?: {
454
+ mode: "match" | "never" | "always";
455
+ match?: {
456
+ method?: string | undefined;
457
+ hasQueryParam?: string | undefined;
458
+ hasHeader?: string | undefined;
459
+ jsonBodyField?: {
460
+ path: string;
461
+ equals?: string | undefined;
462
+ } | undefined;
463
+ formBodyField?: {
464
+ path: string;
465
+ equals?: string | undefined;
466
+ } | undefined;
467
+ }[] | undefined;
468
+ timeoutMs?: number | undefined;
469
+ } | undefined;
470
+ } | undefined;
391
471
  };
392
472
  description?: string | undefined;
393
473
  instructions?: string[] | undefined;
@@ -518,9 +598,18 @@ declare let handleSlateTriggerWebhook: (d: {
518
598
  headers?: Record<string, string>;
519
599
  body?: string | Uint8Array | null;
520
600
  state?: any;
601
+ registrationDetails?: any;
521
602
  }) => Promise<{
522
603
  inputs: Record<string, any>[];
523
604
  updatedState?: any;
605
+ response?: {
606
+ status: number;
607
+ headers: Record<string, string>;
608
+ body: {
609
+ encoding: "base64";
610
+ content: string;
611
+ } | null;
612
+ } | null | undefined;
524
613
  requestTraces?: {
525
614
  startedAt: string;
526
615
  durationMs: number;
package/dist/index.d.ts CHANGED
@@ -149,6 +149,26 @@ declare let getSlateContract: (client: SlatesTestClient) => Promise<{
149
149
  type: "webhook";
150
150
  autoRegistration: boolean;
151
151
  autoUnregistration: boolean;
152
+ http?: {
153
+ methods?: ("GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS")[] | undefined;
154
+ sync?: {
155
+ mode: "match" | "never" | "always";
156
+ match?: {
157
+ method?: string | undefined;
158
+ hasQueryParam?: string | undefined;
159
+ hasHeader?: string | undefined;
160
+ jsonBodyField?: {
161
+ path: string;
162
+ equals?: string | undefined;
163
+ } | undefined;
164
+ formBodyField?: {
165
+ path: string;
166
+ equals?: string | undefined;
167
+ } | undefined;
168
+ }[] | undefined;
169
+ timeoutMs?: number | undefined;
170
+ } | undefined;
171
+ } | undefined;
152
172
  };
153
173
  description?: string | undefined;
154
174
  instructions?: string[] | undefined;
@@ -211,6 +231,26 @@ declare let getSlateContract: (client: SlatesTestClient) => Promise<{
211
231
  type: "webhook";
212
232
  autoRegistration: boolean;
213
233
  autoUnregistration: boolean;
234
+ http?: {
235
+ methods?: ("GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS")[] | undefined;
236
+ sync?: {
237
+ mode: "match" | "never" | "always";
238
+ match?: {
239
+ method?: string | undefined;
240
+ hasQueryParam?: string | undefined;
241
+ hasHeader?: string | undefined;
242
+ jsonBodyField?: {
243
+ path: string;
244
+ equals?: string | undefined;
245
+ } | undefined;
246
+ formBodyField?: {
247
+ path: string;
248
+ equals?: string | undefined;
249
+ } | undefined;
250
+ }[] | undefined;
251
+ timeoutMs?: number | undefined;
252
+ } | undefined;
253
+ } | undefined;
214
254
  };
215
255
  description?: string | undefined;
216
256
  instructions?: string[] | undefined;
@@ -326,6 +366,26 @@ declare let expectSlateContract: (d: {
326
366
  type: "webhook";
327
367
  autoRegistration: boolean;
328
368
  autoUnregistration: boolean;
369
+ http?: {
370
+ methods?: ("GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS")[] | undefined;
371
+ sync?: {
372
+ mode: "match" | "never" | "always";
373
+ match?: {
374
+ method?: string | undefined;
375
+ hasQueryParam?: string | undefined;
376
+ hasHeader?: string | undefined;
377
+ jsonBodyField?: {
378
+ path: string;
379
+ equals?: string | undefined;
380
+ } | undefined;
381
+ formBodyField?: {
382
+ path: string;
383
+ equals?: string | undefined;
384
+ } | undefined;
385
+ }[] | undefined;
386
+ timeoutMs?: number | undefined;
387
+ } | undefined;
388
+ } | undefined;
329
389
  };
330
390
  description?: string | undefined;
331
391
  instructions?: string[] | undefined;
@@ -388,6 +448,26 @@ declare let expectSlateContract: (d: {
388
448
  type: "webhook";
389
449
  autoRegistration: boolean;
390
450
  autoUnregistration: boolean;
451
+ http?: {
452
+ methods?: ("GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS")[] | undefined;
453
+ sync?: {
454
+ mode: "match" | "never" | "always";
455
+ match?: {
456
+ method?: string | undefined;
457
+ hasQueryParam?: string | undefined;
458
+ hasHeader?: string | undefined;
459
+ jsonBodyField?: {
460
+ path: string;
461
+ equals?: string | undefined;
462
+ } | undefined;
463
+ formBodyField?: {
464
+ path: string;
465
+ equals?: string | undefined;
466
+ } | undefined;
467
+ }[] | undefined;
468
+ timeoutMs?: number | undefined;
469
+ } | undefined;
470
+ } | undefined;
391
471
  };
392
472
  description?: string | undefined;
393
473
  instructions?: string[] | undefined;
@@ -518,9 +598,18 @@ declare let handleSlateTriggerWebhook: (d: {
518
598
  headers?: Record<string, string>;
519
599
  body?: string | Uint8Array | null;
520
600
  state?: any;
601
+ registrationDetails?: any;
521
602
  }) => Promise<{
522
603
  inputs: Record<string, any>[];
523
604
  updatedState?: any;
605
+ response?: {
606
+ status: number;
607
+ headers: Record<string, string>;
608
+ body: {
609
+ encoding: "base64";
610
+ content: string;
611
+ } | null;
612
+ } | null | undefined;
524
613
  requestTraces?: {
525
614
  startedAt: string;
526
615
  durationMs: number;
@@ -212,7 +212,8 @@ var handleSlateTriggerWebhook = async (d) => d.client.handleTriggerWebhook({
212
212
  method: d.method ?? "POST",
213
213
  headers: d.headers,
214
214
  body: d.body,
215
- state: d.state
215
+ state: d.state,
216
+ registrationDetails: d.registrationDetails
216
217
  });
217
218
  var unregisterSlateTriggerWebhook = async (d) => d.client.unregisterTriggerWebhook({
218
219
  actionId: d.triggerId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slates/test",
3
- "version": "1.0.0-rc.10",
3
+ "version": "1.0.0-rc.11",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -40,11 +40,11 @@
40
40
  },
41
41
  "dependencies": {
42
42
  "@lowerdeck/testing-tools": "latest",
43
- "@slates/client": "1.0.0-rc.13",
44
- "@slates/profiles": "1.0.0-rc.11"
43
+ "@slates/client": "1.0.0-rc.14",
44
+ "@slates/profiles": "1.0.0-rc.12"
45
45
  },
46
46
  "devDependencies": {
47
- "@slates/provider": "1.0.0-rc.16",
47
+ "@slates/provider": "1.0.0-rc.17",
48
48
  "@slates/tsconfig": "1.0.0-rc.1",
49
49
  "typescript": "5.8.2",
50
50
  "vitest": "^3.1.2",
package/src/index.test.ts CHANGED
@@ -186,6 +186,25 @@ let createDemoSlate = () => {
186
186
  })
187
187
  )
188
188
  .webhook({
189
+ http: {
190
+ methods: ['POST', 'OPTIONS'],
191
+ sync: {
192
+ mode: 'match',
193
+ match: [
194
+ {
195
+ method: 'POST',
196
+ hasHeader: 'x-demo-event'
197
+ },
198
+ {
199
+ formBodyField: {
200
+ path: 'mode',
201
+ equals: 'subscribe'
202
+ }
203
+ }
204
+ ],
205
+ timeoutMs: 4_000
206
+ }
207
+ },
189
208
  autoRegisterWebhook: async ctx => ({
190
209
  registrationDetails: {
191
210
  webhookBaseUrl: ctx.input.webhookBaseUrl,
@@ -213,7 +232,14 @@ let createDemoSlate = () => {
213
232
  ],
214
233
  updatedState: {
215
234
  lastEvent: ctx.request.headers.get('x-demo-event') ?? 'unknown'
216
- }
235
+ },
236
+ response: new Response(ctx.registrationDetails?.channelId ?? 'missing', {
237
+ status: 201,
238
+ headers: {
239
+ 'content-type': 'text/plain',
240
+ 'x-demo-response': 'accepted'
241
+ }
242
+ })
217
243
  };
218
244
  },
219
245
  handleEvent: async ctx => ({
@@ -404,6 +430,32 @@ describe('@slates/test', () => {
404
430
  });
405
431
 
406
432
  expect(contract.configSchema.properties.prefix.type).toBe('string');
433
+ expect(contract.triggers.find(action => action.id === 'webhook_echo')?.invocation).toEqual(
434
+ {
435
+ type: 'webhook',
436
+ autoRegistration: true,
437
+ autoUnregistration: true,
438
+ http: {
439
+ methods: ['POST', 'OPTIONS'],
440
+ sync: {
441
+ mode: 'match',
442
+ match: [
443
+ {
444
+ method: 'POST',
445
+ hasHeader: 'x-demo-event'
446
+ },
447
+ {
448
+ formBodyField: {
449
+ path: 'mode',
450
+ equals: 'subscribe'
451
+ }
452
+ }
453
+ ],
454
+ timeoutMs: 4_000
455
+ }
456
+ }
457
+ }
458
+ );
407
459
 
408
460
  await expectToolCall({
409
461
  client,
@@ -490,12 +542,24 @@ describe('@slates/test', () => {
490
542
  headers: {
491
543
  'x-demo-event': 'created'
492
544
  },
493
- body: 'payload-value'
545
+ body: 'payload-value',
546
+ registrationDetails: registration.registrationDetails
494
547
  });
495
548
  expect(handled).toMatchObject({
496
549
  inputs: [{ value: 'payload-value' }],
497
550
  updatedState: {
498
551
  lastEvent: 'created'
552
+ },
553
+ response: {
554
+ status: 201,
555
+ headers: {
556
+ 'content-type': 'text/plain',
557
+ 'x-demo-response': 'accepted'
558
+ },
559
+ body: {
560
+ encoding: 'base64',
561
+ content: Buffer.from('channel-1').toString('base64')
562
+ }
499
563
  }
500
564
  });
501
565
 
package/src/runtime.ts CHANGED
@@ -337,6 +337,7 @@ export let handleSlateTriggerWebhook = async (d: {
337
337
  headers?: Record<string, string>;
338
338
  body?: string | Uint8Array | null;
339
339
  state?: any;
340
+ registrationDetails?: any;
340
341
  }) =>
341
342
  d.client.handleTriggerWebhook({
342
343
  actionId: d.triggerId,
@@ -344,7 +345,8 @@ export let handleSlateTriggerWebhook = async (d: {
344
345
  method: d.method ?? 'POST',
345
346
  headers: d.headers,
346
347
  body: d.body,
347
- state: d.state
348
+ state: d.state,
349
+ registrationDetails: d.registrationDetails
348
350
  });
349
351
 
350
352
  export let unregisterSlateTriggerWebhook = async (d: {