hyperdb-wasm 0.0.26312-dev.wasm.g913ac019 → 0.0.26313-dev.wasm.g630768ec
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/browser.js +15 -1
- package/dist/hyperdb-wasm.cjs +1 -1
- package/dist/hyperdb-wasm.js +1 -1
- package/dist/hyperdb-wasm.wasm.br +0 -0
- package/dist/node.js +15 -1
- package/package.json +1 -1
package/dist/browser.js
CHANGED
|
@@ -12092,6 +12092,7 @@ RecordBatchFileWriter["throughDOM"] = recordBatchWriterThroughDOMStream;
|
|
|
12092
12092
|
RecordBatchStreamWriter["throughDOM"] = recordBatchWriterThroughDOMStream;
|
|
12093
12093
|
|
|
12094
12094
|
// src/api.ts
|
|
12095
|
+
var maxPersistentDatabaseNameLength = 200;
|
|
12095
12096
|
function normalizeArrowInsertOptions(options) {
|
|
12096
12097
|
if (!options.name) throw new Error("Arrow insert table name must not be empty");
|
|
12097
12098
|
return { name: options.name, schema: options.schema ?? null, create: options.create ?? true };
|
|
@@ -12100,6 +12101,18 @@ function validateDatabaseName(databaseName) {
|
|
|
12100
12101
|
if (!databaseName) throw new Error("Database name must not be empty");
|
|
12101
12102
|
if (databaseName.includes("\0")) throw new Error("Database name must not contain NUL");
|
|
12102
12103
|
}
|
|
12104
|
+
function validatePersistentDatabaseName(databaseName) {
|
|
12105
|
+
validateDatabaseName(databaseName);
|
|
12106
|
+
if (databaseName.length > maxPersistentDatabaseNameLength) {
|
|
12107
|
+
throw new Error(`Persistent database name must be at most ${maxPersistentDatabaseNameLength} characters`);
|
|
12108
|
+
}
|
|
12109
|
+
if (!/^[a-z0-9][a-z0-9_-]*$/.test(databaseName)) {
|
|
12110
|
+
throw new Error("Persistent database name must start with a lowercase ASCII letter or digit and contain only lowercase ASCII letters, digits, hyphens, and underscores");
|
|
12111
|
+
}
|
|
12112
|
+
if (/^(?:con|prn|aux|nul|com[1-9]|lpt[1-9])$/.test(databaseName)) {
|
|
12113
|
+
throw new Error("Persistent database name is reserved by Windows");
|
|
12114
|
+
}
|
|
12115
|
+
}
|
|
12103
12116
|
function validateDatabaseAlias(alias) {
|
|
12104
12117
|
if (!alias) throw new Error("Database alias must not be empty");
|
|
12105
12118
|
if (alias.includes("\0")) throw new Error("Database alias must not contain NUL");
|
|
@@ -12212,12 +12225,13 @@ var HyperDB = class _HyperDB {
|
|
|
12212
12225
|
if (options.storage !== void 0 && options.storage !== "memory" && options.storage !== "persistent") {
|
|
12213
12226
|
throw new Error(`Unsupported database storage: ${String(options.storage)}`);
|
|
12214
12227
|
}
|
|
12228
|
+
if (options.storage === "persistent") validatePersistentDatabaseName(databaseName);
|
|
12215
12229
|
await this.runDatabaseOperation(async () => {
|
|
12216
12230
|
expectOk(await this.client.createDatabase(databaseName, options.storage === "persistent"), "create database");
|
|
12217
12231
|
});
|
|
12218
12232
|
}
|
|
12219
12233
|
async openDatabase(databaseName) {
|
|
12220
|
-
|
|
12234
|
+
validatePersistentDatabaseName(databaseName);
|
|
12221
12235
|
await this.runDatabaseOperation(async () => {
|
|
12222
12236
|
expectOk(await this.client.openDatabase(databaseName), "open database");
|
|
12223
12237
|
});
|