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.cjs
CHANGED
|
@@ -9,6 +9,7 @@ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
|
9
9
|
var __getProtoOf = Object.getPrototypeOf;
|
|
10
10
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
11
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
12
|
+
var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : /* @__PURE__ */ Symbol.for("Symbol." + name);
|
|
12
13
|
var __typeError = (msg) => {
|
|
13
14
|
throw TypeError(msg);
|
|
14
15
|
};
|
|
@@ -76,6 +77,21 @@ var __async = (__this, __arguments, generator) => {
|
|
|
76
77
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
77
78
|
});
|
|
78
79
|
};
|
|
80
|
+
var __await = function(promise, isYieldStar) {
|
|
81
|
+
this[0] = promise;
|
|
82
|
+
this[1] = isYieldStar;
|
|
83
|
+
};
|
|
84
|
+
var __asyncGenerator = (__this, __arguments, generator) => {
|
|
85
|
+
var resume = (k, v, yes, no) => {
|
|
86
|
+
try {
|
|
87
|
+
var x = generator[k](v), isAwait = (v = x.value) instanceof __await, done = x.done;
|
|
88
|
+
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));
|
|
89
|
+
} catch (e) {
|
|
90
|
+
no(e);
|
|
91
|
+
}
|
|
92
|
+
}, 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 = {};
|
|
93
|
+
return generator = generator.apply(__this, __arguments), it[__knownSymbol("asyncIterator")] = () => it, method("next"), method("throw"), method("return"), it;
|
|
94
|
+
};
|
|
79
95
|
|
|
80
96
|
// node_modules/ws/lib/stream.js
|
|
81
97
|
var require_stream = __commonJS({
|
|
@@ -4421,6 +4437,31 @@ var QueryBuilder = class {
|
|
|
4421
4437
|
return yield makeRequest("post" /* POST */, "/api/db/query", void 0, this.payload);
|
|
4422
4438
|
});
|
|
4423
4439
|
}
|
|
4440
|
+
/**
|
|
4441
|
+
* Seamlessly stream query batches for large volume data operations
|
|
4442
|
+
*/
|
|
4443
|
+
stream() {
|
|
4444
|
+
return __asyncGenerator(this, arguments, function* (options = {}) {
|
|
4445
|
+
const batchSize = options.batchSize || 1e3;
|
|
4446
|
+
let offset = this.payload.offset || 0;
|
|
4447
|
+
const maxLimit = this.payload.limit;
|
|
4448
|
+
while (true) {
|
|
4449
|
+
const currentBatchLimit = maxLimit ? Math.min(batchSize, maxLimit - offset) : batchSize;
|
|
4450
|
+
if (currentBatchLimit <= 0) break;
|
|
4451
|
+
const pagePayload = __spreadProps(__spreadValues({}, this.payload), {
|
|
4452
|
+
limit: currentBatchLimit,
|
|
4453
|
+
offset
|
|
4454
|
+
});
|
|
4455
|
+
const result = yield new __await(makeRequest("post" /* POST */, "/api/db/query", void 0, pagePayload));
|
|
4456
|
+
const rows = result.data || [];
|
|
4457
|
+
if (rows.length === 0) break;
|
|
4458
|
+
yield { data: rows, count: rows.length };
|
|
4459
|
+
offset += rows.length;
|
|
4460
|
+
if (rows.length < currentBatchLimit) break;
|
|
4461
|
+
if (maxLimit && offset >= maxLimit) break;
|
|
4462
|
+
}
|
|
4463
|
+
});
|
|
4464
|
+
}
|
|
4424
4465
|
then(onfulfilled, onrejected) {
|
|
4425
4466
|
return this.execute().then(onfulfilled, onrejected);
|
|
4426
4467
|
}
|