@slates/provider 1.0.0-rc.16 → 1.0.0-rc.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +639 -21
- package/dist/index.d.cts +290 -29
- package/dist/index.d.ts +290 -29
- package/dist/index.module.js +606 -18
- package/package.json +2 -2
- package/src/action/action.ts +64 -2
- package/src/action/builder.test.ts +136 -0
- package/src/action/builder.ts +73 -13
- package/src/action/index.ts +2 -1
- package/src/action/publicTool.ts +36 -0
- package/src/action/tool.ts +15 -3
- package/src/action/trigger.ts +9 -1
- package/src/adapter/adapter.ts +38 -0
- package/src/adapter/index.test.ts +322 -0
- package/src/adapter/index.ts +2 -0
- package/src/adapter/spec.ts +154 -0
- package/src/auth/index.ts +1 -0
- package/src/auth/oauth.test.ts +83 -0
- package/src/auth/oauth.ts +150 -0
- package/src/auth/types.ts +22 -6
- package/src/axios/http.test.ts +83 -0
- package/src/axios/index.ts +59 -1
- package/src/axios/trace.ts +3 -3
- package/src/context/context.ts +37 -14
- package/src/context/hook.ts +5 -10
- package/src/crypto/hmac.test.ts +40 -0
- package/src/crypto/hmac.ts +32 -0
- package/src/crypto/index.ts +1 -0
- package/src/error/api.test.ts +114 -0
- package/src/error/api.ts +236 -0
- package/src/error/index.ts +1 -0
- package/src/file/index.test.ts +36 -0
- package/src/file/index.ts +27 -0
- package/src/index.ts +5 -0
- package/src/object/index.test.ts +38 -0
- package/src/object/index.ts +12 -0
- package/src/specification/slate.ts +38 -2
- package/src/webhook/graph.test.ts +37 -0
- package/src/webhook/graph.ts +22 -0
- package/src/webhook/index.ts +2 -0
- package/src/webhook/meta.test.ts +52 -0
- package/src/webhook/meta.ts +43 -0
package/dist/index.d.ts
CHANGED
|
@@ -145,6 +145,7 @@ type SlateAuthWithToken<InputType extends {}, OutputType extends {
|
|
|
145
145
|
docs?: SlateAuthDocsReference[];
|
|
146
146
|
getOutput: (ctx: {
|
|
147
147
|
input: InputType;
|
|
148
|
+
config?: SlateAuthCallbackConfig;
|
|
148
149
|
}) => Promise<{
|
|
149
150
|
output: OutputType;
|
|
150
151
|
scopes?: string[];
|
|
@@ -159,6 +160,8 @@ type SlateAuthWithToken<InputType extends {}, OutputType extends {
|
|
|
159
160
|
getProfile?: (ctx: {
|
|
160
161
|
output: OutputType;
|
|
161
162
|
input: InputType;
|
|
163
|
+
scopes: string[];
|
|
164
|
+
config?: SlateAuthCallbackConfig;
|
|
162
165
|
}) => Promise<{
|
|
163
166
|
profile: Record<string, any>;
|
|
164
167
|
}>;
|
|
@@ -171,6 +174,7 @@ type SlateAuthWithServiceAccount<InputType extends {}, OutputType extends {}> =
|
|
|
171
174
|
docs?: SlateAuthDocsReference[];
|
|
172
175
|
getOutput: (ctx: {
|
|
173
176
|
input: InputType;
|
|
177
|
+
config?: SlateAuthCallbackConfig;
|
|
174
178
|
}) => Promise<{
|
|
175
179
|
output: OutputType;
|
|
176
180
|
scopes?: string[];
|
|
@@ -185,6 +189,8 @@ type SlateAuthWithServiceAccount<InputType extends {}, OutputType extends {}> =
|
|
|
185
189
|
getProfile?: (ctx: {
|
|
186
190
|
output: OutputType;
|
|
187
191
|
input: InputType;
|
|
192
|
+
scopes: string[];
|
|
193
|
+
config?: SlateAuthCallbackConfig;
|
|
188
194
|
}) => Promise<{
|
|
189
195
|
profile: Record<string, any>;
|
|
190
196
|
}>;
|
|
@@ -197,6 +203,7 @@ type SlateAuthWithCustomData<InputType extends {}, OutputType extends {}> = {
|
|
|
197
203
|
docs?: SlateAuthDocsReference[];
|
|
198
204
|
getOutput: (ctx: {
|
|
199
205
|
input: InputType;
|
|
206
|
+
config?: SlateAuthCallbackConfig;
|
|
200
207
|
}) => Promise<{
|
|
201
208
|
output: OutputType;
|
|
202
209
|
scopes?: string[];
|
|
@@ -207,6 +214,7 @@ type SlateAuthWithCustomData<InputType extends {}, OutputType extends {}> = {
|
|
|
207
214
|
clientId: string;
|
|
208
215
|
clientSecret: string;
|
|
209
216
|
scopes: string[];
|
|
217
|
+
config?: SlateAuthCallbackConfig;
|
|
210
218
|
}) => Promise<{
|
|
211
219
|
output: OutputType;
|
|
212
220
|
input?: InputType;
|
|
@@ -221,6 +229,8 @@ type SlateAuthWithCustomData<InputType extends {}, OutputType extends {}> = {
|
|
|
221
229
|
getProfile?: (ctx: {
|
|
222
230
|
output: OutputType;
|
|
223
231
|
input: InputType;
|
|
232
|
+
scopes: string[];
|
|
233
|
+
config?: SlateAuthCallbackConfig;
|
|
224
234
|
}) => Promise<{
|
|
225
235
|
profile: Record<string, any>;
|
|
226
236
|
}>;
|
|
@@ -264,6 +274,34 @@ declare class SlateAuth<OutputType extends {} = {}> {
|
|
|
264
274
|
}
|
|
265
275
|
declare let auth: <OutputType extends {} = {}>() => SlateAuth<OutputType>;
|
|
266
276
|
|
|
277
|
+
type OAuthTokenResponse = {
|
|
278
|
+
access_token?: unknown;
|
|
279
|
+
refresh_token?: unknown;
|
|
280
|
+
expires_in?: unknown;
|
|
281
|
+
[key: string]: unknown;
|
|
282
|
+
};
|
|
283
|
+
type OAuthRefreshTokenFallbackMode = 'nullish' | 'falsy';
|
|
284
|
+
type OAuthExpiresAtOptions = {
|
|
285
|
+
nowMs?: number;
|
|
286
|
+
providerLabel?: string;
|
|
287
|
+
operation?: string;
|
|
288
|
+
required?: boolean;
|
|
289
|
+
expiresInType?: 'number' | 'numberLike';
|
|
290
|
+
message?: string;
|
|
291
|
+
};
|
|
292
|
+
type NormalizeOAuthTokenResponseOptions = OAuthExpiresAtOptions & {
|
|
293
|
+
previousRefreshToken?: string;
|
|
294
|
+
refreshTokenFallbackMode?: OAuthRefreshTokenFallbackMode;
|
|
295
|
+
accessTokenMessage?: string;
|
|
296
|
+
expiresInMessage?: string;
|
|
297
|
+
};
|
|
298
|
+
declare let getOAuthExpiresAtFromExpiresIn: (expiresIn: unknown, options?: OAuthExpiresAtOptions) => string | undefined;
|
|
299
|
+
declare let normalizeOAuthTokenResponse: (data: unknown, options?: NormalizeOAuthTokenResponseOptions) => {
|
|
300
|
+
token: string;
|
|
301
|
+
refreshToken: string | undefined;
|
|
302
|
+
expiresAt: string | undefined;
|
|
303
|
+
};
|
|
304
|
+
|
|
267
305
|
declare class SlateConfig<ConfigType extends {}> {
|
|
268
306
|
#private;
|
|
269
307
|
private constructor();
|
|
@@ -320,18 +358,17 @@ declare class SlateSpecification<ConfigType extends {}, AuthType extends {}> {
|
|
|
320
358
|
}
|
|
321
359
|
declare let spec: <ConfigType extends {}, AuthType extends {}>(params: SlateSpecificationCreateParameters<ConfigType, AuthType>) => SlateSpecification<ConfigType, AuthType>;
|
|
322
360
|
|
|
323
|
-
declare class
|
|
361
|
+
declare class SlatePublicContext<InputType extends {}> {
|
|
324
362
|
#private;
|
|
325
363
|
private readonly spec;
|
|
326
364
|
private readonly logger;
|
|
327
|
-
constructor(
|
|
328
|
-
get specification(): SlateSpecification<
|
|
329
|
-
get config(): Readonly<ConfigType>;
|
|
365
|
+
constructor(input: InputType, spec: SlateSpecification<any, any>, logger: SlateLogger);
|
|
366
|
+
get specification(): SlateSpecification<any, any>;
|
|
330
367
|
get input(): Readonly<InputType>;
|
|
331
368
|
get event(): Readonly<InputType>;
|
|
332
369
|
get state(): "state" extends keyof InputType ? InputType["state"] : never;
|
|
333
370
|
get request(): "request" extends keyof InputType ? InputType["request"] : never;
|
|
334
|
-
get
|
|
371
|
+
get registrationDetails(): "registrationDetails" extends keyof InputType ? InputType["registrationDetails"] : never;
|
|
335
372
|
recordHttpTrace(trace: SlateHttpTrace): void;
|
|
336
373
|
getHttpTraces(): {
|
|
337
374
|
error?: {
|
|
@@ -358,8 +395,14 @@ declare class SlateContext<ConfigType extends {}, AuthType extends {}, InputType
|
|
|
358
395
|
error(message: SlateLogMessageInput): void;
|
|
359
396
|
progress(message: SlateLogMessageInput): void;
|
|
360
397
|
}
|
|
398
|
+
declare class SlateContext<ConfigType extends {}, AuthType extends {}, InputType extends {}> extends SlatePublicContext<InputType> {
|
|
399
|
+
#private;
|
|
400
|
+
constructor(config: ConfigType, input: InputType, auth: AuthType, spec: SlateSpecification<ConfigType, AuthType>, logger: SlateLogger);
|
|
401
|
+
get config(): Readonly<ConfigType>;
|
|
402
|
+
get auth(): Readonly<AuthType>;
|
|
403
|
+
}
|
|
361
404
|
|
|
362
|
-
declare let runWithContext: <
|
|
405
|
+
declare let runWithContext: <InputType extends {}, RV>(context: SlatePublicContext<InputType>, fn: () => Promise<RV>) => Promise<RV>;
|
|
363
406
|
declare let getCurrentContext: <ConfigType extends {}, AuthType extends {}, InputType extends {}>() => SlateContext<ConfigType, AuthType, InputType>;
|
|
364
407
|
|
|
365
408
|
interface SlateAttachmentUrlContent {
|
|
@@ -401,12 +444,19 @@ interface SlateActionParameters {
|
|
|
401
444
|
scopes?: SlateActionScopes;
|
|
402
445
|
authMethods?: string[];
|
|
403
446
|
docs?: SlateActionDocsReference[];
|
|
447
|
+
adapter?: string | null;
|
|
448
|
+
isPublic?: boolean;
|
|
404
449
|
}
|
|
405
450
|
type SlateToolInvocationHandler<ConfigType extends {}, AuthType extends {}, InputType extends {}, OutputType extends {}> = (context: SlateContext<ConfigType, AuthType, InputType>) => Promise<{
|
|
406
451
|
output: OutputType;
|
|
407
452
|
message: string;
|
|
408
453
|
attachments?: SlateAttachment[];
|
|
409
454
|
}>;
|
|
455
|
+
type SlatePublicToolInvocationHandler<InputType extends {}, OutputType extends {}> = (context: SlatePublicContext<InputType>) => Promise<{
|
|
456
|
+
output: OutputType;
|
|
457
|
+
message: string;
|
|
458
|
+
attachments?: SlateAttachment[];
|
|
459
|
+
}>;
|
|
410
460
|
type SlateTriggerMappingHandler<ConfigType extends {}, AuthType extends {}, InputType extends {}, OutputType extends {}> = (context: SlateContext<ConfigType, AuthType, InputType>) => Promise<{
|
|
411
461
|
type: string;
|
|
412
462
|
id: string;
|
|
@@ -418,12 +468,41 @@ type SlateTriggerPollingHandler<ConfigType extends {}, AuthType extends {}, Inpu
|
|
|
418
468
|
inputs: InputType[];
|
|
419
469
|
updatedState?: any;
|
|
420
470
|
}>;
|
|
471
|
+
interface SlateWebhookHttpResponseInit {
|
|
472
|
+
status?: number;
|
|
473
|
+
headers?: Record<string, string>;
|
|
474
|
+
body?: string | Uint8Array | null;
|
|
475
|
+
}
|
|
476
|
+
type SlateWebhookHttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS';
|
|
477
|
+
interface SlateWebhookRequestMatcher {
|
|
478
|
+
method?: string;
|
|
479
|
+
hasQueryParam?: string;
|
|
480
|
+
hasHeader?: string;
|
|
481
|
+
jsonBodyField?: {
|
|
482
|
+
path: string;
|
|
483
|
+
equals?: string;
|
|
484
|
+
};
|
|
485
|
+
formBodyField?: {
|
|
486
|
+
path: string;
|
|
487
|
+
equals?: string;
|
|
488
|
+
};
|
|
489
|
+
}
|
|
490
|
+
interface SlateWebhookHttpOptions {
|
|
491
|
+
methods?: SlateWebhookHttpMethod[];
|
|
492
|
+
sync?: {
|
|
493
|
+
mode: 'never' | 'match' | 'always';
|
|
494
|
+
match?: SlateWebhookRequestMatcher[];
|
|
495
|
+
timeoutMs?: number;
|
|
496
|
+
};
|
|
497
|
+
}
|
|
421
498
|
type SlateTriggerWebhookRequestHandler<ConfigType extends {}, AuthType extends {}, InputType extends {}> = (context: SlateContext<ConfigType, AuthType, {
|
|
422
499
|
request: Request;
|
|
423
500
|
state: any | null;
|
|
501
|
+
registrationDetails: any | null;
|
|
424
502
|
}>) => Promise<{
|
|
425
503
|
inputs: InputType[];
|
|
426
504
|
updatedState?: any;
|
|
505
|
+
response?: Response | SlateWebhookHttpResponseInit;
|
|
427
506
|
}>;
|
|
428
507
|
type SlateTriggerWebhookAutoRegistrationHandler<ConfigType extends {}, AuthType extends {}> = (context: SlateContext<ConfigType, AuthType, {
|
|
429
508
|
webhookBaseUrl: string;
|
|
@@ -449,6 +528,7 @@ interface SlateActionParametersTrigger<ConfigType extends {}, AuthType extends {
|
|
|
449
528
|
polling?: SlatePollingOptions;
|
|
450
529
|
handleEvent: SlateTriggerMappingHandler<ConfigType, AuthType, InputType, OutputType>;
|
|
451
530
|
handleRequest?: SlateTriggerWebhookRequestHandler<ConfigType, AuthType, InputType>;
|
|
531
|
+
http?: SlateWebhookHttpOptions;
|
|
452
532
|
pollEvents?: SlateTriggerPollingHandler<ConfigType, AuthType, InputType>;
|
|
453
533
|
autoRegisterWebhook?: SlateTriggerWebhookAutoRegistrationHandler<ConfigType, AuthType>;
|
|
454
534
|
autoUnregisterWebhook?: SlateTriggerWebhookAutoUnregistrationHandler<ConfigType, AuthType>;
|
|
@@ -485,35 +565,66 @@ declare abstract class SlateAction<Type extends SlateActionType, ConfigType exte
|
|
|
485
565
|
get scopes(): SlateActionScopes | undefined;
|
|
486
566
|
get authMethods(): string[] | undefined;
|
|
487
567
|
get docs(): SlateActionDocsReference[] | undefined;
|
|
568
|
+
get adapter(): string | null;
|
|
569
|
+
get isPublic(): boolean;
|
|
488
570
|
}
|
|
489
571
|
|
|
490
|
-
declare class SlateActionBuilder<Type extends SlateActionType, ConfigType extends {}, AuthType extends {}, InputType extends {}, OutputType extends {}, Result extends SlateAction<Type, ConfigType, AuthType, any, any
|
|
572
|
+
declare class SlateActionBuilder<Type extends SlateActionType, ConfigType extends {}, AuthType extends {}, InputType extends {}, OutputType extends {}, Result extends SlateAction<Type, ConfigType, AuthType, any, any>, IsPublic extends boolean = false> {
|
|
491
573
|
#private;
|
|
492
574
|
private readonly type;
|
|
493
575
|
readonly spec: SlateSpecification<ConfigType, AuthType>;
|
|
494
576
|
private readonly params;
|
|
495
577
|
private readonly factory;
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
578
|
+
private readonly isPublicTool;
|
|
579
|
+
constructor(type: Type, spec: SlateSpecification<ConfigType, AuthType>, params: SlateActionParameters, factory: (params: SlateActionCreateParameters<any, any, any, any>) => Result, isPublicTool?: IsPublic);
|
|
580
|
+
input<NewInputType extends {}>(schema: z.ZodType<NewInputType>): SlateActionBuilder<Type, ConfigType, AuthType, NewInputType, OutputType, Result, IsPublic>;
|
|
581
|
+
output<NewOutputType extends {}>(schema: z.ZodType<NewOutputType>): SlateActionBuilder<Type, ConfigType, AuthType, InputType, NewOutputType, Result, IsPublic>;
|
|
582
|
+
lockInterface(): SlateActionBuilder<Type, ConfigType, AuthType, InputType, OutputType, Result, IsPublic>;
|
|
583
|
+
scopes(scopes: SlateActionScopes): SlateActionBuilder<Type, ConfigType, AuthType, InputType, OutputType, Result, IsPublic>;
|
|
584
|
+
authMethods(authMethods: string[]): SlateActionBuilder<Type, ConfigType, AuthType, InputType, OutputType, Result, IsPublic>;
|
|
501
585
|
private validateAuthMethods;
|
|
502
|
-
handleInvocation(handler: SlateToolInvocationHandler<ConfigType, AuthType, InputType, OutputType>): SlateActionBuilder<Type, ConfigType, AuthType, InputType, OutputType, Result>;
|
|
586
|
+
handleInvocation(handler: IsPublic extends true ? SlatePublicToolInvocationHandler<InputType, OutputType> : SlateToolInvocationHandler<ConfigType, AuthType, InputType, OutputType>): SlateActionBuilder<Type, ConfigType, AuthType, InputType, OutputType, Result, IsPublic>;
|
|
503
587
|
webhook(props: {
|
|
504
588
|
handleEvent: SlateTriggerMappingHandler<ConfigType, AuthType, InputType, OutputType>;
|
|
505
589
|
handleRequest: SlateTriggerWebhookRequestHandler<ConfigType, AuthType, InputType>;
|
|
506
590
|
autoRegisterWebhook?: SlateTriggerWebhookAutoRegistrationHandler<ConfigType, AuthType>;
|
|
507
591
|
autoUnregisterWebhook?: SlateTriggerWebhookAutoUnregistrationHandler<ConfigType, AuthType>;
|
|
508
|
-
|
|
592
|
+
http?: SlateWebhookHttpOptions;
|
|
593
|
+
}): SlateActionBuilder<Type, ConfigType, AuthType, InputType, OutputType, Result, IsPublic>;
|
|
509
594
|
polling(props: {
|
|
510
595
|
options?: SlatePollingOptions;
|
|
511
596
|
pollEvents?: SlateTriggerPollingHandler<ConfigType, AuthType, InputType>;
|
|
512
597
|
handleEvent: SlateTriggerMappingHandler<ConfigType, AuthType, InputType, OutputType>;
|
|
513
|
-
}): SlateActionBuilder<Type, ConfigType, AuthType, InputType, OutputType, Result>;
|
|
598
|
+
}): SlateActionBuilder<Type, ConfigType, AuthType, InputType, OutputType, Result, IsPublic>;
|
|
514
599
|
build(): Result;
|
|
515
600
|
}
|
|
516
601
|
|
|
602
|
+
interface SlateToolParameters<ConfigType extends {}, AuthType extends {}, InputType extends {}, OutputType extends {}> extends SlateActionParameters {
|
|
603
|
+
handleInvocation: SlateToolInvocationHandler<ConfigType, AuthType, InputType, OutputType>;
|
|
604
|
+
}
|
|
605
|
+
declare class SlateTool<ConfigType extends {}, AuthType extends {}, InputType extends {}, OutputType extends {}> extends SlateAction<'tool', ConfigType, AuthType, InputType, OutputType> {
|
|
606
|
+
#private;
|
|
607
|
+
protected constructor(spec: SlateSpecification<ConfigType, AuthType>, inputSchema: z.ZodType<InputType>, outputSchema: z.ZodType<OutputType>, params: SlateToolParameters<ConfigType, AuthType, InputType, OutputType>);
|
|
608
|
+
static create<ConfigType extends {}, AuthType extends {}>(spec: SlateSpecification<ConfigType, AuthType>, params: SlateActionParameters): SlateActionBuilder<"tool", ConfigType, AuthType, {}, {}, SlateTool<ConfigType, AuthType, any, any>, false>;
|
|
609
|
+
static fromCreateParameters<ConfigType extends {}, AuthType extends {}>(spec: SlateSpecification<ConfigType, AuthType>, params: {
|
|
610
|
+
type: string;
|
|
611
|
+
inputSchema: z.ZodType<any>;
|
|
612
|
+
outputSchema: z.ZodType<any>;
|
|
613
|
+
handleInvocation?: SlateToolInvocationHandler<ConfigType, AuthType, any, any>;
|
|
614
|
+
} & SlateActionParameters): SlateTool<ConfigType, AuthType, any, any>;
|
|
615
|
+
get handleInvocation(): SlateToolInvocationHandler<ConfigType, AuthType, InputType, OutputType>;
|
|
616
|
+
}
|
|
617
|
+
declare let tool: <ConfigType extends {}, AuthType extends {}>(spec: SlateSpecification<ConfigType, AuthType>, params: SlateActionParameters) => SlateActionBuilder<"tool", ConfigType, AuthType, {}, {}, SlateTool<ConfigType, AuthType, any, any>, false>;
|
|
618
|
+
|
|
619
|
+
interface SlatePublicToolParameters<InputType extends {}, OutputType extends {}> extends SlateActionParameters {
|
|
620
|
+
handleInvocation: SlatePublicToolInvocationHandler<InputType, OutputType>;
|
|
621
|
+
}
|
|
622
|
+
declare class SlatePublicTool {
|
|
623
|
+
private constructor();
|
|
624
|
+
static create<ConfigType extends {}, AuthType extends {}>(spec: SlateSpecification<ConfigType, AuthType>, params: SlateActionParameters): SlateActionBuilder<"tool", ConfigType, AuthType, {}, {}, SlateTool<ConfigType, AuthType, any, any>, true>;
|
|
625
|
+
}
|
|
626
|
+
declare let publicTool: <ConfigType extends {}, AuthType extends {}>(spec: SlateSpecification<ConfigType, AuthType>, params: SlateActionParameters) => SlateActionBuilder<"tool", ConfigType, AuthType, {}, {}, SlateTool<ConfigType, AuthType, any, any>, true>;
|
|
627
|
+
|
|
517
628
|
type SlateActionScopeValue = string;
|
|
518
629
|
type SlateActionScopeClauseInput = SlateActionScopeValue | readonly SlateActionScopeValue[] | SlateActionScopeClause;
|
|
519
630
|
type SlateActionScopesInput = SlateActionScopeClauseInput | SlateActionScopes;
|
|
@@ -523,17 +634,6 @@ declare let allOf: (...inputs: SlateActionScopesInput[]) => SlateActionScopes;
|
|
|
523
634
|
declare let mergeScopes: (...inputs: Array<SlateActionScopes | null | undefined | false>) => SlateActionScopes | undefined;
|
|
524
635
|
declare let validateScopes: (scopes: SlateActionScopes) => SlateActionScopes;
|
|
525
636
|
|
|
526
|
-
interface SlateToolParameters<ConfigType extends {}, AuthType extends {}, InputType extends {}, OutputType extends {}> extends SlateActionParameters {
|
|
527
|
-
handleInvocation: SlateToolInvocationHandler<ConfigType, AuthType, InputType, OutputType>;
|
|
528
|
-
}
|
|
529
|
-
declare class SlateTool<ConfigType extends {}, AuthType extends {}, InputType extends {}, OutputType extends {}> extends SlateAction<'tool', ConfigType, AuthType, InputType, OutputType> {
|
|
530
|
-
#private;
|
|
531
|
-
private constructor();
|
|
532
|
-
static create<ConfigType extends {}, AuthType extends {}>(spec: SlateSpecification<ConfigType, AuthType>, params: SlateActionParameters): SlateActionBuilder<"tool", ConfigType, AuthType, {}, {}, SlateTool<any, any, any, any>>;
|
|
533
|
-
get handleInvocation(): SlateToolInvocationHandler<ConfigType, AuthType, InputType, OutputType>;
|
|
534
|
-
}
|
|
535
|
-
declare let tool: <ConfigType extends {}, AuthType extends {}>(spec: SlateSpecification<ConfigType, AuthType>, params: SlateActionParameters) => SlateActionBuilder<"tool", ConfigType, AuthType, {}, {}, SlateTool<any, any, any, any>>;
|
|
536
|
-
|
|
537
637
|
declare let SlateDefaultPollingIntervalSeconds: number;
|
|
538
638
|
interface SlateTriggerParameters<ConfigType extends {}, AuthType extends {}, InputType extends {}, OutputType extends {
|
|
539
639
|
type: string;
|
|
@@ -543,6 +643,7 @@ interface SlateTriggerParameters<ConfigType extends {}, AuthType extends {}, Inp
|
|
|
543
643
|
polling?: SlatePollingOptions;
|
|
544
644
|
handleEvent: SlateTriggerMappingHandler<ConfigType, AuthType, InputType, OutputType>;
|
|
545
645
|
handleRequest?: SlateTriggerWebhookRequestHandler<ConfigType, AuthType, InputType>;
|
|
646
|
+
http?: SlateWebhookHttpOptions;
|
|
546
647
|
pollEvents?: SlateTriggerPollingHandler<ConfigType, AuthType, InputType>;
|
|
547
648
|
autoRegisterWebhook?: SlateTriggerWebhookAutoRegistrationHandler<ConfigType, AuthType>;
|
|
548
649
|
autoUnregisterWebhook?: SlateTriggerWebhookAutoUnregistrationHandler<ConfigType, AuthType>;
|
|
@@ -552,16 +653,119 @@ declare class SlateTrigger<ConfigType extends {}, AuthType extends {}, InputType
|
|
|
552
653
|
}> extends SlateAction<'trigger', ConfigType, AuthType, InputType, OutputType> {
|
|
553
654
|
#private;
|
|
554
655
|
private constructor();
|
|
555
|
-
static create<ConfigType extends {}, AuthType extends {}>(spec: SlateSpecification<ConfigType, AuthType>, params: SlateActionParameters): SlateActionBuilder<"trigger", ConfigType, AuthType, {}, {}, SlateTrigger<
|
|
656
|
+
static create<ConfigType extends {}, AuthType extends {}>(spec: SlateSpecification<ConfigType, AuthType>, params: SlateActionParameters): SlateActionBuilder<"trigger", ConfigType, AuthType, {}, {}, SlateTrigger<ConfigType, AuthType, any, any>, false>;
|
|
556
657
|
get polling(): SlatePollingOptions;
|
|
557
658
|
get source(): "polling" | "webhook";
|
|
558
659
|
get handleEvent(): SlateTriggerMappingHandler<ConfigType, AuthType, InputType, OutputType>;
|
|
559
660
|
get handleRequest(): SlateTriggerWebhookRequestHandler<ConfigType, AuthType, InputType> | undefined;
|
|
661
|
+
get http(): SlateWebhookHttpOptions | undefined;
|
|
560
662
|
get pollEvents(): SlateTriggerPollingHandler<ConfigType, AuthType, InputType> | undefined;
|
|
561
663
|
get autoRegisterWebhook(): SlateTriggerWebhookAutoRegistrationHandler<ConfigType, AuthType> | undefined;
|
|
562
664
|
get autoUnregisterWebhook(): SlateTriggerWebhookAutoUnregistrationHandler<ConfigType, AuthType> | undefined;
|
|
563
665
|
}
|
|
564
|
-
declare let trigger: <ConfigType extends {}, AuthType extends {}>(spec: SlateSpecification<ConfigType, AuthType>, params: SlateActionParameters) => SlateActionBuilder<"trigger", ConfigType, AuthType, {}, {}, SlateTrigger<
|
|
666
|
+
declare let trigger: <ConfigType extends {}, AuthType extends {}>(spec: SlateSpecification<ConfigType, AuthType>, params: SlateActionParameters) => SlateActionBuilder<"trigger", ConfigType, AuthType, {}, {}, SlateTrigger<ConfigType, AuthType, any, any>, false>;
|
|
667
|
+
|
|
668
|
+
interface SlateAdapterCapability {
|
|
669
|
+
id: string;
|
|
670
|
+
value: any;
|
|
671
|
+
}
|
|
672
|
+
interface SlateAdapterSpecParameters {
|
|
673
|
+
id: string;
|
|
674
|
+
name: string;
|
|
675
|
+
capabilities?: SlateAdapterCapability[];
|
|
676
|
+
}
|
|
677
|
+
declare class SlateAdapterSpec {
|
|
678
|
+
private readonly _params;
|
|
679
|
+
private constructor();
|
|
680
|
+
static create(params: SlateAdapterSpecParameters): SlateAdapterSpec;
|
|
681
|
+
get id(): string;
|
|
682
|
+
get name(): string;
|
|
683
|
+
get capabilities(): SlateAdapterCapability[];
|
|
684
|
+
get parameters(): {
|
|
685
|
+
id: string;
|
|
686
|
+
name: string;
|
|
687
|
+
capabilities: SlateAdapterCapability[];
|
|
688
|
+
};
|
|
689
|
+
tool<ConfigType extends {}, AuthType extends {}>(spec: SlateSpecification<ConfigType, AuthType>, params: SlateActionParameters): SlateActionBuilder<"tool", ConfigType, AuthType, {}, {}, SlateTool<ConfigType, AuthType, any, any>, false>;
|
|
690
|
+
publicTool<ConfigType extends {}, AuthType extends {}>(spec: SlateSpecification<ConfigType, AuthType>, params: SlateActionParameters): SlateActionBuilder<"tool", ConfigType, AuthType, {}, {}, SlateTool<ConfigType, AuthType, any, any>, true>;
|
|
691
|
+
trigger<ConfigType extends {}, AuthType extends {}>(spec: SlateSpecification<ConfigType, AuthType>, params: SlateActionParameters): SlateActionBuilder<"trigger", ConfigType, AuthType, {}, {}, SlateTrigger<ConfigType, AuthType, any, any>, false>;
|
|
692
|
+
register<ConfigType extends {}, AuthType extends {}>(params: {
|
|
693
|
+
tools: SlateTool<ConfigType, AuthType, any, any>[];
|
|
694
|
+
triggers: SlateTrigger<ConfigType, AuthType, any, any>[];
|
|
695
|
+
}): SlateAdapter<ConfigType, AuthType>;
|
|
696
|
+
private linkAction;
|
|
697
|
+
}
|
|
698
|
+
declare let adapterSpec: (params: SlateAdapterSpecParameters) => SlateAdapterSpec;
|
|
699
|
+
|
|
700
|
+
declare class SlateAdapter<ConfigType extends {}, AuthType extends {}> {
|
|
701
|
+
private readonly _spec;
|
|
702
|
+
private readonly _tools;
|
|
703
|
+
private readonly _triggers;
|
|
704
|
+
constructor(_spec: SlateAdapterSpec, _tools: SlateTool<ConfigType, AuthType, any, any>[], _triggers: SlateTrigger<ConfigType, AuthType, any, any>[]);
|
|
705
|
+
get spec(): SlateAdapterSpec;
|
|
706
|
+
get id(): string;
|
|
707
|
+
get name(): string;
|
|
708
|
+
get capabilities(): SlateAdapterCapability[];
|
|
709
|
+
get tools(): SlateTool<ConfigType, AuthType, any, any>[];
|
|
710
|
+
get triggers(): SlateTrigger<ConfigType, AuthType, any, any>[];
|
|
711
|
+
get actions(): (SlateTrigger<ConfigType, AuthType, any, any> | SlateTool<ConfigType, AuthType, any, any>)[];
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
type ApiErrorStatus = number | string;
|
|
715
|
+
type ApiServiceError = ServiceError<ErrorRecord<any, any>>;
|
|
716
|
+
type ApiErrorResponse = {
|
|
717
|
+
status?: ApiErrorStatus;
|
|
718
|
+
statusText?: string;
|
|
719
|
+
data?: unknown;
|
|
720
|
+
};
|
|
721
|
+
type ApiErrorDetailOptions = {
|
|
722
|
+
detailKeys?: readonly string[];
|
|
723
|
+
nestedKeys?: readonly string[];
|
|
724
|
+
includeNumbers?: boolean;
|
|
725
|
+
separator?: string;
|
|
726
|
+
fallbackMessage?: string;
|
|
727
|
+
};
|
|
728
|
+
type ApiErrorBuildHelpers = {
|
|
729
|
+
collectDetails: (value: unknown, details: string[], options?: ApiErrorDetailOptions) => void;
|
|
730
|
+
extractMessage: (error: unknown, options?: ApiErrorDetailOptions) => string;
|
|
731
|
+
getResponse: (error: unknown) => ApiErrorResponse | undefined;
|
|
732
|
+
getStatus: (error: unknown) => ApiErrorStatus | undefined;
|
|
733
|
+
isRecord: (value: unknown) => value is Record<string, unknown>;
|
|
734
|
+
statusLabelFor: (status?: ApiErrorStatus, statusText?: string) => string;
|
|
735
|
+
};
|
|
736
|
+
type BuildApiServiceErrorOptions = ApiErrorDetailOptions & {
|
|
737
|
+
providerLabel: string;
|
|
738
|
+
reason: string;
|
|
739
|
+
operation?: string;
|
|
740
|
+
extractMessage?: (error: unknown, helpers: ApiErrorBuildHelpers) => string | undefined;
|
|
741
|
+
extractResponse?: (error: unknown, helpers: ApiErrorBuildHelpers) => ApiErrorResponse | undefined;
|
|
742
|
+
extractStatus?: (error: unknown, response: ApiErrorResponse | undefined, helpers: ApiErrorBuildHelpers) => ApiErrorStatus | undefined;
|
|
743
|
+
extractUpstreamCode?: (error: unknown, response: ApiErrorResponse | undefined, helpers: ApiErrorBuildHelpers) => string | undefined;
|
|
744
|
+
formatMessage?: (parts: {
|
|
745
|
+
providerLabel: string;
|
|
746
|
+
operation: string;
|
|
747
|
+
statusLabel: string;
|
|
748
|
+
message: string;
|
|
749
|
+
response?: ApiErrorResponse;
|
|
750
|
+
status?: ApiErrorStatus;
|
|
751
|
+
}) => string;
|
|
752
|
+
parent?: unknown;
|
|
753
|
+
};
|
|
754
|
+
declare let isApiErrorRecord: (value: unknown) => value is Record<string, unknown>;
|
|
755
|
+
declare let collectApiErrorDetails: (value: unknown, details: string[], options?: ApiErrorDetailOptions) => void;
|
|
756
|
+
declare let getApiErrorResponse: (error: unknown) => ApiErrorResponse | undefined;
|
|
757
|
+
declare let getApiErrorStatus: (error: unknown) => ApiErrorStatus | undefined;
|
|
758
|
+
declare let statusLabelForApiError: (status?: ApiErrorStatus, statusText?: string) => string;
|
|
759
|
+
declare let extractApiErrorMessage: (error: unknown, options?: ApiErrorDetailOptions & {
|
|
760
|
+
response?: ApiErrorResponse;
|
|
761
|
+
}) => string;
|
|
762
|
+
declare let createApiServiceError: (message: string, options?: {
|
|
763
|
+
reason?: string;
|
|
764
|
+
upstreamStatus?: ApiErrorStatus;
|
|
765
|
+
upstreamCode?: string;
|
|
766
|
+
parent?: unknown;
|
|
767
|
+
}) => ServiceError<ErrorRecord<"bad_request", 400>>;
|
|
768
|
+
declare let buildApiServiceError: (error: unknown, options: BuildApiServiceErrorOptions) => ServiceError<ErrorRecord<"bad_request", 400>>;
|
|
565
769
|
|
|
566
770
|
declare class SlateError extends Error {
|
|
567
771
|
cause?: unknown;
|
|
@@ -648,20 +852,77 @@ declare let mapServiceErrorToSlateErrorInput: (error: ServiceError<ErrorRecord<a
|
|
|
648
852
|
interface SlateAxiosDefaults extends CreateAxiosDefaults {
|
|
649
853
|
errorMapping?: SlateAxiosErrorOptions;
|
|
650
854
|
}
|
|
855
|
+
type SlateAxiosErrorAdapter = (error: unknown, operation: string) => unknown;
|
|
856
|
+
interface SlateAuthenticatedAxiosDefaults extends SlateAxiosDefaults {
|
|
857
|
+
authHeader?: {
|
|
858
|
+
name?: string;
|
|
859
|
+
value: string;
|
|
860
|
+
};
|
|
861
|
+
contentType?: string | false;
|
|
862
|
+
errorAdapter?: (error: unknown) => unknown;
|
|
863
|
+
}
|
|
651
864
|
declare let createAxios: (config?: SlateAxiosDefaults) => AxiosInstance;
|
|
865
|
+
declare let createAuthenticatedAxios: (config: SlateAuthenticatedAxiosDefaults) => AxiosInstance;
|
|
866
|
+
declare let requestAxios: <T = unknown>(operation: string, request: () => Promise<AxiosResponse<T>>, errorAdapter: SlateAxiosErrorAdapter) => Promise<AxiosResponse<T, any, {}>>;
|
|
867
|
+
declare let requestAxiosData: <T = unknown>(operation: string, request: () => Promise<AxiosResponse<T>>, errorAdapter: SlateAxiosErrorAdapter) => Promise<T>;
|
|
652
868
|
declare let axios: AxiosInstance;
|
|
653
869
|
|
|
870
|
+
interface CreateHmacSignatureOptions {
|
|
871
|
+
secret: string | Uint8Array;
|
|
872
|
+
payload: string | Uint8Array;
|
|
873
|
+
algorithm?: string;
|
|
874
|
+
digest: 'hex' | 'base64';
|
|
875
|
+
prefix?: string;
|
|
876
|
+
}
|
|
877
|
+
interface VerifyHmacSignatureOptions extends CreateHmacSignatureOptions {
|
|
878
|
+
signature: string;
|
|
879
|
+
}
|
|
880
|
+
declare let createHmacSignature: ({ secret, payload, algorithm, digest, prefix }: CreateHmacSignatureOptions) => string;
|
|
881
|
+
declare let verifyHmacSignature: (options: VerifyHmacSignatureOptions) => boolean;
|
|
882
|
+
|
|
883
|
+
declare let getResponseHeaderValue: (headers: unknown, name: string) => string | undefined;
|
|
884
|
+
declare let getBase64ByteLength: (contentBase64: string) => number;
|
|
885
|
+
|
|
886
|
+
declare let pickDefined: <T extends object>(value: T) => Partial<T> & Record<string, unknown>;
|
|
887
|
+
declare let setIfDefined: (target: Record<string, unknown>, key: string, value: unknown) => Record<string, unknown>;
|
|
888
|
+
|
|
654
889
|
declare class Slate<ConfigType extends {}, AuthType extends {}> {
|
|
655
890
|
private readonly _spec;
|
|
656
891
|
private readonly _actions;
|
|
892
|
+
private readonly _adapters;
|
|
657
893
|
private constructor();
|
|
658
894
|
static create<ConfigType extends {}, AuthType extends {}>(params: {
|
|
659
895
|
spec: SlateSpecification<ConfigType, AuthType>;
|
|
660
896
|
triggers: SlateTrigger<ConfigType, AuthType, any, any>[];
|
|
661
897
|
tools: SlateTool<ConfigType, AuthType, any, any>[];
|
|
898
|
+
adapters?: SlateAdapter<ConfigType, AuthType>[];
|
|
662
899
|
}): Slate<ConfigType, AuthType>;
|
|
663
900
|
get spec(): SlateSpecification<ConfigType, AuthType>;
|
|
664
901
|
get actions(): (SlateTrigger<ConfigType, AuthType, any, any> | SlateTool<ConfigType, AuthType, any, any>)[];
|
|
902
|
+
get adapters(): SlateAdapter<ConfigType, AuthType>[];
|
|
665
903
|
}
|
|
666
904
|
|
|
667
|
-
|
|
905
|
+
declare const graphWebhookHttp: {
|
|
906
|
+
methods: "POST"[];
|
|
907
|
+
sync: {
|
|
908
|
+
mode: "match";
|
|
909
|
+
match: {
|
|
910
|
+
hasQueryParam: string;
|
|
911
|
+
}[];
|
|
912
|
+
};
|
|
913
|
+
};
|
|
914
|
+
declare let getGraphWebhookValidationResponse: (request: Request) => SlateWebhookHttpResponseInit | null;
|
|
915
|
+
|
|
916
|
+
declare const metaWebhookHttp: {
|
|
917
|
+
methods: ("GET" | "POST")[];
|
|
918
|
+
sync: {
|
|
919
|
+
mode: "match";
|
|
920
|
+
match: {
|
|
921
|
+
method: string;
|
|
922
|
+
hasQueryParam: string;
|
|
923
|
+
}[];
|
|
924
|
+
};
|
|
925
|
+
};
|
|
926
|
+
declare let getMetaWebhookVerificationResponse: (request: Request, expectedVerifyToken: string | undefined) => SlateWebhookHttpResponseInit | null;
|
|
927
|
+
|
|
928
|
+
export { type ApiErrorBuildHelpers, type ApiErrorDetailOptions, type ApiErrorResponse, type ApiErrorStatus, type ApiServiceError, type BuildApiServiceErrorOptions, type CreateHmacSignatureOptions, type NormalizeOAuthTokenResponseOptions, type OAuthExpiresAtOptions, type OAuthRefreshTokenFallbackMode, type OAuthTokenResponse, Slate, SlateAction, SlateActionBuilder, type SlateActionCreateParameters, type SlateActionDocsReference, type SlateActionParameters, type SlateActionParametersAny, type SlateActionParametersTool, type SlateActionParametersTrigger, type SlateActionScopeClause, type SlateActionScopeClauseInput, type SlateActionScopeValue, type SlateActionScopes, type SlateActionScopesInput, type SlateActionType, SlateAdapter, type SlateAdapterCapability, SlateAdapterSpec, type SlateAdapterSpecParameters, type SlateAttachment, type SlateAttachmentInlineContent, type SlateAttachmentUrlContent, SlateAuth, type SlateAuthDocsReference, type SlateAuthType, type SlateAuthWithCustomData, type SlateAuthWithNone, type SlateAuthWithOauth, type SlateAuthWithServiceAccount, type SlateAuthWithToken, type SlateAuthenticatedAxiosDefaults, type SlateAxiosDefaults, type SlateAxiosErrorAdapter, type SlateAxiosErrorOptions, SlateConfig, type SlateConfigDocsReference, SlateContext, SlateDeclarationError, SlateDefaultPollingIntervalSeconds, type SlateDocsReference, SlateError, type SlateErrorInput, type SlateErrorIssue, type SlateErrorKind, type SlateErrorProviderInfo, type SlateErrorResponse, type SlateErrorUpstreamInfo, type SlateLogEntry, type SlateLogFields, type SlateLogListener, type SlateLogMessageInput, type SlateLogType, SlateLogger, type SlatePollingOptions, type SlateProviderDocsReference, SlatePublicContext, SlatePublicTool, type SlatePublicToolInvocationHandler, type SlatePublicToolParameters, type SlateServiceErrorData, SlateSpecification, type SlateSpecificationCreateParameters, type SlateSpecificationParameters, SlateTool, type SlateToolInvocationHandler, type SlateToolParameters, SlateTrigger, type SlateTriggerMappingHandler, type SlateTriggerParameters, type SlateTriggerPollingHandler, type SlateTriggerWebhookAutoRegistrationHandler, type SlateTriggerWebhookAutoUnregistrationHandler, type SlateTriggerWebhookRequestHandler, type SlateTypedDocsReference, type SlateWebhookHttpMethod, type SlateWebhookHttpOptions, type SlateWebhookHttpResponseInit, type SlateWebhookRequestMatcher, type VerifyHmacSignatureOptions, adapterSpec, allOf, anyOf, auth, axios, buildApiServiceError, collectApiErrorDetails, config, createApiServiceError, createAuthenticatedAxios, createAxios, createBase64Attachment, createHmacSignature, createSlateError, createTextAttachment, createUrlAttachment, extractApiErrorMessage, getApiErrorResponse, getApiErrorStatus, getBase64ByteLength, getCurrentContext, getGraphWebhookValidationResponse, getMetaWebhookVerificationResponse, getOAuthExpiresAtFromExpiresIn, getResponseHeaderValue, getServiceErrorData, graphWebhookHttp, inferSlateErrorFromAxios, isApiErrorRecord, isAxiosErrorLike, isServiceErrorData, mapServiceErrorCode, mapServiceErrorToSlateErrorInput, mergeScopes, metaWebhookHttp, normalizeOAuthTokenResponse, pickDefined, publicTool, requestAxios, requestAxiosData, runWithContext, scopeClause, setIfDefined, spec, statusLabelForApiError, tool, trigger, validateScopes, verifyHmacSignature };
|