@slates/proto 1.0.0-rc.12 → 1.0.0-rc.14
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 +499 -387
- package/dist/index.d.cts +535 -6
- package/dist/index.d.ts +535 -6
- package/dist/index.module.js +489 -387
- package/package.json +2 -2
- package/src/messages/action.ts +20 -3
- package/src/messages/adapter.ts +72 -0
- package/src/messages/index.ts +11 -0
- package/src/types/action.ts +40 -3
- package/src/types/adapter.ts +15 -0
- package/src/types/index.ts +1 -0
package/package.json
CHANGED
package/src/messages/action.ts
CHANGED
|
@@ -2,6 +2,19 @@ import z from 'zod';
|
|
|
2
2
|
import { slatesAction } from '../types';
|
|
3
3
|
import { withRequestTraces } from './tracing';
|
|
4
4
|
|
|
5
|
+
export let slatesWebhookHttpResponse = z.object({
|
|
6
|
+
status: z.number().int().min(100).max(599),
|
|
7
|
+
headers: z.record(z.string(), z.string()),
|
|
8
|
+
body: z
|
|
9
|
+
.object({
|
|
10
|
+
encoding: z.literal('base64'),
|
|
11
|
+
content: z.string()
|
|
12
|
+
})
|
|
13
|
+
.nullable()
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export type SlatesWebhookHttpResponse = z.infer<typeof slatesWebhookHttpResponse>;
|
|
17
|
+
|
|
5
18
|
/**
|
|
6
19
|
* List Actions
|
|
7
20
|
*/
|
|
@@ -9,7 +22,9 @@ export let slatesMessageActionsListRequest = z.object({
|
|
|
9
22
|
jsonrpc: z.literal('2.0'),
|
|
10
23
|
method: z.literal('slates/actions.list'),
|
|
11
24
|
id: z.string(),
|
|
12
|
-
params: z.object({
|
|
25
|
+
params: z.object({
|
|
26
|
+
includeAdapterActions: z.optional(z.nullable(z.boolean()))
|
|
27
|
+
})
|
|
13
28
|
});
|
|
14
29
|
|
|
15
30
|
export type SlatesMessageActionsListRequest = z.infer<typeof slatesMessageActionsListRequest>;
|
|
@@ -177,7 +192,8 @@ export let slatesMessageActionTriggerWebhookHandleRequest = z.object({
|
|
|
177
192
|
content: z.string()
|
|
178
193
|
})
|
|
179
194
|
.nullable(),
|
|
180
|
-
state: z.any().nullable()
|
|
195
|
+
state: z.any().nullable(),
|
|
196
|
+
registrationDetails: z.any().nullable().optional()
|
|
181
197
|
})
|
|
182
198
|
});
|
|
183
199
|
|
|
@@ -190,7 +206,8 @@ export let slatesMessageActionTriggerWebhookHandleResponse = z.object({
|
|
|
190
206
|
id: z.string(),
|
|
191
207
|
result: withRequestTraces({
|
|
192
208
|
inputs: z.array(z.record(z.string(), z.any())),
|
|
193
|
-
updatedState: z.any().nullable().optional()
|
|
209
|
+
updatedState: z.any().nullable().optional(),
|
|
210
|
+
response: slatesWebhookHttpResponse.nullable().optional()
|
|
194
211
|
})
|
|
195
212
|
});
|
|
196
213
|
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
import { slatesAdapter } from '../types';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* List Adapters
|
|
6
|
+
*/
|
|
7
|
+
export let slatesMessageAdaptersListRequest = z.object({
|
|
8
|
+
jsonrpc: z.literal('2.0'),
|
|
9
|
+
method: z.literal('slates/adapters.list'),
|
|
10
|
+
id: z.string(),
|
|
11
|
+
params: z.object({
|
|
12
|
+
includeAdapters: z.optional(z.nullable(z.boolean()))
|
|
13
|
+
})
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export type SlatesMessageAdaptersListRequest = z.infer<
|
|
17
|
+
typeof slatesMessageAdaptersListRequest
|
|
18
|
+
>;
|
|
19
|
+
|
|
20
|
+
export let slatesMessageAdaptersListResponse = z.object({
|
|
21
|
+
jsonrpc: z.literal('2.0'),
|
|
22
|
+
id: z.string(),
|
|
23
|
+
result: z.object({
|
|
24
|
+
adapters: z.array(slatesAdapter)
|
|
25
|
+
})
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
export type SlatesMessageAdaptersListResponse = z.infer<
|
|
29
|
+
typeof slatesMessageAdaptersListResponse
|
|
30
|
+
>;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Get Adapter
|
|
34
|
+
*/
|
|
35
|
+
export let slatesMessageAdapterGetRequest = z.object({
|
|
36
|
+
jsonrpc: z.literal('2.0'),
|
|
37
|
+
method: z.literal('slates/adapter.get'),
|
|
38
|
+
id: z.string(),
|
|
39
|
+
params: z.object({
|
|
40
|
+
adapterId: z.string()
|
|
41
|
+
})
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
export type SlatesMessageAdapterGetRequest = z.infer<typeof slatesMessageAdapterGetRequest>;
|
|
45
|
+
|
|
46
|
+
export let slatesMessageAdapterGetResponse = z.object({
|
|
47
|
+
jsonrpc: z.literal('2.0'),
|
|
48
|
+
id: z.string(),
|
|
49
|
+
result: z.object({
|
|
50
|
+
adapter: slatesAdapter
|
|
51
|
+
})
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
export type SlatesMessageAdapterGetResponse = z.infer<typeof slatesMessageAdapterGetResponse>;
|
|
55
|
+
|
|
56
|
+
export type SlatesAdapterRequests =
|
|
57
|
+
| SlatesMessageAdaptersListRequest
|
|
58
|
+
| SlatesMessageAdapterGetRequest;
|
|
59
|
+
|
|
60
|
+
export type SlatesAdapterResponses =
|
|
61
|
+
| SlatesMessageAdaptersListResponse
|
|
62
|
+
| SlatesMessageAdapterGetResponse;
|
|
63
|
+
|
|
64
|
+
export let slatesAdapterResponsesByMethod = {
|
|
65
|
+
'slates/adapters.list': slatesMessageAdaptersListResponse,
|
|
66
|
+
'slates/adapter.get': slatesMessageAdapterGetResponse
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export let slatesAdapterRequestsByMethod = {
|
|
70
|
+
'slates/adapters.list': slatesMessageAdaptersListRequest,
|
|
71
|
+
'slates/adapter.get': slatesMessageAdapterGetRequest
|
|
72
|
+
};
|
package/src/messages/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export * from './action';
|
|
2
|
+
export * from './adapter';
|
|
2
3
|
export * from './auth';
|
|
3
4
|
export * from './config';
|
|
4
5
|
export * from './controlFlow';
|
|
@@ -12,6 +13,12 @@ import {
|
|
|
12
13
|
slatesActionRequestsByMethod,
|
|
13
14
|
slatesActionResponsesByMethod
|
|
14
15
|
} from './action';
|
|
16
|
+
import {
|
|
17
|
+
type SlatesAdapterRequests,
|
|
18
|
+
type SlatesAdapterResponses,
|
|
19
|
+
slatesAdapterRequestsByMethod,
|
|
20
|
+
slatesAdapterResponsesByMethod
|
|
21
|
+
} from './adapter';
|
|
15
22
|
import {
|
|
16
23
|
type SlatesAuthNotifications,
|
|
17
24
|
type SlatesAuthRequests,
|
|
@@ -46,18 +53,21 @@ export type SlatesNotifications =
|
|
|
46
53
|
|
|
47
54
|
export type SlatesRequests =
|
|
48
55
|
| SlatesActionRequests
|
|
56
|
+
| SlatesAdapterRequests
|
|
49
57
|
| SlatesAuthRequests
|
|
50
58
|
| SlatesConfigRequests
|
|
51
59
|
| SlatesIdentifyRequests;
|
|
52
60
|
|
|
53
61
|
export type SlatesResponses =
|
|
54
62
|
| SlatesActionResponses
|
|
63
|
+
| SlatesAdapterResponses
|
|
55
64
|
| SlatesAuthResponses
|
|
56
65
|
| SlatesConfigResponses
|
|
57
66
|
| SlatesIdentifyResponses;
|
|
58
67
|
|
|
59
68
|
export let slatesResponsesByMethod = {
|
|
60
69
|
...slatesActionResponsesByMethod,
|
|
70
|
+
...slatesAdapterResponsesByMethod,
|
|
61
71
|
...slatesAuthResponsesByMethod,
|
|
62
72
|
...slatesConfigResponsesByMethod,
|
|
63
73
|
...slatesIdentifyResponsesByMethod
|
|
@@ -65,6 +75,7 @@ export let slatesResponsesByMethod = {
|
|
|
65
75
|
|
|
66
76
|
export let slatesRequestsByMethod = {
|
|
67
77
|
...slatesActionRequestsByMethod,
|
|
78
|
+
...slatesAdapterRequestsByMethod,
|
|
68
79
|
...slatesAuthRequestsByMethod,
|
|
69
80
|
...slatesConfigRequestsByMethod,
|
|
70
81
|
...slatesIdentifyRequestsByMethod
|
package/src/types/action.ts
CHANGED
|
@@ -34,12 +34,46 @@ export let slatesActionBase = z.object({
|
|
|
34
34
|
name: z.string(),
|
|
35
35
|
url: z.string()
|
|
36
36
|
})
|
|
37
|
-
)
|
|
37
|
+
),
|
|
38
|
+
|
|
39
|
+
adapter: z.optional(z.nullable(z.string()))
|
|
38
40
|
});
|
|
39
41
|
|
|
40
42
|
export let slatesActionTool = slatesActionBase.extend({
|
|
41
43
|
type: z.literal('action.tool'),
|
|
42
|
-
capabilities: z.object({})
|
|
44
|
+
capabilities: z.object({}),
|
|
45
|
+
isPublic: z.boolean()
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
export let slatesWebhookRequestMatcher = z.object({
|
|
49
|
+
method: z.string().optional(),
|
|
50
|
+
hasQueryParam: z.string().optional(),
|
|
51
|
+
hasHeader: z.string().optional(),
|
|
52
|
+
jsonBodyField: z
|
|
53
|
+
.object({
|
|
54
|
+
path: z.string(),
|
|
55
|
+
equals: z.string().optional()
|
|
56
|
+
})
|
|
57
|
+
.optional(),
|
|
58
|
+
formBodyField: z
|
|
59
|
+
.object({
|
|
60
|
+
path: z.string(),
|
|
61
|
+
equals: z.string().optional()
|
|
62
|
+
})
|
|
63
|
+
.optional()
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
export let slatesWebhookHttp = z.object({
|
|
67
|
+
methods: z
|
|
68
|
+
.array(z.enum(['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'HEAD', 'OPTIONS']))
|
|
69
|
+
.optional(),
|
|
70
|
+
sync: z
|
|
71
|
+
.object({
|
|
72
|
+
mode: z.enum(['never', 'match', 'always']),
|
|
73
|
+
match: z.array(slatesWebhookRequestMatcher).optional(),
|
|
74
|
+
timeoutMs: z.number().int().positive().max(15_000).optional()
|
|
75
|
+
})
|
|
76
|
+
.optional()
|
|
43
77
|
});
|
|
44
78
|
|
|
45
79
|
export let slatesActionTrigger = slatesActionBase.extend({
|
|
@@ -54,7 +88,8 @@ export let slatesActionTrigger = slatesActionBase.extend({
|
|
|
54
88
|
z.object({
|
|
55
89
|
type: z.literal('webhook'),
|
|
56
90
|
autoRegistration: z.boolean(),
|
|
57
|
-
autoUnregistration: z.boolean()
|
|
91
|
+
autoUnregistration: z.boolean(),
|
|
92
|
+
http: slatesWebhookHttp.optional()
|
|
58
93
|
})
|
|
59
94
|
])
|
|
60
95
|
});
|
|
@@ -65,3 +100,5 @@ export type SlatesAction = z.infer<typeof slatesAction>;
|
|
|
65
100
|
export type SlatesActionTool = z.infer<typeof slatesActionTool>;
|
|
66
101
|
export type SlatesActionTrigger = z.infer<typeof slatesActionTrigger>;
|
|
67
102
|
export type SlatesActionScopes = z.infer<typeof slatesActionScopes>;
|
|
103
|
+
export type SlatesWebhookRequestMatcher = z.infer<typeof slatesWebhookRequestMatcher>;
|
|
104
|
+
export type SlatesWebhookHttp = z.infer<typeof slatesWebhookHttp>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
|
|
3
|
+
export let slatesAdapter = z.object({
|
|
4
|
+
id: z.string(),
|
|
5
|
+
name: z.string(),
|
|
6
|
+
|
|
7
|
+
capabilities: z.array(
|
|
8
|
+
z.object({
|
|
9
|
+
id: z.string(),
|
|
10
|
+
value: z.any()
|
|
11
|
+
})
|
|
12
|
+
)
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export type SlateAdapter = z.infer<typeof slatesAdapter>;
|
package/src/types/index.ts
CHANGED