@executor-js/plugin-openapi 0.0.1-beta.6 → 0.0.2
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/README.md +24 -23
- package/dist/api/group.d.ts +94 -37
- package/dist/api/handlers.d.ts +2 -2
- package/dist/chunk-ZZ7TQ4JC.js +2602 -0
- package/dist/chunk-ZZ7TQ4JC.js.map +1 -0
- package/dist/core.js +46 -50
- package/dist/core.js.map +1 -1
- package/dist/index.js +2 -5
- package/dist/index.js.map +1 -1
- package/dist/react/AddOpenApiSource.d.ts +13 -0
- package/dist/react/EditOpenApiSource.d.ts +2 -2
- package/dist/react/OpenApiSourceSummary.d.ts +3 -1
- package/dist/react/atoms.d.ts +129 -0
- package/dist/react/client.d.ts +421 -3
- package/dist/react/source-plugin.d.ts +1 -1
- package/dist/sdk/client-credentials-oauth.test.d.ts +1 -0
- package/dist/sdk/credential-status.d.ts +23 -0
- package/dist/sdk/credential-status.test.d.ts +1 -0
- package/dist/sdk/errors.d.ts +11 -10
- package/dist/sdk/form-urlencoded-body.test.d.ts +1 -0
- package/dist/sdk/index.d.ts +8 -10
- package/dist/sdk/invoke.d.ts +8 -17
- package/dist/sdk/multi-scope-bearer.test.d.ts +1 -0
- package/dist/sdk/multi-scope-oauth.test.d.ts +1 -0
- package/dist/sdk/non-json-body.test.d.ts +1 -0
- package/dist/sdk/oauth-refresh.test.d.ts +1 -0
- package/dist/sdk/openapi-utils.d.ts +35 -4
- package/dist/sdk/parse.d.ts +28 -4
- package/dist/sdk/plugin.d.ts +169 -22
- package/dist/sdk/preview-oauth2.test.d.ts +1 -0
- package/dist/sdk/preview.d.ts +89 -125
- package/dist/sdk/store.d.ts +201 -0
- package/dist/sdk/types.d.ts +234 -266
- package/package.json +11 -22
- package/dist/chunk-V3D5A6HA.js +0 -1224
- package/dist/chunk-V3D5A6HA.js.map +0 -1
- package/dist/promise.d.ts +0 -6
- package/dist/sdk/config-file-store.d.ts +0 -10
- package/dist/sdk/kv-operation-store.d.ts +0 -4
- package/dist/sdk/operation-store.d.ts +0 -35
- package/dist/sdk/stored-source.d.ts +0 -46
package/README.md
CHANGED
|
@@ -1,39 +1,36 @@
|
|
|
1
|
-
# @executor/plugin-openapi
|
|
1
|
+
# @executor-js/plugin-openapi
|
|
2
2
|
|
|
3
3
|
Load [OpenAPI](https://www.openapis.org/) specifications into an executor. Every operation in the spec becomes an invokable tool with a JSON-Schema input, automatic request building, and optional secret-backed auth.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
7
7
|
```sh
|
|
8
|
-
bun add @executor/sdk @executor/plugin-openapi
|
|
8
|
+
bun add @executor-js/sdk @executor-js/plugin-openapi
|
|
9
9
|
# or
|
|
10
|
-
npm install @executor/sdk @executor/plugin-openapi
|
|
10
|
+
npm install @executor-js/sdk @executor-js/plugin-openapi
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
## Usage
|
|
14
14
|
|
|
15
15
|
```ts
|
|
16
|
-
import { createExecutor } from "@executor/sdk";
|
|
17
|
-
import { openApiPlugin } from "@executor/plugin-openapi";
|
|
16
|
+
import { createExecutor } from "@executor-js/sdk";
|
|
17
|
+
import { openApiPlugin } from "@executor-js/plugin-openapi";
|
|
18
18
|
|
|
19
19
|
const executor = await createExecutor({
|
|
20
|
-
|
|
20
|
+
onElicitation: "accept-all",
|
|
21
21
|
plugins: [openApiPlugin()] as const,
|
|
22
22
|
});
|
|
23
23
|
|
|
24
24
|
// Load a spec by URL (JSON or YAML, remote or file://)
|
|
25
25
|
await executor.openapi.addSpec({
|
|
26
|
+
scope: executor.scopes[0]!.id,
|
|
26
27
|
spec: "https://petstore3.swagger.io/api/v3/openapi.json",
|
|
27
28
|
namespace: "petstore",
|
|
28
29
|
});
|
|
29
30
|
|
|
30
31
|
// List and invoke tools like any other plugin
|
|
31
32
|
const tools = await executor.tools.list();
|
|
32
|
-
const result = await executor.tools.invoke(
|
|
33
|
-
"petstore.listPets",
|
|
34
|
-
{},
|
|
35
|
-
{ onElicitation: "accept-all" },
|
|
36
|
-
);
|
|
33
|
+
const result = await executor.tools.invoke("petstore.listPets", {});
|
|
37
34
|
```
|
|
38
35
|
|
|
39
36
|
## Secret-backed auth headers
|
|
@@ -41,14 +38,26 @@ const result = await executor.tools.invoke(
|
|
|
41
38
|
Wire API keys or bearer tokens through the executor's secret store — never hard-code them in source configs:
|
|
42
39
|
|
|
43
40
|
```ts
|
|
41
|
+
import { createExecutor } from "@executor-js/sdk";
|
|
42
|
+
import { openApiPlugin } from "@executor-js/plugin-openapi";
|
|
43
|
+
import { fileSecretsPlugin } from "@executor-js/plugin-file-secrets";
|
|
44
|
+
|
|
45
|
+
const executor = await createExecutor({
|
|
46
|
+
onElicitation: "accept-all",
|
|
47
|
+
plugins: [fileSecretsPlugin(), openApiPlugin()] as const,
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
const scope = executor.scopes[0]!.id;
|
|
51
|
+
|
|
44
52
|
await executor.secrets.set({
|
|
45
53
|
id: "stripe-key",
|
|
46
54
|
name: "Stripe Key",
|
|
47
55
|
value: "sk_live_...",
|
|
48
|
-
|
|
56
|
+
scope,
|
|
49
57
|
});
|
|
50
58
|
|
|
51
59
|
await executor.openapi.addSpec({
|
|
60
|
+
scope,
|
|
52
61
|
spec: "https://raw.githubusercontent.com/stripe/openapi/master/openapi/spec3.json",
|
|
53
62
|
namespace: "stripe",
|
|
54
63
|
headers: {
|
|
@@ -57,20 +66,12 @@ await executor.openapi.addSpec({
|
|
|
57
66
|
});
|
|
58
67
|
```
|
|
59
68
|
|
|
60
|
-
##
|
|
61
|
-
|
|
62
|
-
Common public APIs are available as presets from the `/presets` subpath:
|
|
63
|
-
|
|
64
|
-
```ts
|
|
65
|
-
import { openApiPresets } from "@executor/plugin-openapi/presets";
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
## Effect entry point
|
|
69
|
+
## Using with Effect
|
|
69
70
|
|
|
70
|
-
If you're
|
|
71
|
+
If you're building on `@executor-js/sdk/core` (the raw Effect entry), import this plugin from its `/core` subpath instead — it returns the Effect-shaped plugin with `Effect.Effect<...>`-returning methods rather than promisified wrappers:
|
|
71
72
|
|
|
72
73
|
```ts
|
|
73
|
-
import { openApiPlugin } from "@executor/plugin-openapi";
|
|
74
|
+
import { openApiPlugin } from "@executor-js/plugin-openapi/core";
|
|
74
75
|
```
|
|
75
76
|
|
|
76
77
|
## Status
|
package/dist/api/group.d.ts
CHANGED
|
@@ -1,38 +1,95 @@
|
|
|
1
|
-
import { HttpApiEndpoint, HttpApiGroup } from "
|
|
2
|
-
import {
|
|
1
|
+
import { HttpApiEndpoint, HttpApiGroup } from "effect/unstable/httpapi";
|
|
2
|
+
import { Schema } from "effect";
|
|
3
|
+
import { InternalError } from "@executor-js/api";
|
|
4
|
+
import { OpenApiParseError, OpenApiExtractionError, OpenApiOAuthError } from "../sdk/errors";
|
|
3
5
|
import { SpecPreview } from "../sdk/preview";
|
|
4
|
-
import { StoredSourceSchema } from "../sdk/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
readonly
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
readonly
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
readonly
|
|
24
|
-
readonly
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
readonly
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
6
|
+
import { StoredSourceSchema } from "../sdk/store";
|
|
7
|
+
import { OAuth2Auth, OAuth2SourceConfig, OpenApiSourceBindingRef } from "../sdk/types";
|
|
8
|
+
export declare const OpenApiGroup: HttpApiGroup.HttpApiGroup<"openapi", HttpApiEndpoint.HttpApiEndpoint<"previewSpec", "POST", "/scopes/:scopeId/openapi/preview", HttpApiEndpoint.StringTree<Schema.Struct<{
|
|
9
|
+
scopeId: Schema.brand<Schema.String, "ScopeId">;
|
|
10
|
+
}>>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<Schema.Struct<{
|
|
11
|
+
readonly spec: Schema.String;
|
|
12
|
+
readonly specFetchCredentials: Schema.optional<Schema.Struct<{
|
|
13
|
+
readonly headers: Schema.optional<Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Struct<{
|
|
14
|
+
readonly secretId: Schema.String;
|
|
15
|
+
readonly prefix: Schema.optional<Schema.String>;
|
|
16
|
+
}>]>>>;
|
|
17
|
+
readonly queryParams: Schema.optional<Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Struct<{
|
|
18
|
+
readonly secretId: Schema.String;
|
|
19
|
+
readonly prefix: Schema.optional<Schema.String>;
|
|
20
|
+
}>]>>>;
|
|
21
|
+
}>>;
|
|
22
|
+
}>>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<typeof SpecPreview>, HttpApiEndpoint.Json<typeof InternalError | typeof OpenApiParseError | typeof OpenApiExtractionError | typeof OpenApiOAuthError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"addSpec", "POST", "/scopes/:scopeId/openapi/specs", HttpApiEndpoint.StringTree<Schema.Struct<{
|
|
23
|
+
scopeId: Schema.brand<Schema.String, "ScopeId">;
|
|
24
|
+
}>>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<Schema.Struct<{
|
|
25
|
+
readonly spec: Schema.String;
|
|
26
|
+
readonly specFetchCredentials: Schema.optional<Schema.Struct<{
|
|
27
|
+
readonly headers: Schema.optional<Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Struct<{
|
|
28
|
+
readonly secretId: Schema.String;
|
|
29
|
+
readonly prefix: Schema.optional<Schema.String>;
|
|
30
|
+
}>]>>>;
|
|
31
|
+
readonly queryParams: Schema.optional<Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Struct<{
|
|
32
|
+
readonly secretId: Schema.String;
|
|
33
|
+
readonly prefix: Schema.optional<Schema.String>;
|
|
34
|
+
}>]>>>;
|
|
35
|
+
}>>;
|
|
36
|
+
readonly name: Schema.optional<Schema.String>;
|
|
37
|
+
readonly baseUrl: Schema.optional<Schema.String>;
|
|
38
|
+
readonly namespace: Schema.optional<Schema.String>;
|
|
39
|
+
readonly headers: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
|
|
40
|
+
readonly queryParams: Schema.optional<Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Struct<{
|
|
41
|
+
readonly secretId: Schema.String;
|
|
42
|
+
readonly prefix: Schema.optional<Schema.String>;
|
|
43
|
+
}>]>>>;
|
|
44
|
+
readonly oauth2: Schema.optional<Schema.Union<readonly [typeof OAuth2Auth, typeof OAuth2SourceConfig]>>;
|
|
45
|
+
}>>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<Schema.Struct<{
|
|
46
|
+
readonly toolCount: Schema.Number;
|
|
47
|
+
readonly namespace: Schema.String;
|
|
48
|
+
}>>, HttpApiEndpoint.Json<typeof InternalError | typeof OpenApiParseError | typeof OpenApiExtractionError | typeof OpenApiOAuthError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"getSource", "GET", "/scopes/:scopeId/openapi/sources/:namespace", HttpApiEndpoint.StringTree<Schema.Struct<{
|
|
49
|
+
scopeId: Schema.brand<Schema.String, "ScopeId">;
|
|
50
|
+
namespace: Schema.String;
|
|
51
|
+
}>>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<Schema.NullOr<typeof StoredSourceSchema>>, HttpApiEndpoint.Json<typeof InternalError | typeof OpenApiParseError | typeof OpenApiExtractionError | typeof OpenApiOAuthError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"updateSource", "PATCH", "/scopes/:scopeId/openapi/sources/:namespace", HttpApiEndpoint.StringTree<Schema.Struct<{
|
|
52
|
+
scopeId: Schema.brand<Schema.String, "ScopeId">;
|
|
53
|
+
namespace: Schema.String;
|
|
54
|
+
}>>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<Schema.Struct<{
|
|
55
|
+
readonly name: Schema.optional<Schema.String>;
|
|
56
|
+
readonly baseUrl: Schema.optional<Schema.String>;
|
|
57
|
+
readonly headers: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
|
|
58
|
+
readonly queryParams: Schema.optional<Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Struct<{
|
|
59
|
+
readonly secretId: Schema.String;
|
|
60
|
+
readonly prefix: Schema.optional<Schema.String>;
|
|
61
|
+
}>]>>>;
|
|
62
|
+
readonly oauth2: Schema.optional<Schema.Union<readonly [typeof OAuth2Auth, typeof OAuth2SourceConfig]>>;
|
|
63
|
+
}>>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<Schema.Struct<{
|
|
64
|
+
readonly updated: Schema.Boolean;
|
|
65
|
+
}>>, HttpApiEndpoint.Json<typeof InternalError | typeof OpenApiParseError | typeof OpenApiExtractionError | typeof OpenApiOAuthError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"listSourceBindings", "GET", "/scopes/:scopeId/openapi/sources/:namespace/base/:sourceScopeId/bindings", HttpApiEndpoint.StringTree<Schema.Struct<{
|
|
66
|
+
scopeId: Schema.brand<Schema.String, "ScopeId">;
|
|
67
|
+
namespace: Schema.String;
|
|
68
|
+
sourceScopeId: Schema.brand<Schema.String, "ScopeId">;
|
|
69
|
+
}>>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<Schema.$Array<typeof OpenApiSourceBindingRef>>, HttpApiEndpoint.Json<typeof InternalError | typeof OpenApiParseError | typeof OpenApiExtractionError | typeof OpenApiOAuthError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"setSourceBinding", "POST", "/scopes/:scopeId/openapi/source-bindings", HttpApiEndpoint.StringTree<Schema.Struct<{
|
|
70
|
+
scopeId: Schema.brand<Schema.String, "ScopeId">;
|
|
71
|
+
}>>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<Schema.Struct<{
|
|
72
|
+
readonly sourceId: Schema.String;
|
|
73
|
+
readonly sourceScope: Schema.brand<Schema.String, "ScopeId">;
|
|
74
|
+
readonly scope: Schema.brand<Schema.String, "ScopeId">;
|
|
75
|
+
readonly slot: Schema.String;
|
|
76
|
+
readonly value: Schema.Union<readonly [Schema.Struct<{
|
|
77
|
+
readonly kind: Schema.Literal<"secret">;
|
|
78
|
+
readonly secretId: Schema.brand<Schema.String, "SecretId">;
|
|
79
|
+
}>, Schema.Struct<{
|
|
80
|
+
readonly kind: Schema.Literal<"connection">;
|
|
81
|
+
readonly connectionId: Schema.brand<Schema.String, "ConnectionId">;
|
|
82
|
+
}>, Schema.Struct<{
|
|
83
|
+
readonly kind: Schema.Literal<"text">;
|
|
84
|
+
readonly text: Schema.String;
|
|
85
|
+
}>]>;
|
|
86
|
+
}>>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<typeof OpenApiSourceBindingRef>, HttpApiEndpoint.Json<typeof InternalError | typeof OpenApiParseError | typeof OpenApiExtractionError | typeof OpenApiOAuthError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"removeSourceBinding", "POST", "/scopes/:scopeId/openapi/source-bindings/remove", HttpApiEndpoint.StringTree<Schema.Struct<{
|
|
87
|
+
scopeId: Schema.brand<Schema.String, "ScopeId">;
|
|
88
|
+
}>>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<Schema.Struct<{
|
|
89
|
+
readonly sourceId: Schema.String;
|
|
90
|
+
readonly sourceScope: Schema.brand<Schema.String, "ScopeId">;
|
|
91
|
+
readonly slot: Schema.String;
|
|
92
|
+
readonly scope: Schema.brand<Schema.String, "ScopeId">;
|
|
93
|
+
}>>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<Schema.Struct<{
|
|
94
|
+
readonly removed: Schema.Boolean;
|
|
95
|
+
}>>, HttpApiEndpoint.Json<typeof InternalError | typeof OpenApiParseError | typeof OpenApiExtractionError | typeof OpenApiOAuthError>, never, never>, false>;
|
package/dist/api/handlers.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Context } from "effect";
|
|
2
2
|
import type { OpenApiPluginExtension } from "../sdk/plugin";
|
|
3
|
-
declare const OpenApiExtensionService_base: Context.
|
|
3
|
+
declare const OpenApiExtensionService_base: Context.ServiceClass<OpenApiExtensionService, "OpenApiExtensionService", OpenApiPluginExtension>;
|
|
4
4
|
export declare class OpenApiExtensionService extends OpenApiExtensionService_base {
|
|
5
5
|
}
|
|
6
|
-
export declare const OpenApiHandlers: import("effect/Layer").Layer<import("
|
|
6
|
+
export declare const OpenApiHandlers: import("effect/Layer").Layer<import("effect/unstable/httpapi/HttpApiGroup").ApiGroup<"executor", "openapi">, never, import("effect/unstable/http/HttpRouter").Request<"Requires", OpenApiExtensionService>>;
|
|
7
7
|
export {};
|