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.d.cts CHANGED
@@ -314,6 +314,15 @@ declare class QueryBuilder implements PromiseLike<any> {
314
314
  columns: string[];
315
315
  count: number;
316
316
  }>;
317
+ /**
318
+ * Seamlessly stream query batches for large volume data operations
319
+ */
320
+ stream(options?: {
321
+ batchSize?: number;
322
+ }): AsyncGenerator<{
323
+ data: any[];
324
+ count: number;
325
+ }>;
317
326
  then<TResult1 = any, TResult2 = never>(onfulfilled?: ((value: any) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
318
327
  }
319
328
  interface TableDefinition {
package/dist/index.d.ts CHANGED
@@ -314,6 +314,15 @@ declare class QueryBuilder implements PromiseLike<any> {
314
314
  columns: string[];
315
315
  count: number;
316
316
  }>;
317
+ /**
318
+ * Seamlessly stream query batches for large volume data operations
319
+ */
320
+ stream(options?: {
321
+ batchSize?: number;
322
+ }): AsyncGenerator<{
323
+ data: any[];
324
+ count: number;
325
+ }>;
317
326
  then<TResult1 = any, TResult2 = never>(onfulfilled?: ((value: any) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
318
327
  }
319
328
  interface TableDefinition {
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
  };
@@ -92,6 +93,21 @@ var __async = (__this, __arguments, generator) => {
92
93
  step((generator = generator.apply(__this, __arguments)).next());
93
94
  });
94
95
  };
96
+ var __await = function(promise, isYieldStar) {
97
+ this[0] = promise;
98
+ this[1] = isYieldStar;
99
+ };
100
+ var __asyncGenerator = (__this, __arguments, generator) => {
101
+ var resume = (k, v, yes, no) => {
102
+ try {
103
+ var x = generator[k](v), isAwait = (v = x.value) instanceof __await, done = x.done;
104
+ 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));
105
+ } catch (e) {
106
+ no(e);
107
+ }
108
+ }, 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 = {};
109
+ return generator = generator.apply(__this, __arguments), it[__knownSymbol("asyncIterator")] = () => it, method("next"), method("throw"), method("return"), it;
110
+ };
95
111
 
96
112
  // src/common/token.ts
97
113
  var _token, _type, _expiration, Token;
@@ -4331,6 +4347,31 @@ var QueryBuilder = class {
4331
4347
  return yield makeRequest("post" /* POST */, "/api/db/query", void 0, this.payload);
4332
4348
  });
4333
4349
  }
4350
+ /**
4351
+ * Seamlessly stream query batches for large volume data operations
4352
+ */
4353
+ stream() {
4354
+ return __asyncGenerator(this, arguments, function* (options = {}) {
4355
+ const batchSize = options.batchSize || 1e3;
4356
+ let offset = this.payload.offset || 0;
4357
+ const maxLimit = this.payload.limit;
4358
+ while (true) {
4359
+ const currentBatchLimit = maxLimit ? Math.min(batchSize, maxLimit - offset) : batchSize;
4360
+ if (currentBatchLimit <= 0) break;
4361
+ const pagePayload = __spreadProps(__spreadValues({}, this.payload), {
4362
+ limit: currentBatchLimit,
4363
+ offset
4364
+ });
4365
+ const result = yield new __await(makeRequest("post" /* POST */, "/api/db/query", void 0, pagePayload));
4366
+ const rows = result.data || [];
4367
+ if (rows.length === 0) break;
4368
+ yield { data: rows, count: rows.length };
4369
+ offset += rows.length;
4370
+ if (rows.length < currentBatchLimit) break;
4371
+ if (maxLimit && offset >= maxLimit) break;
4372
+ }
4373
+ });
4374
+ }
4334
4375
  then(onfulfilled, onrejected) {
4335
4376
  return this.execute().then(onfulfilled, onrejected);
4336
4377
  }