albedo-node 0.5.7 → 0.5.89

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.ts CHANGED
@@ -1,18 +1,9 @@
1
1
  type ByteBuffer = Uint8Array;
2
- type BucketHandle = object;
3
- type ListIteratorHandle = object;
4
- type TransformIteratorHandle = object;
5
2
  interface IndexOptions {
6
3
  unique: boolean;
7
4
  sparse: boolean;
8
5
  reverse: boolean;
9
6
  }
10
- interface IndexInfo {
11
- name: string;
12
- unique: boolean;
13
- sparse: boolean;
14
- reverse: boolean;
15
- }
16
7
  interface ObjectIdInstance {
17
8
  buffer: ByteBuffer;
18
9
  toString(): string;
@@ -21,32 +12,11 @@ interface ObjectIdConstructor {
21
12
  new (buffer?: ByteBuffer): ObjectIdInstance;
22
13
  fromString(str: string): ObjectIdInstance;
23
14
  }
24
- interface AlbedoModule {
25
- ObjectId: ObjectIdConstructor;
26
- serialize(value: unknown): Uint8Array;
27
- deserialize<T = unknown>(data: ByteBuffer): T;
28
- open(path: string): BucketHandle;
29
- close(bucket: BucketHandle): void;
30
- list(bucket: BucketHandle, query: object): ListIteratorHandle;
31
- listClose(cursor: ListIteratorHandle): void;
32
- listData(cursor: ListIteratorHandle): unknown | null;
33
- insert(bucket: BucketHandle, doc: ByteBuffer | object): void;
34
- ensureIndex(bucket: BucketHandle, name: string, options: IndexOptions): void;
35
- listIndexes(bucket: BucketHandle): Record<string, IndexInfo>;
36
- dropIndex(bucket: BucketHandle, name: string): void;
37
- delete(bucket: BucketHandle, query: object): void;
38
- transform(bucket: BucketHandle, query: object): TransformIteratorHandle;
39
- transformClose(iter: TransformIteratorHandle): void;
40
- transformData(iter: TransformIteratorHandle): unknown | null;
41
- transformApply(iter: TransformIteratorHandle, replace: ByteBuffer | object | null): void;
42
- setReplicationCallback(bucket: BucketHandle, callback: (data: Uint8Array) => void): void;
43
- applyReplicationBatch(bucket: BucketHandle, data: ByteBuffer): void;
44
- }
45
- declare const albedo: AlbedoModule;
15
+ export declare const albedo: any;
46
16
  export default albedo;
47
17
  export declare const BSON: {
48
- serialize: (value: unknown) => Uint8Array;
49
- deserialize: <T = unknown>(data: ByteBuffer) => T;
18
+ serialize: any;
19
+ deserialize: any;
50
20
  };
51
21
  /**
52
22
  * Native ObjectId class constructor.
@@ -135,7 +105,7 @@ export declare class Bucket {
135
105
  * console.log(bucket.indexes);
136
106
  * ```
137
107
  */
138
- get indexes(): Record<string, IndexInfo>;
108
+ get indexes(): any;
139
109
  /**
140
110
  * Create or update an index on a field.
141
111
  * @param name - index name (field path)
package/dist/index.js CHANGED
@@ -1,16 +1,41 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Query = exports.Bucket = exports.ObjectId = exports.BSON = void 0;
3
+ exports.Query = exports.Bucket = exports.ObjectId = exports.BSON = exports.albedo = void 0;
4
4
  exports.where = where;
5
- const platformSuffix = process.platform == "darwin" ? "macos" : process.platform === "win32" ? "windows" : process.platform;
6
- const archSuffix = process.arch === "x64" ? "x86_64" : process.arch === "arm64" ? "aarch64" : process.arch;
7
- const isMusl = process.versions.libc && process.versions.libc.includes("musl");
8
- const libcSuffix = process.platform == "linux" ? (isMusl ? "_musl" : "_gnu") : "";
9
- const albedo = require(`../native/albedo.${archSuffix}_${platformSuffix}${libcSuffix}.node`);
10
- exports.default = albedo;
5
+ const detect_libc_1 = require("detect-libc");
6
+ function getNativeBinding() {
7
+ const platformMap = {
8
+ win32: "windows",
9
+ darwin: "macos",
10
+ linux: "linux",
11
+ aix: "",
12
+ android: "",
13
+ freebsd: "",
14
+ haiku: "",
15
+ openbsd: "",
16
+ sunos: "",
17
+ cygwin: "",
18
+ netbsd: "",
19
+ };
20
+ const archMap = {
21
+ x64: "x86_64",
22
+ arm64: "aarch64",
23
+ };
24
+ const platform = platformMap[process.platform] ?? process.platform;
25
+ const arch = archMap[process.arch] ?? process.arch;
26
+ let suffix = "";
27
+ if (platform === "linux") {
28
+ const libc = (0, detect_libc_1.familySync)(); // 'glibc' | 'musl' | null
29
+ suffix = libc === detect_libc_1.MUSL ? "_musl" : "_gnu";
30
+ }
31
+ const filename = `albedo.${arch}_${platform}${suffix}.node`;
32
+ return require(`../native/${filename}`); // or import() if you prefer ESM
33
+ }
34
+ exports.albedo = getNativeBinding();
35
+ exports.default = exports.albedo;
11
36
  exports.BSON = {
12
- serialize: albedo.serialize,
13
- deserialize: albedo.deserialize,
37
+ serialize: exports.albedo.serialize,
38
+ deserialize: exports.albedo.deserialize,
14
39
  };
15
40
  /**
16
41
  * Native ObjectId class constructor.
@@ -21,7 +46,7 @@ exports.BSON = {
21
46
  * const parsed = ObjectId.fromString(id.toString());
22
47
  * ```
23
48
  */
24
- exports.ObjectId = albedo.ObjectId;
49
+ exports.ObjectId = exports.albedo.ObjectId;
25
50
  /**
26
51
  * Wrapper around a native Albedo bucket handle providing
27
52
  * methods for CRUD operations, indexing, iteration, and
@@ -65,7 +90,7 @@ class Bucket {
65
90
  * ```
66
91
  */
67
92
  static open(path) {
68
- const handle = albedo.open(path);
93
+ const handle = exports.albedo.open(path);
69
94
  return new Bucket(handle);
70
95
  }
71
96
  /**
@@ -76,7 +101,7 @@ class Bucket {
76
101
  * ```
77
102
  */
78
103
  close() {
79
- albedo.close(this.handle);
104
+ exports.albedo.close(this.handle);
80
105
  }
81
106
  /**
82
107
  * Insert a document or raw byte buffer into the bucket.
@@ -87,7 +112,7 @@ class Bucket {
87
112
  * ```
88
113
  */
89
114
  insert(doc) {
90
- albedo.insert(this.handle, doc);
115
+ exports.albedo.insert(this.handle, doc);
91
116
  }
92
117
  /**
93
118
  * Delete documents matching the query. If no query is provided,
@@ -101,7 +126,7 @@ class Bucket {
101
126
  * ```
102
127
  */
103
128
  delete(query) {
104
- albedo.delete(this.handle, Bucket.convertToQuery(query));
129
+ exports.albedo.delete(this.handle, Bucket.convertToQuery(query));
105
130
  }
106
131
  /**
107
132
  * Retrieve information about all indexes defined on the bucket.
@@ -111,7 +136,7 @@ class Bucket {
111
136
  * ```
112
137
  */
113
138
  get indexes() {
114
- return albedo.listIndexes(this.handle);
139
+ return exports.albedo.listIndexes(this.handle);
115
140
  }
116
141
  /**
117
142
  * Create or update an index on a field.
@@ -123,7 +148,7 @@ class Bucket {
123
148
  * ```
124
149
  */
125
150
  ensureIndex(name, options) {
126
- albedo.ensureIndex(this.handle, name, options);
151
+ exports.albedo.ensureIndex(this.handle, name, options);
127
152
  }
128
153
  /**
129
154
  * Remove an index by name.
@@ -133,7 +158,7 @@ class Bucket {
133
158
  * ```
134
159
  */
135
160
  dropIndex(name) {
136
- albedo.dropIndex(this.handle, name);
161
+ exports.albedo.dropIndex(this.handle, name);
137
162
  }
138
163
  /**
139
164
  * Iterate over documents matching the optional query.
@@ -147,15 +172,15 @@ class Bucket {
147
172
  * ```
148
173
  */
149
174
  *list(query) {
150
- const cursor = albedo.list(this.handle, Bucket.convertToQuery(query));
175
+ const cursor = exports.albedo.list(this.handle, Bucket.convertToQuery(query));
151
176
  try {
152
177
  let data;
153
- while ((data = albedo.listData(cursor)) !== null) {
178
+ while ((data = exports.albedo.listData(cursor)) !== null) {
154
179
  yield data;
155
180
  }
156
181
  }
157
182
  finally {
158
- albedo.listClose(cursor);
183
+ exports.albedo.listClose(cursor);
159
184
  }
160
185
  }
161
186
  /**
@@ -191,16 +216,16 @@ class Bucket {
191
216
  */
192
217
  *transformIterator(query) {
193
218
  const queryObj = Bucket.convertToQuery(query);
194
- const iter = albedo.transform(this.handle, queryObj);
219
+ const iter = exports.albedo.transform(this.handle, queryObj);
195
220
  try {
196
221
  let data;
197
- while ((data = albedo.transformData(iter)) !== undefined) {
222
+ while ((data = exports.albedo.transformData(iter)) !== undefined) {
198
223
  const newDoc = yield data;
199
- albedo.transformApply(iter, newDoc);
224
+ exports.albedo.transformApply(iter, newDoc);
200
225
  }
201
226
  }
202
227
  finally {
203
- albedo.transformClose(iter);
228
+ exports.albedo.transformClose(iter);
204
229
  }
205
230
  }
206
231
  /**
@@ -223,15 +248,15 @@ class Bucket {
223
248
  */
224
249
  transform(query, fn) {
225
250
  const queryObj = Bucket.convertToQuery(query);
226
- const iter = albedo.transform(this.handle, queryObj);
251
+ const iter = exports.albedo.transform(this.handle, queryObj);
227
252
  try {
228
253
  let data;
229
- while ((data = albedo.transformData(iter)) !== undefined) {
230
- albedo.transformApply(iter, fn(data));
254
+ while ((data = exports.albedo.transformData(iter)) !== undefined) {
255
+ exports.albedo.transformApply(iter, fn(data));
231
256
  }
232
257
  }
233
258
  finally {
234
- albedo.transformClose(iter);
259
+ exports.albedo.transformClose(iter);
235
260
  }
236
261
  }
237
262
  /**
@@ -246,7 +271,7 @@ class Bucket {
246
271
  * ```
247
272
  */
248
273
  setReplicationCallback(callback) {
249
- albedo.setReplicationCallback(this.handle, callback);
274
+ exports.albedo.setReplicationCallback(this.handle, callback);
250
275
  }
251
276
  /**
252
277
  * Apply a batch of replication operations to this bucket.
@@ -257,7 +282,7 @@ class Bucket {
257
282
  * ```
258
283
  */
259
284
  applyReplicationBatch(data) {
260
- albedo.applyReplicationBatch(this.handle, data);
285
+ exports.albedo.applyReplicationBatch(this.handle, data);
261
286
  }
262
287
  }
263
288
  exports.Bucket = Bucket;
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "albedo-node",
3
- "version": "0.5.7",
3
+ "version": "0.5.89",
4
4
  "description": "High-performance embedded database for Node.js with native bindings, BSON support, indexing, and replication",
5
5
  "keywords": [
6
6
  "albedo",
Binary file
Binary file
Binary file