@harperfast/rocksdb-js 0.1.1 → 0.1.3

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/index.d.cts CHANGED
@@ -427,6 +427,7 @@ type NativeDatabase = {
427
427
  clear(resolve: ResolveCallback<void>, reject: RejectCallback): void;
428
428
  clearSync(): void;
429
429
  close(): void;
430
+ destroy(): void;
430
431
  drop(resolve: ResolveCallback<void>, reject: RejectCallback): void;
431
432
  dropSync(): void;
432
433
  flush(resolve: ResolveCallback<void>, reject: RejectCallback): void;
@@ -459,6 +460,17 @@ type NativeDatabase = {
459
460
  type RocksDatabaseConfig = {
460
461
  blockCacheSize?: number;
461
462
  };
463
+ type RegistryStatusDB = {
464
+ path: string;
465
+ refCount: number;
466
+ columnFamilies: string[];
467
+ transactions: number;
468
+ closables: number;
469
+ locks: number;
470
+ userSharedBuffers: number;
471
+ listenerCallbacks: number;
472
+ };
473
+ type RegistryStatus = RegistryStatusDB[];
462
474
  declare const constants: {
463
475
  TRANSACTION_LOG_TOKEN: number;
464
476
  TRANSACTION_LOG_FILE_HEADER_SIZE: number;
@@ -470,6 +482,7 @@ declare const constants: {
470
482
  declare const NativeDatabase: NativeDatabase;
471
483
  declare const NativeTransaction: NativeTransaction;
472
484
  declare const TransactionLog: TransactionLog;
485
+ declare const registryStatus: () => RegistryStatus;
473
486
  declare const shutdown: () => void;
474
487
  //#endregion
475
488
  //#region src/transaction.d.ts
@@ -850,6 +863,7 @@ interface RocksDatabaseOptions extends StoreOptions {
850
863
  * ```
851
864
  */
852
865
  declare class RocksDatabase extends DBI<DBITransactional> {
866
+ #private;
853
867
  constructor(pathOrStore: string | Store, options?: RocksDatabaseOptions);
854
868
  /**
855
869
  * Removes all data from the database asynchronously.
@@ -892,6 +906,7 @@ declare class RocksDatabase extends DBI<DBITransactional> {
892
906
  * ```
893
907
  */
894
908
  static config(options: RocksDatabaseConfig): void;
909
+ destroy(): void;
895
910
  drop(): Promise<void>;
896
911
  dropSync(): void;
897
912
  get encoder(): Encoder | null;
@@ -1002,6 +1017,10 @@ declare class RocksDatabase extends DBI<DBITransactional> {
1002
1017
  */
1003
1018
  listLogs(): string[];
1004
1019
  /**
1020
+ * The name of the database.
1021
+ */
1022
+ get name(): string;
1023
+ /**
1005
1024
  * Sugar method for opening a database.
1006
1025
  *
1007
1026
  * @param pathOrStore - The filesystem path to the database or a custom store.
@@ -1036,6 +1055,10 @@ declare class RocksDatabase extends DBI<DBITransactional> {
1036
1055
  */
1037
1056
  purgeLogs(options?: PurgeLogsOptions): string[];
1038
1057
  /**
1058
+ * The status of the database.
1059
+ */
1060
+ get status(): "open" | "closed";
1061
+ /**
1039
1062
  * Executes all operations in the callback as a single transaction.
1040
1063
  *
1041
1064
  * @param callback - A async function that receives the transaction as an argument.
@@ -1148,5 +1171,5 @@ declare const versions: {
1148
1171
  "rocksdb-js": string;
1149
1172
  };
1150
1173
  //#endregion
1151
- export { type Context, DBIterator, type Key, RocksDatabase, type RocksDatabaseOptions, Store, Transaction, type TransactionEntry, TransactionLog, constants, parseTransactionLog, shutdown, versions };
1174
+ export { type Context, DBIterator, type IteratorOptions, type Key, RocksDatabase, type RocksDatabaseOptions, Store, Transaction, type TransactionEntry, TransactionLog, constants, parseTransactionLog, registryStatus, shutdown, versions };
1152
1175
  //# sourceMappingURL=index.d.cts.map
package/dist/index.d.mts CHANGED
@@ -427,6 +427,7 @@ type NativeDatabase = {
427
427
  clear(resolve: ResolveCallback<void>, reject: RejectCallback): void;
428
428
  clearSync(): void;
429
429
  close(): void;
430
+ destroy(): void;
430
431
  drop(resolve: ResolveCallback<void>, reject: RejectCallback): void;
431
432
  dropSync(): void;
432
433
  flush(resolve: ResolveCallback<void>, reject: RejectCallback): void;
@@ -459,6 +460,17 @@ type NativeDatabase = {
459
460
  type RocksDatabaseConfig = {
460
461
  blockCacheSize?: number;
461
462
  };
463
+ type RegistryStatusDB = {
464
+ path: string;
465
+ refCount: number;
466
+ columnFamilies: string[];
467
+ transactions: number;
468
+ closables: number;
469
+ locks: number;
470
+ userSharedBuffers: number;
471
+ listenerCallbacks: number;
472
+ };
473
+ type RegistryStatus = RegistryStatusDB[];
462
474
  declare const constants: {
463
475
  TRANSACTION_LOG_TOKEN: number;
464
476
  TRANSACTION_LOG_FILE_HEADER_SIZE: number;
@@ -470,6 +482,7 @@ declare const constants: {
470
482
  declare const NativeDatabase: NativeDatabase;
471
483
  declare const NativeTransaction: NativeTransaction;
472
484
  declare const TransactionLog: TransactionLog;
485
+ declare const registryStatus: () => RegistryStatus;
473
486
  declare const shutdown: () => void;
474
487
  //#endregion
475
488
  //#region src/transaction.d.ts
@@ -850,6 +863,7 @@ interface RocksDatabaseOptions extends StoreOptions {
850
863
  * ```
851
864
  */
852
865
  declare class RocksDatabase extends DBI<DBITransactional> {
866
+ #private;
853
867
  constructor(pathOrStore: string | Store, options?: RocksDatabaseOptions);
854
868
  /**
855
869
  * Removes all data from the database asynchronously.
@@ -892,6 +906,7 @@ declare class RocksDatabase extends DBI<DBITransactional> {
892
906
  * ```
893
907
  */
894
908
  static config(options: RocksDatabaseConfig): void;
909
+ destroy(): void;
895
910
  drop(): Promise<void>;
896
911
  dropSync(): void;
897
912
  get encoder(): Encoder | null;
@@ -1002,6 +1017,10 @@ declare class RocksDatabase extends DBI<DBITransactional> {
1002
1017
  */
1003
1018
  listLogs(): string[];
1004
1019
  /**
1020
+ * The name of the database.
1021
+ */
1022
+ get name(): string;
1023
+ /**
1005
1024
  * Sugar method for opening a database.
1006
1025
  *
1007
1026
  * @param pathOrStore - The filesystem path to the database or a custom store.
@@ -1036,6 +1055,10 @@ declare class RocksDatabase extends DBI<DBITransactional> {
1036
1055
  */
1037
1056
  purgeLogs(options?: PurgeLogsOptions): string[];
1038
1057
  /**
1058
+ * The status of the database.
1059
+ */
1060
+ get status(): "open" | "closed";
1061
+ /**
1039
1062
  * Executes all operations in the callback as a single transaction.
1040
1063
  *
1041
1064
  * @param callback - A async function that receives the transaction as an argument.
@@ -1148,5 +1171,5 @@ declare const versions: {
1148
1171
  "rocksdb-js": string;
1149
1172
  };
1150
1173
  //#endregion
1151
- export { type Context, DBIterator, type Key, RocksDatabase, type RocksDatabaseOptions, Store, Transaction, type TransactionEntry, TransactionLog, constants, parseTransactionLog, shutdown, versions };
1174
+ export { type Context, DBIterator, type IteratorOptions, type Key, RocksDatabase, type RocksDatabaseOptions, Store, Transaction, type TransactionEntry, TransactionLog, constants, parseTransactionLog, registryStatus, shutdown, versions };
1152
1175
  //# sourceMappingURL=index.d.mts.map
package/dist/index.mjs CHANGED
@@ -7,7 +7,7 @@ import { Encoder } from "msgpackr";
7
7
  import * as orderedBinary from "ordered-binary";
8
8
  import { ExtendedIterable } from "@harperfast/extended-iterable";
9
9
 
10
- //#region rolldown:runtime
10
+ //#region \0rolldown/runtime.js
11
11
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
12
12
 
13
13
  //#endregion
@@ -55,8 +55,9 @@ const NativeDatabase = binding.Database;
55
55
  const NativeIterator = binding.Iterator;
56
56
  const NativeTransaction = binding.Transaction;
57
57
  const TransactionLog = binding.TransactionLog;
58
- const version = binding.version;
58
+ const registryStatus = binding.registryStatus;
59
59
  const shutdown = binding.shutdown;
60
+ const version = binding.version;
60
61
 
61
62
  //#endregion
62
63
  //#region src/util.ts
@@ -1055,10 +1056,15 @@ var Transaction = class extends DBI {
1055
1056
  * ```
1056
1057
  */
1057
1058
  var RocksDatabase = class RocksDatabase extends DBI {
1059
+ /**
1060
+ * The name of the database.
1061
+ */
1062
+ #name;
1058
1063
  constructor(pathOrStore, options) {
1059
1064
  if (typeof pathOrStore === "string") super(new Store(pathOrStore, options));
1060
1065
  else if (pathOrStore instanceof Store) super(pathOrStore);
1061
1066
  else throw new TypeError("Invalid database path or store");
1067
+ this.#name = options?.name ?? "default";
1062
1068
  }
1063
1069
  /**
1064
1070
  * Removes all data from the database asynchronously.
@@ -1070,7 +1076,6 @@ var RocksDatabase = class RocksDatabase extends DBI {
1070
1076
  * ```
1071
1077
  */
1072
1078
  clear() {
1073
- if (!this.store.db.opened) return Promise.reject(/* @__PURE__ */ new Error("Database not open"));
1074
1079
  if (this.store.encoder?.structures !== void 0) this.store.encoder.structures = [];
1075
1080
  return new Promise((resolve, reject) => {
1076
1081
  this.store.db.clear(resolve, reject);
@@ -1086,9 +1091,8 @@ var RocksDatabase = class RocksDatabase extends DBI {
1086
1091
  * ```
1087
1092
  */
1088
1093
  clearSync() {
1089
- if (!this.store.db.opened) throw new Error("Database not open");
1090
1094
  if (this.store.encoder?.structures !== void 0) this.store.encoder.structures = [];
1091
- return this.store.db.clearSync();
1095
+ this.store.db.clearSync();
1092
1096
  }
1093
1097
  /**
1094
1098
  * Closes the database.
@@ -1115,14 +1119,15 @@ var RocksDatabase = class RocksDatabase extends DBI {
1115
1119
  static config(options) {
1116
1120
  config(options);
1117
1121
  }
1122
+ destroy() {
1123
+ this.store.db.destroy();
1124
+ }
1118
1125
  async drop() {
1119
- if (!this.store.db.opened) return Promise.reject(/* @__PURE__ */ new Error("Database not open"));
1120
1126
  return new Promise((resolve, reject) => {
1121
1127
  this.store.db.drop(resolve, reject);
1122
1128
  });
1123
1129
  }
1124
1130
  dropSync() {
1125
- if (!this.store.db.opened) throw new Error("Database not open");
1126
1131
  return this.store.db.dropSync();
1127
1132
  }
1128
1133
  get encoder() {
@@ -1257,6 +1262,12 @@ var RocksDatabase = class RocksDatabase extends DBI {
1257
1262
  return this.store.listLogs();
1258
1263
  }
1259
1264
  /**
1265
+ * The name of the database.
1266
+ */
1267
+ get name() {
1268
+ return this.#name;
1269
+ }
1270
+ /**
1260
1271
  * Sugar method for opening a database.
1261
1272
  *
1262
1273
  * @param pathOrStore - The filesystem path to the database or a custom store.
@@ -1375,6 +1386,12 @@ var RocksDatabase = class RocksDatabase extends DBI {
1375
1386
  return this.store.db.purgeLogs(options);
1376
1387
  }
1377
1388
  /**
1389
+ * The status of the database.
1390
+ */
1391
+ get status() {
1392
+ return this.store.isOpen() ? "open" : "closed";
1393
+ }
1394
+ /**
1378
1395
  * Executes all operations in the callback as a single transaction.
1379
1396
  *
1380
1397
  * @param callback - A async function that receives the transaction as an argument.
@@ -1763,9 +1780,9 @@ function loadLastPosition(transactionLog, readUncommitted) {
1763
1780
  //#region src/index.ts
1764
1781
  const versions = {
1765
1782
  rocksdb: version,
1766
- "rocksdb-js": "0.1.1"
1783
+ "rocksdb-js": "0.1.3"
1767
1784
  };
1768
1785
 
1769
1786
  //#endregion
1770
- export { DBIterator, RocksDatabase, Store, Transaction, TransactionLog, constants, parseTransactionLog, shutdown, versions };
1787
+ export { DBIterator, RocksDatabase, Store, Transaction, TransactionLog, constants, parseTransactionLog, registryStatus, shutdown, versions };
1771
1788
  //# sourceMappingURL=index.mjs.map