@slates/provider 1.0.0-rc.16 → 1.0.0-rc.18

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.
Files changed (42) hide show
  1. package/dist/index.cjs +639 -21
  2. package/dist/index.d.cts +290 -29
  3. package/dist/index.d.ts +290 -29
  4. package/dist/index.module.js +606 -18
  5. package/package.json +2 -2
  6. package/src/action/action.ts +64 -2
  7. package/src/action/builder.test.ts +136 -0
  8. package/src/action/builder.ts +73 -13
  9. package/src/action/index.ts +2 -1
  10. package/src/action/publicTool.ts +36 -0
  11. package/src/action/tool.ts +15 -3
  12. package/src/action/trigger.ts +9 -1
  13. package/src/adapter/adapter.ts +38 -0
  14. package/src/adapter/index.test.ts +322 -0
  15. package/src/adapter/index.ts +2 -0
  16. package/src/adapter/spec.ts +154 -0
  17. package/src/auth/index.ts +1 -0
  18. package/src/auth/oauth.test.ts +83 -0
  19. package/src/auth/oauth.ts +150 -0
  20. package/src/auth/types.ts +22 -6
  21. package/src/axios/http.test.ts +83 -0
  22. package/src/axios/index.ts +59 -1
  23. package/src/axios/trace.ts +3 -3
  24. package/src/context/context.ts +37 -14
  25. package/src/context/hook.ts +5 -10
  26. package/src/crypto/hmac.test.ts +40 -0
  27. package/src/crypto/hmac.ts +32 -0
  28. package/src/crypto/index.ts +1 -0
  29. package/src/error/api.test.ts +114 -0
  30. package/src/error/api.ts +236 -0
  31. package/src/error/index.ts +1 -0
  32. package/src/file/index.test.ts +36 -0
  33. package/src/file/index.ts +27 -0
  34. package/src/index.ts +5 -0
  35. package/src/object/index.test.ts +38 -0
  36. package/src/object/index.ts +12 -0
  37. package/src/specification/slate.ts +38 -2
  38. package/src/webhook/graph.test.ts +37 -0
  39. package/src/webhook/graph.ts +22 -0
  40. package/src/webhook/index.ts +2 -0
  41. package/src/webhook/meta.test.ts +52 -0
  42. package/src/webhook/meta.ts +43 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slates/provider",
3
- "version": "1.0.0-rc.16",
3
+ "version": "1.0.0-rc.18",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -42,4 +42,4 @@
42
42
  "typescript": "5.8.2",
43
43
  "vitest": "^3.1.2"
44
44
  }
45
- }
45
+ }
@@ -1,5 +1,5 @@
1
1
  import type { z } from 'zod';
2
- import type { SlateContext } from '../context';
2
+ import type { SlateContext, SlatePublicContext } from '../context';
3
3
  import type { SlateActionDocsReference } from '../docs';
4
4
  import type { SlateSpecification } from '../specification/specification';
5
5
  import type { SlateAttachment } from './attachment';
@@ -29,6 +29,8 @@ export interface SlateActionParameters {
29
29
  scopes?: SlateActionScopes;
30
30
  authMethods?: string[];
31
31
  docs?: SlateActionDocsReference[];
32
+ adapter?: string | null;
33
+ isPublic?: boolean;
32
34
  }
33
35
 
34
36
  export type SlateToolInvocationHandler<
@@ -42,6 +44,14 @@ export type SlateToolInvocationHandler<
42
44
  attachments?: SlateAttachment[];
43
45
  }>;
44
46
 
47
+ export type SlatePublicToolInvocationHandler<InputType extends {}, OutputType extends {}> = (
48
+ context: SlatePublicContext<InputType>
49
+ ) => Promise<{
50
+ output: OutputType;
51
+ message: string;
52
+ attachments?: SlateAttachment[];
53
+ }>;
54
+
45
55
  export type SlateTriggerMappingHandler<
46
56
  ConfigType extends {},
47
57
  AuthType extends {},
@@ -62,15 +72,58 @@ export type SlateTriggerPollingHandler<
62
72
  updatedState?: any;
63
73
  }>;
64
74
 
75
+ export interface SlateWebhookHttpResponseInit {
76
+ status?: number;
77
+ headers?: Record<string, string>;
78
+ body?: string | Uint8Array | null;
79
+ }
80
+
81
+ export type SlateWebhookHttpMethod =
82
+ | 'GET'
83
+ | 'POST'
84
+ | 'PUT'
85
+ | 'PATCH'
86
+ | 'DELETE'
87
+ | 'HEAD'
88
+ | 'OPTIONS';
89
+
90
+ export interface SlateWebhookRequestMatcher {
91
+ method?: string;
92
+ hasQueryParam?: string;
93
+ hasHeader?: string;
94
+ jsonBodyField?: {
95
+ path: string;
96
+ equals?: string;
97
+ };
98
+ formBodyField?: {
99
+ path: string;
100
+ equals?: string;
101
+ };
102
+ }
103
+
104
+ export interface SlateWebhookHttpOptions {
105
+ methods?: SlateWebhookHttpMethod[];
106
+ sync?: {
107
+ mode: 'never' | 'match' | 'always';
108
+ match?: SlateWebhookRequestMatcher[];
109
+ timeoutMs?: number;
110
+ };
111
+ }
112
+
65
113
  export type SlateTriggerWebhookRequestHandler<
66
114
  ConfigType extends {},
67
115
  AuthType extends {},
68
116
  InputType extends {}
69
117
  > = (
70
- context: SlateContext<ConfigType, AuthType, { request: Request; state: any | null }>
118
+ context: SlateContext<
119
+ ConfigType,
120
+ AuthType,
121
+ { request: Request; state: any | null; registrationDetails: any | null }
122
+ >
71
123
  ) => Promise<{
72
124
  inputs: InputType[];
73
125
  updatedState?: any;
126
+ response?: Response | SlateWebhookHttpResponseInit;
74
127
  }>;
75
128
 
76
129
  export type SlateTriggerWebhookAutoRegistrationHandler<
@@ -117,6 +170,7 @@ export interface SlateActionParametersTrigger<
117
170
  polling?: SlatePollingOptions;
118
171
  handleEvent: SlateTriggerMappingHandler<ConfigType, AuthType, InputType, OutputType>;
119
172
  handleRequest?: SlateTriggerWebhookRequestHandler<ConfigType, AuthType, InputType>;
173
+ http?: SlateWebhookHttpOptions;
120
174
  pollEvents?: SlateTriggerPollingHandler<ConfigType, AuthType, InputType>;
121
175
  autoRegisterWebhook?: SlateTriggerWebhookAutoRegistrationHandler<ConfigType, AuthType>;
122
176
  autoUnregisterWebhook?: SlateTriggerWebhookAutoUnregistrationHandler<ConfigType, AuthType>;
@@ -214,4 +268,12 @@ export abstract class SlateAction<
214
268
  get docs() {
215
269
  return this._params.docs;
216
270
  }
271
+
272
+ get adapter() {
273
+ return this._params.adapter ?? null;
274
+ }
275
+
276
+ get isPublic() {
277
+ return this._params.isPublic === true;
278
+ }
217
279
  }
@@ -0,0 +1,136 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { z } from 'zod';
3
+ import { SlateAuth } from '../auth';
4
+ import { SlateConfig } from '../config';
5
+ import { SlatePublicContext } from '../context';
6
+ import { SlateSpecification } from '../specification/specification';
7
+ import { SlatePublicTool } from './publicTool';
8
+ import { SlateTool } from './tool';
9
+
10
+ let createTestSpec = () => {
11
+ let config = SlateConfig.create(
12
+ z.object({
13
+ prefix: z.string()
14
+ })
15
+ );
16
+ let auth = SlateAuth.create<{ token: string }>().output(
17
+ z.object({
18
+ token: z.string()
19
+ })
20
+ );
21
+
22
+ return SlateSpecification.create({
23
+ key: 'demo',
24
+ name: 'Demo',
25
+ config,
26
+ auth
27
+ });
28
+ };
29
+
30
+ describe('SlateActionBuilder.lockInterface', () => {
31
+ it('prevents changing input and output schemas after the interface is locked', () => {
32
+ let spec = createTestSpec();
33
+ let builder = SlateTool.create(spec, {
34
+ key: 'send',
35
+ name: 'Send'
36
+ })
37
+ .input(z.object({ to: z.string() }))
38
+ .output(z.object({ id: z.string() }))
39
+ .lockInterface();
40
+
41
+ expect(() => builder.input(z.object({}))).toThrow(
42
+ 'Adapter contract input schema cannot be changed'
43
+ );
44
+ expect(() => builder.output(z.object({}))).toThrow(
45
+ 'Adapter contract output schema cannot be changed'
46
+ );
47
+ });
48
+ });
49
+
50
+ describe('SlatePublicTool', () => {
51
+ it('builds a public tool that omits config and auth from the handler context', async () => {
52
+ let spec = createTestSpec();
53
+ let tool = SlatePublicTool.create(spec, {
54
+ key: 'setup',
55
+ name: 'Setup'
56
+ })
57
+ .input(
58
+ z.object({
59
+ name: z.string()
60
+ })
61
+ )
62
+ .output(
63
+ z.object({
64
+ greeting: z.string()
65
+ })
66
+ )
67
+ .handleInvocation(async ctx => {
68
+ expect(ctx).not.toHaveProperty('config');
69
+ expect(ctx).not.toHaveProperty('auth');
70
+
71
+ return {
72
+ output: { greeting: `Hello ${ctx.input.name}` },
73
+ message: 'ok'
74
+ };
75
+ })
76
+ .build();
77
+
78
+ expect(tool.isPublic).toBe(true);
79
+ expect(tool.key).toBe('setup');
80
+
81
+ let result = await tool.handleInvocation(
82
+ new SlatePublicContext({ name: 'Ada' }, spec, {
83
+ debug: () => {},
84
+ error: () => {},
85
+ info: () => {},
86
+ progress: () => {},
87
+ warn: () => {}
88
+ } as any) as any
89
+ );
90
+
91
+ expect(result.output).toEqual({ greeting: 'Hello Ada' });
92
+ });
93
+
94
+ it('keeps regular tools private by default', () => {
95
+ let spec = createTestSpec();
96
+ let tool = SlateTool.create(spec, {
97
+ key: 'send',
98
+ name: 'Send'
99
+ })
100
+ .input(z.object({}))
101
+ .output(z.object({}))
102
+ .handleInvocation(async () => ({
103
+ output: {},
104
+ message: 'ok'
105
+ }))
106
+ .build();
107
+
108
+ expect(tool.isPublic).toBe(false);
109
+ });
110
+
111
+ it('rejects authentication methods on public tools', () => {
112
+ let spec = createTestSpec();
113
+
114
+ expect(() =>
115
+ SlatePublicTool.create(spec, {
116
+ key: 'setup',
117
+ name: 'Setup'
118
+ }).authMethods(['token_auth'])
119
+ ).toThrow('Public tools cannot require authentication methods');
120
+
121
+ expect(() =>
122
+ SlatePublicTool.create(spec, {
123
+ key: 'setup',
124
+ name: 'Setup',
125
+ authMethods: ['token_auth']
126
+ })
127
+ .input(z.object({}))
128
+ .output(z.object({}))
129
+ .handleInvocation(async () => ({
130
+ output: {},
131
+ message: 'ok'
132
+ }))
133
+ .build()
134
+ ).toThrow('Public tools cannot require authentication methods');
135
+ });
136
+ });
@@ -10,12 +10,14 @@ import type {
10
10
  SlateActionScopes,
11
11
  SlateActionType,
12
12
  SlatePollingOptions,
13
+ SlatePublicToolInvocationHandler,
13
14
  SlateToolInvocationHandler,
14
15
  SlateTriggerMappingHandler,
15
16
  SlateTriggerPollingHandler,
16
17
  SlateTriggerWebhookAutoRegistrationHandler,
17
18
  SlateTriggerWebhookAutoUnregistrationHandler,
18
- SlateTriggerWebhookRequestHandler
19
+ SlateTriggerWebhookRequestHandler,
20
+ SlateWebhookHttpOptions
19
21
  } from './action';
20
22
  import { validateScopes } from './scopes';
21
23
 
@@ -25,7 +27,8 @@ export class SlateActionBuilder<
25
27
  AuthType extends {},
26
28
  InputType extends {},
27
29
  OutputType extends {},
28
- Result extends SlateAction<Type, ConfigType, AuthType, any, any>
30
+ Result extends SlateAction<Type, ConfigType, AuthType, any, any>,
31
+ IsPublic extends boolean = false
29
32
  > {
30
33
  #configSchema: z.ZodType<ConfigType>;
31
34
  #authSchema: z.ZodType<AuthType>;
@@ -42,6 +45,7 @@ export class SlateActionBuilder<
42
45
  InputType,
43
46
  OutputType
44
47
  > | null = null;
48
+ #interfaceLocked = false;
45
49
 
46
50
  constructor(
47
51
  private readonly type: Type,
@@ -49,7 +53,8 @@ export class SlateActionBuilder<
49
53
  private readonly params: SlateActionParameters,
50
54
  private readonly factory: (
51
55
  params: SlateActionCreateParameters<any, any, any, any>
52
- ) => Result
56
+ ) => Result,
57
+ private readonly isPublicTool: IsPublic = false as IsPublic
53
58
  ) {
54
59
  this.#configSchema = spec.configSchema;
55
60
  this.#authSchema = spec.authSchema;
@@ -57,21 +62,58 @@ export class SlateActionBuilder<
57
62
 
58
63
  input<NewInputType extends {}>(
59
64
  schema: z.ZodType<NewInputType>
60
- ): SlateActionBuilder<Type, ConfigType, AuthType, NewInputType, OutputType, Result> {
65
+ ): SlateActionBuilder<
66
+ Type,
67
+ ConfigType,
68
+ AuthType,
69
+ NewInputType,
70
+ OutputType,
71
+ Result,
72
+ IsPublic
73
+ > {
74
+ if (this.#interfaceLocked) {
75
+ throw new SlateDeclarationError('Adapter contract input schema cannot be changed');
76
+ }
77
+
61
78
  this.#inputSchema = schema as any;
62
79
  return this as any;
63
80
  }
64
81
 
65
82
  output<NewOutputType extends {}>(
66
83
  schema: z.ZodType<NewOutputType>
67
- ): SlateActionBuilder<Type, ConfigType, AuthType, InputType, NewOutputType, Result> {
84
+ ): SlateActionBuilder<
85
+ Type,
86
+ ConfigType,
87
+ AuthType,
88
+ InputType,
89
+ NewOutputType,
90
+ Result,
91
+ IsPublic
92
+ > {
93
+ if (this.#interfaceLocked) {
94
+ throw new SlateDeclarationError('Adapter contract output schema cannot be changed');
95
+ }
96
+
68
97
  this.#outputSchema = schema as any;
69
98
  return this as any;
70
99
  }
71
100
 
101
+ lockInterface(): SlateActionBuilder<
102
+ Type,
103
+ ConfigType,
104
+ AuthType,
105
+ InputType,
106
+ OutputType,
107
+ Result,
108
+ IsPublic
109
+ > {
110
+ this.#interfaceLocked = true;
111
+ return this;
112
+ }
113
+
72
114
  scopes(
73
115
  scopes: SlateActionScopes
74
- ): SlateActionBuilder<Type, ConfigType, AuthType, InputType, OutputType, Result> {
116
+ ): SlateActionBuilder<Type, ConfigType, AuthType, InputType, OutputType, Result, IsPublic> {
75
117
  validateScopes(scopes);
76
118
  this.#scopes = scopes;
77
119
  return this;
@@ -79,7 +121,11 @@ export class SlateActionBuilder<
79
121
 
80
122
  authMethods(
81
123
  authMethods: string[]
82
- ): SlateActionBuilder<Type, ConfigType, AuthType, InputType, OutputType, Result> {
124
+ ): SlateActionBuilder<Type, ConfigType, AuthType, InputType, OutputType, Result, IsPublic> {
125
+ if (this.isPublicTool) {
126
+ throw new SlateDeclarationError('Public tools cannot require authentication methods');
127
+ }
128
+
83
129
  this.#authMethods = this.validateAuthMethods(authMethods);
84
130
  return this;
85
131
  }
@@ -96,15 +142,22 @@ export class SlateActionBuilder<
96
142
  }
97
143
 
98
144
  handleInvocation(
99
- handler: SlateToolInvocationHandler<ConfigType, AuthType, InputType, OutputType>
100
- ): SlateActionBuilder<Type, ConfigType, AuthType, InputType, OutputType, Result> {
145
+ handler: IsPublic extends true
146
+ ? SlatePublicToolInvocationHandler<InputType, OutputType>
147
+ : SlateToolInvocationHandler<ConfigType, AuthType, InputType, OutputType>
148
+ ): SlateActionBuilder<Type, ConfigType, AuthType, InputType, OutputType, Result, IsPublic> {
101
149
  if (this.type !== 'tool') {
102
150
  throw new SlateDeclarationError('handleInvocation can only be set for tool actions');
103
151
  }
104
152
 
105
153
  this.#toolParams = {
106
154
  type: 'tool',
107
- handleInvocation: handler
155
+ handleInvocation: handler as SlateToolInvocationHandler<
156
+ ConfigType,
157
+ AuthType,
158
+ InputType,
159
+ OutputType
160
+ >
108
161
  };
109
162
 
110
163
  return this;
@@ -115,7 +168,8 @@ export class SlateActionBuilder<
115
168
  handleRequest: SlateTriggerWebhookRequestHandler<ConfigType, AuthType, InputType>;
116
169
  autoRegisterWebhook?: SlateTriggerWebhookAutoRegistrationHandler<ConfigType, AuthType>;
117
170
  autoUnregisterWebhook?: SlateTriggerWebhookAutoUnregistrationHandler<ConfigType, AuthType>;
118
- }): SlateActionBuilder<Type, ConfigType, AuthType, InputType, OutputType, Result> {
171
+ http?: SlateWebhookHttpOptions;
172
+ }): SlateActionBuilder<Type, ConfigType, AuthType, InputType, OutputType, Result, IsPublic> {
119
173
  if (this.type !== 'trigger') {
120
174
  throw new SlateDeclarationError('handleEvent can only be set for trigger actions');
121
175
  }
@@ -126,7 +180,8 @@ export class SlateActionBuilder<
126
180
  handleEvent: props.handleEvent,
127
181
  handleRequest: props.handleRequest,
128
182
  autoRegisterWebhook: props.autoRegisterWebhook,
129
- autoUnregisterWebhook: props.autoUnregisterWebhook
183
+ autoUnregisterWebhook: props.autoUnregisterWebhook,
184
+ http: props.http
130
185
  };
131
186
 
132
187
  return this;
@@ -136,7 +191,7 @@ export class SlateActionBuilder<
136
191
  options?: SlatePollingOptions;
137
192
  pollEvents?: SlateTriggerPollingHandler<ConfigType, AuthType, InputType>;
138
193
  handleEvent: SlateTriggerMappingHandler<ConfigType, AuthType, InputType, OutputType>;
139
- }): SlateActionBuilder<Type, ConfigType, AuthType, InputType, OutputType, Result> {
194
+ }): SlateActionBuilder<Type, ConfigType, AuthType, InputType, OutputType, Result, IsPublic> {
140
195
  if (this.type !== 'trigger') {
141
196
  throw new SlateDeclarationError('handleEvent can only be set for trigger actions');
142
197
  }
@@ -159,6 +214,10 @@ export class SlateActionBuilder<
159
214
  }
160
215
  let authMethods = this.validateAuthMethods(this.#authMethods ?? this.params.authMethods);
161
216
 
217
+ if (this.isPublicTool && authMethods) {
218
+ throw new SlateDeclarationError('Public tools cannot require authentication methods');
219
+ }
220
+
162
221
  if (!this.#inputSchema) {
163
222
  throw new SlateDeclarationError('Input schema is not defined');
164
223
  }
@@ -176,6 +235,7 @@ export class SlateActionBuilder<
176
235
  ...this.params,
177
236
  scopes,
178
237
  authMethods,
238
+ isPublic: this.isPublicTool === true,
179
239
  configSchema: this.#configSchema,
180
240
  authSchema: this.#authSchema,
181
241
  inputSchema: this.#inputSchema,
@@ -1,5 +1,6 @@
1
1
  export * from './action';
2
- export type * from './builder';
2
+ export * from './builder';
3
+ export * from './publicTool';
3
4
  export * from './scopes';
4
5
  export * from './tool';
5
6
  export * from './trigger';
@@ -0,0 +1,36 @@
1
+ import type { SlateSpecification } from '../specification/specification';
2
+ import type { SlateActionParameters, SlatePublicToolInvocationHandler } from './action';
3
+ import { SlateActionBuilder } from './builder';
4
+ import { SlateTool } from './tool';
5
+
6
+ export interface SlatePublicToolParameters<InputType extends {}, OutputType extends {}>
7
+ extends SlateActionParameters {
8
+ handleInvocation: SlatePublicToolInvocationHandler<InputType, OutputType>;
9
+ }
10
+
11
+ export class SlatePublicTool {
12
+ private constructor() {}
13
+
14
+ static create<ConfigType extends {}, AuthType extends {}>(
15
+ spec: SlateSpecification<ConfigType, AuthType>,
16
+ params: SlateActionParameters
17
+ ) {
18
+ return new SlateActionBuilder(
19
+ 'tool',
20
+ spec,
21
+ params,
22
+ params => {
23
+ return SlateTool.fromCreateParameters(spec, {
24
+ ...params,
25
+ isPublic: true
26
+ });
27
+ },
28
+ true
29
+ );
30
+ }
31
+ }
32
+
33
+ export let publicTool = <ConfigType extends {}, AuthType extends {}>(
34
+ spec: SlateSpecification<ConfigType, AuthType>,
35
+ params: SlateActionParameters
36
+ ) => SlatePublicTool.create(spec, params);
@@ -24,7 +24,7 @@ export class SlateTool<
24
24
  > extends SlateAction<'tool', ConfigType, AuthType, InputType, OutputType> {
25
25
  #handleInvocation: SlateToolInvocationHandler<ConfigType, AuthType, InputType, OutputType>;
26
26
 
27
- private constructor(
27
+ protected constructor(
28
28
  spec: SlateSpecification<ConfigType, AuthType>,
29
29
  inputSchema: z.ZodType<InputType>,
30
30
  outputSchema: z.ZodType<OutputType>,
@@ -40,11 +40,23 @@ export class SlateTool<
40
40
  params: SlateActionParameters
41
41
  ) {
42
42
  return new SlateActionBuilder('tool', spec, params, params => {
43
- if (params.type !== 'tool') throw new Error('Invalid action type for tool');
44
- return new SlateTool(spec, params.inputSchema, params.outputSchema, params);
43
+ return SlateTool.fromCreateParameters(spec, params);
45
44
  });
46
45
  }
47
46
 
47
+ static fromCreateParameters<ConfigType extends {}, AuthType extends {}>(
48
+ spec: SlateSpecification<ConfigType, AuthType>,
49
+ params: {
50
+ type: string;
51
+ inputSchema: z.ZodType<any>;
52
+ outputSchema: z.ZodType<any>;
53
+ handleInvocation?: SlateToolInvocationHandler<ConfigType, AuthType, any, any>;
54
+ } & SlateActionParameters
55
+ ) {
56
+ if (params.type !== 'tool') throw new Error('Invalid action type for tool');
57
+ return new SlateTool(spec, params.inputSchema, params.outputSchema, params as any);
58
+ }
59
+
48
60
  get handleInvocation() {
49
61
  return this.#handleInvocation;
50
62
  }
@@ -8,7 +8,8 @@ import {
8
8
  type SlateTriggerPollingHandler,
9
9
  type SlateTriggerWebhookAutoRegistrationHandler,
10
10
  type SlateTriggerWebhookAutoUnregistrationHandler,
11
- type SlateTriggerWebhookRequestHandler
11
+ type SlateTriggerWebhookRequestHandler,
12
+ type SlateWebhookHttpOptions
12
13
  } from './action';
13
14
  import { SlateActionBuilder } from './builder';
14
15
 
@@ -27,6 +28,7 @@ export interface SlateTriggerParameters<
27
28
  polling?: SlatePollingOptions;
28
29
  handleEvent: SlateTriggerMappingHandler<ConfigType, AuthType, InputType, OutputType>;
29
30
  handleRequest?: SlateTriggerWebhookRequestHandler<ConfigType, AuthType, InputType>;
31
+ http?: SlateWebhookHttpOptions;
30
32
  pollEvents?: SlateTriggerPollingHandler<ConfigType, AuthType, InputType>;
31
33
  autoRegisterWebhook?: SlateTriggerWebhookAutoRegistrationHandler<ConfigType, AuthType>;
32
34
  autoUnregisterWebhook?: SlateTriggerWebhookAutoUnregistrationHandler<ConfigType, AuthType>;
@@ -44,6 +46,7 @@ export class SlateTrigger<
44
46
  #polling: SlatePollingOptions;
45
47
  #handleEvent: SlateTriggerMappingHandler<ConfigType, AuthType, InputType, OutputType>;
46
48
  #handleRequest?: SlateTriggerWebhookRequestHandler<ConfigType, AuthType, InputType>;
49
+ #http?: SlateWebhookHttpOptions;
47
50
  #pollEvents?: SlateTriggerPollingHandler<ConfigType, AuthType, InputType>;
48
51
  #autoRegisterWebhook?: SlateTriggerWebhookAutoRegistrationHandler<ConfigType, AuthType>;
49
52
  #autoUnregisterWebhook?: SlateTriggerWebhookAutoUnregistrationHandler<ConfigType, AuthType>;
@@ -62,6 +65,7 @@ export class SlateTrigger<
62
65
  };
63
66
  this.#handleEvent = params.handleEvent;
64
67
  this.#handleRequest = params.handleRequest;
68
+ this.#http = params.http;
65
69
  this.#pollEvents = params.pollEvents;
66
70
  this.#autoRegisterWebhook = params.autoRegisterWebhook;
67
71
  this.#autoUnregisterWebhook = params.autoUnregisterWebhook;
@@ -93,6 +97,10 @@ export class SlateTrigger<
93
97
  return this.#handleRequest;
94
98
  }
95
99
 
100
+ get http() {
101
+ return this.#http;
102
+ }
103
+
96
104
  get pollEvents() {
97
105
  return this.#pollEvents;
98
106
  }
@@ -0,0 +1,38 @@
1
+ import type { SlateTool, SlateTrigger } from '../action';
2
+ import type { SlateAdapterSpec } from './spec';
3
+
4
+ export class SlateAdapter<ConfigType extends {}, AuthType extends {}> {
5
+ constructor(
6
+ private readonly _spec: SlateAdapterSpec,
7
+ private readonly _tools: SlateTool<ConfigType, AuthType, any, any>[],
8
+ private readonly _triggers: SlateTrigger<ConfigType, AuthType, any, any>[]
9
+ ) {}
10
+
11
+ get spec() {
12
+ return this._spec;
13
+ }
14
+
15
+ get id() {
16
+ return this._spec.id;
17
+ }
18
+
19
+ get name() {
20
+ return this._spec.name;
21
+ }
22
+
23
+ get capabilities() {
24
+ return this._spec.capabilities;
25
+ }
26
+
27
+ get tools() {
28
+ return this._tools;
29
+ }
30
+
31
+ get triggers() {
32
+ return this._triggers;
33
+ }
34
+
35
+ get actions() {
36
+ return [...this._triggers, ...this._tools];
37
+ }
38
+ }