@slates/provider-handler 1.0.0-rc.3 → 1.0.0-rc.32
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 +1475 -2
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +6 -3
- package/dist/index.module.js +1452 -2
- package/package.json +11 -10
- package/src/attachments.test.ts +171 -0
- package/src/index.ts +1060 -137
- package/src/pQueue.test.ts +18 -0
- package/src/pQueue.ts +18 -0
- package/src/spec.test.ts +83 -0
- package/src/spec.ts +150 -21
- package/src/validation.ts +1 -1
- package/src/webhook.test.ts +65 -0
- package/src/webhook.ts +69 -0
- package/dist/action/action.d.ts +0 -90
- package/dist/action/action.d.ts.map +0 -1
- package/dist/action/builder.d.ts +0 -27
- package/dist/action/builder.d.ts.map +0 -1
- package/dist/action/index.d.ts +0 -5
- package/dist/action/index.d.ts.map +0 -1
- package/dist/action/tool.d.ts +0 -11
- package/dist/action/tool.d.ts.map +0 -1
- package/dist/action/trigger.d.ts +0 -14
- package/dist/action/trigger.d.ts.map +0 -1
- package/dist/auth/auth.d.ts +0 -26
- package/dist/auth/auth.d.ts.map +0 -1
- package/dist/auth/index.d.ts +0 -3
- package/dist/auth/index.d.ts.map +0 -1
- package/dist/auth/types.d.ts +0 -148
- package/dist/auth/types.d.ts.map +0 -1
- package/dist/axios/index.d.ts +0 -4
- package/dist/axios/index.d.ts.map +0 -1
- package/dist/config/config.d.ts +0 -22
- package/dist/config/config.d.ts.map +0 -1
- package/dist/config/index.d.ts +0 -2
- package/dist/config/index.d.ts.map +0 -1
- package/dist/context/context.d.ts +0 -20
- package/dist/context/context.d.ts.map +0 -1
- package/dist/context/hook.d.ts +0 -4
- package/dist/context/hook.d.ts.map +0 -1
- package/dist/context/index.d.ts +0 -2
- package/dist/context/index.d.ts.map +0 -1
- package/dist/error/base.d.ts +0 -5
- package/dist/error/base.d.ts.map +0 -1
- package/dist/error/declaration.d.ts +0 -6
- package/dist/error/declaration.d.ts.map +0 -1
- package/dist/error/index.d.ts +0 -3
- package/dist/error/index.d.ts.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.modern.js +0 -2
- package/dist/index.modern.js.map +0 -1
- package/dist/index.module.js.map +0 -1
- package/dist/index.umd.js +0 -2
- package/dist/index.umd.js.map +0 -1
- package/dist/spec.d.ts +0 -14
- package/dist/spec.d.ts.map +0 -1
- package/dist/specification/index.d.ts +0 -3
- package/dist/specification/index.d.ts.map +0 -1
- package/dist/specification/slate.d.ts +0 -15
- package/dist/specification/slate.d.ts.map +0 -1
- package/dist/specification/specification.d.ts +0 -30
- package/dist/specification/specification.d.ts.map +0 -1
- package/dist/specification/zero.d.ts +0 -13
- package/dist/specification/zero.d.ts.map +0 -1
- package/dist/state.d.ts +0 -8
- package/dist/state.d.ts.map +0 -1
- package/dist/tokens.d.ts +0 -34
- package/dist/tokens.d.ts.map +0 -1
- package/dist/validation.d.ts +0 -5
- package/dist/validation.d.ts.map +0 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { resolveDefaultExport } from './pQueue';
|
|
3
|
+
|
|
4
|
+
class Example {
|
|
5
|
+
value: number;
|
|
6
|
+
constructor(value: number) {
|
|
7
|
+
this.value = value;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
describe('resolveDefaultExport', () => {
|
|
12
|
+
it('unwraps nested CJS default exports from bundlers', () => {
|
|
13
|
+
expect(resolveDefaultExport<typeof Example>({ default: { default: Example } })).toBe(
|
|
14
|
+
Example
|
|
15
|
+
);
|
|
16
|
+
expect(new (resolveDefaultExport<typeof Example>({ default: Example }))(3).value).toBe(3);
|
|
17
|
+
});
|
|
18
|
+
});
|
package/src/pQueue.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import PQueueImport from 'p-queue';
|
|
2
|
+
|
|
3
|
+
export let resolveDefaultExport = <T>(value: unknown): T => {
|
|
4
|
+
let current = value;
|
|
5
|
+
|
|
6
|
+
for (let i = 0; i < 4; i++) {
|
|
7
|
+
if (typeof current === 'function') return current as T;
|
|
8
|
+
if (current && typeof current === 'object' && 'default' in current) {
|
|
9
|
+
current = (current as { default: unknown }).default;
|
|
10
|
+
continue;
|
|
11
|
+
}
|
|
12
|
+
break;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
throw new TypeError('Module export is not a constructor');
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export let PQueue = resolveDefaultExport<typeof PQueueImport>(PQueueImport);
|
package/src/spec.test.ts
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { isServiceError } from '@lowerdeck/error';
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { getMappableAction, getTriggersForGroup, isMappableTrigger, mapAction } from './spec';
|
|
5
|
+
|
|
6
|
+
let baseAction = {
|
|
7
|
+
key: 'do_thing',
|
|
8
|
+
name: 'Do Thing',
|
|
9
|
+
description: 'desc',
|
|
10
|
+
instructions: undefined,
|
|
11
|
+
constraints: undefined,
|
|
12
|
+
tags: [],
|
|
13
|
+
metadata: {},
|
|
14
|
+
scopes: [],
|
|
15
|
+
authMethods: [],
|
|
16
|
+
docs: [],
|
|
17
|
+
adapter: undefined,
|
|
18
|
+
inputSchema: z.object({}),
|
|
19
|
+
outputSchema: z.object({})
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
let toolAction: any = { ...baseAction, type: 'tool', isPublic: false };
|
|
23
|
+
|
|
24
|
+
let validTriggerGroup = { key: 'my_group', name: 'My Group' };
|
|
25
|
+
let validTrigger: any = {
|
|
26
|
+
...baseAction,
|
|
27
|
+
type: 'trigger',
|
|
28
|
+
triggerGroup: validTriggerGroup,
|
|
29
|
+
matches: () => true,
|
|
30
|
+
map: () => ({})
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
let incompatibleTrigger: any = { ...baseAction, type: 'trigger', triggerGroup: undefined };
|
|
34
|
+
|
|
35
|
+
describe('isMappableTrigger', () => {
|
|
36
|
+
it('is true for tool actions', () => {
|
|
37
|
+
expect(isMappableTrigger(toolAction)).toBe(true);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('is true for triggers with a trigger group', () => {
|
|
41
|
+
expect(isMappableTrigger(validTrigger)).toBe(true);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('is false for triggers missing a trigger group', () => {
|
|
45
|
+
expect(isMappableTrigger(incompatibleTrigger)).toBe(false);
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
describe('mapAction', () => {
|
|
50
|
+
it('maps a well-formed trigger', () => {
|
|
51
|
+
let mapped = mapAction({} as any, validTrigger);
|
|
52
|
+
expect(mapped).toMatchObject({ type: 'action.trigger', triggerGroupId: 'my_group' });
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
describe('getTriggersForGroup', () => {
|
|
57
|
+
it('filters out triggers missing a trigger group instead of throwing', () => {
|
|
58
|
+
let slate = { actions: [toolAction, validTrigger, incompatibleTrigger] } as any;
|
|
59
|
+
|
|
60
|
+
expect(getTriggersForGroup(slate, 'my_group')).toEqual([validTrigger]);
|
|
61
|
+
expect(getTriggersForGroup(slate, 'other_group')).toEqual([]);
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
describe('getMappableAction', () => {
|
|
66
|
+
it('returns tool and well-formed trigger actions', () => {
|
|
67
|
+
let slate = { actions: [toolAction, validTrigger] } as any;
|
|
68
|
+
|
|
69
|
+
expect(getMappableAction(slate, 'do_thing')).toBe(toolAction);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('treats a trigger missing its group as not found instead of crashing', () => {
|
|
73
|
+
let slate = { actions: [incompatibleTrigger] } as any;
|
|
74
|
+
|
|
75
|
+
try {
|
|
76
|
+
getMappableAction(slate, 'do_thing');
|
|
77
|
+
expect.unreachable();
|
|
78
|
+
} catch (e) {
|
|
79
|
+
expect(isServiceError(e)).toBe(true);
|
|
80
|
+
expect((e as any).data.status).toBe(404);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
});
|
package/src/spec.ts
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { badRequestError, notFoundError, ServiceError } from '@lowerdeck/error';
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import type {
|
|
3
|
+
SlateAuthenticationMethod,
|
|
4
|
+
SlatesAction,
|
|
5
|
+
SlateAdapter as SlatesAdapter,
|
|
6
|
+
SlatesTriggerGroup
|
|
7
|
+
} from '@slates/proto';
|
|
8
|
+
import {
|
|
9
|
+
type Slate,
|
|
10
|
+
type SlateAdapter,
|
|
11
|
+
type SlateTrigger,
|
|
12
|
+
SlateDefaultPollingIntervalSeconds
|
|
13
|
+
} from '@slates/provider';
|
|
4
14
|
import z from 'zod';
|
|
5
15
|
import { toJsonSchema } from './validation';
|
|
6
16
|
|
|
@@ -8,7 +18,7 @@ export let getAuthMethod = <ConfigType extends {}, AuthType extends {}>(
|
|
|
8
18
|
slate: Slate<ConfigType, AuthType>,
|
|
9
19
|
authenticationMethodId: string
|
|
10
20
|
) => {
|
|
11
|
-
let authMethod = slate.spec.auth.authStack.find(m => m.key
|
|
21
|
+
let authMethod = slate.spec.auth.authStack.find(m => m.key === authenticationMethodId);
|
|
12
22
|
if (!authMethod) {
|
|
13
23
|
throw new ServiceError(
|
|
14
24
|
badRequestError({
|
|
@@ -49,14 +59,16 @@ export let mapAuthMethod = <ConfigType extends {}, AuthType extends {}>(
|
|
|
49
59
|
enabled: !!m.onInputChanged
|
|
50
60
|
},
|
|
51
61
|
getProfile: { enabled: !!m.getProfile }
|
|
52
|
-
}
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
docs: m.docs ?? []
|
|
53
65
|
});
|
|
54
66
|
|
|
55
67
|
export let getAction = <ConfigType extends {}, AuthType extends {}>(
|
|
56
68
|
slate: Slate<ConfigType, AuthType>,
|
|
57
69
|
actionId: string
|
|
58
70
|
) => {
|
|
59
|
-
let action = slate.actions.find(m => m.key
|
|
71
|
+
let action = slate.actions.find(m => m.key === actionId);
|
|
60
72
|
if (!action) {
|
|
61
73
|
throw new ServiceError(notFoundError(`action`, actionId));
|
|
62
74
|
}
|
|
@@ -64,6 +76,26 @@ export let getAction = <ConfigType extends {}, AuthType extends {}>(
|
|
|
64
76
|
return action;
|
|
65
77
|
};
|
|
66
78
|
|
|
79
|
+
export let getAdapter = <ConfigType extends {}, AuthType extends {}>(
|
|
80
|
+
slate: Slate<ConfigType, AuthType>,
|
|
81
|
+
adapterId: string
|
|
82
|
+
) => {
|
|
83
|
+
let adapter = slate.adapters.find(m => m.id === adapterId);
|
|
84
|
+
if (!adapter) {
|
|
85
|
+
throw new ServiceError(notFoundError(`adapter`, adapterId));
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return adapter;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export let mapAdapter = <ConfigType extends {}, AuthType extends {}>(
|
|
92
|
+
adapter: SlateAdapter<ConfigType, AuthType>
|
|
93
|
+
): SlatesAdapter => ({
|
|
94
|
+
id: adapter.id,
|
|
95
|
+
name: adapter.name,
|
|
96
|
+
capabilities: adapter.capabilities
|
|
97
|
+
});
|
|
98
|
+
|
|
67
99
|
export let getActionWithType = <
|
|
68
100
|
Type extends 'tool' | 'trigger',
|
|
69
101
|
ConfigType extends {},
|
|
@@ -74,7 +106,7 @@ export let getActionWithType = <
|
|
|
74
106
|
actionId: string
|
|
75
107
|
): ReturnType<typeof getAction<ConfigType, AuthType>> & { type: Type } => {
|
|
76
108
|
let action = getAction(slate, actionId);
|
|
77
|
-
if (action.type
|
|
109
|
+
if (action.type !== type) {
|
|
78
110
|
throw new ServiceError(
|
|
79
111
|
badRequestError({
|
|
80
112
|
message: `Action with ID ${actionId} is not of type ${type}`
|
|
@@ -86,7 +118,7 @@ export let getActionWithType = <
|
|
|
86
118
|
};
|
|
87
119
|
|
|
88
120
|
export let mapAction = <ConfigType extends {}, AuthType extends {}>(
|
|
89
|
-
|
|
121
|
+
_slate: Slate<ConfigType, AuthType>,
|
|
90
122
|
a: ReturnType<typeof getAction<ConfigType, AuthType>>
|
|
91
123
|
): SlatesAction => {
|
|
92
124
|
let base = {
|
|
@@ -97,16 +129,21 @@ export let mapAction = <ConfigType extends {}, AuthType extends {}>(
|
|
|
97
129
|
constraints: a.constraints,
|
|
98
130
|
tags: a.tags,
|
|
99
131
|
metadata: a.metadata,
|
|
132
|
+
scopes: a.scopes,
|
|
133
|
+
authMethods: a.authMethods,
|
|
134
|
+
docs: a.docs ?? [],
|
|
135
|
+
...(a.adapter ? { adapter: a.adapter } : {}),
|
|
100
136
|
|
|
101
137
|
inputSchema: toJsonSchema(a.inputSchema),
|
|
102
138
|
outputSchema: toJsonSchema(a.outputSchema)
|
|
103
139
|
};
|
|
104
140
|
|
|
105
|
-
if (a.type
|
|
141
|
+
if (a.type === 'tool') {
|
|
106
142
|
return {
|
|
107
143
|
...base,
|
|
108
144
|
type: 'action.tool',
|
|
109
|
-
capabilities: {}
|
|
145
|
+
capabilities: {},
|
|
146
|
+
isPublic: a.isPublic
|
|
110
147
|
};
|
|
111
148
|
}
|
|
112
149
|
|
|
@@ -114,17 +151,109 @@ export let mapAction = <ConfigType extends {}, AuthType extends {}>(
|
|
|
114
151
|
...base,
|
|
115
152
|
type: 'action.trigger',
|
|
116
153
|
capabilities: {},
|
|
117
|
-
|
|
118
|
-
invocation:
|
|
119
|
-
a.source == 'polling'
|
|
120
|
-
? {
|
|
121
|
-
type: 'polling',
|
|
122
|
-
intervalSeconds: a.polling.intervalInSeconds ?? SlateDefaultPollingIntervalSeconds
|
|
123
|
-
}
|
|
124
|
-
: {
|
|
125
|
-
type: 'webhook',
|
|
126
|
-
autoRegistration: !!a.autoRegisterWebhook,
|
|
127
|
-
autoUnregistration: !!a.autoUnregisterWebhook
|
|
128
|
-
}
|
|
154
|
+
triggerGroupId: a.triggerGroup.key
|
|
129
155
|
};
|
|
130
156
|
};
|
|
157
|
+
|
|
158
|
+
export let isMappableTrigger = <ConfigType extends {}, AuthType extends {}>(
|
|
159
|
+
action: Slate<ConfigType, AuthType>['actions'][number]
|
|
160
|
+
): boolean => action.type !== 'trigger' || !!action.triggerGroup;
|
|
161
|
+
|
|
162
|
+
export let getMappableAction = <ConfigType extends {}, AuthType extends {}>(
|
|
163
|
+
slate: Slate<ConfigType, AuthType>,
|
|
164
|
+
actionId: string
|
|
165
|
+
) => {
|
|
166
|
+
let action = getAction(slate, actionId);
|
|
167
|
+
if (!isMappableTrigger(action)) {
|
|
168
|
+
throw new ServiceError(notFoundError(`action`, actionId));
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
return action;
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
export let getTriggerGroup = <ConfigType extends {}, AuthType extends {}>(
|
|
175
|
+
slate: Slate<ConfigType, AuthType>,
|
|
176
|
+
triggerGroupId: string
|
|
177
|
+
) => {
|
|
178
|
+
let group = slate.triggerGroups.find(g => g.key === triggerGroupId);
|
|
179
|
+
if (!group) {
|
|
180
|
+
throw new ServiceError(notFoundError(`trigger_group`, triggerGroupId));
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
return group;
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
export let getTriggersForGroup = <ConfigType extends {}, AuthType extends {}>(
|
|
187
|
+
slate: Slate<ConfigType, AuthType>,
|
|
188
|
+
triggerGroupId: string
|
|
189
|
+
): SlateTrigger<ConfigType, AuthType, any, any>[] =>
|
|
190
|
+
slate.actions.filter(
|
|
191
|
+
(action): action is SlateTrigger<ConfigType, AuthType, any, any> =>
|
|
192
|
+
action.type === 'trigger' && action.triggerGroup?.key === triggerGroupId
|
|
193
|
+
);
|
|
194
|
+
|
|
195
|
+
export let evaluateTriggerMatches = <ConfigType extends {}, AuthType extends {}>(
|
|
196
|
+
slate: Slate<ConfigType, AuthType>,
|
|
197
|
+
triggerGroupId: string,
|
|
198
|
+
payload: unknown
|
|
199
|
+
): string[] =>
|
|
200
|
+
getTriggersForGroup(slate, triggerGroupId)
|
|
201
|
+
.filter(trigger => trigger.matches(payload))
|
|
202
|
+
.map(trigger => trigger.key);
|
|
203
|
+
|
|
204
|
+
export let getWebhookAutoRegistration = <ConfigType extends {}, AuthType extends {}>(
|
|
205
|
+
group: ReturnType<typeof getTriggerGroup<ConfigType, AuthType>>
|
|
206
|
+
) => {
|
|
207
|
+
if (group.source !== 'webhook' || !group.webhook?.autoRegistration) {
|
|
208
|
+
throw new ServiceError(
|
|
209
|
+
badRequestError({
|
|
210
|
+
message: `Trigger group does not support webhook auto-registration: ${group.key}`
|
|
211
|
+
})
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
return group.webhook.autoRegistration;
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
export let getWebhookManualRegistration = <ConfigType extends {}, AuthType extends {}>(
|
|
219
|
+
group: ReturnType<typeof getTriggerGroup<ConfigType, AuthType>>
|
|
220
|
+
) => {
|
|
221
|
+
if (group.source !== 'webhook' || !group.webhook?.manualRegistration) {
|
|
222
|
+
throw new ServiceError(
|
|
223
|
+
badRequestError({
|
|
224
|
+
message: `Trigger group does not support manual webhook registration: ${group.key}`
|
|
225
|
+
})
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
return group.webhook.manualRegistration;
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
export let mapTriggerGroup = <ConfigType extends {}, AuthType extends {}>(
|
|
233
|
+
group: ReturnType<typeof getTriggerGroup<ConfigType, AuthType>>
|
|
234
|
+
): SlatesTriggerGroup => ({
|
|
235
|
+
id: group.key,
|
|
236
|
+
name: group.name,
|
|
237
|
+
description: group.description,
|
|
238
|
+
metadata: group.metadata,
|
|
239
|
+
invocation:
|
|
240
|
+
group.source === 'polling'
|
|
241
|
+
? {
|
|
242
|
+
type: 'polling',
|
|
243
|
+
intervalSeconds: group.polling?.intervalSeconds ?? SlateDefaultPollingIntervalSeconds
|
|
244
|
+
}
|
|
245
|
+
: {
|
|
246
|
+
type: 'webhook',
|
|
247
|
+
registration: group.webhook?.manualRegistration
|
|
248
|
+
? {
|
|
249
|
+
mode: 'manual',
|
|
250
|
+
userConfigSchema: toJsonSchema(
|
|
251
|
+
group.webhook.manualRegistration.userConfigSchema
|
|
252
|
+
),
|
|
253
|
+
fullConfigSchema: toJsonSchema(
|
|
254
|
+
group.webhook.manualRegistration.fullConfigSchema
|
|
255
|
+
)
|
|
256
|
+
}
|
|
257
|
+
: { mode: 'auto' }
|
|
258
|
+
}
|
|
259
|
+
});
|
package/src/validation.ts
CHANGED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import {
|
|
3
|
+
SLATE_WEBHOOK_RESPONSE_MAX_BODY_BYTES,
|
|
4
|
+
serializeWebhookHttpResponse
|
|
5
|
+
} from './webhook';
|
|
6
|
+
|
|
7
|
+
describe('serializeWebhookHttpResponse', () => {
|
|
8
|
+
it('serializes a Response with status, headers, and body', async () => {
|
|
9
|
+
await expect(
|
|
10
|
+
serializeWebhookHttpResponse(
|
|
11
|
+
new Response('created', {
|
|
12
|
+
status: 201,
|
|
13
|
+
headers: {
|
|
14
|
+
'content-type': 'text/plain',
|
|
15
|
+
'x-webhook-result': 'accepted'
|
|
16
|
+
}
|
|
17
|
+
})
|
|
18
|
+
)
|
|
19
|
+
).resolves.toEqual({
|
|
20
|
+
status: 201,
|
|
21
|
+
headers: {
|
|
22
|
+
'content-type': 'text/plain',
|
|
23
|
+
'x-webhook-result': 'accepted'
|
|
24
|
+
},
|
|
25
|
+
body: {
|
|
26
|
+
encoding: 'base64',
|
|
27
|
+
content: Buffer.from('created').toString('base64')
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('applies defaults to a plain response init', async () => {
|
|
33
|
+
await expect(serializeWebhookHttpResponse({ body: 'ok' })).resolves.toEqual({
|
|
34
|
+
status: 200,
|
|
35
|
+
headers: {},
|
|
36
|
+
body: {
|
|
37
|
+
encoding: 'base64',
|
|
38
|
+
content: Buffer.from('ok').toString('base64')
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('serializes binary response bodies without changing their bytes', async () => {
|
|
44
|
+
await expect(
|
|
45
|
+
serializeWebhookHttpResponse({
|
|
46
|
+
status: 202,
|
|
47
|
+
body: new Uint8Array([0, 127, 128, 255])
|
|
48
|
+
})
|
|
49
|
+
).resolves.toMatchObject({
|
|
50
|
+
status: 202,
|
|
51
|
+
body: {
|
|
52
|
+
encoding: 'base64',
|
|
53
|
+
content: Buffer.from([0, 127, 128, 255]).toString('base64')
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('rejects bodies larger than one MiB', async () => {
|
|
59
|
+
await expect(
|
|
60
|
+
serializeWebhookHttpResponse({
|
|
61
|
+
body: new Uint8Array(SLATE_WEBHOOK_RESPONSE_MAX_BODY_BYTES + 1)
|
|
62
|
+
})
|
|
63
|
+
).rejects.toThrow('Webhook response body exceeds');
|
|
64
|
+
});
|
|
65
|
+
});
|
package/src/webhook.ts
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { badRequestError, ServiceError } from '@lowerdeck/error';
|
|
2
|
+
import type { SlatesWebhookHttpResponse } from '@slates/proto';
|
|
3
|
+
import type { SlateWebhookHttpResponseInit } from '@slates/provider';
|
|
4
|
+
|
|
5
|
+
export let SLATE_WEBHOOK_RESPONSE_MAX_BODY_BYTES = 1024 * 1024;
|
|
6
|
+
|
|
7
|
+
let serializeBody = (body: Uint8Array | null): SlatesWebhookHttpResponse['body'] => {
|
|
8
|
+
if (body === null) return null;
|
|
9
|
+
|
|
10
|
+
if (body.byteLength > SLATE_WEBHOOK_RESPONSE_MAX_BODY_BYTES) {
|
|
11
|
+
throw new ServiceError(
|
|
12
|
+
badRequestError({
|
|
13
|
+
message: `Webhook response body exceeds the ${SLATE_WEBHOOK_RESPONSE_MAX_BODY_BYTES}-byte limit`
|
|
14
|
+
})
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return {
|
|
19
|
+
encoding: 'base64',
|
|
20
|
+
content: Buffer.from(body).toString('base64')
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
let headersToObject = (headers: Headers) => {
|
|
25
|
+
let result: Record<string, string> = {};
|
|
26
|
+
headers.forEach((value, key) => {
|
|
27
|
+
result[key] = value;
|
|
28
|
+
});
|
|
29
|
+
return result;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
let validateStatus = (status: number) => {
|
|
33
|
+
if (!Number.isInteger(status) || status < 100 || status > 599) {
|
|
34
|
+
throw new ServiceError(
|
|
35
|
+
badRequestError({
|
|
36
|
+
message: 'Webhook response status must be an integer between 100 and 599'
|
|
37
|
+
})
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export let serializeWebhookHttpResponse = async (
|
|
43
|
+
response: Response | SlateWebhookHttpResponseInit
|
|
44
|
+
): Promise<SlatesWebhookHttpResponse> => {
|
|
45
|
+
if (response instanceof Response) {
|
|
46
|
+
validateStatus(response.status);
|
|
47
|
+
return {
|
|
48
|
+
status: response.status,
|
|
49
|
+
headers: headersToObject(response.headers),
|
|
50
|
+
body: serializeBody(
|
|
51
|
+
response.body === null ? null : new Uint8Array(await response.arrayBuffer())
|
|
52
|
+
)
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
let status = response.status ?? 200;
|
|
57
|
+
validateStatus(status);
|
|
58
|
+
|
|
59
|
+
let body =
|
|
60
|
+
typeof response.body === 'string'
|
|
61
|
+
? new TextEncoder().encode(response.body)
|
|
62
|
+
: (response.body ?? null);
|
|
63
|
+
|
|
64
|
+
return {
|
|
65
|
+
status,
|
|
66
|
+
headers: response.headers ?? {},
|
|
67
|
+
body: serializeBody(body)
|
|
68
|
+
};
|
|
69
|
+
};
|
package/dist/action/action.d.ts
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { SlateContext } from '../context';
|
|
3
|
-
import { SlateSpecification } from '../specification/specification';
|
|
4
|
-
export type SlateActionType = 'tool' | 'trigger';
|
|
5
|
-
export interface SlateActionParameters {
|
|
6
|
-
key: string;
|
|
7
|
-
name: string;
|
|
8
|
-
description?: string;
|
|
9
|
-
instructions?: string[];
|
|
10
|
-
constraints?: string[];
|
|
11
|
-
tags?: {
|
|
12
|
-
destructive?: boolean;
|
|
13
|
-
readOnly?: boolean;
|
|
14
|
-
[key: string]: boolean | undefined;
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
export type SlateToolInvocationHandler<ConfigType extends {}, AuthType extends {}, InputType extends {}, OutputType extends {}> = (context: SlateContext<ConfigType, AuthType, InputType>) => Promise<{
|
|
18
|
-
output: OutputType;
|
|
19
|
-
message: string;
|
|
20
|
-
}>;
|
|
21
|
-
export type SlateTriggerMappingHandler<ConfigType extends {}, AuthType extends {}, InputType extends {}, OutputType extends {}> = (context: SlateContext<ConfigType, AuthType, InputType>) => Promise<{
|
|
22
|
-
type: string;
|
|
23
|
-
id: string;
|
|
24
|
-
output: OutputType;
|
|
25
|
-
}>;
|
|
26
|
-
export type SlateTriggerPollingHandler<ConfigType extends {}, AuthType extends {}, InputType extends {}> = (context: SlateContext<ConfigType, AuthType, {
|
|
27
|
-
state: any;
|
|
28
|
-
}>) => Promise<{
|
|
29
|
-
inputs: InputType[];
|
|
30
|
-
updatedState?: any;
|
|
31
|
-
}>;
|
|
32
|
-
export type SlateTriggerWebhookRequestHandler<ConfigType extends {}, AuthType extends {}, InputType extends {}> = (context: SlateContext<ConfigType, AuthType, {
|
|
33
|
-
request: Request;
|
|
34
|
-
state: any;
|
|
35
|
-
}>) => Promise<{
|
|
36
|
-
inputs: InputType[];
|
|
37
|
-
updatedState?: any;
|
|
38
|
-
}>;
|
|
39
|
-
export type SlateTriggerWebhookAutoRegistrationHandler<ConfigType extends {}, AuthType extends {}> = (context: SlateContext<ConfigType, AuthType, {
|
|
40
|
-
webhookBaseUrl: string;
|
|
41
|
-
}>) => Promise<{
|
|
42
|
-
registrationDetails: any;
|
|
43
|
-
}>;
|
|
44
|
-
export type SlateTriggerWebhookAutoUnregistrationHandler<ConfigType extends {}, AuthType extends {}> = (context: SlateContext<ConfigType, AuthType, {
|
|
45
|
-
webhookBaseUrl: string;
|
|
46
|
-
registrationDetails: any;
|
|
47
|
-
}>) => Promise<unknown>;
|
|
48
|
-
export interface SlateActionParametersTool<ConfigType extends {}, AuthType extends {}, InputType extends {}, OutputType extends {}> {
|
|
49
|
-
handlerInvocation: SlateToolInvocationHandler<ConfigType, AuthType, InputType, OutputType>;
|
|
50
|
-
}
|
|
51
|
-
export interface SlatePollingOptions {
|
|
52
|
-
intervalInSeconds?: number;
|
|
53
|
-
}
|
|
54
|
-
export interface SlateActionParametersTrigger<ConfigType extends {}, AuthType extends {}, InputType extends {}, OutputType extends {}> {
|
|
55
|
-
source: 'polling' | 'webhook';
|
|
56
|
-
polling?: SlatePollingOptions;
|
|
57
|
-
handleEvent: SlateTriggerMappingHandler<ConfigType, AuthType, InputType, OutputType>;
|
|
58
|
-
handleRequest?: SlateTriggerWebhookRequestHandler<ConfigType, AuthType, InputType>;
|
|
59
|
-
pollEvents?: SlateTriggerPollingHandler<ConfigType, AuthType, InputType>;
|
|
60
|
-
autoRegisterWebhook?: SlateTriggerWebhookAutoRegistrationHandler<ConfigType, AuthType>;
|
|
61
|
-
autoUnregisterWebhook?: SlateTriggerWebhookAutoUnregistrationHandler<ConfigType, AuthType>;
|
|
62
|
-
}
|
|
63
|
-
export type SlateActionParametersAny<ConfigType extends {}, AuthType extends {}, InputType extends {}, OutputType extends {}> = SlateActionParametersTool<ConfigType, AuthType, InputType, OutputType> | SlateActionParametersTrigger<ConfigType, AuthType, InputType, OutputType>;
|
|
64
|
-
export type SlateActionCreateParameters<ConfigType extends {}, AuthType extends {}, InputType extends {}, OutputType extends {}> = SlateActionParametersAny<ConfigType, AuthType, InputType, OutputType> & SlateActionParameters & {
|
|
65
|
-
configSchema: z.ZodType<ConfigType>;
|
|
66
|
-
authSchema: z.ZodType<AuthType>;
|
|
67
|
-
inputSchema: z.ZodType<InputType>;
|
|
68
|
-
outputSchema: z.ZodType<OutputType>;
|
|
69
|
-
};
|
|
70
|
-
export declare abstract class SlateAction<Type extends SlateActionType, ConfigType extends {}, AuthType extends {}, InputType extends {}, OutputType extends {}> {
|
|
71
|
-
readonly type: Type;
|
|
72
|
-
protected readonly _spec: SlateSpecification<ConfigType, AuthType>;
|
|
73
|
-
protected readonly _inputSchema: z.ZodType<InputType>;
|
|
74
|
-
protected readonly _outputSchema: z.ZodType<OutputType>;
|
|
75
|
-
protected readonly _params: SlateActionParameters;
|
|
76
|
-
constructor(type: Type, _spec: SlateSpecification<ConfigType, AuthType>, _inputSchema: z.ZodType<InputType>, _outputSchema: z.ZodType<OutputType>, _params: SlateActionParameters);
|
|
77
|
-
get configSchema(): z.ZodType<ConfigType, unknown, z.core.$ZodTypeInternals<ConfigType, unknown>>;
|
|
78
|
-
get inputSchema(): z.ZodType<InputType, unknown, z.core.$ZodTypeInternals<InputType, unknown>>;
|
|
79
|
-
get outputSchema(): z.ZodType<OutputType, unknown, z.core.$ZodTypeInternals<OutputType, unknown>>;
|
|
80
|
-
get parameters(): SlateActionParameters;
|
|
81
|
-
get key(): string;
|
|
82
|
-
get name(): string;
|
|
83
|
-
get description(): string | undefined;
|
|
84
|
-
get tags(): {
|
|
85
|
-
[key: string]: boolean | undefined;
|
|
86
|
-
destructive?: boolean;
|
|
87
|
-
readOnly?: boolean;
|
|
88
|
-
} | undefined;
|
|
89
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G,WAEN;IAED,IAAI,IAAI,WAEP;IAED,IAAI,WAAW,uBAEd;IAED,IAAI,IAAI;;sBA9JQ,OAAO;mBACV,OAAO;kBA+JnB;CACF"}
|
package/dist/action/builder.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import z from 'zod';
|
|
2
|
-
import { SlateSpecification } from '../specification/specification';
|
|
3
|
-
import { SlateAction, SlateActionCreateParameters, SlateActionParameters, SlateActionType, SlatePollingOptions, SlateToolInvocationHandler, SlateTriggerMappingHandler, SlateTriggerPollingHandler, SlateTriggerWebhookAutoRegistrationHandler, SlateTriggerWebhookAutoUnregistrationHandler, SlateTriggerWebhookRequestHandler } from './action';
|
|
4
|
-
export declare class SlateActionBuilder<Type extends SlateActionType, ConfigType extends {}, AuthType extends {}, InputType extends {}, OutputType extends {}> {
|
|
5
|
-
#private;
|
|
6
|
-
private readonly type;
|
|
7
|
-
private readonly spec;
|
|
8
|
-
private readonly params;
|
|
9
|
-
private readonly factory;
|
|
10
|
-
constructor(type: Type, spec: SlateSpecification<ConfigType, AuthType>, params: SlateActionParameters, factory: (params: SlateActionCreateParameters<any, any, any, any>) => SlateAction<Type, any, any, any, any>);
|
|
11
|
-
input<NewInputType extends {}>(schema: z.ZodType<NewInputType>): SlateActionBuilder<Type, ConfigType, AuthType, NewInputType, OutputType>;
|
|
12
|
-
output<NewOutputType extends {}>(schema: z.ZodType<NewOutputType>): SlateActionBuilder<Type, ConfigType, AuthType, InputType, NewOutputType>;
|
|
13
|
-
handleInvocation(handler: SlateToolInvocationHandler<ConfigType, AuthType, InputType, OutputType>): SlateActionBuilder<Type, ConfigType, AuthType, InputType, OutputType>;
|
|
14
|
-
webhook(props: {
|
|
15
|
-
handleEvent: SlateTriggerMappingHandler<ConfigType, AuthType, InputType, OutputType>;
|
|
16
|
-
handleRequest: SlateTriggerWebhookRequestHandler<ConfigType, AuthType, InputType>;
|
|
17
|
-
autoRegisterWebhook?: SlateTriggerWebhookAutoRegistrationHandler<ConfigType, AuthType>;
|
|
18
|
-
autoUnregisterWebhook?: SlateTriggerWebhookAutoUnregistrationHandler<ConfigType, AuthType>;
|
|
19
|
-
}): SlateActionBuilder<Type, ConfigType, AuthType, InputType, OutputType>;
|
|
20
|
-
polling(props: {
|
|
21
|
-
options?: SlatePollingOptions;
|
|
22
|
-
pollEvents?: SlateTriggerPollingHandler<ConfigType, AuthType, InputType>;
|
|
23
|
-
handleEvent: SlateTriggerMappingHandler<ConfigType, AuthType, InputType, OutputType>;
|
|
24
|
-
}): SlateActionBuilder<Type, ConfigType, AuthType, InputType, OutputType>;
|
|
25
|
-
build(): SlateAction<Type, ConfigType, AuthType, InputType, OutputType>;
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=builder.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../../src/action/builder.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AAEpB,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EACL,WAAW,EACX,2BAA2B,EAC3B,qBAAqB,EAGrB,eAAe,EACf,mBAAmB,EACnB,0BAA0B,EAC1B,0BAA0B,EAC1B,0BAA0B,EAC1B,0CAA0C,EAC1C,4CAA4C,EAC5C,iCAAiC,EAClC,MAAM,UAAU,CAAC;AAElB,qBAAa,kBAAkB,CAC7B,IAAI,SAAS,eAAe,EAC5B,UAAU,SAAS,EAAE,EACrB,QAAQ,SAAS,EAAE,EACnB,SAAS,SAAS,EAAE,EACpB,UAAU,SAAS,EAAE;;IAiBnB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAHP,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,kBAAkB,CAAC,UAAU,EAAE,QA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AAmB,CAAC;QAC9B,UAAU,CAAC,EAAE,0BAA0B,CAAC,UAAU,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;QACzE,WAAW,EAAE,0BAA0B,CAAC,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;KACtF,GAAG,kBAAkB,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,CAAC;IAezE,KAAK,IAuBG,WAAW,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,CAAC;CAEvE"}
|
package/dist/action/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/action/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAE1B,mBAAmB,WAAW,CAAC"}
|
package/dist/action/tool.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { SlateSpecification } from '../specification/specification';
|
|
2
|
-
import { SlateAction, SlateActionParameters } from './action';
|
|
3
|
-
import { SlateActionBuilder } from './builder';
|
|
4
|
-
export interface SlateToolParameters extends SlateActionParameters {
|
|
5
|
-
}
|
|
6
|
-
export declare class SlateTool<ConfigType extends {}, AuthType extends {}, InputType extends {}, OutputType extends {}> extends SlateAction<'tool', ConfigType, AuthType, InputType, OutputType> {
|
|
7
|
-
private constructor();
|
|
8
|
-
static create<ConfigType extends {}, AuthType extends {}>(spec: SlateSpecification<ConfigType, AuthType>, params: SlateToolParameters): SlateActionBuilder<"tool", ConfigType, AuthType, {}, {}>;
|
|
9
|
-
}
|
|
10
|
-
export declare let tool: <ConfigType extends {}, AuthType extends {}>(spec: SlateSpecification<ConfigType, AuthType>, params: SlateToolParameters) => SlateActionBuilder<"tool", ConfigType, AuthType, {}, {}>;
|
|
11
|
-
//# sourceMappingURL=tool.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../../src/action/tool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAE/C,MAAM,WAAW,mBAAoB,SAAQ,qBAAqB;CAAG;AAErE,qBAAa,SAAS,CACpB,UAAU,SAAS,EAAE,EACrB,QAAQ,SAAS,EAAE,EACnB,SAAS,SAAS,EAAE,EACpB,UAAU,SAAS,EAAE,CACrB,SAAQ,WAAW,CAAC,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,CAAC;IACxE,OAAO;IASP,MAAM,CAAC,MAAM,CAAC,UAAU,SAAS,EAAE,EAAE,QAAQ,SAAS,EAAE,EACtD,IAAI,EAAE,kBAAkB,CAAC,UAAU,EAAE,QAAQ,CAAC,EAC9C,MAAM,EAAE,mBAAmB;CAS9B;AAED,eAAO,IAAI,IAAI,GAAI,UAAU,SAAS,EAAE,EAAE,QAAQ,SAAS,EAAE,EAC3D,MAAM,kBAAkB,CAAC,UAAU,EAAE,QAAQ,CAAC,EAC9C,QAAQ,mBAAmB,6DACM,CAAC"}
|