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.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;
@@ -295,4 +304,66 @@ declare class Storage {
295
304
  deleteObject(key: string): Promise<void>;
296
305
  }
297
306
 
298
- export { type AuthorizeOptions, type BucketInfo, type ChangePasswordInput, type ListObjectsResult, type LoginInput, PaginatedResponse, type Profile, type ProfileInput, type ResetPasswordInput, type S3Object, Storage, type StorageOptions, type TokenResponse, assignRole, changePassword, createRole, createService, db, deleteRole, deleteService, getAccessToken, getProfile, getRoles, getServices, getUsers, handleRedirectCallback, initializeSdk, isLoggedIn, loginService as login, loginService, loginWithPassword, loginWithRedirect, logout, refreshTokens, resetPassword, search, setAccessToken, setRefreshToken, unassignRole, updateProfile, updateUser, verifyServiceToken, verifyToken };
307
+ interface AIToolCall {
308
+ id: string;
309
+ type: "function";
310
+ function: {
311
+ name: string;
312
+ arguments: string;
313
+ };
314
+ }
315
+ interface AITool {
316
+ type: "function";
317
+ function: {
318
+ name: string;
319
+ description?: string;
320
+ parameters?: Record<string, any>;
321
+ };
322
+ }
323
+ interface AIChatMessage {
324
+ role: "system" | "user" | "assistant" | "tool";
325
+ content?: string | null;
326
+ name?: string;
327
+ tool_call_id?: string;
328
+ tool_calls?: AIToolCall[];
329
+ }
330
+ interface AIChatCompletionOptions {
331
+ model?: string;
332
+ messages: AIChatMessage[];
333
+ tools?: AITool[];
334
+ tool_choice?: any;
335
+ temperature?: number;
336
+ max_tokens?: number;
337
+ }
338
+ interface AIChatCompletionResponse {
339
+ id?: string;
340
+ object?: string;
341
+ created?: number;
342
+ model?: string;
343
+ choices: Array<{
344
+ index?: number;
345
+ message: {
346
+ role: string;
347
+ content: string | null;
348
+ tool_calls?: AIToolCall[];
349
+ };
350
+ finish_reason?: string;
351
+ }>;
352
+ usage?: {
353
+ prompt_tokens: number;
354
+ completion_tokens: number;
355
+ total_tokens: number;
356
+ };
357
+ }
358
+ /**
359
+ * Generate completion using the AI service.
360
+ */
361
+ declare const ai: {
362
+ chat: {
363
+ completions: {
364
+ create: (options: AIChatCompletionOptions) => Promise<AIChatCompletionResponse>;
365
+ };
366
+ };
367
+ };
368
+
369
+ export { type AIChatCompletionOptions, type AIChatCompletionResponse, type AIChatMessage, type AuthorizeOptions, type BucketInfo, type ChangePasswordInput, type ListObjectsResult, type LoginInput, PaginatedResponse, type Profile, type ProfileInput, type ResetPasswordInput, type S3Object, Storage, type StorageOptions, type TokenResponse, ai, assignRole, changePassword, createRole, createService, db, deleteRole, deleteService, getAccessToken, getProfile, getRoles, getServices, getUsers, handleRedirectCallback, initializeSdk, isLoggedIn, loginService as login, loginService, loginWithPassword, loginWithRedirect, logout, refreshTokens, resetPassword, search, setAccessToken, setRefreshToken, unassignRole, updateProfile, updateUser, verifyServiceToken, verifyToken };
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;
@@ -295,4 +304,66 @@ declare class Storage {
295
304
  deleteObject(key: string): Promise<void>;
296
305
  }
297
306
 
298
- export { type AuthorizeOptions, type BucketInfo, type ChangePasswordInput, type ListObjectsResult, type LoginInput, PaginatedResponse, type Profile, type ProfileInput, type ResetPasswordInput, type S3Object, Storage, type StorageOptions, type TokenResponse, assignRole, changePassword, createRole, createService, db, deleteRole, deleteService, getAccessToken, getProfile, getRoles, getServices, getUsers, handleRedirectCallback, initializeSdk, isLoggedIn, loginService as login, loginService, loginWithPassword, loginWithRedirect, logout, refreshTokens, resetPassword, search, setAccessToken, setRefreshToken, unassignRole, updateProfile, updateUser, verifyServiceToken, verifyToken };
307
+ interface AIToolCall {
308
+ id: string;
309
+ type: "function";
310
+ function: {
311
+ name: string;
312
+ arguments: string;
313
+ };
314
+ }
315
+ interface AITool {
316
+ type: "function";
317
+ function: {
318
+ name: string;
319
+ description?: string;
320
+ parameters?: Record<string, any>;
321
+ };
322
+ }
323
+ interface AIChatMessage {
324
+ role: "system" | "user" | "assistant" | "tool";
325
+ content?: string | null;
326
+ name?: string;
327
+ tool_call_id?: string;
328
+ tool_calls?: AIToolCall[];
329
+ }
330
+ interface AIChatCompletionOptions {
331
+ model?: string;
332
+ messages: AIChatMessage[];
333
+ tools?: AITool[];
334
+ tool_choice?: any;
335
+ temperature?: number;
336
+ max_tokens?: number;
337
+ }
338
+ interface AIChatCompletionResponse {
339
+ id?: string;
340
+ object?: string;
341
+ created?: number;
342
+ model?: string;
343
+ choices: Array<{
344
+ index?: number;
345
+ message: {
346
+ role: string;
347
+ content: string | null;
348
+ tool_calls?: AIToolCall[];
349
+ };
350
+ finish_reason?: string;
351
+ }>;
352
+ usage?: {
353
+ prompt_tokens: number;
354
+ completion_tokens: number;
355
+ total_tokens: number;
356
+ };
357
+ }
358
+ /**
359
+ * Generate completion using the AI service.
360
+ */
361
+ declare const ai: {
362
+ chat: {
363
+ completions: {
364
+ create: (options: AIChatCompletionOptions) => Promise<AIChatCompletionResponse>;
365
+ };
366
+ };
367
+ };
368
+
369
+ export { type AIChatCompletionOptions, type AIChatCompletionResponse, type AIChatMessage, type AuthorizeOptions, type BucketInfo, type ChangePasswordInput, type ListObjectsResult, type LoginInput, PaginatedResponse, type Profile, type ProfileInput, type ResetPasswordInput, type S3Object, Storage, type StorageOptions, type TokenResponse, ai, assignRole, changePassword, createRole, createService, db, deleteRole, deleteService, getAccessToken, getProfile, getRoles, getServices, getUsers, handleRedirectCallback, initializeSdk, isLoggedIn, loginService as login, loginService, loginWithPassword, loginWithRedirect, logout, refreshTokens, resetPassword, search, setAccessToken, setRefreshToken, unassignRole, updateProfile, updateUser, verifyServiceToken, verifyToken };
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
  }
@@ -4732,9 +4773,28 @@ var Storage = class {
4732
4773
  });
4733
4774
  }
4734
4775
  };
4776
+
4777
+ // src/ai.ts
4778
+ var ai = {
4779
+ chat: {
4780
+ completions: {
4781
+ create: (options) => __async(null, null, function* () {
4782
+ return yield makeRequest("post" /* POST */, "/api/ai/chat/completions", void 0, {
4783
+ model: options.model || "gemini-3.5-flash-lite",
4784
+ messages: options.messages,
4785
+ tools: options.tools,
4786
+ tool_choice: options.tool_choice,
4787
+ temperature: options.temperature,
4788
+ max_tokens: options.max_tokens
4789
+ });
4790
+ })
4791
+ }
4792
+ }
4793
+ };
4735
4794
  export {
4736
4795
  PaginatedResponse,
4737
4796
  Storage,
4797
+ ai,
4738
4798
  assignRole,
4739
4799
  changePassword,
4740
4800
  createRole,