@blinkdotnew/dev-sdk 2.1.1 → 2.1.2

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.js CHANGED
@@ -7,33 +7,6 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
7
7
  throw Error('Dynamic require of "' + x + '" is not supported');
8
8
  });
9
9
 
10
- // ../core/src/platform.ts
11
- function detectPlatform() {
12
- if (typeof Deno !== "undefined") {
13
- return "deno";
14
- }
15
- if (typeof process !== "undefined" && process.versions?.node) {
16
- if (typeof navigator !== "undefined" && navigator.product === "ReactNative") {
17
- return "react-native";
18
- }
19
- return "node";
20
- }
21
- if (typeof navigator !== "undefined" && navigator.product === "ReactNative") {
22
- return "react-native";
23
- }
24
- if (typeof window !== "undefined" && typeof document !== "undefined") {
25
- return "web";
26
- }
27
- return "node";
28
- }
29
- var platform = detectPlatform();
30
- var isWeb = platform === "web";
31
- var isReactNative = platform === "react-native";
32
- var isNode = platform === "node";
33
- var isDeno = platform === "deno";
34
- var isBrowser = isWeb || isReactNative;
35
- var isServer = isNode || isDeno;
36
-
37
10
  // ../core/src/storage-adapter.ts
38
11
  var WebStorageAdapter = class {
39
12
  getItem(key) {
@@ -119,9 +92,6 @@ var NoOpStorageAdapter = class {
119
92
  }
120
93
  };
121
94
  function getDefaultStorageAdapter() {
122
- if (isDeno) {
123
- return new NoOpStorageAdapter();
124
- }
125
95
  if (typeof window !== "undefined" && typeof localStorage !== "undefined") {
126
96
  try {
127
97
  localStorage.setItem("__test__", "test");
@@ -133,6 +103,28 @@ function getDefaultStorageAdapter() {
133
103
  return new NoOpStorageAdapter();
134
104
  }
135
105
 
106
+ // ../core/src/platform.ts
107
+ function detectPlatform() {
108
+ if (typeof process !== "undefined" && process.versions?.node) {
109
+ if (typeof navigator !== "undefined" && navigator.product === "ReactNative") {
110
+ return "react-native";
111
+ }
112
+ return "node";
113
+ }
114
+ if (typeof navigator !== "undefined" && navigator.product === "ReactNative") {
115
+ return "react-native";
116
+ }
117
+ if (typeof window !== "undefined" && typeof document !== "undefined") {
118
+ return "web";
119
+ }
120
+ return "node";
121
+ }
122
+ var platform = detectPlatform();
123
+ var isWeb = platform === "web";
124
+ var isReactNative = platform === "react-native";
125
+ var isNode = platform === "node";
126
+ var isBrowser = isWeb || isReactNative;
127
+
136
128
  // ../core/src/types.ts
137
129
  var BlinkError = class extends Error {
138
130
  constructor(message, code, status, details) {
@@ -396,44 +388,17 @@ function convertKeysToCamelCase(obj) {
396
388
  return converted;
397
389
  }
398
390
  var HttpClient = class {
399
- authUrl = "https://blink.new";
400
- coreUrl = "https://core.blink.new";
391
+ authUrl;
392
+ coreUrl;
401
393
  projectId;
402
- publishableKey;
403
- secretKey;
404
- // Permanent, non-expiring key (like Stripe's sk_live_...)
405
394
  getToken;
406
395
  getValidToken;
407
396
  constructor(config, getToken, getValidToken) {
408
397
  this.projectId = config.projectId;
409
- this.publishableKey = config.publishableKey;
410
- this.secretKey = config.secretKey || config.serviceToken;
411
398
  this.getToken = getToken;
412
399
  this.getValidToken = getValidToken;
413
- }
414
- shouldAttachPublishableKey(path, method) {
415
- if (method !== "GET" && method !== "POST") return false;
416
- if (path.includes("/api/analytics/")) return true;
417
- if (path.includes("/api/storage/")) return true;
418
- if (path.includes("/api/db/") && path.includes("/rest/v1/")) return method === "GET";
419
- return false;
420
- }
421
- shouldSkipSecretKey(url) {
422
- try {
423
- const parsed = new URL(url);
424
- return parsed.hostname.endsWith(".functions.blink.new");
425
- } catch {
426
- return false;
427
- }
428
- }
429
- getAuthorizationHeader(url, token) {
430
- if (this.secretKey && !this.shouldSkipSecretKey(url)) {
431
- return `Bearer ${this.secretKey}`;
432
- }
433
- if (token) {
434
- return `Bearer ${token}`;
435
- }
436
- return null;
400
+ this.authUrl = config.auth?.authUrl ?? "https://blink.new";
401
+ this.coreUrl = config.auth?.coreUrl ?? "https://dev.core.blink.new";
437
402
  }
438
403
  /**
439
404
  * Make an authenticated request to the Blink API
@@ -441,23 +406,19 @@ var HttpClient = class {
441
406
  async request(path, options = {}) {
442
407
  const url = this.buildUrl(path, options.searchParams);
443
408
  const token = this.getValidToken ? await this.getValidToken() : this.getToken();
444
- const method = options.method || "GET";
445
409
  const headers = {
446
410
  "Content-Type": "application/json",
447
411
  ...options.headers
448
412
  };
449
- const auth = this.getAuthorizationHeader(url, token);
450
- if (auth) {
451
- headers.Authorization = auth;
452
- } else if (this.publishableKey && !headers["x-blink-publishable-key"] && this.shouldAttachPublishableKey(path, method)) {
453
- headers["x-blink-publishable-key"] = this.publishableKey;
413
+ if (token) {
414
+ headers.Authorization = `Bearer ${token}`;
454
415
  }
455
416
  const requestInit = {
456
- method,
417
+ method: options.method || "GET",
457
418
  headers,
458
419
  signal: options.signal
459
420
  };
460
- if (options.body && method !== "GET") {
421
+ if (options.body && options.method !== "GET") {
461
422
  requestInit.body = typeof options.body === "string" ? options.body : JSON.stringify(options.body);
462
423
  }
463
424
  try {
@@ -611,12 +572,12 @@ var HttpClient = class {
611
572
  throw new BlinkValidationError("Unsupported file type");
612
573
  }
613
574
  formData.append("path", filePath);
575
+ if (options.upsert !== void 0) {
576
+ formData.append("options", JSON.stringify({ upsert: options.upsert }));
577
+ }
614
578
  const headers = {};
615
- const auth = this.getAuthorizationHeader(url, token);
616
- if (auth) {
617
- headers.Authorization = auth;
618
- } else if (this.publishableKey && path.includes("/api/storage/") && !headers["x-blink-publishable-key"]) {
619
- headers["x-blink-publishable-key"] = this.publishableKey;
579
+ if (token) {
580
+ headers.Authorization = `Bearer ${token}`;
620
581
  }
621
582
  try {
622
583
  if (typeof XMLHttpRequest !== "undefined" && options.onProgress) {
@@ -717,7 +678,7 @@ var HttpClient = class {
717
678
  });
718
679
  }
719
680
  /**
720
- * Stream AI text generation - uses Vercel AI SDK's pipeUIMessageStreamToResponse (Data Stream Protocol)
681
+ * Stream AI text generation with Vercel AI SDK data stream format
721
682
  */
722
683
  async streamAiText(prompt, options = {}, onChunk) {
723
684
  const url = this.buildUrl(`/api/ai/${this.projectId}/text`);
@@ -725,8 +686,9 @@ var HttpClient = class {
725
686
  const headers = {
726
687
  "Content-Type": "application/json"
727
688
  };
728
- const auth = this.getAuthorizationHeader(url, token);
729
- if (auth) headers.Authorization = auth;
689
+ if (token) {
690
+ headers.Authorization = `Bearer ${token}`;
691
+ }
730
692
  const body = {
731
693
  prompt,
732
694
  stream: true,
@@ -746,7 +708,7 @@ var HttpClient = class {
746
708
  if (!response.body) {
747
709
  throw new BlinkNetworkError("No response body for streaming");
748
710
  }
749
- return this.parseDataStreamProtocol(response.body, onChunk);
711
+ return this.parseDataStream(response.body, onChunk);
750
712
  } catch (error) {
751
713
  if (error instanceof BlinkError) {
752
714
  throw error;
@@ -771,7 +733,7 @@ var HttpClient = class {
771
733
  });
772
734
  }
773
735
  /**
774
- * Stream AI object generation - uses Vercel AI SDK's pipeTextStreamToResponse
736
+ * Stream AI object generation with Vercel AI SDK data stream format
775
737
  */
776
738
  async streamAiObject(prompt, options = {}, onPartial) {
777
739
  const url = this.buildUrl(`/api/ai/${this.projectId}/object`);
@@ -779,8 +741,9 @@ var HttpClient = class {
779
741
  const headers = {
780
742
  "Content-Type": "application/json"
781
743
  };
782
- const auth = this.getAuthorizationHeader(url, token);
783
- if (auth) headers.Authorization = auth;
744
+ if (token) {
745
+ headers.Authorization = `Bearer ${token}`;
746
+ }
784
747
  const body = {
785
748
  prompt,
786
749
  stream: true,
@@ -800,35 +763,7 @@ var HttpClient = class {
800
763
  if (!response.body) {
801
764
  throw new BlinkNetworkError("No response body for streaming");
802
765
  }
803
- const reader = response.body.getReader();
804
- const decoder = new TextDecoder();
805
- let buffer = "";
806
- let latestObject = {};
807
- try {
808
- while (true) {
809
- const { done, value } = await reader.read();
810
- if (done) break;
811
- const chunk = decoder.decode(value, { stream: true });
812
- buffer += chunk;
813
- try {
814
- const parsed = JSON.parse(buffer);
815
- latestObject = parsed;
816
- if (onPartial) {
817
- onPartial(parsed);
818
- }
819
- } catch {
820
- }
821
- }
822
- if (buffer) {
823
- try {
824
- latestObject = JSON.parse(buffer);
825
- } catch {
826
- }
827
- }
828
- return { object: latestObject };
829
- } finally {
830
- reader.releaseLock();
831
- }
766
+ return this.parseDataStream(response.body, void 0, onPartial);
832
767
  } catch (error) {
833
768
  if (error instanceof BlinkError) {
834
769
  throw error;
@@ -926,38 +861,6 @@ var HttpClient = class {
926
861
  async dataSearch(projectId, request) {
927
862
  return this.post(`/api/data/${projectId}/search`, request);
928
863
  }
929
- /**
930
- * Connector requests
931
- */
932
- formatProviderForPath(provider) {
933
- return provider.replace("_", "-");
934
- }
935
- async connectorStatus(provider) {
936
- return this.request(`/api/connectors/${this.formatProviderForPath(provider)}/${this.projectId}/status`, {
937
- method: "GET"
938
- });
939
- }
940
- async connectorExecute(provider, request) {
941
- const path = request.method.startsWith("/") ? request.method : `/${request.method}`;
942
- const url = `/api/connectors/${this.formatProviderForPath(provider)}/${this.projectId}${path}`;
943
- const method = (request.http_method || "GET").toUpperCase();
944
- if (method === "GET") {
945
- return this.request(url, {
946
- method: "GET",
947
- searchParams: request.params
948
- });
949
- }
950
- return this.request(url, {
951
- method,
952
- body: request.params || {}
953
- });
954
- }
955
- async connectorSaveApiKey(provider, request) {
956
- return this.request(`/api/connectors/${this.formatProviderForPath(provider)}/${this.projectId}/api-key`, {
957
- method: "POST",
958
- body: request
959
- });
960
- }
961
864
  /**
962
865
  * Realtime-specific requests
963
866
  */
@@ -1023,94 +926,93 @@ var HttpClient = class {
1023
926
  }
1024
927
  }
1025
928
  /**
1026
- * Parse Vercel AI SDK v5 Data Stream Protocol (Server-Sent Events)
1027
- * Supports all event types from the UI Message Stream protocol
929
+ * Parse Vercel AI SDK data stream format
930
+ * Handles text chunks (0:"text"), partial objects (2:[...]), and metadata (d:, e:)
1028
931
  */
1029
- async parseDataStreamProtocol(body, onChunk) {
932
+ async parseDataStream(body, onChunk, onPartial) {
1030
933
  const reader = body.getReader();
1031
934
  const decoder = new TextDecoder();
1032
- const finalResult = {
1033
- text: "",
1034
- toolCalls: [],
1035
- toolResults: [],
1036
- sources: [],
1037
- files: [],
1038
- reasoning: []
1039
- };
1040
935
  let buffer = "";
936
+ let finalResult = {};
1041
937
  try {
1042
938
  while (true) {
1043
939
  const { done, value } = await reader.read();
1044
940
  if (done) break;
1045
941
  buffer += decoder.decode(value, { stream: true });
1046
- const lines = buffer.split("\n");
942
+ const lines = buffer.split(/\r?\n/);
1047
943
  buffer = lines.pop() || "";
1048
944
  for (const line of lines) {
1049
945
  if (!line.trim()) continue;
1050
- if (line === "[DONE]") {
1051
- continue;
1052
- }
1053
- if (!line.startsWith("data: ")) continue;
1054
946
  try {
1055
- const jsonStr = line.slice(6);
1056
- const part = JSON.parse(jsonStr);
1057
- switch (part.type) {
1058
- case "text-start":
1059
- break;
1060
- case "text-delta":
1061
- if (part.delta) {
1062
- finalResult.text += part.delta;
1063
- if (onChunk) onChunk(part.delta);
947
+ if (line.startsWith("f:")) {
948
+ const metadata = JSON.parse(line.slice(2));
949
+ finalResult.messageId = metadata.messageId;
950
+ } else if (line.startsWith("0:")) {
951
+ const textChunk = JSON.parse(line.slice(2));
952
+ if (onChunk) {
953
+ onChunk(textChunk);
954
+ }
955
+ finalResult.text = (finalResult.text || "") + textChunk;
956
+ } else if (line.startsWith("2:")) {
957
+ const data = JSON.parse(line.slice(2));
958
+ if (Array.isArray(data) && data.length > 0) {
959
+ const item = data[0];
960
+ if (typeof item === "string") {
961
+ finalResult.status = item;
962
+ } else if (typeof item === "object") {
963
+ if (onPartial) {
964
+ onPartial(item);
965
+ }
966
+ finalResult.object = item;
1064
967
  }
1065
- if (part.textDelta) {
1066
- finalResult.text += part.textDelta;
1067
- if (onChunk) onChunk(part.textDelta);
968
+ }
969
+ } else if (line.startsWith("d:")) {
970
+ const metadata = JSON.parse(line.slice(2));
971
+ if (metadata.usage) {
972
+ finalResult.usage = metadata.usage;
973
+ }
974
+ if (metadata.finishReason) {
975
+ finalResult.finishReason = metadata.finishReason;
976
+ }
977
+ } else if (line.startsWith("e:")) {
978
+ const errorData = JSON.parse(line.slice(2));
979
+ finalResult.error = errorData;
980
+ }
981
+ } catch (error) {
982
+ console.warn("Failed to parse stream line:", line, error);
983
+ }
984
+ }
985
+ }
986
+ if (buffer.trim()) {
987
+ try {
988
+ if (buffer.startsWith("0:")) {
989
+ const textChunk = JSON.parse(buffer.slice(2));
990
+ if (onChunk) {
991
+ onChunk(textChunk);
992
+ }
993
+ finalResult.text = (finalResult.text || "") + textChunk;
994
+ } else if (buffer.startsWith("2:")) {
995
+ const data = JSON.parse(buffer.slice(2));
996
+ if (Array.isArray(data) && data.length > 0) {
997
+ const item = data[0];
998
+ if (typeof item === "object") {
999
+ if (onPartial) {
1000
+ onPartial(item);
1068
1001
  }
1069
- break;
1070
- case "text-end":
1071
- break;
1072
- case "tool-call":
1073
- finalResult.toolCalls.push({
1074
- toolCallId: part.toolCallId,
1075
- toolName: part.toolName,
1076
- args: part.args
1077
- });
1078
- break;
1079
- case "tool-result":
1080
- finalResult.toolResults.push({
1081
- toolCallId: part.toolCallId,
1082
- toolName: part.toolName,
1083
- result: part.result
1084
- });
1085
- break;
1086
- case "source-url":
1087
- finalResult.sources.push({
1088
- id: part.id,
1089
- url: part.url,
1090
- title: part.title
1091
- });
1092
- break;
1093
- case "file":
1094
- finalResult.files.push(part.file);
1095
- break;
1096
- case "reasoning":
1097
- finalResult.reasoning.push(part.content);
1098
- break;
1099
- case "finish":
1100
- finalResult.finishReason = part.finishReason;
1101
- finalResult.usage = part.usage;
1102
- if (part.response) finalResult.response = part.response;
1103
- break;
1104
- case "error":
1105
- finalResult.error = part.error;
1106
- throw new Error(part.error);
1107
- case "data":
1108
- if (!finalResult.customData) finalResult.customData = [];
1109
- finalResult.customData.push(part.value);
1110
- break;
1002
+ finalResult.object = item;
1003
+ }
1004
+ }
1005
+ } else if (buffer.startsWith("d:")) {
1006
+ const metadata = JSON.parse(buffer.slice(2));
1007
+ if (metadata.usage) {
1008
+ finalResult.usage = metadata.usage;
1009
+ }
1010
+ if (metadata.finishReason) {
1011
+ finalResult.finishReason = metadata.finishReason;
1111
1012
  }
1112
- } catch (e) {
1113
1013
  }
1014
+ } catch (error) {
1015
+ console.warn("Failed to parse final buffer:", buffer, error);
1114
1016
  }
1115
1017
  }
1116
1018
  return finalResult;
@@ -1278,13 +1180,13 @@ var BlinkAuth = class {
1278
1180
  mode: "managed",
1279
1181
  // Default mode
1280
1182
  authUrl: "https://blink.new",
1281
- coreUrl: "https://core.blink.new",
1183
+ coreUrl: "https://dev.core.blink.new",
1282
1184
  detectSessionInUrl: true,
1283
1185
  // Default to true for web compatibility
1284
1186
  ...config.auth
1285
1187
  };
1286
1188
  this.authUrl = this.authConfig.authUrl || "https://blink.new";
1287
- this.coreUrl = this.authConfig.coreUrl || "https://core.blink.new";
1189
+ this.coreUrl = this.authConfig.coreUrl || "https://dev.core.blink.new";
1288
1190
  const hostname = getLocationHostname();
1289
1191
  if (hostname && this.authUrl === "https://blink.new" && (hostname === "localhost" || hostname === "127.0.0.1")) {
1290
1192
  console.warn("\u26A0\uFE0F Using default authUrl in development. Set auth.authUrl to your app origin for headless auth endpoints to work.");
@@ -3037,11 +2939,6 @@ var BlinkAuth = class {
3037
2939
  };
3038
2940
 
3039
2941
  // src/database.ts
3040
- function assertServerOnly(methodName) {
3041
- if (typeof window !== "undefined") {
3042
- throw new Error(`${methodName} is server-only. Use Blink CRUD methods (blink.db.<table>.*) instead.`);
3043
- }
3044
- }
3045
2942
  function camelToSnake3(str) {
3046
2943
  return str.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
3047
2944
  }
@@ -3260,7 +3157,6 @@ var BlinkTable = class {
3260
3157
  * Raw SQL query on this table (for advanced use cases)
3261
3158
  */
3262
3159
  async sql(query, params) {
3263
- assertServerOnly("blink.db.<table>.sql");
3264
3160
  const response = await this.httpClient.dbSql(query, params);
3265
3161
  return response.data;
3266
3162
  }
@@ -3309,7 +3205,6 @@ var BlinkDatabase = class {
3309
3205
  * Execute raw SQL query
3310
3206
  */
3311
3207
  async sql(query, params) {
3312
- assertServerOnly("blink.db.sql");
3313
3208
  const response = await this.httpClient.dbSql(query, params);
3314
3209
  return response.data;
3315
3210
  }
@@ -3317,7 +3212,6 @@ var BlinkDatabase = class {
3317
3212
  * Execute batch SQL operations
3318
3213
  */
3319
3214
  async batch(statements, mode = "write") {
3320
- assertServerOnly("blink.db.batch");
3321
3215
  const response = await this.httpClient.dbBatch(statements, mode);
3322
3216
  return response.data;
3323
3217
  }
@@ -3380,6 +3274,7 @@ var BlinkStorageImpl = class {
3380
3274
  correctedPath,
3381
3275
  // Use corrected path with proper extension
3382
3276
  {
3277
+ upsert: options.upsert,
3383
3278
  onProgress: options.onProgress,
3384
3279
  contentType: detectedContentType
3385
3280
  // Pass detected content type
@@ -3399,7 +3294,7 @@ var BlinkStorageImpl = class {
3399
3294
  if (error instanceof Error && "status" in error) {
3400
3295
  const status = error.status;
3401
3296
  if (status === 409) {
3402
- throw new BlinkStorageError("File already exists.", 409);
3297
+ throw new BlinkStorageError("File already exists. Set upsert: true to overwrite.", 409);
3403
3298
  }
3404
3299
  if (status === 400) {
3405
3300
  throw new BlinkStorageError("Invalid request parameters", 400);
@@ -3444,6 +3339,7 @@ var BlinkStorageImpl = class {
3444
3339
  detectedContentType
3445
3340
  };
3446
3341
  } catch (error) {
3342
+ console.warn("File type detection failed, using original path:", error);
3447
3343
  return {
3448
3344
  correctedPath: originalPath,
3449
3345
  detectedContentType: "application/octet-stream"
@@ -3833,7 +3729,13 @@ var BlinkAIImpl = class {
3833
3729
  options.prompt || "",
3834
3730
  requestBody
3835
3731
  );
3836
- return response.data;
3732
+ if (response.data?.result) {
3733
+ return response.data.result;
3734
+ } else if (response.data?.text) {
3735
+ return response.data;
3736
+ } else {
3737
+ throw new BlinkAIError("Invalid response format: missing text");
3738
+ }
3837
3739
  } catch (error) {
3838
3740
  if (error instanceof BlinkAIError) {
3839
3741
  throw error;
@@ -3902,14 +3804,9 @@ var BlinkAIImpl = class {
3902
3804
  );
3903
3805
  return {
3904
3806
  text: result.text || "",
3905
- finishReason: result.finishReason || "stop",
3807
+ finishReason: "stop",
3906
3808
  usage: result.usage,
3907
- toolCalls: result.toolCalls,
3908
- toolResults: result.toolResults,
3909
- sources: result.sources,
3910
- files: result.files,
3911
- reasoningDetails: result.reasoning,
3912
- response: result.response
3809
+ ...result
3913
3810
  };
3914
3811
  } catch (error) {
3915
3812
  if (error instanceof BlinkAIError) {
@@ -3988,7 +3885,13 @@ var BlinkAIImpl = class {
3988
3885
  signal: options.signal
3989
3886
  }
3990
3887
  );
3991
- return response.data;
3888
+ if (response.data?.result) {
3889
+ return response.data.result;
3890
+ } else if (response.data?.object) {
3891
+ return response.data;
3892
+ } else {
3893
+ throw new BlinkAIError("Invalid response format: missing object");
3894
+ }
3992
3895
  } catch (error) {
3993
3896
  if (error instanceof BlinkAIError) {
3994
3897
  throw error;
@@ -4050,7 +3953,8 @@ var BlinkAIImpl = class {
4050
3953
  return {
4051
3954
  object: result.object || {},
4052
3955
  finishReason: "stop",
4053
- usage: result.usage
3956
+ usage: result.usage,
3957
+ ...result
4054
3958
  };
4055
3959
  } catch (error) {
4056
3960
  if (error instanceof BlinkAIError) {
@@ -4900,7 +4804,7 @@ var BlinkRealtimeChannel = class {
4900
4804
  return new Promise((resolve, reject) => {
4901
4805
  try {
4902
4806
  const httpClient = this.httpClient;
4903
- const coreUrl = httpClient.coreUrl || "https://core.blink.new";
4807
+ const coreUrl = httpClient.coreUrl || "https://dev.core.blink.new";
4904
4808
  const baseUrl = coreUrl.replace("https://", "wss://").replace("http://", "ws://");
4905
4809
  const wsUrl = `${baseUrl}?project_id=${this.projectId}`;
4906
4810
  console.log(`\u{1F517} Attempting WebSocket connection to: ${wsUrl}`);
@@ -5369,6 +5273,7 @@ var BlinkAnalyticsImpl = class {
5369
5273
  } catch (error) {
5370
5274
  this.queue = [...events, ...this.queue];
5371
5275
  this.persistQueue();
5276
+ console.error("Failed to send analytics events:", error);
5372
5277
  }
5373
5278
  if (this.queue.length > 0) {
5374
5279
  this.timer = setTimeout(() => this.flush(), BATCH_TIMEOUT);
@@ -5559,64 +5464,6 @@ var BlinkAnalyticsImpl = class {
5559
5464
  }
5560
5465
  };
5561
5466
 
5562
- // src/connectors.ts
5563
- var BlinkConnectorsImpl = class {
5564
- constructor(httpClient) {
5565
- this.httpClient = httpClient;
5566
- }
5567
- async status(provider, options) {
5568
- const response = await this.httpClient.connectorStatus(provider);
5569
- return response.data;
5570
- }
5571
- async execute(provider, request) {
5572
- const response = await this.httpClient.connectorExecute(provider, request);
5573
- return response.data;
5574
- }
5575
- async saveApiKey(provider, request) {
5576
- const response = await this.httpClient.connectorSaveApiKey(provider, request);
5577
- return response.data;
5578
- }
5579
- };
5580
-
5581
- // src/functions.ts
5582
- var BlinkFunctionsImpl = class {
5583
- httpClient;
5584
- projectId;
5585
- constructor(httpClient, projectId, _getToken) {
5586
- this.httpClient = httpClient;
5587
- this.projectId = projectId;
5588
- }
5589
- /**
5590
- * Get the project suffix from the full project ID.
5591
- * Project IDs are formatted as: prj_xxxxx
5592
- * The suffix is the last 8 characters used in function URLs.
5593
- */
5594
- getProjectSuffix() {
5595
- return this.projectId.slice(-8);
5596
- }
5597
- /**
5598
- * Build the full function URL
5599
- */
5600
- buildFunctionUrl(functionSlug, searchParams) {
5601
- const suffix = this.getProjectSuffix();
5602
- const baseUrl = `https://${suffix}--${functionSlug}.functions.blink.new`;
5603
- if (!searchParams || Object.keys(searchParams).length === 0) {
5604
- return baseUrl;
5605
- }
5606
- const url = new URL(baseUrl);
5607
- Object.entries(searchParams).forEach(([key, value]) => {
5608
- url.searchParams.set(key, value);
5609
- });
5610
- return url.toString();
5611
- }
5612
- async invoke(functionSlug, options = {}) {
5613
- const { method = "POST", body, headers = {}, searchParams } = options;
5614
- const url = this.buildFunctionUrl(functionSlug, searchParams);
5615
- const res = await this.httpClient.request(url, { method, body, headers });
5616
- return { data: res.data, status: res.status, headers: res.headers };
5617
- }
5618
- };
5619
-
5620
5467
  // src/client.ts
5621
5468
  var BlinkClientImpl = class {
5622
5469
  auth;
@@ -5627,13 +5474,8 @@ var BlinkClientImpl = class {
5627
5474
  realtime;
5628
5475
  notifications;
5629
5476
  analytics;
5630
- connectors;
5631
- functions;
5632
5477
  httpClient;
5633
5478
  constructor(config) {
5634
- if ((config.secretKey || config.serviceToken) && isBrowser) {
5635
- throw new Error("secretKey/serviceToken is server-only. Do not provide it in browser/React Native clients.");
5636
- }
5637
5479
  this.auth = new BlinkAuth(config);
5638
5480
  this.httpClient = new HttpClient(
5639
5481
  config,
@@ -5647,12 +5489,6 @@ var BlinkClientImpl = class {
5647
5489
  this.realtime = new BlinkRealtimeImpl(this.httpClient, config.projectId);
5648
5490
  this.notifications = new BlinkNotificationsImpl(this.httpClient);
5649
5491
  this.analytics = new BlinkAnalyticsImpl(this.httpClient, config.projectId);
5650
- this.connectors = new BlinkConnectorsImpl(this.httpClient);
5651
- this.functions = new BlinkFunctionsImpl(
5652
- this.httpClient,
5653
- config.projectId,
5654
- () => this.auth.getValidToken()
5655
- );
5656
5492
  this.auth.onAuthStateChanged((state) => {
5657
5493
  if (state.isAuthenticated && state.user) {
5658
5494
  this.analytics.setUserId(state.user.id);
@@ -5674,7 +5510,6 @@ function createClient(config) {
5674
5510
  exports.AsyncStorageAdapter = AsyncStorageAdapter;
5675
5511
  exports.BlinkAIImpl = BlinkAIImpl;
5676
5512
  exports.BlinkAnalyticsImpl = BlinkAnalyticsImpl;
5677
- exports.BlinkConnectorsImpl = BlinkConnectorsImpl;
5678
5513
  exports.BlinkDataImpl = BlinkDataImpl;
5679
5514
  exports.BlinkDatabase = BlinkDatabase;
5680
5515
  exports.BlinkRealtimeChannel = BlinkRealtimeChannel;
@@ -5686,10 +5521,8 @@ exports.WebStorageAdapter = WebStorageAdapter;
5686
5521
  exports.createClient = createClient;
5687
5522
  exports.getDefaultStorageAdapter = getDefaultStorageAdapter;
5688
5523
  exports.isBrowser = isBrowser;
5689
- exports.isDeno = isDeno;
5690
5524
  exports.isNode = isNode;
5691
5525
  exports.isReactNative = isReactNative;
5692
- exports.isServer = isServer;
5693
5526
  exports.isWeb = isWeb;
5694
5527
  exports.platform = platform;
5695
5528
  //# sourceMappingURL=index.js.map