@omnikit-ai/sdk 2.0.7 → 2.0.8

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
@@ -436,7 +436,8 @@ var LiveVoiceSessionImpl = class {
436
436
  // src/client.ts
437
437
  var LLM_MODEL_MAP = {
438
438
  "gemini-flash": "vertex_ai/gemini-2.5-flash",
439
- "gemini-pro": "vertex_ai/gemini-2.5-pro"
439
+ "gemini-pro": "vertex_ai/gemini-2.5-pro",
440
+ "gemini-pro-3": "vertex_ai/gemini-3-pro-preview"
440
441
  };
441
442
  function mapLLMModel(model) {
442
443
  if (!model) return void 0;
@@ -614,6 +615,26 @@ var APIClient = class {
614
615
  get collections() {
615
616
  return this.createCollectionsProxy(false);
616
617
  }
618
+ /**
619
+ * Helper method to access a collection by name.
620
+ * Provides a more intuitive API: omnikit.collection('user').list()
621
+ * This is an alternative to: omnikit.collections.user.list()
622
+ *
623
+ * @param name - Collection name (case-insensitive, supports PascalCase, camelCase, snake_case)
624
+ * @returns CollectionClass with CRUD methods
625
+ *
626
+ * @example
627
+ * ```typescript
628
+ * // All of these work:
629
+ * await omnikit.collection('user').list()
630
+ * await omnikit.collection('User').list()
631
+ * await omnikit.collection('chatbot').list()
632
+ * await omnikit.collection('Chatbot').list()
633
+ * ```
634
+ */
635
+ collection(name) {
636
+ return this.collections[name];
637
+ }
617
638
  /**
618
639
  * @deprecated Use collections instead. This alias exists for backward compatibility.
619
640
  */
@@ -695,8 +716,12 @@ var APIClient = class {
695
716
  },
696
717
  login(returnUrl) {
697
718
  const fullReturnUrl = returnUrl || (typeof window !== "undefined" ? window.location.href : "/");
698
- const encodedReturnUrl = encodeURIComponent(fullReturnUrl);
699
719
  if (typeof window !== "undefined") {
720
+ if (window.__omnikit_openLoginModal) {
721
+ window.__omnikit_openLoginModal(fullReturnUrl);
722
+ return;
723
+ }
724
+ const encodedReturnUrl = encodeURIComponent(fullReturnUrl);
700
725
  const currentPath = window.location.pathname;
701
726
  const apiSitesMatch = currentPath.match(/^\/api\/sites\/([^\/]+)/);
702
727
  if (apiSitesMatch) {
@@ -1095,10 +1120,15 @@ Example: await ${collectionName}.list({ limit: 100, sort: '-created_at' })`,
1095
1120
  */
1096
1121
  createServicesProxy(useServiceToken) {
1097
1122
  const client = this;
1123
+ function normalizeServiceName(name) {
1124
+ if (!name) return name;
1125
+ return name.charAt(0).toUpperCase() + name.slice(1);
1126
+ }
1098
1127
  return new Proxy({}, {
1099
1128
  get(target, serviceName) {
1100
1129
  if (typeof serviceName === "string" && !serviceName.startsWith("_")) {
1101
- if (serviceName === "CheckJobStatus") {
1130
+ const normalizedName = normalizeServiceName(serviceName);
1131
+ if (normalizedName === "CheckJobStatus") {
1102
1132
  return async function(params) {
1103
1133
  await client.ensureInitialized();
1104
1134
  if (!params?.job_id) {
@@ -1114,7 +1144,7 @@ Example: await ${collectionName}.list({ limit: 100, sort: '-created_at' })`,
1114
1144
  );
1115
1145
  };
1116
1146
  }
1117
- if (serviceName === "DownloadPrivateFile") {
1147
+ if (normalizedName === "DownloadPrivateFile") {
1118
1148
  return async function(params) {
1119
1149
  await client.ensureInitialized();
1120
1150
  if (!params?.file_uri) {
@@ -1138,7 +1168,7 @@ Example: await ${collectionName}.list({ limit: 100, sort: '-created_at' })`,
1138
1168
  }
1139
1169
  return async function(params, asyncOptions) {
1140
1170
  await client.ensureInitialized();
1141
- if (serviceName === "InvokeLLM") {
1171
+ if (normalizedName === "InvokeLLM") {
1142
1172
  if (params?.model) {
1143
1173
  params = { ...params, model: mapLLMModel(params.model) };
1144
1174
  }
@@ -1147,7 +1177,7 @@ Example: await ${collectionName}.list({ limit: 100, sort: '-created_at' })`,
1147
1177
  }
1148
1178
  }
1149
1179
  let response;
1150
- const method = client._services[serviceName];
1180
+ const method = client._services[normalizedName];
1151
1181
  if (method) {
1152
1182
  response = await method(params, useServiceToken);
1153
1183
  } else {
@@ -1163,10 +1193,10 @@ Example: await ${collectionName}.list({ limit: 100, sort: '-created_at' })`,
1163
1193
  "UploadPrivateFile": "services/files/private/init",
1164
1194
  "CreateFileSignedUrl": "services/files/signed-url"
1165
1195
  };
1166
- const servicePath = servicePathMap[serviceName];
1196
+ const servicePath = servicePathMap[normalizedName];
1167
1197
  if (!servicePath) {
1168
1198
  throw new OmnikitError(
1169
- `Service '${serviceName}' not found. Known services: ${Object.keys(servicePathMap).join(", ")}`,
1199
+ `Service '${serviceName}' not found. Known services: ${Object.keys(servicePathMap).join(", ")} (camelCase also supported)`,
1170
1200
  404,
1171
1201
  "SERVICE_NOT_FOUND"
1172
1202
  );
@@ -1334,23 +1364,6 @@ Example: await ${collectionName}.list({ limit: 100, sort: '-created_at' })`,
1334
1364
  }
1335
1365
  return await response.json();
1336
1366
  }
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
1367
  /**
1355
1368
  * Create collection classes from schema
1356
1369
  */