@slates/provider 1.0.0-rc.17 → 1.0.0-rc.19
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 +569 -55
- package/dist/index.d.cts +218 -48
- package/dist/index.d.ts +218 -48
- package/dist/index.module.js +554 -55
- package/package.json +3 -2
- package/src/action/action.ts +19 -1
- package/src/action/attachment.ts +55 -9
- package/src/action/builder.test.ts +136 -0
- package/src/action/builder.ts +68 -11
- package/src/action/directUpload.ts +59 -0
- package/src/action/getFileUrlTool.ts +41 -0
- package/src/action/index.ts +3 -1
- package/src/action/publicTool.ts +36 -0
- package/src/action/tool.ts +15 -3
- 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/redact.test.ts +103 -0
- package/src/auth/redact.ts +111 -0
- package/src/auth/types.ts +0 -1
- package/src/axios/trace.ts +72 -38
- package/src/context/context.ts +222 -17
- package/src/context/hook.ts +5 -10
- package/src/index.ts +2 -0
- package/src/specification/slate.ts +38 -2
package/dist/index.d.cts
CHANGED
|
@@ -2,6 +2,66 @@ import z, { z as z$1 } from 'zod';
|
|
|
2
2
|
import { AxiosResponse, AxiosError, CreateAxiosDefaults, AxiosInstance } from 'axios';
|
|
3
3
|
import { ServiceError, ErrorRecord, ErrorData } from '@lowerdeck/error';
|
|
4
4
|
|
|
5
|
+
interface SlateAttachmentUrlContent {
|
|
6
|
+
type: 'url';
|
|
7
|
+
url: string;
|
|
8
|
+
headers?: Record<string, string>;
|
|
9
|
+
query?: Record<string, string>;
|
|
10
|
+
refreshReference?: unknown;
|
|
11
|
+
refreshAt?: string;
|
|
12
|
+
}
|
|
13
|
+
interface SlateAttachmentInlineContent {
|
|
14
|
+
type: 'content';
|
|
15
|
+
encoding: 'base64' | 'utf-8';
|
|
16
|
+
content: string;
|
|
17
|
+
}
|
|
18
|
+
interface SlateAttachmentUploadReferenceContent {
|
|
19
|
+
type: 'upload_reference';
|
|
20
|
+
referenceId: string;
|
|
21
|
+
}
|
|
22
|
+
interface SlateAttachment {
|
|
23
|
+
mimeType?: string;
|
|
24
|
+
attachmentHash?: string;
|
|
25
|
+
content: SlateAttachmentUrlContent | SlateAttachmentInlineContent | SlateAttachmentUploadReferenceContent;
|
|
26
|
+
}
|
|
27
|
+
declare let createUrlAttachment: (url: string, opts?: {
|
|
28
|
+
mimeType?: string;
|
|
29
|
+
attachmentHash?: string;
|
|
30
|
+
headers?: Record<string, string>;
|
|
31
|
+
query?: Record<string, string>;
|
|
32
|
+
refreshReference?: unknown;
|
|
33
|
+
refreshAt?: string;
|
|
34
|
+
}) => SlateAttachment;
|
|
35
|
+
declare let createBase64Attachment: (content: string, mimeType?: string, attachmentHash?: string) => SlateAttachment;
|
|
36
|
+
declare let createTextAttachment: (content: string, mimeType?: string, attachmentHash?: string) => SlateAttachment;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Placeholder prefix used to mark a redacted auth-config secret. Must match the hub's
|
|
40
|
+
* AuthConfigSecretSerializer (oss/src/slates/apps/hub/src/lib/secretSerializer.ts) exactly --
|
|
41
|
+
* the hub resolves these placeholders back to live secret values when it proxies an attachment.
|
|
42
|
+
*/
|
|
43
|
+
declare let AUTH_CONFIG_SECRET_PLACEHOLDER_PREFIX: string;
|
|
44
|
+
/**
|
|
45
|
+
* Walks an auth config object and replaces any string value that exactly matches one of its
|
|
46
|
+
* leaf values with a `$$MT$secret$authConfig$<path>` placeholder. Literal, whole-value
|
|
47
|
+
* substitution only -- not a substring scan, and not a heuristic key-name/value-shape guess
|
|
48
|
+
* like the http trace redactor in '../axios/trace'.
|
|
49
|
+
*/
|
|
50
|
+
declare class AuthConfigSecretRedactor {
|
|
51
|
+
private readonly secretToPlaceholder;
|
|
52
|
+
constructor(authConfig: Record<string, unknown> | undefined);
|
|
53
|
+
redact<T>(value: T): T;
|
|
54
|
+
private buildSecretMap;
|
|
55
|
+
private transform;
|
|
56
|
+
private isPlainObject;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Applied to every finalized attachment list right before it's sent over
|
|
60
|
+
* `slates/action.tool.invoke` (see @slates/provider-handler). Only `type: 'url'` attachments
|
|
61
|
+
* carry headers/query -- content/upload_reference attachments pass through untouched.
|
|
62
|
+
*/
|
|
63
|
+
declare let redactUrlAttachmentSecrets: (attachments: SlateAttachment[] | undefined, authConfig: Record<string, unknown> | undefined) => SlateAttachment[] | undefined;
|
|
64
|
+
|
|
5
65
|
interface SlateHttpTraceTextBody {
|
|
6
66
|
contentType?: string;
|
|
7
67
|
text: string;
|
|
@@ -28,6 +88,19 @@ interface SlateHttpTrace {
|
|
|
28
88
|
};
|
|
29
89
|
}
|
|
30
90
|
|
|
91
|
+
interface SlateLiveInvocationInfo {
|
|
92
|
+
token: string;
|
|
93
|
+
baseUrl: string;
|
|
94
|
+
maxAttachmentSizeBytes: number;
|
|
95
|
+
}
|
|
96
|
+
interface SlateDirectUploadInput {
|
|
97
|
+
live: SlateLiveInvocationInfo;
|
|
98
|
+
mimeType?: string;
|
|
99
|
+
filename?: string;
|
|
100
|
+
body: ReadableStream<Uint8Array> | Uint8Array;
|
|
101
|
+
}
|
|
102
|
+
declare let uploadAttachmentDirect: (d: SlateDirectUploadInput) => Promise<SlateAttachment>;
|
|
103
|
+
|
|
31
104
|
type SlateLogType = 'info' | 'warn' | 'error' | 'progress';
|
|
32
105
|
type SlateLogFields = Record<string, unknown>;
|
|
33
106
|
type SlateLogMessageInput = string | Error | boolean | number | null | undefined | object | SlateLogMessageInput[];
|
|
@@ -74,7 +147,6 @@ type SlateAuthWithOauth<InputType extends {}, OutputType extends {
|
|
|
74
147
|
scopes: {
|
|
75
148
|
title: string;
|
|
76
149
|
description?: string;
|
|
77
|
-
defaultChecked?: boolean;
|
|
78
150
|
scope: string;
|
|
79
151
|
}[];
|
|
80
152
|
docs?: SlateAuthDocsReference[];
|
|
@@ -358,19 +430,33 @@ declare class SlateSpecification<ConfigType extends {}, AuthType extends {}> {
|
|
|
358
430
|
}
|
|
359
431
|
declare let spec: <ConfigType extends {}, AuthType extends {}>(params: SlateSpecificationCreateParameters<ConfigType, AuthType>) => SlateSpecification<ConfigType, AuthType>;
|
|
360
432
|
|
|
361
|
-
|
|
433
|
+
type SlateAddAttachmentContent = Buffer | Uint8Array | ArrayBuffer | ReadableStream<Uint8Array> | NodeJS.ReadableStream | Response;
|
|
434
|
+
type SlateAddAttachmentInput = {
|
|
435
|
+
type: 'url';
|
|
436
|
+
url: string | URL;
|
|
437
|
+
mimeType?: string;
|
|
438
|
+
filename?: string;
|
|
439
|
+
headers?: Record<string, string>;
|
|
440
|
+
query?: Record<string, string>;
|
|
441
|
+
refreshReference?: unknown;
|
|
442
|
+
refreshAt?: string;
|
|
443
|
+
} | {
|
|
444
|
+
type: 'content';
|
|
445
|
+
content: SlateAddAttachmentContent;
|
|
446
|
+
mimeType?: string;
|
|
447
|
+
filename?: string;
|
|
448
|
+
};
|
|
449
|
+
declare class SlatePublicContext<InputType extends {}> {
|
|
362
450
|
#private;
|
|
363
451
|
private readonly spec;
|
|
364
452
|
private readonly logger;
|
|
365
|
-
constructor(
|
|
366
|
-
get specification(): SlateSpecification<
|
|
367
|
-
get config(): Readonly<ConfigType>;
|
|
453
|
+
constructor(input: InputType, spec: SlateSpecification<any, any>, logger: SlateLogger, liveInvocation?: SlateLiveInvocationInfo | null);
|
|
454
|
+
get specification(): SlateSpecification<any, any>;
|
|
368
455
|
get input(): Readonly<InputType>;
|
|
369
456
|
get event(): Readonly<InputType>;
|
|
370
457
|
get state(): "state" extends keyof InputType ? InputType["state"] : never;
|
|
371
458
|
get request(): "request" extends keyof InputType ? InputType["request"] : never;
|
|
372
459
|
get registrationDetails(): "registrationDetails" extends keyof InputType ? InputType["registrationDetails"] : never;
|
|
373
|
-
get auth(): Readonly<AuthType>;
|
|
374
460
|
recordHttpTrace(trace: SlateHttpTrace): void;
|
|
375
461
|
getHttpTraces(): {
|
|
376
462
|
error?: {
|
|
@@ -396,28 +482,21 @@ declare class SlateContext<ConfigType extends {}, AuthType extends {}, InputType
|
|
|
396
482
|
warn(message: SlateLogMessageInput): void;
|
|
397
483
|
error(message: SlateLogMessageInput): void;
|
|
398
484
|
progress(message: SlateLogMessageInput): void;
|
|
485
|
+
addAttachment(input: SlateAddAttachmentInput): Promise<void>;
|
|
486
|
+
_finalizeAttachments(): Promise<SlateAttachment[]>;
|
|
487
|
+
_getAuthConfigForRedaction(): Record<string, unknown> | undefined;
|
|
488
|
+
}
|
|
489
|
+
declare class SlateContext<ConfigType extends {}, AuthType extends {}, InputType extends {}> extends SlatePublicContext<InputType> {
|
|
490
|
+
#private;
|
|
491
|
+
constructor(config: ConfigType, input: InputType, auth: AuthType, spec: SlateSpecification<ConfigType, AuthType>, logger: SlateLogger, liveInvocation?: SlateLiveInvocationInfo | null);
|
|
492
|
+
get config(): Readonly<ConfigType>;
|
|
493
|
+
get auth(): Readonly<AuthType>;
|
|
494
|
+
_getAuthConfigForRedaction(): Record<string, unknown> | undefined;
|
|
399
495
|
}
|
|
400
496
|
|
|
401
|
-
declare let runWithContext: <
|
|
497
|
+
declare let runWithContext: <InputType extends {}, RV>(context: SlatePublicContext<InputType>, fn: () => Promise<RV>) => Promise<RV>;
|
|
402
498
|
declare let getCurrentContext: <ConfigType extends {}, AuthType extends {}, InputType extends {}>() => SlateContext<ConfigType, AuthType, InputType>;
|
|
403
499
|
|
|
404
|
-
interface SlateAttachmentUrlContent {
|
|
405
|
-
type: 'url';
|
|
406
|
-
url: string;
|
|
407
|
-
}
|
|
408
|
-
interface SlateAttachmentInlineContent {
|
|
409
|
-
type: 'content';
|
|
410
|
-
encoding: 'base64' | 'utf-8';
|
|
411
|
-
content: string;
|
|
412
|
-
}
|
|
413
|
-
interface SlateAttachment {
|
|
414
|
-
mimeType?: string;
|
|
415
|
-
content: SlateAttachmentUrlContent | SlateAttachmentInlineContent;
|
|
416
|
-
}
|
|
417
|
-
declare let createUrlAttachment: (url: string, mimeType?: string) => SlateAttachment;
|
|
418
|
-
declare let createBase64Attachment: (content: string, mimeType?: string) => SlateAttachment;
|
|
419
|
-
declare let createTextAttachment: (content: string, mimeType?: string) => SlateAttachment;
|
|
420
|
-
|
|
421
500
|
type SlateActionType = 'tool' | 'trigger';
|
|
422
501
|
interface SlateActionScopeClause {
|
|
423
502
|
OR: string[];
|
|
@@ -440,12 +519,19 @@ interface SlateActionParameters {
|
|
|
440
519
|
scopes?: SlateActionScopes;
|
|
441
520
|
authMethods?: string[];
|
|
442
521
|
docs?: SlateActionDocsReference[];
|
|
522
|
+
adapter?: string | null;
|
|
523
|
+
isPublic?: boolean;
|
|
443
524
|
}
|
|
444
525
|
type SlateToolInvocationHandler<ConfigType extends {}, AuthType extends {}, InputType extends {}, OutputType extends {}> = (context: SlateContext<ConfigType, AuthType, InputType>) => Promise<{
|
|
445
526
|
output: OutputType;
|
|
446
527
|
message: string;
|
|
447
528
|
attachments?: SlateAttachment[];
|
|
448
529
|
}>;
|
|
530
|
+
type SlatePublicToolInvocationHandler<InputType extends {}, OutputType extends {}> = (context: SlatePublicContext<InputType>) => Promise<{
|
|
531
|
+
output: OutputType;
|
|
532
|
+
message: string;
|
|
533
|
+
attachments?: SlateAttachment[];
|
|
534
|
+
}>;
|
|
449
535
|
type SlateTriggerMappingHandler<ConfigType extends {}, AuthType extends {}, InputType extends {}, OutputType extends {}> = (context: SlateContext<ConfigType, AuthType, InputType>) => Promise<{
|
|
450
536
|
type: string;
|
|
451
537
|
id: string;
|
|
@@ -554,36 +640,82 @@ declare abstract class SlateAction<Type extends SlateActionType, ConfigType exte
|
|
|
554
640
|
get scopes(): SlateActionScopes | undefined;
|
|
555
641
|
get authMethods(): string[] | undefined;
|
|
556
642
|
get docs(): SlateActionDocsReference[] | undefined;
|
|
643
|
+
get adapter(): string | null;
|
|
644
|
+
get isPublic(): boolean;
|
|
557
645
|
}
|
|
558
646
|
|
|
559
|
-
declare class SlateActionBuilder<Type extends SlateActionType, ConfigType extends {}, AuthType extends {}, InputType extends {}, OutputType extends {}, Result extends SlateAction<Type, ConfigType, AuthType, any, any
|
|
647
|
+
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> {
|
|
560
648
|
#private;
|
|
561
649
|
private readonly type;
|
|
562
650
|
readonly spec: SlateSpecification<ConfigType, AuthType>;
|
|
563
651
|
private readonly params;
|
|
564
652
|
private readonly factory;
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
653
|
+
private readonly isPublicTool;
|
|
654
|
+
constructor(type: Type, spec: SlateSpecification<ConfigType, AuthType>, params: SlateActionParameters, factory: (params: SlateActionCreateParameters<any, any, any, any>) => Result, isPublicTool?: IsPublic);
|
|
655
|
+
input<NewInputType extends {}>(schema: z.ZodType<NewInputType>): SlateActionBuilder<Type, ConfigType, AuthType, NewInputType, OutputType, Result, IsPublic>;
|
|
656
|
+
output<NewOutputType extends {}>(schema: z.ZodType<NewOutputType>): SlateActionBuilder<Type, ConfigType, AuthType, InputType, NewOutputType, Result, IsPublic>;
|
|
657
|
+
lockInterface(): SlateActionBuilder<Type, ConfigType, AuthType, InputType, OutputType, Result, IsPublic>;
|
|
658
|
+
scopes(scopes: SlateActionScopes): SlateActionBuilder<Type, ConfigType, AuthType, InputType, OutputType, Result, IsPublic>;
|
|
659
|
+
authMethods(authMethods: string[]): SlateActionBuilder<Type, ConfigType, AuthType, InputType, OutputType, Result, IsPublic>;
|
|
570
660
|
private validateAuthMethods;
|
|
571
|
-
handleInvocation(handler: SlateToolInvocationHandler<ConfigType, AuthType, InputType, OutputType>): SlateActionBuilder<Type, ConfigType, AuthType, InputType, OutputType, Result>;
|
|
661
|
+
handleInvocation(handler: IsPublic extends true ? SlatePublicToolInvocationHandler<InputType, OutputType> : SlateToolInvocationHandler<ConfigType, AuthType, InputType, OutputType>): SlateActionBuilder<Type, ConfigType, AuthType, InputType, OutputType, Result, IsPublic>;
|
|
572
662
|
webhook(props: {
|
|
573
663
|
handleEvent: SlateTriggerMappingHandler<ConfigType, AuthType, InputType, OutputType>;
|
|
574
664
|
handleRequest: SlateTriggerWebhookRequestHandler<ConfigType, AuthType, InputType>;
|
|
575
665
|
autoRegisterWebhook?: SlateTriggerWebhookAutoRegistrationHandler<ConfigType, AuthType>;
|
|
576
666
|
autoUnregisterWebhook?: SlateTriggerWebhookAutoUnregistrationHandler<ConfigType, AuthType>;
|
|
577
667
|
http?: SlateWebhookHttpOptions;
|
|
578
|
-
}): SlateActionBuilder<Type, ConfigType, AuthType, InputType, OutputType, Result>;
|
|
668
|
+
}): SlateActionBuilder<Type, ConfigType, AuthType, InputType, OutputType, Result, IsPublic>;
|
|
579
669
|
polling(props: {
|
|
580
670
|
options?: SlatePollingOptions;
|
|
581
671
|
pollEvents?: SlateTriggerPollingHandler<ConfigType, AuthType, InputType>;
|
|
582
672
|
handleEvent: SlateTriggerMappingHandler<ConfigType, AuthType, InputType, OutputType>;
|
|
583
|
-
}): SlateActionBuilder<Type, ConfigType, AuthType, InputType, OutputType, Result>;
|
|
673
|
+
}): SlateActionBuilder<Type, ConfigType, AuthType, InputType, OutputType, Result, IsPublic>;
|
|
584
674
|
build(): Result;
|
|
585
675
|
}
|
|
586
676
|
|
|
677
|
+
interface SlateToolParameters<ConfigType extends {}, AuthType extends {}, InputType extends {}, OutputType extends {}> extends SlateActionParameters {
|
|
678
|
+
handleInvocation: SlateToolInvocationHandler<ConfigType, AuthType, InputType, OutputType>;
|
|
679
|
+
}
|
|
680
|
+
declare class SlateTool<ConfigType extends {}, AuthType extends {}, InputType extends {}, OutputType extends {}> extends SlateAction<'tool', ConfigType, AuthType, InputType, OutputType> {
|
|
681
|
+
#private;
|
|
682
|
+
protected constructor(spec: SlateSpecification<ConfigType, AuthType>, inputSchema: z.ZodType<InputType>, outputSchema: z.ZodType<OutputType>, params: SlateToolParameters<ConfigType, AuthType, InputType, OutputType>);
|
|
683
|
+
static create<ConfigType extends {}, AuthType extends {}>(spec: SlateSpecification<ConfigType, AuthType>, params: SlateActionParameters): SlateActionBuilder<"tool", ConfigType, AuthType, {}, {}, SlateTool<ConfigType, AuthType, any, any>, false>;
|
|
684
|
+
static fromCreateParameters<ConfigType extends {}, AuthType extends {}>(spec: SlateSpecification<ConfigType, AuthType>, params: {
|
|
685
|
+
type: string;
|
|
686
|
+
inputSchema: z.ZodType<any>;
|
|
687
|
+
outputSchema: z.ZodType<any>;
|
|
688
|
+
handleInvocation?: SlateToolInvocationHandler<ConfigType, AuthType, any, any>;
|
|
689
|
+
} & SlateActionParameters): SlateTool<ConfigType, AuthType, any, any>;
|
|
690
|
+
get handleInvocation(): SlateToolInvocationHandler<ConfigType, AuthType, InputType, OutputType>;
|
|
691
|
+
}
|
|
692
|
+
declare let tool: <ConfigType extends {}, AuthType extends {}>(spec: SlateSpecification<ConfigType, AuthType>, params: SlateActionParameters) => SlateActionBuilder<"tool", ConfigType, AuthType, {}, {}, SlateTool<ConfigType, AuthType, any, any>, false>;
|
|
693
|
+
|
|
694
|
+
declare let GET_FILE_URL_TOOL_ID: string;
|
|
695
|
+
declare let getFileUrlToolInputSchema: z$1.ZodObject<{
|
|
696
|
+
url: z$1.ZodString;
|
|
697
|
+
reference: z$1.ZodNullable<z$1.ZodAny>;
|
|
698
|
+
}, z$1.core.$strip>;
|
|
699
|
+
type GetFileUrlToolInput = z$1.infer<typeof getFileUrlToolInputSchema>;
|
|
700
|
+
declare let getFileUrlToolOutputSchema: z$1.ZodObject<{
|
|
701
|
+
url: z$1.ZodString;
|
|
702
|
+
expiresAt: z$1.ZodString;
|
|
703
|
+
headers: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodString>>;
|
|
704
|
+
query: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodString>>;
|
|
705
|
+
}, z$1.core.$strip>;
|
|
706
|
+
type GetFileUrlToolOutput = z$1.infer<typeof getFileUrlToolOutputSchema>;
|
|
707
|
+
type GetFileUrlHandler<ConfigType extends {}, AuthType extends {}> = (context: SlateContext<ConfigType, AuthType, GetFileUrlToolInput>) => Promise<GetFileUrlToolOutput>;
|
|
708
|
+
declare let getFileUrlTool: <ConfigType extends {}, AuthType extends {}>(spec: SlateSpecification<ConfigType, AuthType>, handleGetFileUrl: GetFileUrlHandler<ConfigType, AuthType>) => SlateTool<ConfigType, AuthType, any, any>;
|
|
709
|
+
|
|
710
|
+
interface SlatePublicToolParameters<InputType extends {}, OutputType extends {}> extends SlateActionParameters {
|
|
711
|
+
handleInvocation: SlatePublicToolInvocationHandler<InputType, OutputType>;
|
|
712
|
+
}
|
|
713
|
+
declare class SlatePublicTool {
|
|
714
|
+
private constructor();
|
|
715
|
+
static create<ConfigType extends {}, AuthType extends {}>(spec: SlateSpecification<ConfigType, AuthType>, params: SlateActionParameters): SlateActionBuilder<"tool", ConfigType, AuthType, {}, {}, SlateTool<ConfigType, AuthType, any, any>, true>;
|
|
716
|
+
}
|
|
717
|
+
declare let publicTool: <ConfigType extends {}, AuthType extends {}>(spec: SlateSpecification<ConfigType, AuthType>, params: SlateActionParameters) => SlateActionBuilder<"tool", ConfigType, AuthType, {}, {}, SlateTool<ConfigType, AuthType, any, any>, true>;
|
|
718
|
+
|
|
587
719
|
type SlateActionScopeValue = string;
|
|
588
720
|
type SlateActionScopeClauseInput = SlateActionScopeValue | readonly SlateActionScopeValue[] | SlateActionScopeClause;
|
|
589
721
|
type SlateActionScopesInput = SlateActionScopeClauseInput | SlateActionScopes;
|
|
@@ -593,17 +725,6 @@ declare let allOf: (...inputs: SlateActionScopesInput[]) => SlateActionScopes;
|
|
|
593
725
|
declare let mergeScopes: (...inputs: Array<SlateActionScopes | null | undefined | false>) => SlateActionScopes | undefined;
|
|
594
726
|
declare let validateScopes: (scopes: SlateActionScopes) => SlateActionScopes;
|
|
595
727
|
|
|
596
|
-
interface SlateToolParameters<ConfigType extends {}, AuthType extends {}, InputType extends {}, OutputType extends {}> extends SlateActionParameters {
|
|
597
|
-
handleInvocation: SlateToolInvocationHandler<ConfigType, AuthType, InputType, OutputType>;
|
|
598
|
-
}
|
|
599
|
-
declare class SlateTool<ConfigType extends {}, AuthType extends {}, InputType extends {}, OutputType extends {}> extends SlateAction<'tool', ConfigType, AuthType, InputType, OutputType> {
|
|
600
|
-
#private;
|
|
601
|
-
private constructor();
|
|
602
|
-
static create<ConfigType extends {}, AuthType extends {}>(spec: SlateSpecification<ConfigType, AuthType>, params: SlateActionParameters): SlateActionBuilder<"tool", ConfigType, AuthType, {}, {}, SlateTool<any, any, any, any>>;
|
|
603
|
-
get handleInvocation(): SlateToolInvocationHandler<ConfigType, AuthType, InputType, OutputType>;
|
|
604
|
-
}
|
|
605
|
-
declare let tool: <ConfigType extends {}, AuthType extends {}>(spec: SlateSpecification<ConfigType, AuthType>, params: SlateActionParameters) => SlateActionBuilder<"tool", ConfigType, AuthType, {}, {}, SlateTool<any, any, any, any>>;
|
|
606
|
-
|
|
607
728
|
declare let SlateDefaultPollingIntervalSeconds: number;
|
|
608
729
|
interface SlateTriggerParameters<ConfigType extends {}, AuthType extends {}, InputType extends {}, OutputType extends {
|
|
609
730
|
type: string;
|
|
@@ -623,7 +744,7 @@ declare class SlateTrigger<ConfigType extends {}, AuthType extends {}, InputType
|
|
|
623
744
|
}> extends SlateAction<'trigger', ConfigType, AuthType, InputType, OutputType> {
|
|
624
745
|
#private;
|
|
625
746
|
private constructor();
|
|
626
|
-
static create<ConfigType extends {}, AuthType extends {}>(spec: SlateSpecification<ConfigType, AuthType>, params: SlateActionParameters): SlateActionBuilder<"trigger", ConfigType, AuthType, {}, {}, SlateTrigger<
|
|
747
|
+
static create<ConfigType extends {}, AuthType extends {}>(spec: SlateSpecification<ConfigType, AuthType>, params: SlateActionParameters): SlateActionBuilder<"trigger", ConfigType, AuthType, {}, {}, SlateTrigger<ConfigType, AuthType, any, any>, false>;
|
|
627
748
|
get polling(): SlatePollingOptions;
|
|
628
749
|
get source(): "polling" | "webhook";
|
|
629
750
|
get handleEvent(): SlateTriggerMappingHandler<ConfigType, AuthType, InputType, OutputType>;
|
|
@@ -633,7 +754,53 @@ declare class SlateTrigger<ConfigType extends {}, AuthType extends {}, InputType
|
|
|
633
754
|
get autoRegisterWebhook(): SlateTriggerWebhookAutoRegistrationHandler<ConfigType, AuthType> | undefined;
|
|
634
755
|
get autoUnregisterWebhook(): SlateTriggerWebhookAutoUnregistrationHandler<ConfigType, AuthType> | undefined;
|
|
635
756
|
}
|
|
636
|
-
declare let trigger: <ConfigType extends {}, AuthType extends {}>(spec: SlateSpecification<ConfigType, AuthType>, params: SlateActionParameters) => SlateActionBuilder<"trigger", ConfigType, AuthType, {}, {}, SlateTrigger<
|
|
757
|
+
declare let trigger: <ConfigType extends {}, AuthType extends {}>(spec: SlateSpecification<ConfigType, AuthType>, params: SlateActionParameters) => SlateActionBuilder<"trigger", ConfigType, AuthType, {}, {}, SlateTrigger<ConfigType, AuthType, any, any>, false>;
|
|
758
|
+
|
|
759
|
+
interface SlateAdapterCapability {
|
|
760
|
+
id: string;
|
|
761
|
+
value: any;
|
|
762
|
+
}
|
|
763
|
+
interface SlateAdapterSpecParameters {
|
|
764
|
+
id: string;
|
|
765
|
+
name: string;
|
|
766
|
+
capabilities?: SlateAdapterCapability[];
|
|
767
|
+
}
|
|
768
|
+
declare class SlateAdapterSpec {
|
|
769
|
+
private readonly _params;
|
|
770
|
+
private constructor();
|
|
771
|
+
static create(params: SlateAdapterSpecParameters): SlateAdapterSpec;
|
|
772
|
+
get id(): string;
|
|
773
|
+
get name(): string;
|
|
774
|
+
get capabilities(): SlateAdapterCapability[];
|
|
775
|
+
get parameters(): {
|
|
776
|
+
id: string;
|
|
777
|
+
name: string;
|
|
778
|
+
capabilities: SlateAdapterCapability[];
|
|
779
|
+
};
|
|
780
|
+
tool<ConfigType extends {}, AuthType extends {}>(spec: SlateSpecification<ConfigType, AuthType>, params: SlateActionParameters): SlateActionBuilder<"tool", ConfigType, AuthType, {}, {}, SlateTool<ConfigType, AuthType, any, any>, false>;
|
|
781
|
+
publicTool<ConfigType extends {}, AuthType extends {}>(spec: SlateSpecification<ConfigType, AuthType>, params: SlateActionParameters): SlateActionBuilder<"tool", ConfigType, AuthType, {}, {}, SlateTool<ConfigType, AuthType, any, any>, true>;
|
|
782
|
+
trigger<ConfigType extends {}, AuthType extends {}>(spec: SlateSpecification<ConfigType, AuthType>, params: SlateActionParameters): SlateActionBuilder<"trigger", ConfigType, AuthType, {}, {}, SlateTrigger<ConfigType, AuthType, any, any>, false>;
|
|
783
|
+
register<ConfigType extends {}, AuthType extends {}>(params: {
|
|
784
|
+
tools: SlateTool<ConfigType, AuthType, any, any>[];
|
|
785
|
+
triggers: SlateTrigger<ConfigType, AuthType, any, any>[];
|
|
786
|
+
}): SlateAdapter<ConfigType, AuthType>;
|
|
787
|
+
private linkAction;
|
|
788
|
+
}
|
|
789
|
+
declare let adapterSpec: (params: SlateAdapterSpecParameters) => SlateAdapterSpec;
|
|
790
|
+
|
|
791
|
+
declare class SlateAdapter<ConfigType extends {}, AuthType extends {}> {
|
|
792
|
+
private readonly _spec;
|
|
793
|
+
private readonly _tools;
|
|
794
|
+
private readonly _triggers;
|
|
795
|
+
constructor(_spec: SlateAdapterSpec, _tools: SlateTool<ConfigType, AuthType, any, any>[], _triggers: SlateTrigger<ConfigType, AuthType, any, any>[]);
|
|
796
|
+
get spec(): SlateAdapterSpec;
|
|
797
|
+
get id(): string;
|
|
798
|
+
get name(): string;
|
|
799
|
+
get capabilities(): SlateAdapterCapability[];
|
|
800
|
+
get tools(): SlateTool<ConfigType, AuthType, any, any>[];
|
|
801
|
+
get triggers(): SlateTrigger<ConfigType, AuthType, any, any>[];
|
|
802
|
+
get actions(): (SlateTrigger<ConfigType, AuthType, any, any> | SlateTool<ConfigType, AuthType, any, any>)[];
|
|
803
|
+
}
|
|
637
804
|
|
|
638
805
|
type ApiErrorStatus = number | string;
|
|
639
806
|
type ApiServiceError = ServiceError<ErrorRecord<any, any>>;
|
|
@@ -813,14 +980,17 @@ declare let setIfDefined: (target: Record<string, unknown>, key: string, value:
|
|
|
813
980
|
declare class Slate<ConfigType extends {}, AuthType extends {}> {
|
|
814
981
|
private readonly _spec;
|
|
815
982
|
private readonly _actions;
|
|
983
|
+
private readonly _adapters;
|
|
816
984
|
private constructor();
|
|
817
985
|
static create<ConfigType extends {}, AuthType extends {}>(params: {
|
|
818
986
|
spec: SlateSpecification<ConfigType, AuthType>;
|
|
819
987
|
triggers: SlateTrigger<ConfigType, AuthType, any, any>[];
|
|
820
988
|
tools: SlateTool<ConfigType, AuthType, any, any>[];
|
|
989
|
+
adapters?: SlateAdapter<ConfigType, AuthType>[];
|
|
821
990
|
}): Slate<ConfigType, AuthType>;
|
|
822
991
|
get spec(): SlateSpecification<ConfigType, AuthType>;
|
|
823
992
|
get actions(): (SlateTrigger<ConfigType, AuthType, any, any> | SlateTool<ConfigType, AuthType, any, any>)[];
|
|
993
|
+
get adapters(): SlateAdapter<ConfigType, AuthType>[];
|
|
824
994
|
}
|
|
825
995
|
|
|
826
996
|
declare const graphWebhookHttp: {
|
|
@@ -835,7 +1005,7 @@ declare const graphWebhookHttp: {
|
|
|
835
1005
|
declare let getGraphWebhookValidationResponse: (request: Request) => SlateWebhookHttpResponseInit | null;
|
|
836
1006
|
|
|
837
1007
|
declare const metaWebhookHttp: {
|
|
838
|
-
methods: ("
|
|
1008
|
+
methods: ("POST" | "GET")[];
|
|
839
1009
|
sync: {
|
|
840
1010
|
mode: "match";
|
|
841
1011
|
match: {
|
|
@@ -846,4 +1016,4 @@ declare const metaWebhookHttp: {
|
|
|
846
1016
|
};
|
|
847
1017
|
declare let getMetaWebhookVerificationResponse: (request: Request, expectedVerifyToken: string | undefined) => SlateWebhookHttpResponseInit | null;
|
|
848
1018
|
|
|
849
|
-
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, 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, 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, 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, requestAxios, requestAxiosData, runWithContext, scopeClause, setIfDefined, spec, statusLabelForApiError, tool, trigger, validateScopes, verifyHmacSignature };
|
|
1019
|
+
export { AUTH_CONFIG_SECRET_PLACEHOLDER_PREFIX, type ApiErrorBuildHelpers, type ApiErrorDetailOptions, type ApiErrorResponse, type ApiErrorStatus, type ApiServiceError, AuthConfigSecretRedactor, type BuildApiServiceErrorOptions, type CreateHmacSignatureOptions, GET_FILE_URL_TOOL_ID, type GetFileUrlHandler, type GetFileUrlToolInput, type GetFileUrlToolOutput, 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 SlateAddAttachmentContent, type SlateAddAttachmentInput, type SlateAttachment, type SlateAttachmentInlineContent, type SlateAttachmentUploadReferenceContent, 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 SlateDirectUploadInput, type SlateDocsReference, SlateError, type SlateErrorInput, type SlateErrorIssue, type SlateErrorKind, type SlateErrorProviderInfo, type SlateErrorResponse, type SlateErrorUpstreamInfo, type SlateLiveInvocationInfo, 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, getFileUrlTool, getFileUrlToolInputSchema, getFileUrlToolOutputSchema, getGraphWebhookValidationResponse, getMetaWebhookVerificationResponse, getOAuthExpiresAtFromExpiresIn, getResponseHeaderValue, getServiceErrorData, graphWebhookHttp, inferSlateErrorFromAxios, isApiErrorRecord, isAxiosErrorLike, isServiceErrorData, mapServiceErrorCode, mapServiceErrorToSlateErrorInput, mergeScopes, metaWebhookHttp, normalizeOAuthTokenResponse, pickDefined, publicTool, redactUrlAttachmentSecrets, requestAxios, requestAxiosData, runWithContext, scopeClause, setIfDefined, spec, statusLabelForApiError, tool, trigger, uploadAttachmentDirect, validateScopes, verifyHmacSignature };
|