@query-farm/vgi 0.36.3 → 0.37.1
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/catalog/attach-option.d.ts +30 -2
- package/dist/client-entry.js +5 -3
- package/dist/client-entry.js.map +3 -3
- package/dist/index.js +7 -4
- package/dist/index.js.map +3 -3
- package/dist/worker-cf-entry.js +5 -3
- package/dist/worker-cf-entry.js.map +3 -3
- package/package.json +1 -1
- package/src/catalog/attach-option.ts +37 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@query-farm/vgi",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.37.1",
|
|
4
4
|
"description": "TypeScript framework for extending DuckDB with user-defined functions via the Vector Gateway Interface (VGI) over Arrow IPC.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"author": "Query Farm LLC (https://query.farm)",
|
|
@@ -22,6 +22,9 @@
|
|
|
22
22
|
// that predates the column reads the batch by
|
|
23
23
|
// name and simply doesn't see it; absent and
|
|
24
24
|
// explicit-null both mean "not required".
|
|
25
|
+
// secret: Bool nullable -- the option carries a credential. Appended AFTER
|
|
26
|
+
// `required` under the same rule: readers look it
|
|
27
|
+
// up by name, and absent or null reads as false.
|
|
25
28
|
//
|
|
26
29
|
// The extension reads the outer `attach_option_specs: list<binary>` column
|
|
27
30
|
// from CatalogInfo and validates user-supplied ATTACH options against the
|
|
@@ -75,6 +78,34 @@ export interface AttachOptionSpec {
|
|
|
75
78
|
* is by definition satisfiable without the caller.
|
|
76
79
|
*/
|
|
77
80
|
required?: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* The option carries a credential: an API key, a token, a password, or
|
|
83
|
+
* anything else that must not be shown, stored or logged in plain text.
|
|
84
|
+
*
|
|
85
|
+
* Credential options **MUST** be declared `secret: true`. The value is still
|
|
86
|
+
* passed inline as an ordinary ATTACH option; the flag tells the DuckDB
|
|
87
|
+
* extension to redact it from `duckdb_databases()`, keep only a salted hash
|
|
88
|
+
* of it in its result-cache key, and never log it. Clients use the flag to
|
|
89
|
+
* mask the field and keep the value out of shared links and exported
|
|
90
|
+
* configuration.
|
|
91
|
+
*
|
|
92
|
+
* To keep the credential out of the SQL text itself, pass it as an
|
|
93
|
+
* expression:
|
|
94
|
+
*
|
|
95
|
+
* ```sql
|
|
96
|
+
* ATTACH 'sales' (TYPE vgi, LOCATION 'https://worker.example.com',
|
|
97
|
+
* api_key getenv('SALES_API_KEY'));
|
|
98
|
+
* ```
|
|
99
|
+
*
|
|
100
|
+
* Combines with `required` (a credential the catalog cannot attach without,
|
|
101
|
+
* which a client can then ask for before attaching). It is allowed together
|
|
102
|
+
* with `default`, but a secret option normally has none: a default would be
|
|
103
|
+
* a credential shipped in the catalog's own discovery metadata.
|
|
104
|
+
*
|
|
105
|
+
* Defaults to `false`. On the wire it is a nullable `secret` Bool column
|
|
106
|
+
* appended after `required`; a peer that predates it reads it as `false`.
|
|
107
|
+
*/
|
|
108
|
+
secret?: boolean;
|
|
78
109
|
}
|
|
79
110
|
|
|
80
111
|
const SPEC_SCHEMA = makeSchema([
|
|
@@ -83,6 +114,7 @@ const SPEC_SCHEMA = makeSchema([
|
|
|
83
114
|
field("type", binary(), false),
|
|
84
115
|
field("default_value", binary(), true),
|
|
85
116
|
field("required", bool(), true),
|
|
117
|
+
field("secret", bool(), true),
|
|
86
118
|
]);
|
|
87
119
|
|
|
88
120
|
/**
|
|
@@ -126,6 +158,8 @@ export function serializeAttachOptionSpec(spec: AttachOptionSpec): Uint8Array {
|
|
|
126
158
|
// Written explicitly rather than left null so a reader sees `false`, not
|
|
127
159
|
// NULL, for an option that simply isn't required.
|
|
128
160
|
required: [spec.required ?? false],
|
|
161
|
+
// Same reasoning: an ordinary option reads `false`, not NULL.
|
|
162
|
+
secret: [spec.secret ?? false],
|
|
129
163
|
},
|
|
130
164
|
SPEC_SCHEMA,
|
|
131
165
|
);
|
|
@@ -145,8 +179,8 @@ export function serializeAttachOptionSpecs(
|
|
|
145
179
|
* Deserialize one AttachOptionSpec from the wire format above.
|
|
146
180
|
*
|
|
147
181
|
* Reads by column name, so a spec written by a peer that predates the
|
|
148
|
-
* `required` column deserializes with `
|
|
149
|
-
* the same tolerance the Python and C++ readers have.
|
|
182
|
+
* `required` or `secret` column deserializes with that flag `false` rather
|
|
183
|
+
* than failing — the same tolerance the Python and C++ readers have.
|
|
150
184
|
*/
|
|
151
185
|
export function deserializeAttachOptionSpec(
|
|
152
186
|
bytes: Uint8Array,
|
|
@@ -181,6 +215,7 @@ export function deserializeAttachOptionSpec(
|
|
|
181
215
|
type,
|
|
182
216
|
...(value === undefined || value === null ? {} : { default: value }),
|
|
183
217
|
required: row.required === true,
|
|
218
|
+
secret: row.secret === true,
|
|
184
219
|
};
|
|
185
220
|
}
|
|
186
221
|
|