swiftbase-sdk 1.0.3 → 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 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({
@@ -3594,6 +3610,7 @@ var index_exports = {};
3594
3610
  __export(index_exports, {
3595
3611
  PaginatedResponse: () => PaginatedResponse,
3596
3612
  Storage: () => Storage,
3613
+ ai: () => ai,
3597
3614
  assignRole: () => assignRole,
3598
3615
  changePassword: () => changePassword,
3599
3616
  createRole: () => createRole,
@@ -4420,6 +4437,31 @@ var QueryBuilder = class {
4420
4437
  return yield makeRequest("post" /* POST */, "/api/db/query", void 0, this.payload);
4421
4438
  });
4422
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
+ }
4423
4465
  then(onfulfilled, onrejected) {
4424
4466
  return this.execute().then(onfulfilled, onrejected);
4425
4467
  }
@@ -4766,10 +4808,29 @@ var Storage = class {
4766
4808
  });
4767
4809
  }
4768
4810
  };
4811
+
4812
+ // src/ai.ts
4813
+ var ai = {
4814
+ chat: {
4815
+ completions: {
4816
+ create: (options) => __async(null, null, function* () {
4817
+ return yield makeRequest("post" /* POST */, "/api/ai/chat/completions", void 0, {
4818
+ model: options.model || "gemini-3.5-flash-lite",
4819
+ messages: options.messages,
4820
+ tools: options.tools,
4821
+ tool_choice: options.tool_choice,
4822
+ temperature: options.temperature,
4823
+ max_tokens: options.max_tokens
4824
+ });
4825
+ })
4826
+ }
4827
+ }
4828
+ };
4769
4829
  // Annotate the CommonJS export names for ESM import in node:
4770
4830
  0 && (module.exports = {
4771
4831
  PaginatedResponse,
4772
4832
  Storage,
4833
+ ai,
4773
4834
  assignRole,
4774
4835
  changePassword,
4775
4836
  createRole,