@slates/provider 1.0.0-rc.15 → 1.0.0-rc.16
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 +18 -0
- package/dist/index.d.cts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.module.js +18 -0
- package/package.json +2 -2
- package/src/action/action.ts +5 -0
- package/src/action/builder.ts +21 -0
- package/src/auth/types.ts +12 -3
package/dist/index.cjs
CHANGED
|
@@ -119,6 +119,9 @@ var SlateAction = class {
|
|
|
119
119
|
get scopes() {
|
|
120
120
|
return this._params.scopes;
|
|
121
121
|
}
|
|
122
|
+
get authMethods() {
|
|
123
|
+
return this._params.authMethods;
|
|
124
|
+
}
|
|
122
125
|
get docs() {
|
|
123
126
|
return this._params.docs;
|
|
124
127
|
}
|
|
@@ -765,6 +768,7 @@ var SlateActionBuilder = class {
|
|
|
765
768
|
#inputSchema = null;
|
|
766
769
|
#outputSchema = null;
|
|
767
770
|
#scopes;
|
|
771
|
+
#authMethods;
|
|
768
772
|
#toolParams = null;
|
|
769
773
|
#triggerParams = null;
|
|
770
774
|
input(schema) {
|
|
@@ -780,6 +784,18 @@ var SlateActionBuilder = class {
|
|
|
780
784
|
this.#scopes = scopes;
|
|
781
785
|
return this;
|
|
782
786
|
}
|
|
787
|
+
authMethods(authMethods) {
|
|
788
|
+
this.#authMethods = this.validateAuthMethods(authMethods);
|
|
789
|
+
return this;
|
|
790
|
+
}
|
|
791
|
+
validateAuthMethods(authMethods) {
|
|
792
|
+
if (!authMethods) return void 0;
|
|
793
|
+
let normalized = [...new Set(authMethods.map((authMethod) => authMethod.trim()))];
|
|
794
|
+
if (normalized.some((authMethod) => !authMethod)) {
|
|
795
|
+
throw new SlateDeclarationError("Auth method IDs must be non-empty strings");
|
|
796
|
+
}
|
|
797
|
+
return normalized;
|
|
798
|
+
}
|
|
783
799
|
handleInvocation(handler) {
|
|
784
800
|
if (this.type !== "tool") {
|
|
785
801
|
throw new SlateDeclarationError("handleInvocation can only be set for tool actions");
|
|
@@ -822,6 +838,7 @@ var SlateActionBuilder = class {
|
|
|
822
838
|
if (scopes) {
|
|
823
839
|
validateScopes(scopes);
|
|
824
840
|
}
|
|
841
|
+
let authMethods = this.validateAuthMethods(this.#authMethods ?? this.params.authMethods);
|
|
825
842
|
if (!this.#inputSchema) {
|
|
826
843
|
throw new SlateDeclarationError("Input schema is not defined");
|
|
827
844
|
}
|
|
@@ -837,6 +854,7 @@ var SlateActionBuilder = class {
|
|
|
837
854
|
return this.factory({
|
|
838
855
|
...this.params,
|
|
839
856
|
scopes,
|
|
857
|
+
authMethods,
|
|
840
858
|
configSchema: this.#configSchema,
|
|
841
859
|
authSchema: this.#authSchema,
|
|
842
860
|
inputSchema: this.#inputSchema,
|
package/dist/index.d.cts
CHANGED
|
@@ -147,6 +147,7 @@ type SlateAuthWithToken<InputType extends {}, OutputType extends {
|
|
|
147
147
|
input: InputType;
|
|
148
148
|
}) => Promise<{
|
|
149
149
|
output: OutputType;
|
|
150
|
+
scopes?: string[];
|
|
150
151
|
}>;
|
|
151
152
|
onInputChanged?: (params: {
|
|
152
153
|
previousInput: InputType;
|
|
@@ -172,6 +173,7 @@ type SlateAuthWithServiceAccount<InputType extends {}, OutputType extends {}> =
|
|
|
172
173
|
input: InputType;
|
|
173
174
|
}) => Promise<{
|
|
174
175
|
output: OutputType;
|
|
176
|
+
scopes?: string[];
|
|
175
177
|
}>;
|
|
176
178
|
onInputChanged?: (params: {
|
|
177
179
|
previousInput: InputType;
|
|
@@ -197,6 +199,7 @@ type SlateAuthWithCustomData<InputType extends {}, OutputType extends {}> = {
|
|
|
197
199
|
input: InputType;
|
|
198
200
|
}) => Promise<{
|
|
199
201
|
output: OutputType;
|
|
202
|
+
scopes?: string[];
|
|
200
203
|
}>;
|
|
201
204
|
handleTokenRefresh?: (ctx: {
|
|
202
205
|
output: OutputType;
|
|
@@ -396,6 +399,7 @@ interface SlateActionParameters {
|
|
|
396
399
|
};
|
|
397
400
|
metadata?: Record<string, any>;
|
|
398
401
|
scopes?: SlateActionScopes;
|
|
402
|
+
authMethods?: string[];
|
|
399
403
|
docs?: SlateActionDocsReference[];
|
|
400
404
|
}
|
|
401
405
|
type SlateToolInvocationHandler<ConfigType extends {}, AuthType extends {}, InputType extends {}, OutputType extends {}> = (context: SlateContext<ConfigType, AuthType, InputType>) => Promise<{
|
|
@@ -479,6 +483,7 @@ declare abstract class SlateAction<Type extends SlateActionType, ConfigType exte
|
|
|
479
483
|
get constraints(): string[] | undefined;
|
|
480
484
|
get metadata(): Record<string, any> | undefined;
|
|
481
485
|
get scopes(): SlateActionScopes | undefined;
|
|
486
|
+
get authMethods(): string[] | undefined;
|
|
482
487
|
get docs(): SlateActionDocsReference[] | undefined;
|
|
483
488
|
}
|
|
484
489
|
|
|
@@ -492,6 +497,8 @@ declare class SlateActionBuilder<Type extends SlateActionType, ConfigType extend
|
|
|
492
497
|
input<NewInputType extends {}>(schema: z.ZodType<NewInputType>): SlateActionBuilder<Type, ConfigType, AuthType, NewInputType, OutputType, Result>;
|
|
493
498
|
output<NewOutputType extends {}>(schema: z.ZodType<NewOutputType>): SlateActionBuilder<Type, ConfigType, AuthType, InputType, NewOutputType, Result>;
|
|
494
499
|
scopes(scopes: SlateActionScopes): SlateActionBuilder<Type, ConfigType, AuthType, InputType, OutputType, Result>;
|
|
500
|
+
authMethods(authMethods: string[]): SlateActionBuilder<Type, ConfigType, AuthType, InputType, OutputType, Result>;
|
|
501
|
+
private validateAuthMethods;
|
|
495
502
|
handleInvocation(handler: SlateToolInvocationHandler<ConfigType, AuthType, InputType, OutputType>): SlateActionBuilder<Type, ConfigType, AuthType, InputType, OutputType, Result>;
|
|
496
503
|
webhook(props: {
|
|
497
504
|
handleEvent: SlateTriggerMappingHandler<ConfigType, AuthType, InputType, OutputType>;
|
package/dist/index.d.ts
CHANGED
|
@@ -147,6 +147,7 @@ type SlateAuthWithToken<InputType extends {}, OutputType extends {
|
|
|
147
147
|
input: InputType;
|
|
148
148
|
}) => Promise<{
|
|
149
149
|
output: OutputType;
|
|
150
|
+
scopes?: string[];
|
|
150
151
|
}>;
|
|
151
152
|
onInputChanged?: (params: {
|
|
152
153
|
previousInput: InputType;
|
|
@@ -172,6 +173,7 @@ type SlateAuthWithServiceAccount<InputType extends {}, OutputType extends {}> =
|
|
|
172
173
|
input: InputType;
|
|
173
174
|
}) => Promise<{
|
|
174
175
|
output: OutputType;
|
|
176
|
+
scopes?: string[];
|
|
175
177
|
}>;
|
|
176
178
|
onInputChanged?: (params: {
|
|
177
179
|
previousInput: InputType;
|
|
@@ -197,6 +199,7 @@ type SlateAuthWithCustomData<InputType extends {}, OutputType extends {}> = {
|
|
|
197
199
|
input: InputType;
|
|
198
200
|
}) => Promise<{
|
|
199
201
|
output: OutputType;
|
|
202
|
+
scopes?: string[];
|
|
200
203
|
}>;
|
|
201
204
|
handleTokenRefresh?: (ctx: {
|
|
202
205
|
output: OutputType;
|
|
@@ -396,6 +399,7 @@ interface SlateActionParameters {
|
|
|
396
399
|
};
|
|
397
400
|
metadata?: Record<string, any>;
|
|
398
401
|
scopes?: SlateActionScopes;
|
|
402
|
+
authMethods?: string[];
|
|
399
403
|
docs?: SlateActionDocsReference[];
|
|
400
404
|
}
|
|
401
405
|
type SlateToolInvocationHandler<ConfigType extends {}, AuthType extends {}, InputType extends {}, OutputType extends {}> = (context: SlateContext<ConfigType, AuthType, InputType>) => Promise<{
|
|
@@ -479,6 +483,7 @@ declare abstract class SlateAction<Type extends SlateActionType, ConfigType exte
|
|
|
479
483
|
get constraints(): string[] | undefined;
|
|
480
484
|
get metadata(): Record<string, any> | undefined;
|
|
481
485
|
get scopes(): SlateActionScopes | undefined;
|
|
486
|
+
get authMethods(): string[] | undefined;
|
|
482
487
|
get docs(): SlateActionDocsReference[] | undefined;
|
|
483
488
|
}
|
|
484
489
|
|
|
@@ -492,6 +497,8 @@ declare class SlateActionBuilder<Type extends SlateActionType, ConfigType extend
|
|
|
492
497
|
input<NewInputType extends {}>(schema: z.ZodType<NewInputType>): SlateActionBuilder<Type, ConfigType, AuthType, NewInputType, OutputType, Result>;
|
|
493
498
|
output<NewOutputType extends {}>(schema: z.ZodType<NewOutputType>): SlateActionBuilder<Type, ConfigType, AuthType, InputType, NewOutputType, Result>;
|
|
494
499
|
scopes(scopes: SlateActionScopes): SlateActionBuilder<Type, ConfigType, AuthType, InputType, OutputType, Result>;
|
|
500
|
+
authMethods(authMethods: string[]): SlateActionBuilder<Type, ConfigType, AuthType, InputType, OutputType, Result>;
|
|
501
|
+
private validateAuthMethods;
|
|
495
502
|
handleInvocation(handler: SlateToolInvocationHandler<ConfigType, AuthType, InputType, OutputType>): SlateActionBuilder<Type, ConfigType, AuthType, InputType, OutputType, Result>;
|
|
496
503
|
webhook(props: {
|
|
497
504
|
handleEvent: SlateTriggerMappingHandler<ConfigType, AuthType, InputType, OutputType>;
|
package/dist/index.module.js
CHANGED
|
@@ -48,6 +48,9 @@ var SlateAction = class {
|
|
|
48
48
|
get scopes() {
|
|
49
49
|
return this._params.scopes;
|
|
50
50
|
}
|
|
51
|
+
get authMethods() {
|
|
52
|
+
return this._params.authMethods;
|
|
53
|
+
}
|
|
51
54
|
get docs() {
|
|
52
55
|
return this._params.docs;
|
|
53
56
|
}
|
|
@@ -694,6 +697,7 @@ var SlateActionBuilder = class {
|
|
|
694
697
|
#inputSchema = null;
|
|
695
698
|
#outputSchema = null;
|
|
696
699
|
#scopes;
|
|
700
|
+
#authMethods;
|
|
697
701
|
#toolParams = null;
|
|
698
702
|
#triggerParams = null;
|
|
699
703
|
input(schema) {
|
|
@@ -709,6 +713,18 @@ var SlateActionBuilder = class {
|
|
|
709
713
|
this.#scopes = scopes;
|
|
710
714
|
return this;
|
|
711
715
|
}
|
|
716
|
+
authMethods(authMethods) {
|
|
717
|
+
this.#authMethods = this.validateAuthMethods(authMethods);
|
|
718
|
+
return this;
|
|
719
|
+
}
|
|
720
|
+
validateAuthMethods(authMethods) {
|
|
721
|
+
if (!authMethods) return void 0;
|
|
722
|
+
let normalized = [...new Set(authMethods.map((authMethod) => authMethod.trim()))];
|
|
723
|
+
if (normalized.some((authMethod) => !authMethod)) {
|
|
724
|
+
throw new SlateDeclarationError("Auth method IDs must be non-empty strings");
|
|
725
|
+
}
|
|
726
|
+
return normalized;
|
|
727
|
+
}
|
|
712
728
|
handleInvocation(handler) {
|
|
713
729
|
if (this.type !== "tool") {
|
|
714
730
|
throw new SlateDeclarationError("handleInvocation can only be set for tool actions");
|
|
@@ -751,6 +767,7 @@ var SlateActionBuilder = class {
|
|
|
751
767
|
if (scopes) {
|
|
752
768
|
validateScopes(scopes);
|
|
753
769
|
}
|
|
770
|
+
let authMethods = this.validateAuthMethods(this.#authMethods ?? this.params.authMethods);
|
|
754
771
|
if (!this.#inputSchema) {
|
|
755
772
|
throw new SlateDeclarationError("Input schema is not defined");
|
|
756
773
|
}
|
|
@@ -766,6 +783,7 @@ var SlateActionBuilder = class {
|
|
|
766
783
|
return this.factory({
|
|
767
784
|
...this.params,
|
|
768
785
|
scopes,
|
|
786
|
+
authMethods,
|
|
769
787
|
configSchema: this.#configSchema,
|
|
770
788
|
authSchema: this.#authSchema,
|
|
771
789
|
inputSchema: this.#inputSchema,
|
package/package.json
CHANGED
package/src/action/action.ts
CHANGED
|
@@ -27,6 +27,7 @@ export interface SlateActionParameters {
|
|
|
27
27
|
};
|
|
28
28
|
metadata?: Record<string, any>;
|
|
29
29
|
scopes?: SlateActionScopes;
|
|
30
|
+
authMethods?: string[];
|
|
30
31
|
docs?: SlateActionDocsReference[];
|
|
31
32
|
}
|
|
32
33
|
|
|
@@ -206,6 +207,10 @@ export abstract class SlateAction<
|
|
|
206
207
|
return this._params.scopes;
|
|
207
208
|
}
|
|
208
209
|
|
|
210
|
+
get authMethods() {
|
|
211
|
+
return this._params.authMethods;
|
|
212
|
+
}
|
|
213
|
+
|
|
209
214
|
get docs() {
|
|
210
215
|
return this._params.docs;
|
|
211
216
|
}
|
package/src/action/builder.ts
CHANGED
|
@@ -32,6 +32,7 @@ export class SlateActionBuilder<
|
|
|
32
32
|
#inputSchema: z.ZodType<InputType> | null = null;
|
|
33
33
|
#outputSchema: z.ZodType<OutputType> | null = null;
|
|
34
34
|
#scopes: SlateActionScopes | undefined;
|
|
35
|
+
#authMethods: string[] | undefined;
|
|
35
36
|
|
|
36
37
|
#toolParams: SlateActionParametersTool<ConfigType, AuthType, InputType, OutputType> | null =
|
|
37
38
|
null;
|
|
@@ -76,6 +77,24 @@ export class SlateActionBuilder<
|
|
|
76
77
|
return this;
|
|
77
78
|
}
|
|
78
79
|
|
|
80
|
+
authMethods(
|
|
81
|
+
authMethods: string[]
|
|
82
|
+
): SlateActionBuilder<Type, ConfigType, AuthType, InputType, OutputType, Result> {
|
|
83
|
+
this.#authMethods = this.validateAuthMethods(authMethods);
|
|
84
|
+
return this;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
private validateAuthMethods(authMethods: string[] | undefined) {
|
|
88
|
+
if (!authMethods) return undefined;
|
|
89
|
+
|
|
90
|
+
let normalized = [...new Set(authMethods.map(authMethod => authMethod.trim()))];
|
|
91
|
+
if (normalized.some(authMethod => !authMethod)) {
|
|
92
|
+
throw new SlateDeclarationError('Auth method IDs must be non-empty strings');
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return normalized;
|
|
96
|
+
}
|
|
97
|
+
|
|
79
98
|
handleInvocation(
|
|
80
99
|
handler: SlateToolInvocationHandler<ConfigType, AuthType, InputType, OutputType>
|
|
81
100
|
): SlateActionBuilder<Type, ConfigType, AuthType, InputType, OutputType, Result> {
|
|
@@ -138,6 +157,7 @@ export class SlateActionBuilder<
|
|
|
138
157
|
if (scopes) {
|
|
139
158
|
validateScopes(scopes);
|
|
140
159
|
}
|
|
160
|
+
let authMethods = this.validateAuthMethods(this.#authMethods ?? this.params.authMethods);
|
|
141
161
|
|
|
142
162
|
if (!this.#inputSchema) {
|
|
143
163
|
throw new SlateDeclarationError('Input schema is not defined');
|
|
@@ -155,6 +175,7 @@ export class SlateActionBuilder<
|
|
|
155
175
|
return this.factory({
|
|
156
176
|
...this.params,
|
|
157
177
|
scopes,
|
|
178
|
+
authMethods,
|
|
158
179
|
configSchema: this.#configSchema,
|
|
159
180
|
authSchema: this.#authSchema,
|
|
160
181
|
inputSchema: this.#inputSchema,
|
package/src/auth/types.ts
CHANGED
|
@@ -97,7 +97,10 @@ export type SlateAuthWithToken<InputType extends {}, OutputType extends { token?
|
|
|
97
97
|
|
|
98
98
|
docs?: SlateAuthDocsReference[];
|
|
99
99
|
|
|
100
|
-
getOutput: (ctx: { input: InputType }) => Promise<{
|
|
100
|
+
getOutput: (ctx: { input: InputType }) => Promise<{
|
|
101
|
+
output: OutputType;
|
|
102
|
+
scopes?: string[];
|
|
103
|
+
}>;
|
|
101
104
|
|
|
102
105
|
onInputChanged?: (params: {
|
|
103
106
|
previousInput: InputType;
|
|
@@ -121,7 +124,10 @@ export type SlateAuthWithServiceAccount<InputType extends {}, OutputType extends
|
|
|
121
124
|
|
|
122
125
|
docs?: SlateAuthDocsReference[];
|
|
123
126
|
|
|
124
|
-
getOutput: (ctx: { input: InputType }) => Promise<{
|
|
127
|
+
getOutput: (ctx: { input: InputType }) => Promise<{
|
|
128
|
+
output: OutputType;
|
|
129
|
+
scopes?: string[];
|
|
130
|
+
}>;
|
|
125
131
|
|
|
126
132
|
onInputChanged?: (params: {
|
|
127
133
|
previousInput: InputType;
|
|
@@ -145,7 +151,10 @@ export type SlateAuthWithCustomData<InputType extends {}, OutputType extends {}>
|
|
|
145
151
|
|
|
146
152
|
docs?: SlateAuthDocsReference[];
|
|
147
153
|
|
|
148
|
-
getOutput: (ctx: { input: InputType }) => Promise<{
|
|
154
|
+
getOutput: (ctx: { input: InputType }) => Promise<{
|
|
155
|
+
output: OutputType;
|
|
156
|
+
scopes?: string[];
|
|
157
|
+
}>;
|
|
149
158
|
|
|
150
159
|
handleTokenRefresh?: (ctx: {
|
|
151
160
|
output: OutputType;
|