@slates/test 1.0.0-rc.24 → 1.0.0-rc.25

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
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
+ connectSlateTriggerGroupGateway: () => connectSlateTriggerGroupGateway,
23
24
  createLocalSlateTestClient: () => createLocalSlateTestClient,
24
25
  createSlatesTestClient: () => createSlatesTestClient,
25
26
  describeMcpCompatibleToolSchemas: () => describeMcpCompatibleToolSchemas,
@@ -35,6 +36,7 @@ __export(index_exports, {
35
36
  mapSlateTriggerEvent: () => mapSlateTriggerEvent,
36
37
  pollSlateTriggerGroupEvents: () => pollSlateTriggerGroupEvents,
37
38
  processSlateTriggerGroupWebhook: () => processSlateTriggerGroupWebhook,
39
+ receiveSlateTriggerGroupGatewayFrames: () => receiveSlateTriggerGroupGatewayFrames,
38
40
  registerSlateTriggerGroupWebhook: () => registerSlateTriggerGroupWebhook,
39
41
  unregisterSlateTriggerGroupWebhook: () => unregisterSlateTriggerGroupWebhook,
40
42
  withSlateProfile: () => withSlateProfile
@@ -266,6 +268,22 @@ var pollSlateTriggerGroupEvents = async (d) => {
266
268
  state: d.state ?? null
267
269
  });
268
270
  };
271
+ var connectSlateTriggerGroupGateway = async (d) => {
272
+ d.client.ensureSession();
273
+ return d.client.connectTriggerGroupGateway({
274
+ triggerGroupId: d.triggerGroupId,
275
+ state: d.state ?? null
276
+ });
277
+ };
278
+ var receiveSlateTriggerGroupGatewayFrames = async (d) => {
279
+ d.client.ensureSession();
280
+ return d.client.receiveTriggerGroupGatewayFrames({
281
+ triggerGroupId: d.triggerGroupId,
282
+ state: d.state ?? null,
283
+ frames: d.frames ?? [],
284
+ closed: d.closed ?? null
285
+ });
286
+ };
269
287
  var processSlateTriggerGroupWebhook = async (d) => d.client.processTriggerGroupWebhook({
270
288
  triggerGroupId: d.triggerGroupId,
271
289
  url: d.url,
@@ -14867,6 +14885,7 @@ var describeMcpCompatibleToolSchemas = (name, source) => {
14867
14885
  };
14868
14886
  // Annotate the CommonJS export names for ESM import in node:
14869
14887
  0 && (module.exports = {
14888
+ connectSlateTriggerGroupGateway,
14870
14889
  createLocalSlateTestClient,
14871
14890
  createSlatesTestClient,
14872
14891
  describeMcpCompatibleToolSchemas,
@@ -14882,6 +14901,7 @@ var describeMcpCompatibleToolSchemas = (name, source) => {
14882
14901
  mapSlateTriggerEvent,
14883
14902
  pollSlateTriggerGroupEvents,
14884
14903
  processSlateTriggerGroupWebhook,
14904
+ receiveSlateTriggerGroupGatewayFrames,
14885
14905
  registerSlateTriggerGroupWebhook,
14886
14906
  unregisterSlateTriggerGroupWebhook,
14887
14907
  withSlateProfile
package/dist/index.d.cts CHANGED
@@ -29,7 +29,7 @@ interface ExpectedSlateTriggerGroup {
29
29
  id: string;
30
30
  name?: string;
31
31
  description?: string;
32
- invocationType?: 'polling' | 'webhook';
32
+ invocationType?: 'polling' | 'webhook' | 'gateway';
33
33
  }
34
34
  declare let getVitestExpect: () => vitest.ExpectStatic;
35
35
  declare let loadSlatesRuntimeContext: (opts?: {
@@ -238,6 +238,8 @@ declare let getSlateContract: (client: SlatesTestClient) => Promise<{
238
238
  invocation: {
239
239
  type: "polling";
240
240
  intervalSeconds: number;
241
+ } | {
242
+ type: "gateway";
241
243
  } | {
242
244
  type: "webhook";
243
245
  registration: {
@@ -429,6 +431,8 @@ declare let expectSlateContract: (d: {
429
431
  invocation: {
430
432
  type: "polling";
431
433
  intervalSeconds: number;
434
+ } | {
435
+ type: "gateway";
432
436
  } | {
433
437
  type: "webhook";
434
438
  registration: {
@@ -555,6 +559,98 @@ declare let pollSlateTriggerGroupEvents: (d: {
555
559
  } | undefined;
556
560
  }[] | undefined;
557
561
  }>;
562
+ declare let connectSlateTriggerGroupGateway: (d: {
563
+ client: SlatesTestClient;
564
+ triggerGroupId: string;
565
+ state?: any;
566
+ }) => Promise<{
567
+ url: string;
568
+ state?: any;
569
+ requestTraces?: {
570
+ startedAt: string;
571
+ durationMs: number;
572
+ request: {
573
+ method: string;
574
+ url: string;
575
+ headers?: Record<string, string> | undefined;
576
+ body?: {
577
+ text: string;
578
+ contentType?: string | undefined;
579
+ truncated?: boolean | undefined;
580
+ } | undefined;
581
+ };
582
+ response?: {
583
+ status: number;
584
+ statusText?: string | undefined;
585
+ headers?: Record<string, string> | undefined;
586
+ body?: {
587
+ text: string;
588
+ contentType?: string | undefined;
589
+ truncated?: boolean | undefined;
590
+ } | undefined;
591
+ } | undefined;
592
+ error?: {
593
+ message: string;
594
+ code?: string | undefined;
595
+ } | undefined;
596
+ }[] | undefined;
597
+ }>;
598
+ declare let receiveSlateTriggerGroupGatewayFrames: (d: {
599
+ client: SlatesTestClient;
600
+ triggerGroupId: string;
601
+ state?: any;
602
+ frames?: string[];
603
+ closed?: {
604
+ code: number;
605
+ reason: string;
606
+ } | null;
607
+ }) => Promise<{
608
+ send: string[];
609
+ events: {
610
+ payload: Record<string, any>;
611
+ triggerIds: string[];
612
+ idempotencyKey?: string | undefined;
613
+ }[];
614
+ state?: any;
615
+ heartbeat?: {
616
+ intervalMs: number;
617
+ frame: string;
618
+ expectsAck?: boolean | undefined;
619
+ } | null | undefined;
620
+ heartbeatAcked?: boolean | undefined;
621
+ close?: {
622
+ reconnect: boolean;
623
+ reason?: string | undefined;
624
+ } | null | undefined;
625
+ requestTraces?: {
626
+ startedAt: string;
627
+ durationMs: number;
628
+ request: {
629
+ method: string;
630
+ url: string;
631
+ headers?: Record<string, string> | undefined;
632
+ body?: {
633
+ text: string;
634
+ contentType?: string | undefined;
635
+ truncated?: boolean | undefined;
636
+ } | undefined;
637
+ };
638
+ response?: {
639
+ status: number;
640
+ statusText?: string | undefined;
641
+ headers?: Record<string, string> | undefined;
642
+ body?: {
643
+ text: string;
644
+ contentType?: string | undefined;
645
+ truncated?: boolean | undefined;
646
+ } | undefined;
647
+ } | undefined;
648
+ error?: {
649
+ message: string;
650
+ code?: string | undefined;
651
+ } | undefined;
652
+ }[] | undefined;
653
+ }>;
558
654
  declare let processSlateTriggerGroupWebhook: (d: {
559
655
  client: SlatesTestClient;
560
656
  triggerGroupId: string;
@@ -697,4 +793,4 @@ declare let getMcpCompatibleToolSchemaCases: (source: ToolSchemaSource) => Reado
697
793
  declare let expectMcpCompatibleToolSchema: (tool: ToolSchemaTarget) => void;
698
794
  declare let describeMcpCompatibleToolSchemas: (name: string, source: ToolSchemaSource) => void;
699
795
 
700
- export { type ExpectedSlateAction, type ExpectedSlateTriggerGroup, type SlatesRuntimeContext, type SlatesTestClient, createLocalSlateTestClient, createSlatesTestClient, describeMcpCompatibleToolSchemas, expectMcpCompatibleToolSchema, expectSlateContract, expectSlateError, expectToolCall, getMcpCompatibleToolSchemaCases, getSlateContract, getVitestExpect, loadSlatesProfile, loadSlatesRuntimeContext, mapSlateTriggerEvent, pollSlateTriggerGroupEvents, processSlateTriggerGroupWebhook, registerSlateTriggerGroupWebhook, unregisterSlateTriggerGroupWebhook, withSlateProfile };
796
+ export { type ExpectedSlateAction, type ExpectedSlateTriggerGroup, type SlatesRuntimeContext, type SlatesTestClient, connectSlateTriggerGroupGateway, createLocalSlateTestClient, createSlatesTestClient, describeMcpCompatibleToolSchemas, expectMcpCompatibleToolSchema, expectSlateContract, expectSlateError, expectToolCall, getMcpCompatibleToolSchemaCases, getSlateContract, getVitestExpect, loadSlatesProfile, loadSlatesRuntimeContext, mapSlateTriggerEvent, pollSlateTriggerGroupEvents, processSlateTriggerGroupWebhook, receiveSlateTriggerGroupGatewayFrames, registerSlateTriggerGroupWebhook, unregisterSlateTriggerGroupWebhook, withSlateProfile };
package/dist/index.d.ts CHANGED
@@ -29,7 +29,7 @@ interface ExpectedSlateTriggerGroup {
29
29
  id: string;
30
30
  name?: string;
31
31
  description?: string;
32
- invocationType?: 'polling' | 'webhook';
32
+ invocationType?: 'polling' | 'webhook' | 'gateway';
33
33
  }
34
34
  declare let getVitestExpect: () => vitest.ExpectStatic;
35
35
  declare let loadSlatesRuntimeContext: (opts?: {
@@ -238,6 +238,8 @@ declare let getSlateContract: (client: SlatesTestClient) => Promise<{
238
238
  invocation: {
239
239
  type: "polling";
240
240
  intervalSeconds: number;
241
+ } | {
242
+ type: "gateway";
241
243
  } | {
242
244
  type: "webhook";
243
245
  registration: {
@@ -429,6 +431,8 @@ declare let expectSlateContract: (d: {
429
431
  invocation: {
430
432
  type: "polling";
431
433
  intervalSeconds: number;
434
+ } | {
435
+ type: "gateway";
432
436
  } | {
433
437
  type: "webhook";
434
438
  registration: {
@@ -555,6 +559,98 @@ declare let pollSlateTriggerGroupEvents: (d: {
555
559
  } | undefined;
556
560
  }[] | undefined;
557
561
  }>;
562
+ declare let connectSlateTriggerGroupGateway: (d: {
563
+ client: SlatesTestClient;
564
+ triggerGroupId: string;
565
+ state?: any;
566
+ }) => Promise<{
567
+ url: string;
568
+ state?: any;
569
+ requestTraces?: {
570
+ startedAt: string;
571
+ durationMs: number;
572
+ request: {
573
+ method: string;
574
+ url: string;
575
+ headers?: Record<string, string> | undefined;
576
+ body?: {
577
+ text: string;
578
+ contentType?: string | undefined;
579
+ truncated?: boolean | undefined;
580
+ } | undefined;
581
+ };
582
+ response?: {
583
+ status: number;
584
+ statusText?: string | undefined;
585
+ headers?: Record<string, string> | undefined;
586
+ body?: {
587
+ text: string;
588
+ contentType?: string | undefined;
589
+ truncated?: boolean | undefined;
590
+ } | undefined;
591
+ } | undefined;
592
+ error?: {
593
+ message: string;
594
+ code?: string | undefined;
595
+ } | undefined;
596
+ }[] | undefined;
597
+ }>;
598
+ declare let receiveSlateTriggerGroupGatewayFrames: (d: {
599
+ client: SlatesTestClient;
600
+ triggerGroupId: string;
601
+ state?: any;
602
+ frames?: string[];
603
+ closed?: {
604
+ code: number;
605
+ reason: string;
606
+ } | null;
607
+ }) => Promise<{
608
+ send: string[];
609
+ events: {
610
+ payload: Record<string, any>;
611
+ triggerIds: string[];
612
+ idempotencyKey?: string | undefined;
613
+ }[];
614
+ state?: any;
615
+ heartbeat?: {
616
+ intervalMs: number;
617
+ frame: string;
618
+ expectsAck?: boolean | undefined;
619
+ } | null | undefined;
620
+ heartbeatAcked?: boolean | undefined;
621
+ close?: {
622
+ reconnect: boolean;
623
+ reason?: string | undefined;
624
+ } | null | undefined;
625
+ requestTraces?: {
626
+ startedAt: string;
627
+ durationMs: number;
628
+ request: {
629
+ method: string;
630
+ url: string;
631
+ headers?: Record<string, string> | undefined;
632
+ body?: {
633
+ text: string;
634
+ contentType?: string | undefined;
635
+ truncated?: boolean | undefined;
636
+ } | undefined;
637
+ };
638
+ response?: {
639
+ status: number;
640
+ statusText?: string | undefined;
641
+ headers?: Record<string, string> | undefined;
642
+ body?: {
643
+ text: string;
644
+ contentType?: string | undefined;
645
+ truncated?: boolean | undefined;
646
+ } | undefined;
647
+ } | undefined;
648
+ error?: {
649
+ message: string;
650
+ code?: string | undefined;
651
+ } | undefined;
652
+ }[] | undefined;
653
+ }>;
558
654
  declare let processSlateTriggerGroupWebhook: (d: {
559
655
  client: SlatesTestClient;
560
656
  triggerGroupId: string;
@@ -697,4 +793,4 @@ declare let getMcpCompatibleToolSchemaCases: (source: ToolSchemaSource) => Reado
697
793
  declare let expectMcpCompatibleToolSchema: (tool: ToolSchemaTarget) => void;
698
794
  declare let describeMcpCompatibleToolSchemas: (name: string, source: ToolSchemaSource) => void;
699
795
 
700
- export { type ExpectedSlateAction, type ExpectedSlateTriggerGroup, type SlatesRuntimeContext, type SlatesTestClient, createLocalSlateTestClient, createSlatesTestClient, describeMcpCompatibleToolSchemas, expectMcpCompatibleToolSchema, expectSlateContract, expectSlateError, expectToolCall, getMcpCompatibleToolSchemaCases, getSlateContract, getVitestExpect, loadSlatesProfile, loadSlatesRuntimeContext, mapSlateTriggerEvent, pollSlateTriggerGroupEvents, processSlateTriggerGroupWebhook, registerSlateTriggerGroupWebhook, unregisterSlateTriggerGroupWebhook, withSlateProfile };
796
+ export { type ExpectedSlateAction, type ExpectedSlateTriggerGroup, type SlatesRuntimeContext, type SlatesTestClient, connectSlateTriggerGroupGateway, createLocalSlateTestClient, createSlatesTestClient, describeMcpCompatibleToolSchemas, expectMcpCompatibleToolSchema, expectSlateContract, expectSlateError, expectToolCall, getMcpCompatibleToolSchemaCases, getSlateContract, getVitestExpect, loadSlatesProfile, loadSlatesRuntimeContext, mapSlateTriggerEvent, pollSlateTriggerGroupEvents, processSlateTriggerGroupWebhook, receiveSlateTriggerGroupGatewayFrames, registerSlateTriggerGroupWebhook, unregisterSlateTriggerGroupWebhook, withSlateProfile };
@@ -236,6 +236,22 @@ var pollSlateTriggerGroupEvents = async (d) => {
236
236
  state: d.state ?? null
237
237
  });
238
238
  };
239
+ var connectSlateTriggerGroupGateway = async (d) => {
240
+ d.client.ensureSession();
241
+ return d.client.connectTriggerGroupGateway({
242
+ triggerGroupId: d.triggerGroupId,
243
+ state: d.state ?? null
244
+ });
245
+ };
246
+ var receiveSlateTriggerGroupGatewayFrames = async (d) => {
247
+ d.client.ensureSession();
248
+ return d.client.receiveTriggerGroupGatewayFrames({
249
+ triggerGroupId: d.triggerGroupId,
250
+ state: d.state ?? null,
251
+ frames: d.frames ?? [],
252
+ closed: d.closed ?? null
253
+ });
254
+ };
239
255
  var processSlateTriggerGroupWebhook = async (d) => d.client.processTriggerGroupWebhook({
240
256
  triggerGroupId: d.triggerGroupId,
241
257
  url: d.url,
@@ -14836,6 +14852,7 @@ var describeMcpCompatibleToolSchemas = (name, source) => {
14836
14852
  });
14837
14853
  };
14838
14854
  export {
14855
+ connectSlateTriggerGroupGateway,
14839
14856
  createLocalSlateTestClient,
14840
14857
  createSlatesTestClient,
14841
14858
  describeMcpCompatibleToolSchemas,
@@ -14851,6 +14868,7 @@ export {
14851
14868
  mapSlateTriggerEvent,
14852
14869
  pollSlateTriggerGroupEvents,
14853
14870
  processSlateTriggerGroupWebhook,
14871
+ receiveSlateTriggerGroupGatewayFrames,
14854
14872
  registerSlateTriggerGroupWebhook,
14855
14873
  unregisterSlateTriggerGroupWebhook,
14856
14874
  withSlateProfile
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slates/test",
3
- "version": "1.0.0-rc.24",
3
+ "version": "1.0.0-rc.25",
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.27",
44
- "@slates/profiles": "1.0.0-rc.25"
43
+ "@slates/client": "1.0.0-rc.28",
44
+ "@slates/profiles": "1.0.0-rc.26"
45
45
  },
46
46
  "devDependencies": {
47
- "@slates/provider": "1.0.0-rc.27",
47
+ "@slates/provider": "1.0.0-rc.28",
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
@@ -15,6 +15,7 @@ import path from 'path';
15
15
  import { afterEach, describe, expect, it } from 'vitest';
16
16
  import { z } from 'zod';
17
17
  import {
18
+ connectSlateTriggerGroupGateway,
18
19
  createLocalSlateTestClient,
19
20
  expectSlateContract,
20
21
  expectSlateError,
@@ -23,6 +24,7 @@ import {
23
24
  mapSlateTriggerEvent,
24
25
  pollSlateTriggerGroupEvents,
25
26
  processSlateTriggerGroupWebhook,
27
+ receiveSlateTriggerGroupGatewayFrames,
26
28
  registerSlateTriggerGroupWebhook,
27
29
  unregisterSlateTriggerGroupWebhook
28
30
  } from './index';
@@ -298,11 +300,57 @@ let createDemoSlate = () => {
298
300
  }))
299
301
  .build();
300
302
 
303
+ let gatewayGroup = SlateTriggerGroup.create(spec, {
304
+ key: 'gateway_group',
305
+ name: 'Gateway Group'
306
+ })
307
+ .gateway({
308
+ connect: async ctx => ({
309
+ url: `wss://gateway.example.com?resume=${ctx.input.state?.session ?? 'none'}`,
310
+ state: { session: ctx.input.state?.session ?? null }
311
+ }),
312
+ receive: async ctx => {
313
+ if (ctx.input.closed) {
314
+ return { close: { reconnect: ctx.input.closed.code !== 4004 } };
315
+ }
316
+ let frames = ctx.input.frames.map(
317
+ frame => JSON.parse(frame) as { op: string; v?: string }
318
+ );
319
+ return {
320
+ state: { session: 'session-1' },
321
+ send: frames.some(f => f.op === 'hello')
322
+ ? [JSON.stringify({ op: 'identify', token: ctx.auth.token })]
323
+ : [],
324
+ heartbeat: { intervalMs: 41_250, frame: JSON.stringify({ op: 'heartbeat' }) },
325
+ events: frames
326
+ .filter(f => f.op === 'dispatch')
327
+ .map(f => ({ payload: { value: f.v }, idempotencyKey: `gw-${f.v}` }))
328
+ };
329
+ }
330
+ })
331
+ .routingMatchers(async () => [])
332
+ .build();
333
+
334
+ let gatewayEcho = SlateTrigger.create(spec, {
335
+ key: 'gateway_echo',
336
+ name: 'Gateway Echo'
337
+ })
338
+ .input(z.object({ value: z.string() }))
339
+ .output(z.object({ echoed: z.string() }))
340
+ .triggerGroup(gatewayGroup)
341
+ .matches(() => true)
342
+ .map(async ctx => ({
343
+ type: 'demo.gateway',
344
+ id: `gateway-${ctx.input.value}`,
345
+ output: { echoed: ctx.input.value }
346
+ }))
347
+ .build();
348
+
301
349
  return Slate.create({
302
350
  spec,
303
351
  tools: [echo, fail, attachmentEcho, downloadLink],
304
- triggers: [webhookEcho, pollEcho],
305
- triggerGroups: [webhookGroup, pollGroup]
352
+ triggers: [webhookEcho, pollEcho, gatewayEcho],
353
+ triggerGroups: [webhookGroup, pollGroup, gatewayGroup]
306
354
  });
307
355
  };
308
356
 
@@ -431,8 +479,8 @@ describe('@slates/test', () => {
431
479
  description: 'A tiny test slate'
432
480
  },
433
481
  toolIds: ['echo', 'fail', 'attachment_echo', 'download_link'],
434
- triggerIds: ['webhook_echo', 'poll_echo'],
435
- triggerGroupIds: ['webhook_group', 'poll_group'],
482
+ triggerIds: ['webhook_echo', 'poll_echo', 'gateway_echo'],
483
+ triggerGroupIds: ['webhook_group', 'poll_group', 'gateway_group'],
436
484
  authMethodIds: ['token_auth'],
437
485
  tools: [
438
486
  { id: 'echo', readOnly: false, destructive: false },
@@ -440,10 +488,11 @@ describe('@slates/test', () => {
440
488
  { id: 'attachment_echo', readOnly: true, destructive: false },
441
489
  { id: 'download_link', readOnly: true, destructive: false }
442
490
  ],
443
- triggers: [{ id: 'webhook_echo' }, { id: 'poll_echo' }],
491
+ triggers: [{ id: 'webhook_echo' }, { id: 'poll_echo' }, { id: 'gateway_echo' }],
444
492
  triggerGroups: [
445
493
  { id: 'webhook_group', invocationType: 'webhook' },
446
- { id: 'poll_group', invocationType: 'polling' }
494
+ { id: 'poll_group', invocationType: 'polling' },
495
+ { id: 'gateway_group', invocationType: 'gateway' }
447
496
  ]
448
497
  });
449
498
 
@@ -630,4 +679,64 @@ describe('@slates/test', () => {
630
679
  seen: true
631
680
  });
632
681
  });
682
+
683
+ it('wraps trigger gateway flows', async () => {
684
+ let client = createLocalSlateTestClient({
685
+ slate: createDemoSlate(),
686
+ state: {
687
+ config: { prefix: 'Hi' },
688
+ auth: { authenticationMethodId: 'token_auth', output: { token: 'secret-token' } }
689
+ }
690
+ });
691
+
692
+ let connected = await connectSlateTriggerGroupGateway({
693
+ client,
694
+ triggerGroupId: 'gateway_group'
695
+ });
696
+ expect(connected).toMatchObject({
697
+ url: 'wss://gateway.example.com?resume=none',
698
+ state: { session: null }
699
+ });
700
+
701
+ let received = await receiveSlateTriggerGroupGatewayFrames({
702
+ client,
703
+ triggerGroupId: 'gateway_group',
704
+ state: connected.state,
705
+ frames: [
706
+ JSON.stringify({ op: 'hello' }),
707
+ JSON.stringify({ op: 'dispatch', v: 'gw-value' })
708
+ ]
709
+ });
710
+ expect(received).toMatchObject({
711
+ state: { session: 'session-1' },
712
+ // The credential leaves the slate as a placeholder the hub resolves at the socket.
713
+ send: [JSON.stringify({ op: 'identify', token: '$$MT$secret$authConfig$token$$' })],
714
+ heartbeat: { intervalMs: 41_250, frame: JSON.stringify({ op: 'heartbeat' }) },
715
+ close: null,
716
+ events: [
717
+ {
718
+ payload: { value: 'gw-value' },
719
+ idempotencyKey: 'gw-gw-value',
720
+ triggerIds: ['gateway_echo']
721
+ }
722
+ ]
723
+ });
724
+
725
+ let mapped = await mapSlateTriggerEvent({
726
+ client,
727
+ triggerId: 'gateway_echo',
728
+ input: received.events[0]!.payload,
729
+ type: 'demo.gateway',
730
+ output: { echoed: 'gw-value' }
731
+ });
732
+ expect(mapped.id).toBe('gateway-gw-value');
733
+
734
+ let closed = await receiveSlateTriggerGroupGatewayFrames({
735
+ client,
736
+ triggerGroupId: 'gateway_group',
737
+ state: received.state,
738
+ closed: { code: 4004, reason: 'Authentication failed' }
739
+ });
740
+ expect(closed).toMatchObject({ send: [], events: [], close: { reconnect: false } });
741
+ });
633
742
  });
package/src/runtime.ts CHANGED
@@ -71,7 +71,7 @@ export interface ExpectedSlateTriggerGroup {
71
71
  id: string;
72
72
  name?: string;
73
73
  description?: string;
74
- invocationType?: 'polling' | 'webhook';
74
+ invocationType?: 'polling' | 'webhook' | 'gateway';
75
75
  }
76
76
 
77
77
  export let getVitestExpect = () => {
@@ -378,6 +378,34 @@ export let pollSlateTriggerGroupEvents = async (d: {
378
378
  });
379
379
  };
380
380
 
381
+ export let connectSlateTriggerGroupGateway = async (d: {
382
+ client: SlatesTestClient;
383
+ triggerGroupId: string;
384
+ state?: any;
385
+ }) => {
386
+ d.client.ensureSession();
387
+ return d.client.connectTriggerGroupGateway({
388
+ triggerGroupId: d.triggerGroupId,
389
+ state: d.state ?? null
390
+ });
391
+ };
392
+
393
+ export let receiveSlateTriggerGroupGatewayFrames = async (d: {
394
+ client: SlatesTestClient;
395
+ triggerGroupId: string;
396
+ state?: any;
397
+ frames?: string[];
398
+ closed?: { code: number; reason: string } | null;
399
+ }) => {
400
+ d.client.ensureSession();
401
+ return d.client.receiveTriggerGroupGatewayFrames({
402
+ triggerGroupId: d.triggerGroupId,
403
+ state: d.state ?? null,
404
+ frames: d.frames ?? [],
405
+ closed: d.closed ?? null
406
+ });
407
+ };
408
+
381
409
  export let processSlateTriggerGroupWebhook = async (d: {
382
410
  client: SlatesTestClient;
383
411
  triggerGroupId: string;