@slates/test 1.0.0-rc.17 → 1.0.0-rc.19

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
@@ -30,13 +30,13 @@ __export(index_exports, {
30
30
  getMcpCompatibleToolSchemaCases: () => getMcpCompatibleToolSchemaCases,
31
31
  getSlateContract: () => getSlateContract,
32
32
  getVitestExpect: () => getVitestExpect,
33
- handleSlateTriggerWebhook: () => handleSlateTriggerWebhook,
34
33
  loadSlatesProfile: () => loadSlatesProfile,
35
34
  loadSlatesRuntimeContext: () => loadSlatesRuntimeContext,
36
35
  mapSlateTriggerEvent: () => mapSlateTriggerEvent,
37
- pollSlateTriggerEvents: () => pollSlateTriggerEvents,
38
- registerSlateTriggerWebhook: () => registerSlateTriggerWebhook,
39
- unregisterSlateTriggerWebhook: () => unregisterSlateTriggerWebhook,
36
+ pollSlateTriggerGroupEvents: () => pollSlateTriggerGroupEvents,
37
+ processSlateTriggerGroupWebhook: () => processSlateTriggerGroupWebhook,
38
+ registerSlateTriggerGroupWebhook: () => registerSlateTriggerGroupWebhook,
39
+ unregisterSlateTriggerGroupWebhook: () => unregisterSlateTriggerGroupWebhook,
40
40
  withSlateProfile: () => withSlateProfile
41
41
  });
42
42
  module.exports = __toCommonJS(index_exports);
@@ -144,15 +144,19 @@ var expectToolCall = async (d) => {
144
144
  };
145
145
  var createLocalSlateTestClient = (opts) => (0, import_client.createSlatesClient)({
146
146
  transport: (0, import_client.createLocalSlateTransport)({ slate: opts.slate }),
147
- state: opts.state,
147
+ state: {
148
+ capabilities: { triggers: true },
149
+ ...opts.state
150
+ },
148
151
  participants: opts.participants
149
152
  });
150
153
  var getSlateContract = async (client) => {
151
- let [provider, actions, authMethods, configSchema] = await Promise.all([
154
+ let [provider, actions, authMethods, configSchema, triggerGroups] = await Promise.all([
152
155
  client.identify(),
153
156
  client.listActions(),
154
157
  client.listAuthMethods(),
155
- client.getConfigSchema()
158
+ client.getConfigSchema(),
159
+ client.listTriggerGroups()
156
160
  ]);
157
161
  return {
158
162
  provider: provider.provider,
@@ -163,6 +167,7 @@ var getSlateContract = async (client) => {
163
167
  triggers: actions.actions.filter(
164
168
  (action) => action.type === "action.trigger"
165
169
  ),
170
+ triggerGroups: triggerGroups.triggerGroups,
166
171
  authMethods: authMethods.authenticationMethods,
167
172
  configSchema: configSchema.schema
168
173
  };
@@ -183,6 +188,17 @@ var expectActionMatches = (actual, expected) => {
183
188
  if (expected.destructive !== void 0) {
184
189
  expect2(actual?.tags?.destructive ?? false).toBe(expected.destructive);
185
190
  }
191
+ };
192
+ var expectTriggerGroupMatches = (actual, expected) => {
193
+ let expect2 = getVitestExpect();
194
+ expect2(actual).toBeTruthy();
195
+ expect2(actual?.id).toBe(expected.id);
196
+ if (expected.name !== void 0) {
197
+ expect2(actual?.name).toBe(expected.name);
198
+ }
199
+ if (expected.description !== void 0) {
200
+ expect2(actual?.description).toBe(expected.description);
201
+ }
186
202
  if (expected.invocationType !== void 0) {
187
203
  expect2(actual?.invocation?.type).toBe(
188
204
  expected.invocationType
@@ -209,6 +225,9 @@ var expectSlateContract = async (d) => {
209
225
  d.triggerIds
210
226
  );
211
227
  }
228
+ if (d.triggerGroupIds) {
229
+ expect2(contract.triggerGroups.map((group) => group.id)).toEqual(d.triggerGroupIds);
230
+ }
212
231
  if (d.authMethodIds) {
213
232
  expect2(contract.authMethods.map((method) => method.id)).toEqual(
214
233
  d.authMethodIds
@@ -226,30 +245,39 @@ var expectSlateContract = async (d) => {
226
245
  trigger
227
246
  );
228
247
  }
248
+ for (let triggerGroup of d.triggerGroups ?? []) {
249
+ expectTriggerGroupMatches(
250
+ contract.triggerGroups.find((group) => group.id === triggerGroup.id),
251
+ triggerGroup
252
+ );
253
+ }
229
254
  return contract;
230
255
  };
231
- var registerSlateTriggerWebhook = async (d) => d.client.registerTriggerWebhook(d.triggerId, d.webhookBaseUrl);
232
- var pollSlateTriggerEvents = async (d) => {
256
+ var registerSlateTriggerGroupWebhook = async (d) => d.client.registerTriggerGroupWebhook({
257
+ triggerGroupId: d.triggerGroupId,
258
+ webhookTargetIdentifier: d.webhookTargetIdentifier,
259
+ webhookTargetPayload: d.webhookTargetPayload,
260
+ webhookUrl: d.webhookUrl
261
+ });
262
+ var pollSlateTriggerGroupEvents = async (d) => {
233
263
  d.client.ensureSession();
234
- return d.client.request("slates/action.trigger.poll_events", {
235
- actionId: d.triggerId,
264
+ return d.client.pollTriggerGroup({
265
+ triggerGroupId: d.triggerGroupId,
236
266
  state: d.state ?? null
237
267
  });
238
268
  };
239
- var handleSlateTriggerWebhook = async (d) => d.client.handleTriggerWebhook({
240
- actionId: d.triggerId,
269
+ var processSlateTriggerGroupWebhook = async (d) => d.client.processTriggerGroupWebhook({
270
+ triggerGroupId: d.triggerGroupId,
241
271
  url: d.url,
242
272
  method: d.method ?? "POST",
243
273
  headers: d.headers,
244
274
  body: d.body,
245
- state: d.state,
246
- registrationDetails: d.registrationDetails
275
+ webhookRegistrationPayload: d.webhookRegistrationPayload ?? null
247
276
  });
248
- var unregisterSlateTriggerWebhook = async (d) => d.client.unregisterTriggerWebhook({
249
- actionId: d.triggerId,
250
- webhookBaseUrl: d.webhookBaseUrl,
251
- registrationDetails: d.registrationDetails,
252
- state: d.state
277
+ var unregisterSlateTriggerGroupWebhook = async (d) => d.client.unregisterTriggerGroupWebhook({
278
+ triggerGroupId: d.triggerGroupId,
279
+ webhookRegistrationIdentifier: d.webhookRegistrationIdentifier,
280
+ webhookRegistrationPayload: d.webhookRegistrationPayload
253
281
  });
254
282
  var mapSlateTriggerEvent = async (d) => {
255
283
  let expect2 = getVitestExpect();
@@ -14849,12 +14877,12 @@ var describeMcpCompatibleToolSchemas = (name, source) => {
14849
14877
  getMcpCompatibleToolSchemaCases,
14850
14878
  getSlateContract,
14851
14879
  getVitestExpect,
14852
- handleSlateTriggerWebhook,
14853
14880
  loadSlatesProfile,
14854
14881
  loadSlatesRuntimeContext,
14855
14882
  mapSlateTriggerEvent,
14856
- pollSlateTriggerEvents,
14857
- registerSlateTriggerWebhook,
14858
- unregisterSlateTriggerWebhook,
14883
+ pollSlateTriggerGroupEvents,
14884
+ processSlateTriggerGroupWebhook,
14885
+ registerSlateTriggerGroupWebhook,
14886
+ unregisterSlateTriggerGroupWebhook,
14859
14887
  withSlateProfile
14860
14888
  });
package/dist/index.d.cts CHANGED
@@ -24,6 +24,11 @@ interface ExpectedSlateAction {
24
24
  description?: string;
25
25
  readOnly?: boolean;
26
26
  destructive?: boolean;
27
+ }
28
+ interface ExpectedSlateTriggerGroup {
29
+ id: string;
30
+ name?: string;
31
+ description?: string;
27
32
  invocationType?: 'polling' | 'webhook';
28
33
  }
29
34
  declare let getVitestExpect: () => vitest.ExpectStatic;
@@ -57,6 +62,8 @@ declare let expectToolCall: (d: {
57
62
  url: string;
58
63
  headers?: Record<string, string> | undefined;
59
64
  query?: Record<string, string> | undefined;
65
+ refreshReference?: unknown;
66
+ refreshAt?: string | undefined;
60
67
  } | {
61
68
  type: "content";
62
69
  encoding: "utf-8" | "base64";
@@ -150,34 +157,7 @@ declare let getSlateContract: (client: SlatesTestClient) => Promise<{
150
157
  }[];
151
158
  type: "action.trigger";
152
159
  capabilities: Record<string, never>;
153
- invocation: {
154
- type: "polling";
155
- intervalSeconds: number;
156
- } | {
157
- type: "webhook";
158
- autoRegistration: boolean;
159
- autoUnregistration: boolean;
160
- http?: {
161
- methods?: ("GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS")[] | undefined;
162
- sync?: {
163
- mode: "match" | "never" | "always";
164
- match?: {
165
- method?: string | undefined;
166
- hasQueryParam?: string | undefined;
167
- hasHeader?: string | undefined;
168
- jsonBodyField?: {
169
- path: string;
170
- equals?: string | undefined;
171
- } | undefined;
172
- formBodyField?: {
173
- path: string;
174
- equals?: string | undefined;
175
- } | undefined;
176
- }[] | undefined;
177
- timeoutMs?: number | undefined;
178
- } | undefined;
179
- } | undefined;
180
- };
160
+ triggerGroupId: string;
181
161
  description?: string | undefined;
182
162
  instructions?: string[] | undefined;
183
163
  constraints?: string[] | undefined;
@@ -235,34 +215,7 @@ declare let getSlateContract: (client: SlatesTestClient) => Promise<{
235
215
  }[];
236
216
  type: "action.trigger";
237
217
  capabilities: Record<string, never>;
238
- invocation: {
239
- type: "polling";
240
- intervalSeconds: number;
241
- } | {
242
- type: "webhook";
243
- autoRegistration: boolean;
244
- autoUnregistration: boolean;
245
- http?: {
246
- methods?: ("GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS")[] | undefined;
247
- sync?: {
248
- mode: "match" | "never" | "always";
249
- match?: {
250
- method?: string | undefined;
251
- hasQueryParam?: string | undefined;
252
- hasHeader?: string | undefined;
253
- jsonBodyField?: {
254
- path: string;
255
- equals?: string | undefined;
256
- } | undefined;
257
- formBodyField?: {
258
- path: string;
259
- equals?: string | undefined;
260
- } | undefined;
261
- }[] | undefined;
262
- timeoutMs?: number | undefined;
263
- } | undefined;
264
- } | undefined;
265
- };
218
+ triggerGroupId: string;
266
219
  description?: string | undefined;
267
220
  instructions?: string[] | undefined;
268
221
  constraints?: string[] | undefined;
@@ -279,6 +232,25 @@ declare let getSlateContract: (client: SlatesTestClient) => Promise<{
279
232
  authMethods?: string[] | undefined;
280
233
  adapter?: string | null | undefined;
281
234
  }[];
235
+ triggerGroups: {
236
+ id: string;
237
+ name: string;
238
+ invocation: {
239
+ type: "polling";
240
+ intervalSeconds: number;
241
+ } | {
242
+ type: "webhook";
243
+ registration: {
244
+ mode: "auto";
245
+ } | {
246
+ mode: "manual";
247
+ userConfigSchema: Record<string, any>;
248
+ fullConfigSchema: Record<string, any>;
249
+ };
250
+ };
251
+ description?: string | undefined;
252
+ metadata?: Record<string, any> | undefined;
253
+ }[];
282
254
  authMethods: {
283
255
  id: string;
284
256
  name: string;
@@ -321,9 +293,11 @@ declare let expectSlateContract: (d: {
321
293
  };
322
294
  toolIds?: string[];
323
295
  triggerIds?: string[];
296
+ triggerGroupIds?: string[];
324
297
  authMethodIds?: string[];
325
298
  tools?: ExpectedSlateAction[];
326
299
  triggers?: ExpectedSlateAction[];
300
+ triggerGroups?: ExpectedSlateTriggerGroup[];
327
301
  }) => Promise<{
328
302
  provider: {
329
303
  type: "provider";
@@ -372,34 +346,7 @@ declare let expectSlateContract: (d: {
372
346
  }[];
373
347
  type: "action.trigger";
374
348
  capabilities: Record<string, never>;
375
- invocation: {
376
- type: "polling";
377
- intervalSeconds: number;
378
- } | {
379
- type: "webhook";
380
- autoRegistration: boolean;
381
- autoUnregistration: boolean;
382
- http?: {
383
- methods?: ("GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS")[] | undefined;
384
- sync?: {
385
- mode: "match" | "never" | "always";
386
- match?: {
387
- method?: string | undefined;
388
- hasQueryParam?: string | undefined;
389
- hasHeader?: string | undefined;
390
- jsonBodyField?: {
391
- path: string;
392
- equals?: string | undefined;
393
- } | undefined;
394
- formBodyField?: {
395
- path: string;
396
- equals?: string | undefined;
397
- } | undefined;
398
- }[] | undefined;
399
- timeoutMs?: number | undefined;
400
- } | undefined;
401
- } | undefined;
402
- };
349
+ triggerGroupId: string;
403
350
  description?: string | undefined;
404
351
  instructions?: string[] | undefined;
405
352
  constraints?: string[] | undefined;
@@ -457,34 +404,7 @@ declare let expectSlateContract: (d: {
457
404
  }[];
458
405
  type: "action.trigger";
459
406
  capabilities: Record<string, never>;
460
- invocation: {
461
- type: "polling";
462
- intervalSeconds: number;
463
- } | {
464
- type: "webhook";
465
- autoRegistration: boolean;
466
- autoUnregistration: boolean;
467
- http?: {
468
- methods?: ("GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS")[] | undefined;
469
- sync?: {
470
- mode: "match" | "never" | "always";
471
- match?: {
472
- method?: string | undefined;
473
- hasQueryParam?: string | undefined;
474
- hasHeader?: string | undefined;
475
- jsonBodyField?: {
476
- path: string;
477
- equals?: string | undefined;
478
- } | undefined;
479
- formBodyField?: {
480
- path: string;
481
- equals?: string | undefined;
482
- } | undefined;
483
- }[] | undefined;
484
- timeoutMs?: number | undefined;
485
- } | undefined;
486
- } | undefined;
487
- };
407
+ triggerGroupId: string;
488
408
  description?: string | undefined;
489
409
  instructions?: string[] | undefined;
490
410
  constraints?: string[] | undefined;
@@ -501,6 +421,25 @@ declare let expectSlateContract: (d: {
501
421
  authMethods?: string[] | undefined;
502
422
  adapter?: string | null | undefined;
503
423
  }[];
424
+ triggerGroups: {
425
+ id: string;
426
+ name: string;
427
+ invocation: {
428
+ type: "polling";
429
+ intervalSeconds: number;
430
+ } | {
431
+ type: "webhook";
432
+ registration: {
433
+ mode: "auto";
434
+ } | {
435
+ mode: "manual";
436
+ userConfigSchema: Record<string, any>;
437
+ fullConfigSchema: Record<string, any>;
438
+ };
439
+ };
440
+ description?: string | undefined;
441
+ metadata?: Record<string, any> | undefined;
442
+ }[];
504
443
  authMethods: {
505
444
  id: string;
506
445
  name: string;
@@ -534,13 +473,15 @@ declare let expectSlateContract: (d: {
534
473
  }[];
535
474
  configSchema: Record<string, any>;
536
475
  }>;
537
- declare let registerSlateTriggerWebhook: (d: {
476
+ declare let registerSlateTriggerGroupWebhook: (d: {
538
477
  client: SlatesTestClient;
539
- triggerId: string;
540
- webhookBaseUrl: string;
478
+ triggerGroupId: string;
479
+ webhookTargetIdentifier: string;
480
+ webhookTargetPayload: any;
481
+ webhookUrl: string;
541
482
  }) => Promise<{
542
- registrationDetails: any;
543
- state?: any;
483
+ webhookRegistrationIdentifier: string;
484
+ webhookRegistrationPayload: any;
544
485
  requestTraces?: {
545
486
  startedAt: string;
546
487
  durationMs: number;
@@ -570,12 +511,16 @@ declare let registerSlateTriggerWebhook: (d: {
570
511
  } | undefined;
571
512
  }[] | undefined;
572
513
  }>;
573
- declare let pollSlateTriggerEvents: (d: {
514
+ declare let pollSlateTriggerGroupEvents: (d: {
574
515
  client: SlatesTestClient;
575
- triggerId: string;
516
+ triggerGroupId: string;
576
517
  state?: any;
577
518
  }) => Promise<{
578
- inputs: Record<string, any>[];
519
+ events: {
520
+ payload: Record<string, any>;
521
+ triggerIds: string[];
522
+ idempotencyKey?: string | undefined;
523
+ }[];
579
524
  updatedState?: any;
580
525
  requestTraces?: {
581
526
  startedAt: string;
@@ -606,18 +551,21 @@ declare let pollSlateTriggerEvents: (d: {
606
551
  } | undefined;
607
552
  }[] | undefined;
608
553
  }>;
609
- declare let handleSlateTriggerWebhook: (d: {
554
+ declare let processSlateTriggerGroupWebhook: (d: {
610
555
  client: SlatesTestClient;
611
- triggerId: string;
556
+ triggerGroupId: string;
612
557
  url: string;
613
558
  method?: string;
614
559
  headers?: Record<string, string>;
615
560
  body?: string | Uint8Array | null;
616
- state?: any;
617
- registrationDetails?: any;
561
+ webhookRegistrationPayload?: any;
618
562
  }) => Promise<{
619
- inputs: Record<string, any>[];
620
- updatedState?: any;
563
+ events: {
564
+ matchers: Record<string, any>[];
565
+ payload: Record<string, any>;
566
+ triggerIds: string[];
567
+ idempotencyKey?: string | undefined;
568
+ }[];
621
569
  response?: {
622
570
  status: number;
623
571
  headers: Record<string, string>;
@@ -655,12 +603,11 @@ declare let handleSlateTriggerWebhook: (d: {
655
603
  } | undefined;
656
604
  }[] | undefined;
657
605
  }>;
658
- declare let unregisterSlateTriggerWebhook: (d: {
606
+ declare let unregisterSlateTriggerGroupWebhook: (d: {
659
607
  client: SlatesTestClient;
660
- triggerId: string;
661
- webhookBaseUrl: string;
662
- registrationDetails: any;
663
- state?: any;
608
+ triggerGroupId: string;
609
+ webhookRegistrationIdentifier: string;
610
+ webhookRegistrationPayload: any;
664
611
  }) => Promise<{
665
612
  requestTraces?: {
666
613
  startedAt: string;
@@ -743,4 +690,4 @@ declare let getMcpCompatibleToolSchemaCases: (source: ToolSchemaSource) => Reado
743
690
  declare let expectMcpCompatibleToolSchema: (tool: ToolSchemaTarget) => void;
744
691
  declare let describeMcpCompatibleToolSchemas: (name: string, source: ToolSchemaSource) => void;
745
692
 
746
- export { type ExpectedSlateAction, type SlatesRuntimeContext, type SlatesTestClient, createLocalSlateTestClient, createSlatesTestClient, describeMcpCompatibleToolSchemas, expectMcpCompatibleToolSchema, expectSlateContract, expectSlateError, expectToolCall, getMcpCompatibleToolSchemaCases, getSlateContract, getVitestExpect, handleSlateTriggerWebhook, loadSlatesProfile, loadSlatesRuntimeContext, mapSlateTriggerEvent, pollSlateTriggerEvents, registerSlateTriggerWebhook, unregisterSlateTriggerWebhook, withSlateProfile };
693
+ 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 };