add duckdb-ui-client & other ts pkgs (#10)
* add duckdb-ui-client & other ts pkgs * workflow fixes * fix working dir * no sparse checkout; specify package.json path * path to pnpm-lock.yaml * add check & build test * workflow step descriptions * use comments & names * one more naming tweak
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import { toBase64 } from '../../util/functions/toBase64.js';
|
||||
|
||||
export interface DuckDBUIHttpRequestHeaderOptions {
|
||||
description?: string;
|
||||
connectionName?: string;
|
||||
databaseName?: string;
|
||||
parameters?: unknown[];
|
||||
}
|
||||
|
||||
export function makeDuckDBUIHttpRequestHeaders({
|
||||
description,
|
||||
connectionName,
|
||||
databaseName,
|
||||
parameters,
|
||||
}: DuckDBUIHttpRequestHeaderOptions): Headers {
|
||||
const headers = new Headers();
|
||||
if (description) {
|
||||
headers.append('X-DuckDB-UI-Request-Description', description);
|
||||
}
|
||||
if (connectionName) {
|
||||
headers.append('X-DuckDB-UI-Connection-Name', connectionName);
|
||||
}
|
||||
if (databaseName) {
|
||||
// base64 encode the value because it can contain characters invalid in an HTTP header
|
||||
headers.append('X-DuckDB-UI-Database-Name', toBase64(databaseName));
|
||||
}
|
||||
if (parameters) {
|
||||
headers.append('X-DuckDB-UI-Parameter-Count', String(parameters.length));
|
||||
for (let i = 0; i < parameters.length; i++) {
|
||||
// base64 encode the value because it can contain characters invalid in an HTTP header
|
||||
// TODO: support non-string parameters?
|
||||
headers.append(
|
||||
`X-DuckDB-UI-Parameter-Value-${i}`,
|
||||
toBase64(String(parameters[i])),
|
||||
);
|
||||
}
|
||||
}
|
||||
return headers;
|
||||
}
|
||||
Reference in New Issue
Block a user