treege 3.0.0-beta.44 → 3.0.0-beta.45
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 +16 -9
- package/dist/DefaultInputs-DYKtphqY.js +1701 -0
- package/dist/ThemeContext-O482h1XZ.js +1397 -0
- package/dist/editor/context/OpenApiContext.d.ts +79 -0
- package/dist/editor/context/TreegeEditorContext.d.ts +7 -0
- package/dist/editor/features/TreegeEditor/TreegeEditor.d.ts +1 -1
- package/dist/editor/features/TreegeEditor/dialogs/AuthorizeDialog.d.ts +20 -0
- package/dist/editor/features/TreegeEditor/dialogs/HeadersDialog.d.ts +19 -0
- package/dist/editor/features/TreegeEditor/dialogs/OpenApiDialog.d.ts +6 -0
- package/dist/editor/features/TreegeEditor/forms/OptionsSourceForm.d.ts +7 -0
- package/dist/editor/features/TreegeEditor/inputs/ApiUrlCombobox.d.ts +30 -0
- package/dist/editor/features/TreegeEditor/nodes/TreegeNode.d.ts +0 -1
- package/dist/editor/features/TreegeEditor/nodes/components/NodeImage.d.ts +5 -0
- package/dist/editor/features/TreegeEditor/nodes/components/NodeImageButton.d.ts +6 -0
- package/dist/editor/features/TreegeEditor/nodes/components/NodeOptions.d.ts +12 -0
- package/dist/editor/features/TreegeEditor/nodes/components/NodeRequiredButton.d.ts +6 -0
- package/dist/editor/features/TreegeEditor/panel/ActionsPanel.d.ts +5 -2
- package/dist/editor/types/editor.d.ts +39 -1
- package/dist/editor/types/openapi.d.ts +81 -0
- package/dist/editor/utils/openapi.d.ts +35 -0
- package/dist/editor-DBCMmZtt.js +5147 -0
- package/dist/editor.js +2 -2
- package/dist/main.js +4 -4
- package/dist/renderer/context/TreegeConfigContext.d.ts +3 -27
- package/dist/renderer/context/TreegeRendererContext.d.ts +99 -2
- package/dist/renderer/features/TreegeRenderer/native/components/DefaultInputWrapper.d.ts +9 -0
- package/dist/renderer/features/TreegeRenderer/useTreegeRenderer.d.ts +3 -2
- package/dist/renderer/features/TreegeRenderer/web/TreegeRenderer.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/DefaultFormWrapper.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/DefaultInputWrapper.d.ts +9 -0
- package/dist/renderer/hooks/useInputOptions.d.ts +28 -0
- package/dist/renderer/hooks/useRenderNode.d.ts +7 -3
- package/dist/renderer/hooks/useSubmitHandler.d.ts +3 -2
- package/dist/renderer/types/renderer.d.ts +13 -25
- package/dist/renderer/utils/http.d.ts +29 -1
- package/dist/renderer/utils/submit.d.ts +3 -2
- package/dist/renderer-native.js +794 -782
- package/dist/renderer.js +3 -3
- package/dist/shared/components/ui/button.d.ts +1 -1
- package/dist/shared/components/ui/field.d.ts +24 -0
- package/dist/shared/components/ui/toggle-group.d.ts +7 -0
- package/dist/shared/components/ui/toggle.d.ts +9 -0
- package/dist/shared/locales/ar.json.d.ts +80 -0
- package/dist/shared/locales/de.json.d.ts +80 -0
- package/dist/shared/locales/en.json.d.ts +80 -0
- package/dist/shared/locales/es.json.d.ts +80 -0
- package/dist/shared/locales/fr.json.d.ts +80 -0
- package/dist/shared/locales/it.json.d.ts +80 -0
- package/dist/shared/locales/pt.json.d.ts +80 -0
- package/dist/shared/types/node.d.ts +44 -0
- package/package.json +3 -1
- package/dist/DefaultInputs-D6a1ESW-.js +0 -1562
- package/dist/ThemeContext-CUHjGVUf.js +0 -1602
- package/dist/editor/features/TreegeEditor/nodes/components/OptionsEditor.d.ts +0 -7
- package/dist/editor/features/TreegeEditor/nodes/components/RequiredBadge.d.ts +0 -6
- package/dist/editor-DjtjUgyb.js +0 -4041
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { ApiRoute, OpenApiDocument } from '../types/openapi';
|
|
3
|
+
/**
|
|
4
|
+
* The exact input the user fed to the OpenAPI dialog last time it loaded
|
|
5
|
+
* successfully. Kept around so re-opening the dialog can pre-fill the field
|
|
6
|
+
* (the user may want to tweak/re-load the same source).
|
|
7
|
+
*/
|
|
8
|
+
export type OpenApiSourceInput = {
|
|
9
|
+
mode: "url";
|
|
10
|
+
value: string;
|
|
11
|
+
} | {
|
|
12
|
+
mode: "json";
|
|
13
|
+
value: string;
|
|
14
|
+
};
|
|
15
|
+
interface OpenApiContextValue {
|
|
16
|
+
/**
|
|
17
|
+
* The currently loaded OpenAPI document, or `null` when none is set.
|
|
18
|
+
*/
|
|
19
|
+
document: OpenApiDocument | null;
|
|
20
|
+
/**
|
|
21
|
+
* Memoized flat list of routes derived from `document`.
|
|
22
|
+
*/
|
|
23
|
+
routes: ApiRoute[];
|
|
24
|
+
/**
|
|
25
|
+
* User-provided base URL that overrides the document's `servers[0].url`.
|
|
26
|
+
* Useful when the OpenAPI spec points at a different environment than the
|
|
27
|
+
* one the user wants to call (e.g. staging vs prod). Empty string means
|
|
28
|
+
* "no override — use the document's declared server".
|
|
29
|
+
*/
|
|
30
|
+
baseUrlOverride: string;
|
|
31
|
+
/**
|
|
32
|
+
* Effective base URL: the override when non-empty, otherwise the document's
|
|
33
|
+
* first declared server. Trailing slash trimmed.
|
|
34
|
+
*/
|
|
35
|
+
baseUrl: string;
|
|
36
|
+
/**
|
|
37
|
+
* Last source input (URL or pasted JSON) used to load the document. `null`
|
|
38
|
+
* before the user has loaded anything.
|
|
39
|
+
*/
|
|
40
|
+
lastSourceInput: OpenApiSourceInput | null;
|
|
41
|
+
/**
|
|
42
|
+
* Replace the loaded document. Pass `null` to clear.
|
|
43
|
+
*/
|
|
44
|
+
setDocument: (next: OpenApiDocument | null) => void;
|
|
45
|
+
/**
|
|
46
|
+
* Replace the base URL override. Pass `""` to clear.
|
|
47
|
+
*/
|
|
48
|
+
setBaseUrlOverride: (next: string) => void;
|
|
49
|
+
/**
|
|
50
|
+
* Record the last source input the user used to load the document.
|
|
51
|
+
*/
|
|
52
|
+
setLastSourceInput: (next: OpenApiSourceInput | null) => void;
|
|
53
|
+
}
|
|
54
|
+
interface OpenApiProviderProps {
|
|
55
|
+
children: ReactNode;
|
|
56
|
+
/**
|
|
57
|
+
* Initial OpenAPI source. Accepts either a pre-parsed document or a URL
|
|
58
|
+
* string — when a URL is given, the provider fetches it on mount and
|
|
59
|
+
* toasts on failure (matching the runtime behavior of the dialog).
|
|
60
|
+
*/
|
|
61
|
+
initialDocument?: OpenApiDocument | string | null;
|
|
62
|
+
/**
|
|
63
|
+
* Initial base URL. When set, takes precedence over the document's
|
|
64
|
+
* `servers[0].url`. Empty string means "no override".
|
|
65
|
+
*/
|
|
66
|
+
initialBaseUrl?: string;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Holds the current OpenAPI document at editor scope. The document is
|
|
70
|
+
* editor-local state (not persisted in the flow JSON), so reloading the
|
|
71
|
+
* editor with a different consumer-supplied initial document is supported.
|
|
72
|
+
*/
|
|
73
|
+
export declare const OpenApiProvider: ({ children, initialDocument, initialBaseUrl }: OpenApiProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
74
|
+
/**
|
|
75
|
+
* Read the OpenAPI context. Returns a no-op default outside of the provider
|
|
76
|
+
* so consumers (e.g., URL combobox) don't have to null-check.
|
|
77
|
+
*/
|
|
78
|
+
export declare const useOpenApi: () => OpenApiContextValue;
|
|
79
|
+
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { PropsWithChildren } from 'react';
|
|
2
2
|
import { AIConfig } from '../types/ai';
|
|
3
|
+
import { HttpHeader } from '../../shared/types/node';
|
|
3
4
|
export interface TreegeEditorContextValue {
|
|
4
5
|
/**
|
|
5
6
|
* Current language
|
|
@@ -9,6 +10,12 @@ export interface TreegeEditorContextValue {
|
|
|
9
10
|
* Current flow ID
|
|
10
11
|
*/
|
|
11
12
|
flowId?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Global HTTP headers used by editor-time HTTP calls (e.g. the
|
|
15
|
+
* "Detect fields" button). Forwarded by the consumer; same shape and
|
|
16
|
+
* semantics as `TreegeRenderer`'s `headers`.
|
|
17
|
+
*/
|
|
18
|
+
headers?: HttpHeader[];
|
|
12
19
|
/**
|
|
13
20
|
* Function to set the current flow ID
|
|
14
21
|
* @param flow
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { TreegeEditorProps } from '../../types/editor';
|
|
2
|
-
declare const TreegeEditor: ({ flow, onExportJson, onSave, theme, language, aiConfig, extraMenuItems }: TreegeEditorProps) => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
declare const TreegeEditor: ({ flow, onExportJson, onSave, theme, language, aiConfig, extraMenuItems, openApi, openApiBaseUrl, onAuthorize, headers, onHeadersChange, }: TreegeEditorProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
export default TreegeEditor;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { HttpHeader } from '../../../../shared/types/node';
|
|
2
|
+
interface AuthorizeDialogProps {
|
|
3
|
+
open: boolean;
|
|
4
|
+
onOpenChange: (open: boolean) => void;
|
|
5
|
+
onAuthorize?: (headers: HttpHeader[]) => void;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Reads supported security schemes from the loaded OpenAPI document and
|
|
9
|
+
* collects credentials from the user (Bearer token, API key value, or
|
|
10
|
+
* OAuth2 password grant). On submit, exchanges OAuth2 credentials at the
|
|
11
|
+
* token endpoint, builds the resulting `HttpHeader[]`, and calls
|
|
12
|
+
* `onAuthorize` so the consumer can forward them to the renderer's
|
|
13
|
+
* global `headers`.
|
|
14
|
+
*
|
|
15
|
+
* Inspired by Swagger UI's "Authorize" modal. OAuth2 flows other than
|
|
16
|
+
* `password` (auth_code, client_credentials, implicit) are out of scope —
|
|
17
|
+
* they require browser redirects, server-side state, or PKCE.
|
|
18
|
+
*/
|
|
19
|
+
declare const AuthorizeDialog: ({ open, onOpenChange, onAuthorize }: AuthorizeDialogProps) => import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
export default AuthorizeDialog;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { HttpHeader } from '../../../../shared/types/node';
|
|
2
|
+
interface HeadersDialogProps {
|
|
3
|
+
open: boolean;
|
|
4
|
+
onOpenChange: (open: boolean) => void;
|
|
5
|
+
headers: HttpHeader[];
|
|
6
|
+
onChange: (headers: HttpHeader[]) => void;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Edit the editor's "global headers" — forwarded to every HTTP request the
|
|
10
|
+
* runtime form issues (HTTP inputs, submit buttons, options-source fetches).
|
|
11
|
+
* Field-level headers configured on individual nodes override these on key
|
|
12
|
+
* collision (case-insensitive).
|
|
13
|
+
*
|
|
14
|
+
* The dialog is fully controlled: the parent owns the headers list and
|
|
15
|
+
* receives every mutation via `onChange`, so the same value can be forwarded
|
|
16
|
+
* to `TreegeRenderer` without any state duplication.
|
|
17
|
+
*/
|
|
18
|
+
declare const HeadersDialog: ({ open, onOpenChange, headers, onChange }: HeadersDialogProps) => import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
export default HeadersDialog;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { OptionsSource } from '../../../../shared/types/node';
|
|
2
|
+
interface OptionsSourceFormProps {
|
|
3
|
+
value: OptionsSource | undefined;
|
|
4
|
+
onChange: (value: OptionsSource | undefined) => void;
|
|
5
|
+
}
|
|
6
|
+
declare const OptionsSourceForm: ({ value, onChange }: OptionsSourceFormProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export default OptionsSourceForm;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ComponentProps, ReactNode } from 'react';
|
|
2
|
+
import { ApiRouteMethod } from '../../../types/openapi';
|
|
3
|
+
import { Input } from '../../../../shared/components/ui/input';
|
|
4
|
+
interface ApiUrlComboboxProps extends Omit<ComponentProps<typeof Input>, "onChange" | "value" | "children"> {
|
|
5
|
+
value: string;
|
|
6
|
+
/**
|
|
7
|
+
* Called whenever the URL changes. When `method` is set, the user picked
|
|
8
|
+
* a route from the OpenAPI document — callers should also update their
|
|
9
|
+
* HTTP method state accordingly.
|
|
10
|
+
*/
|
|
11
|
+
onChange: (url: string, method?: ApiRouteMethod) => void;
|
|
12
|
+
/**
|
|
13
|
+
* Optional trailing adornments rendered next to the input (e.g. a variable
|
|
14
|
+
* picker). Always rendered, regardless of whether an OpenAPI document is
|
|
15
|
+
* loaded.
|
|
16
|
+
*/
|
|
17
|
+
children?: ReactNode;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* URL field that augments a regular `<Input>` with a Popover suggesting
|
|
21
|
+
* routes from the editor-loaded OpenAPI document. The user can either type
|
|
22
|
+
* a custom URL freely (current behavior preserved) or click the Globe icon
|
|
23
|
+
* to pick a route — selecting one resolves the URL with the document's
|
|
24
|
+
* server and emits the route's HTTP method back to the caller.
|
|
25
|
+
*
|
|
26
|
+
* When no OpenAPI document is loaded, the Globe trigger is hidden and the
|
|
27
|
+
* component is functionally identical to a plain `<Input>`.
|
|
28
|
+
*/
|
|
29
|
+
declare const ApiUrlCombobox: ({ value, onChange, placeholder, children, ...inputProps }: ApiUrlComboboxProps) => import("react/jsx-runtime").JSX.Element;
|
|
30
|
+
export default ApiUrlCombobox;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Node, NodeProps } from '@xyflow/react';
|
|
2
2
|
import { FlowNodeData, InputNodeData, UINodeData } from '../../../../shared/types/node';
|
|
3
|
-
export type TreegeNodeType = Node<FlowNodeData, "flow"> | Node<InputNodeData, "input"> | Node<UINodeData, "ui">;
|
|
4
3
|
export type TreegeNodeProps = NodeProps<Node<FlowNodeData, "flow">> | NodeProps<Node<InputNodeData, "input">> | NodeProps<Node<UINodeData, "ui">>;
|
|
5
4
|
declare const _default: import('react').MemoExoticComponent<(props: TreegeNodeProps) => import("react/jsx-runtime").JSX.Element>;
|
|
6
5
|
export default _default;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FlowNodeData, InputNodeData, UINodeData } from '../../../../../shared/types/node';
|
|
2
|
+
interface NodeOptionsProps {
|
|
3
|
+
nodeId: string;
|
|
4
|
+
data?: FlowNodeData | InputNodeData | UINodeData;
|
|
5
|
+
/**
|
|
6
|
+
* When true, hovering an option row reveals edit/delete icons. We gate the
|
|
7
|
+
* icons on selection so unselected nodes stay visually clean.
|
|
8
|
+
*/
|
|
9
|
+
selected?: boolean;
|
|
10
|
+
}
|
|
11
|
+
declare const NodeOptions: ({ nodeId, data, selected }: NodeOptionsProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
12
|
+
export default NodeOptions;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { ExtraMenuItem } from '../../../types/editor';
|
|
2
|
-
import { Flow } from '../../../../shared/types/node';
|
|
2
|
+
import { Flow, HttpHeader } from '../../../../shared/types/node';
|
|
3
3
|
export interface ActionsPanelProps {
|
|
4
4
|
onExportJson?: (data: Flow) => void;
|
|
5
5
|
onSave?: (data: Flow) => void;
|
|
6
6
|
extraMenuItems?: ExtraMenuItem[];
|
|
7
|
+
onAuthorize?: (headers: HttpHeader[]) => void;
|
|
8
|
+
headers?: HttpHeader[];
|
|
9
|
+
onHeadersChange?: (headers: HttpHeader[]) => void;
|
|
7
10
|
}
|
|
8
|
-
declare const ActionsPanel: ({ onExportJson, onSave, extraMenuItems }: ActionsPanelProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
declare const ActionsPanel: ({ onExportJson, onSave, extraMenuItems, onAuthorize, headers, onHeadersChange }: ActionsPanelProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
12
|
export default ActionsPanel;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Edge, Node } from '@xyflow/react';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
import { AIConfig } from './ai';
|
|
4
|
-
import {
|
|
4
|
+
import { OpenApiDocument } from './openapi';
|
|
5
|
+
import { Flow, HttpHeader } from '../../shared/types/node';
|
|
5
6
|
export interface ExtraMenuItem {
|
|
6
7
|
/**
|
|
7
8
|
* Label displayed in the menu item.
|
|
@@ -58,4 +59,41 @@ export interface TreegeEditorProps {
|
|
|
58
59
|
* Extra menu items to append to the "more" dropdown of the actions panel.
|
|
59
60
|
*/
|
|
60
61
|
extraMenuItems?: ExtraMenuItem[];
|
|
62
|
+
/**
|
|
63
|
+
* OpenAPI 3.x source used to power URL/route suggestions inside HTTP and
|
|
64
|
+
* Options-source forms, and to drive the Authorize flow. Accepts either:
|
|
65
|
+
* - a pre-parsed `OpenApiDocument` object
|
|
66
|
+
* - a URL string (the editor fetches it on mount and toasts on failure)
|
|
67
|
+
*
|
|
68
|
+
* Users can still load one at runtime via the editor's "OpenAPI" button.
|
|
69
|
+
*/
|
|
70
|
+
openApi?: OpenApiDocument | string;
|
|
71
|
+
/**
|
|
72
|
+
* Base URL used for OpenAPI route resolution. When set, it takes precedence
|
|
73
|
+
* over the document's `servers[0].url` — useful when the spec points at a
|
|
74
|
+
* different environment than the one to call (e.g. staging vs prod).
|
|
75
|
+
*/
|
|
76
|
+
openApiBaseUrl?: string;
|
|
77
|
+
/**
|
|
78
|
+
* Global HTTP headers applied to in-editor requests (e.g. the "Detect
|
|
79
|
+
* fields" button in `OptionsSourceForm`). Pass the same value you give to
|
|
80
|
+
* `TreegeRenderer` so editor-time previews use the same auth and headers
|
|
81
|
+
* that the runtime form will use.
|
|
82
|
+
*/
|
|
83
|
+
headers?: HttpHeader[];
|
|
84
|
+
/**
|
|
85
|
+
* Called when the user submits the Authorize dialog. Receives the resulting
|
|
86
|
+
* HTTP headers (`Authorization`, API key headers…). The consumer is expected
|
|
87
|
+
* to forward those headers to `TreegeRenderer` (or `TreegeConfigProvider`)
|
|
88
|
+
* via its `headers` prop so every request issued by the form is authenticated.
|
|
89
|
+
*/
|
|
90
|
+
onAuthorize?: (headers: HttpHeader[]) => void;
|
|
91
|
+
/**
|
|
92
|
+
* Called whenever the user edits the global headers via the editor's
|
|
93
|
+
* built-in "Global headers" dialog. The component is controlled — the
|
|
94
|
+
* parent is expected to update its `headers` state in response and pass
|
|
95
|
+
* the new list back via the `headers` prop, so every editor-time and
|
|
96
|
+
* runtime request reflects the change.
|
|
97
|
+
*/
|
|
98
|
+
onHeadersChange?: (headers: HttpHeader[]) => void;
|
|
61
99
|
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal OpenAPI 3.x types — only what the editor needs to suggest API
|
|
3
|
+
* routes and authenticate against an API. Not a full OpenAPI definition.
|
|
4
|
+
*
|
|
5
|
+
* Swagger 2.0 (`swagger: "2.0"`) is intentionally not supported.
|
|
6
|
+
*/
|
|
7
|
+
export interface OpenApiDocument {
|
|
8
|
+
openapi: string;
|
|
9
|
+
info?: {
|
|
10
|
+
title?: string;
|
|
11
|
+
version?: string;
|
|
12
|
+
description?: string;
|
|
13
|
+
};
|
|
14
|
+
servers?: Array<{
|
|
15
|
+
url: string;
|
|
16
|
+
description?: string;
|
|
17
|
+
}>;
|
|
18
|
+
paths: Record<string, OpenApiPathItem | undefined>;
|
|
19
|
+
components?: {
|
|
20
|
+
securitySchemes?: Record<string, OpenApiSecurityScheme | undefined>;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export interface OpenApiPathItem {
|
|
24
|
+
get?: OpenApiOperation;
|
|
25
|
+
put?: OpenApiOperation;
|
|
26
|
+
post?: OpenApiOperation;
|
|
27
|
+
delete?: OpenApiOperation;
|
|
28
|
+
patch?: OpenApiOperation;
|
|
29
|
+
}
|
|
30
|
+
export interface OpenApiOperation {
|
|
31
|
+
summary?: string;
|
|
32
|
+
description?: string;
|
|
33
|
+
tags?: string[];
|
|
34
|
+
operationId?: string;
|
|
35
|
+
}
|
|
36
|
+
/** HTTP Bearer auth scheme. */
|
|
37
|
+
export interface OpenApiHttpBearerScheme {
|
|
38
|
+
type: "http";
|
|
39
|
+
scheme: "bearer";
|
|
40
|
+
bearerFormat?: string;
|
|
41
|
+
description?: string;
|
|
42
|
+
}
|
|
43
|
+
/** Header-based API key auth scheme. */
|
|
44
|
+
export interface OpenApiApiKeyHeaderScheme {
|
|
45
|
+
type: "apiKey";
|
|
46
|
+
in: "header";
|
|
47
|
+
name: string;
|
|
48
|
+
description?: string;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* OAuth2 with the `password` grant. The user provides username + password
|
|
52
|
+
* directly, the editor exchanges them at `tokenUrl` and uses the returned
|
|
53
|
+
* access token as a Bearer header.
|
|
54
|
+
*
|
|
55
|
+
* Other OAuth2 flows (`authorization_code`, `client_credentials`, `implicit`)
|
|
56
|
+
* are out of scope — they require browser redirects, server-side state, or
|
|
57
|
+
* PKCE.
|
|
58
|
+
*/
|
|
59
|
+
export interface OpenApiOAuth2PasswordScheme {
|
|
60
|
+
type: "oauth2";
|
|
61
|
+
/** Resolved against `servers[0].url` when the spec uses a relative path. */
|
|
62
|
+
tokenUrl: string;
|
|
63
|
+
description?: string;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Security schemes the editor supports today. Other schemes (OAuth2 flows
|
|
67
|
+
* other than password, cookie/query API keys, openIdConnect) are filtered
|
|
68
|
+
* out at extraction time.
|
|
69
|
+
*/
|
|
70
|
+
export type OpenApiSecurityScheme = OpenApiHttpBearerScheme | OpenApiApiKeyHeaderScheme | OpenApiOAuth2PasswordScheme;
|
|
71
|
+
export type ApiRouteMethod = "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
|
|
72
|
+
/**
|
|
73
|
+
* One operation extracted from an OpenAPI document, flattened to a single
|
|
74
|
+
* (method, path) record for easy listing.
|
|
75
|
+
*/
|
|
76
|
+
export interface ApiRoute {
|
|
77
|
+
method: ApiRouteMethod;
|
|
78
|
+
path: string;
|
|
79
|
+
summary?: string;
|
|
80
|
+
operationId?: string;
|
|
81
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ApiRoute, OpenApiDocument, OpenApiSecurityScheme } from '../types/openapi';
|
|
2
|
+
/**
|
|
3
|
+
* Type guard validating that `value` is a usable OpenAPI 3.x document.
|
|
4
|
+
* Rejects 2.0 (Swagger) since we don't support it.
|
|
5
|
+
*/
|
|
6
|
+
export declare const isOpenApi3Document: (value: unknown) => value is OpenApiDocument;
|
|
7
|
+
/**
|
|
8
|
+
* Load an OpenAPI document from either a remote URL or a raw JSON string.
|
|
9
|
+
* Throws when the input is empty, unreachable, malformed JSON, or not an
|
|
10
|
+
* OpenAPI 3.x document.
|
|
11
|
+
*/
|
|
12
|
+
export declare const loadOpenApiDocument: (input: string) => Promise<OpenApiDocument>;
|
|
13
|
+
/**
|
|
14
|
+
* Flatten every (method, path) tuple defined in the document, preserving
|
|
15
|
+
* the path declaration order.
|
|
16
|
+
*/
|
|
17
|
+
export declare const extractApiRoutes: (doc: OpenApiDocument) => ApiRoute[];
|
|
18
|
+
/** Returns the first declared server URL (with any trailing slash trimmed). */
|
|
19
|
+
export declare const getBaseUrl: (doc: OpenApiDocument) => string;
|
|
20
|
+
/** Resolve a path to a full URL using the document's first server. */
|
|
21
|
+
export declare const resolveRouteUrl: (doc: OpenApiDocument, path: string) => string;
|
|
22
|
+
/**
|
|
23
|
+
* Extract every supported security scheme from the document. Schemes other
|
|
24
|
+
* than `http+bearer` and `apiKey-in-header` are silently dropped — they're
|
|
25
|
+
* out of MVP scope.
|
|
26
|
+
*/
|
|
27
|
+
export declare const extractSecuritySchemes: (doc: OpenApiDocument) => Array<{
|
|
28
|
+
name: string;
|
|
29
|
+
scheme: OpenApiSecurityScheme;
|
|
30
|
+
}>;
|
|
31
|
+
/**
|
|
32
|
+
* Resolve a `tokenUrl` (which the OpenAPI spec sometimes leaves relative)
|
|
33
|
+
* against the document's first declared server URL.
|
|
34
|
+
*/
|
|
35
|
+
export declare const resolveTokenUrl: (tokenUrl: string, doc: OpenApiDocument) => string;
|