@flanksource/clicky-ui 0.3.84 → 0.3.86
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Combobox.cjs +8 -6
- package/dist/components/Combobox.cjs.map +1 -1
- package/dist/components/Combobox.d.ts.map +1 -1
- package/dist/components/Combobox.js +8 -6
- package/dist/components/Combobox.js.map +1 -1
- package/dist/components/ComboboxMenu.cjs +7 -4
- package/dist/components/ComboboxMenu.cjs.map +1 -1
- package/dist/components/ComboboxMenu.d.ts +3 -2
- package/dist/components/ComboboxMenu.d.ts.map +1 -1
- package/dist/components/ComboboxMenu.js +7 -4
- package/dist/components/ComboboxMenu.js.map +1 -1
- package/dist/components/FilterBar.cjs +64 -47
- package/dist/components/FilterBar.cjs.map +1 -1
- package/dist/components/FilterBar.d.ts +20 -2
- package/dist/components/FilterBar.d.ts.map +1 -1
- package/dist/components/FilterBar.js +63 -46
- package/dist/components/FilterBar.js.map +1 -1
- package/dist/components/TimeRange.cjs +156 -128
- package/dist/components/TimeRange.cjs.map +1 -1
- package/dist/components/TimeRange.d.ts +8 -1
- package/dist/components/TimeRange.d.ts.map +1 -1
- package/dist/components/TimeRange.js +156 -128
- package/dist/components/TimeRange.js.map +1 -1
- package/dist/components/combobox-types.d.ts +5 -0
- package/dist/components/combobox-types.d.ts.map +1 -1
- package/dist/components/filter-bar-context.cjs.map +1 -1
- package/dist/components/filter-bar-context.d.ts +2 -0
- package/dist/components/filter-bar-context.d.ts.map +1 -1
- package/dist/components/filter-bar-context.js.map +1 -1
- package/dist/components/filter-bar-field-utils.cjs +18 -4
- package/dist/components/filter-bar-field-utils.cjs.map +1 -1
- package/dist/components/filter-bar-field-utils.d.ts +3 -2
- package/dist/components/filter-bar-field-utils.d.ts.map +1 -1
- package/dist/components/filter-bar-field-utils.js +19 -5
- package/dist/components/filter-bar-field-utils.js.map +1 -1
- package/dist/components/filter-bar-menu.cjs +189 -0
- package/dist/components/filter-bar-menu.cjs.map +1 -0
- package/dist/components/filter-bar-menu.d.ts +25 -0
- package/dist/components/filter-bar-menu.d.ts.map +1 -0
- package/dist/components/filter-bar-menu.js +189 -0
- package/dist/components/filter-bar-menu.js.map +1 -0
- package/dist/components/filter-bar-multi.cjs +1 -1
- package/dist/components/filter-bar-multi.cjs.map +1 -1
- package/dist/components/filter-bar-multi.js +2 -2
- package/dist/components/filter-bar-multi.js.map +1 -1
- package/dist/components/filter-bar-popup.cjs +37 -0
- package/dist/components/filter-bar-popup.cjs.map +1 -0
- package/dist/components/filter-bar-popup.d.ts +32 -0
- package/dist/components/filter-bar-popup.d.ts.map +1 -0
- package/dist/components/filter-bar-popup.js +37 -0
- package/dist/components/filter-bar-popup.js.map +1 -0
- package/dist/components/filter-bar-tree.cjs +1 -1
- package/dist/components/filter-bar-tree.cjs.map +1 -1
- package/dist/components/filter-bar-tree.js +2 -2
- package/dist/components/filter-bar-tree.js.map +1 -1
- package/dist/components/json-schema-form-table-array.cjs +5 -3
- package/dist/components/json-schema-form-table-array.cjs.map +1 -1
- package/dist/components/json-schema-form-table-array.d.ts.map +1 -1
- package/dist/components/json-schema-form-table-array.js +5 -3
- package/dist/components/json-schema-form-table-array.js.map +1 -1
- package/dist/components.cjs +1 -1
- package/dist/components.js +1 -1
- package/dist/connections/ConnectionPicker.cjs +6 -2
- package/dist/connections/ConnectionPicker.cjs.map +1 -1
- package/dist/connections/ConnectionPicker.d.ts.map +1 -1
- package/dist/connections/ConnectionPicker.js +6 -2
- package/dist/connections/ConnectionPicker.js.map +1 -1
- package/dist/connections/CreateConnectionDialog.cjs +8 -21
- package/dist/connections/CreateConnectionDialog.cjs.map +1 -1
- package/dist/connections/CreateConnectionDialog.d.ts +2 -1
- package/dist/connections/CreateConnectionDialog.d.ts.map +1 -1
- package/dist/connections/CreateConnectionDialog.js +8 -21
- package/dist/connections/CreateConnectionDialog.js.map +1 -1
- package/dist/data/ExpandableMarkdown.cjs +59 -0
- package/dist/data/ExpandableMarkdown.cjs.map +1 -0
- package/dist/data/ExpandableMarkdown.d.ts +17 -0
- package/dist/data/ExpandableMarkdown.d.ts.map +1 -0
- package/dist/data/ExpandableMarkdown.js +59 -0
- package/dist/data/ExpandableMarkdown.js.map +1 -0
- package/dist/data/MultiGaugeBar.cjs +49 -21
- package/dist/data/MultiGaugeBar.cjs.map +1 -1
- package/dist/data/MultiGaugeBar.d.ts +5 -2
- package/dist/data/MultiGaugeBar.d.ts.map +1 -1
- package/dist/data/MultiGaugeBar.js +49 -21
- package/dist/data/MultiGaugeBar.js.map +1 -1
- package/dist/data/flow-node/BoxNode.cjs +45 -0
- package/dist/data/flow-node/BoxNode.cjs.map +1 -0
- package/dist/data/flow-node/BoxNode.d.ts +28 -0
- package/dist/data/flow-node/BoxNode.d.ts.map +1 -0
- package/dist/data/flow-node/BoxNode.js +45 -0
- package/dist/data/flow-node/BoxNode.js.map +1 -0
- package/dist/data/flow-node/FlowMetrics.cjs +208 -0
- package/dist/data/flow-node/FlowMetrics.cjs.map +1 -0
- package/dist/data/flow-node/FlowMetrics.d.ts +60 -0
- package/dist/data/flow-node/FlowMetrics.d.ts.map +1 -0
- package/dist/data/flow-node/FlowMetrics.js +206 -0
- package/dist/data/flow-node/FlowMetrics.js.map +1 -0
- package/dist/data/flow-node/WorkloadNode.cjs +63 -0
- package/dist/data/flow-node/WorkloadNode.cjs.map +1 -0
- package/dist/data/flow-node/WorkloadNode.d.ts +42 -0
- package/dist/data/flow-node/WorkloadNode.d.ts.map +1 -0
- package/dist/data/flow-node/WorkloadNode.js +63 -0
- package/dist/data/flow-node/WorkloadNode.js.map +1 -0
- package/dist/data/flow-node/index.d.ts +5 -0
- package/dist/data/flow-node/index.d.ts.map +1 -0
- package/dist/data/flow-node/latency.cjs +37 -0
- package/dist/data/flow-node/latency.cjs.map +1 -0
- package/dist/data/flow-node/latency.d.ts +13 -0
- package/dist/data/flow-node/latency.d.ts.map +1 -0
- package/dist/data/flow-node/latency.js +35 -0
- package/dist/data/flow-node/latency.js.map +1 -0
- package/dist/data/traces/index.d.ts +1 -0
- package/dist/data/traces/index.d.ts.map +1 -1
- package/dist/data/traces/otel/OtelTraceDetail.cjs +4 -7
- package/dist/data/traces/otel/OtelTraceDetail.cjs.map +1 -1
- package/dist/data/traces/otel/OtelTraceDetail.js +4 -7
- package/dist/data/traces/otel/OtelTraceDetail.js.map +1 -1
- package/dist/data/traces/otel/OtelTraceSearch.cjs +90 -56
- package/dist/data/traces/otel/OtelTraceSearch.cjs.map +1 -1
- package/dist/data/traces/otel/OtelTraceSearch.d.ts.map +1 -1
- package/dist/data/traces/otel/OtelTraceSearch.js +91 -57
- package/dist/data/traces/otel/OtelTraceSearch.js.map +1 -1
- package/dist/data/traces/otel/QueryBar.cjs +83 -10
- package/dist/data/traces/otel/QueryBar.cjs.map +1 -1
- package/dist/data/traces/otel/QueryBar.d.ts.map +1 -1
- package/dist/data/traces/otel/QueryBar.js +83 -10
- package/dist/data/traces/otel/QueryBar.js.map +1 -1
- package/dist/data/traces/otel/TraceResults.cjs +81 -13
- package/dist/data/traces/otel/TraceResults.cjs.map +1 -1
- package/dist/data/traces/otel/TraceResults.d.ts +11 -3
- package/dist/data/traces/otel/TraceResults.d.ts.map +1 -1
- package/dist/data/traces/otel/TraceResults.js +81 -13
- package/dist/data/traces/otel/TraceResults.js.map +1 -1
- package/dist/data/traces/otel/api.cjs.map +1 -1
- package/dist/data/traces/otel/api.d.ts +14 -0
- package/dist/data/traces/otel/api.d.ts.map +1 -1
- package/dist/data/traces/otel/api.js.map +1 -1
- package/dist/data/traces/otel/query.cjs +2 -2
- package/dist/data/traces/otel/query.cjs.map +1 -1
- package/dist/data/traces/otel/query.d.ts +1 -1
- package/dist/data/traces/otel/query.d.ts.map +1 -1
- package/dist/data/traces/otel/query.js +2 -2
- package/dist/data/traces/otel/query.js.map +1 -1
- package/dist/data/version-info.cjs +3 -3
- package/dist/data/version-info.cjs.map +1 -1
- package/dist/data/version-info.js +3 -3
- package/dist/data/version-info.js.map +1 -1
- package/dist/data/workload-panel/MemoryStack.cjs +38 -1
- package/dist/data/workload-panel/MemoryStack.cjs.map +1 -1
- package/dist/data/workload-panel/MemoryStack.d.ts.map +1 -1
- package/dist/data/workload-panel/MemoryStack.js +38 -1
- package/dist/data/workload-panel/MemoryStack.js.map +1 -1
- package/dist/data.cjs +18 -1
- package/dist/data.d.ts +2 -0
- package/dist/data.d.ts.map +1 -1
- package/dist/data.js +8 -2
- package/dist/file-findings/AnnotatedCode.cjs +18 -2
- package/dist/file-findings/AnnotatedCode.cjs.map +1 -1
- package/dist/file-findings/AnnotatedCode.d.ts +2 -0
- package/dist/file-findings/AnnotatedCode.d.ts.map +1 -1
- package/dist/file-findings/AnnotatedCode.js +18 -2
- package/dist/file-findings/AnnotatedCode.js.map +1 -1
- package/dist/file-findings/FileFindingsView.cjs.map +1 -1
- package/dist/file-findings/FileFindingsView.d.ts +2 -0
- package/dist/file-findings/FileFindingsView.d.ts.map +1 -1
- package/dist/file-findings/FileFindingsView.js.map +1 -1
- package/dist/file-findings/file-review/FileReview.cjs +2 -1
- package/dist/file-findings/file-review/FileReview.cjs.map +1 -1
- package/dist/file-findings/file-review/FileReview.d.ts +3 -1
- package/dist/file-findings/file-review/FileReview.d.ts.map +1 -1
- package/dist/file-findings/file-review/FileReview.js +2 -1
- package/dist/file-findings/file-review/FileReview.js.map +1 -1
- package/dist/index.cjs +18 -1
- package/dist/index.js +8 -2
- package/dist/profiles/editor/profileEditor.cjs +29 -30
- package/dist/profiles/editor/profileEditor.cjs.map +1 -1
- package/dist/profiles/editor/profileEditor.d.ts.map +1 -1
- package/dist/profiles/editor/profileEditor.js +29 -30
- package/dist/profiles/editor/profileEditor.js.map +1 -1
- package/dist/profiles/editor/profileEditorPreview.cjs +44 -43
- package/dist/profiles/editor/profileEditorPreview.cjs.map +1 -1
- package/dist/profiles/editor/profileEditorPreview.d.ts +10 -5
- package/dist/profiles/editor/profileEditorPreview.d.ts.map +1 -1
- package/dist/profiles/editor/profileEditorPreview.js +44 -43
- package/dist/profiles/editor/profileEditorPreview.js.map +1 -1
- package/dist/profiles/editor/profileMappingPreview.cjs +153 -48
- package/dist/profiles/editor/profileMappingPreview.cjs.map +1 -1
- package/dist/profiles/editor/profileMappingPreview.d.ts +16 -2
- package/dist/profiles/editor/profileMappingPreview.d.ts.map +1 -1
- package/dist/profiles/editor/profileMappingPreview.js +155 -50
- package/dist/profiles/editor/profileMappingPreview.js.map +1 -1
- package/dist/profiles/editor/sampleError.cjs +29 -0
- package/dist/profiles/editor/sampleError.cjs.map +1 -0
- package/dist/profiles/editor/sampleError.d.ts +16 -0
- package/dist/profiles/editor/sampleError.d.ts.map +1 -0
- package/dist/profiles/editor/sampleError.js +27 -0
- package/dist/profiles/editor/sampleError.js.map +1 -0
- package/dist/profiles/query/profileSampleResult.cjs.map +1 -1
- package/dist/profiles/query/profileSampleResult.d.ts +2 -0
- package/dist/profiles/query/profileSampleResult.d.ts.map +1 -1
- package/dist/profiles/query/profileSampleResult.js.map +1 -1
- package/dist/profiles/wizard/profileWizardQueryStep.cjs +1 -0
- package/dist/profiles/wizard/profileWizardQueryStep.cjs.map +1 -1
- package/dist/profiles/wizard/profileWizardQueryStep.d.ts +2 -0
- package/dist/profiles/wizard/profileWizardQueryStep.d.ts.map +1 -1
- package/dist/profiles/wizard/profileWizardQueryStep.js +1 -0
- package/dist/profiles/wizard/profileWizardQueryStep.js.map +1 -1
- package/dist/react-grab/core/index.js +1 -1
- package/dist/react-grab/{core-BERtFDWh.js → core-BK5CU6Lb.js} +2 -2
- package/dist/react-grab/index.js +1 -1
- package/dist/react-grab/{renderer-KT3FY3K2.js → renderer-DcHrsQ8k.js} +1 -1
- package/dist/rpc/apiClient.cjs +12 -15
- package/dist/rpc/apiClient.cjs.map +1 -1
- package/dist/rpc/apiClient.js +12 -15
- package/dist/rpc/apiClient.js.map +1 -1
- package/dist/runtime/barrels.json +6481 -6441
- package/dist/runtime/importmap.json +2198 -2190
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/rpc/apiClient.cjs
CHANGED
|
@@ -28,13 +28,13 @@ function createOperationsApiClient(options = {}) {
|
|
|
28
28
|
const prepared = await options.prepareHeaders?.(headers, context);
|
|
29
29
|
return prepared ? new Headers(prepared) : headers;
|
|
30
30
|
}
|
|
31
|
+
const urlOf = (path) => joinUrl(options.baseUrl, path);
|
|
31
32
|
async function request(path, method, init = {}) {
|
|
32
|
-
const url = joinUrl(options.baseUrl, path);
|
|
33
33
|
const headers = await makeHeaders(init.headers, {
|
|
34
34
|
path,
|
|
35
35
|
method
|
|
36
36
|
});
|
|
37
|
-
return fetcher(
|
|
37
|
+
return fetcher(urlOf(path), {
|
|
38
38
|
...init,
|
|
39
39
|
method,
|
|
40
40
|
headers,
|
|
@@ -44,7 +44,7 @@ function createOperationsApiClient(options = {}) {
|
|
|
44
44
|
async function getOpenAPISpec() {
|
|
45
45
|
const response = await request(openApiPath, "GET", { headers: { Accept: `${CLICKY_OPENAPI_MEDIA_TYPE}, application/json;q=0.9` } });
|
|
46
46
|
const parsed = await readResponseBody(response, "json");
|
|
47
|
-
if (!response.ok) throw errorFromResponse(response, "GET", openApiPath, parsed);
|
|
47
|
+
if (!response.ok) throw errorFromResponse(response, "GET", urlOf(openApiPath), parsed);
|
|
48
48
|
return parsed.data;
|
|
49
49
|
}
|
|
50
50
|
async function withDefaults(path, method, params) {
|
|
@@ -62,14 +62,11 @@ function createOperationsApiClient(options = {}) {
|
|
|
62
62
|
const scoped = await withDefaults(resolved.path, upper, resolved.params);
|
|
63
63
|
const accept = headerValue(headers, "Accept");
|
|
64
64
|
if (upper === "GET") {
|
|
65
|
-
const
|
|
66
|
-
const response = await request(
|
|
67
|
-
...headers ? { headers } : {},
|
|
68
|
-
requestUrl
|
|
69
|
-
});
|
|
65
|
+
const requestPath = appendQuery(resolved.path, scoped);
|
|
66
|
+
const response = await request(requestPath, upper, headers ? { headers } : {});
|
|
70
67
|
return parseExecutionResponse(response, await readResponseBody(response, responseKind(accept)), {
|
|
71
68
|
method: upper,
|
|
72
|
-
requestUrl
|
|
69
|
+
requestUrl: urlOf(requestPath)
|
|
73
70
|
});
|
|
74
71
|
}
|
|
75
72
|
const response = await request(resolved.path, upper, {
|
|
@@ -81,7 +78,7 @@ function createOperationsApiClient(options = {}) {
|
|
|
81
78
|
});
|
|
82
79
|
return parseExecutionResponse(response, await readResponseBody(response, responseKind(accept)), {
|
|
83
80
|
method: upper,
|
|
84
|
-
requestUrl: resolved.path
|
|
81
|
+
requestUrl: urlOf(resolved.path)
|
|
85
82
|
});
|
|
86
83
|
},
|
|
87
84
|
async executeCommandBody(path, body, headers) {
|
|
@@ -95,7 +92,7 @@ function createOperationsApiClient(options = {}) {
|
|
|
95
92
|
});
|
|
96
93
|
return parseExecutionResponse(response, await readResponseBody(response, responseKind(accept)), {
|
|
97
94
|
method: "POST",
|
|
98
|
-
requestUrl: path
|
|
95
|
+
requestUrl: urlOf(path)
|
|
99
96
|
});
|
|
100
97
|
},
|
|
101
98
|
async getSchema(path) {
|
|
@@ -116,7 +113,7 @@ function createOperationsApiClient(options = {}) {
|
|
|
116
113
|
});
|
|
117
114
|
return parseExecutionResponse(response, await readResponseBody(response, "json"), {
|
|
118
115
|
method: upper,
|
|
119
|
-
requestUrl: path
|
|
116
|
+
requestUrl: urlOf(path)
|
|
120
117
|
});
|
|
121
118
|
},
|
|
122
119
|
async lookupFilters(path, method, params, headers) {
|
|
@@ -133,7 +130,7 @@ function createOperationsApiClient(options = {}) {
|
|
|
133
130
|
} });
|
|
134
131
|
if (response.status === 404) return { filters: {} };
|
|
135
132
|
const parsed = await readResponseBody(response, "json");
|
|
136
|
-
if (!response.ok) throw errorFromResponse(response, "GET", requestUrl, parsed);
|
|
133
|
+
if (!response.ok) throw errorFromResponse(response, "GET", urlOf(requestUrl), parsed);
|
|
137
134
|
return parsed.data ?? { filters: {} };
|
|
138
135
|
}
|
|
139
136
|
const response = await request(appendQuery(resolved.path, { __lookup: "filters" }), upper, {
|
|
@@ -146,7 +143,7 @@ function createOperationsApiClient(options = {}) {
|
|
|
146
143
|
});
|
|
147
144
|
if (response.status === 404) return { filters: {} };
|
|
148
145
|
const parsed = await readResponseBody(response, "json");
|
|
149
|
-
if (!response.ok) throw errorFromResponse(response, upper, resolved.path, parsed);
|
|
146
|
+
if (!response.ok) throw errorFromResponse(response, upper, urlOf(resolved.path), parsed);
|
|
150
147
|
return parsed.data ?? { filters: {} };
|
|
151
148
|
},
|
|
152
149
|
async lookupFilterOptions(path, method, filterKey, query, extraParams) {
|
|
@@ -161,7 +158,7 @@ function createOperationsApiClient(options = {}) {
|
|
|
161
158
|
const requestPath = appendQuery(resolved.path, queryParams);
|
|
162
159
|
const response = await request(requestPath, upper, { headers: { Accept: "application/json+clicky" } });
|
|
163
160
|
const parsed = await readResponseBody(response, "json");
|
|
164
|
-
if (!response.ok) throw errorFromResponse(response, upper, requestPath, parsed);
|
|
161
|
+
if (!response.ok) throw errorFromResponse(response, upper, urlOf(requestPath), parsed);
|
|
165
162
|
return parsed.data?.filters?.[filterKey] ?? {};
|
|
166
163
|
}
|
|
167
164
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apiClient.cjs","names":["stripTrailingSlashes","stripLeadingSlashes"],"sources":["../../src/rpc/apiClient.ts"],"sourcesContent":["import type { JsonSchemaObject } from \"../components/json-schema-form-types\";\nimport { stripLeadingSlashes, stripTrailingSlashes } from \"../lib/string\";\nimport type {\n ExecutionPagination,\n ExecutionResponse,\n OpenAPISpec,\n OperationLookupFilter,\n OperationLookupResponse,\n OperationRequestValues,\n} from \"./types\";\nimport type { OperationsApiClient } from \"./useOperations\";\n\ntype MaybePromise<T> = T | Promise<T>;\n\n/** Operation catalog: an OpenAPI document whose response schemas may be stubs. */\nexport const CLICKY_OPENAPI_MEDIA_TYPE = \"application/vnd.clicky.openapi+json\";\n\nexport type OperationApiClientContext = {\n path: string;\n method: string;\n};\n\nexport type OperationDefaultParams = (context: {\n path: string;\n method: string;\n params: OperationRequestValues;\n}) => MaybePromise<OperationRequestValues>;\n\nexport type OperationHeadersProvider = (\n headers: Headers,\n context: OperationApiClientContext,\n) => MaybePromise<HeadersInit | void>;\n\nexport type CreateOperationsApiClientOptions = {\n baseUrl?: string;\n openApiPath?: string;\n credentials?: RequestCredentials;\n fetch?: typeof fetch;\n prepareHeaders?: OperationHeadersProvider;\n defaultParams?: OperationDefaultParams;\n};\n\nexport class OperationsApiClientError extends Error {\n status: number | undefined;\n method: string | undefined;\n url: string | undefined;\n responseBody: string | undefined;\n responseData: unknown;\n responseHeaders: Record<string, string> | undefined;\n\n constructor(\n message: string,\n // Each field mirrors the property it lands on, undefined included: a caller\n // rebuilding an error from a partial response should not have to spread\n // conditionally to say \"this one is unknown\".\n options: {\n status?: number | undefined;\n method?: string | undefined;\n url?: string | undefined;\n responseBody?: string | undefined;\n responseData?: unknown;\n responseHeaders?: Record<string, string> | undefined;\n } = {},\n ) {\n super(message);\n this.name = \"OperationsApiClientError\";\n this.status = options.status;\n this.method = options.method;\n this.url = options.url;\n this.responseBody = options.responseBody;\n this.responseData = options.responseData;\n this.responseHeaders = options.responseHeaders;\n }\n}\n\nexport interface SharedOperationsApiClient extends OperationsApiClient {\n lookupFilterOptions(\n path: string,\n method: string,\n filterKey: string,\n query: string,\n extraParams?: OperationRequestValues,\n ): Promise<OperationLookupFilter>;\n executeCommandBody(\n path: string,\n body: Record<string, unknown>,\n headers?: Record<string, string>,\n ): Promise<ExecutionResponse>;\n getSchema(path: string): Promise<JsonSchemaObject | undefined>;\n submitForm(\n path: string,\n method: string,\n body: Record<string, unknown>,\n headers?: Record<string, string>,\n ): Promise<ExecutionResponse>;\n}\n\nexport function createOperationsApiClient(\n options: CreateOperationsApiClientOptions = {},\n): SharedOperationsApiClient {\n const fetcher = options.fetch ?? fetch;\n const openApiPath = options.openApiPath ?? \"/api/openapi.json\";\n\n async function makeHeaders(\n base: HeadersInit | undefined,\n context: OperationApiClientContext,\n ): Promise<Headers> {\n const headers = new Headers(base);\n const prepared = await options.prepareHeaders?.(headers, context);\n return prepared ? new Headers(prepared) : headers;\n }\n\n async function request(\n path: string,\n method: string,\n init: Omit<RequestInit, \"method\" | \"headers\" | \"credentials\"> & {\n headers?: HeadersInit;\n requestUrl?: string;\n } = {},\n ): Promise<Response> {\n const url = joinUrl(options.baseUrl, path);\n const headers = await makeHeaders(init.headers, { path, method });\n return fetcher(url, {\n ...init,\n method,\n headers,\n ...(options.credentials ? { credentials: options.credentials } : {}),\n });\n }\n\n async function getOpenAPISpec(): Promise<OpenAPISpec> {\n const response = await request(openApiPath, \"GET\", {\n // Prefer the catalog projection — the same document with each operation's\n // response schemas stubbed, which nothing here reads and which is over\n // half the bytes. A server that does not serve it answers with the\n // complete document, which parses the same.\n headers: {\n Accept: `${CLICKY_OPENAPI_MEDIA_TYPE}, application/json;q=0.9`,\n },\n });\n const parsed = await readResponseBody(response, \"json\");\n if (!response.ok) {\n throw errorFromResponse(response, \"GET\", openApiPath, parsed);\n }\n return parsed.data as OpenAPISpec;\n }\n\n async function withDefaults(path: string, method: string, params: OperationRequestValues) {\n return (await options.defaultParams?.({ path, method, params })) ?? params;\n }\n\n return {\n getOpenAPISpec,\n\n async executeCommand(path, method, params, headers) {\n const upper = method.toUpperCase();\n const resolved = resolvePathParams(path, params);\n const scoped = await withDefaults(resolved.path, upper, resolved.params);\n const accept = headerValue(headers, \"Accept\");\n\n if (upper === \"GET\") {\n const requestUrl = appendQuery(resolved.path, scoped);\n const response = await request(requestUrl, upper, {\n ...(headers ? { headers } : {}),\n requestUrl,\n });\n return parseExecutionResponse(response, await readResponseBody(response, responseKind(accept)), {\n method: upper,\n requestUrl,\n });\n }\n\n const response = await request(resolved.path, upper, {\n headers: { \"Content-Type\": \"application/json\", ...headers },\n body: JSON.stringify(scoped),\n });\n return parseExecutionResponse(response, await readResponseBody(response, responseKind(accept)), {\n method: upper,\n requestUrl: resolved.path,\n });\n },\n\n async executeCommandBody(path, body, headers) {\n const accept = headerValue(headers, \"Accept\");\n const response = await request(path, \"POST\", {\n headers: { \"Content-Type\": \"application/json\", ...headers },\n body: JSON.stringify(body),\n });\n return parseExecutionResponse(response, await readResponseBody(response, responseKind(accept)), {\n method: \"POST\",\n requestUrl: path,\n });\n },\n\n // getSchema fetches a resource's JSON Schema via content negotiation\n // (Accept: application/schema+json on the same endpoint). It returns\n // undefined when the resource serves no schema (the request falls through to\n // its data representation), so callers can fall back to a parameter form.\n async getSchema(path) {\n const response = await request(path, \"GET\", {\n headers: { Accept: \"application/schema+json\" },\n });\n if (!response.ok) return undefined;\n const contentType = response.headers.get(\"Content-Type\") || \"\";\n if (!contentType.toLowerCase().includes(\"schema\")) return undefined;\n const parsed = await readResponseBody(response, \"json\");\n const data = parsed.data;\n return data && typeof data === \"object\" ? (data as JsonSchemaObject) : undefined;\n },\n\n // submitForm sends a nested JSON body with the given HTTP method (POST to\n // create, PUT to update). Unlike executeCommand it preserves nested objects\n // and arrays — the server reads the raw body (clicky's RequestFromContext),\n // so connection `properties` and profile `provider`/`params`/`columns`\n // survive intact.\n async submitForm(path, method, body, headers) {\n const upper = method.toUpperCase();\n const response = await request(path, upper, {\n headers: { \"Content-Type\": \"application/json\", ...headers },\n body: JSON.stringify(body),\n });\n return parseExecutionResponse(response, await readResponseBody(response, \"json\"), {\n method: upper,\n requestUrl: path,\n });\n },\n\n async lookupFilters(path, method, params, headers) {\n const upper = method.toUpperCase();\n const resolved = resolvePathParams(path, params);\n\n if (upper === \"GET\") {\n const requestUrl = appendQuery(resolved.path, { ...resolved.params, __lookup: \"filters\" });\n const response = await request(requestUrl, \"GET\", {\n headers: { Accept: \"application/json+clicky\", ...headers },\n });\n if (response.status === 404) return { filters: {} };\n const parsed = await readResponseBody(response, \"json\");\n if (!response.ok) throw errorFromResponse(response, \"GET\", requestUrl, parsed);\n return (parsed.data as OperationLookupResponse | undefined) ?? { filters: {} };\n }\n\n const response = await request(appendQuery(resolved.path, { __lookup: \"filters\" }), upper, {\n headers: {\n Accept: \"application/json+clicky\",\n \"Content-Type\": \"application/json\",\n ...headers,\n },\n body: JSON.stringify(resolved.params),\n });\n if (response.status === 404) return { filters: {} };\n const parsed = await readResponseBody(response, \"json\");\n if (!response.ok) throw errorFromResponse(response, upper, resolved.path, parsed);\n return (parsed.data as OperationLookupResponse | undefined) ?? { filters: {} };\n },\n\n async lookupFilterOptions(path, method, filterKey, query, extraParams) {\n const upper = method.toUpperCase();\n // Resolved against the supplied params, as lookupFilters does: a lookup on\n // an operation with a templated path would otherwise request the literal\n // \"{id}\" and the sibling values that scope the search would be lost.\n const resolved = resolvePathParams(path, extraParams ?? {});\n const queryParams = {\n ...resolved.params,\n __lookup: \"filters\",\n __lookup_filter: filterKey,\n __lookup_q: query,\n };\n\n const requestPath = appendQuery(resolved.path, queryParams);\n const response = await request(requestPath, upper, {\n headers: { Accept: \"application/json+clicky\" },\n });\n const parsed = await readResponseBody(response, \"json\");\n if (!response.ok) throw errorFromResponse(response, upper, requestPath, parsed);\n return ((parsed.data as OperationLookupResponse | undefined)?.filters?.[filterKey] ??\n {}) as OperationLookupFilter;\n },\n };\n}\n\nfunction responseKind(accept?: string): \"json\" | \"text\" | \"blob\" {\n if (!accept) return \"json\";\n const normalized = accept.toLowerCase();\n if (normalized.includes(\"application/pdf\")) return \"blob\";\n if (\n normalized.includes(\"text/\") ||\n normalized.includes(\"application/x-yaml\") ||\n normalized.includes(\"application/yaml\")\n ) {\n return \"text\";\n }\n return \"json\";\n}\n\nexport type ParsedBody = {\n data: unknown;\n text: string;\n blob?: Blob;\n contentType: string;\n};\n\nexport async function readResponseBody(response: Response, kind: \"json\" | \"text\" | \"blob\"): Promise<ParsedBody> {\n const contentType = response.headers.get(\"Content-Type\") || \"\";\n if (kind === \"blob\") {\n const blob = await response.blob();\n return { data: undefined, text: \"[binary]\", blob, contentType };\n }\n\n const text = await response.text();\n if (kind === \"text\" || !shouldParseJson(text, contentType)) {\n return { data: text, text, contentType };\n }\n\n try {\n return { data: JSON.parse(text) as unknown, text, contentType };\n } catch {\n return { data: text, text, contentType };\n }\n}\n\nfunction parseExecutionResponse(\n response: Response,\n parsed: ParsedBody,\n context: { method: string; requestUrl: string },\n): ExecutionResponse {\n const headers = responseHeaders(response.headers);\n const data = parsed.data;\n const stdout =\n parsed.blob != null\n ? \"[binary]\"\n : typeof data === \"string\"\n ? data\n : parsed.text || JSON.stringify(data, null, 2);\n const clickyEnvelope = isClickyEnvelope(data);\n\n if (!response.ok && !clickyEnvelope) {\n throw errorFromResponse(response, context.method, context.requestUrl, parsed);\n }\n\n const clickyError = errorFromClickyEnvelope(data);\n const successHeader = headers[\"x-execution-success\"];\n const success = successHeader == null ? response.ok && !clickyError : successHeader !== \"false\";\n const exitCode = parseInt(headers[\"x-exit-code\"] ?? (success ? \"0\" : \"1\"), 10);\n const cli = headers[\"x-cli-command\"];\n const error = headers[\"x-error\"] || clickyError;\n const pagination = paginationFromHeaders(headers);\n\n return {\n success,\n stdout,\n output: stdout,\n exit_code: Number.isFinite(exitCode) ? exitCode : success ? 0 : 1,\n contentType: parsed.contentType || headers[\"content-type\"] || \"application/json\",\n requestUrl: context.requestUrl,\n responseHeaders: headers,\n ...(pagination ? { pagination } : {}),\n ...(cli ? { cli } : {}),\n ...(error ? { error } : {}),\n ...(parsed.blob ? { blob: parsed.blob } : {}),\n ...(parsed.blob == null && typeof data !== \"string\" ? { parsed: data } : {}),\n };\n}\n\n// Exported because every fetch in the package has to fail the same way: with\n// the status, the URL and the parsed body attached, which is what\n// operationErrorDiagnostics reads back out to render ErrorDetails. A second\n// error-from-Response path would silently drop one of those again.\nexport function errorFromResponse(\n response: Response,\n method: string,\n url: string,\n parsed: ParsedBody,\n): OperationsApiClientError {\n const headers = responseHeaders(response.headers);\n const message =\n headers[\"x-error\"] ||\n messageFromBody(parsed.data) ||\n `${method} ${url} failed with ${response.status}: ${\n parsed.text || response.statusText\n }`;\n return new OperationsApiClientError(message, {\n status: response.status,\n method,\n url,\n responseBody: parsed.text,\n responseData: parsed.data,\n responseHeaders: headers,\n });\n}\n\nfunction resolvePathParams(\n path: string,\n params: OperationRequestValues,\n): { path: string; params: OperationRequestValues } {\n const queryParams = { ...params };\n let resolvedPath = path;\n const placeholders = [...path.matchAll(/\\{([^{}]+)\\}/g)]\n .map((match) => match[1])\n .filter((name): name is string => Boolean(name));\n const argValues = parseArgsParam(params.args);\n let consumedArgs = false;\n const consumedDirectValues: string[] = [];\n\n for (const [index, name] of placeholders.entries()) {\n const rawDirectValue = queryParams[name];\n if (Array.isArray(rawDirectValue)) {\n throw new Error(`Path parameter ${name} must be a scalar value`);\n }\n const directValue = rawDirectValue;\n const fallbackValue = directValue || argValues[index];\n if (!fallbackValue) continue;\n\n resolvedPath = resolvedPath.replace(`{${name}}`, encodeURIComponent(fallbackValue));\n delete queryParams[name];\n if (!directValue && argValues[index]) consumedArgs = true;\n if (directValue) consumedDirectValues[index] = directValue;\n }\n\n const argsDuplicateResolvedPath =\n argValues.length > 0 &&\n argValues.length === consumedDirectValues.filter(Boolean).length &&\n argValues.every((value, index) => value === consumedDirectValues[index]);\n\n if (consumedArgs || argsDuplicateResolvedPath) {\n delete queryParams.args;\n }\n\n return { path: resolvedPath, params: stripRunnerParams(queryParams) };\n}\n\nfunction parseArgsParam(value: string | string[] | undefined): string[] {\n if (!value) return [];\n if (Array.isArray(value)) return value.map(String).filter(Boolean);\n const trimmed = value.trim();\n if (!trimmed || trimmed === \"[]\" || trimmed.toLowerCase() === \"null\") return [];\n try {\n const parsed = JSON.parse(trimmed);\n if (Array.isArray(parsed)) return parsed.map(String).filter(Boolean);\n } catch {\n // Fall back to comma-delimited args below.\n }\n return trimmed\n .split(\",\")\n .map((part) => part.trim())\n .filter(Boolean);\n}\n\nfunction stripRunnerParams(params: OperationRequestValues) {\n const next = { ...params };\n delete next.autoRun;\n delete next.__autoRun;\n return next;\n}\n\nfunction appendQuery(path: string, params: OperationRequestValues) {\n const query = new URLSearchParams(\n Object.fromEntries(\n Object.entries(pruneParams(params)).map(([key, value]) => [\n key,\n Array.isArray(value) ? value.join(\",\") : value,\n ]),\n ),\n ).toString();\n if (!query) return path;\n return `${path}${path.includes(\"?\") ? \"&\" : \"?\"}${query}`;\n}\n\nfunction pruneParams(params: OperationRequestValues): OperationRequestValues {\n return Object.fromEntries(\n Object.entries(params).filter(([, value]) => value !== \"\" && value.length > 0),\n );\n}\n\nfunction joinUrl(baseUrl: string | undefined, path: string) {\n if (!baseUrl || /^https?:\\/\\//i.test(path)) return path;\n return `${stripTrailingSlashes(baseUrl)}/${stripLeadingSlashes(path)}`;\n}\n\nfunction headerValue(headers: Record<string, string> | undefined, name: string) {\n const wanted = name.toLowerCase();\n for (const [key, value] of Object.entries(headers ?? {})) {\n if (key.toLowerCase() === wanted) return value;\n }\n return undefined;\n}\n\nfunction responseHeaders(headers: Headers): Record<string, string> {\n const out: Record<string, string> = {};\n headers.forEach((value, key) => {\n out[key.toLowerCase()] = value;\n });\n return out;\n}\n\nfunction paginationFromHeaders(headers: Record<string, string>): ExecutionPagination | undefined {\n const pagination: ExecutionPagination = {};\n const total = integerHeader(headers[\"x-total-count\"]);\n const limit = integerHeader(headers[\"x-page-limit\"]);\n const offset = integerHeader(headers[\"x-page-offset\"]);\n\n if (total !== undefined) pagination.total = total;\n if (limit !== undefined) pagination.limit = limit;\n if (offset !== undefined) pagination.offset = offset;\n\n const relation = headers[\"x-total-relation\"];\n if (relation === \"eq\" || relation === \"gte\") pagination.totalRelation = relation;\n\n const hasMore = booleanHeader(headers[\"x-has-more\"]);\n if (hasMore !== undefined) pagination.hasMore = hasMore;\n\n const cursor = headers[\"x-next-cursor\"];\n if (cursor != null && cursor.trim() !== \"\") pagination.nextCursor = cursor;\n\n if (booleanHeader(headers[\"x-truncated\"]) === true) pagination.truncated = true;\n\n return Object.keys(pagination).length > 0 ? pagination : undefined;\n}\n\nfunction booleanHeader(value: string | undefined): boolean | undefined {\n if (value == null || value.trim() === \"\") return undefined;\n const normalized = value.trim().toLowerCase();\n if (normalized === \"true\") return true;\n if (normalized === \"false\") return false;\n return undefined;\n}\n\nfunction integerHeader(value: string | undefined): number | undefined {\n if (value == null || value.trim() === \"\") return undefined;\n const parsed = parseInt(value, 10);\n return Number.isFinite(parsed) ? parsed : undefined;\n}\n\nfunction shouldParseJson(text: string, contentType: string) {\n const trimmed = text.trim();\n return (\n trimmed !== \"\" &&\n (contentType.toLowerCase().includes(\"json\") ||\n trimmed.startsWith(\"{\") ||\n trimmed.startsWith(\"[\"))\n );\n}\n\nfunction isClickyEnvelope(data: unknown): boolean {\n if (!data || typeof data !== \"object\") return false;\n const body = data as Record<string, unknown>;\n return body.version != null && body.node != null && typeof body.node === \"object\";\n}\n\nfunction readClickyText(node: unknown): string | undefined {\n if (!node || typeof node !== \"object\") return undefined;\n const n = node as Record<string, unknown>;\n if (typeof n.plain === \"string\" && n.plain !== \"\") return n.plain;\n if (typeof n.text === \"string\" && n.text !== \"\") return n.text;\n if (Array.isArray(n.children)) {\n for (const child of n.children) {\n const text = readClickyText(child);\n if (text) return text;\n }\n }\n return undefined;\n}\n\nfunction errorFromClickyEnvelope(data: unknown): string | undefined {\n if (!data || typeof data !== \"object\") return undefined;\n const node = (data as Record<string, unknown>).node;\n if (!node || typeof node !== \"object\") return undefined;\n const n = node as Record<string, unknown>;\n if (n.kind !== \"map\" || !Array.isArray(n.fields)) return undefined;\n\n let errorText: string | undefined;\n let failed = false;\n for (const field of n.fields) {\n if (!field || typeof field !== \"object\") continue;\n const f = field as Record<string, unknown>;\n if (f.name === \"Error\") errorText = readClickyText(f.value);\n if (f.name === \"Success\" && readClickyText(f.value) === \"false\") failed = true;\n }\n return failed ? errorText : undefined;\n}\n\nfunction messageFromBody(data: unknown): string | undefined {\n if (!data || typeof data !== \"object\") return undefined;\n const body = data as Record<string, unknown>;\n if (typeof body.error === \"string\" && body.error) return body.error;\n if (typeof body.message === \"string\" && body.message) return body.message;\n return errorFromClickyEnvelope(data);\n}\n"],"mappings":";;;AAeA,IAAa,4BAA4B;AA2Bz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;CAC9C,MAAM,IAAI;CACV,IAAI,EAAE,SAAS,SAAS,CAAC,MAAM,QAAQ,EAAE,MAAM,GAAG,OAAO,KAAA;CAEzD,IAAI;CACJ,IAAI,SAAS;CACb,KAAK,MAAM,SAAS,EAAE,QAAQ;EAC5B,IAAI,CAAC,SAAS,OAAO,UAAU,UAAU;EACzC,MAAM,IAAI;EACV,IAAI,EAAE,SAAS,SAAS,YAAY,eAAe,EAAE,KAAK;EAC1D,IAAI,EAAE,SAAS,aAAa,eAAe,EAAE,KAAK,MAAM,SAAS,SAAS;CAC5E;CACA,OAAO,SAAS,YAAY,KAAA;AAC9B;AAEA,SAAS,gBAAgB,MAAmC;CAC1D,IAAI,CAAC,QAAQ,OAAO,SAAS,UAAU,OAAO,KAAA;CAC9C,MAAM,OAAO;CACb,IAAI,OAAO,KAAK,UAAU,YAAY,KAAK,OAAO,OAAO,KAAK;CAC9D,IAAI,OAAO,KAAK,YAAY,YAAY,KAAK,SAAS,OAAO,KAAK;CAClE,OAAO,wBAAwB,IAAI;AACrC"}
|
|
1
|
+
{"version":3,"file":"apiClient.cjs","names":["stripTrailingSlashes","stripLeadingSlashes"],"sources":["../../src/rpc/apiClient.ts"],"sourcesContent":["import type { JsonSchemaObject } from \"../components/json-schema-form-types\";\nimport { stripLeadingSlashes, stripTrailingSlashes } from \"../lib/string\";\nimport type {\n ExecutionPagination,\n ExecutionResponse,\n OpenAPISpec,\n OperationLookupFilter,\n OperationLookupResponse,\n OperationRequestValues,\n} from \"./types\";\nimport type { OperationsApiClient } from \"./useOperations\";\n\ntype MaybePromise<T> = T | Promise<T>;\n\n/** Operation catalog: an OpenAPI document whose response schemas may be stubs. */\nexport const CLICKY_OPENAPI_MEDIA_TYPE = \"application/vnd.clicky.openapi+json\";\n\nexport type OperationApiClientContext = {\n path: string;\n method: string;\n};\n\nexport type OperationDefaultParams = (context: {\n path: string;\n method: string;\n params: OperationRequestValues;\n}) => MaybePromise<OperationRequestValues>;\n\nexport type OperationHeadersProvider = (\n headers: Headers,\n context: OperationApiClientContext,\n) => MaybePromise<HeadersInit | void>;\n\nexport type CreateOperationsApiClientOptions = {\n baseUrl?: string;\n openApiPath?: string;\n credentials?: RequestCredentials;\n fetch?: typeof fetch;\n prepareHeaders?: OperationHeadersProvider;\n defaultParams?: OperationDefaultParams;\n};\n\nexport class OperationsApiClientError extends Error {\n status: number | undefined;\n method: string | undefined;\n url: string | undefined;\n responseBody: string | undefined;\n responseData: unknown;\n responseHeaders: Record<string, string> | undefined;\n\n constructor(\n message: string,\n // Each field mirrors the property it lands on, undefined included: a caller\n // rebuilding an error from a partial response should not have to spread\n // conditionally to say \"this one is unknown\".\n options: {\n status?: number | undefined;\n method?: string | undefined;\n url?: string | undefined;\n responseBody?: string | undefined;\n responseData?: unknown;\n responseHeaders?: Record<string, string> | undefined;\n } = {},\n ) {\n super(message);\n this.name = \"OperationsApiClientError\";\n this.status = options.status;\n this.method = options.method;\n this.url = options.url;\n this.responseBody = options.responseBody;\n this.responseData = options.responseData;\n this.responseHeaders = options.responseHeaders;\n }\n}\n\nexport interface SharedOperationsApiClient extends OperationsApiClient {\n lookupFilterOptions(\n path: string,\n method: string,\n filterKey: string,\n query: string,\n extraParams?: OperationRequestValues,\n ): Promise<OperationLookupFilter>;\n executeCommandBody(\n path: string,\n body: Record<string, unknown>,\n headers?: Record<string, string>,\n ): Promise<ExecutionResponse>;\n getSchema(path: string): Promise<JsonSchemaObject | undefined>;\n submitForm(\n path: string,\n method: string,\n body: Record<string, unknown>,\n headers?: Record<string, string>,\n ): Promise<ExecutionResponse>;\n}\n\nexport function createOperationsApiClient(\n options: CreateOperationsApiClientOptions = {},\n): SharedOperationsApiClient {\n const fetcher = options.fetch ?? fetch;\n const openApiPath = options.openApiPath ?? \"/api/openapi.json\";\n\n async function makeHeaders(\n base: HeadersInit | undefined,\n context: OperationApiClientContext,\n ): Promise<Headers> {\n const headers = new Headers(base);\n const prepared = await options.prepareHeaders?.(headers, context);\n return prepared ? new Headers(prepared) : headers;\n }\n\n // urlOf is the URL a path is fetched at, which responses and errors report:\n // a caller re-requesting it (a download, a format switch) must reach the\n // same server mount the client did.\n const urlOf = (path: string) => joinUrl(options.baseUrl, path);\n\n async function request(\n path: string,\n method: string,\n init: Omit<RequestInit, \"method\" | \"headers\" | \"credentials\"> & {\n headers?: HeadersInit;\n } = {},\n ): Promise<Response> {\n const headers = await makeHeaders(init.headers, { path, method });\n return fetcher(urlOf(path), {\n ...init,\n method,\n headers,\n ...(options.credentials ? { credentials: options.credentials } : {}),\n });\n }\n\n async function getOpenAPISpec(): Promise<OpenAPISpec> {\n const response = await request(openApiPath, \"GET\", {\n // Prefer the catalog projection — the same document with each operation's\n // response schemas stubbed, which nothing here reads and which is over\n // half the bytes. A server that does not serve it answers with the\n // complete document, which parses the same.\n headers: {\n Accept: `${CLICKY_OPENAPI_MEDIA_TYPE}, application/json;q=0.9`,\n },\n });\n const parsed = await readResponseBody(response, \"json\");\n if (!response.ok) {\n throw errorFromResponse(response, \"GET\", urlOf(openApiPath), parsed);\n }\n return parsed.data as OpenAPISpec;\n }\n\n async function withDefaults(path: string, method: string, params: OperationRequestValues) {\n return (await options.defaultParams?.({ path, method, params })) ?? params;\n }\n\n return {\n getOpenAPISpec,\n\n async executeCommand(path, method, params, headers) {\n const upper = method.toUpperCase();\n const resolved = resolvePathParams(path, params);\n const scoped = await withDefaults(resolved.path, upper, resolved.params);\n const accept = headerValue(headers, \"Accept\");\n\n if (upper === \"GET\") {\n const requestPath = appendQuery(resolved.path, scoped);\n const response = await request(requestPath, upper, headers ? { headers } : {});\n return parseExecutionResponse(response, await readResponseBody(response, responseKind(accept)), {\n method: upper,\n requestUrl: urlOf(requestPath),\n });\n }\n\n const response = await request(resolved.path, upper, {\n headers: { \"Content-Type\": \"application/json\", ...headers },\n body: JSON.stringify(scoped),\n });\n return parseExecutionResponse(response, await readResponseBody(response, responseKind(accept)), {\n method: upper,\n requestUrl: urlOf(resolved.path),\n });\n },\n\n async executeCommandBody(path, body, headers) {\n const accept = headerValue(headers, \"Accept\");\n const response = await request(path, \"POST\", {\n headers: { \"Content-Type\": \"application/json\", ...headers },\n body: JSON.stringify(body),\n });\n return parseExecutionResponse(response, await readResponseBody(response, responseKind(accept)), {\n method: \"POST\",\n requestUrl: urlOf(path),\n });\n },\n\n // getSchema fetches a resource's JSON Schema via content negotiation\n // (Accept: application/schema+json on the same endpoint). It returns\n // undefined when the resource serves no schema (the request falls through to\n // its data representation), so callers can fall back to a parameter form.\n async getSchema(path) {\n const response = await request(path, \"GET\", {\n headers: { Accept: \"application/schema+json\" },\n });\n if (!response.ok) return undefined;\n const contentType = response.headers.get(\"Content-Type\") || \"\";\n if (!contentType.toLowerCase().includes(\"schema\")) return undefined;\n const parsed = await readResponseBody(response, \"json\");\n const data = parsed.data;\n return data && typeof data === \"object\" ? (data as JsonSchemaObject) : undefined;\n },\n\n // submitForm sends a nested JSON body with the given HTTP method (POST to\n // create, PUT to update). Unlike executeCommand it preserves nested objects\n // and arrays — the server reads the raw body (clicky's RequestFromContext),\n // so connection `properties` and profile `provider`/`params`/`columns`\n // survive intact.\n async submitForm(path, method, body, headers) {\n const upper = method.toUpperCase();\n const response = await request(path, upper, {\n headers: { \"Content-Type\": \"application/json\", ...headers },\n body: JSON.stringify(body),\n });\n return parseExecutionResponse(response, await readResponseBody(response, \"json\"), {\n method: upper,\n requestUrl: urlOf(path),\n });\n },\n\n async lookupFilters(path, method, params, headers) {\n const upper = method.toUpperCase();\n const resolved = resolvePathParams(path, params);\n\n if (upper === \"GET\") {\n const requestUrl = appendQuery(resolved.path, { ...resolved.params, __lookup: \"filters\" });\n const response = await request(requestUrl, \"GET\", {\n headers: { Accept: \"application/json+clicky\", ...headers },\n });\n if (response.status === 404) return { filters: {} };\n const parsed = await readResponseBody(response, \"json\");\n if (!response.ok) throw errorFromResponse(response, \"GET\", urlOf(requestUrl), parsed);\n return (parsed.data as OperationLookupResponse | undefined) ?? { filters: {} };\n }\n\n const response = await request(appendQuery(resolved.path, { __lookup: \"filters\" }), upper, {\n headers: {\n Accept: \"application/json+clicky\",\n \"Content-Type\": \"application/json\",\n ...headers,\n },\n body: JSON.stringify(resolved.params),\n });\n if (response.status === 404) return { filters: {} };\n const parsed = await readResponseBody(response, \"json\");\n if (!response.ok) throw errorFromResponse(response, upper, urlOf(resolved.path), parsed);\n return (parsed.data as OperationLookupResponse | undefined) ?? { filters: {} };\n },\n\n async lookupFilterOptions(path, method, filterKey, query, extraParams) {\n const upper = method.toUpperCase();\n // Resolved against the supplied params, as lookupFilters does: a lookup on\n // an operation with a templated path would otherwise request the literal\n // \"{id}\" and the sibling values that scope the search would be lost.\n const resolved = resolvePathParams(path, extraParams ?? {});\n const queryParams = {\n ...resolved.params,\n __lookup: \"filters\",\n __lookup_filter: filterKey,\n __lookup_q: query,\n };\n\n const requestPath = appendQuery(resolved.path, queryParams);\n const response = await request(requestPath, upper, {\n headers: { Accept: \"application/json+clicky\" },\n });\n const parsed = await readResponseBody(response, \"json\");\n if (!response.ok) throw errorFromResponse(response, upper, urlOf(requestPath), parsed);\n return ((parsed.data as OperationLookupResponse | undefined)?.filters?.[filterKey] ??\n {}) as OperationLookupFilter;\n },\n };\n}\n\nfunction responseKind(accept?: string): \"json\" | \"text\" | \"blob\" {\n if (!accept) return \"json\";\n const normalized = accept.toLowerCase();\n if (normalized.includes(\"application/pdf\")) return \"blob\";\n if (\n normalized.includes(\"text/\") ||\n normalized.includes(\"application/x-yaml\") ||\n normalized.includes(\"application/yaml\")\n ) {\n return \"text\";\n }\n return \"json\";\n}\n\nexport type ParsedBody = {\n data: unknown;\n text: string;\n blob?: Blob;\n contentType: string;\n};\n\nexport async function readResponseBody(response: Response, kind: \"json\" | \"text\" | \"blob\"): Promise<ParsedBody> {\n const contentType = response.headers.get(\"Content-Type\") || \"\";\n if (kind === \"blob\") {\n const blob = await response.blob();\n return { data: undefined, text: \"[binary]\", blob, contentType };\n }\n\n const text = await response.text();\n if (kind === \"text\" || !shouldParseJson(text, contentType)) {\n return { data: text, text, contentType };\n }\n\n try {\n return { data: JSON.parse(text) as unknown, text, contentType };\n } catch {\n return { data: text, text, contentType };\n }\n}\n\nfunction parseExecutionResponse(\n response: Response,\n parsed: ParsedBody,\n context: { method: string; requestUrl: string },\n): ExecutionResponse {\n const headers = responseHeaders(response.headers);\n const data = parsed.data;\n const stdout =\n parsed.blob != null\n ? \"[binary]\"\n : typeof data === \"string\"\n ? data\n : parsed.text || JSON.stringify(data, null, 2);\n const clickyEnvelope = isClickyEnvelope(data);\n\n if (!response.ok && !clickyEnvelope) {\n throw errorFromResponse(response, context.method, context.requestUrl, parsed);\n }\n\n const clickyError = errorFromClickyEnvelope(data);\n const successHeader = headers[\"x-execution-success\"];\n const success = successHeader == null ? response.ok && !clickyError : successHeader !== \"false\";\n const exitCode = parseInt(headers[\"x-exit-code\"] ?? (success ? \"0\" : \"1\"), 10);\n const cli = headers[\"x-cli-command\"];\n const error = headers[\"x-error\"] || clickyError;\n const pagination = paginationFromHeaders(headers);\n\n return {\n success,\n stdout,\n output: stdout,\n exit_code: Number.isFinite(exitCode) ? exitCode : success ? 0 : 1,\n contentType: parsed.contentType || headers[\"content-type\"] || \"application/json\",\n requestUrl: context.requestUrl,\n responseHeaders: headers,\n ...(pagination ? { pagination } : {}),\n ...(cli ? { cli } : {}),\n ...(error ? { error } : {}),\n ...(parsed.blob ? { blob: parsed.blob } : {}),\n ...(parsed.blob == null && typeof data !== \"string\" ? { parsed: data } : {}),\n };\n}\n\n// Exported because every fetch in the package has to fail the same way: with\n// the status, the URL and the parsed body attached, which is what\n// operationErrorDiagnostics reads back out to render ErrorDetails. A second\n// error-from-Response path would silently drop one of those again.\nexport function errorFromResponse(\n response: Response,\n method: string,\n url: string,\n parsed: ParsedBody,\n): OperationsApiClientError {\n const headers = responseHeaders(response.headers);\n const message =\n headers[\"x-error\"] ||\n messageFromBody(parsed.data) ||\n `${method} ${url} failed with ${response.status}: ${\n parsed.text || response.statusText\n }`;\n return new OperationsApiClientError(message, {\n status: response.status,\n method,\n url,\n responseBody: parsed.text,\n responseData: parsed.data,\n responseHeaders: headers,\n });\n}\n\nfunction resolvePathParams(\n path: string,\n params: OperationRequestValues,\n): { path: string; params: OperationRequestValues } {\n const queryParams = { ...params };\n let resolvedPath = path;\n const placeholders = [...path.matchAll(/\\{([^{}]+)\\}/g)]\n .map((match) => match[1])\n .filter((name): name is string => Boolean(name));\n const argValues = parseArgsParam(params.args);\n let consumedArgs = false;\n const consumedDirectValues: string[] = [];\n\n for (const [index, name] of placeholders.entries()) {\n const rawDirectValue = queryParams[name];\n if (Array.isArray(rawDirectValue)) {\n throw new Error(`Path parameter ${name} must be a scalar value`);\n }\n const directValue = rawDirectValue;\n const fallbackValue = directValue || argValues[index];\n if (!fallbackValue) continue;\n\n resolvedPath = resolvedPath.replace(`{${name}}`, encodeURIComponent(fallbackValue));\n delete queryParams[name];\n if (!directValue && argValues[index]) consumedArgs = true;\n if (directValue) consumedDirectValues[index] = directValue;\n }\n\n const argsDuplicateResolvedPath =\n argValues.length > 0 &&\n argValues.length === consumedDirectValues.filter(Boolean).length &&\n argValues.every((value, index) => value === consumedDirectValues[index]);\n\n if (consumedArgs || argsDuplicateResolvedPath) {\n delete queryParams.args;\n }\n\n return { path: resolvedPath, params: stripRunnerParams(queryParams) };\n}\n\nfunction parseArgsParam(value: string | string[] | undefined): string[] {\n if (!value) return [];\n if (Array.isArray(value)) return value.map(String).filter(Boolean);\n const trimmed = value.trim();\n if (!trimmed || trimmed === \"[]\" || trimmed.toLowerCase() === \"null\") return [];\n try {\n const parsed = JSON.parse(trimmed);\n if (Array.isArray(parsed)) return parsed.map(String).filter(Boolean);\n } catch {\n // Fall back to comma-delimited args below.\n }\n return trimmed\n .split(\",\")\n .map((part) => part.trim())\n .filter(Boolean);\n}\n\nfunction stripRunnerParams(params: OperationRequestValues) {\n const next = { ...params };\n delete next.autoRun;\n delete next.__autoRun;\n return next;\n}\n\nfunction appendQuery(path: string, params: OperationRequestValues) {\n const query = new URLSearchParams(\n Object.fromEntries(\n Object.entries(pruneParams(params)).map(([key, value]) => [\n key,\n Array.isArray(value) ? value.join(\",\") : value,\n ]),\n ),\n ).toString();\n if (!query) return path;\n return `${path}${path.includes(\"?\") ? \"&\" : \"?\"}${query}`;\n}\n\nfunction pruneParams(params: OperationRequestValues): OperationRequestValues {\n return Object.fromEntries(\n Object.entries(params).filter(([, value]) => value !== \"\" && value.length > 0),\n );\n}\n\nfunction joinUrl(baseUrl: string | undefined, path: string) {\n if (!baseUrl || /^https?:\\/\\//i.test(path)) return path;\n return `${stripTrailingSlashes(baseUrl)}/${stripLeadingSlashes(path)}`;\n}\n\nfunction headerValue(headers: Record<string, string> | undefined, name: string) {\n const wanted = name.toLowerCase();\n for (const [key, value] of Object.entries(headers ?? {})) {\n if (key.toLowerCase() === wanted) return value;\n }\n return undefined;\n}\n\nfunction responseHeaders(headers: Headers): Record<string, string> {\n const out: Record<string, string> = {};\n headers.forEach((value, key) => {\n out[key.toLowerCase()] = value;\n });\n return out;\n}\n\nfunction paginationFromHeaders(headers: Record<string, string>): ExecutionPagination | undefined {\n const pagination: ExecutionPagination = {};\n const total = integerHeader(headers[\"x-total-count\"]);\n const limit = integerHeader(headers[\"x-page-limit\"]);\n const offset = integerHeader(headers[\"x-page-offset\"]);\n\n if (total !== undefined) pagination.total = total;\n if (limit !== undefined) pagination.limit = limit;\n if (offset !== undefined) pagination.offset = offset;\n\n const relation = headers[\"x-total-relation\"];\n if (relation === \"eq\" || relation === \"gte\") pagination.totalRelation = relation;\n\n const hasMore = booleanHeader(headers[\"x-has-more\"]);\n if (hasMore !== undefined) pagination.hasMore = hasMore;\n\n const cursor = headers[\"x-next-cursor\"];\n if (cursor != null && cursor.trim() !== \"\") pagination.nextCursor = cursor;\n\n if (booleanHeader(headers[\"x-truncated\"]) === true) pagination.truncated = true;\n\n return Object.keys(pagination).length > 0 ? pagination : undefined;\n}\n\nfunction booleanHeader(value: string | undefined): boolean | undefined {\n if (value == null || value.trim() === \"\") return undefined;\n const normalized = value.trim().toLowerCase();\n if (normalized === \"true\") return true;\n if (normalized === \"false\") return false;\n return undefined;\n}\n\nfunction integerHeader(value: string | undefined): number | undefined {\n if (value == null || value.trim() === \"\") return undefined;\n const parsed = parseInt(value, 10);\n return Number.isFinite(parsed) ? parsed : undefined;\n}\n\nfunction shouldParseJson(text: string, contentType: string) {\n const trimmed = text.trim();\n return (\n trimmed !== \"\" &&\n (contentType.toLowerCase().includes(\"json\") ||\n trimmed.startsWith(\"{\") ||\n trimmed.startsWith(\"[\"))\n );\n}\n\nfunction isClickyEnvelope(data: unknown): boolean {\n if (!data || typeof data !== \"object\") return false;\n const body = data as Record<string, unknown>;\n return body.version != null && body.node != null && typeof body.node === \"object\";\n}\n\nfunction readClickyText(node: unknown): string | undefined {\n if (!node || typeof node !== \"object\") return undefined;\n const n = node as Record<string, unknown>;\n if (typeof n.plain === \"string\" && n.plain !== \"\") return n.plain;\n if (typeof n.text === \"string\" && n.text !== \"\") return n.text;\n if (Array.isArray(n.children)) {\n for (const child of n.children) {\n const text = readClickyText(child);\n if (text) return text;\n }\n }\n return undefined;\n}\n\nfunction errorFromClickyEnvelope(data: unknown): string | undefined {\n if (!data || typeof data !== \"object\") return undefined;\n const node = (data as Record<string, unknown>).node;\n if (!node || typeof node !== \"object\") return undefined;\n const n = node as Record<string, unknown>;\n if (n.kind !== \"map\" || !Array.isArray(n.fields)) return undefined;\n\n let errorText: string | undefined;\n let failed = false;\n for (const field of n.fields) {\n if (!field || typeof field !== \"object\") continue;\n const f = field as Record<string, unknown>;\n if (f.name === \"Error\") errorText = readClickyText(f.value);\n if (f.name === \"Success\" && readClickyText(f.value) === \"false\") failed = true;\n }\n return failed ? errorText : undefined;\n}\n\nfunction messageFromBody(data: unknown): string | undefined {\n if (!data || typeof data !== \"object\") return undefined;\n const body = data as Record<string, unknown>;\n if (typeof body.error === \"string\" && body.error) return body.error;\n if (typeof body.message === \"string\" && body.message) return body.message;\n return errorFromClickyEn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,wBAAwB,MAAmC;CAClE,IAAI,CAAC,QAAQ,OAAO,SAAS,UAAU,OAAO,KAAA;CAC9C,MAAM,OAAQ,KAAiC;CAC/C,IAAI,CAAC,QAAQ,OAAO,SAAS,UAAU,OAAO,KAAA;CAC9C,MAAM,IAAI;CACV,IAAI,EAAE,SAAS,SAAS,CAAC,MAAM,QAAQ,EAAE,MAAM,GAAG,OAAO,KAAA;CAEzD,IAAI;CACJ,IAAI,SAAS;CACb,KAAK,MAAM,SAAS,EAAE,QAAQ;EAC5B,IAAI,CAAC,SAAS,OAAO,UAAU,UAAU;EACzC,MAAM,IAAI;EACV,IAAI,EAAE,SAAS,SAAS,YAAY,eAAe,EAAE,KAAK;EAC1D,IAAI,EAAE,SAAS,aAAa,eAAe,EAAE,KAAK,MAAM,SAAS,SAAS;CAC5E;CACA,OAAO,SAAS,YAAY,KAAA;AAC9B;AAEA,SAAS,gBAAgB,MAAmC;CAC1D,IAAI,CAAC,QAAQ,OAAO,SAAS,UAAU,OAAO,KAAA;CAC9C,MAAM,OAAO;CACb,IAAI,OAAO,KAAK,UAAU,YAAY,KAAK,OAAO,OAAO,KAAK;CAC9D,IAAI,OAAO,KAAK,YAAY,YAAY,KAAK,SAAS,OAAO,KAAK;CAClE,OAAO,wBAAwB,IAAI;AACrC"}
|
package/dist/rpc/apiClient.js
CHANGED
|
@@ -28,13 +28,13 @@ function createOperationsApiClient(options = {}) {
|
|
|
28
28
|
const prepared = await options.prepareHeaders?.(headers, context);
|
|
29
29
|
return prepared ? new Headers(prepared) : headers;
|
|
30
30
|
}
|
|
31
|
+
const urlOf = (path) => joinUrl(options.baseUrl, path);
|
|
31
32
|
async function request(path, method, init = {}) {
|
|
32
|
-
const url = joinUrl(options.baseUrl, path);
|
|
33
33
|
const headers = await makeHeaders(init.headers, {
|
|
34
34
|
path,
|
|
35
35
|
method
|
|
36
36
|
});
|
|
37
|
-
return fetcher(
|
|
37
|
+
return fetcher(urlOf(path), {
|
|
38
38
|
...init,
|
|
39
39
|
method,
|
|
40
40
|
headers,
|
|
@@ -44,7 +44,7 @@ function createOperationsApiClient(options = {}) {
|
|
|
44
44
|
async function getOpenAPISpec() {
|
|
45
45
|
const response = await request(openApiPath, "GET", { headers: { Accept: `${CLICKY_OPENAPI_MEDIA_TYPE}, application/json;q=0.9` } });
|
|
46
46
|
const parsed = await readResponseBody(response, "json");
|
|
47
|
-
if (!response.ok) throw errorFromResponse(response, "GET", openApiPath, parsed);
|
|
47
|
+
if (!response.ok) throw errorFromResponse(response, "GET", urlOf(openApiPath), parsed);
|
|
48
48
|
return parsed.data;
|
|
49
49
|
}
|
|
50
50
|
async function withDefaults(path, method, params) {
|
|
@@ -62,14 +62,11 @@ function createOperationsApiClient(options = {}) {
|
|
|
62
62
|
const scoped = await withDefaults(resolved.path, upper, resolved.params);
|
|
63
63
|
const accept = headerValue(headers, "Accept");
|
|
64
64
|
if (upper === "GET") {
|
|
65
|
-
const
|
|
66
|
-
const response = await request(
|
|
67
|
-
...headers ? { headers } : {},
|
|
68
|
-
requestUrl
|
|
69
|
-
});
|
|
65
|
+
const requestPath = appendQuery(resolved.path, scoped);
|
|
66
|
+
const response = await request(requestPath, upper, headers ? { headers } : {});
|
|
70
67
|
return parseExecutionResponse(response, await readResponseBody(response, responseKind(accept)), {
|
|
71
68
|
method: upper,
|
|
72
|
-
requestUrl
|
|
69
|
+
requestUrl: urlOf(requestPath)
|
|
73
70
|
});
|
|
74
71
|
}
|
|
75
72
|
const response = await request(resolved.path, upper, {
|
|
@@ -81,7 +78,7 @@ function createOperationsApiClient(options = {}) {
|
|
|
81
78
|
});
|
|
82
79
|
return parseExecutionResponse(response, await readResponseBody(response, responseKind(accept)), {
|
|
83
80
|
method: upper,
|
|
84
|
-
requestUrl: resolved.path
|
|
81
|
+
requestUrl: urlOf(resolved.path)
|
|
85
82
|
});
|
|
86
83
|
},
|
|
87
84
|
async executeCommandBody(path, body, headers) {
|
|
@@ -95,7 +92,7 @@ function createOperationsApiClient(options = {}) {
|
|
|
95
92
|
});
|
|
96
93
|
return parseExecutionResponse(response, await readResponseBody(response, responseKind(accept)), {
|
|
97
94
|
method: "POST",
|
|
98
|
-
requestUrl: path
|
|
95
|
+
requestUrl: urlOf(path)
|
|
99
96
|
});
|
|
100
97
|
},
|
|
101
98
|
async getSchema(path) {
|
|
@@ -116,7 +113,7 @@ function createOperationsApiClient(options = {}) {
|
|
|
116
113
|
});
|
|
117
114
|
return parseExecutionResponse(response, await readResponseBody(response, "json"), {
|
|
118
115
|
method: upper,
|
|
119
|
-
requestUrl: path
|
|
116
|
+
requestUrl: urlOf(path)
|
|
120
117
|
});
|
|
121
118
|
},
|
|
122
119
|
async lookupFilters(path, method, params, headers) {
|
|
@@ -133,7 +130,7 @@ function createOperationsApiClient(options = {}) {
|
|
|
133
130
|
} });
|
|
134
131
|
if (response.status === 404) return { filters: {} };
|
|
135
132
|
const parsed = await readResponseBody(response, "json");
|
|
136
|
-
if (!response.ok) throw errorFromResponse(response, "GET", requestUrl, parsed);
|
|
133
|
+
if (!response.ok) throw errorFromResponse(response, "GET", urlOf(requestUrl), parsed);
|
|
137
134
|
return parsed.data ?? { filters: {} };
|
|
138
135
|
}
|
|
139
136
|
const response = await request(appendQuery(resolved.path, { __lookup: "filters" }), upper, {
|
|
@@ -146,7 +143,7 @@ function createOperationsApiClient(options = {}) {
|
|
|
146
143
|
});
|
|
147
144
|
if (response.status === 404) return { filters: {} };
|
|
148
145
|
const parsed = await readResponseBody(response, "json");
|
|
149
|
-
if (!response.ok) throw errorFromResponse(response, upper, resolved.path, parsed);
|
|
146
|
+
if (!response.ok) throw errorFromResponse(response, upper, urlOf(resolved.path), parsed);
|
|
150
147
|
return parsed.data ?? { filters: {} };
|
|
151
148
|
},
|
|
152
149
|
async lookupFilterOptions(path, method, filterKey, query, extraParams) {
|
|
@@ -161,7 +158,7 @@ function createOperationsApiClient(options = {}) {
|
|
|
161
158
|
const requestPath = appendQuery(resolved.path, queryParams);
|
|
162
159
|
const response = await request(requestPath, upper, { headers: { Accept: "application/json+clicky" } });
|
|
163
160
|
const parsed = await readResponseBody(response, "json");
|
|
164
|
-
if (!response.ok) throw errorFromResponse(response, upper, requestPath, parsed);
|
|
161
|
+
if (!response.ok) throw errorFromResponse(response, upper, urlOf(requestPath), parsed);
|
|
165
162
|
return parsed.data?.filters?.[filterKey] ?? {};
|
|
166
163
|
}
|
|
167
164
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apiClient.js","names":[],"sources":["../../src/rpc/apiClient.ts"],"sourcesContent":["import type { JsonSchemaObject } from \"../components/json-schema-form-types\";\nimport { stripLeadingSlashes, stripTrailingSlashes } from \"../lib/string\";\nimport type {\n ExecutionPagination,\n ExecutionResponse,\n OpenAPISpec,\n OperationLookupFilter,\n OperationLookupResponse,\n OperationRequestValues,\n} from \"./types\";\nimport type { OperationsApiClient } from \"./useOperations\";\n\ntype MaybePromise<T> = T | Promise<T>;\n\n/** Operation catalog: an OpenAPI document whose response schemas may be stubs. */\nexport const CLICKY_OPENAPI_MEDIA_TYPE = \"application/vnd.clicky.openapi+json\";\n\nexport type OperationApiClientContext = {\n path: string;\n method: string;\n};\n\nexport type OperationDefaultParams = (context: {\n path: string;\n method: string;\n params: OperationRequestValues;\n}) => MaybePromise<OperationRequestValues>;\n\nexport type OperationHeadersProvider = (\n headers: Headers,\n context: OperationApiClientContext,\n) => MaybePromise<HeadersInit | void>;\n\nexport type CreateOperationsApiClientOptions = {\n baseUrl?: string;\n openApiPath?: string;\n credentials?: RequestCredentials;\n fetch?: typeof fetch;\n prepareHeaders?: OperationHeadersProvider;\n defaultParams?: OperationDefaultParams;\n};\n\nexport class OperationsApiClientError extends Error {\n status: number | undefined;\n method: string | undefined;\n url: string | undefined;\n responseBody: string | undefined;\n responseData: unknown;\n responseHeaders: Record<string, string> | undefined;\n\n constructor(\n message: string,\n // Each field mirrors the property it lands on, undefined included: a caller\n // rebuilding an error from a partial response should not have to spread\n // conditionally to say \"this one is unknown\".\n options: {\n status?: number | undefined;\n method?: string | undefined;\n url?: string | undefined;\n responseBody?: string | undefined;\n responseData?: unknown;\n responseHeaders?: Record<string, string> | undefined;\n } = {},\n ) {\n super(message);\n this.name = \"OperationsApiClientError\";\n this.status = options.status;\n this.method = options.method;\n this.url = options.url;\n this.responseBody = options.responseBody;\n this.responseData = options.responseData;\n this.responseHeaders = options.responseHeaders;\n }\n}\n\nexport interface SharedOperationsApiClient extends OperationsApiClient {\n lookupFilterOptions(\n path: string,\n method: string,\n filterKey: string,\n query: string,\n extraParams?: OperationRequestValues,\n ): Promise<OperationLookupFilter>;\n executeCommandBody(\n path: string,\n body: Record<string, unknown>,\n headers?: Record<string, string>,\n ): Promise<ExecutionResponse>;\n getSchema(path: string): Promise<JsonSchemaObject | undefined>;\n submitForm(\n path: string,\n method: string,\n body: Record<string, unknown>,\n headers?: Record<string, string>,\n ): Promise<ExecutionResponse>;\n}\n\nexport function createOperationsApiClient(\n options: CreateOperationsApiClientOptions = {},\n): SharedOperationsApiClient {\n const fetcher = options.fetch ?? fetch;\n const openApiPath = options.openApiPath ?? \"/api/openapi.json\";\n\n async function makeHeaders(\n base: HeadersInit | undefined,\n context: OperationApiClientContext,\n ): Promise<Headers> {\n const headers = new Headers(base);\n const prepared = await options.prepareHeaders?.(headers, context);\n return prepared ? new Headers(prepared) : headers;\n }\n\n async function request(\n path: string,\n method: string,\n init: Omit<RequestInit, \"method\" | \"headers\" | \"credentials\"> & {\n headers?: HeadersInit;\n requestUrl?: string;\n } = {},\n ): Promise<Response> {\n const url = joinUrl(options.baseUrl, path);\n const headers = await makeHeaders(init.headers, { path, method });\n return fetcher(url, {\n ...init,\n method,\n headers,\n ...(options.credentials ? { credentials: options.credentials } : {}),\n });\n }\n\n async function getOpenAPISpec(): Promise<OpenAPISpec> {\n const response = await request(openApiPath, \"GET\", {\n // Prefer the catalog projection — the same document with each operation's\n // response schemas stubbed, which nothing here reads and which is over\n // half the bytes. A server that does not serve it answers with the\n // complete document, which parses the same.\n headers: {\n Accept: `${CLICKY_OPENAPI_MEDIA_TYPE}, application/json;q=0.9`,\n },\n });\n const parsed = await readResponseBody(response, \"json\");\n if (!response.ok) {\n throw errorFromResponse(response, \"GET\", openApiPath, parsed);\n }\n return parsed.data as OpenAPISpec;\n }\n\n async function withDefaults(path: string, method: string, params: OperationRequestValues) {\n return (await options.defaultParams?.({ path, method, params })) ?? params;\n }\n\n return {\n getOpenAPISpec,\n\n async executeCommand(path, method, params, headers) {\n const upper = method.toUpperCase();\n const resolved = resolvePathParams(path, params);\n const scoped = await withDefaults(resolved.path, upper, resolved.params);\n const accept = headerValue(headers, \"Accept\");\n\n if (upper === \"GET\") {\n const requestUrl = appendQuery(resolved.path, scoped);\n const response = await request(requestUrl, upper, {\n ...(headers ? { headers } : {}),\n requestUrl,\n });\n return parseExecutionResponse(response, await readResponseBody(response, responseKind(accept)), {\n method: upper,\n requestUrl,\n });\n }\n\n const response = await request(resolved.path, upper, {\n headers: { \"Content-Type\": \"application/json\", ...headers },\n body: JSON.stringify(scoped),\n });\n return parseExecutionResponse(response, await readResponseBody(response, responseKind(accept)), {\n method: upper,\n requestUrl: resolved.path,\n });\n },\n\n async executeCommandBody(path, body, headers) {\n const accept = headerValue(headers, \"Accept\");\n const response = await request(path, \"POST\", {\n headers: { \"Content-Type\": \"application/json\", ...headers },\n body: JSON.stringify(body),\n });\n return parseExecutionResponse(response, await readResponseBody(response, responseKind(accept)), {\n method: \"POST\",\n requestUrl: path,\n });\n },\n\n // getSchema fetches a resource's JSON Schema via content negotiation\n // (Accept: application/schema+json on the same endpoint). It returns\n // undefined when the resource serves no schema (the request falls through to\n // its data representation), so callers can fall back to a parameter form.\n async getSchema(path) {\n const response = await request(path, \"GET\", {\n headers: { Accept: \"application/schema+json\" },\n });\n if (!response.ok) return undefined;\n const contentType = response.headers.get(\"Content-Type\") || \"\";\n if (!contentType.toLowerCase().includes(\"schema\")) return undefined;\n const parsed = await readResponseBody(response, \"json\");\n const data = parsed.data;\n return data && typeof data === \"object\" ? (data as JsonSchemaObject) : undefined;\n },\n\n // submitForm sends a nested JSON body with the given HTTP method (POST to\n // create, PUT to update). Unlike executeCommand it preserves nested objects\n // and arrays — the server reads the raw body (clicky's RequestFromContext),\n // so connection `properties` and profile `provider`/`params`/`columns`\n // survive intact.\n async submitForm(path, method, body, headers) {\n const upper = method.toUpperCase();\n const response = await request(path, upper, {\n headers: { \"Content-Type\": \"application/json\", ...headers },\n body: JSON.stringify(body),\n });\n return parseExecutionResponse(response, await readResponseBody(response, \"json\"), {\n method: upper,\n requestUrl: path,\n });\n },\n\n async lookupFilters(path, method, params, headers) {\n const upper = method.toUpperCase();\n const resolved = resolvePathParams(path, params);\n\n if (upper === \"GET\") {\n const requestUrl = appendQuery(resolved.path, { ...resolved.params, __lookup: \"filters\" });\n const response = await request(requestUrl, \"GET\", {\n headers: { Accept: \"application/json+clicky\", ...headers },\n });\n if (response.status === 404) return { filters: {} };\n const parsed = await readResponseBody(response, \"json\");\n if (!response.ok) throw errorFromResponse(response, \"GET\", requestUrl, parsed);\n return (parsed.data as OperationLookupResponse | undefined) ?? { filters: {} };\n }\n\n const response = await request(appendQuery(resolved.path, { __lookup: \"filters\" }), upper, {\n headers: {\n Accept: \"application/json+clicky\",\n \"Content-Type\": \"application/json\",\n ...headers,\n },\n body: JSON.stringify(resolved.params),\n });\n if (response.status === 404) return { filters: {} };\n const parsed = await readResponseBody(response, \"json\");\n if (!response.ok) throw errorFromResponse(response, upper, resolved.path, parsed);\n return (parsed.data as OperationLookupResponse | undefined) ?? { filters: {} };\n },\n\n async lookupFilterOptions(path, method, filterKey, query, extraParams) {\n const upper = method.toUpperCase();\n // Resolved against the supplied params, as lookupFilters does: a lookup on\n // an operation with a templated path would otherwise request the literal\n // \"{id}\" and the sibling values that scope the search would be lost.\n const resolved = resolvePathParams(path, extraParams ?? {});\n const queryParams = {\n ...resolved.params,\n __lookup: \"filters\",\n __lookup_filter: filterKey,\n __lookup_q: query,\n };\n\n const requestPath = appendQuery(resolved.path, queryParams);\n const response = await request(requestPath, upper, {\n headers: { Accept: \"application/json+clicky\" },\n });\n const parsed = await readResponseBody(response, \"json\");\n if (!response.ok) throw errorFromResponse(response, upper, requestPath, parsed);\n return ((parsed.data as OperationLookupResponse | undefined)?.filters?.[filterKey] ??\n {}) as OperationLookupFilter;\n },\n };\n}\n\nfunction responseKind(accept?: string): \"json\" | \"text\" | \"blob\" {\n if (!accept) return \"json\";\n const normalized = accept.toLowerCase();\n if (normalized.includes(\"application/pdf\")) return \"blob\";\n if (\n normalized.includes(\"text/\") ||\n normalized.includes(\"application/x-yaml\") ||\n normalized.includes(\"application/yaml\")\n ) {\n return \"text\";\n }\n return \"json\";\n}\n\nexport type ParsedBody = {\n data: unknown;\n text: string;\n blob?: Blob;\n contentType: string;\n};\n\nexport async function readResponseBody(response: Response, kind: \"json\" | \"text\" | \"blob\"): Promise<ParsedBody> {\n const contentType = response.headers.get(\"Content-Type\") || \"\";\n if (kind === \"blob\") {\n const blob = await response.blob();\n return { data: undefined, text: \"[binary]\", blob, contentType };\n }\n\n const text = await response.text();\n if (kind === \"text\" || !shouldParseJson(text, contentType)) {\n return { data: text, text, contentType };\n }\n\n try {\n return { data: JSON.parse(text) as unknown, text, contentType };\n } catch {\n return { data: text, text, contentType };\n }\n}\n\nfunction parseExecutionResponse(\n response: Response,\n parsed: ParsedBody,\n context: { method: string; requestUrl: string },\n): ExecutionResponse {\n const headers = responseHeaders(response.headers);\n const data = parsed.data;\n const stdout =\n parsed.blob != null\n ? \"[binary]\"\n : typeof data === \"string\"\n ? data\n : parsed.text || JSON.stringify(data, null, 2);\n const clickyEnvelope = isClickyEnvelope(data);\n\n if (!response.ok && !clickyEnvelope) {\n throw errorFromResponse(response, context.method, context.requestUrl, parsed);\n }\n\n const clickyError = errorFromClickyEnvelope(data);\n const successHeader = headers[\"x-execution-success\"];\n const success = successHeader == null ? response.ok && !clickyError : successHeader !== \"false\";\n const exitCode = parseInt(headers[\"x-exit-code\"] ?? (success ? \"0\" : \"1\"), 10);\n const cli = headers[\"x-cli-command\"];\n const error = headers[\"x-error\"] || clickyError;\n const pagination = paginationFromHeaders(headers);\n\n return {\n success,\n stdout,\n output: stdout,\n exit_code: Number.isFinite(exitCode) ? exitCode : success ? 0 : 1,\n contentType: parsed.contentType || headers[\"content-type\"] || \"application/json\",\n requestUrl: context.requestUrl,\n responseHeaders: headers,\n ...(pagination ? { pagination } : {}),\n ...(cli ? { cli } : {}),\n ...(error ? { error } : {}),\n ...(parsed.blob ? { blob: parsed.blob } : {}),\n ...(parsed.blob == null && typeof data !== \"string\" ? { parsed: data } : {}),\n };\n}\n\n// Exported because every fetch in the package has to fail the same way: with\n// the status, the URL and the parsed body attached, which is what\n// operationErrorDiagnostics reads back out to render ErrorDetails. A second\n// error-from-Response path would silently drop one of those again.\nexport function errorFromResponse(\n response: Response,\n method: string,\n url: string,\n parsed: ParsedBody,\n): OperationsApiClientError {\n const headers = responseHeaders(response.headers);\n const message =\n headers[\"x-error\"] ||\n messageFromBody(parsed.data) ||\n `${method} ${url} failed with ${response.status}: ${\n parsed.text || response.statusText\n }`;\n return new OperationsApiClientError(message, {\n status: response.status,\n method,\n url,\n responseBody: parsed.text,\n responseData: parsed.data,\n responseHeaders: headers,\n });\n}\n\nfunction resolvePathParams(\n path: string,\n params: OperationRequestValues,\n): { path: string; params: OperationRequestValues } {\n const queryParams = { ...params };\n let resolvedPath = path;\n const placeholders = [...path.matchAll(/\\{([^{}]+)\\}/g)]\n .map((match) => match[1])\n .filter((name): name is string => Boolean(name));\n const argValues = parseArgsParam(params.args);\n let consumedArgs = false;\n const consumedDirectValues: string[] = [];\n\n for (const [index, name] of placeholders.entries()) {\n const rawDirectValue = queryParams[name];\n if (Array.isArray(rawDirectValue)) {\n throw new Error(`Path parameter ${name} must be a scalar value`);\n }\n const directValue = rawDirectValue;\n const fallbackValue = directValue || argValues[index];\n if (!fallbackValue) continue;\n\n resolvedPath = resolvedPath.replace(`{${name}}`, encodeURIComponent(fallbackValue));\n delete queryParams[name];\n if (!directValue && argValues[index]) consumedArgs = true;\n if (directValue) consumedDirectValues[index] = directValue;\n }\n\n const argsDuplicateResolvedPath =\n argValues.length > 0 &&\n argValues.length === consumedDirectValues.filter(Boolean).length &&\n argValues.every((value, index) => value === consumedDirectValues[index]);\n\n if (consumedArgs || argsDuplicateResolvedPath) {\n delete queryParams.args;\n }\n\n return { path: resolvedPath, params: stripRunnerParams(queryParams) };\n}\n\nfunction parseArgsParam(value: string | string[] | undefined): string[] {\n if (!value) return [];\n if (Array.isArray(value)) return value.map(String).filter(Boolean);\n const trimmed = value.trim();\n if (!trimmed || trimmed === \"[]\" || trimmed.toLowerCase() === \"null\") return [];\n try {\n const parsed = JSON.parse(trimmed);\n if (Array.isArray(parsed)) return parsed.map(String).filter(Boolean);\n } catch {\n // Fall back to comma-delimited args below.\n }\n return trimmed\n .split(\",\")\n .map((part) => part.trim())\n .filter(Boolean);\n}\n\nfunction stripRunnerParams(params: OperationRequestValues) {\n const next = { ...params };\n delete next.autoRun;\n delete next.__autoRun;\n return next;\n}\n\nfunction appendQuery(path: string, params: OperationRequestValues) {\n const query = new URLSearchParams(\n Object.fromEntries(\n Object.entries(pruneParams(params)).map(([key, value]) => [\n key,\n Array.isArray(value) ? value.join(\",\") : value,\n ]),\n ),\n ).toString();\n if (!query) return path;\n return `${path}${path.includes(\"?\") ? \"&\" : \"?\"}${query}`;\n}\n\nfunction pruneParams(params: OperationRequestValues): OperationRequestValues {\n return Object.fromEntries(\n Object.entries(params).filter(([, value]) => value !== \"\" && value.length > 0),\n );\n}\n\nfunction joinUrl(baseUrl: string | undefined, path: string) {\n if (!baseUrl || /^https?:\\/\\//i.test(path)) return path;\n return `${stripTrailingSlashes(baseUrl)}/${stripLeadingSlashes(path)}`;\n}\n\nfunction headerValue(headers: Record<string, string> | undefined, name: string) {\n const wanted = name.toLowerCase();\n for (const [key, value] of Object.entries(headers ?? {})) {\n if (key.toLowerCase() === wanted) return value;\n }\n return undefined;\n}\n\nfunction responseHeaders(headers: Headers): Record<string, string> {\n const out: Record<string, string> = {};\n headers.forEach((value, key) => {\n out[key.toLowerCase()] = value;\n });\n return out;\n}\n\nfunction paginationFromHeaders(headers: Record<string, string>): ExecutionPagination | undefined {\n const pagination: ExecutionPagination = {};\n const total = integerHeader(headers[\"x-total-count\"]);\n const limit = integerHeader(headers[\"x-page-limit\"]);\n const offset = integerHeader(headers[\"x-page-offset\"]);\n\n if (total !== undefined) pagination.total = total;\n if (limit !== undefined) pagination.limit = limit;\n if (offset !== undefined) pagination.offset = offset;\n\n const relation = headers[\"x-total-relation\"];\n if (relation === \"eq\" || relation === \"gte\") pagination.totalRelation = relation;\n\n const hasMore = booleanHeader(headers[\"x-has-more\"]);\n if (hasMore !== undefined) pagination.hasMore = hasMore;\n\n const cursor = headers[\"x-next-cursor\"];\n if (cursor != null && cursor.trim() !== \"\") pagination.nextCursor = cursor;\n\n if (booleanHeader(headers[\"x-truncated\"]) === true) pagination.truncated = true;\n\n return Object.keys(pagination).length > 0 ? pagination : undefined;\n}\n\nfunction booleanHeader(value: string | undefined): boolean | undefined {\n if (value == null || value.trim() === \"\") return undefined;\n const normalized = value.trim().toLowerCase();\n if (normalized === \"true\") return true;\n if (normalized === \"false\") return false;\n return undefined;\n}\n\nfunction integerHeader(value: string | undefined): number | undefined {\n if (value == null || value.trim() === \"\") return undefined;\n const parsed = parseInt(value, 10);\n return Number.isFinite(parsed) ? parsed : undefined;\n}\n\nfunction shouldParseJson(text: string, contentType: string) {\n const trimmed = text.trim();\n return (\n trimmed !== \"\" &&\n (contentType.toLowerCase().includes(\"json\") ||\n trimmed.startsWith(\"{\") ||\n trimmed.startsWith(\"[\"))\n );\n}\n\nfunction isClickyEnvelope(data: unknown): boolean {\n if (!data || typeof data !== \"object\") return false;\n const body = data as Record<string, unknown>;\n return body.version != null && body.node != null && typeof body.node === \"object\";\n}\n\nfunction readClickyText(node: unknown): string | undefined {\n if (!node || typeof node !== \"object\") return undefined;\n const n = node as Record<string, unknown>;\n if (typeof n.plain === \"string\" && n.plain !== \"\") return n.plain;\n if (typeof n.text === \"string\" && n.text !== \"\") return n.text;\n if (Array.isArray(n.children)) {\n for (const child of n.children) {\n const text = readClickyText(child);\n if (text) return text;\n }\n }\n return undefined;\n}\n\nfunction errorFromClickyEnvelope(data: unknown): string | undefined {\n if (!data || typeof data !== \"object\") return undefined;\n const node = (data as Record<string, unknown>).node;\n if (!node || typeof node !== \"object\") return undefined;\n const n = node as Record<string, unknown>;\n if (n.kind !== \"map\" || !Array.isArray(n.fields)) return undefined;\n\n let errorText: string | undefined;\n let failed = false;\n for (const field of n.fields) {\n if (!field || typeof field !== \"object\") continue;\n const f = field as Record<string, unknown>;\n if (f.name === \"Error\") errorText = readClickyText(f.value);\n if (f.name === \"Success\" && readClickyText(f.value) === \"false\") failed = true;\n }\n return failed ? errorText : undefined;\n}\n\nfunction messageFromBody(data: unknown): string | undefined {\n if (!data || typeof data !== \"object\") return undefined;\n const body = data as Record<string, unknown>;\n if (typeof body.error === \"string\" && body.error) return body.error;\n if (typeof body.message === \"string\" && body.message) return body.message;\n return errorFromClickyEnvelope(data);\n}\n"],"mappings":";;;AAeA,IAAa,4BAA4B;AA2BzC,IAAa,2BAAb,cAA8C,MAAM;CAClD;CACA;CACA;CACA;CACA;CACA;CAEA,YACE,SAIA,UAOI,CAAC,GACL;EACA,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,SAAS,QAAQ;EACtB,KAAK,SAAS,QAAQ;EACtB,KAAK,MAAM,QAAQ;EACnB,KAAK,eAAe,QAAQ;EAC5B,KAAK,eAAe,QAAQ;EAC5B,KAAK,kBAAkB,QAAQ;CACjC;AACF;AAwBA,SAAgB,0BACd,UAA4C,CAAC,GAClB;CAC3B,MAAM,UAAU,QAAQ,SAAS;CACjC,MAAM,cAAc,QAAQ,eAAe;CAE3C,eAAe,YACb,MACA,SACkB;EAClB,MAAM,UAAU,IAAI,QAAQ,IAAI;EAChC,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M,OAAO;CACb,IAAI,OAAO,KAAK,UAAU,YAAY,KAAK,OAAO,OAAO,KAAK;CAC9D,IAAI,OAAO,KAAK,YAAY,YAAY,KAAK,SAAS,OAAO,KAAK;CAClE,OAAO,wBAAwB,IAAI;AACrC"}
|
|
1
|
+
{"version":3,"file":"apiClient.js","names":[],"sources":["../../src/rpc/apiClient.ts"],"sourcesContent":["import type { JsonSchemaObject } from \"../components/json-schema-form-types\";\nimport { stripLeadingSlashes, stripTrailingSlashes } from \"../lib/string\";\nimport type {\n ExecutionPagination,\n ExecutionResponse,\n OpenAPISpec,\n OperationLookupFilter,\n OperationLookupResponse,\n OperationRequestValues,\n} from \"./types\";\nimport type { OperationsApiClient } from \"./useOperations\";\n\ntype MaybePromise<T> = T | Promise<T>;\n\n/** Operation catalog: an OpenAPI document whose response schemas may be stubs. */\nexport const CLICKY_OPENAPI_MEDIA_TYPE = \"application/vnd.clicky.openapi+json\";\n\nexport type OperationApiClientContext = {\n path: string;\n method: string;\n};\n\nexport type OperationDefaultParams = (context: {\n path: string;\n method: string;\n params: OperationRequestValues;\n}) => MaybePromise<OperationRequestValues>;\n\nexport type OperationHeadersProvider = (\n headers: Headers,\n context: OperationApiClientContext,\n) => MaybePromise<HeadersInit | void>;\n\nexport type CreateOperationsApiClientOptions = {\n baseUrl?: string;\n openApiPath?: string;\n credentials?: RequestCredentials;\n fetch?: typeof fetch;\n prepareHeaders?: OperationHeadersProvider;\n defaultParams?: OperationDefaultParams;\n};\n\nexport class OperationsApiClientError extends Error {\n status: number | undefined;\n method: string | undefined;\n url: string | undefined;\n responseBody: string | undefined;\n responseData: unknown;\n responseHeaders: Record<string, string> | undefined;\n\n constructor(\n message: string,\n // Each field mirrors the property it lands on, undefined included: a caller\n // rebuilding an error from a partial response should not have to spread\n // conditionally to say \"this one is unknown\".\n options: {\n status?: number | undefined;\n method?: string | undefined;\n url?: string | undefined;\n responseBody?: string | undefined;\n responseData?: unknown;\n responseHeaders?: Record<string, string> | undefined;\n } = {},\n ) {\n super(message);\n this.name = \"OperationsApiClientError\";\n this.status = options.status;\n this.method = options.method;\n this.url = options.url;\n this.responseBody = options.responseBody;\n this.responseData = options.responseData;\n this.responseHeaders = options.responseHeaders;\n }\n}\n\nexport interface SharedOperationsApiClient extends OperationsApiClient {\n lookupFilterOptions(\n path: string,\n method: string,\n filterKey: string,\n query: string,\n extraParams?: OperationRequestValues,\n ): Promise<OperationLookupFilter>;\n executeCommandBody(\n path: string,\n body: Record<string, unknown>,\n headers?: Record<string, string>,\n ): Promise<ExecutionResponse>;\n getSchema(path: string): Promise<JsonSchemaObject | undefined>;\n submitForm(\n path: string,\n method: string,\n body: Record<string, unknown>,\n headers?: Record<string, string>,\n ): Promise<ExecutionResponse>;\n}\n\nexport function createOperationsApiClient(\n options: CreateOperationsApiClientOptions = {},\n): SharedOperationsApiClient {\n const fetcher = options.fetch ?? fetch;\n const openApiPath = options.openApiPath ?? \"/api/openapi.json\";\n\n async function makeHeaders(\n base: HeadersInit | undefined,\n context: OperationApiClientContext,\n ): Promise<Headers> {\n const headers = new Headers(base);\n const prepared = await options.prepareHeaders?.(headers, context);\n return prepared ? new Headers(prepared) : headers;\n }\n\n // urlOf is the URL a path is fetched at, which responses and errors report:\n // a caller re-requesting it (a download, a format switch) must reach the\n // same server mount the client did.\n const urlOf = (path: string) => joinUrl(options.baseUrl, path);\n\n async function request(\n path: string,\n method: string,\n init: Omit<RequestInit, \"method\" | \"headers\" | \"credentials\"> & {\n headers?: HeadersInit;\n } = {},\n ): Promise<Response> {\n const headers = await makeHeaders(init.headers, { path, method });\n return fetcher(urlOf(path), {\n ...init,\n method,\n headers,\n ...(options.credentials ? { credentials: options.credentials } : {}),\n });\n }\n\n async function getOpenAPISpec(): Promise<OpenAPISpec> {\n const response = await request(openApiPath, \"GET\", {\n // Prefer the catalog projection — the same document with each operation's\n // response schemas stubbed, which nothing here reads and which is over\n // half the bytes. A server that does not serve it answers with the\n // complete document, which parses the same.\n headers: {\n Accept: `${CLICKY_OPENAPI_MEDIA_TYPE}, application/json;q=0.9`,\n },\n });\n const parsed = await readResponseBody(response, \"json\");\n if (!response.ok) {\n throw errorFromResponse(response, \"GET\", urlOf(openApiPath), parsed);\n }\n return parsed.data as OpenAPISpec;\n }\n\n async function withDefaults(path: string, method: string, params: OperationRequestValues) {\n return (await options.defaultParams?.({ path, method, params })) ?? params;\n }\n\n return {\n getOpenAPISpec,\n\n async executeCommand(path, method, params, headers) {\n const upper = method.toUpperCase();\n const resolved = resolvePathParams(path, params);\n const scoped = await withDefaults(resolved.path, upper, resolved.params);\n const accept = headerValue(headers, \"Accept\");\n\n if (upper === \"GET\") {\n const requestPath = appendQuery(resolved.path, scoped);\n const response = await request(requestPath, upper, headers ? { headers } : {});\n return parseExecutionResponse(response, await readResponseBody(response, responseKind(accept)), {\n method: upper,\n requestUrl: urlOf(requestPath),\n });\n }\n\n const response = await request(resolved.path, upper, {\n headers: { \"Content-Type\": \"application/json\", ...headers },\n body: JSON.stringify(scoped),\n });\n return parseExecutionResponse(response, await readResponseBody(response, responseKind(accept)), {\n method: upper,\n requestUrl: urlOf(resolved.path),\n });\n },\n\n async executeCommandBody(path, body, headers) {\n const accept = headerValue(headers, \"Accept\");\n const response = await request(path, \"POST\", {\n headers: { \"Content-Type\": \"application/json\", ...headers },\n body: JSON.stringify(body),\n });\n return parseExecutionResponse(response, await readResponseBody(response, responseKind(accept)), {\n method: \"POST\",\n requestUrl: urlOf(path),\n });\n },\n\n // getSchema fetches a resource's JSON Schema via content negotiation\n // (Accept: application/schema+json on the same endpoint). It returns\n // undefined when the resource serves no schema (the request falls through to\n // its data representation), so callers can fall back to a parameter form.\n async getSchema(path) {\n const response = await request(path, \"GET\", {\n headers: { Accept: \"application/schema+json\" },\n });\n if (!response.ok) return undefined;\n const contentType = response.headers.get(\"Content-Type\") || \"\";\n if (!contentType.toLowerCase().includes(\"schema\")) return undefined;\n const parsed = await readResponseBody(response, \"json\");\n const data = parsed.data;\n return data && typeof data === \"object\" ? (data as JsonSchemaObject) : undefined;\n },\n\n // submitForm sends a nested JSON body with the given HTTP method (POST to\n // create, PUT to update). Unlike executeCommand it preserves nested objects\n // and arrays — the server reads the raw body (clicky's RequestFromContext),\n // so connection `properties` and profile `provider`/`params`/`columns`\n // survive intact.\n async submitForm(path, method, body, headers) {\n const upper = method.toUpperCase();\n const response = await request(path, upper, {\n headers: { \"Content-Type\": \"application/json\", ...headers },\n body: JSON.stringify(body),\n });\n return parseExecutionResponse(response, await readResponseBody(response, \"json\"), {\n method: upper,\n requestUrl: urlOf(path),\n });\n },\n\n async lookupFilters(path, method, params, headers) {\n const upper = method.toUpperCase();\n const resolved = resolvePathParams(path, params);\n\n if (upper === \"GET\") {\n const requestUrl = appendQuery(resolved.path, { ...resolved.params, __lookup: \"filters\" });\n const response = await request(requestUrl, \"GET\", {\n headers: { Accept: \"application/json+clicky\", ...headers },\n });\n if (response.status === 404) return { filters: {} };\n const parsed = await readResponseBody(response, \"json\");\n if (!response.ok) throw errorFromResponse(response, \"GET\", urlOf(requestUrl), parsed);\n return (parsed.data as OperationLookupResponse | undefined) ?? { filters: {} };\n }\n\n const response = await request(appendQuery(resolved.path, { __lookup: \"filters\" }), upper, {\n headers: {\n Accept: \"application/json+clicky\",\n \"Content-Type\": \"application/json\",\n ...headers,\n },\n body: JSON.stringify(resolved.params),\n });\n if (response.status === 404) return { filters: {} };\n const parsed = await readResponseBody(response, \"json\");\n if (!response.ok) throw errorFromResponse(response, upper, urlOf(resolved.path), parsed);\n return (parsed.data as OperationLookupResponse | undefined) ?? { filters: {} };\n },\n\n async lookupFilterOptions(path, method, filterKey, query, extraParams) {\n const upper = method.toUpperCase();\n // Resolved against the supplied params, as lookupFilters does: a lookup on\n // an operation with a templated path would otherwise request the literal\n // \"{id}\" and the sibling values that scope the search would be lost.\n const resolved = resolvePathParams(path, extraParams ?? {});\n const queryParams = {\n ...resolved.params,\n __lookup: \"filters\",\n __lookup_filter: filterKey,\n __lookup_q: query,\n };\n\n const requestPath = appendQuery(resolved.path, queryParams);\n const response = await request(requestPath, upper, {\n headers: { Accept: \"application/json+clicky\" },\n });\n const parsed = await readResponseBody(response, \"json\");\n if (!response.ok) throw errorFromResponse(response, upper, urlOf(requestPath), parsed);\n return ((parsed.data as OperationLookupResponse | undefined)?.filters?.[filterKey] ??\n {}) as OperationLookupFilter;\n },\n };\n}\n\nfunction responseKind(accept?: string): \"json\" | \"text\" | \"blob\" {\n if (!accept) return \"json\";\n const normalized = accept.toLowerCase();\n if (normalized.includes(\"application/pdf\")) return \"blob\";\n if (\n normalized.includes(\"text/\") ||\n normalized.includes(\"application/x-yaml\") ||\n normalized.includes(\"application/yaml\")\n ) {\n return \"text\";\n }\n return \"json\";\n}\n\nexport type ParsedBody = {\n data: unknown;\n text: string;\n blob?: Blob;\n contentType: string;\n};\n\nexport async function readResponseBody(response: Response, kind: \"json\" | \"text\" | \"blob\"): Promise<ParsedBody> {\n const contentType = response.headers.get(\"Content-Type\") || \"\";\n if (kind === \"blob\") {\n const blob = await response.blob();\n return { data: undefined, text: \"[binary]\", blob, contentType };\n }\n\n const text = await response.text();\n if (kind === \"text\" || !shouldParseJson(text, contentType)) {\n return { data: text, text, contentType };\n }\n\n try {\n return { data: JSON.parse(text) as unknown, text, contentType };\n } catch {\n return { data: text, text, contentType };\n }\n}\n\nfunction parseExecutionResponse(\n response: Response,\n parsed: ParsedBody,\n context: { method: string; requestUrl: string },\n): ExecutionResponse {\n const headers = responseHeaders(response.headers);\n const data = parsed.data;\n const stdout =\n parsed.blob != null\n ? \"[binary]\"\n : typeof data === \"string\"\n ? data\n : parsed.text || JSON.stringify(data, null, 2);\n const clickyEnvelope = isClickyEnvelope(data);\n\n if (!response.ok && !clickyEnvelope) {\n throw errorFromResponse(response, context.method, context.requestUrl, parsed);\n }\n\n const clickyError = errorFromClickyEnvelope(data);\n const successHeader = headers[\"x-execution-success\"];\n const success = successHeader == null ? response.ok && !clickyError : successHeader !== \"false\";\n const exitCode = parseInt(headers[\"x-exit-code\"] ?? (success ? \"0\" : \"1\"), 10);\n const cli = headers[\"x-cli-command\"];\n const error = headers[\"x-error\"] || clickyError;\n const pagination = paginationFromHeaders(headers);\n\n return {\n success,\n stdout,\n output: stdout,\n exit_code: Number.isFinite(exitCode) ? exitCode : success ? 0 : 1,\n contentType: parsed.contentType || headers[\"content-type\"] || \"application/json\",\n requestUrl: context.requestUrl,\n responseHeaders: headers,\n ...(pagination ? { pagination } : {}),\n ...(cli ? { cli } : {}),\n ...(error ? { error } : {}),\n ...(parsed.blob ? { blob: parsed.blob } : {}),\n ...(parsed.blob == null && typeof data !== \"string\" ? { parsed: data } : {}),\n };\n}\n\n// Exported because every fetch in the package has to fail the same way: with\n// the status, the URL and the parsed body attached, which is what\n// operationErrorDiagnostics reads back out to render ErrorDetails. A second\n// error-from-Response path would silently drop one of those again.\nexport function errorFromResponse(\n response: Response,\n method: string,\n url: string,\n parsed: ParsedBody,\n): OperationsApiClientError {\n const headers = responseHeaders(response.headers);\n const message =\n headers[\"x-error\"] ||\n messageFromBody(parsed.data) ||\n `${method} ${url} failed with ${response.status}: ${\n parsed.text || response.statusText\n }`;\n return new OperationsApiClientError(message, {\n status: response.status,\n method,\n url,\n responseBody: parsed.text,\n responseData: parsed.data,\n responseHeaders: headers,\n });\n}\n\nfunction resolvePathParams(\n path: string,\n params: OperationRequestValues,\n): { path: string; params: OperationRequestValues } {\n const queryParams = { ...params };\n let resolvedPath = path;\n const placeholders = [...path.matchAll(/\\{([^{}]+)\\}/g)]\n .map((match) => match[1])\n .filter((name): name is string => Boolean(name));\n const argValues = parseArgsParam(params.args);\n let consumedArgs = false;\n const consumedDirectValues: string[] = [];\n\n for (const [index, name] of placeholders.entries()) {\n const rawDirectValue = queryParams[name];\n if (Array.isArray(rawDirectValue)) {\n throw new Error(`Path parameter ${name} must be a scalar value`);\n }\n const directValue = rawDirectValue;\n const fallbackValue = directValue || argValues[index];\n if (!fallbackValue) continue;\n\n resolvedPath = resolvedPath.replace(`{${name}}`, encodeURIComponent(fallbackValue));\n delete queryParams[name];\n if (!directValue && argValues[index]) consumedArgs = true;\n if (directValue) consumedDirectValues[index] = directValue;\n }\n\n const argsDuplicateResolvedPath =\n argValues.length > 0 &&\n argValues.length === consumedDirectValues.filter(Boolean).length &&\n argValues.every((value, index) => value === consumedDirectValues[index]);\n\n if (consumedArgs || argsDuplicateResolvedPath) {\n delete queryParams.args;\n }\n\n return { path: resolvedPath, params: stripRunnerParams(queryParams) };\n}\n\nfunction parseArgsParam(value: string | string[] | undefined): string[] {\n if (!value) return [];\n if (Array.isArray(value)) return value.map(String).filter(Boolean);\n const trimmed = value.trim();\n if (!trimmed || trimmed === \"[]\" || trimmed.toLowerCase() === \"null\") return [];\n try {\n const parsed = JSON.parse(trimmed);\n if (Array.isArray(parsed)) return parsed.map(String).filter(Boolean);\n } catch {\n // Fall back to comma-delimited args below.\n }\n return trimmed\n .split(\",\")\n .map((part) => part.trim())\n .filter(Boolean);\n}\n\nfunction stripRunnerParams(params: OperationRequestValues) {\n const next = { ...params };\n delete next.autoRun;\n delete next.__autoRun;\n return next;\n}\n\nfunction appendQuery(path: string, params: OperationRequestValues) {\n const query = new URLSearchParams(\n Object.fromEntries(\n Object.entries(pruneParams(params)).map(([key, value]) => [\n key,\n Array.isArray(value) ? value.join(\",\") : value,\n ]),\n ),\n ).toString();\n if (!query) return path;\n return `${path}${path.includes(\"?\") ? \"&\" : \"?\"}${query}`;\n}\n\nfunction pruneParams(params: OperationRequestValues): OperationRequestValues {\n return Object.fromEntries(\n Object.entries(params).filter(([, value]) => value !== \"\" && value.length > 0),\n );\n}\n\nfunction joinUrl(baseUrl: string | undefined, path: string) {\n if (!baseUrl || /^https?:\\/\\//i.test(path)) return path;\n return `${stripTrailingSlashes(baseUrl)}/${stripLeadingSlashes(path)}`;\n}\n\nfunction headerValue(headers: Record<string, string> | undefined, name: string) {\n const wanted = name.toLowerCase();\n for (const [key, value] of Object.entries(headers ?? {})) {\n if (key.toLowerCase() === wanted) return value;\n }\n return undefined;\n}\n\nfunction responseHeaders(headers: Headers): Record<string, string> {\n const out: Record<string, string> = {};\n headers.forEach((value, key) => {\n out[key.toLowerCase()] = value;\n });\n return out;\n}\n\nfunction paginationFromHeaders(headers: Record<string, string>): ExecutionPagination | undefined {\n const pagination: ExecutionPagination = {};\n const total = integerHeader(headers[\"x-total-count\"]);\n const limit = integerHeader(headers[\"x-page-limit\"]);\n const offset = integerHeader(headers[\"x-page-offset\"]);\n\n if (total !== undefined) pagination.total = total;\n if (limit !== undefined) pagination.limit = limit;\n if (offset !== undefined) pagination.offset = offset;\n\n const relation = headers[\"x-total-relation\"];\n if (relation === \"eq\" || relation === \"gte\") pagination.totalRelation = relation;\n\n const hasMore = booleanHeader(headers[\"x-has-more\"]);\n if (hasMore !== undefined) pagination.hasMore = hasMore;\n\n const cursor = headers[\"x-next-cursor\"];\n if (cursor != null && cursor.trim() !== \"\") pagination.nextCursor = cursor;\n\n if (booleanHeader(headers[\"x-truncated\"]) === true) pagination.truncated = true;\n\n return Object.keys(pagination).length > 0 ? pagination : undefined;\n}\n\nfunction booleanHeader(value: string | undefined): boolean | undefined {\n if (value == null || value.trim() === \"\") return undefined;\n const normalized = value.trim().toLowerCase();\n if (normalized === \"true\") return true;\n if (normalized === \"false\") return false;\n return undefined;\n}\n\nfunction integerHeader(value: string | undefined): number | undefined {\n if (value == null || value.trim() === \"\") return undefined;\n const parsed = parseInt(value, 10);\n return Number.isFinite(parsed) ? parsed : undefined;\n}\n\nfunction shouldParseJson(text: string, contentType: string) {\n const trimmed = text.trim();\n return (\n trimmed !== \"\" &&\n (contentType.toLowerCase().includes(\"json\") ||\n trimmed.startsWith(\"{\") ||\n trimmed.startsWith(\"[\"))\n );\n}\n\nfunction isClickyEnvelope(data: unknown): boolean {\n if (!data || typeof data !== \"object\") return false;\n const body = data as Record<string, unknown>;\n return body.version != null && body.node != null && typeof body.node === \"object\";\n}\n\nfunction readClickyText(node: unknown): string | undefined {\n if (!node || typeof node !== \"object\") return undefined;\n const n = node as Record<string, unknown>;\n if (typeof n.plain === \"string\" && n.plain !== \"\") return n.plain;\n if (typeof n.text === \"string\" && n.text !== \"\") return n.text;\n if (Array.isArray(n.children)) {\n for (const child of n.children) {\n const text = readClickyText(child);\n if (text) return text;\n }\n }\n return undefined;\n}\n\nfunction errorFromClickyEnvelope(data: unknown): string | undefined {\n if (!data || typeof data !== \"object\") return undefined;\n const node = (data as Record<string, unknown>).node;\n if (!node || typeof node !== \"object\") return undefined;\n const n = node as Record<string, unknown>;\n if (n.kind !== \"map\" || !Array.isArray(n.fields)) return undefined;\n\n let errorText: string | undefined;\n let failed = false;\n for (const field of n.fields) {\n if (!field || typeof field !== \"object\") continue;\n const f = field as Record<string, unknown>;\n if (f.name === \"Error\") errorText = readClickyText(f.value);\n if (f.name === \"Success\" && readClickyText(f.value) === \"false\") failed = true;\n }\n return failed ? errorText : undefined;\n}\n\nfunction messageFromBody(data: unknown): string | undefined {\n if (!data || typeof data !== \"object\") return undefined;\n const body = data as Record<string, unknown>;\n if (typeof body.error === \"string\" && body.error) return body.error;\n if (typeof body.message === \"string\" && body.message) return body.message;\n return errorFromClickyEnvelope(data);\n}\n"],"mappings":";;;AAeA,IAAa,4BAA4B;AA2BzC,IAAa,2BAAb,cAA8C,MAAM;CAClD;CACA;CACA;CACA;CACA;CACA;CAEA,YACE,SAIA,UAOI,CAAC,GACL;EACA,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,SAAS,QAAQ;EACtB,KAAK,SAAS,QAAQ;EACtB,KAAK,MAAM,QAAQ;EACnB,KAAK,eAAe,QAAQ;EAC5B,KAAK,eAAe,QAAQ;EAC5B,KAAK,kBAAkB,QAAQ;CACjC;AACF;AAwBA,SAAgB,0BACd,UAA4C,CAAC,GAClB;CAC3B,MAAM,UAAU,QAAQ,SAAS;CACjC,MAAM,cAAc,QAAQ,eAAe;CAE3C,eAAe,YACb,MACA,SACkB;EAClB,MAAM,UAAU,IAAI,QAAQ,IAAI;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