@dual-os/sdk 0.0.0-stage → 0.8.0-next.0
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/LICENSE +4 -0
- package/README.md +19 -2
- package/dist/Action.d.ts +201 -0
- package/dist/Action.d.ts.map +1 -0
- package/dist/Action.js +172 -0
- package/dist/Action.js.map +1 -0
- package/dist/AgentChannel.d.ts +1717 -0
- package/dist/AgentChannel.d.ts.map +1 -0
- package/dist/AgentChannel.js +708 -0
- package/dist/AgentChannel.js.map +1 -0
- package/dist/AgentChannelConformance.d.ts +1543 -0
- package/dist/AgentChannelConformance.d.ts.map +1 -0
- package/dist/AgentChannelConformance.js +163 -0
- package/dist/AgentChannelConformance.js.map +1 -0
- package/dist/AgentChannelRuntime.d.ts +78 -0
- package/dist/AgentChannelRuntime.d.ts.map +1 -0
- package/dist/AgentChannelRuntime.js +270 -0
- package/dist/AgentChannelRuntime.js.map +1 -0
- package/dist/AiProvider.d.ts +132 -0
- package/dist/AiProvider.d.ts.map +1 -0
- package/dist/AiProvider.js +100 -0
- package/dist/AiProvider.js.map +1 -0
- package/dist/AuthMethod.d.ts +381 -0
- package/dist/AuthMethod.d.ts.map +1 -0
- package/dist/AuthMethod.js +225 -0
- package/dist/AuthMethod.js.map +1 -0
- package/dist/AuthMethodBinding.d.ts +77 -0
- package/dist/AuthMethodBinding.d.ts.map +1 -0
- package/dist/AuthMethodBinding.js +31 -0
- package/dist/AuthMethodBinding.js.map +1 -0
- package/dist/AuthMethodExecution.d.ts +223 -0
- package/dist/AuthMethodExecution.d.ts.map +1 -0
- package/dist/AuthMethodExecution.js +277 -0
- package/dist/AuthMethodExecution.js.map +1 -0
- package/dist/ConnectionResolver.d.ts +219 -0
- package/dist/ConnectionResolver.d.ts.map +1 -0
- package/dist/ConnectionResolver.js +153 -0
- package/dist/ConnectionResolver.js.map +1 -0
- package/dist/DefinitionError.d.ts +67 -0
- package/dist/DefinitionError.d.ts.map +1 -0
- package/dist/DefinitionError.js +82 -0
- package/dist/DefinitionError.js.map +1 -0
- package/dist/DualRegistry.d.ts +71 -0
- package/dist/DualRegistry.d.ts.map +1 -0
- package/dist/DualRegistry.js +96 -0
- package/dist/DualRegistry.js.map +1 -0
- package/dist/DualRuntime.d.ts +279 -0
- package/dist/DualRuntime.d.ts.map +1 -0
- package/dist/DualRuntime.js +311 -0
- package/dist/DualRuntime.js.map +1 -0
- package/dist/Files.d.ts +80 -0
- package/dist/Files.d.ts.map +1 -0
- package/dist/Files.js +66 -0
- package/dist/Files.js.map +1 -0
- package/dist/Group.d.ts +106 -0
- package/dist/Group.d.ts.map +1 -0
- package/dist/Group.js +86 -0
- package/dist/Group.js.map +1 -0
- package/dist/Http.d.ts +342 -0
- package/dist/Http.d.ts.map +1 -0
- package/dist/Http.js +677 -0
- package/dist/Http.js.map +1 -0
- package/dist/Mcp.d.ts +109 -0
- package/dist/Mcp.d.ts.map +1 -0
- package/dist/Mcp.js +176 -0
- package/dist/Mcp.js.map +1 -0
- package/dist/OAuth2TokenRefresher.d.ts +18 -0
- package/dist/OAuth2TokenRefresher.d.ts.map +1 -0
- package/dist/OAuth2TokenRefresher.js +19 -0
- package/dist/OAuth2TokenRefresher.js.map +1 -0
- package/dist/OAuthFlow.d.ts +71 -0
- package/dist/OAuthFlow.d.ts.map +1 -0
- package/dist/OAuthFlow.js +488 -0
- package/dist/OAuthFlow.js.map +1 -0
- package/dist/Plugin.d.ts +383 -0
- package/dist/Plugin.d.ts.map +1 -0
- package/dist/Plugin.js +249 -0
- package/dist/Plugin.js.map +1 -0
- package/dist/PluginRuntime.d.ts +3186 -0
- package/dist/PluginRuntime.d.ts.map +1 -0
- package/dist/PluginRuntime.js +331 -0
- package/dist/PluginRuntime.js.map +1 -0
- package/dist/Runner.d.ts +1 -0
- package/dist/Runner.js +124 -0
- package/dist/Runner.js.map +1 -0
- package/dist/ToolFile.d.ts +23 -0
- package/dist/ToolFile.d.ts.map +1 -0
- package/dist/ToolFile.js +33 -0
- package/dist/ToolFile.js.map +1 -0
- package/dist/Trigger.d.ts +358 -0
- package/dist/Trigger.d.ts.map +1 -0
- package/dist/Trigger.js +287 -0
- package/dist/Trigger.js.map +1 -0
- package/dist/_virtual/_rolldown/runtime.js +13 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +24 -0
- package/dist/internal/auth-context.d.ts +23 -0
- package/dist/internal/auth-context.d.ts.map +1 -0
- package/dist/internal/auth-context.js +1 -0
- package/dist/internal/auth-execution.d.ts +27 -0
- package/dist/internal/auth-execution.d.ts.map +1 -0
- package/dist/internal/auth-execution.js +66 -0
- package/dist/internal/auth-execution.js.map +1 -0
- package/dist/internal/auth-runtime.d.ts +5 -0
- package/dist/internal/auth-runtime.d.ts.map +1 -0
- package/dist/internal/auth-runtime.js +16 -0
- package/dist/internal/auth-runtime.js.map +1 -0
- package/dist/internal/capabilities.d.ts +24 -0
- package/dist/internal/capabilities.d.ts.map +1 -0
- package/dist/internal/capabilities.js +22 -0
- package/dist/internal/capabilities.js.map +1 -0
- package/dist/internal/children.d.ts +34 -0
- package/dist/internal/children.d.ts.map +1 -0
- package/dist/internal/children.js +53 -0
- package/dist/internal/children.js.map +1 -0
- package/dist/internal/collection-utils.d.ts +4 -0
- package/dist/internal/collection-utils.d.ts.map +1 -0
- package/dist/internal/collection-utils.js +6 -0
- package/dist/internal/collection-utils.js.map +1 -0
- package/dist/internal/dual/actions.d.ts +33 -0
- package/dist/internal/dual/actions.d.ts.map +1 -0
- package/dist/internal/dual/actions.js +26 -0
- package/dist/internal/dual/actions.js.map +1 -0
- package/dist/internal/dual/invoke.d.ts +63 -0
- package/dist/internal/dual/invoke.d.ts.map +1 -0
- package/dist/internal/dual/invoke.js +75 -0
- package/dist/internal/dual/invoke.js.map +1 -0
- package/dist/internal/dual/registry.d.ts +125 -0
- package/dist/internal/dual/registry.d.ts.map +1 -0
- package/dist/internal/dual/registry.js +172 -0
- package/dist/internal/dual/registry.js.map +1 -0
- package/dist/internal/dual/triggers.d.ts +29 -0
- package/dist/internal/dual/triggers.d.ts.map +1 -0
- package/dist/internal/dual/triggers.js +26 -0
- package/dist/internal/dual/triggers.js.map +1 -0
- package/dist/internal/handler-context.d.ts +9 -0
- package/dist/internal/handler-context.d.ts.map +1 -0
- package/dist/internal/handler-context.js +31 -0
- package/dist/internal/handler-context.js.map +1 -0
- package/dist/internal/identifier.d.ts +6 -0
- package/dist/internal/identifier.d.ts.map +1 -0
- package/dist/internal/identifier.js +28 -0
- package/dist/internal/identifier.js.map +1 -0
- package/dist/internal/plugin-handlers.d.ts +38 -0
- package/dist/internal/plugin-handlers.d.ts.map +1 -0
- package/dist/internal/plugin-handlers.js +52 -0
- package/dist/internal/plugin-handlers.js.map +1 -0
- package/dist/internal/proto.d.ts +7 -0
- package/dist/internal/proto.d.ts.map +1 -0
- package/dist/internal/proto.js +10 -0
- package/dist/internal/proto.js.map +1 -0
- package/dist/internal/schema-runtime.d.ts +6 -0
- package/dist/internal/schema-runtime.d.ts.map +1 -0
- package/dist/internal/schema-runtime.js +10 -0
- package/dist/internal/schema-runtime.js.map +1 -0
- package/dist/internal/trigger-runtime-shared.d.ts +41 -0
- package/dist/internal/trigger-runtime-shared.d.ts.map +1 -0
- package/dist/internal/trigger-runtime-shared.js +132 -0
- package/dist/internal/trigger-runtime-shared.js.map +1 -0
- package/dist/internal/trigger-runtime.d.ts +12 -0
- package/dist/internal/trigger-runtime.d.ts.map +1 -0
- package/dist/internal/trigger-runtime.js +95 -0
- package/dist/internal/trigger-runtime.js.map +1 -0
- package/dist/internal/types.d.ts +7 -0
- package/dist/internal/types.d.ts.map +1 -0
- package/dist/internal/types.js +1 -0
- package/dist/remote-runtime.d.ts +585 -0
- package/dist/remote-runtime.d.ts.map +1 -0
- package/dist/remote-runtime.js +367 -0
- package/dist/remote-runtime.js.map +1 -0
- package/package.json +55 -4
- package/src/Action.ts +370 -0
- package/src/AgentChannel.ts +860 -0
- package/src/AgentChannelConformance.ts +124 -0
- package/src/AgentChannelRuntime.ts +616 -0
- package/src/AiProvider.ts +255 -0
- package/src/AuthMethod.ts +954 -0
- package/src/AuthMethodBinding.ts +112 -0
- package/src/AuthMethodExecution.ts +542 -0
- package/src/ConnectionResolver.ts +265 -0
- package/src/DefinitionError.ts +115 -0
- package/src/DualRegistry.ts +152 -0
- package/src/DualRuntime.ts +1081 -0
- package/src/Files.ts +89 -0
- package/src/Group.ts +292 -0
- package/src/Http.ts +1205 -0
- package/src/Mcp.ts +299 -0
- package/src/OAuth2TokenRefresher.ts +22 -0
- package/src/OAuthFlow.ts +874 -0
- package/src/Plugin.ts +912 -0
- package/src/PluginRuntime.ts +414 -0
- package/src/Runner.ts +248 -0
- package/src/ToolFile.ts +28 -0
- package/src/Trigger.ts +722 -0
- package/src/index.ts +158 -0
- package/src/internal/auth-context.ts +27 -0
- package/src/internal/auth-execution.ts +241 -0
- package/src/internal/auth-runtime.ts +20 -0
- package/src/internal/capabilities.ts +55 -0
- package/src/internal/children.ts +126 -0
- package/src/internal/collection-utils.ts +8 -0
- package/src/internal/dual/actions.ts +116 -0
- package/src/internal/dual/invoke.ts +307 -0
- package/src/internal/dual/registry.ts +340 -0
- package/src/internal/dual/triggers.ts +128 -0
- package/src/internal/handler-context.ts +57 -0
- package/src/internal/identifier.ts +27 -0
- package/src/internal/plugin-handlers.ts +146 -0
- package/src/internal/proto.ts +8 -0
- package/src/internal/schema-runtime.ts +15 -0
- package/src/internal/trigger-runtime-shared.ts +449 -0
- package/src/internal/trigger-runtime.ts +223 -0
- package/src/internal/types.ts +12 -0
- package/src/remote-runtime.ts +469 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { BindingFor } from "./AuthMethodBinding.js";
|
|
2
|
+
import { Any as Any$1 } from "./AuthMethod.js";
|
|
3
|
+
import { Category } from "./Plugin.js";
|
|
4
|
+
import { Pipeable, Schema } from "effect";
|
|
5
|
+
declare namespace AiProvider_d_exports {
|
|
6
|
+
export { AddAuthMethods, AiProvider, AiProviderOptions, Any, RuntimeConfig, RuntimeConfigResolver, RuntimeConfigResolverInput, RuntimeModel, TypeId, isAiProvider, make, registryId, withAuthMethod, withAuthMethods, withCategories, withDescription, withDocsUrl, withHomepageUrl, withIconUrl, withIconUrlDark, withName, withRuntimeConfig };
|
|
7
|
+
}
|
|
8
|
+
/** @since 0.0.0 @category type ids */
|
|
9
|
+
export declare const TypeId: "@dual-os/sdk/AiProvider";
|
|
10
|
+
/** @since 0.0.0 @category type ids */
|
|
11
|
+
export type TypeId = typeof TypeId;
|
|
12
|
+
/** @since 0.0.0 @category type-level */
|
|
13
|
+
export interface Any extends Pipeable.Pipeable {
|
|
14
|
+
readonly [TypeId]: TypeId;
|
|
15
|
+
readonly identifier: string;
|
|
16
|
+
readonly name: string | undefined;
|
|
17
|
+
readonly description: string | undefined;
|
|
18
|
+
readonly iconUrl: string | undefined;
|
|
19
|
+
readonly iconUrlDark: string | undefined;
|
|
20
|
+
readonly categories: readonly Category[];
|
|
21
|
+
readonly homepageUrl: string | undefined;
|
|
22
|
+
readonly docsUrl: string | undefined;
|
|
23
|
+
readonly authMethods: readonly Any$1[];
|
|
24
|
+
readonly resolveRuntimeConfig: unknown;
|
|
25
|
+
}
|
|
26
|
+
/** @since 0.0.0 @category models */
|
|
27
|
+
export declare const RuntimeConfig: Schema.Struct<{
|
|
28
|
+
readonly apiKey: Schema.optional<Schema.String>;
|
|
29
|
+
readonly baseUrl: Schema.optional<Schema.String>;
|
|
30
|
+
readonly env: Schema.optional<Schema.$Record<Schema.String, Schema.String>>;
|
|
31
|
+
readonly headers: Schema.optional<Schema.$Record<Schema.String, Schema.NullOr<Schema.String>>>;
|
|
32
|
+
}>;
|
|
33
|
+
/** @since 0.0.0 @category models */
|
|
34
|
+
export type RuntimeConfig = typeof RuntimeConfig.Type;
|
|
35
|
+
/** @since 0.0.0 @category models */
|
|
36
|
+
export interface RuntimeModel {
|
|
37
|
+
readonly id: string;
|
|
38
|
+
readonly baseUrl: string;
|
|
39
|
+
}
|
|
40
|
+
/** @since 0.0.0 @category models */
|
|
41
|
+
export interface RuntimeConfigResolverInput<Methods extends readonly Any$1[]> {
|
|
42
|
+
readonly model: RuntimeModel;
|
|
43
|
+
readonly binding: BindingFor<Methods>;
|
|
44
|
+
}
|
|
45
|
+
/** @since 0.0.0 @category models */
|
|
46
|
+
export type RuntimeConfigResolver<Methods extends readonly Any$1[]> = (input: RuntimeConfigResolverInput<Methods>) => RuntimeConfig;
|
|
47
|
+
/** @since 0.0.0 @category models */
|
|
48
|
+
export interface AiProviderOptions<Identifier extends string = string> {
|
|
49
|
+
readonly identifier: Identifier;
|
|
50
|
+
readonly name?: string;
|
|
51
|
+
readonly description?: string;
|
|
52
|
+
readonly iconUrl?: string;
|
|
53
|
+
readonly iconUrlDark?: string;
|
|
54
|
+
readonly categories?: readonly Category[];
|
|
55
|
+
readonly homepageUrl?: string;
|
|
56
|
+
readonly docsUrl?: string;
|
|
57
|
+
}
|
|
58
|
+
/** @since 0.0.0 @category models */
|
|
59
|
+
export interface AiProvider<out Identifier extends string = string, out AuthMethods extends readonly Any$1[] = readonly []> extends Pipeable.Pipeable {
|
|
60
|
+
readonly [TypeId]: TypeId;
|
|
61
|
+
readonly identifier: Identifier;
|
|
62
|
+
readonly name: string | undefined;
|
|
63
|
+
readonly description: string | undefined;
|
|
64
|
+
readonly iconUrl: string | undefined;
|
|
65
|
+
readonly iconUrlDark: string | undefined;
|
|
66
|
+
readonly categories: readonly Category[];
|
|
67
|
+
readonly homepageUrl: string | undefined;
|
|
68
|
+
readonly docsUrl: string | undefined;
|
|
69
|
+
readonly authMethods: AuthMethods;
|
|
70
|
+
readonly resolveRuntimeConfig: RuntimeConfigResolver<AuthMethods> | undefined;
|
|
71
|
+
}
|
|
72
|
+
/** @since 0.0.0 @category type-level */
|
|
73
|
+
export type AddAuthMethods<Self extends Any, AddedMethods extends readonly Any$1[]> = Self extends AiProvider<infer Identifier, infer AuthMethods> ? AiProvider<Identifier, readonly [...AuthMethods, ...AddedMethods]> : never;
|
|
74
|
+
/** @since 0.0.0 @category constructors */
|
|
75
|
+
export declare const make: <const Identifier extends string>(identifier: Identifier) => AiProvider<Identifier>;
|
|
76
|
+
/** @since 0.0.0 @category registry */
|
|
77
|
+
export declare const registryId: (identifier: string) => string;
|
|
78
|
+
/** @since 0.0.0 @category guards */
|
|
79
|
+
export declare const isAiProvider: (value: unknown) => value is Any;
|
|
80
|
+
/** @since 0.0.0 @category combinators */
|
|
81
|
+
export declare const withName: {
|
|
82
|
+
(name: string): <P extends AiProvider<any, any>>(provider: P) => P;
|
|
83
|
+
<P extends AiProvider<any, any>>(provider: P, name: string): P;
|
|
84
|
+
};
|
|
85
|
+
/** @since 0.0.0 @category combinators */
|
|
86
|
+
export declare const withDescription: {
|
|
87
|
+
(description: string): <P extends AiProvider<any, any>>(provider: P) => P;
|
|
88
|
+
<P extends AiProvider<any, any>>(provider: P, description: string): P;
|
|
89
|
+
};
|
|
90
|
+
/** @since 0.0.0 @category combinators */
|
|
91
|
+
export declare const withIconUrl: {
|
|
92
|
+
(iconUrl: string): <P extends AiProvider<any, any>>(provider: P) => P;
|
|
93
|
+
<P extends AiProvider<any, any>>(provider: P, iconUrl: string): P;
|
|
94
|
+
};
|
|
95
|
+
/** @since 0.0.0 @category combinators */
|
|
96
|
+
export declare const withIconUrlDark: {
|
|
97
|
+
(iconUrlDark: string): <P extends AiProvider<any, any>>(provider: P) => P;
|
|
98
|
+
<P extends AiProvider<any, any>>(provider: P, iconUrlDark: string): P;
|
|
99
|
+
};
|
|
100
|
+
/** @since 0.0.0 @category combinators */
|
|
101
|
+
export declare const withCategories: {
|
|
102
|
+
(categories: readonly Category[]): <P extends AiProvider<any, any>>(provider: P) => P;
|
|
103
|
+
<P extends AiProvider<any, any>>(provider: P, categories: readonly Category[]): P;
|
|
104
|
+
};
|
|
105
|
+
/** @since 0.0.0 @category combinators */
|
|
106
|
+
export declare const withHomepageUrl: {
|
|
107
|
+
(homepageUrl: string): <P extends AiProvider<any, any>>(provider: P) => P;
|
|
108
|
+
<P extends AiProvider<any, any>>(provider: P, homepageUrl: string): P;
|
|
109
|
+
};
|
|
110
|
+
/** @since 0.0.0 @category combinators */
|
|
111
|
+
export declare const withDocsUrl: {
|
|
112
|
+
(docsUrl: string): <P extends AiProvider<any, any>>(provider: P) => P;
|
|
113
|
+
<P extends AiProvider<any, any>>(provider: P, docsUrl: string): P;
|
|
114
|
+
};
|
|
115
|
+
/** @since 0.0.0 @category combinators */
|
|
116
|
+
export declare const withAuthMethods: {
|
|
117
|
+
<const AddedMethods extends readonly Any$1[]>(methods: AddedMethods): <Self extends Any>(provider: Self) => AddAuthMethods<Self, AddedMethods>;
|
|
118
|
+
<Self extends Any, const AddedMethods extends readonly Any$1[]>(provider: Self, methods: AddedMethods): AddAuthMethods<Self, AddedMethods>;
|
|
119
|
+
};
|
|
120
|
+
/** @since 0.0.0 @category combinators */
|
|
121
|
+
export declare const withAuthMethod: {
|
|
122
|
+
<const AddedMethod extends Any$1>(method: AddedMethod): <Self extends Any>(provider: Self) => AddAuthMethods<Self, readonly [AddedMethod]>;
|
|
123
|
+
<Self extends Any, const AddedMethod extends Any$1>(provider: Self, method: AddedMethod): AddAuthMethods<Self, readonly [AddedMethod]>;
|
|
124
|
+
};
|
|
125
|
+
/** @since 0.0.0 @category combinators */
|
|
126
|
+
export declare const withRuntimeConfig: {
|
|
127
|
+
<Self extends Any>(resolve: RuntimeConfigResolver<Self["authMethods"]>): (provider: Self) => Self;
|
|
128
|
+
<Self extends Any>(provider: Self, resolve: RuntimeConfigResolver<Self["authMethods"]>): Self;
|
|
129
|
+
};
|
|
130
|
+
//#endregion
|
|
131
|
+
export { AiProvider_d_exports };
|
|
132
|
+
//# sourceMappingURL=AiProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AiProvider.d.ts","names":["AuthMethod.Any","AuthMethodBinding.BindingFor"],"sources":["../src/AiProvider.ts"],"mappings":";;;;;;;;qBAqBa;;YAED,gBAAgB;;iBAGX,YAAY,SAAS;YAC1B,SAAS;WACV;WACA;WACA;WACA;WACA;WACA,qBAAqB;WACrB;WACA;WACA,sBAAsBA;WACtB;;;qBAIE,eAAa,OAAA;;;;;;;YAQd,uBAAuB,cAAc;;iBAGhC;WACN;WACA;;;iBAIM,2BAA2B,yBAAyBA;WAC1D,OAAO;WACP,SAASC,WAA6B;;;YAIrC,sBAAsB,yBAAyBD,YACzD,OAAO,2BAA2B,aAC/B;;iBAGY,kBAAkB;WACxB,YAAY;WACZ;WACA;WACA;WACA;WACA,sBAAsB;WACtB;WACA;;;iBAIM,eACX,wCACA,6BAA6BA,+BAEzB,SAAS;YACP,SAAS;WACV,YAAY;WACZ;WACA;WACA;WACA;WACA,qBAAqB;WACrB;WACA;WACA,aAAa;WACb,sBAAsB,sBAAsB;;;YAI3C,eAAe,aAAa,KAAK,8BAA8BA,WACzE,aAAa,iBAAiB,kBAAkB,eAC5C,WAAW,yBAAyB,gBAAgB;;qBAuC7C,aAAc,2BAAyB,YACtC,eACX,WAAW;;qBAGD,aAAU;;qBAGV,eAAY,mBAAqB,SAAS;;qBAa1C;GACV,gBAAgB,UAAU,sBAAsB,UAAU,MAAM;GAChE,UAAU,sBAAsB,UAAU,GAAG,eAAe;;;qBAIlD;GACV,uBAAuB,UAAU,sBAAsB,UAAU,MAAM;GACvE,UAAU,sBAAsB,UAAU,GAAG,sBAAsB;;;qBAMzD;GACV,mBAAmB,UAAU,sBAAsB,UAAU,MAAM;GACnE,UAAU,sBAAsB,UAAU,GAAG,kBAAkB;;;qBAMrD;GACV,uBAAuB,UAAU,sBAAsB,UAAU,MAAM;GACvE,UAAU,sBAAsB,UAAU,GAAG,sBAAsB;;;qBAMzD;GACV,qBAAqB,cAAc,UAAU,sBAAsB,UAAU,MAAM;GACnF,UAAU,sBAAsB,UAAU,GAAG,qBAAqB,aAAa;;;qBAMrE;GACV,uBAAuB,UAAU,sBAAsB,UAAU,MAAM;GACvE,UAAU,sBAAsB,UAAU,GAAG,sBAAsB;;;qBAMzD;GACV,mBAAmB,UAAU,sBAAsB,UAAU,MAAM;GACnE,UAAU,sBAAsB,UAAU,GAAG,kBAAkB;;;qBAMrD;SACJ,8BAA8BA,SACnC,SAAS,gBACP,aAAa,KAAK,UAAU,SAAS,eAAe,MAAM;GAC7D,aAAa,WAAW,8BAA8BA,SACrD,UAAU,MACV,SAAS,eACR,eAAe,MAAM;;;qBAWb;SACJ,oBAAoBA,OACzB,QAAQ,eACN,aAAa,KAAK,UAAU,SAAS,eAAe,gBAAgB;GACvE,aAAa,WAAW,oBAAoBA,OAC3C,UAAU,MACV,QAAQ,cACP,eAAe,gBAAgB;;;qBAMvB;GACV,aAAa,KAAK,SAAS,sBAAsB,wBAAwB,UAAU,SAAS;GAC5F,aAAa,KAAK,UAAU,MAAM,SAAS,sBAAsB,uBAAuB"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { validateIdentifier } from "./internal/identifier.js";
|
|
3
|
+
import { PipeableProto } from "./internal/proto.js";
|
|
4
|
+
import { assertNoDuplicateAuthMethodIdentifiers } from "./internal/auth-runtime.js";
|
|
5
|
+
import { appendElements } from "./internal/collection-utils.js";
|
|
6
|
+
import { Function, Predicate, Schema } from "effect";
|
|
7
|
+
//#region src/AiProvider.ts
|
|
8
|
+
var AiProvider_exports = /* @__PURE__ */ __exportAll({
|
|
9
|
+
RuntimeConfig: () => RuntimeConfig,
|
|
10
|
+
TypeId: () => TypeId,
|
|
11
|
+
isAiProvider: () => isAiProvider,
|
|
12
|
+
make: () => make,
|
|
13
|
+
registryId: () => registryId,
|
|
14
|
+
withAuthMethod: () => withAuthMethod,
|
|
15
|
+
withAuthMethods: () => withAuthMethods,
|
|
16
|
+
withCategories: () => withCategories,
|
|
17
|
+
withDescription: () => withDescription,
|
|
18
|
+
withDocsUrl: () => withDocsUrl,
|
|
19
|
+
withHomepageUrl: () => withHomepageUrl,
|
|
20
|
+
withIconUrl: () => withIconUrl,
|
|
21
|
+
withIconUrlDark: () => withIconUrlDark,
|
|
22
|
+
withName: () => withName,
|
|
23
|
+
withRuntimeConfig: () => withRuntimeConfig
|
|
24
|
+
});
|
|
25
|
+
/** @since 0.0.0 @category type ids */
|
|
26
|
+
const TypeId = "@dual-os/sdk/AiProvider";
|
|
27
|
+
/** @since 0.0.0 @category models */
|
|
28
|
+
const RuntimeConfig = Schema.Struct({
|
|
29
|
+
apiKey: Schema.optional(Schema.String),
|
|
30
|
+
baseUrl: Schema.optional(Schema.String),
|
|
31
|
+
env: Schema.optional(Schema.Record(Schema.String, Schema.String)),
|
|
32
|
+
headers: Schema.optional(Schema.Record(Schema.String, Schema.NullOr(Schema.String)))
|
|
33
|
+
});
|
|
34
|
+
const optionsFromProvider = (provider) => ({
|
|
35
|
+
identifier: provider.identifier,
|
|
36
|
+
...provider.name === void 0 ? {} : { name: provider.name },
|
|
37
|
+
...provider.description === void 0 ? {} : { description: provider.description },
|
|
38
|
+
...provider.iconUrl === void 0 ? {} : { iconUrl: provider.iconUrl },
|
|
39
|
+
...provider.iconUrlDark === void 0 ? {} : { iconUrlDark: provider.iconUrlDark },
|
|
40
|
+
...provider.categories.length === 0 ? {} : { categories: provider.categories },
|
|
41
|
+
...provider.homepageUrl === void 0 ? {} : { homepageUrl: provider.homepageUrl },
|
|
42
|
+
...provider.docsUrl === void 0 ? {} : { docsUrl: provider.docsUrl }
|
|
43
|
+
});
|
|
44
|
+
const Proto = {
|
|
45
|
+
...PipeableProto,
|
|
46
|
+
[TypeId]: TypeId
|
|
47
|
+
};
|
|
48
|
+
const makeProvider = (options, authMethods, resolveRuntimeConfig) => {
|
|
49
|
+
validateIdentifier("provider", options.identifier);
|
|
50
|
+
assertNoDuplicateAuthMethodIdentifiers(options.identifier, authMethods);
|
|
51
|
+
return Object.assign(Object.create(Proto), {
|
|
52
|
+
authMethods,
|
|
53
|
+
categories: options.categories ?? [],
|
|
54
|
+
description: options.description,
|
|
55
|
+
docsUrl: options.docsUrl,
|
|
56
|
+
homepageUrl: options.homepageUrl,
|
|
57
|
+
iconUrl: options.iconUrl,
|
|
58
|
+
iconUrlDark: options.iconUrlDark,
|
|
59
|
+
identifier: options.identifier,
|
|
60
|
+
name: options.name,
|
|
61
|
+
resolveRuntimeConfig
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
/** @since 0.0.0 @category constructors */
|
|
65
|
+
const make = (identifier) => makeProvider({ identifier }, []);
|
|
66
|
+
/** @since 0.0.0 @category registry */
|
|
67
|
+
const registryId = (identifier) => `ai/${identifier}`;
|
|
68
|
+
/** @since 0.0.0 @category guards */
|
|
69
|
+
const isAiProvider = (value) => Predicate.hasProperty(value, TypeId);
|
|
70
|
+
const withOption = (provider, options) => makeProvider({
|
|
71
|
+
...optionsFromProvider(provider),
|
|
72
|
+
...options
|
|
73
|
+
}, provider.authMethods, provider.resolveRuntimeConfig);
|
|
74
|
+
/** @since 0.0.0 @category combinators */
|
|
75
|
+
const withName = Function.dual(2, (provider, name) => withOption(provider, { name }));
|
|
76
|
+
/** @since 0.0.0 @category combinators */
|
|
77
|
+
const withDescription = Function.dual(2, (provider, description) => withOption(provider, { description }));
|
|
78
|
+
/** @since 0.0.0 @category combinators */
|
|
79
|
+
const withIconUrl = Function.dual(2, (provider, iconUrl) => withOption(provider, { iconUrl }));
|
|
80
|
+
/** @since 0.0.0 @category combinators */
|
|
81
|
+
const withIconUrlDark = Function.dual(2, (provider, iconUrlDark) => withOption(provider, { iconUrlDark }));
|
|
82
|
+
/** @since 0.0.0 @category combinators */
|
|
83
|
+
const withCategories = Function.dual(2, (provider, categories) => withOption(provider, { categories: [...categories] }));
|
|
84
|
+
/** @since 0.0.0 @category combinators */
|
|
85
|
+
const withHomepageUrl = Function.dual(2, (provider, homepageUrl) => withOption(provider, { homepageUrl }));
|
|
86
|
+
/** @since 0.0.0 @category combinators */
|
|
87
|
+
const withDocsUrl = Function.dual(2, (provider, docsUrl) => withOption(provider, { docsUrl }));
|
|
88
|
+
/** @since 0.0.0 @category combinators */
|
|
89
|
+
const withAuthMethods = Function.dual(2, (provider, methods) => {
|
|
90
|
+
if (provider.resolveRuntimeConfig !== void 0) throw new Error(`AI provider "${provider.identifier}" must declare auth methods before its runtime config`);
|
|
91
|
+
return makeProvider(optionsFromProvider(provider), appendElements(provider.authMethods, methods));
|
|
92
|
+
});
|
|
93
|
+
/** @since 0.0.0 @category combinators */
|
|
94
|
+
const withAuthMethod = Function.dual(2, (provider, method) => withAuthMethods(provider, [method]));
|
|
95
|
+
/** @since 0.0.0 @category combinators */
|
|
96
|
+
const withRuntimeConfig = Function.dual(2, (provider, resolve) => makeProvider(optionsFromProvider(provider), provider.authMethods, resolve));
|
|
97
|
+
//#endregion
|
|
98
|
+
export { AiProvider_exports, RuntimeConfig, TypeId, isAiProvider, make, registryId, withAuthMethod, withAuthMethods, withCategories, withDescription, withDocsUrl, withHomepageUrl, withIconUrl, withIconUrlDark, withName, withRuntimeConfig };
|
|
99
|
+
|
|
100
|
+
//# sourceMappingURL=AiProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AiProvider.js","names":["Func"],"sources":["../src/AiProvider.ts"],"sourcesContent":["/**\n * AI provider definitions for model authentication.\n *\n * AI providers share provider metadata and auth methods with Tools providers,\n * but cannot contribute actions, triggers, or groups. Their identifier is a\n * stable key matched exactly against Pi's `Model.provider` value.\n *\n * @since 0.0.0\n */\nimport type { Pipeable } from \"effect\";\nimport { Function as Func, Predicate, Schema } from \"effect\";\n\nimport type * as AuthMethod from \"./AuthMethod.ts\";\nimport type * as AuthMethodBinding from \"./AuthMethodBinding.ts\";\nimport { assertNoDuplicateAuthMethodIdentifiers } from \"./internal/auth-runtime.ts\";\nimport { appendElements } from \"./internal/collection-utils.ts\";\nimport { validateIdentifier } from \"./internal/identifier.ts\";\nimport { PipeableProto } from \"./internal/proto.ts\";\nimport type { Category } from \"./Plugin.ts\";\n\n/** @since 0.0.0 @category type ids */\nexport const TypeId = \"@dual-os/sdk/AiProvider\" as const;\n/** @since 0.0.0 @category type ids */\nexport type TypeId = typeof TypeId;\n\n/** @since 0.0.0 @category type-level */\nexport interface Any extends Pipeable.Pipeable {\n readonly [TypeId]: TypeId;\n readonly identifier: string;\n readonly name: string | undefined;\n readonly description: string | undefined;\n readonly iconUrl: string | undefined;\n readonly iconUrlDark: string | undefined;\n readonly categories: readonly Category[];\n readonly homepageUrl: string | undefined;\n readonly docsUrl: string | undefined;\n readonly authMethods: readonly AuthMethod.Any[];\n readonly resolveRuntimeConfig: unknown;\n}\n\n/** @since 0.0.0 @category models */\nexport const RuntimeConfig = Schema.Struct({\n apiKey: Schema.optional(Schema.String),\n baseUrl: Schema.optional(Schema.String),\n env: Schema.optional(Schema.Record(Schema.String, Schema.String)),\n headers: Schema.optional(Schema.Record(Schema.String, Schema.NullOr(Schema.String))),\n});\n\n/** @since 0.0.0 @category models */\nexport type RuntimeConfig = typeof RuntimeConfig.Type;\n\n/** @since 0.0.0 @category models */\nexport interface RuntimeModel {\n readonly id: string;\n readonly baseUrl: string;\n}\n\n/** @since 0.0.0 @category models */\nexport interface RuntimeConfigResolverInput<Methods extends readonly AuthMethod.Any[]> {\n readonly model: RuntimeModel;\n readonly binding: AuthMethodBinding.BindingFor<Methods>;\n}\n\n/** @since 0.0.0 @category models */\nexport type RuntimeConfigResolver<Methods extends readonly AuthMethod.Any[]> = (\n input: RuntimeConfigResolverInput<Methods>,\n) => RuntimeConfig;\n\n/** @since 0.0.0 @category models */\nexport interface AiProviderOptions<Identifier extends string = string> {\n readonly identifier: Identifier;\n readonly name?: string;\n readonly description?: string;\n readonly iconUrl?: string;\n readonly iconUrlDark?: string;\n readonly categories?: readonly Category[];\n readonly homepageUrl?: string;\n readonly docsUrl?: string;\n}\n\n/** @since 0.0.0 @category models */\nexport interface AiProvider<\n out Identifier extends string = string,\n out AuthMethods extends readonly AuthMethod.Any[] = readonly [],\n>\n extends Pipeable.Pipeable {\n readonly [TypeId]: TypeId;\n readonly identifier: Identifier;\n readonly name: string | undefined;\n readonly description: string | undefined;\n readonly iconUrl: string | undefined;\n readonly iconUrlDark: string | undefined;\n readonly categories: readonly Category[];\n readonly homepageUrl: string | undefined;\n readonly docsUrl: string | undefined;\n readonly authMethods: AuthMethods;\n readonly resolveRuntimeConfig: RuntimeConfigResolver<AuthMethods> | undefined;\n}\n\n/** @since 0.0.0 @category type-level */\nexport type AddAuthMethods<Self extends Any, AddedMethods extends readonly AuthMethod.Any[]> =\n Self extends AiProvider<infer Identifier, infer AuthMethods>\n ? AiProvider<Identifier, readonly [...AuthMethods, ...AddedMethods]>\n : never;\n\nconst optionsFromProvider = (provider: Any): AiProviderOptions => ({\n identifier: provider.identifier,\n ...(provider.name === undefined ? {} : { name: provider.name }),\n ...(provider.description === undefined ? {} : { description: provider.description }),\n ...(provider.iconUrl === undefined ? {} : { iconUrl: provider.iconUrl }),\n ...(provider.iconUrlDark === undefined ? {} : { iconUrlDark: provider.iconUrlDark }),\n ...(provider.categories.length === 0 ? {} : { categories: provider.categories }),\n ...(provider.homepageUrl === undefined ? {} : { homepageUrl: provider.homepageUrl }),\n ...(provider.docsUrl === undefined ? {} : { docsUrl: provider.docsUrl }),\n});\n\nconst Proto = { ...PipeableProto, [TypeId]: TypeId };\n\nconst makeProvider = <Identifier extends string, AuthMethods extends readonly AuthMethod.Any[]>(\n options: AiProviderOptions<Identifier>,\n authMethods: AuthMethods,\n resolveRuntimeConfig?: RuntimeConfigResolver<AuthMethods>,\n): AiProvider<Identifier, AuthMethods> => {\n validateIdentifier(\"provider\", options.identifier);\n assertNoDuplicateAuthMethodIdentifiers(options.identifier, authMethods);\n\n return Object.assign(Object.create(Proto), {\n authMethods,\n categories: options.categories ?? [],\n description: options.description,\n docsUrl: options.docsUrl,\n homepageUrl: options.homepageUrl,\n iconUrl: options.iconUrl,\n iconUrlDark: options.iconUrlDark,\n identifier: options.identifier,\n name: options.name,\n resolveRuntimeConfig,\n });\n};\n\n/** @since 0.0.0 @category constructors */\nexport const make = <const Identifier extends string>(\n identifier: Identifier,\n): AiProvider<Identifier> => makeProvider({ identifier }, [] as const);\n\n/** @since 0.0.0 @category registry */\nexport const registryId = (identifier: string): string => `ai/${identifier}`;\n\n/** @since 0.0.0 @category guards */\nexport const isAiProvider = (value: unknown): value is Any => Predicate.hasProperty(value, TypeId);\n\nconst withOption = <P extends AiProvider<any, any>>(\n provider: P,\n options: Partial<AiProviderOptions>,\n): P =>\n makeProvider(\n { ...optionsFromProvider(provider), ...options },\n provider.authMethods,\n provider.resolveRuntimeConfig,\n ) as P;\n\n/** @since 0.0.0 @category combinators */\nexport const withName: {\n (name: string): <P extends AiProvider<any, any>>(provider: P) => P;\n <P extends AiProvider<any, any>>(provider: P, name: string): P;\n} = Func.dual(2, (provider: AiProvider<any, any>, name: string) => withOption(provider, { name }));\n\n/** @since 0.0.0 @category combinators */\nexport const withDescription: {\n (description: string): <P extends AiProvider<any, any>>(provider: P) => P;\n <P extends AiProvider<any, any>>(provider: P, description: string): P;\n} = Func.dual(2, (provider: AiProvider<any, any>, description: string) =>\n withOption(provider, { description }),\n);\n\n/** @since 0.0.0 @category combinators */\nexport const withIconUrl: {\n (iconUrl: string): <P extends AiProvider<any, any>>(provider: P) => P;\n <P extends AiProvider<any, any>>(provider: P, iconUrl: string): P;\n} = Func.dual(2, (provider: AiProvider<any, any>, iconUrl: string) =>\n withOption(provider, { iconUrl }),\n);\n\n/** @since 0.0.0 @category combinators */\nexport const withIconUrlDark: {\n (iconUrlDark: string): <P extends AiProvider<any, any>>(provider: P) => P;\n <P extends AiProvider<any, any>>(provider: P, iconUrlDark: string): P;\n} = Func.dual(2, (provider: AiProvider<any, any>, iconUrlDark: string) =>\n withOption(provider, { iconUrlDark }),\n);\n\n/** @since 0.0.0 @category combinators */\nexport const withCategories: {\n (categories: readonly Category[]): <P extends AiProvider<any, any>>(provider: P) => P;\n <P extends AiProvider<any, any>>(provider: P, categories: readonly Category[]): P;\n} = Func.dual(2, (provider: AiProvider<any, any>, categories: readonly Category[]) =>\n withOption(provider, { categories: [...categories] }),\n);\n\n/** @since 0.0.0 @category combinators */\nexport const withHomepageUrl: {\n (homepageUrl: string): <P extends AiProvider<any, any>>(provider: P) => P;\n <P extends AiProvider<any, any>>(provider: P, homepageUrl: string): P;\n} = Func.dual(2, (provider: AiProvider<any, any>, homepageUrl: string) =>\n withOption(provider, { homepageUrl }),\n);\n\n/** @since 0.0.0 @category combinators */\nexport const withDocsUrl: {\n (docsUrl: string): <P extends AiProvider<any, any>>(provider: P) => P;\n <P extends AiProvider<any, any>>(provider: P, docsUrl: string): P;\n} = Func.dual(2, (provider: AiProvider<any, any>, docsUrl: string) =>\n withOption(provider, { docsUrl }),\n);\n\n/** @since 0.0.0 @category combinators */\nexport const withAuthMethods: {\n <const AddedMethods extends readonly AuthMethod.Any[]>(\n methods: AddedMethods,\n ): <Self extends Any>(provider: Self) => AddAuthMethods<Self, AddedMethods>;\n <Self extends Any, const AddedMethods extends readonly AuthMethod.Any[]>(\n provider: Self,\n methods: AddedMethods,\n ): AddAuthMethods<Self, AddedMethods>;\n} = Func.dual(2, (provider: Any, methods: readonly AuthMethod.Any[]) => {\n if (provider.resolveRuntimeConfig !== undefined) {\n throw new Error(\n `AI provider \"${provider.identifier}\" must declare auth methods before its runtime config`,\n );\n }\n return makeProvider(optionsFromProvider(provider), appendElements(provider.authMethods, methods));\n});\n\n/** @since 0.0.0 @category combinators */\nexport const withAuthMethod: {\n <const AddedMethod extends AuthMethod.Any>(\n method: AddedMethod,\n ): <Self extends Any>(provider: Self) => AddAuthMethods<Self, readonly [AddedMethod]>;\n <Self extends Any, const AddedMethod extends AuthMethod.Any>(\n provider: Self,\n method: AddedMethod,\n ): AddAuthMethods<Self, readonly [AddedMethod]>;\n} = Func.dual(2, (provider: Any, method: AuthMethod.Any) =>\n withAuthMethods(provider, [method] as const),\n);\n\n/** @since 0.0.0 @category combinators */\nexport const withRuntimeConfig: {\n <Self extends Any>(resolve: RuntimeConfigResolver<Self[\"authMethods\"]>): (provider: Self) => Self;\n <Self extends Any>(provider: Self, resolve: RuntimeConfigResolver<Self[\"authMethods\"]>): Self;\n} = Func.dual(\n 2,\n (provider: AiProvider<any, any>, resolve: RuntimeConfigResolver<readonly AuthMethod.Any[]>) =>\n makeProvider(optionsFromProvider(provider), provider.authMethods, resolve),\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAqBA,MAAa,SAAS;;AAoBtB,MAAa,gBAAgB,OAAO,OAAO;CACzC,QAAQ,OAAO,SAAS,OAAO,MAAM;CACrC,SAAS,OAAO,SAAS,OAAO,MAAM;CACtC,KAAK,OAAO,SAAS,OAAO,OAAO,OAAO,QAAQ,OAAO,MAAM,CAAC;CAChE,SAAS,OAAO,SAAS,OAAO,OAAO,OAAO,QAAQ,OAAO,OAAO,OAAO,MAAM,CAAC,CAAC;AACrF,CAAC;AA2DD,MAAM,uBAAuB,cAAsC;CACjE,YAAY,SAAS;CACrB,GAAI,SAAS,SAAS,KAAA,IAAY,CAAC,IAAI,EAAE,MAAM,SAAS,KAAK;CAC7D,GAAI,SAAS,gBAAgB,KAAA,IAAY,CAAC,IAAI,EAAE,aAAa,SAAS,YAAY;CAClF,GAAI,SAAS,YAAY,KAAA,IAAY,CAAC,IAAI,EAAE,SAAS,SAAS,QAAQ;CACtE,GAAI,SAAS,gBAAgB,KAAA,IAAY,CAAC,IAAI,EAAE,aAAa,SAAS,YAAY;CAClF,GAAI,SAAS,WAAW,WAAW,IAAI,CAAC,IAAI,EAAE,YAAY,SAAS,WAAW;CAC9E,GAAI,SAAS,gBAAgB,KAAA,IAAY,CAAC,IAAI,EAAE,aAAa,SAAS,YAAY;CAClF,GAAI,SAAS,YAAY,KAAA,IAAY,CAAC,IAAI,EAAE,SAAS,SAAS,QAAQ;AACxE;AAEA,MAAM,QAAQ;CAAE,GAAG;EAAgB,SAAS;AAAO;AAEnD,MAAM,gBACJ,SACA,aACA,yBACwC;CACxC,mBAAmB,YAAY,QAAQ,UAAU;CACjD,uCAAuC,QAAQ,YAAY,WAAW;CAEtE,OAAO,OAAO,OAAO,OAAO,OAAO,KAAK,GAAG;EACzC;EACA,YAAY,QAAQ,cAAc,CAAC;EACnC,aAAa,QAAQ;EACrB,SAAS,QAAQ;EACjB,aAAa,QAAQ;EACrB,SAAS,QAAQ;EACjB,aAAa,QAAQ;EACrB,YAAY,QAAQ;EACpB,MAAM,QAAQ;EACd;CACF,CAAC;AACH;;AAGA,MAAa,QACX,eAC2B,aAAa,EAAE,WAAW,GAAG,CAAC,CAAU;;AAGrE,MAAa,cAAc,eAA+B,MAAM;;AAGhE,MAAa,gBAAgB,UAAiC,UAAU,YAAY,OAAO,MAAM;AAEjG,MAAM,cACJ,UACA,YAEA,aACE;CAAE,GAAG,oBAAoB,QAAQ;CAAG,GAAG;AAAQ,GAC/C,SAAS,aACT,SAAS,oBACX;;AAGF,MAAa,WAGTA,SAAK,KAAK,IAAI,UAAgC,SAAiB,WAAW,UAAU,EAAE,KAAK,CAAC,CAAC;;AAGjG,MAAa,kBAGTA,SAAK,KAAK,IAAI,UAAgC,gBAChD,WAAW,UAAU,EAAE,YAAY,CAAC,CACtC;;AAGA,MAAa,cAGTA,SAAK,KAAK,IAAI,UAAgC,YAChD,WAAW,UAAU,EAAE,QAAQ,CAAC,CAClC;;AAGA,MAAa,kBAGTA,SAAK,KAAK,IAAI,UAAgC,gBAChD,WAAW,UAAU,EAAE,YAAY,CAAC,CACtC;;AAGA,MAAa,iBAGTA,SAAK,KAAK,IAAI,UAAgC,eAChD,WAAW,UAAU,EAAE,YAAY,CAAC,GAAG,UAAU,EAAE,CAAC,CACtD;;AAGA,MAAa,kBAGTA,SAAK,KAAK,IAAI,UAAgC,gBAChD,WAAW,UAAU,EAAE,YAAY,CAAC,CACtC;;AAGA,MAAa,cAGTA,SAAK,KAAK,IAAI,UAAgC,YAChD,WAAW,UAAU,EAAE,QAAQ,CAAC,CAClC;;AAGA,MAAa,kBAQTA,SAAK,KAAK,IAAI,UAAe,YAAuC;CACtE,IAAI,SAAS,yBAAyB,KAAA,GACpC,MAAM,IAAI,MACR,gBAAgB,SAAS,WAAW,sDACtC;CAEF,OAAO,aAAa,oBAAoB,QAAQ,GAAG,eAAe,SAAS,aAAa,OAAO,CAAC;AAClG,CAAC;;AAGD,MAAa,iBAQTA,SAAK,KAAK,IAAI,UAAe,WAC/B,gBAAgB,UAAU,CAAC,MAAM,CAAU,CAC7C;;AAGA,MAAa,oBAGTA,SAAK,KACP,IACC,UAAgC,YAC/B,aAAa,oBAAoB,QAAQ,GAAG,SAAS,aAAa,OAAO,CAC7E"}
|
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
import { OAuth2TokenRefresher_d_exports, Service } from "./OAuth2TokenRefresher.js";
|
|
2
|
+
import { Binding, BindingFor, BindingForMethod, Context, MatchCases, isBindingForMethod, makeBinding } from "./AuthMethodBinding.js";
|
|
3
|
+
import { decodeInput, decodeMaterial, decodeSetup, decodeValue, display, prepare, prepareDecoded, prepareOAuth2Tokens, prepareUnknown, refreshDecoded, refreshUnknown, resolve, resolveDecoded, resolveUnknown, test } from "./AuthMethodExecution.js";
|
|
4
|
+
import { Config, Effect, Pipeable, Schema } from "effect";
|
|
5
|
+
import * as Types from "effect/Types";
|
|
6
|
+
declare namespace AuthMethod_d_exports {
|
|
7
|
+
export { Any, AuthMethod, AuthMethodHookError, AuthMethodHookOperation, AuthMethodKind, AuthMethodOptions, AuthOptionsWithMaterial, AuthOptionsWithoutMaterial, Binding, BindingFor, BindingForMethod, Context, Display, DisplayHook, ExpectedOAuth2MethodError, FormOptions, HookContext, Input, InputSchema, MatchCases, Material, MaterialSchema, MaybeEffect, OAuth2Client, OAuth2ClientConfig, OAuth2ClientHook, OAuth2Endpoint, OAuth2EndpointHook, OAuth2Headers, OAuth2HeadersHook, OAuth2Options, OAuth2Params, OAuth2ParamsHook, OAuth2ProviderTokenResponse, OAuth2RefreshTokenUnavailableError, OAuth2Setup, OAuth2TokenMaterial, OAuth2TokenRefresher_d_exports as OAuth2TokenRefresher, OAuth2TokenResponse, PrepareHook, RefreshContext, RefreshHook, RefreshReason, Requirements, RequirementsVariance, ResolveHook, SchemaType, Service, Setup, SetupSchema, TestHook, TestResult, TypeId, Value, ValueSchema, auth, decodeInput, decodeMaterial, decodeSetup, decodeValue, display, form, isAuthMethod, isBindingForMethod, make, makeBinding, oauth2, prepare, prepareDecoded, prepareOAuth2Tokens, prepareUnknown, refreshDecoded, refreshUnknown, resolve, resolveDecoded, resolveUnknown, test };
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* @since 0.0.0
|
|
11
|
+
* @category type ids
|
|
12
|
+
*/
|
|
13
|
+
export declare const TypeId: "@dual-os/sdk/AuthMethod";
|
|
14
|
+
/**
|
|
15
|
+
* @since 0.0.0
|
|
16
|
+
* @category type ids
|
|
17
|
+
*/
|
|
18
|
+
export type TypeId = typeof TypeId;
|
|
19
|
+
/**
|
|
20
|
+
* Phantom inference slot for the hook requirements union.
|
|
21
|
+
*
|
|
22
|
+
* Unlike the schema parameters, hook requirements only occur inside optional
|
|
23
|
+
* hook signatures, which TypeScript cannot reliably infer through; this slot
|
|
24
|
+
* gives the {@link Requirements} extractor a stable inference site.
|
|
25
|
+
*
|
|
26
|
+
* One union instead of per-hook parameters on purpose: in practice a method's
|
|
27
|
+
* dependencies are provided once at the plugin/app definition (for example a
|
|
28
|
+
* Gmail client layer), not separately per hook, and every consumption path
|
|
29
|
+
* (invoke, trigger phases, credential lifecycle, `DualRuntime.toLayer`) must demand
|
|
30
|
+
* the same set so none of them can silently under-require.
|
|
31
|
+
*
|
|
32
|
+
* @since 0.0.0
|
|
33
|
+
* @category models
|
|
34
|
+
*/
|
|
35
|
+
export interface RequirementsVariance<out Requirements> {
|
|
36
|
+
readonly _Requirements: Types.Covariant<Requirements>;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Constraint type for working with any {@link AuthMethod}.
|
|
40
|
+
*
|
|
41
|
+
* @since 0.0.0
|
|
42
|
+
* @category type-level
|
|
43
|
+
*/
|
|
44
|
+
export interface Any extends Pipeable.Pipeable {
|
|
45
|
+
readonly [TypeId]: RequirementsVariance<any>;
|
|
46
|
+
readonly identifier: string;
|
|
47
|
+
readonly name: string | undefined;
|
|
48
|
+
readonly description: string | undefined;
|
|
49
|
+
readonly kind: AuthMethodKind;
|
|
50
|
+
readonly setup: Schema.Top | undefined;
|
|
51
|
+
readonly input: Schema.Top | undefined;
|
|
52
|
+
readonly material: Schema.Top;
|
|
53
|
+
readonly value: Schema.Top;
|
|
54
|
+
readonly schema: Schema.Top;
|
|
55
|
+
readonly prepare: unknown;
|
|
56
|
+
readonly refresh: unknown;
|
|
57
|
+
readonly resolve: unknown;
|
|
58
|
+
readonly display: unknown;
|
|
59
|
+
readonly test: unknown;
|
|
60
|
+
readonly oauth2: OAuth2Setup<Schema.Top, any, any> | undefined;
|
|
61
|
+
}
|
|
62
|
+
/** @since 0.0.0 @category models */
|
|
63
|
+
export type AuthMethodKind = "form" | "oauth2" | "custom";
|
|
64
|
+
/** @since 0.0.0 @category type-level */
|
|
65
|
+
export type SchemaType<SchemaDef extends Schema.Top | undefined> = SchemaDef extends Schema.Top ? Schema.Schema.Type<SchemaDef> : undefined;
|
|
66
|
+
/** @since 0.0.0 @category hooks */
|
|
67
|
+
export interface HookContext<Setup = undefined> {
|
|
68
|
+
readonly setup: Setup;
|
|
69
|
+
}
|
|
70
|
+
/** @since 0.0.0 @category hooks */
|
|
71
|
+
export type MaybeEffect<Value, Error = never, Requirements = never> = Value | Effect.Effect<Value, Error, Requirements>;
|
|
72
|
+
/** @since 0.0.0 @category hooks */
|
|
73
|
+
export type PrepareHook<Input, Material, Error = never, Requirements = never, Setup = undefined> = (input: Input, context: HookContext<Setup>) => MaybeEffect<Material, Error, Requirements>;
|
|
74
|
+
/** @since 0.0.0 @category hooks */
|
|
75
|
+
export type RefreshReason = "before-use" | "forced";
|
|
76
|
+
/** @since 0.0.0 @category hooks */
|
|
77
|
+
export interface RefreshContext<Setup = undefined> extends HookContext<Setup> {
|
|
78
|
+
readonly now: number;
|
|
79
|
+
readonly minValidityMs: number;
|
|
80
|
+
readonly reason: RefreshReason;
|
|
81
|
+
}
|
|
82
|
+
/** @since 0.0.0 @category hooks */
|
|
83
|
+
export type RefreshHook<Material, Error = never, Requirements = never, Setup = undefined> = (material: Material, context: RefreshContext<Setup>) => MaybeEffect<Material | undefined, Error, Requirements>;
|
|
84
|
+
/** @since 0.0.0 @category hooks */
|
|
85
|
+
export type ResolveHook<Material, Value, Error = never, Requirements = never, Setup = undefined> = (material: Material, context: HookContext<Setup>) => MaybeEffect<Value, Error, Requirements>;
|
|
86
|
+
/** @since 0.0.0 @category models */
|
|
87
|
+
export interface Display {
|
|
88
|
+
readonly label?: string;
|
|
89
|
+
readonly description?: string;
|
|
90
|
+
readonly metadata?: Record<string, unknown>;
|
|
91
|
+
}
|
|
92
|
+
/** @since 0.0.0 @category hooks */
|
|
93
|
+
export type DisplayHook<Material, Error = never, Requirements = never, Setup = undefined> = (material: Material, context: HookContext<Setup>) => MaybeEffect<Display, Error, Requirements>;
|
|
94
|
+
/** @since 0.0.0 @category models */
|
|
95
|
+
export interface TestResult {
|
|
96
|
+
readonly ok: boolean;
|
|
97
|
+
readonly message?: string;
|
|
98
|
+
}
|
|
99
|
+
declare const ExpectedOAuth2MethodError_base: Schema.Class<ExpectedOAuth2MethodError, Schema.TaggedStruct<"ExpectedOAuth2MethodError", {
|
|
100
|
+
readonly methodIdentifier: Schema.String;
|
|
101
|
+
}>, import("effect/Cause").YieldableError>;
|
|
102
|
+
/** @since 0.0.0 @category errors */
|
|
103
|
+
export declare class ExpectedOAuth2MethodError extends ExpectedOAuth2MethodError_base {}
|
|
104
|
+
/** @since 0.0.0 @category hooks */
|
|
105
|
+
export type TestHook<Material, Error = never, Requirements = never, Setup = undefined> = (material: Material, context: HookContext<Setup>) => MaybeEffect<TestResult, Error, Requirements>;
|
|
106
|
+
/**
|
|
107
|
+
* Options used to create an {@link AuthMethod}.
|
|
108
|
+
*
|
|
109
|
+
* @since 0.0.0
|
|
110
|
+
* @category models
|
|
111
|
+
*/
|
|
112
|
+
export interface AuthMethodOptions<ValueSchema extends Schema.Top> {
|
|
113
|
+
readonly name?: string;
|
|
114
|
+
readonly description?: string;
|
|
115
|
+
readonly schema: ValueSchema;
|
|
116
|
+
}
|
|
117
|
+
/** @since 0.0.0 @category models */
|
|
118
|
+
export interface FormOptions<ValueSchema extends Schema.Top, SetupSchema extends Schema.Top | undefined = undefined> extends AuthMethodOptions<ValueSchema> {
|
|
119
|
+
readonly setup?: SetupSchema;
|
|
120
|
+
}
|
|
121
|
+
/** @since 0.0.0 @category models */
|
|
122
|
+
export interface AuthOptionsWithoutMaterial<InputSchema extends Schema.Top, ValueSchema extends Schema.Top = InputSchema, SetupSchema extends Schema.Top | undefined = undefined, PrepareRequirements = never, RefreshRequirements = never, ResolveRequirements = never, DisplayRequirements = never, TestRequirements = never> {
|
|
123
|
+
readonly name?: string;
|
|
124
|
+
readonly description?: string;
|
|
125
|
+
readonly setup?: SetupSchema;
|
|
126
|
+
readonly input: InputSchema;
|
|
127
|
+
readonly material?: undefined;
|
|
128
|
+
readonly value?: ValueSchema;
|
|
129
|
+
readonly prepare?: PrepareHook<SchemaType<InputSchema>, SchemaType<InputSchema>, any, PrepareRequirements, SchemaType<SetupSchema>>;
|
|
130
|
+
readonly refresh?: RefreshHook<SchemaType<InputSchema>, any, RefreshRequirements, SchemaType<SetupSchema>>;
|
|
131
|
+
readonly resolve?: ResolveHook<SchemaType<InputSchema>, Schema.Schema.Type<ValueSchema>, any, ResolveRequirements, SchemaType<SetupSchema>>;
|
|
132
|
+
readonly display?: DisplayHook<SchemaType<InputSchema>, any, DisplayRequirements, SchemaType<SetupSchema>>;
|
|
133
|
+
readonly test?: TestHook<SchemaType<InputSchema>, any, TestRequirements, SchemaType<SetupSchema>>;
|
|
134
|
+
}
|
|
135
|
+
/** @since 0.0.0 @category models */
|
|
136
|
+
export interface AuthOptionsWithMaterial<InputSchema extends Schema.Top | undefined, MaterialSchema extends Schema.Top, ValueSchema extends Schema.Top = MaterialSchema, SetupSchema extends Schema.Top | undefined = undefined, PrepareRequirements = never, RefreshRequirements = never, ResolveRequirements = never, DisplayRequirements = never, TestRequirements = never> {
|
|
137
|
+
readonly name?: string;
|
|
138
|
+
readonly description?: string;
|
|
139
|
+
readonly setup?: SetupSchema;
|
|
140
|
+
readonly input: InputSchema;
|
|
141
|
+
readonly material: MaterialSchema;
|
|
142
|
+
readonly value?: ValueSchema;
|
|
143
|
+
readonly prepare?: PrepareHook<SchemaType<InputSchema>, Schema.Schema.Type<MaterialSchema>, any, PrepareRequirements, SchemaType<SetupSchema>>;
|
|
144
|
+
readonly refresh?: RefreshHook<Schema.Schema.Type<MaterialSchema>, any, RefreshRequirements, SchemaType<SetupSchema>>;
|
|
145
|
+
readonly resolve?: ResolveHook<Schema.Schema.Type<MaterialSchema>, Schema.Schema.Type<ValueSchema>, any, ResolveRequirements, SchemaType<SetupSchema>>;
|
|
146
|
+
readonly display?: DisplayHook<Schema.Schema.Type<MaterialSchema>, any, DisplayRequirements, SchemaType<SetupSchema>>;
|
|
147
|
+
readonly test?: TestHook<Schema.Schema.Type<MaterialSchema>, any, TestRequirements, SchemaType<SetupSchema>>;
|
|
148
|
+
}
|
|
149
|
+
/** @since 0.0.0 @category models */
|
|
150
|
+
export interface OAuth2ClientConfig {
|
|
151
|
+
readonly clientId: string | Config.Config<string>;
|
|
152
|
+
readonly clientSecret?: string | Config.Config<string>;
|
|
153
|
+
readonly authentication?: "basic" | "post" | "none";
|
|
154
|
+
}
|
|
155
|
+
/** @since 0.0.0 @category hooks */
|
|
156
|
+
export type OAuth2ClientHook<Setup> = (context: HookContext<Setup>) => OAuth2ClientConfig;
|
|
157
|
+
/** @since 0.0.0 @category models */
|
|
158
|
+
export type OAuth2Client<Setup = undefined> = OAuth2ClientConfig | OAuth2ClientHook<Setup>;
|
|
159
|
+
/** @since 0.0.0 @category hooks */
|
|
160
|
+
export type OAuth2EndpointHook<Setup> = (context: HookContext<Setup>) => string;
|
|
161
|
+
/**
|
|
162
|
+
* An OAuth2 endpoint, fixed or derived from the setup.
|
|
163
|
+
*
|
|
164
|
+
* Providers that host one instance per customer — a Microsoft tenant, a
|
|
165
|
+
* self-hosted GitLab — cannot name their endpoints until the connection's setup
|
|
166
|
+
* says which instance it is.
|
|
167
|
+
*
|
|
168
|
+
* @since 0.0.0
|
|
169
|
+
* @category models
|
|
170
|
+
*/
|
|
171
|
+
export type OAuth2Endpoint<Setup = undefined> = string | OAuth2EndpointHook<Setup>;
|
|
172
|
+
/** @since 0.0.0 @category models */
|
|
173
|
+
export type OAuth2ParamsHook<Setup> = (context: HookContext<Setup>) => Readonly<Record<string, string>>;
|
|
174
|
+
/**
|
|
175
|
+
* Query parameters added to the authorization or token request, fixed or
|
|
176
|
+
* derived from the setup — the same freedom the endpoints have. A provider
|
|
177
|
+
* that knows which account a connection is for can say so in the request
|
|
178
|
+
* instead of leaving the choice to whatever session the browser carries.
|
|
179
|
+
*
|
|
180
|
+
* @since 0.0.0 @category models
|
|
181
|
+
*/
|
|
182
|
+
export type OAuth2Params<Setup = undefined> = Readonly<Record<string, string>> | OAuth2ParamsHook<Setup>;
|
|
183
|
+
/** @since 0.0.0 @category hooks */
|
|
184
|
+
export type OAuth2HeadersHook<SetupValue> = (context: HookContext<SetupValue>) => Readonly<Record<string, string>>;
|
|
185
|
+
/**
|
|
186
|
+
* Provider headers for token exchange and refresh, fixed or derived from setup.
|
|
187
|
+
* Hosts must reject invalid headers and case-insensitive overrides of client
|
|
188
|
+
* authentication and transport headers. Keep values out of authorization URLs,
|
|
189
|
+
* public metadata, logs, and errors.
|
|
190
|
+
*
|
|
191
|
+
* @since 0.0.0 @category models
|
|
192
|
+
*/
|
|
193
|
+
export type OAuth2Headers<SetupValue = HookContext["setup"]> = Readonly<Record<string, string>> | OAuth2HeadersHook<SetupValue>;
|
|
194
|
+
/** @since 0.0.0 @category schemas */
|
|
195
|
+
export declare const OAuth2ProviderTokenResponse: Schema.Struct<{
|
|
196
|
+
readonly access_token: Schema.optional<Schema.String>;
|
|
197
|
+
readonly expires_at: Schema.optional<Schema.String>;
|
|
198
|
+
readonly expires_in: Schema.optional<Schema.Union<readonly [Schema.Number, Schema.String]>>;
|
|
199
|
+
readonly refresh_token: Schema.optional<Schema.String>;
|
|
200
|
+
readonly scope: Schema.optional<Schema.String>;
|
|
201
|
+
readonly token_type: Schema.optional<Schema.String>;
|
|
202
|
+
}>;
|
|
203
|
+
/** @since 0.0.0 @category models */
|
|
204
|
+
export type OAuth2ProviderTokenResponse = typeof OAuth2ProviderTokenResponse.Type;
|
|
205
|
+
/** @since 0.0.0 @category schemas */
|
|
206
|
+
export declare const OAuth2TokenResponse: Schema.Struct<{
|
|
207
|
+
readonly accessToken: Schema.String;
|
|
208
|
+
readonly expiresAt: Schema.optional<Schema.Number>;
|
|
209
|
+
readonly expiresIn: Schema.optional<Schema.Number>;
|
|
210
|
+
readonly raw: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
211
|
+
readonly refreshToken: Schema.optional<Schema.String>;
|
|
212
|
+
readonly scope: Schema.optional<Schema.String>;
|
|
213
|
+
readonly tokenType: Schema.optional<Schema.String>;
|
|
214
|
+
}>;
|
|
215
|
+
/** @since 0.0.0 @category models */
|
|
216
|
+
export type OAuth2TokenResponse = typeof OAuth2TokenResponse.Type;
|
|
217
|
+
declare const OAuth2RefreshTokenUnavailableError_base: Schema.Class<OAuth2RefreshTokenUnavailableError, Schema.TaggedStruct<"OAuth2RefreshTokenUnavailableError", {
|
|
218
|
+
readonly methodIdentifier: Schema.String;
|
|
219
|
+
}>, import("effect/Cause").YieldableError>;
|
|
220
|
+
/** @since 0.0.0 @category errors */
|
|
221
|
+
export declare class OAuth2RefreshTokenUnavailableError extends OAuth2RefreshTokenUnavailableError_base {}
|
|
222
|
+
/** @since 0.0.0 @category errors */
|
|
223
|
+
export declare const AuthMethodHookOperation: Schema.Literals<readonly ["prepare", "refresh", "prepareOAuth2Tokens", "resolve", "display", "test", "oauth2TokenRefresh"]>;
|
|
224
|
+
/** @since 0.0.0 @category errors */
|
|
225
|
+
export type AuthMethodHookOperation = typeof AuthMethodHookOperation.Type;
|
|
226
|
+
declare const AuthMethodHookError_base: Schema.Class<AuthMethodHookError, Schema.TaggedStruct<"AuthMethodHookError", {
|
|
227
|
+
readonly cause: Schema.Defect;
|
|
228
|
+
readonly methodIdentifier: Schema.String;
|
|
229
|
+
readonly operation: Schema.Literals<readonly ["prepare", "refresh", "prepareOAuth2Tokens", "resolve", "display", "test", "oauth2TokenRefresh"]>;
|
|
230
|
+
}>, import("effect/Cause").YieldableError>;
|
|
231
|
+
/** @since 0.0.0 @category errors */
|
|
232
|
+
export declare class AuthMethodHookError extends AuthMethodHookError_base {}
|
|
233
|
+
/** @since 0.0.0 @category schemas */
|
|
234
|
+
export declare const OAuth2TokenMaterial: Schema.Struct<{
|
|
235
|
+
readonly accessToken: Schema.String;
|
|
236
|
+
readonly expiresAt: Schema.optional<Schema.Number>;
|
|
237
|
+
readonly expiresIn: Schema.optional<Schema.Number>;
|
|
238
|
+
readonly raw: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
|
|
239
|
+
readonly refreshToken: Schema.optional<Schema.String>;
|
|
240
|
+
readonly scope: Schema.optional<Schema.String>;
|
|
241
|
+
readonly tokenType: Schema.optional<Schema.String>;
|
|
242
|
+
}>;
|
|
243
|
+
/** @since 0.0.0 @category models */
|
|
244
|
+
export interface OAuth2Setup<MaterialSchema extends Schema.Top, Setup = undefined, TokenRequirements = never> {
|
|
245
|
+
readonly scopes: readonly string[];
|
|
246
|
+
readonly client: OAuth2Client<Setup>;
|
|
247
|
+
readonly discoveryUrl?: OAuth2Endpoint<Setup>;
|
|
248
|
+
readonly authorizationUrl?: OAuth2Endpoint<Setup>;
|
|
249
|
+
readonly tokenUrl?: OAuth2Endpoint<Setup>;
|
|
250
|
+
readonly pkce?: boolean;
|
|
251
|
+
readonly authorizationParams?: OAuth2Params<Setup>;
|
|
252
|
+
readonly tokenParams?: OAuth2Params<Setup>;
|
|
253
|
+
readonly tokenHeaders?: OAuth2Headers<Setup>;
|
|
254
|
+
/** Token request body encoding. Standard OAuth2 methods use form encoding. */
|
|
255
|
+
readonly tokenRequestEncoding?: "form" | "json";
|
|
256
|
+
/** Decode a provider response into the standard token fields before host normalization. */
|
|
257
|
+
readonly tokenResponse?: Schema.Decoder<OAuth2ProviderTokenResponse>;
|
|
258
|
+
readonly fromTokens?: PrepareHook<OAuth2TokenResponse, Schema.Schema.Type<MaterialSchema>, any, TokenRequirements, Setup>;
|
|
259
|
+
}
|
|
260
|
+
/** @since 0.0.0 @category models */
|
|
261
|
+
export interface OAuth2Options<MaterialSchema extends Schema.Top, ValueSchema extends Schema.Top = MaterialSchema, SetupSchema extends Schema.Top | undefined = undefined, TokenRequirements = never, ResolveRequirements = never, DisplayRequirements = never, TestRequirements = never> extends OAuth2Setup<MaterialSchema, SchemaType<SetupSchema>, TokenRequirements> {
|
|
262
|
+
readonly name?: string;
|
|
263
|
+
readonly description?: string;
|
|
264
|
+
readonly setup?: SetupSchema;
|
|
265
|
+
readonly material: MaterialSchema;
|
|
266
|
+
readonly value?: ValueSchema;
|
|
267
|
+
readonly fromTokens?: PrepareHook<OAuth2TokenResponse, Schema.Schema.Type<MaterialSchema>, any, TokenRequirements, SchemaType<SetupSchema>>;
|
|
268
|
+
readonly resolve?: ResolveHook<Schema.Schema.Type<MaterialSchema>, Schema.Schema.Type<ValueSchema>, any, ResolveRequirements, SchemaType<SetupSchema>>;
|
|
269
|
+
readonly display?: DisplayHook<Schema.Schema.Type<MaterialSchema>, any, DisplayRequirements, SchemaType<SetupSchema>>;
|
|
270
|
+
readonly test?: TestHook<Schema.Schema.Type<MaterialSchema>, any, TestRequirements, SchemaType<SetupSchema>>;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* A typed provider-owned auth method definition.
|
|
274
|
+
*
|
|
275
|
+
* @since 0.0.0
|
|
276
|
+
* @category models
|
|
277
|
+
*/
|
|
278
|
+
export interface AuthMethod<out Identifier extends string = string, out SetupSchema extends Schema.Top | undefined = Schema.Top | undefined, out InputSchema extends Schema.Top | undefined = Schema.Top | undefined, out MaterialSchema extends Schema.Top = Schema.Top, out ValueSchema extends Schema.Top = Schema.Top, out Requirements = never> extends Pipeable.Pipeable {
|
|
279
|
+
readonly [TypeId]: RequirementsVariance<Requirements>;
|
|
280
|
+
readonly identifier: Identifier;
|
|
281
|
+
readonly name: string | undefined;
|
|
282
|
+
readonly description: string | undefined;
|
|
283
|
+
readonly kind: AuthMethodKind;
|
|
284
|
+
readonly setup: SetupSchema;
|
|
285
|
+
readonly input: InputSchema;
|
|
286
|
+
readonly material: MaterialSchema;
|
|
287
|
+
readonly value: ValueSchema;
|
|
288
|
+
/** Runtime value schema retained for concise action/trigger typing. */
|
|
289
|
+
readonly schema: ValueSchema;
|
|
290
|
+
readonly prepare: PrepareHook<SchemaType<InputSchema>, Schema.Schema.Type<MaterialSchema>, any, Requirements, SchemaType<SetupSchema>> | undefined;
|
|
291
|
+
readonly refresh: RefreshHook<Schema.Schema.Type<MaterialSchema>, any, Requirements, SchemaType<SetupSchema>> | undefined;
|
|
292
|
+
readonly resolve: ResolveHook<Schema.Schema.Type<MaterialSchema>, Schema.Schema.Type<ValueSchema>, any, Requirements, SchemaType<SetupSchema>> | undefined;
|
|
293
|
+
readonly display: DisplayHook<Schema.Schema.Type<MaterialSchema>, any, Requirements, SchemaType<SetupSchema>> | undefined;
|
|
294
|
+
readonly test: TestHook<Schema.Schema.Type<MaterialSchema>, any, Requirements, SchemaType<SetupSchema>> | undefined;
|
|
295
|
+
readonly oauth2: OAuth2Setup<MaterialSchema, SchemaType<SetupSchema>, Requirements> | undefined;
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Create an {@link AuthMethod} definition.
|
|
299
|
+
*
|
|
300
|
+
* @since 0.0.0
|
|
301
|
+
* @category constructors
|
|
302
|
+
*/
|
|
303
|
+
export declare const make: <const Identifier extends string, ValueSchema extends Schema.Top, SetupSchema extends Schema.Top | undefined = undefined>(identifier: Identifier, options: FormOptions<ValueSchema, SetupSchema>) => AuthMethod<Identifier, SetupSchema, ValueSchema, ValueSchema, ValueSchema>;
|
|
304
|
+
/**
|
|
305
|
+
* Create a simple form auth method where input, stored material, and runtime value share one schema.
|
|
306
|
+
*
|
|
307
|
+
* @since 0.0.0
|
|
308
|
+
* @category constructors
|
|
309
|
+
*/
|
|
310
|
+
export declare const form: <const Identifier extends string, ValueSchema extends Schema.Top, SetupSchema extends Schema.Top | undefined = undefined>(identifier: Identifier, options: FormOptions<ValueSchema, SetupSchema>) => AuthMethod<Identifier, SetupSchema, ValueSchema, ValueSchema, ValueSchema>;
|
|
311
|
+
/**
|
|
312
|
+
* Create a custom auth setup method.
|
|
313
|
+
*
|
|
314
|
+
* @since 0.0.0
|
|
315
|
+
* @category constructors
|
|
316
|
+
*/
|
|
317
|
+
export declare function auth<const Identifier extends string, InputSchema extends Schema.Top, ValueSchema extends Schema.Top = InputSchema, SetupSchema extends Schema.Top | undefined = undefined, PrepareRequirements = never, RefreshRequirements = never, ResolveRequirements = never, DisplayRequirements = never, TestRequirements = never>(identifier: Identifier, options: AuthOptionsWithoutMaterial<InputSchema, ValueSchema, SetupSchema, PrepareRequirements, RefreshRequirements, ResolveRequirements, DisplayRequirements, TestRequirements>): AuthMethod<Identifier, SetupSchema, InputSchema, InputSchema, ValueSchema, PrepareRequirements | RefreshRequirements | ResolveRequirements | DisplayRequirements | TestRequirements>;
|
|
318
|
+
export declare function auth<const Identifier extends string, InputSchema extends Schema.Top | undefined, MaterialSchema extends Schema.Top, ValueSchema extends Schema.Top = MaterialSchema, SetupSchema extends Schema.Top | undefined = undefined, PrepareRequirements = never, RefreshRequirements = never, ResolveRequirements = never, DisplayRequirements = never, TestRequirements = never>(identifier: Identifier, options: AuthOptionsWithMaterial<InputSchema, MaterialSchema, ValueSchema, SetupSchema, PrepareRequirements, RefreshRequirements, ResolveRequirements, DisplayRequirements, TestRequirements>): AuthMethod<Identifier, SetupSchema, InputSchema, MaterialSchema, ValueSchema, PrepareRequirements | RefreshRequirements | ResolveRequirements | DisplayRequirements | TestRequirements>;
|
|
319
|
+
/**
|
|
320
|
+
* Create an OAuth2 auth method over the same setup primitive.
|
|
321
|
+
*
|
|
322
|
+
* OAuth2 has no submitted form input; the platform owns the browser redirect,
|
|
323
|
+
* callback, state/PKCE, and token exchange before storing mapped material.
|
|
324
|
+
*
|
|
325
|
+
* @since 0.0.0
|
|
326
|
+
* @category constructors
|
|
327
|
+
*/
|
|
328
|
+
export declare const oauth2: <const Identifier extends string, MaterialSchema extends Schema.Top, ValueSchema extends Schema.Top = MaterialSchema, SetupSchema extends Schema.Top | undefined = undefined, TokenRequirements = never, ResolveRequirements = never, DisplayRequirements = never, TestRequirements = never>(identifier: Identifier, options: OAuth2Options<MaterialSchema, ValueSchema, SetupSchema, TokenRequirements, ResolveRequirements, DisplayRequirements, TestRequirements>) => AuthMethod<Identifier, SetupSchema, undefined, MaterialSchema, ValueSchema, Service | Schema.Codec.DecodingServices<MaterialSchema> | TokenRequirements | ResolveRequirements | DisplayRequirements | TestRequirements>;
|
|
329
|
+
/**
|
|
330
|
+
* Check if a value is an {@link AuthMethod}.
|
|
331
|
+
*
|
|
332
|
+
* @since 0.0.0
|
|
333
|
+
* @category guards
|
|
334
|
+
*/
|
|
335
|
+
export declare const isAuthMethod: (u: unknown) => u is Any;
|
|
336
|
+
/**
|
|
337
|
+
* Resolved value type carried by a {@link AuthMethod}.
|
|
338
|
+
*
|
|
339
|
+
* @since 0.0.0
|
|
340
|
+
* @category type-level
|
|
341
|
+
*/
|
|
342
|
+
export type Value<Method extends Any> = Schema.Schema.Type<ValueSchema<Method>>;
|
|
343
|
+
/** @since 0.0.0 @category type-level */
|
|
344
|
+
export type Setup<Method extends Any> = SchemaType<SetupSchema<Method>>;
|
|
345
|
+
/**
|
|
346
|
+
* Submitted setup input type carried by an {@link AuthMethod}.
|
|
347
|
+
*
|
|
348
|
+
* @since 0.0.0
|
|
349
|
+
* @category type-level
|
|
350
|
+
*/
|
|
351
|
+
export type Input<Method extends Any> = SchemaType<InputSchema<Method>>;
|
|
352
|
+
/**
|
|
353
|
+
* Encrypted stored material type carried by an {@link AuthMethod}.
|
|
354
|
+
*
|
|
355
|
+
* @since 0.0.0
|
|
356
|
+
* @category type-level
|
|
357
|
+
*/
|
|
358
|
+
export type Material<Method extends Any> = Schema.Schema.Type<MaterialSchema<Method>>;
|
|
359
|
+
/**
|
|
360
|
+
* Schema type carried by a {@link AuthMethod}.
|
|
361
|
+
*
|
|
362
|
+
* @since 0.0.0
|
|
363
|
+
* @category type-level
|
|
364
|
+
*/
|
|
365
|
+
export type ValueSchema<Method extends Any> = Method["value"];
|
|
366
|
+
/** @since 0.0.0 @category type-level */
|
|
367
|
+
export type SetupSchema<Method extends Any> = Method["setup"];
|
|
368
|
+
/** @since 0.0.0 @category type-level */
|
|
369
|
+
export type InputSchema<Method extends Any> = Method["input"];
|
|
370
|
+
/** @since 0.0.0 @category type-level */
|
|
371
|
+
export type MaterialSchema<Method extends Any> = Method["material"];
|
|
372
|
+
/**
|
|
373
|
+
* Services required by the method's hooks, as one union.
|
|
374
|
+
*
|
|
375
|
+
* @since 0.0.0
|
|
376
|
+
* @category type-level
|
|
377
|
+
*/
|
|
378
|
+
export type Requirements<Method extends Any> = Types.Covariant.Type<Method[TypeId]["_Requirements"]>;
|
|
379
|
+
//#endregion
|
|
380
|
+
export { AuthMethod_d_exports, type Binding, type BindingFor, type BindingForMethod, type Context, type MatchCases, OAuth2TokenRefresher_d_exports as OAuth2TokenRefresher, Service, decodeInput, decodeMaterial, decodeSetup, decodeValue, display, isBindingForMethod, makeBinding, prepare, prepareDecoded, prepareOAuth2Tokens, prepareUnknown, refreshDecoded, refreshUnknown, resolve, resolveDecoded, resolveUnknown, test };
|
|
381
|
+
//# sourceMappingURL=AuthMethod.d.ts.map
|