@query-farm/vgi 0.24.0 → 0.24.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/catalog/attach-option.d.ts +30 -0
- package/dist/catalog/read-only.d.ts +11 -0
- package/dist/index.js +55 -28
- package/dist/index.js.map +5 -5
- package/dist/worker-cf-entry.js +55 -28
- package/dist/worker-cf-entry.js.map +5 -5
- package/package.json +6 -3
- package/scripts/postinstall.cjs +47 -0
- package/src/catalog/attach-option.ts +74 -0
- package/src/catalog/read-only.ts +20 -0
package/dist/worker-cf-entry.js
CHANGED
|
@@ -8116,6 +8116,56 @@ function resolveMetadata(func) {
|
|
|
8116
8116
|
};
|
|
8117
8117
|
}
|
|
8118
8118
|
|
|
8119
|
+
// src/catalog/attach-option.ts
|
|
8120
|
+
init_arrow();
|
|
8121
|
+
var SPEC_SCHEMA = schema2([
|
|
8122
|
+
field2("name", utf82(), false),
|
|
8123
|
+
field2("description", utf82(), false),
|
|
8124
|
+
field2("type", binary2(), false),
|
|
8125
|
+
field2("default_value", binary2(), true),
|
|
8126
|
+
field2("required", bool2(), true)
|
|
8127
|
+
]);
|
|
8128
|
+
function serializeAttachOptionSpec(spec) {
|
|
8129
|
+
if (spec.required && spec.default !== undefined && spec.default !== null) {
|
|
8130
|
+
throw new Error(`Attach option '${spec.name}' is required but also declares a default ` + `(${JSON.stringify(spec.default)}); an option with a default is always ` + "satisfiable without the caller. Drop one.");
|
|
8131
|
+
}
|
|
8132
|
+
const typeSchema = schema2([field2("value", spec.type, true)]);
|
|
8133
|
+
const typeBytes = serializeSchema(typeSchema);
|
|
8134
|
+
let defaultBytes = null;
|
|
8135
|
+
if (spec.default !== undefined && spec.default !== null) {
|
|
8136
|
+
const defaultBatch = batchFromColumns({ value: [spec.default] }, typeSchema);
|
|
8137
|
+
defaultBytes = serializeBatch(defaultBatch);
|
|
8138
|
+
}
|
|
8139
|
+
const batch = batchFromColumns({
|
|
8140
|
+
name: [spec.name],
|
|
8141
|
+
description: [spec.description],
|
|
8142
|
+
type: [typeBytes],
|
|
8143
|
+
default_value: [defaultBytes],
|
|
8144
|
+
required: [spec.required ?? false]
|
|
8145
|
+
}, SPEC_SCHEMA);
|
|
8146
|
+
return serializeBatch(batch);
|
|
8147
|
+
}
|
|
8148
|
+
function serializeAttachOptionSpecs(specs) {
|
|
8149
|
+
return Array.from(specs, serializeAttachOptionSpec);
|
|
8150
|
+
}
|
|
8151
|
+
|
|
8152
|
+
class MissingAttachOptionsError extends Error {
|
|
8153
|
+
missing;
|
|
8154
|
+
constructor(catalogName, missing) {
|
|
8155
|
+
const joined = missing.map((name) => `'${name}'`).join(", ");
|
|
8156
|
+
super(`Catalog '${catalogName}' cannot be attached without the required ` + `option${missing.length > 1 ? "s" : ""} ${joined}.`);
|
|
8157
|
+
this.name = "MissingAttachOptionsError";
|
|
8158
|
+
this.missing = missing;
|
|
8159
|
+
}
|
|
8160
|
+
}
|
|
8161
|
+
function validateRequiredAttachOptions(catalogName, specs, options) {
|
|
8162
|
+
const supplied = new Set(Object.keys(options).map((key) => key.toLowerCase()));
|
|
8163
|
+
const missing = Array.from(specs).filter((spec) => spec.required && !supplied.has(spec.name.toLowerCase())).map((spec) => spec.name);
|
|
8164
|
+
if (missing.length > 0) {
|
|
8165
|
+
throw new MissingAttachOptionsError(catalogName, missing);
|
|
8166
|
+
}
|
|
8167
|
+
}
|
|
8168
|
+
|
|
8119
8169
|
// src/catalog/read-only.ts
|
|
8120
8170
|
class ReadOnlyCatalogInterface extends CatalogInterface {
|
|
8121
8171
|
_descriptor;
|
|
@@ -8141,6 +8191,9 @@ class ReadOnlyCatalogInterface extends CatalogInterface {
|
|
|
8141
8191
|
catalogs() {
|
|
8142
8192
|
return [this._descriptor.name];
|
|
8143
8193
|
}
|
|
8194
|
+
attachOptionSpecs(_name) {
|
|
8195
|
+
return [];
|
|
8196
|
+
}
|
|
8144
8197
|
catalogsInfo() {
|
|
8145
8198
|
return [{
|
|
8146
8199
|
name: this._descriptor.name,
|
|
@@ -8155,6 +8208,7 @@ class ReadOnlyCatalogInterface extends CatalogInterface {
|
|
|
8155
8208
|
if (!this.catalogs().includes(name)) {
|
|
8156
8209
|
throw new Error(`No worker handles catalog '${name}'`);
|
|
8157
8210
|
}
|
|
8211
|
+
validateRequiredAttachOptions(name, this.attachOptionSpecs(name), options ?? {});
|
|
8158
8212
|
const attachOpaqueData = new Uint8Array(16);
|
|
8159
8213
|
crypto.getRandomValues(attachOpaqueData);
|
|
8160
8214
|
this._attachments.set(name, attachOpaqueData);
|
|
@@ -9164,33 +9218,6 @@ class FunctionRegistry {
|
|
|
9164
9218
|
return result;
|
|
9165
9219
|
}
|
|
9166
9220
|
}
|
|
9167
|
-
// src/catalog/attach-option.ts
|
|
9168
|
-
init_arrow();
|
|
9169
|
-
var SPEC_SCHEMA = schema2([
|
|
9170
|
-
field2("name", utf82(), false),
|
|
9171
|
-
field2("description", utf82(), false),
|
|
9172
|
-
field2("type", binary2(), false),
|
|
9173
|
-
field2("default_value", binary2(), true)
|
|
9174
|
-
]);
|
|
9175
|
-
function serializeAttachOptionSpec(spec) {
|
|
9176
|
-
const typeSchema = schema2([field2("value", spec.type, true)]);
|
|
9177
|
-
const typeBytes = serializeSchema(typeSchema);
|
|
9178
|
-
let defaultBytes = null;
|
|
9179
|
-
if (spec.default !== undefined && spec.default !== null) {
|
|
9180
|
-
const defaultBatch = batchFromColumns({ value: [spec.default] }, typeSchema);
|
|
9181
|
-
defaultBytes = serializeBatch(defaultBatch);
|
|
9182
|
-
}
|
|
9183
|
-
const batch = batchFromColumns({
|
|
9184
|
-
name: [spec.name],
|
|
9185
|
-
description: [spec.description],
|
|
9186
|
-
type: [typeBytes],
|
|
9187
|
-
default_value: [defaultBytes]
|
|
9188
|
-
}, SPEC_SCHEMA);
|
|
9189
|
-
return serializeBatch(batch);
|
|
9190
|
-
}
|
|
9191
|
-
function serializeAttachOptionSpecs(specs) {
|
|
9192
|
-
return Array.from(specs, serializeAttachOptionSpec);
|
|
9193
|
-
}
|
|
9194
9221
|
// src/http/describe-json.ts
|
|
9195
9222
|
init_arrow();
|
|
9196
9223
|
var LANDING_SCHEMA_VERSION2 = 1;
|
|
@@ -9712,4 +9739,4 @@ export {
|
|
|
9712
9739
|
Arguments
|
|
9713
9740
|
};
|
|
9714
9741
|
|
|
9715
|
-
//# debugId=
|
|
9742
|
+
//# debugId=676F411DADAC67E064756E2164756E21
|