@omnikit-ai/sdk 2.0.6 → 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.d.mts CHANGED
@@ -232,8 +232,9 @@ interface LLMMessage {
232
232
  * Available LLM models for InvokeLLM
233
233
  * - 'gemini-flash': Fast and cost-effective (default)
234
234
  * - 'gemini-pro': Smarter with extended thinking (128 token thinking budget)
235
+ * - 'gemini-pro-3': Gemini 3 Pro Preview with low thinking effort
235
236
  */
236
- type LLMModel = 'gemini-flash' | 'gemini-pro';
237
+ type LLMModel = 'gemini-flash' | 'gemini-pro' | 'gemini-pro-3';
237
238
  interface LLMParams {
238
239
  /** Message-based format for advanced use */
239
240
  messages?: LLMMessage[];
@@ -256,6 +257,7 @@ interface LLMParams {
256
257
  * Model to use for LLM processing
257
258
  * - 'gemini-flash': Fast and cost-effective (default)
258
259
  * - 'gemini-pro': Smarter with extended thinking for complex reasoning
260
+ * - 'gemini-pro-3': Gemini 3 Pro Preview with low thinking effort
259
261
  */
260
262
  model?: LLMModel | string;
261
263
  /**
@@ -842,6 +844,21 @@ interface OmnikitClient {
842
844
  metadata: CachedMetadata;
843
845
  /** Collection operations */
844
846
  collections: Record<string, CollectionClass>;
847
+ /**
848
+ * Get a collection by name (function-style accessor)
849
+ * Alternative to omnikit.collections.name for more intuitive API
850
+ *
851
+ * @param name - Collection name (case-insensitive)
852
+ * @returns CollectionClass with CRUD methods
853
+ *
854
+ * @example
855
+ * ```typescript
856
+ * // Both of these work:
857
+ * await omnikit.collection('user').list()
858
+ * await omnikit.collections.user.list()
859
+ * ```
860
+ */
861
+ collection(name: string): CollectionClass;
845
862
  /** @deprecated Use collections instead */
846
863
  entities: Record<string, CollectionClass>;
847
864
  /** Integration operations */
@@ -1111,6 +1128,19 @@ interface LiveVoiceServerMessage {
1111
1128
  session_id?: string;
1112
1129
  duration_seconds?: number;
1113
1130
  }
1131
+ /**
1132
+ * Global window extensions used by the SDK
1133
+ */
1134
+ declare global {
1135
+ interface Window {
1136
+ /**
1137
+ * Opens the login modal (registered by LoginModalProvider in main.jsx)
1138
+ * Used by auth.login() to show inline login for public apps instead of redirecting
1139
+ * @param returnUrl - URL to return to after successful login
1140
+ */
1141
+ __omnikit_openLoginModal?: (returnUrl?: string) => void;
1142
+ }
1143
+ }
1114
1144
 
1115
1145
  /**
1116
1146
  * Omnikit SDK v2.0 - Main Client
@@ -1196,6 +1226,24 @@ declare class APIClient implements OmnikitClient {
1196
1226
  * Lazy getter for collections - auto-initializes on first access
1197
1227
  */
1198
1228
  get collections(): Record<string, CollectionClass>;
1229
+ /**
1230
+ * Helper method to access a collection by name.
1231
+ * Provides a more intuitive API: omnikit.collection('user').list()
1232
+ * This is an alternative to: omnikit.collections.user.list()
1233
+ *
1234
+ * @param name - Collection name (case-insensitive, supports PascalCase, camelCase, snake_case)
1235
+ * @returns CollectionClass with CRUD methods
1236
+ *
1237
+ * @example
1238
+ * ```typescript
1239
+ * // All of these work:
1240
+ * await omnikit.collection('user').list()
1241
+ * await omnikit.collection('User').list()
1242
+ * await omnikit.collection('chatbot').list()
1243
+ * await omnikit.collection('Chatbot').list()
1244
+ * ```
1245
+ */
1246
+ collection(name: string): CollectionClass;
1199
1247
  /**
1200
1248
  * @deprecated Use collections instead. This alias exists for backward compatibility.
1201
1249
  */
@@ -1271,11 +1319,6 @@ declare class APIClient implements OmnikitClient {
1271
1319
  * Fetch app schema from backend
1272
1320
  */
1273
1321
  private fetchAppSchema;
1274
- /**
1275
- * Fetch integration schema from backend
1276
- * Returns ServicesSchema (new flat format) or IntegrationSchema (legacy)
1277
- */
1278
- private fetchIntegrationSchema;
1279
1322
  /**
1280
1323
  * Create collection classes from schema
1281
1324
  */
package/dist/index.d.ts CHANGED
@@ -232,8 +232,9 @@ interface LLMMessage {
232
232
  * Available LLM models for InvokeLLM
233
233
  * - 'gemini-flash': Fast and cost-effective (default)
234
234
  * - 'gemini-pro': Smarter with extended thinking (128 token thinking budget)
235
+ * - 'gemini-pro-3': Gemini 3 Pro Preview with low thinking effort
235
236
  */
236
- type LLMModel = 'gemini-flash' | 'gemini-pro';
237
+ type LLMModel = 'gemini-flash' | 'gemini-pro' | 'gemini-pro-3';
237
238
  interface LLMParams {
238
239
  /** Message-based format for advanced use */
239
240
  messages?: LLMMessage[];
@@ -256,6 +257,7 @@ interface LLMParams {
256
257
  * Model to use for LLM processing
257
258
  * - 'gemini-flash': Fast and cost-effective (default)
258
259
  * - 'gemini-pro': Smarter with extended thinking for complex reasoning
260
+ * - 'gemini-pro-3': Gemini 3 Pro Preview with low thinking effort
259
261
  */
260
262
  model?: LLMModel | string;
261
263
  /**
@@ -842,6 +844,21 @@ interface OmnikitClient {
842
844
  metadata: CachedMetadata;
843
845
  /** Collection operations */
844
846
  collections: Record<string, CollectionClass>;
847
+ /**
848
+ * Get a collection by name (function-style accessor)
849
+ * Alternative to omnikit.collections.name for more intuitive API
850
+ *
851
+ * @param name - Collection name (case-insensitive)
852
+ * @returns CollectionClass with CRUD methods
853
+ *
854
+ * @example
855
+ * ```typescript
856
+ * // Both of these work:
857
+ * await omnikit.collection('user').list()
858
+ * await omnikit.collections.user.list()
859
+ * ```
860
+ */
861
+ collection(name: string): CollectionClass;
845
862
  /** @deprecated Use collections instead */
846
863
  entities: Record<string, CollectionClass>;
847
864
  /** Integration operations */
@@ -1111,6 +1128,19 @@ interface LiveVoiceServerMessage {
1111
1128
  session_id?: string;
1112
1129
  duration_seconds?: number;
1113
1130
  }
1131
+ /**
1132
+ * Global window extensions used by the SDK
1133
+ */
1134
+ declare global {
1135
+ interface Window {
1136
+ /**
1137
+ * Opens the login modal (registered by LoginModalProvider in main.jsx)
1138
+ * Used by auth.login() to show inline login for public apps instead of redirecting
1139
+ * @param returnUrl - URL to return to after successful login
1140
+ */
1141
+ __omnikit_openLoginModal?: (returnUrl?: string) => void;
1142
+ }
1143
+ }
1114
1144
 
1115
1145
  /**
1116
1146
  * Omnikit SDK v2.0 - Main Client
@@ -1196,6 +1226,24 @@ declare class APIClient implements OmnikitClient {
1196
1226
  * Lazy getter for collections - auto-initializes on first access
1197
1227
  */
1198
1228
  get collections(): Record<string, CollectionClass>;
1229
+ /**
1230
+ * Helper method to access a collection by name.
1231
+ * Provides a more intuitive API: omnikit.collection('user').list()
1232
+ * This is an alternative to: omnikit.collections.user.list()
1233
+ *
1234
+ * @param name - Collection name (case-insensitive, supports PascalCase, camelCase, snake_case)
1235
+ * @returns CollectionClass with CRUD methods
1236
+ *
1237
+ * @example
1238
+ * ```typescript
1239
+ * // All of these work:
1240
+ * await omnikit.collection('user').list()
1241
+ * await omnikit.collection('User').list()
1242
+ * await omnikit.collection('chatbot').list()
1243
+ * await omnikit.collection('Chatbot').list()
1244
+ * ```
1245
+ */
1246
+ collection(name: string): CollectionClass;
1199
1247
  /**
1200
1248
  * @deprecated Use collections instead. This alias exists for backward compatibility.
1201
1249
  */
@@ -1271,11 +1319,6 @@ declare class APIClient implements OmnikitClient {
1271
1319
  * Fetch app schema from backend
1272
1320
  */
1273
1321
  private fetchAppSchema;
1274
- /**
1275
- * Fetch integration schema from backend
1276
- * Returns ServicesSchema (new flat format) or IntegrationSchema (legacy)
1277
- */
1278
- private fetchIntegrationSchema;
1279
1322
  /**
1280
1323
  * Create collection classes from schema
1281
1324
  */
package/dist/index.js CHANGED
@@ -438,7 +438,8 @@ var LiveVoiceSessionImpl = class {
438
438
  // src/client.ts
439
439
  var LLM_MODEL_MAP = {
440
440
  "gemini-flash": "vertex_ai/gemini-2.5-flash",
441
- "gemini-pro": "vertex_ai/gemini-2.5-pro"
441
+ "gemini-pro": "vertex_ai/gemini-2.5-pro",
442
+ "gemini-pro-3": "vertex_ai/gemini-3-pro-preview"
442
443
  };
443
444
  function mapLLMModel(model) {
444
445
  if (!model) return void 0;
@@ -616,6 +617,26 @@ var APIClient = class {
616
617
  get collections() {
617
618
  return this.createCollectionsProxy(false);
618
619
  }
620
+ /**
621
+ * Helper method to access a collection by name.
622
+ * Provides a more intuitive API: omnikit.collection('user').list()
623
+ * This is an alternative to: omnikit.collections.user.list()
624
+ *
625
+ * @param name - Collection name (case-insensitive, supports PascalCase, camelCase, snake_case)
626
+ * @returns CollectionClass with CRUD methods
627
+ *
628
+ * @example
629
+ * ```typescript
630
+ * // All of these work:
631
+ * await omnikit.collection('user').list()
632
+ * await omnikit.collection('User').list()
633
+ * await omnikit.collection('chatbot').list()
634
+ * await omnikit.collection('Chatbot').list()
635
+ * ```
636
+ */
637
+ collection(name) {
638
+ return this.collections[name];
639
+ }
619
640
  /**
620
641
  * @deprecated Use collections instead. This alias exists for backward compatibility.
621
642
  */
@@ -697,8 +718,12 @@ var APIClient = class {
697
718
  },
698
719
  login(returnUrl) {
699
720
  const fullReturnUrl = returnUrl || (typeof window !== "undefined" ? window.location.href : "/");
700
- const encodedReturnUrl = encodeURIComponent(fullReturnUrl);
701
721
  if (typeof window !== "undefined") {
722
+ if (window.__omnikit_openLoginModal) {
723
+ window.__omnikit_openLoginModal(fullReturnUrl);
724
+ return;
725
+ }
726
+ const encodedReturnUrl = encodeURIComponent(fullReturnUrl);
702
727
  const currentPath = window.location.pathname;
703
728
  const apiSitesMatch = currentPath.match(/^\/api\/sites\/([^\/]+)/);
704
729
  if (apiSitesMatch) {
@@ -1097,10 +1122,15 @@ Example: await ${collectionName}.list({ limit: 100, sort: '-created_at' })`,
1097
1122
  */
1098
1123
  createServicesProxy(useServiceToken) {
1099
1124
  const client = this;
1125
+ function normalizeServiceName(name) {
1126
+ if (!name) return name;
1127
+ return name.charAt(0).toUpperCase() + name.slice(1);
1128
+ }
1100
1129
  return new Proxy({}, {
1101
1130
  get(target, serviceName) {
1102
1131
  if (typeof serviceName === "string" && !serviceName.startsWith("_")) {
1103
- if (serviceName === "CheckJobStatus") {
1132
+ const normalizedName = normalizeServiceName(serviceName);
1133
+ if (normalizedName === "CheckJobStatus") {
1104
1134
  return async function(params) {
1105
1135
  await client.ensureInitialized();
1106
1136
  if (!params?.job_id) {
@@ -1116,7 +1146,7 @@ Example: await ${collectionName}.list({ limit: 100, sort: '-created_at' })`,
1116
1146
  );
1117
1147
  };
1118
1148
  }
1119
- if (serviceName === "DownloadPrivateFile") {
1149
+ if (normalizedName === "DownloadPrivateFile") {
1120
1150
  return async function(params) {
1121
1151
  await client.ensureInitialized();
1122
1152
  if (!params?.file_uri) {
@@ -1140,7 +1170,7 @@ Example: await ${collectionName}.list({ limit: 100, sort: '-created_at' })`,
1140
1170
  }
1141
1171
  return async function(params, asyncOptions) {
1142
1172
  await client.ensureInitialized();
1143
- if (serviceName === "InvokeLLM") {
1173
+ if (normalizedName === "InvokeLLM") {
1144
1174
  if (params?.model) {
1145
1175
  params = { ...params, model: mapLLMModel(params.model) };
1146
1176
  }
@@ -1149,26 +1179,26 @@ Example: await ${collectionName}.list({ limit: 100, sort: '-created_at' })`,
1149
1179
  }
1150
1180
  }
1151
1181
  let response;
1152
- const method = client._services[serviceName];
1182
+ const method = client._services[normalizedName];
1153
1183
  if (method) {
1154
1184
  response = await method(params, useServiceToken);
1155
1185
  } else {
1156
1186
  const servicePathMap = {
1157
- "SendEmail": "email/send",
1158
- "InvokeLLM": "llm/invoke",
1159
- "GenerateImage": "image/generate",
1160
- "GenerateSpeech": "speech/generate",
1161
- "GenerateVideo": "video/generate",
1162
- "ExtractData": "extract/data",
1163
- "SendSMS": "sms/send",
1164
- "UploadFile": "storage/upload",
1165
- "UploadPrivateFile": "storage/upload-private",
1166
- "CreateFileSignedUrl": "storage/signed-url"
1187
+ "SendEmail": "services/email",
1188
+ "InvokeLLM": "services/llm",
1189
+ "GenerateImage": "services/images",
1190
+ "GenerateSpeech": "services/speech",
1191
+ "GenerateVideo": "services/video",
1192
+ "ExtractData": "services/extract-text",
1193
+ "SendSMS": "services/sms",
1194
+ "UploadFile": "services/files",
1195
+ "UploadPrivateFile": "services/files/private/init",
1196
+ "CreateFileSignedUrl": "services/files/signed-url"
1167
1197
  };
1168
- const servicePath = servicePathMap[serviceName];
1198
+ const servicePath = servicePathMap[normalizedName];
1169
1199
  if (!servicePath) {
1170
1200
  throw new OmnikitError(
1171
- `Service '${serviceName}' not found. Known services: ${Object.keys(servicePathMap).join(", ")}`,
1201
+ `Service '${serviceName}' not found. Known services: ${Object.keys(servicePathMap).join(", ")} (camelCase also supported)`,
1172
1202
  404,
1173
1203
  "SERVICE_NOT_FOUND"
1174
1204
  );
@@ -1182,7 +1212,7 @@ Example: await ${collectionName}.list({ limit: 100, sort: '-created_at' })`,
1182
1212
  headers["Authorization"] = `Bearer ${client.userToken}`;
1183
1213
  }
1184
1214
  const fetchResponse = await fetch(
1185
- `${client.baseUrl}/apps/${client.appId}/integrations/${servicePath}`,
1215
+ `${client.baseUrl}/apps/${client.appId}/${servicePath}`,
1186
1216
  {
1187
1217
  method: "POST",
1188
1218
  headers,
@@ -1336,23 +1366,6 @@ Example: await ${collectionName}.list({ limit: 100, sort: '-created_at' })`,
1336
1366
  }
1337
1367
  return await response.json();
1338
1368
  }
1339
- /**
1340
- * Fetch integration schema from backend
1341
- * Returns ServicesSchema (new flat format) or IntegrationSchema (legacy)
1342
- */
1343
- async fetchIntegrationSchema() {
1344
- try {
1345
- const response = await fetch(
1346
- `${this.baseUrl}/apps/${this.appId}/services`
1347
- );
1348
- if (!response.ok) {
1349
- return null;
1350
- }
1351
- return await response.json();
1352
- } catch (error) {
1353
- return null;
1354
- }
1355
- }
1356
1369
  /**
1357
1370
  * Create collection classes from schema
1358
1371
  */