@omnikit-ai/sdk 2.0.7 → 2.0.9

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.mjs CHANGED
@@ -435,8 +435,17 @@ var LiveVoiceSessionImpl = class {
435
435
 
436
436
  // src/client.ts
437
437
  var LLM_MODEL_MAP = {
438
+ // Gemini 2.5 models
439
+ "gemini-2.5-flash-lite": "vertex_ai/gemini-2.5-flash-lite",
440
+ "gemini-2.5-flash": "vertex_ai/gemini-2.5-flash",
441
+ "gemini-2.5-pro": "vertex_ai/gemini-2.5-pro",
442
+ // Gemini 3 models
443
+ "gemini-3-flash": "vertex_ai/gemini-3-flash-preview",
444
+ "gemini-3-pro": "vertex_ai/gemini-3-pro-preview",
445
+ // Legacy aliases (for backward compatibility)
438
446
  "gemini-flash": "vertex_ai/gemini-2.5-flash",
439
- "gemini-pro": "vertex_ai/gemini-2.5-pro"
447
+ "gemini-pro": "vertex_ai/gemini-2.5-pro",
448
+ "gemini-pro-3": "vertex_ai/gemini-3-pro-preview"
440
449
  };
441
450
  function mapLLMModel(model) {
442
451
  if (!model) return void 0;
@@ -614,6 +623,26 @@ var APIClient = class {
614
623
  get collections() {
615
624
  return this.createCollectionsProxy(false);
616
625
  }
626
+ /**
627
+ * Helper method to access a collection by name.
628
+ * Provides a more intuitive API: omnikit.collection('user').list()
629
+ * This is an alternative to: omnikit.collections.user.list()
630
+ *
631
+ * @param name - Collection name (case-insensitive, supports PascalCase, camelCase, snake_case)
632
+ * @returns CollectionClass with CRUD methods
633
+ *
634
+ * @example
635
+ * ```typescript
636
+ * // All of these work:
637
+ * await omnikit.collection('user').list()
638
+ * await omnikit.collection('User').list()
639
+ * await omnikit.collection('chatbot').list()
640
+ * await omnikit.collection('Chatbot').list()
641
+ * ```
642
+ */
643
+ collection(name) {
644
+ return this.collections[name];
645
+ }
617
646
  /**
618
647
  * @deprecated Use collections instead. This alias exists for backward compatibility.
619
648
  */
@@ -695,8 +724,12 @@ var APIClient = class {
695
724
  },
696
725
  login(returnUrl) {
697
726
  const fullReturnUrl = returnUrl || (typeof window !== "undefined" ? window.location.href : "/");
698
- const encodedReturnUrl = encodeURIComponent(fullReturnUrl);
699
727
  if (typeof window !== "undefined") {
728
+ if (window.__omnikit_openLoginModal) {
729
+ window.__omnikit_openLoginModal(fullReturnUrl);
730
+ return;
731
+ }
732
+ const encodedReturnUrl = encodeURIComponent(fullReturnUrl);
700
733
  const currentPath = window.location.pathname;
701
734
  const apiSitesMatch = currentPath.match(/^\/api\/sites\/([^\/]+)/);
702
735
  if (apiSitesMatch) {
@@ -1095,10 +1128,15 @@ Example: await ${collectionName}.list({ limit: 100, sort: '-created_at' })`,
1095
1128
  */
1096
1129
  createServicesProxy(useServiceToken) {
1097
1130
  const client = this;
1131
+ function normalizeServiceName(name) {
1132
+ if (!name) return name;
1133
+ return name.charAt(0).toUpperCase() + name.slice(1);
1134
+ }
1098
1135
  return new Proxy({}, {
1099
1136
  get(target, serviceName) {
1100
1137
  if (typeof serviceName === "string" && !serviceName.startsWith("_")) {
1101
- if (serviceName === "CheckJobStatus") {
1138
+ const normalizedName = normalizeServiceName(serviceName);
1139
+ if (normalizedName === "CheckJobStatus") {
1102
1140
  return async function(params) {
1103
1141
  await client.ensureInitialized();
1104
1142
  if (!params?.job_id) {
@@ -1114,7 +1152,7 @@ Example: await ${collectionName}.list({ limit: 100, sort: '-created_at' })`,
1114
1152
  );
1115
1153
  };
1116
1154
  }
1117
- if (serviceName === "DownloadPrivateFile") {
1155
+ if (normalizedName === "DownloadPrivateFile") {
1118
1156
  return async function(params) {
1119
1157
  await client.ensureInitialized();
1120
1158
  if (!params?.file_uri) {
@@ -1138,7 +1176,7 @@ Example: await ${collectionName}.list({ limit: 100, sort: '-created_at' })`,
1138
1176
  }
1139
1177
  return async function(params, asyncOptions) {
1140
1178
  await client.ensureInitialized();
1141
- if (serviceName === "InvokeLLM") {
1179
+ if (normalizedName === "InvokeLLM") {
1142
1180
  if (params?.model) {
1143
1181
  params = { ...params, model: mapLLMModel(params.model) };
1144
1182
  }
@@ -1147,7 +1185,7 @@ Example: await ${collectionName}.list({ limit: 100, sort: '-created_at' })`,
1147
1185
  }
1148
1186
  }
1149
1187
  let response;
1150
- const method = client._services[serviceName];
1188
+ const method = client._services[normalizedName];
1151
1189
  if (method) {
1152
1190
  response = await method(params, useServiceToken);
1153
1191
  } else {
@@ -1163,10 +1201,10 @@ Example: await ${collectionName}.list({ limit: 100, sort: '-created_at' })`,
1163
1201
  "UploadPrivateFile": "services/files/private/init",
1164
1202
  "CreateFileSignedUrl": "services/files/signed-url"
1165
1203
  };
1166
- const servicePath = servicePathMap[serviceName];
1204
+ const servicePath = servicePathMap[normalizedName];
1167
1205
  if (!servicePath) {
1168
1206
  throw new OmnikitError(
1169
- `Service '${serviceName}' not found. Known services: ${Object.keys(servicePathMap).join(", ")}`,
1207
+ `Service '${serviceName}' not found. Known services: ${Object.keys(servicePathMap).join(", ")} (camelCase also supported)`,
1170
1208
  404,
1171
1209
  "SERVICE_NOT_FOUND"
1172
1210
  );
@@ -1179,6 +1217,12 @@ Example: await ${collectionName}.list({ limit: 100, sort: '-created_at' })`,
1179
1217
  } else if (client.userToken) {
1180
1218
  headers["Authorization"] = `Bearer ${client.userToken}`;
1181
1219
  }
1220
+ if ((normalizedName === "UploadFile" || normalizedName === "uploadFile") && params?.file instanceof File) {
1221
+ return client.handleFileUpload(params.file, servicePath, useServiceToken);
1222
+ }
1223
+ if ((normalizedName === "UploadPrivateFile" || normalizedName === "uploadPrivateFile") && params?.file instanceof File) {
1224
+ return client.handleFileUpload(params.file, servicePath, useServiceToken);
1225
+ }
1182
1226
  const fetchResponse = await fetch(
1183
1227
  `${client.baseUrl}/apps/${client.appId}/${servicePath}`,
1184
1228
  {
@@ -1334,23 +1378,6 @@ Example: await ${collectionName}.list({ limit: 100, sort: '-created_at' })`,
1334
1378
  }
1335
1379
  return await response.json();
1336
1380
  }
1337
- /**
1338
- * Fetch integration schema from backend
1339
- * Returns ServicesSchema (new flat format) or IntegrationSchema (legacy)
1340
- */
1341
- async fetchIntegrationSchema() {
1342
- try {
1343
- const response = await fetch(
1344
- `${this.baseUrl}/apps/${this.appId}/services`
1345
- );
1346
- if (!response.ok) {
1347
- return null;
1348
- }
1349
- return await response.json();
1350
- } catch (error) {
1351
- return null;
1352
- }
1353
- }
1354
1381
  /**
1355
1382
  * Create collection classes from schema
1356
1383
  */