@slates/client 1.0.0-rc.21 → 1.0.0-rc.23
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 +47 -15
- package/dist/index.d.cts +41 -41
- package/dist/index.d.ts +41 -41
- package/dist/index.module.js +47 -15
- package/package.json +4 -4
- package/src/client.test.ts +73 -42
- package/src/client.ts +97 -30
- package/src/types.ts +5 -0
package/dist/index.cjs
CHANGED
|
@@ -136,7 +136,8 @@ var SlatesProtocolClient = class {
|
|
|
136
136
|
participants: opts.participants ?? createDefaultParticipants(),
|
|
137
137
|
config: opts.state?.config ?? null,
|
|
138
138
|
auth: opts.state?.auth ?? null,
|
|
139
|
-
session: opts.state?.session ?? null
|
|
139
|
+
session: opts.state?.session ?? null,
|
|
140
|
+
capabilities: opts.state?.capabilities ?? null
|
|
140
141
|
};
|
|
141
142
|
}
|
|
142
143
|
setParticipants(participants) {
|
|
@@ -159,6 +160,10 @@ var SlatesProtocolClient = class {
|
|
|
159
160
|
this.state.session = session;
|
|
160
161
|
return this;
|
|
161
162
|
}
|
|
163
|
+
setCapabilities(capabilities) {
|
|
164
|
+
this.state.capabilities = capabilities;
|
|
165
|
+
return this;
|
|
166
|
+
}
|
|
162
167
|
ensureSession() {
|
|
163
168
|
if (!this.state.session) {
|
|
164
169
|
this.state.session = {
|
|
@@ -180,6 +185,13 @@ var SlatesProtocolClient = class {
|
|
|
180
185
|
method: "slates/participant.set",
|
|
181
186
|
params: { participants: this.state.participants }
|
|
182
187
|
},
|
|
188
|
+
...this.state.capabilities ? [
|
|
189
|
+
{
|
|
190
|
+
jsonrpc: "2.0",
|
|
191
|
+
method: "slates/hub.capabilities.set",
|
|
192
|
+
params: { capabilities: this.state.capabilities }
|
|
193
|
+
}
|
|
194
|
+
] : [],
|
|
183
195
|
...this.state.config ? [
|
|
184
196
|
{
|
|
185
197
|
jsonrpc: "2.0",
|
|
@@ -326,18 +338,37 @@ var SlatesProtocolClient = class {
|
|
|
326
338
|
input
|
|
327
339
|
});
|
|
328
340
|
}
|
|
329
|
-
async
|
|
341
|
+
async listTriggerGroups() {
|
|
342
|
+
return this.request("slates/trigger_groups.list", {});
|
|
343
|
+
}
|
|
344
|
+
async getTriggerGroup(triggerGroupId) {
|
|
345
|
+
return this.request("slates/trigger_group.get", { triggerGroupId });
|
|
346
|
+
}
|
|
347
|
+
async listTriggerGroupWebhookTargets(d) {
|
|
330
348
|
this.ensureSession();
|
|
331
|
-
return this.request("slates/
|
|
332
|
-
|
|
333
|
-
|
|
349
|
+
return this.request("slates/trigger_group.webhook.targets_list", {
|
|
350
|
+
triggerGroupId: d.triggerGroupId,
|
|
351
|
+
pageToken: d.pageToken ?? null
|
|
334
352
|
});
|
|
335
353
|
}
|
|
336
|
-
async
|
|
354
|
+
async registerTriggerGroupWebhook(d) {
|
|
355
|
+
this.ensureSession();
|
|
356
|
+
return this.request("slates/trigger_group.webhook.register", d);
|
|
357
|
+
}
|
|
358
|
+
async unregisterTriggerGroupWebhook(d) {
|
|
337
359
|
this.ensureSession();
|
|
360
|
+
return this.request("slates/trigger_group.webhook.unregister", d);
|
|
361
|
+
}
|
|
362
|
+
async setupTriggerGroupWebhookManually(d) {
|
|
363
|
+
return this.request("slates/trigger_group.webhook.manual_setup", d);
|
|
364
|
+
}
|
|
365
|
+
async finishTriggerGroupWebhookManualSetup(d) {
|
|
366
|
+
return this.request("slates/trigger_group.webhook.manual_finish", d);
|
|
367
|
+
}
|
|
368
|
+
async processTriggerGroupWebhook(d) {
|
|
338
369
|
let encodedBody = typeof d.body === "string" ? Buffer.from(d.body, "utf-8").toString("base64") : d.body ? Buffer.from(d.body).toString("base64") : null;
|
|
339
|
-
return this.request("slates/
|
|
340
|
-
|
|
370
|
+
return this.request("slates/trigger_group.webhook.process", {
|
|
371
|
+
triggerGroupId: d.triggerGroupId,
|
|
341
372
|
url: d.url,
|
|
342
373
|
method: d.method,
|
|
343
374
|
headers: d.headers ?? {},
|
|
@@ -345,16 +376,17 @@ var SlatesProtocolClient = class {
|
|
|
345
376
|
encoding: "base64",
|
|
346
377
|
content: encodedBody
|
|
347
378
|
} : null,
|
|
348
|
-
|
|
349
|
-
registrationDetails: d.registrationDetails ?? null
|
|
379
|
+
webhookRegistrationPayload: d.webhookRegistrationPayload
|
|
350
380
|
});
|
|
351
381
|
}
|
|
352
|
-
async
|
|
382
|
+
async getTriggerGroupRoutingMatchers(triggerGroupId) {
|
|
383
|
+
this.ensureSession();
|
|
384
|
+
return this.request("slates/trigger_group.routing_matchers.get", { triggerGroupId });
|
|
385
|
+
}
|
|
386
|
+
async pollTriggerGroup(d) {
|
|
353
387
|
this.ensureSession();
|
|
354
|
-
return this.request("slates/
|
|
355
|
-
|
|
356
|
-
webhookBaseUrl: d.webhookBaseUrl,
|
|
357
|
-
registrationDetails: d.registrationDetails,
|
|
388
|
+
return this.request("slates/trigger_group.polling.poll", {
|
|
389
|
+
triggerGroupId: d.triggerGroupId,
|
|
358
390
|
state: d.state ?? null
|
|
359
391
|
});
|
|
360
392
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { SlatesProtocolVersion, SlatesParticipant, SlatesNotifications, SlatesRequests, SlatesResponses, SlatesResponsesByMethod, SlatesMessageProviderIdentifyResponse, SlatesMessageActionsListResponse, SlatesActionTool, SlatesAction, SlatesMessageActionGetResponse, SlatesMessageConfigSchemaGetResponse, SlatesMessageConfigDefaultGetResponse, SlatesMessageConfigChangedResponse, SlateAuthenticationMethod, SlatesMessageAuthMethodGetResponse, SlatesMessageAuthDefaultInputGetResponse, SlatesMessageAuthInputChangedResponse, SlatesMessageAuthOutputGetResponse, SlatesMessageAuthAuthorizationUrlGetResponse, SlatesMessageAuthTokenRefreshHandleResponse, SlatesMessageAuthProfileGetResponse, SlatesMessageActionInvokeResponse, SlatesMessageActionTriggerEventMapResponse,
|
|
1
|
+
import { SlatesProtocolVersion, SlatesParticipant, SlatesMessageHubCapabilitiesSetNotification, SlatesNotifications, SlatesRequests, SlatesResponses, SlatesResponsesByMethod, SlatesMessageProviderIdentifyResponse, SlatesMessageActionsListResponse, SlatesActionTool, SlatesAction, SlatesMessageActionGetResponse, SlatesMessageConfigSchemaGetResponse, SlatesMessageConfigDefaultGetResponse, SlatesMessageConfigChangedResponse, SlateAuthenticationMethod, SlatesMessageAuthMethodGetResponse, SlatesMessageAuthDefaultInputGetResponse, SlatesMessageAuthInputChangedResponse, SlatesMessageAuthOutputGetResponse, SlatesMessageAuthAuthorizationUrlGetResponse, SlatesMessageAuthTokenRefreshHandleResponse, SlatesMessageAuthProfileGetResponse, SlatesMessageActionInvokeResponse, SlatesMessageActionTriggerEventMapResponse, SlatesMessageTriggerGroupsListResponse, SlatesMessageTriggerGroupGetResponse, SlatesMessageTriggerGroupWebhookTargetsListResponse, SlatesMessageTriggerGroupWebhookRegisterResponse, SlatesMessageTriggerGroupWebhookUnregisterResponse, SlatesMessageTriggerGroupWebhookManualSetupResponse, SlatesMessageTriggerGroupWebhookManualFinishResponse, SlatesMessageTriggerGroupWebhookProcessResponse, SlatesMessageTriggerGroupRoutingMatchersGetResponse, SlatesMessageTriggerGroupPollingPollResponse } from '@slates/proto';
|
|
2
2
|
import { Slate, SlateLogListener } from '@slates/provider';
|
|
3
3
|
|
|
4
4
|
type SlatesJsonObject = Record<string, any>;
|
|
5
5
|
type SlatesProtocolMessage = SlatesNotifications | SlatesRequests;
|
|
6
6
|
type SlatesProtocolResponse = SlatesNotifications | SlatesResponses;
|
|
7
|
+
type SlatesHubCapabilities = SlatesMessageHubCapabilitiesSetNotification['params']['capabilities'];
|
|
7
8
|
interface SlatesClientState {
|
|
8
9
|
protocol: SlatesProtocolVersion;
|
|
9
10
|
participants: SlatesParticipant[];
|
|
@@ -16,6 +17,7 @@ interface SlatesClientState {
|
|
|
16
17
|
id: string;
|
|
17
18
|
state: SlatesJsonObject;
|
|
18
19
|
} | null;
|
|
20
|
+
capabilities: SlatesHubCapabilities | null;
|
|
19
21
|
}
|
|
20
22
|
interface SlatesMessageTransport {
|
|
21
23
|
send(messages: SlatesProtocolMessage[]): Promise<SlatesProtocolResponse[]>;
|
|
@@ -36,6 +38,7 @@ declare class SlatesProtocolClient {
|
|
|
36
38
|
setAuth(auth: SlatesClientState['auth']): this;
|
|
37
39
|
clearAuth(): this;
|
|
38
40
|
setSession(session: SlatesClientState['session']): this;
|
|
41
|
+
setCapabilities(capabilities: SlatesClientState['capabilities']): this;
|
|
39
42
|
ensureSession(): {
|
|
40
43
|
id: string;
|
|
41
44
|
state: SlatesJsonObject;
|
|
@@ -90,34 +93,7 @@ declare class SlatesProtocolClient {
|
|
|
90
93
|
}[];
|
|
91
94
|
type: "action.trigger";
|
|
92
95
|
capabilities: Record<string, never>;
|
|
93
|
-
|
|
94
|
-
type: "polling";
|
|
95
|
-
intervalSeconds: number;
|
|
96
|
-
} | {
|
|
97
|
-
type: "webhook";
|
|
98
|
-
autoRegistration: boolean;
|
|
99
|
-
autoUnregistration: boolean;
|
|
100
|
-
http?: {
|
|
101
|
-
methods?: ("GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS")[] | undefined;
|
|
102
|
-
sync?: {
|
|
103
|
-
mode: "match" | "never" | "always";
|
|
104
|
-
match?: {
|
|
105
|
-
method?: string | undefined;
|
|
106
|
-
hasQueryParam?: string | undefined;
|
|
107
|
-
hasHeader?: string | undefined;
|
|
108
|
-
jsonBodyField?: {
|
|
109
|
-
path: string;
|
|
110
|
-
equals?: string | undefined;
|
|
111
|
-
} | undefined;
|
|
112
|
-
formBodyField?: {
|
|
113
|
-
path: string;
|
|
114
|
-
equals?: string | undefined;
|
|
115
|
-
} | undefined;
|
|
116
|
-
}[] | undefined;
|
|
117
|
-
timeoutMs?: number | undefined;
|
|
118
|
-
} | undefined;
|
|
119
|
-
} | undefined;
|
|
120
|
-
};
|
|
96
|
+
triggerGroupId: string;
|
|
121
97
|
description?: string | undefined;
|
|
122
98
|
instructions?: string[] | undefined;
|
|
123
99
|
constraints?: string[] | undefined;
|
|
@@ -192,22 +168,46 @@ declare class SlatesProtocolClient {
|
|
|
192
168
|
}): Promise<SlatesMessageAuthProfileGetResponse['result']>;
|
|
193
169
|
invokeTool(actionId: string, input: Record<string, any>): Promise<SlatesMessageActionInvokeResponse['result']>;
|
|
194
170
|
mapTriggerEvent(actionId: string, input: Record<string, any>): Promise<SlatesMessageActionTriggerEventMapResponse['result']>;
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
171
|
+
listTriggerGroups(): Promise<SlatesMessageTriggerGroupsListResponse['result']>;
|
|
172
|
+
getTriggerGroup(triggerGroupId: string): Promise<SlatesMessageTriggerGroupGetResponse['result']>;
|
|
173
|
+
listTriggerGroupWebhookTargets(d: {
|
|
174
|
+
triggerGroupId: string;
|
|
175
|
+
pageToken?: any;
|
|
176
|
+
}): Promise<SlatesMessageTriggerGroupWebhookTargetsListResponse['result']>;
|
|
177
|
+
registerTriggerGroupWebhook(d: {
|
|
178
|
+
triggerGroupId: string;
|
|
179
|
+
webhookTargetIdentifier: string;
|
|
180
|
+
webhookTargetPayload: any;
|
|
181
|
+
webhookUrl: string;
|
|
182
|
+
}): Promise<SlatesMessageTriggerGroupWebhookRegisterResponse['result']>;
|
|
183
|
+
unregisterTriggerGroupWebhook(d: {
|
|
184
|
+
triggerGroupId: string;
|
|
185
|
+
webhookRegistrationIdentifier: string;
|
|
186
|
+
webhookRegistrationPayload: any;
|
|
187
|
+
}): Promise<SlatesMessageTriggerGroupWebhookUnregisterResponse['result']>;
|
|
188
|
+
setupTriggerGroupWebhookManually(d: {
|
|
189
|
+
triggerGroupId: string;
|
|
190
|
+
webhookUrl: string;
|
|
191
|
+
}): Promise<SlatesMessageTriggerGroupWebhookManualSetupResponse['result']>;
|
|
192
|
+
finishTriggerGroupWebhookManualSetup(d: {
|
|
193
|
+
triggerGroupId: string;
|
|
194
|
+
webhookUrl: string;
|
|
195
|
+
partialWebhookRegistrationPayload: any;
|
|
196
|
+
userWebhookRegistrationPayload: any;
|
|
197
|
+
}): Promise<SlatesMessageTriggerGroupWebhookManualFinishResponse['result']>;
|
|
198
|
+
processTriggerGroupWebhook(d: {
|
|
199
|
+
triggerGroupId: string;
|
|
198
200
|
url: string;
|
|
199
201
|
method: string;
|
|
200
202
|
headers?: Record<string, string>;
|
|
201
203
|
body?: string | Uint8Array | null;
|
|
204
|
+
webhookRegistrationPayload: any;
|
|
205
|
+
}): Promise<SlatesMessageTriggerGroupWebhookProcessResponse['result']>;
|
|
206
|
+
getTriggerGroupRoutingMatchers(triggerGroupId: string): Promise<SlatesMessageTriggerGroupRoutingMatchersGetResponse['result']>;
|
|
207
|
+
pollTriggerGroup(d: {
|
|
208
|
+
triggerGroupId: string;
|
|
202
209
|
state?: any;
|
|
203
|
-
|
|
204
|
-
}): Promise<SlatesMessageActionTriggerWebhookHandleResponse['result']>;
|
|
205
|
-
unregisterTriggerWebhook(d: {
|
|
206
|
-
actionId: string;
|
|
207
|
-
webhookBaseUrl: string;
|
|
208
|
-
registrationDetails: any;
|
|
209
|
-
state?: any;
|
|
210
|
-
}): Promise<SlatesMessageActionTriggerWebhookUnregisterResponse['result']>;
|
|
210
|
+
}): Promise<SlatesMessageTriggerGroupPollingPollResponse['result']>;
|
|
211
211
|
close(): Promise<void>;
|
|
212
212
|
}
|
|
213
213
|
|
|
@@ -260,4 +260,4 @@ declare let createLocalSlateTransport: <ConfigType extends {}, AuthType extends
|
|
|
260
260
|
|
|
261
261
|
declare let createSlatesClient: (opts: SlatesProtocolClientOptions) => SlatesProtocolClient;
|
|
262
262
|
|
|
263
|
-
export { SlateProtocolError, type SlateProtocolErrorKind, type SlateProtocolErrorResponse, type SlateProtocolErrorSource, type SlatesClientState, type SlatesJsonObject, type SlatesMessageTransport, SlatesProtocolClient, type SlatesProtocolClientOptions, type SlatesProtocolMessage, type SlatesProtocolResponse, createLocalSlateTransport, createSlatesClient };
|
|
263
|
+
export { SlateProtocolError, type SlateProtocolErrorKind, type SlateProtocolErrorResponse, type SlateProtocolErrorSource, type SlatesClientState, type SlatesHubCapabilities, type SlatesJsonObject, type SlatesMessageTransport, SlatesProtocolClient, type SlatesProtocolClientOptions, type SlatesProtocolMessage, type SlatesProtocolResponse, createLocalSlateTransport, createSlatesClient };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { SlatesProtocolVersion, SlatesParticipant, SlatesNotifications, SlatesRequests, SlatesResponses, SlatesResponsesByMethod, SlatesMessageProviderIdentifyResponse, SlatesMessageActionsListResponse, SlatesActionTool, SlatesAction, SlatesMessageActionGetResponse, SlatesMessageConfigSchemaGetResponse, SlatesMessageConfigDefaultGetResponse, SlatesMessageConfigChangedResponse, SlateAuthenticationMethod, SlatesMessageAuthMethodGetResponse, SlatesMessageAuthDefaultInputGetResponse, SlatesMessageAuthInputChangedResponse, SlatesMessageAuthOutputGetResponse, SlatesMessageAuthAuthorizationUrlGetResponse, SlatesMessageAuthTokenRefreshHandleResponse, SlatesMessageAuthProfileGetResponse, SlatesMessageActionInvokeResponse, SlatesMessageActionTriggerEventMapResponse,
|
|
1
|
+
import { SlatesProtocolVersion, SlatesParticipant, SlatesMessageHubCapabilitiesSetNotification, SlatesNotifications, SlatesRequests, SlatesResponses, SlatesResponsesByMethod, SlatesMessageProviderIdentifyResponse, SlatesMessageActionsListResponse, SlatesActionTool, SlatesAction, SlatesMessageActionGetResponse, SlatesMessageConfigSchemaGetResponse, SlatesMessageConfigDefaultGetResponse, SlatesMessageConfigChangedResponse, SlateAuthenticationMethod, SlatesMessageAuthMethodGetResponse, SlatesMessageAuthDefaultInputGetResponse, SlatesMessageAuthInputChangedResponse, SlatesMessageAuthOutputGetResponse, SlatesMessageAuthAuthorizationUrlGetResponse, SlatesMessageAuthTokenRefreshHandleResponse, SlatesMessageAuthProfileGetResponse, SlatesMessageActionInvokeResponse, SlatesMessageActionTriggerEventMapResponse, SlatesMessageTriggerGroupsListResponse, SlatesMessageTriggerGroupGetResponse, SlatesMessageTriggerGroupWebhookTargetsListResponse, SlatesMessageTriggerGroupWebhookRegisterResponse, SlatesMessageTriggerGroupWebhookUnregisterResponse, SlatesMessageTriggerGroupWebhookManualSetupResponse, SlatesMessageTriggerGroupWebhookManualFinishResponse, SlatesMessageTriggerGroupWebhookProcessResponse, SlatesMessageTriggerGroupRoutingMatchersGetResponse, SlatesMessageTriggerGroupPollingPollResponse } from '@slates/proto';
|
|
2
2
|
import { Slate, SlateLogListener } from '@slates/provider';
|
|
3
3
|
|
|
4
4
|
type SlatesJsonObject = Record<string, any>;
|
|
5
5
|
type SlatesProtocolMessage = SlatesNotifications | SlatesRequests;
|
|
6
6
|
type SlatesProtocolResponse = SlatesNotifications | SlatesResponses;
|
|
7
|
+
type SlatesHubCapabilities = SlatesMessageHubCapabilitiesSetNotification['params']['capabilities'];
|
|
7
8
|
interface SlatesClientState {
|
|
8
9
|
protocol: SlatesProtocolVersion;
|
|
9
10
|
participants: SlatesParticipant[];
|
|
@@ -16,6 +17,7 @@ interface SlatesClientState {
|
|
|
16
17
|
id: string;
|
|
17
18
|
state: SlatesJsonObject;
|
|
18
19
|
} | null;
|
|
20
|
+
capabilities: SlatesHubCapabilities | null;
|
|
19
21
|
}
|
|
20
22
|
interface SlatesMessageTransport {
|
|
21
23
|
send(messages: SlatesProtocolMessage[]): Promise<SlatesProtocolResponse[]>;
|
|
@@ -36,6 +38,7 @@ declare class SlatesProtocolClient {
|
|
|
36
38
|
setAuth(auth: SlatesClientState['auth']): this;
|
|
37
39
|
clearAuth(): this;
|
|
38
40
|
setSession(session: SlatesClientState['session']): this;
|
|
41
|
+
setCapabilities(capabilities: SlatesClientState['capabilities']): this;
|
|
39
42
|
ensureSession(): {
|
|
40
43
|
id: string;
|
|
41
44
|
state: SlatesJsonObject;
|
|
@@ -90,34 +93,7 @@ declare class SlatesProtocolClient {
|
|
|
90
93
|
}[];
|
|
91
94
|
type: "action.trigger";
|
|
92
95
|
capabilities: Record<string, never>;
|
|
93
|
-
|
|
94
|
-
type: "polling";
|
|
95
|
-
intervalSeconds: number;
|
|
96
|
-
} | {
|
|
97
|
-
type: "webhook";
|
|
98
|
-
autoRegistration: boolean;
|
|
99
|
-
autoUnregistration: boolean;
|
|
100
|
-
http?: {
|
|
101
|
-
methods?: ("GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS")[] | undefined;
|
|
102
|
-
sync?: {
|
|
103
|
-
mode: "match" | "never" | "always";
|
|
104
|
-
match?: {
|
|
105
|
-
method?: string | undefined;
|
|
106
|
-
hasQueryParam?: string | undefined;
|
|
107
|
-
hasHeader?: string | undefined;
|
|
108
|
-
jsonBodyField?: {
|
|
109
|
-
path: string;
|
|
110
|
-
equals?: string | undefined;
|
|
111
|
-
} | undefined;
|
|
112
|
-
formBodyField?: {
|
|
113
|
-
path: string;
|
|
114
|
-
equals?: string | undefined;
|
|
115
|
-
} | undefined;
|
|
116
|
-
}[] | undefined;
|
|
117
|
-
timeoutMs?: number | undefined;
|
|
118
|
-
} | undefined;
|
|
119
|
-
} | undefined;
|
|
120
|
-
};
|
|
96
|
+
triggerGroupId: string;
|
|
121
97
|
description?: string | undefined;
|
|
122
98
|
instructions?: string[] | undefined;
|
|
123
99
|
constraints?: string[] | undefined;
|
|
@@ -192,22 +168,46 @@ declare class SlatesProtocolClient {
|
|
|
192
168
|
}): Promise<SlatesMessageAuthProfileGetResponse['result']>;
|
|
193
169
|
invokeTool(actionId: string, input: Record<string, any>): Promise<SlatesMessageActionInvokeResponse['result']>;
|
|
194
170
|
mapTriggerEvent(actionId: string, input: Record<string, any>): Promise<SlatesMessageActionTriggerEventMapResponse['result']>;
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
171
|
+
listTriggerGroups(): Promise<SlatesMessageTriggerGroupsListResponse['result']>;
|
|
172
|
+
getTriggerGroup(triggerGroupId: string): Promise<SlatesMessageTriggerGroupGetResponse['result']>;
|
|
173
|
+
listTriggerGroupWebhookTargets(d: {
|
|
174
|
+
triggerGroupId: string;
|
|
175
|
+
pageToken?: any;
|
|
176
|
+
}): Promise<SlatesMessageTriggerGroupWebhookTargetsListResponse['result']>;
|
|
177
|
+
registerTriggerGroupWebhook(d: {
|
|
178
|
+
triggerGroupId: string;
|
|
179
|
+
webhookTargetIdentifier: string;
|
|
180
|
+
webhookTargetPayload: any;
|
|
181
|
+
webhookUrl: string;
|
|
182
|
+
}): Promise<SlatesMessageTriggerGroupWebhookRegisterResponse['result']>;
|
|
183
|
+
unregisterTriggerGroupWebhook(d: {
|
|
184
|
+
triggerGroupId: string;
|
|
185
|
+
webhookRegistrationIdentifier: string;
|
|
186
|
+
webhookRegistrationPayload: any;
|
|
187
|
+
}): Promise<SlatesMessageTriggerGroupWebhookUnregisterResponse['result']>;
|
|
188
|
+
setupTriggerGroupWebhookManually(d: {
|
|
189
|
+
triggerGroupId: string;
|
|
190
|
+
webhookUrl: string;
|
|
191
|
+
}): Promise<SlatesMessageTriggerGroupWebhookManualSetupResponse['result']>;
|
|
192
|
+
finishTriggerGroupWebhookManualSetup(d: {
|
|
193
|
+
triggerGroupId: string;
|
|
194
|
+
webhookUrl: string;
|
|
195
|
+
partialWebhookRegistrationPayload: any;
|
|
196
|
+
userWebhookRegistrationPayload: any;
|
|
197
|
+
}): Promise<SlatesMessageTriggerGroupWebhookManualFinishResponse['result']>;
|
|
198
|
+
processTriggerGroupWebhook(d: {
|
|
199
|
+
triggerGroupId: string;
|
|
198
200
|
url: string;
|
|
199
201
|
method: string;
|
|
200
202
|
headers?: Record<string, string>;
|
|
201
203
|
body?: string | Uint8Array | null;
|
|
204
|
+
webhookRegistrationPayload: any;
|
|
205
|
+
}): Promise<SlatesMessageTriggerGroupWebhookProcessResponse['result']>;
|
|
206
|
+
getTriggerGroupRoutingMatchers(triggerGroupId: string): Promise<SlatesMessageTriggerGroupRoutingMatchersGetResponse['result']>;
|
|
207
|
+
pollTriggerGroup(d: {
|
|
208
|
+
triggerGroupId: string;
|
|
202
209
|
state?: any;
|
|
203
|
-
|
|
204
|
-
}): Promise<SlatesMessageActionTriggerWebhookHandleResponse['result']>;
|
|
205
|
-
unregisterTriggerWebhook(d: {
|
|
206
|
-
actionId: string;
|
|
207
|
-
webhookBaseUrl: string;
|
|
208
|
-
registrationDetails: any;
|
|
209
|
-
state?: any;
|
|
210
|
-
}): Promise<SlatesMessageActionTriggerWebhookUnregisterResponse['result']>;
|
|
210
|
+
}): Promise<SlatesMessageTriggerGroupPollingPollResponse['result']>;
|
|
211
211
|
close(): Promise<void>;
|
|
212
212
|
}
|
|
213
213
|
|
|
@@ -260,4 +260,4 @@ declare let createLocalSlateTransport: <ConfigType extends {}, AuthType extends
|
|
|
260
260
|
|
|
261
261
|
declare let createSlatesClient: (opts: SlatesProtocolClientOptions) => SlatesProtocolClient;
|
|
262
262
|
|
|
263
|
-
export { SlateProtocolError, type SlateProtocolErrorKind, type SlateProtocolErrorResponse, type SlateProtocolErrorSource, type SlatesClientState, type SlatesJsonObject, type SlatesMessageTransport, SlatesProtocolClient, type SlatesProtocolClientOptions, type SlatesProtocolMessage, type SlatesProtocolResponse, createLocalSlateTransport, createSlatesClient };
|
|
263
|
+
export { SlateProtocolError, type SlateProtocolErrorKind, type SlateProtocolErrorResponse, type SlateProtocolErrorSource, type SlatesClientState, type SlatesHubCapabilities, type SlatesJsonObject, type SlatesMessageTransport, SlatesProtocolClient, type SlatesProtocolClientOptions, type SlatesProtocolMessage, type SlatesProtocolResponse, createLocalSlateTransport, createSlatesClient };
|
package/dist/index.module.js
CHANGED
|
@@ -109,7 +109,8 @@ var SlatesProtocolClient = class {
|
|
|
109
109
|
participants: opts.participants ?? createDefaultParticipants(),
|
|
110
110
|
config: opts.state?.config ?? null,
|
|
111
111
|
auth: opts.state?.auth ?? null,
|
|
112
|
-
session: opts.state?.session ?? null
|
|
112
|
+
session: opts.state?.session ?? null,
|
|
113
|
+
capabilities: opts.state?.capabilities ?? null
|
|
113
114
|
};
|
|
114
115
|
}
|
|
115
116
|
setParticipants(participants) {
|
|
@@ -132,6 +133,10 @@ var SlatesProtocolClient = class {
|
|
|
132
133
|
this.state.session = session;
|
|
133
134
|
return this;
|
|
134
135
|
}
|
|
136
|
+
setCapabilities(capabilities) {
|
|
137
|
+
this.state.capabilities = capabilities;
|
|
138
|
+
return this;
|
|
139
|
+
}
|
|
135
140
|
ensureSession() {
|
|
136
141
|
if (!this.state.session) {
|
|
137
142
|
this.state.session = {
|
|
@@ -153,6 +158,13 @@ var SlatesProtocolClient = class {
|
|
|
153
158
|
method: "slates/participant.set",
|
|
154
159
|
params: { participants: this.state.participants }
|
|
155
160
|
},
|
|
161
|
+
...this.state.capabilities ? [
|
|
162
|
+
{
|
|
163
|
+
jsonrpc: "2.0",
|
|
164
|
+
method: "slates/hub.capabilities.set",
|
|
165
|
+
params: { capabilities: this.state.capabilities }
|
|
166
|
+
}
|
|
167
|
+
] : [],
|
|
156
168
|
...this.state.config ? [
|
|
157
169
|
{
|
|
158
170
|
jsonrpc: "2.0",
|
|
@@ -299,18 +311,37 @@ var SlatesProtocolClient = class {
|
|
|
299
311
|
input
|
|
300
312
|
});
|
|
301
313
|
}
|
|
302
|
-
async
|
|
314
|
+
async listTriggerGroups() {
|
|
315
|
+
return this.request("slates/trigger_groups.list", {});
|
|
316
|
+
}
|
|
317
|
+
async getTriggerGroup(triggerGroupId) {
|
|
318
|
+
return this.request("slates/trigger_group.get", { triggerGroupId });
|
|
319
|
+
}
|
|
320
|
+
async listTriggerGroupWebhookTargets(d) {
|
|
303
321
|
this.ensureSession();
|
|
304
|
-
return this.request("slates/
|
|
305
|
-
|
|
306
|
-
|
|
322
|
+
return this.request("slates/trigger_group.webhook.targets_list", {
|
|
323
|
+
triggerGroupId: d.triggerGroupId,
|
|
324
|
+
pageToken: d.pageToken ?? null
|
|
307
325
|
});
|
|
308
326
|
}
|
|
309
|
-
async
|
|
327
|
+
async registerTriggerGroupWebhook(d) {
|
|
328
|
+
this.ensureSession();
|
|
329
|
+
return this.request("slates/trigger_group.webhook.register", d);
|
|
330
|
+
}
|
|
331
|
+
async unregisterTriggerGroupWebhook(d) {
|
|
310
332
|
this.ensureSession();
|
|
333
|
+
return this.request("slates/trigger_group.webhook.unregister", d);
|
|
334
|
+
}
|
|
335
|
+
async setupTriggerGroupWebhookManually(d) {
|
|
336
|
+
return this.request("slates/trigger_group.webhook.manual_setup", d);
|
|
337
|
+
}
|
|
338
|
+
async finishTriggerGroupWebhookManualSetup(d) {
|
|
339
|
+
return this.request("slates/trigger_group.webhook.manual_finish", d);
|
|
340
|
+
}
|
|
341
|
+
async processTriggerGroupWebhook(d) {
|
|
311
342
|
let encodedBody = typeof d.body === "string" ? Buffer.from(d.body, "utf-8").toString("base64") : d.body ? Buffer.from(d.body).toString("base64") : null;
|
|
312
|
-
return this.request("slates/
|
|
313
|
-
|
|
343
|
+
return this.request("slates/trigger_group.webhook.process", {
|
|
344
|
+
triggerGroupId: d.triggerGroupId,
|
|
314
345
|
url: d.url,
|
|
315
346
|
method: d.method,
|
|
316
347
|
headers: d.headers ?? {},
|
|
@@ -318,16 +349,17 @@ var SlatesProtocolClient = class {
|
|
|
318
349
|
encoding: "base64",
|
|
319
350
|
content: encodedBody
|
|
320
351
|
} : null,
|
|
321
|
-
|
|
322
|
-
registrationDetails: d.registrationDetails ?? null
|
|
352
|
+
webhookRegistrationPayload: d.webhookRegistrationPayload
|
|
323
353
|
});
|
|
324
354
|
}
|
|
325
|
-
async
|
|
355
|
+
async getTriggerGroupRoutingMatchers(triggerGroupId) {
|
|
356
|
+
this.ensureSession();
|
|
357
|
+
return this.request("slates/trigger_group.routing_matchers.get", { triggerGroupId });
|
|
358
|
+
}
|
|
359
|
+
async pollTriggerGroup(d) {
|
|
326
360
|
this.ensureSession();
|
|
327
|
-
return this.request("slates/
|
|
328
|
-
|
|
329
|
-
webhookBaseUrl: d.webhookBaseUrl,
|
|
330
|
-
registrationDetails: d.registrationDetails,
|
|
361
|
+
return this.request("slates/trigger_group.polling.poll", {
|
|
362
|
+
triggerGroupId: d.triggerGroupId,
|
|
331
363
|
state: d.state ?? null
|
|
332
364
|
});
|
|
333
365
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slates/client",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.23",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -31,9 +31,9 @@
|
|
|
31
31
|
"biome:check": "biome check --write src"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@slates/proto": "1.0.0-rc.
|
|
35
|
-
"@slates/provider": "1.0.0-rc.
|
|
36
|
-
"@slates/provider-handler": "1.0.0-rc.
|
|
34
|
+
"@slates/proto": "1.0.0-rc.19",
|
|
35
|
+
"@slates/provider": "1.0.0-rc.23",
|
|
36
|
+
"@slates/provider-handler": "1.0.0-rc.32"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@slates/tsconfig": "1.0.0-rc.1",
|
package/src/client.test.ts
CHANGED
|
@@ -7,7 +7,8 @@ import {
|
|
|
7
7
|
SlatePublicTool,
|
|
8
8
|
SlateSpecification,
|
|
9
9
|
SlateTool,
|
|
10
|
-
SlateTrigger
|
|
10
|
+
SlateTrigger,
|
|
11
|
+
SlateTriggerGroup
|
|
11
12
|
} from '@slates/provider';
|
|
12
13
|
import { rm } from 'fs/promises';
|
|
13
14
|
import { createServer } from 'http';
|
|
@@ -266,6 +267,18 @@ let createTriggerTraceSlate = () => {
|
|
|
266
267
|
auth
|
|
267
268
|
});
|
|
268
269
|
|
|
270
|
+
let pollTriggerGroup = SlateTriggerGroup.create(spec, {
|
|
271
|
+
key: 'poll_group',
|
|
272
|
+
name: 'Poll Group'
|
|
273
|
+
})
|
|
274
|
+
.polling({
|
|
275
|
+
pollEvents: async () => ({
|
|
276
|
+
events: [{ payload: { id: 'poll-1' } }, { payload: { id: 'poll-2' } }]
|
|
277
|
+
})
|
|
278
|
+
})
|
|
279
|
+
.routingMatchers(async () => [])
|
|
280
|
+
.build();
|
|
281
|
+
|
|
269
282
|
let pollingTrigger = SlateTrigger.create(spec, {
|
|
270
283
|
key: 'poll_trigger',
|
|
271
284
|
name: 'Poll Trigger'
|
|
@@ -281,19 +294,46 @@ let createTriggerTraceSlate = () => {
|
|
|
281
294
|
value: z.string()
|
|
282
295
|
})
|
|
283
296
|
)
|
|
284
|
-
.
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
297
|
+
.triggerGroup(pollTriggerGroup)
|
|
298
|
+
.matches(() => true)
|
|
299
|
+
.map(async ctx => ({
|
|
300
|
+
id: ctx.input.id,
|
|
301
|
+
type: 'poll.event',
|
|
302
|
+
output: {
|
|
290
303
|
type: 'poll.event',
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
304
|
+
value: ctx.input.id
|
|
305
|
+
}
|
|
306
|
+
}))
|
|
307
|
+
.build();
|
|
308
|
+
|
|
309
|
+
let webhookTriggerGroup = SlateTriggerGroup.create(spec, {
|
|
310
|
+
key: 'webhook_group',
|
|
311
|
+
name: 'Webhook Group'
|
|
312
|
+
})
|
|
313
|
+
.webhook({
|
|
314
|
+
manualRegistration: {
|
|
315
|
+
userConfigSchema: z.object({}),
|
|
316
|
+
fullConfigSchema: z.object({}),
|
|
317
|
+
setup: async () => ({
|
|
318
|
+
webhookSetupDocument: '',
|
|
319
|
+
partialWebhookRegistrationPayload: {}
|
|
320
|
+
})
|
|
321
|
+
},
|
|
322
|
+
process: async () => ({
|
|
323
|
+
events: [
|
|
324
|
+
{ matchers: [], payload: { id: 'webhook-1' } },
|
|
325
|
+
{ matchers: [], payload: { id: 'webhook-2' } }
|
|
326
|
+
],
|
|
327
|
+
response: {
|
|
328
|
+
status: 202,
|
|
329
|
+
headers: {
|
|
330
|
+
'x-trigger-result': 'accepted'
|
|
331
|
+
},
|
|
332
|
+
body: 'accepted'
|
|
294
333
|
}
|
|
295
334
|
})
|
|
296
335
|
})
|
|
336
|
+
.routingMatchers(async () => [])
|
|
297
337
|
.build();
|
|
298
338
|
|
|
299
339
|
let webhookTrigger = SlateTrigger.create(spec, {
|
|
@@ -311,32 +351,23 @@ let createTriggerTraceSlate = () => {
|
|
|
311
351
|
value: z.string()
|
|
312
352
|
})
|
|
313
353
|
)
|
|
314
|
-
.
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
'x-trigger-result': 'accepted'
|
|
321
|
-
},
|
|
322
|
-
body: 'accepted'
|
|
323
|
-
}
|
|
324
|
-
}),
|
|
325
|
-
handleEvent: async ctx => ({
|
|
326
|
-
id: ctx.input.id,
|
|
354
|
+
.triggerGroup(webhookTriggerGroup)
|
|
355
|
+
.matches(() => true)
|
|
356
|
+
.map(async ctx => ({
|
|
357
|
+
id: ctx.input.id,
|
|
358
|
+
type: 'webhook.event',
|
|
359
|
+
output: {
|
|
327
360
|
type: 'webhook.event',
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
}
|
|
332
|
-
})
|
|
333
|
-
})
|
|
361
|
+
value: ctx.input.id
|
|
362
|
+
}
|
|
363
|
+
}))
|
|
334
364
|
.build();
|
|
335
365
|
|
|
336
366
|
return Slate.create({
|
|
337
367
|
spec,
|
|
338
368
|
tools: [],
|
|
339
|
-
triggers: [pollingTrigger, webhookTrigger]
|
|
369
|
+
triggers: [pollingTrigger, webhookTrigger],
|
|
370
|
+
triggerGroups: [pollTriggerGroup, webhookTriggerGroup]
|
|
340
371
|
});
|
|
341
372
|
};
|
|
342
373
|
|
|
@@ -699,20 +730,20 @@ describe('@slates/client local transport', () => {
|
|
|
699
730
|
|
|
700
731
|
client.ensureSession();
|
|
701
732
|
|
|
702
|
-
await client.
|
|
703
|
-
|
|
733
|
+
await client.pollTriggerGroup({
|
|
734
|
+
triggerGroupId: 'poll_group',
|
|
704
735
|
state: null
|
|
705
736
|
});
|
|
706
737
|
|
|
707
|
-
let webhookResult = await client.
|
|
708
|
-
|
|
738
|
+
let webhookResult = await client.processTriggerGroupWebhook({
|
|
739
|
+
triggerGroupId: 'webhook_group',
|
|
709
740
|
url: 'https://example.com/webhook',
|
|
710
741
|
method: 'POST',
|
|
711
742
|
headers: {
|
|
712
743
|
'content-type': 'application/json'
|
|
713
744
|
},
|
|
714
745
|
body: null,
|
|
715
|
-
|
|
746
|
+
webhookRegistrationPayload: null
|
|
716
747
|
});
|
|
717
748
|
expect(webhookResult.response).toEqual({
|
|
718
749
|
status: 202,
|
|
@@ -731,24 +762,24 @@ describe('@slates/client local transport', () => {
|
|
|
731
762
|
expect.arrayContaining([
|
|
732
763
|
expect.objectContaining({
|
|
733
764
|
type: 'info',
|
|
734
|
-
message: 'Polled 2 event(s) for trigger "Poll
|
|
765
|
+
message: 'Polled 2 event(s) for trigger group "Poll Group" (poll_group)',
|
|
735
766
|
data: expect.objectContaining({
|
|
736
767
|
component: 'action',
|
|
737
768
|
functionName: 'pollEvents',
|
|
738
|
-
|
|
739
|
-
|
|
769
|
+
eventCount: 2,
|
|
770
|
+
triggerGroupId: 'poll_group'
|
|
740
771
|
})
|
|
741
772
|
}),
|
|
742
773
|
expect.objectContaining({
|
|
743
774
|
type: 'info',
|
|
744
775
|
message:
|
|
745
|
-
'
|
|
776
|
+
'Extracted 2 event(s) from webhook request for trigger group "Webhook Group" (webhook_group)',
|
|
746
777
|
data: expect.objectContaining({
|
|
747
778
|
component: 'action',
|
|
748
|
-
functionName: '
|
|
749
|
-
|
|
779
|
+
functionName: 'webhookProcess',
|
|
780
|
+
eventCount: 2,
|
|
750
781
|
hasResponse: true,
|
|
751
|
-
|
|
782
|
+
triggerGroupId: 'webhook_group'
|
|
752
783
|
})
|
|
753
784
|
})
|
|
754
785
|
])
|
package/src/client.ts
CHANGED
|
@@ -7,9 +7,6 @@ import {
|
|
|
7
7
|
type SlatesMessageActionInvokeResponse,
|
|
8
8
|
type SlatesMessageActionsListResponse,
|
|
9
9
|
type SlatesMessageActionTriggerEventMapResponse,
|
|
10
|
-
type SlatesMessageActionTriggerWebhookHandleResponse,
|
|
11
|
-
type SlatesMessageActionTriggerWebhookRegisterResponse,
|
|
12
|
-
type SlatesMessageActionTriggerWebhookUnregisterResponse,
|
|
13
10
|
type SlatesMessageAuthAuthorizationUrlGetResponse,
|
|
14
11
|
type SlatesMessageAuthDefaultInputGetResponse,
|
|
15
12
|
type SlatesMessageAuthInputChangedResponse,
|
|
@@ -21,6 +18,16 @@ import {
|
|
|
21
18
|
type SlatesMessageConfigDefaultGetResponse,
|
|
22
19
|
type SlatesMessageConfigSchemaGetResponse,
|
|
23
20
|
type SlatesMessageProviderIdentifyResponse,
|
|
21
|
+
type SlatesMessageTriggerGroupGetResponse,
|
|
22
|
+
type SlatesMessageTriggerGroupPollingPollResponse,
|
|
23
|
+
type SlatesMessageTriggerGroupRoutingMatchersGetResponse,
|
|
24
|
+
type SlatesMessageTriggerGroupsListResponse,
|
|
25
|
+
type SlatesMessageTriggerGroupWebhookManualFinishResponse,
|
|
26
|
+
type SlatesMessageTriggerGroupWebhookManualSetupResponse,
|
|
27
|
+
type SlatesMessageTriggerGroupWebhookProcessResponse,
|
|
28
|
+
type SlatesMessageTriggerGroupWebhookRegisterResponse,
|
|
29
|
+
type SlatesMessageTriggerGroupWebhookTargetsListResponse,
|
|
30
|
+
type SlatesMessageTriggerGroupWebhookUnregisterResponse,
|
|
24
31
|
type SlatesParticipant,
|
|
25
32
|
type SlatesRequests,
|
|
26
33
|
type SlatesResponsesByMethod
|
|
@@ -48,7 +55,8 @@ export class SlatesProtocolClient {
|
|
|
48
55
|
participants: opts.participants ?? createDefaultParticipants(),
|
|
49
56
|
config: opts.state?.config ?? null,
|
|
50
57
|
auth: opts.state?.auth ?? null,
|
|
51
|
-
session: opts.state?.session ?? null
|
|
58
|
+
session: opts.state?.session ?? null,
|
|
59
|
+
capabilities: opts.state?.capabilities ?? null
|
|
52
60
|
};
|
|
53
61
|
}
|
|
54
62
|
|
|
@@ -77,6 +85,11 @@ export class SlatesProtocolClient {
|
|
|
77
85
|
return this;
|
|
78
86
|
}
|
|
79
87
|
|
|
88
|
+
setCapabilities(capabilities: SlatesClientState['capabilities']) {
|
|
89
|
+
this.state.capabilities = capabilities;
|
|
90
|
+
return this;
|
|
91
|
+
}
|
|
92
|
+
|
|
80
93
|
ensureSession() {
|
|
81
94
|
if (!this.state.session) {
|
|
82
95
|
this.state.session = {
|
|
@@ -100,6 +113,15 @@ export class SlatesProtocolClient {
|
|
|
100
113
|
method: 'slates/participant.set' as const,
|
|
101
114
|
params: { participants: this.state.participants }
|
|
102
115
|
},
|
|
116
|
+
...(this.state.capabilities
|
|
117
|
+
? [
|
|
118
|
+
{
|
|
119
|
+
jsonrpc: '2.0' as const,
|
|
120
|
+
method: 'slates/hub.capabilities.set' as const,
|
|
121
|
+
params: { capabilities: this.state.capabilities }
|
|
122
|
+
}
|
|
123
|
+
]
|
|
124
|
+
: []),
|
|
103
125
|
...(this.state.config
|
|
104
126
|
? [
|
|
105
127
|
{
|
|
@@ -341,27 +363,70 @@ export class SlatesProtocolClient {
|
|
|
341
363
|
});
|
|
342
364
|
}
|
|
343
365
|
|
|
344
|
-
async
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
366
|
+
async listTriggerGroups(): Promise<SlatesMessageTriggerGroupsListResponse['result']> {
|
|
367
|
+
return this.request('slates/trigger_groups.list', {});
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
async getTriggerGroup(
|
|
371
|
+
triggerGroupId: string
|
|
372
|
+
): Promise<SlatesMessageTriggerGroupGetResponse['result']> {
|
|
373
|
+
return this.request('slates/trigger_group.get', { triggerGroupId });
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
async listTriggerGroupWebhookTargets(d: {
|
|
377
|
+
triggerGroupId: string;
|
|
378
|
+
pageToken?: any;
|
|
379
|
+
}): Promise<SlatesMessageTriggerGroupWebhookTargetsListResponse['result']> {
|
|
348
380
|
this.ensureSession();
|
|
349
|
-
return this.request('slates/
|
|
350
|
-
|
|
351
|
-
|
|
381
|
+
return this.request('slates/trigger_group.webhook.targets_list', {
|
|
382
|
+
triggerGroupId: d.triggerGroupId,
|
|
383
|
+
pageToken: d.pageToken ?? null
|
|
352
384
|
});
|
|
353
385
|
}
|
|
354
386
|
|
|
355
|
-
async
|
|
356
|
-
|
|
387
|
+
async registerTriggerGroupWebhook(d: {
|
|
388
|
+
triggerGroupId: string;
|
|
389
|
+
webhookTargetIdentifier: string;
|
|
390
|
+
webhookTargetPayload: any;
|
|
391
|
+
webhookUrl: string;
|
|
392
|
+
}): Promise<SlatesMessageTriggerGroupWebhookRegisterResponse['result']> {
|
|
393
|
+
this.ensureSession();
|
|
394
|
+
return this.request('slates/trigger_group.webhook.register', d);
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
async unregisterTriggerGroupWebhook(d: {
|
|
398
|
+
triggerGroupId: string;
|
|
399
|
+
webhookRegistrationIdentifier: string;
|
|
400
|
+
webhookRegistrationPayload: any;
|
|
401
|
+
}): Promise<SlatesMessageTriggerGroupWebhookUnregisterResponse['result']> {
|
|
402
|
+
this.ensureSession();
|
|
403
|
+
return this.request('slates/trigger_group.webhook.unregister', d);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
async setupTriggerGroupWebhookManually(d: {
|
|
407
|
+
triggerGroupId: string;
|
|
408
|
+
webhookUrl: string;
|
|
409
|
+
}): Promise<SlatesMessageTriggerGroupWebhookManualSetupResponse['result']> {
|
|
410
|
+
return this.request('slates/trigger_group.webhook.manual_setup', d);
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
async finishTriggerGroupWebhookManualSetup(d: {
|
|
414
|
+
triggerGroupId: string;
|
|
415
|
+
webhookUrl: string;
|
|
416
|
+
partialWebhookRegistrationPayload: any;
|
|
417
|
+
userWebhookRegistrationPayload: any;
|
|
418
|
+
}): Promise<SlatesMessageTriggerGroupWebhookManualFinishResponse['result']> {
|
|
419
|
+
return this.request('slates/trigger_group.webhook.manual_finish', d);
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
async processTriggerGroupWebhook(d: {
|
|
423
|
+
triggerGroupId: string;
|
|
357
424
|
url: string;
|
|
358
425
|
method: string;
|
|
359
426
|
headers?: Record<string, string>;
|
|
360
427
|
body?: string | Uint8Array | null;
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
}): Promise<SlatesMessageActionTriggerWebhookHandleResponse['result']> {
|
|
364
|
-
this.ensureSession();
|
|
428
|
+
webhookRegistrationPayload: any;
|
|
429
|
+
}): Promise<SlatesMessageTriggerGroupWebhookProcessResponse['result']> {
|
|
365
430
|
let encodedBody =
|
|
366
431
|
typeof d.body === 'string'
|
|
367
432
|
? Buffer.from(d.body, 'utf-8').toString('base64')
|
|
@@ -369,8 +434,8 @@ export class SlatesProtocolClient {
|
|
|
369
434
|
? Buffer.from(d.body).toString('base64')
|
|
370
435
|
: null;
|
|
371
436
|
|
|
372
|
-
return this.request('slates/
|
|
373
|
-
|
|
437
|
+
return this.request('slates/trigger_group.webhook.process', {
|
|
438
|
+
triggerGroupId: d.triggerGroupId,
|
|
374
439
|
url: d.url,
|
|
375
440
|
method: d.method,
|
|
376
441
|
headers: d.headers ?? {},
|
|
@@ -380,22 +445,24 @@ export class SlatesProtocolClient {
|
|
|
380
445
|
content: encodedBody
|
|
381
446
|
}
|
|
382
447
|
: null,
|
|
383
|
-
|
|
384
|
-
registrationDetails: d.registrationDetails ?? null
|
|
448
|
+
webhookRegistrationPayload: d.webhookRegistrationPayload
|
|
385
449
|
});
|
|
386
450
|
}
|
|
387
451
|
|
|
388
|
-
async
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
452
|
+
async getTriggerGroupRoutingMatchers(
|
|
453
|
+
triggerGroupId: string
|
|
454
|
+
): Promise<SlatesMessageTriggerGroupRoutingMatchersGetResponse['result']> {
|
|
455
|
+
this.ensureSession();
|
|
456
|
+
return this.request('slates/trigger_group.routing_matchers.get', { triggerGroupId });
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
async pollTriggerGroup(d: {
|
|
460
|
+
triggerGroupId: string;
|
|
392
461
|
state?: any;
|
|
393
|
-
}): Promise<
|
|
462
|
+
}): Promise<SlatesMessageTriggerGroupPollingPollResponse['result']> {
|
|
394
463
|
this.ensureSession();
|
|
395
|
-
return this.request('slates/
|
|
396
|
-
|
|
397
|
-
webhookBaseUrl: d.webhookBaseUrl,
|
|
398
|
-
registrationDetails: d.registrationDetails,
|
|
464
|
+
return this.request('slates/trigger_group.polling.poll', {
|
|
465
|
+
triggerGroupId: d.triggerGroupId,
|
|
399
466
|
state: d.state ?? null
|
|
400
467
|
});
|
|
401
468
|
}
|
package/src/types.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type {
|
|
2
|
+
SlatesMessageHubCapabilitiesSetNotification,
|
|
2
3
|
SlatesNotifications,
|
|
3
4
|
SlatesParticipant,
|
|
4
5
|
SlatesProtocolVersion,
|
|
@@ -10,6 +11,9 @@ export type SlatesJsonObject = Record<string, any>;
|
|
|
10
11
|
export type SlatesProtocolMessage = SlatesNotifications | SlatesRequests;
|
|
11
12
|
export type SlatesProtocolResponse = SlatesNotifications | SlatesResponses;
|
|
12
13
|
|
|
14
|
+
export type SlatesHubCapabilities =
|
|
15
|
+
SlatesMessageHubCapabilitiesSetNotification['params']['capabilities'];
|
|
16
|
+
|
|
13
17
|
export interface SlatesClientState {
|
|
14
18
|
protocol: SlatesProtocolVersion;
|
|
15
19
|
participants: SlatesParticipant[];
|
|
@@ -22,6 +26,7 @@ export interface SlatesClientState {
|
|
|
22
26
|
id: string;
|
|
23
27
|
state: SlatesJsonObject;
|
|
24
28
|
} | null;
|
|
29
|
+
capabilities: SlatesHubCapabilities | null;
|
|
25
30
|
}
|
|
26
31
|
|
|
27
32
|
export interface SlatesMessageTransport {
|