@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.
Files changed (41) hide show
  1. package/README.md +24 -23
  2. package/dist/api/group.d.ts +94 -37
  3. package/dist/api/handlers.d.ts +2 -2
  4. package/dist/chunk-ZZ7TQ4JC.js +2602 -0
  5. package/dist/chunk-ZZ7TQ4JC.js.map +1 -0
  6. package/dist/core.js +46 -50
  7. package/dist/core.js.map +1 -1
  8. package/dist/index.js +2 -5
  9. package/dist/index.js.map +1 -1
  10. package/dist/react/AddOpenApiSource.d.ts +13 -0
  11. package/dist/react/EditOpenApiSource.d.ts +2 -2
  12. package/dist/react/OpenApiSourceSummary.d.ts +3 -1
  13. package/dist/react/atoms.d.ts +129 -0
  14. package/dist/react/client.d.ts +421 -3
  15. package/dist/react/source-plugin.d.ts +1 -1
  16. package/dist/sdk/client-credentials-oauth.test.d.ts +1 -0
  17. package/dist/sdk/credential-status.d.ts +23 -0
  18. package/dist/sdk/credential-status.test.d.ts +1 -0
  19. package/dist/sdk/errors.d.ts +11 -10
  20. package/dist/sdk/form-urlencoded-body.test.d.ts +1 -0
  21. package/dist/sdk/index.d.ts +8 -10
  22. package/dist/sdk/invoke.d.ts +8 -17
  23. package/dist/sdk/multi-scope-bearer.test.d.ts +1 -0
  24. package/dist/sdk/multi-scope-oauth.test.d.ts +1 -0
  25. package/dist/sdk/non-json-body.test.d.ts +1 -0
  26. package/dist/sdk/oauth-refresh.test.d.ts +1 -0
  27. package/dist/sdk/openapi-utils.d.ts +35 -4
  28. package/dist/sdk/parse.d.ts +28 -4
  29. package/dist/sdk/plugin.d.ts +169 -22
  30. package/dist/sdk/preview-oauth2.test.d.ts +1 -0
  31. package/dist/sdk/preview.d.ts +89 -125
  32. package/dist/sdk/store.d.ts +201 -0
  33. package/dist/sdk/types.d.ts +234 -266
  34. package/package.json +11 -22
  35. package/dist/chunk-V3D5A6HA.js +0 -1224
  36. package/dist/chunk-V3D5A6HA.js.map +0 -1
  37. package/dist/promise.d.ts +0 -6
  38. package/dist/sdk/config-file-store.d.ts +0 -10
  39. package/dist/sdk/kv-operation-store.d.ts +0 -4
  40. package/dist/sdk/operation-store.d.ts +0 -35
  41. package/dist/sdk/stored-source.d.ts +0 -46
package/dist/core.js CHANGED
@@ -1,105 +1,101 @@
1
1
  import {
2
2
  AuthStrategy,
3
3
  DocResolver,
4
+ EncodingObject,
4
5
  ExtractedOperation,
5
6
  ExtractionResult,
6
7
  HeaderPreset,
7
8
  HttpMethod,
8
9
  InvocationConfig,
9
10
  InvocationResult,
11
+ MediaBinding,
12
+ OAuth2Auth,
13
+ OAuth2AuthorizationCodeFlow,
14
+ OAuth2ClientCredentialsFlow,
15
+ OAuth2Flows,
16
+ OAuth2Preset,
17
+ OAuth2SourceConfig,
10
18
  OpenApiExtractionError,
11
19
  OpenApiInvocationError,
20
+ OpenApiOAuthError,
12
21
  OpenApiParseError,
22
+ OpenApiSourceBindingInput,
23
+ OpenApiSourceBindingRef,
24
+ OpenApiSourceBindingValue,
13
25
  OperationBinding,
14
26
  OperationId,
15
27
  OperationParameter,
16
28
  OperationRequestBody,
17
29
  ParameterLocation,
30
+ PreviewOperation,
18
31
  SecurityScheme,
19
32
  ServerInfo,
33
+ ServerVariable,
20
34
  SpecPreview,
35
+ annotationsForOperation,
21
36
  extract,
37
+ fetchSpecText,
22
38
  invoke,
23
- makeInMemoryOperationStore,
24
- makeKvOperationStore,
25
- makeOpenApiInvoker,
39
+ invokeWithLayer,
40
+ makeDefaultOpenapiStore,
26
41
  openApiPlugin,
42
+ openapiSchema,
27
43
  parse,
28
44
  preferredContent,
29
45
  previewSpec,
30
- resolveBaseUrl
31
- } from "./chunk-V3D5A6HA.js";
32
-
33
- // src/sdk/config-file-store.ts
34
- import { Effect } from "effect";
35
- import { addSourceToConfig, removeSourceFromConfig, SECRET_REF_PREFIX } from "@executor/config";
36
- var translateSecretHeaders = (headers) => {
37
- if (!headers) return void 0;
38
- const result = {};
39
- for (const [key, value] of Object.entries(headers)) {
40
- if (typeof value === "string") {
41
- result[key] = value;
42
- continue;
43
- }
44
- const ref = `${SECRET_REF_PREFIX}${value.secretId}`;
45
- result[key] = value.prefix ? { value: ref, prefix: value.prefix } : ref;
46
- }
47
- return result;
48
- };
49
- var toSourceConfig = (source) => ({
50
- kind: "openapi",
51
- spec: source.config.spec,
52
- baseUrl: source.config.baseUrl,
53
- namespace: source.namespace,
54
- headers: translateSecretHeaders(source.config.headers)
55
- });
56
- var withConfigFile = (inner, configPath, fsLayer) => ({
57
- ...inner,
58
- putSource: (source) => Effect.gen(function* () {
59
- yield* inner.putSource(source);
60
- yield* addSourceToConfig(configPath, toSourceConfig(source)).pipe(
61
- Effect.provide(fsLayer),
62
- Effect.catchAll(() => Effect.void)
63
- );
64
- }),
65
- removeSource: (namespace) => Effect.gen(function* () {
66
- yield* inner.removeSource(namespace);
67
- yield* removeSourceFromConfig(configPath, namespace).pipe(
68
- Effect.provide(fsLayer),
69
- Effect.catchAll(() => Effect.void)
70
- );
71
- })
72
- });
46
+ resolveBaseUrl,
47
+ resolveHeaders,
48
+ resolveSpecText,
49
+ substituteUrlVariables
50
+ } from "./chunk-ZZ7TQ4JC.js";
73
51
  export {
74
52
  AuthStrategy,
75
53
  DocResolver,
54
+ EncodingObject,
76
55
  ExtractedOperation,
77
56
  ExtractionResult,
78
57
  HeaderPreset,
79
58
  HttpMethod,
80
59
  InvocationConfig,
81
60
  InvocationResult,
61
+ MediaBinding,
62
+ OAuth2Auth,
63
+ OAuth2AuthorizationCodeFlow,
64
+ OAuth2ClientCredentialsFlow,
65
+ OAuth2Flows,
66
+ OAuth2Preset,
67
+ OAuth2SourceConfig,
82
68
  OpenApiExtractionError,
83
69
  OpenApiInvocationError,
70
+ OpenApiOAuthError,
84
71
  OpenApiParseError,
72
+ OpenApiSourceBindingInput,
73
+ OpenApiSourceBindingRef,
74
+ OpenApiSourceBindingValue,
85
75
  OperationBinding,
86
76
  OperationId,
87
77
  OperationParameter,
88
78
  OperationRequestBody,
89
79
  ParameterLocation,
80
+ PreviewOperation,
90
81
  SecurityScheme,
91
82
  ServerInfo,
83
+ ServerVariable,
92
84
  SpecPreview,
85
+ annotationsForOperation,
93
86
  extract,
87
+ fetchSpecText,
94
88
  invoke,
95
- makeInMemoryOperationStore,
96
- makeKvOperationStore,
97
- makeOpenApiInvoker,
89
+ invokeWithLayer,
90
+ makeDefaultOpenapiStore,
98
91
  openApiPlugin,
92
+ openapiSchema,
99
93
  parse,
100
94
  preferredContent,
101
95
  previewSpec,
102
96
  resolveBaseUrl,
103
- withConfigFile
97
+ resolveHeaders,
98
+ resolveSpecText,
99
+ substituteUrlVariables
104
100
  };
105
101
  //# sourceMappingURL=core.js.map
package/dist/core.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/sdk/config-file-store.ts"],"sourcesContent":["/**\n * Config-file wrapper for OpenApiOperationStore.\n *\n * Decorates an underlying store so that `putSource` and `removeSource` also\n * write to executor.jsonc.\n */\n\nimport { Effect } from \"effect\";\nimport { FileSystem } from \"@effect/platform\";\nimport type { Layer } from \"effect\";\n\nimport { addSourceToConfig, removeSourceFromConfig, SECRET_REF_PREFIX } from \"@executor/config\";\nimport type { SourceConfig as ConfigFileSourceConfig, ConfigHeaderValue } from \"@executor/config\";\n\nimport type { OpenApiOperationStore, StoredSource } from \"./operation-store\";\n\ntype PluginHeaderValue = string | { readonly secretId: string; readonly prefix?: string };\n\nconst translateSecretHeaders = (\n headers: Readonly<Record<string, PluginHeaderValue>> | undefined,\n): Record<string, ConfigHeaderValue> | undefined => {\n if (!headers) return undefined;\n const result: Record<string, ConfigHeaderValue> = {};\n for (const [key, value] of Object.entries(headers)) {\n if (typeof value === \"string\") {\n result[key] = value;\n continue;\n }\n const ref = `${SECRET_REF_PREFIX}${value.secretId}`;\n result[key] = value.prefix ? { value: ref, prefix: value.prefix } : ref;\n }\n return result;\n};\n\nconst toSourceConfig = (source: StoredSource): ConfigFileSourceConfig => ({\n kind: \"openapi\",\n spec: source.config.spec,\n baseUrl: source.config.baseUrl,\n namespace: source.namespace,\n headers: translateSecretHeaders(source.config.headers),\n});\n\nexport const withConfigFile = (\n inner: OpenApiOperationStore,\n configPath: string,\n fsLayer: Layer.Layer<FileSystem.FileSystem>,\n): OpenApiOperationStore => ({\n ...inner,\n putSource: (source) =>\n Effect.gen(function* () {\n yield* inner.putSource(source);\n yield* addSourceToConfig(configPath, toSourceConfig(source)).pipe(\n Effect.provide(fsLayer),\n Effect.catchAll(() => Effect.void),\n );\n }),\n removeSource: (namespace) =>\n Effect.gen(function* () {\n yield* inner.removeSource(namespace);\n yield* removeSourceFromConfig(configPath, namespace).pipe(\n Effect.provide(fsLayer),\n Effect.catchAll(() => Effect.void),\n );\n }),\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,SAAS,cAAc;AAIvB,SAAS,mBAAmB,wBAAwB,yBAAyB;AAO7E,IAAM,yBAAyB,CAC7B,YACkD;AAClD,MAAI,CAAC,QAAS,QAAO;AACrB,QAAM,SAA4C,CAAC;AACnD,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,OAAO,GAAG;AAClD,QAAI,OAAO,UAAU,UAAU;AAC7B,aAAO,GAAG,IAAI;AACd;AAAA,IACF;AACA,UAAM,MAAM,GAAG,iBAAiB,GAAG,MAAM,QAAQ;AACjD,WAAO,GAAG,IAAI,MAAM,SAAS,EAAE,OAAO,KAAK,QAAQ,MAAM,OAAO,IAAI;AAAA,EACtE;AACA,SAAO;AACT;AAEA,IAAM,iBAAiB,CAAC,YAAkD;AAAA,EACxE,MAAM;AAAA,EACN,MAAM,OAAO,OAAO;AAAA,EACpB,SAAS,OAAO,OAAO;AAAA,EACvB,WAAW,OAAO;AAAA,EAClB,SAAS,uBAAuB,OAAO,OAAO,OAAO;AACvD;AAEO,IAAM,iBAAiB,CAC5B,OACA,YACA,aAC2B;AAAA,EAC3B,GAAG;AAAA,EACH,WAAW,CAAC,WACV,OAAO,IAAI,aAAa;AACtB,WAAO,MAAM,UAAU,MAAM;AAC7B,WAAO,kBAAkB,YAAY,eAAe,MAAM,CAAC,EAAE;AAAA,MAC3D,OAAO,QAAQ,OAAO;AAAA,MACtB,OAAO,SAAS,MAAM,OAAO,IAAI;AAAA,IACnC;AAAA,EACF,CAAC;AAAA,EACH,cAAc,CAAC,cACb,OAAO,IAAI,aAAa;AACtB,WAAO,MAAM,aAAa,SAAS;AACnC,WAAO,uBAAuB,YAAY,SAAS,EAAE;AAAA,MACnD,OAAO,QAAQ,OAAO;AAAA,MACtB,OAAO,SAAS,MAAM,OAAO,IAAI;AAAA,IACnC;AAAA,EACF,CAAC;AACL;","names":[]}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/dist/index.js CHANGED
@@ -1,10 +1,7 @@
1
1
  import {
2
2
  openApiPlugin
3
- } from "./chunk-V3D5A6HA.js";
4
-
5
- // src/promise.ts
6
- var openApiPlugin2 = (options) => openApiPlugin(options);
3
+ } from "./chunk-ZZ7TQ4JC.js";
7
4
  export {
8
- openApiPlugin2 as openApiPlugin
5
+ openApiPlugin
9
6
  };
10
7
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/promise.ts"],"sourcesContent":["import { openApiPlugin as openApiPluginEffect } from \"./sdk/plugin\";\n\nexport type { OpenApiSpecConfig } from \"./sdk/plugin\";\nexport type { OpenApiOperationStore } from \"./sdk/operation-store\";\n\nexport interface OpenApiPluginOptions {\n readonly operationStore?: import(\"./sdk/operation-store\").OpenApiOperationStore;\n}\n\nexport const openApiPlugin = (options?: OpenApiPluginOptions) => openApiPluginEffect(options);\n"],"mappings":";;;;;AASO,IAAMA,iBAAgB,CAAC,YAAmC,cAAoB,OAAO;","names":["openApiPlugin"]}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,3 +1,16 @@
1
+ import type { OAuth2Preset } from "../sdk/preview";
2
+ export declare const OPENAPI_OAUTH_POPUP_NAME = "openapi-oauth";
3
+ export declare const OPENAPI_OAUTH_CALLBACK_PATH = "/api/oauth/callback";
4
+ export declare const openApiOAuthConnectionId: (namespaceSlug: string, flow: OAuth2Preset["flow"]) => string;
5
+ /**
6
+ * OpenAPI 3.x requires OAuth2 tokenUrl/authorizationUrl to be absolute,
7
+ * but some specs ship relative paths like `/api/rest/v1/oauth/token`.
8
+ * Resolve them against the source's chosen baseUrl so the backend can
9
+ * fetch them directly and the absolute URL is what gets persisted on
10
+ * OAuth2Auth.
11
+ */
12
+ export declare function resolveOAuthUrl(url: string, baseUrl: string): string;
13
+ export declare function inferOAuthIssuerUrl(authorizationUrl: string): string | null;
1
14
  export default function AddOpenApiSource(props: {
2
15
  onComplete: () => void;
3
16
  onCancel: () => void;
@@ -1,4 +1,4 @@
1
1
  export default function EditOpenApiSource(props: {
2
- sourceId: string;
3
- onSave: () => void;
2
+ readonly sourceId: string;
3
+ readonly onSave: () => void;
4
4
  }): import("react/jsx-runtime").JSX.Element;
@@ -1,3 +1,5 @@
1
1
  export default function OpenApiSourceSummary(props: {
2
2
  sourceId: string;
3
- }): import("react/jsx-runtime").JSX.Element;
3
+ variant?: "badge" | "panel";
4
+ onAction?: () => void;
5
+ }): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,129 @@
1
+ import type { ScopeId } from "@executor-js/sdk/core";
2
+ export declare const openApiSourceAtom: (scopeId: ScopeId, namespace: string) => import("effect/unstable/reactivity/Atom").Atom<import("effect/unstable/reactivity/AsyncResult").AsyncResult<import("../sdk/store").StoredSourceSchema | null, import("@executor-js/api").InternalError | import("../sdk").OpenApiParseError | import("../sdk").OpenApiExtractionError | import("../sdk").OpenApiOAuthError>>;
3
+ export declare const openApiSourceBindingsAtom: (scopeId: ScopeId, namespace: string, sourceScopeId: ScopeId) => import("effect/unstable/reactivity/Atom").Atom<import("effect/unstable/reactivity/AsyncResult").AsyncResult<readonly import("../sdk").OpenApiSourceBindingRef[], import("@executor-js/api").InternalError | import("../sdk").OpenApiParseError | import("../sdk").OpenApiExtractionError | import("../sdk").OpenApiOAuthError>>;
4
+ export declare const previewOpenApiSpec: import("effect/unstable/reactivity/Atom").AtomResultFn<{
5
+ readonly params: {
6
+ readonly scopeId: string & import("effect/Brand").Brand<"ScopeId">;
7
+ };
8
+ readonly payload: {
9
+ readonly spec: string;
10
+ readonly specFetchCredentials?: {
11
+ readonly headers?: {
12
+ readonly [x: string]: string | {
13
+ readonly secretId: string;
14
+ readonly prefix?: string | undefined;
15
+ };
16
+ } | undefined;
17
+ readonly queryParams?: {
18
+ readonly [x: string]: string | {
19
+ readonly secretId: string;
20
+ readonly prefix?: string | undefined;
21
+ };
22
+ } | undefined;
23
+ } | undefined;
24
+ };
25
+ readonly responseMode?: "decoded-only" | undefined;
26
+ readonly reactivityKeys?: readonly unknown[] | import("effect/Record").ReadonlyRecord<string, readonly unknown[]> | undefined;
27
+ }, import("../sdk").SpecPreview, import("@executor-js/api").InternalError | import("../sdk").OpenApiParseError | import("../sdk").OpenApiExtractionError | import("../sdk").OpenApiOAuthError>;
28
+ export declare const addOpenApiSpec: import("effect/unstable/reactivity/Atom").AtomResultFn<{
29
+ readonly params: {
30
+ readonly scopeId: string & import("effect/Brand").Brand<"ScopeId">;
31
+ };
32
+ readonly payload: {
33
+ readonly spec: string;
34
+ readonly name?: string | undefined;
35
+ readonly namespace?: string | undefined;
36
+ readonly oauth2?: import("../sdk").OAuth2Auth | import("../sdk").OAuth2SourceConfig | undefined;
37
+ readonly headers?: {
38
+ readonly [x: string]: unknown;
39
+ } | undefined;
40
+ readonly queryParams?: {
41
+ readonly [x: string]: string | {
42
+ readonly secretId: string;
43
+ readonly prefix?: string | undefined;
44
+ };
45
+ } | undefined;
46
+ readonly baseUrl?: string | undefined;
47
+ readonly specFetchCredentials?: {
48
+ readonly headers?: {
49
+ readonly [x: string]: string | {
50
+ readonly secretId: string;
51
+ readonly prefix?: string | undefined;
52
+ };
53
+ } | undefined;
54
+ readonly queryParams?: {
55
+ readonly [x: string]: string | {
56
+ readonly secretId: string;
57
+ readonly prefix?: string | undefined;
58
+ };
59
+ } | undefined;
60
+ } | undefined;
61
+ };
62
+ readonly responseMode?: "decoded-only" | undefined;
63
+ readonly reactivityKeys?: readonly unknown[] | import("effect/Record").ReadonlyRecord<string, readonly unknown[]> | undefined;
64
+ }, {
65
+ readonly namespace: string;
66
+ readonly toolCount: number;
67
+ }, import("@executor-js/api").InternalError | import("../sdk").OpenApiParseError | import("../sdk").OpenApiExtractionError | import("../sdk").OpenApiOAuthError>;
68
+ export declare const updateOpenApiSource: import("effect/unstable/reactivity/Atom").AtomResultFn<{
69
+ readonly params: {
70
+ readonly namespace: string;
71
+ readonly scopeId: string & import("effect/Brand").Brand<"ScopeId">;
72
+ };
73
+ readonly payload: {
74
+ readonly name?: string | undefined;
75
+ readonly oauth2?: import("../sdk").OAuth2Auth | import("../sdk").OAuth2SourceConfig | undefined;
76
+ readonly headers?: {
77
+ readonly [x: string]: unknown;
78
+ } | undefined;
79
+ readonly queryParams?: {
80
+ readonly [x: string]: string | {
81
+ readonly secretId: string;
82
+ readonly prefix?: string | undefined;
83
+ };
84
+ } | undefined;
85
+ readonly baseUrl?: string | undefined;
86
+ };
87
+ readonly responseMode?: "decoded-only" | undefined;
88
+ readonly reactivityKeys?: readonly unknown[] | import("effect/Record").ReadonlyRecord<string, readonly unknown[]> | undefined;
89
+ }, {
90
+ readonly updated: boolean;
91
+ }, import("@executor-js/api").InternalError | import("../sdk").OpenApiParseError | import("../sdk").OpenApiExtractionError | import("../sdk").OpenApiOAuthError>;
92
+ export declare const setOpenApiSourceBinding: import("effect/unstable/reactivity/Atom").AtomResultFn<{
93
+ readonly params: {
94
+ readonly scopeId: string & import("effect/Brand").Brand<"ScopeId">;
95
+ };
96
+ readonly payload: {
97
+ readonly value: {
98
+ readonly secretId: string & import("effect/Brand").Brand<"SecretId">;
99
+ readonly kind: "secret";
100
+ } | {
101
+ readonly connectionId: string & import("effect/Brand").Brand<"ConnectionId">;
102
+ readonly kind: "connection";
103
+ } | {
104
+ readonly kind: "text";
105
+ readonly text: string;
106
+ };
107
+ readonly sourceId: string;
108
+ readonly scope: string & import("effect/Brand").Brand<"ScopeId">;
109
+ readonly slot: string;
110
+ readonly sourceScope: string & import("effect/Brand").Brand<"ScopeId">;
111
+ };
112
+ readonly responseMode?: "decoded-only" | undefined;
113
+ readonly reactivityKeys?: readonly unknown[] | import("effect/Record").ReadonlyRecord<string, readonly unknown[]> | undefined;
114
+ }, import("../sdk").OpenApiSourceBindingRef, import("@executor-js/api").InternalError | import("../sdk").OpenApiParseError | import("../sdk").OpenApiExtractionError | import("../sdk").OpenApiOAuthError>;
115
+ export declare const removeOpenApiSourceBinding: import("effect/unstable/reactivity/Atom").AtomResultFn<{
116
+ readonly params: {
117
+ readonly scopeId: string & import("effect/Brand").Brand<"ScopeId">;
118
+ };
119
+ readonly payload: {
120
+ readonly sourceId: string;
121
+ readonly scope: string & import("effect/Brand").Brand<"ScopeId">;
122
+ readonly slot: string;
123
+ readonly sourceScope: string & import("effect/Brand").Brand<"ScopeId">;
124
+ };
125
+ readonly responseMode?: "decoded-only" | undefined;
126
+ readonly reactivityKeys?: readonly unknown[] | import("effect/Record").ReadonlyRecord<string, readonly unknown[]> | undefined;
127
+ }, {
128
+ readonly removed: boolean;
129
+ }, import("@executor-js/api").InternalError | import("../sdk").OpenApiParseError | import("../sdk").OpenApiExtractionError | import("../sdk").OpenApiOAuthError>;