@harperfast/rocksdb-js 0.1.2 → 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.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
@@ -893,6 +906,7 @@ declare class RocksDatabase extends DBI<DBITransactional> {
893
906
  * ```
894
907
  */
895
908
  static config(options: RocksDatabaseConfig): void;
909
+ destroy(): void;
896
910
  drop(): Promise<void>;
897
911
  dropSync(): void;
898
912
  get encoder(): Encoder | null;
@@ -1041,6 +1055,10 @@ declare class RocksDatabase extends DBI<DBITransactional> {
1041
1055
  */
1042
1056
  purgeLogs(options?: PurgeLogsOptions): string[];
1043
1057
  /**
1058
+ * The status of the database.
1059
+ */
1060
+ get status(): "open" | "closed";
1061
+ /**
1044
1062
  * Executes all operations in the callback as a single transaction.
1045
1063
  *
1046
1064
  * @param callback - A async function that receives the transaction as an argument.
@@ -1153,5 +1171,5 @@ declare const versions: {
1153
1171
  "rocksdb-js": string;
1154
1172
  };
1155
1173
  //#endregion
1156
- export { type Context, DBIterator, type IteratorOptions, 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 };
1157
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
@@ -1075,7 +1076,6 @@ var RocksDatabase = class RocksDatabase extends DBI {
1075
1076
  * ```
1076
1077
  */
1077
1078
  clear() {
1078
- if (!this.store.db.opened) return Promise.reject(/* @__PURE__ */ new Error("Database not open"));
1079
1079
  if (this.store.encoder?.structures !== void 0) this.store.encoder.structures = [];
1080
1080
  return new Promise((resolve, reject) => {
1081
1081
  this.store.db.clear(resolve, reject);
@@ -1091,9 +1091,8 @@ var RocksDatabase = class RocksDatabase extends DBI {
1091
1091
  * ```
1092
1092
  */
1093
1093
  clearSync() {
1094
- if (!this.store.db.opened) throw new Error("Database not open");
1095
1094
  if (this.store.encoder?.structures !== void 0) this.store.encoder.structures = [];
1096
- return this.store.db.clearSync();
1095
+ this.store.db.clearSync();
1097
1096
  }
1098
1097
  /**
1099
1098
  * Closes the database.
@@ -1120,14 +1119,15 @@ var RocksDatabase = class RocksDatabase extends DBI {
1120
1119
  static config(options) {
1121
1120
  config(options);
1122
1121
  }
1122
+ destroy() {
1123
+ this.store.db.destroy();
1124
+ }
1123
1125
  async drop() {
1124
- if (!this.store.db.opened) return Promise.reject(/* @__PURE__ */ new Error("Database not open"));
1125
1126
  return new Promise((resolve, reject) => {
1126
1127
  this.store.db.drop(resolve, reject);
1127
1128
  });
1128
1129
  }
1129
1130
  dropSync() {
1130
- if (!this.store.db.opened) throw new Error("Database not open");
1131
1131
  return this.store.db.dropSync();
1132
1132
  }
1133
1133
  get encoder() {
@@ -1386,6 +1386,12 @@ var RocksDatabase = class RocksDatabase extends DBI {
1386
1386
  return this.store.db.purgeLogs(options);
1387
1387
  }
1388
1388
  /**
1389
+ * The status of the database.
1390
+ */
1391
+ get status() {
1392
+ return this.store.isOpen() ? "open" : "closed";
1393
+ }
1394
+ /**
1389
1395
  * Executes all operations in the callback as a single transaction.
1390
1396
  *
1391
1397
  * @param callback - A async function that receives the transaction as an argument.
@@ -1774,9 +1780,9 @@ function loadLastPosition(transactionLog, readUncommitted) {
1774
1780
  //#region src/index.ts
1775
1781
  const versions = {
1776
1782
  rocksdb: version,
1777
- "rocksdb-js": "0.1.2"
1783
+ "rocksdb-js": "0.1.3"
1778
1784
  };
1779
1785
 
1780
1786
  //#endregion
1781
- export { DBIterator, RocksDatabase, Store, Transaction, TransactionLog, constants, parseTransactionLog, shutdown, versions };
1787
+ export { DBIterator, RocksDatabase, Store, Transaction, TransactionLog, constants, parseTransactionLog, registryStatus, shutdown, versions };
1782
1788
  //# sourceMappingURL=index.mjs.map