@slates/proto 1.0.0-rc.1 → 1.0.0-rc.10
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 +1103 -0
- package/dist/index.d.cts +3521 -0
- package/dist/index.d.ts +3521 -0
- package/dist/index.module.js +997 -0
- package/package.json +14 -7
- package/src/handler/provider.test.ts +121 -0
- package/src/handler/provider.ts +268 -27
- package/src/index.ts +1 -0
- package/src/messages/action.ts +26 -7
- package/src/messages/auth.ts +15 -10
- package/src/messages/config.ts +4 -2
- package/src/messages/controlFlow.ts +2 -1
- package/src/messages/identify.ts +3 -2
- package/src/messages/index.ts +15 -18
- package/src/messages/tracing.ts +38 -0
- package/src/types/action.ts +11 -1
- package/src/types/authMethod.ts +11 -2
- package/src/version.ts +3 -0
- package/src/messages/log.ts +0 -29
- package/tsconfig.json +0 -8
package/src/messages/config.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import z from 'zod';
|
|
2
|
+
import { withRequestTraces } from './tracing';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Set Config
|
|
@@ -47,6 +48,7 @@ export type SlatesMessageConfigSchemaGetResponse = z.infer<
|
|
|
47
48
|
export let slatesMessageConfigChangedRequest = z.object({
|
|
48
49
|
jsonrpc: z.literal('2.0'),
|
|
49
50
|
method: z.literal('slates/config.changed'),
|
|
51
|
+
id: z.string(),
|
|
50
52
|
params: z.object({
|
|
51
53
|
previousConfig: z.record(z.string(), z.any()).nullable(),
|
|
52
54
|
newConfig: z.record(z.string(), z.any())
|
|
@@ -60,7 +62,7 @@ export type SlatesMessageConfigChangedRequest = z.infer<
|
|
|
60
62
|
export let slatesMessageConfigChangedResponse = z.object({
|
|
61
63
|
jsonrpc: z.literal('2.0'),
|
|
62
64
|
id: z.string(),
|
|
63
|
-
result:
|
|
65
|
+
result: withRequestTraces({
|
|
64
66
|
success: z.boolean(),
|
|
65
67
|
config: z.record(z.string(), z.any()).optional(),
|
|
66
68
|
errors: z
|
|
@@ -96,7 +98,7 @@ export type SlatesMessageConfigDefaultGetRequest = z.infer<
|
|
|
96
98
|
export let slatesMessageConfigDefaultGetResponse = z.object({
|
|
97
99
|
jsonrpc: z.literal('2.0'),
|
|
98
100
|
id: z.string(),
|
|
99
|
-
result:
|
|
101
|
+
result: withRequestTraces({
|
|
100
102
|
config: z.record(z.string(), z.any()).nullable()
|
|
101
103
|
})
|
|
102
104
|
});
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import z from 'zod';
|
|
2
2
|
import { slatesParticipant } from '../types';
|
|
3
|
+
import { SLATES_PROTOCOL_VERSION } from '../version';
|
|
3
4
|
|
|
4
5
|
export let slatesMessageHelloNotification = z.object({
|
|
5
6
|
jsonrpc: z.literal('2.0'),
|
|
6
7
|
method: z.literal('slates/hello'),
|
|
7
8
|
params: z.object({
|
|
8
|
-
protocol: z.literal(
|
|
9
|
+
protocol: z.literal(SLATES_PROTOCOL_VERSION)
|
|
9
10
|
})
|
|
10
11
|
});
|
|
11
12
|
|
package/src/messages/identify.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import z from 'zod';
|
|
2
|
+
import { SLATES_PROTOCOL_VERSION } from '../version';
|
|
2
3
|
|
|
3
4
|
export let slatesMessageProviderIdentifyRequest = z.object({
|
|
4
5
|
jsonrpc: z.literal('2.0'),
|
|
5
6
|
method: z.literal('slates/provider.identify'),
|
|
7
|
+
id: z.string(),
|
|
6
8
|
params: z.object({})
|
|
7
9
|
});
|
|
8
10
|
|
|
@@ -14,8 +16,7 @@ export let slatesMessageProviderIdentifyResponse = z.object({
|
|
|
14
16
|
jsonrpc: z.literal('2.0'),
|
|
15
17
|
id: z.string(),
|
|
16
18
|
result: z.object({
|
|
17
|
-
protocol: z.literal(
|
|
18
|
-
|
|
19
|
+
protocol: z.literal(SLATES_PROTOCOL_VERSION),
|
|
19
20
|
provider: z.object({
|
|
20
21
|
type: z.literal('provider'),
|
|
21
22
|
id: z.string(),
|
package/src/messages/index.ts
CHANGED
|
@@ -3,48 +3,46 @@ export * from './auth';
|
|
|
3
3
|
export * from './config';
|
|
4
4
|
export * from './controlFlow';
|
|
5
5
|
export * from './identify';
|
|
6
|
-
export * from './
|
|
6
|
+
export * from './tracing';
|
|
7
7
|
|
|
8
|
-
import { z } from 'zod';
|
|
8
|
+
import type { z } from 'zod';
|
|
9
9
|
import {
|
|
10
|
-
SlatesActionRequests,
|
|
10
|
+
type SlatesActionRequests,
|
|
11
|
+
type SlatesActionResponses,
|
|
11
12
|
slatesActionRequestsByMethod,
|
|
12
|
-
SlatesActionResponses,
|
|
13
13
|
slatesActionResponsesByMethod
|
|
14
14
|
} from './action';
|
|
15
15
|
import {
|
|
16
|
-
SlatesAuthNotifications,
|
|
16
|
+
type SlatesAuthNotifications,
|
|
17
|
+
type SlatesAuthRequests,
|
|
18
|
+
type SlatesAuthResponses,
|
|
17
19
|
slatesAuthNotificationsByMethod,
|
|
18
|
-
SlatesAuthRequests,
|
|
19
20
|
slatesAuthRequestsByMethod,
|
|
20
|
-
SlatesAuthResponses,
|
|
21
21
|
slatesAuthResponsesByMethod
|
|
22
22
|
} from './auth';
|
|
23
23
|
import {
|
|
24
|
-
SlatesConfigNotifications,
|
|
24
|
+
type SlatesConfigNotifications,
|
|
25
|
+
type SlatesConfigRequests,
|
|
26
|
+
type SlatesConfigResponses,
|
|
25
27
|
slatesConfigNotificationsByMethod,
|
|
26
|
-
SlatesConfigRequests,
|
|
27
28
|
slatesConfigRequestsByMethod,
|
|
28
|
-
SlatesConfigResponses,
|
|
29
29
|
slatesConfigResponsesByMethod
|
|
30
30
|
} from './config';
|
|
31
31
|
import {
|
|
32
|
-
SlatesControlFlowNotifications,
|
|
32
|
+
type SlatesControlFlowNotifications,
|
|
33
33
|
slatesControlFlowNotificationsByMethod
|
|
34
34
|
} from './controlFlow';
|
|
35
35
|
import {
|
|
36
|
-
SlatesIdentifyRequests,
|
|
36
|
+
type SlatesIdentifyRequests,
|
|
37
|
+
type SlatesIdentifyResponses,
|
|
37
38
|
slatesIdentifyRequestsByMethod,
|
|
38
|
-
SlatesIdentifyResponses,
|
|
39
39
|
slatesIdentifyResponsesByMethod
|
|
40
40
|
} from './identify';
|
|
41
|
-
import { SlatesLogNotifications, slatesLogNotificationsByMethod } from './log';
|
|
42
41
|
|
|
43
42
|
export type SlatesNotifications =
|
|
44
43
|
| SlatesAuthNotifications
|
|
45
44
|
| SlatesConfigNotifications
|
|
46
|
-
| SlatesControlFlowNotifications
|
|
47
|
-
| SlatesLogNotifications;
|
|
45
|
+
| SlatesControlFlowNotifications;
|
|
48
46
|
|
|
49
47
|
export type SlatesRequests =
|
|
50
48
|
| SlatesActionRequests
|
|
@@ -75,8 +73,7 @@ export let slatesRequestsByMethod = {
|
|
|
75
73
|
export let slatesNotificationsByMethod = {
|
|
76
74
|
...slatesAuthNotificationsByMethod,
|
|
77
75
|
...slatesConfigNotificationsByMethod,
|
|
78
|
-
...slatesControlFlowNotificationsByMethod
|
|
79
|
-
...slatesLogNotificationsByMethod
|
|
76
|
+
...slatesControlFlowNotificationsByMethod
|
|
80
77
|
};
|
|
81
78
|
|
|
82
79
|
export type SlatesResponsesByMethod = {
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
|
|
3
|
+
export let slatesRequestTraceTextBody = z.object({
|
|
4
|
+
contentType: z.string().optional(),
|
|
5
|
+
text: z.string(),
|
|
6
|
+
truncated: z.boolean().optional()
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export let slatesRequestTrace = z.object({
|
|
10
|
+
startedAt: z.string(),
|
|
11
|
+
durationMs: z.number().nonnegative(),
|
|
12
|
+
request: z.object({
|
|
13
|
+
method: z.string(),
|
|
14
|
+
url: z.string(),
|
|
15
|
+
headers: z.record(z.string(), z.string()).optional(),
|
|
16
|
+
body: slatesRequestTraceTextBody.optional()
|
|
17
|
+
}),
|
|
18
|
+
response: z
|
|
19
|
+
.object({
|
|
20
|
+
status: z.number(),
|
|
21
|
+
statusText: z.string().optional(),
|
|
22
|
+
headers: z.record(z.string(), z.string()).optional(),
|
|
23
|
+
body: slatesRequestTraceTextBody.optional()
|
|
24
|
+
})
|
|
25
|
+
.optional(),
|
|
26
|
+
error: z
|
|
27
|
+
.object({
|
|
28
|
+
code: z.string().optional(),
|
|
29
|
+
message: z.string()
|
|
30
|
+
})
|
|
31
|
+
.optional()
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
export let withRequestTraces = <Shape extends z.ZodRawShape>(shape: Shape) =>
|
|
35
|
+
z.object({
|
|
36
|
+
...shape,
|
|
37
|
+
requestTraces: z.array(slatesRequestTrace).optional()
|
|
38
|
+
});
|
package/src/types/action.ts
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import z from 'zod';
|
|
2
2
|
|
|
3
|
+
export let slatesActionScopeClause = z.object({
|
|
4
|
+
OR: z.array(z.string()).min(1)
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
export let slatesActionScopes = z.object({
|
|
8
|
+
AND: z.array(slatesActionScopeClause).min(1)
|
|
9
|
+
});
|
|
10
|
+
|
|
3
11
|
export let slatesActionBase = z.object({
|
|
4
12
|
id: z.string(),
|
|
5
13
|
|
|
@@ -14,6 +22,7 @@ export let slatesActionBase = z.object({
|
|
|
14
22
|
})
|
|
15
23
|
.optional(),
|
|
16
24
|
metadata: z.record(z.string(), z.any()).optional(),
|
|
25
|
+
scopes: slatesActionScopes.optional(),
|
|
17
26
|
|
|
18
27
|
inputSchema: z.record(z.string(), z.any()),
|
|
19
28
|
outputSchema: z.record(z.string(), z.any())
|
|
@@ -31,7 +40,7 @@ export let slatesActionTrigger = slatesActionBase.extend({
|
|
|
31
40
|
invocation: z.union([
|
|
32
41
|
z.object({
|
|
33
42
|
type: z.literal('polling'),
|
|
34
|
-
intervalSeconds: z.number().min(
|
|
43
|
+
intervalSeconds: z.number().min(60 * 10)
|
|
35
44
|
}),
|
|
36
45
|
z.object({
|
|
37
46
|
type: z.literal('webhook'),
|
|
@@ -46,3 +55,4 @@ export let slatesAction = z.union([slatesActionTool, slatesActionTrigger]);
|
|
|
46
55
|
export type SlatesAction = z.infer<typeof slatesAction>;
|
|
47
56
|
export type SlatesActionTool = z.infer<typeof slatesActionTool>;
|
|
48
57
|
export type SlatesActionTrigger = z.infer<typeof slatesActionTrigger>;
|
|
58
|
+
export type SlatesActionScopes = z.infer<typeof slatesActionScopes>;
|
package/src/types/authMethod.ts
CHANGED
|
@@ -16,7 +16,8 @@ export let slatesAuthenticationMethod = z.object({
|
|
|
16
16
|
z.object({
|
|
17
17
|
id: z.string(),
|
|
18
18
|
title: z.string(),
|
|
19
|
-
description: z.string().optional()
|
|
19
|
+
description: z.string().optional(),
|
|
20
|
+
defaultChecked: z.boolean().optional()
|
|
20
21
|
})
|
|
21
22
|
)
|
|
22
23
|
.optional(),
|
|
@@ -29,7 +30,15 @@ export let slatesAuthenticationMethod = z.object({
|
|
|
29
30
|
handleChangedInput: z.object({ enabled: z.boolean() }).optional(),
|
|
30
31
|
handleTokenRefresh: z.object({ enabled: z.boolean() }).optional(),
|
|
31
32
|
getProfile: z.object({ enabled: z.boolean() }).optional()
|
|
32
|
-
})
|
|
33
|
+
}),
|
|
34
|
+
|
|
35
|
+
docs: z.object({
|
|
36
|
+
oauthDocsLink: z.string().optional(),
|
|
37
|
+
oauthScopesLink: z.string().optional(),
|
|
38
|
+
tokenDocsLink: z.string().optional(),
|
|
39
|
+
serviceAccountDocsLink: z.string().optional(),
|
|
40
|
+
customAuthDocsLink: z.string().optional()
|
|
41
|
+
}).optional()
|
|
33
42
|
});
|
|
34
43
|
|
|
35
44
|
export type SlateAuthenticationMethod = z.infer<typeof slatesAuthenticationMethod>;
|
package/src/version.ts
ADDED
package/src/messages/log.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import z from 'zod';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Send Log
|
|
5
|
-
*/
|
|
6
|
-
export let slatesMessageLogSendNotification = z.object({
|
|
7
|
-
jsonrpc: z.literal('2.0'),
|
|
8
|
-
method: z.literal('slates/log.send'),
|
|
9
|
-
params: z.object({
|
|
10
|
-
type: z.union([
|
|
11
|
-
z.literal('info'),
|
|
12
|
-
z.literal('warning'),
|
|
13
|
-
z.literal('error'),
|
|
14
|
-
z.literal('progress')
|
|
15
|
-
]),
|
|
16
|
-
timestamp: z.string(),
|
|
17
|
-
message: z.string()
|
|
18
|
-
})
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
export type SlatesMessageLogSendNotification = z.infer<
|
|
22
|
-
typeof slatesMessageLogSendNotification
|
|
23
|
-
>;
|
|
24
|
-
|
|
25
|
-
export type SlatesLogNotifications = SlatesMessageLogSendNotification;
|
|
26
|
-
|
|
27
|
-
export let slatesLogNotificationsByMethod = {
|
|
28
|
-
'slates/log.send': slatesMessageLogSendNotification
|
|
29
|
-
};
|