swiftbase-sdk 1.0.4 → 1.0.5
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.cjs +41 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +41 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -240,6 +240,15 @@ declare class QueryBuilder implements PromiseLike<any> {
|
|
|
240
240
|
columns: string[];
|
|
241
241
|
count: number;
|
|
242
242
|
}>;
|
|
243
|
+
/**
|
|
244
|
+
* Seamlessly stream query batches for large volume data operations
|
|
245
|
+
*/
|
|
246
|
+
stream(options?: {
|
|
247
|
+
batchSize?: number;
|
|
248
|
+
}): AsyncGenerator<{
|
|
249
|
+
data: any[];
|
|
250
|
+
count: number;
|
|
251
|
+
}>;
|
|
243
252
|
then<TResult1 = any, TResult2 = never>(onfulfilled?: ((value: any) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
|
|
244
253
|
}
|
|
245
254
|
declare function db(dbName: string): (tableName: string) => QueryBuilder;
|
package/dist/index.d.ts
CHANGED
|
@@ -240,6 +240,15 @@ declare class QueryBuilder implements PromiseLike<any> {
|
|
|
240
240
|
columns: string[];
|
|
241
241
|
count: number;
|
|
242
242
|
}>;
|
|
243
|
+
/**
|
|
244
|
+
* Seamlessly stream query batches for large volume data operations
|
|
245
|
+
*/
|
|
246
|
+
stream(options?: {
|
|
247
|
+
batchSize?: number;
|
|
248
|
+
}): AsyncGenerator<{
|
|
249
|
+
data: any[];
|
|
250
|
+
count: number;
|
|
251
|
+
}>;
|
|
243
252
|
then<TResult1 = any, TResult2 = never>(onfulfilled?: ((value: any) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
|
|
244
253
|
}
|
|
245
254
|
declare function db(dbName: string): (tableName: string) => QueryBuilder;
|
package/dist/index.js
CHANGED
|
@@ -8,6 +8,7 @@ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
|
8
8
|
var __getProtoOf = Object.getPrototypeOf;
|
|
9
9
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
10
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
+
var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : /* @__PURE__ */ Symbol.for("Symbol." + name);
|
|
11
12
|
var __typeError = (msg) => {
|
|
12
13
|
throw TypeError(msg);
|
|
13
14
|
};
|
|
@@ -80,6 +81,21 @@ var __async = (__this, __arguments, generator) => {
|
|
|
80
81
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
81
82
|
});
|
|
82
83
|
};
|
|
84
|
+
var __await = function(promise, isYieldStar) {
|
|
85
|
+
this[0] = promise;
|
|
86
|
+
this[1] = isYieldStar;
|
|
87
|
+
};
|
|
88
|
+
var __asyncGenerator = (__this, __arguments, generator) => {
|
|
89
|
+
var resume = (k, v, yes, no) => {
|
|
90
|
+
try {
|
|
91
|
+
var x = generator[k](v), isAwait = (v = x.value) instanceof __await, done = x.done;
|
|
92
|
+
Promise.resolve(isAwait ? v[0] : v).then((y) => isAwait ? resume(k === "return" ? k : "next", v[1] ? { done: y.done, value: y.value } : y, yes, no) : yes({ value: y, done })).catch((e) => resume("throw", e, yes, no));
|
|
93
|
+
} catch (e) {
|
|
94
|
+
no(e);
|
|
95
|
+
}
|
|
96
|
+
}, method = (k, call, wait, clear) => it[k] = (x) => (call = new Promise((yes, no, run) => (run = () => resume(k, x, yes, no), q ? q.then(run) : run())), clear = () => q === wait && (q = 0), q = wait = call.then(clear, clear), call), q, it = {};
|
|
97
|
+
return generator = generator.apply(__this, __arguments), it[__knownSymbol("asyncIterator")] = () => it, method("next"), method("throw"), method("return"), it;
|
|
98
|
+
};
|
|
83
99
|
|
|
84
100
|
// node_modules/ws/lib/stream.js
|
|
85
101
|
var require_stream = __commonJS({
|
|
@@ -4386,6 +4402,31 @@ var QueryBuilder = class {
|
|
|
4386
4402
|
return yield makeRequest("post" /* POST */, "/api/db/query", void 0, this.payload);
|
|
4387
4403
|
});
|
|
4388
4404
|
}
|
|
4405
|
+
/**
|
|
4406
|
+
* Seamlessly stream query batches for large volume data operations
|
|
4407
|
+
*/
|
|
4408
|
+
stream() {
|
|
4409
|
+
return __asyncGenerator(this, arguments, function* (options = {}) {
|
|
4410
|
+
const batchSize = options.batchSize || 1e3;
|
|
4411
|
+
let offset = this.payload.offset || 0;
|
|
4412
|
+
const maxLimit = this.payload.limit;
|
|
4413
|
+
while (true) {
|
|
4414
|
+
const currentBatchLimit = maxLimit ? Math.min(batchSize, maxLimit - offset) : batchSize;
|
|
4415
|
+
if (currentBatchLimit <= 0) break;
|
|
4416
|
+
const pagePayload = __spreadProps(__spreadValues({}, this.payload), {
|
|
4417
|
+
limit: currentBatchLimit,
|
|
4418
|
+
offset
|
|
4419
|
+
});
|
|
4420
|
+
const result = yield new __await(makeRequest("post" /* POST */, "/api/db/query", void 0, pagePayload));
|
|
4421
|
+
const rows = result.data || [];
|
|
4422
|
+
if (rows.length === 0) break;
|
|
4423
|
+
yield { data: rows, count: rows.length };
|
|
4424
|
+
offset += rows.length;
|
|
4425
|
+
if (rows.length < currentBatchLimit) break;
|
|
4426
|
+
if (maxLimit && offset >= maxLimit) break;
|
|
4427
|
+
}
|
|
4428
|
+
});
|
|
4429
|
+
}
|
|
4389
4430
|
then(onfulfilled, onrejected) {
|
|
4390
4431
|
return this.execute().then(onfulfilled, onrejected);
|
|
4391
4432
|
}
|