swiftbase-admin-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
|
};
|
|
@@ -88,6 +89,21 @@ var __async = (__this, __arguments, generator) => {
|
|
|
88
89
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
89
90
|
});
|
|
90
91
|
};
|
|
92
|
+
var __await = function(promise, isYieldStar) {
|
|
93
|
+
this[0] = promise;
|
|
94
|
+
this[1] = isYieldStar;
|
|
95
|
+
};
|
|
96
|
+
var __asyncGenerator = (__this, __arguments, generator) => {
|
|
97
|
+
var resume = (k, v, yes, no) => {
|
|
98
|
+
try {
|
|
99
|
+
var x = generator[k](v), isAwait = (v = x.value) instanceof __await, done = x.done;
|
|
100
|
+
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));
|
|
101
|
+
} catch (e) {
|
|
102
|
+
no(e);
|
|
103
|
+
}
|
|
104
|
+
}, 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 = {};
|
|
105
|
+
return generator = generator.apply(__this, __arguments), it[__knownSymbol("asyncIterator")] = () => it, method("next"), method("throw"), method("return"), it;
|
|
106
|
+
};
|
|
91
107
|
|
|
92
108
|
// src/common/token.ts
|
|
93
109
|
var _token, _type, _expiration, Token;
|
|
@@ -4363,6 +4379,31 @@ var QueryBuilder = class {
|
|
|
4363
4379
|
return yield makeRequest("post" /* POST */, "/api/db/query", void 0, this.payload);
|
|
4364
4380
|
});
|
|
4365
4381
|
}
|
|
4382
|
+
/**
|
|
4383
|
+
* Seamlessly stream query batches for large volume data operations
|
|
4384
|
+
*/
|
|
4385
|
+
stream() {
|
|
4386
|
+
return __asyncGenerator(this, arguments, function* (options = {}) {
|
|
4387
|
+
const batchSize = options.batchSize || 1e3;
|
|
4388
|
+
let offset = this.payload.offset || 0;
|
|
4389
|
+
const maxLimit = this.payload.limit;
|
|
4390
|
+
while (true) {
|
|
4391
|
+
const currentBatchLimit = maxLimit ? Math.min(batchSize, maxLimit - offset) : batchSize;
|
|
4392
|
+
if (currentBatchLimit <= 0) break;
|
|
4393
|
+
const pagePayload = __spreadProps(__spreadValues({}, this.payload), {
|
|
4394
|
+
limit: currentBatchLimit,
|
|
4395
|
+
offset
|
|
4396
|
+
});
|
|
4397
|
+
const result = yield new __await(makeRequest("post" /* POST */, "/api/db/query", void 0, pagePayload));
|
|
4398
|
+
const rows = result.data || [];
|
|
4399
|
+
if (rows.length === 0) break;
|
|
4400
|
+
yield { data: rows, count: rows.length };
|
|
4401
|
+
offset += rows.length;
|
|
4402
|
+
if (rows.length < currentBatchLimit) break;
|
|
4403
|
+
if (maxLimit && offset >= maxLimit) break;
|
|
4404
|
+
}
|
|
4405
|
+
});
|
|
4406
|
+
}
|
|
4366
4407
|
then(onfulfilled, onrejected) {
|
|
4367
4408
|
return this.execute().then(onfulfilled, onrejected);
|
|
4368
4409
|
}
|