@symbo.ls/sdk 2.32.7 → 2.32.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.
Files changed (34) hide show
  1. package/dist/cjs/config/environment.js +19 -0
  2. package/dist/cjs/services/AuthService.js +4 -2
  3. package/dist/cjs/services/CollabService.js +214 -64
  4. package/dist/cjs/services/ProjectService.js +19 -10
  5. package/dist/cjs/utils/CollabClient.js +46 -9
  6. package/dist/esm/config/environment.js +19 -0
  7. package/dist/esm/index.js +302 -85
  8. package/dist/esm/services/AdminService.js +19 -0
  9. package/dist/esm/services/AuthService.js +23 -2
  10. package/dist/esm/services/BaseService.js +19 -0
  11. package/dist/esm/services/BranchService.js +19 -0
  12. package/dist/esm/services/CollabService.js +279 -73
  13. package/dist/esm/services/CoreService.js +19 -0
  14. package/dist/esm/services/DnsService.js +19 -0
  15. package/dist/esm/services/FileService.js +19 -0
  16. package/dist/esm/services/PaymentService.js +19 -0
  17. package/dist/esm/services/PlanService.js +19 -0
  18. package/dist/esm/services/ProjectService.js +38 -10
  19. package/dist/esm/services/PullRequestService.js +19 -0
  20. package/dist/esm/services/ScreenshotService.js +19 -0
  21. package/dist/esm/services/SubscriptionService.js +19 -0
  22. package/dist/esm/services/index.js +302 -85
  23. package/dist/esm/utils/CollabClient.js +65 -9
  24. package/dist/node/config/environment.js +19 -0
  25. package/dist/node/services/AuthService.js +4 -2
  26. package/dist/node/services/CollabService.js +214 -64
  27. package/dist/node/services/ProjectService.js +19 -10
  28. package/dist/node/utils/CollabClient.js +46 -9
  29. package/package.json +6 -6
  30. package/src/config/environment.js +20 -1
  31. package/src/services/AuthService.js +7 -2
  32. package/src/services/CollabService.js +258 -77
  33. package/src/services/ProjectService.js +19 -10
  34. package/src/utils/CollabClient.js +51 -8
package/dist/esm/index.js CHANGED
@@ -14113,6 +14113,9 @@ var CONFIG = {
14113
14113
  // For based api
14114
14114
  githubClientId: "Ov23liAFrsR0StbAO6PO",
14115
14115
  // For github api
14116
+ grafanaUrl: "https://faro-collector-prod-us-east-0.grafana.net/collect/aef64330db80bdfeaac084317bf72f99",
14117
+ // For grafana tracing
14118
+ grafanaAppName: "Localhost Symbols",
14116
14119
  // Environment-specific feature toggles (override common)
14117
14120
  features: {
14118
14121
  betaFeatures: true
@@ -14128,6 +14131,9 @@ var CONFIG = {
14128
14131
  socketUrl: "https://dev.api.symbols.app",
14129
14132
  apiUrl: "https://dev.api.symbols.app",
14130
14133
  githubClientId: "Ov23liHxyWFBxS8f1gnF",
14134
+ grafanaUrl: "https://faro-collector-prod-us-east-0.grafana.net/collect/7a3ba473cee2025c68513667024316b8",
14135
+ // For grafana tracing
14136
+ grafanaAppName: "Symbols Dev",
14131
14137
  typesenseCollectionName: "docs",
14132
14138
  typesenseApiKey: "awmcVpbWqZi9IUgmvslp1C5LKDU8tMjA",
14133
14139
  typesenseHost: "tl2qpnwxev4cjm36p-1.a1.typesense.net",
@@ -14141,6 +14147,9 @@ var CONFIG = {
14141
14147
  basedProject: "platform-v2-sm",
14142
14148
  basedOrg: "symbols",
14143
14149
  githubClientId: "Ov23liHxyWFBxS8f1gnF",
14150
+ grafanaUrl: "https://faro-collector-prod-us-east-0.grafana.net/collect/7a3ba473cee2025c68513667024316b8",
14151
+ // For grafana tracing
14152
+ grafanaAppName: "Symbols Test",
14144
14153
  typesenseCollectionName: "docs",
14145
14154
  typesenseApiKey: "awmcVpbWqZi9IUgmvslp1C5LKDU8tMjA",
14146
14155
  typesenseHost: "tl2qpnwxev4cjm36p-1.a1.typesense.net",
@@ -14151,6 +14160,9 @@ var CONFIG = {
14151
14160
  socketUrl: "https://upcoming.api.symbols.app",
14152
14161
  apiUrl: "https://upcoming.api.symbols.app",
14153
14162
  githubClientId: "Ov23liWF7NvdZ056RV5J",
14163
+ grafanaUrl: "https://faro-collector-prod-us-east-0.grafana.net/collect/7a3ba473cee2025c68513667024316b8",
14164
+ // For grafana tracing
14165
+ grafanaAppName: "Symbols Upcoming",
14154
14166
  typesenseCollectionName: "docs",
14155
14167
  typesenseApiKey: "awmcVpbWqZi9IUgmvslp1C5LKDU8tMjA",
14156
14168
  typesenseHost: "tl2qpnwxev4cjm36p-1.a1.typesense.net",
@@ -14164,6 +14176,9 @@ var CONFIG = {
14164
14176
  basedProject: "platform-v2-sm",
14165
14177
  basedOrg: "symbols",
14166
14178
  githubClientId: "Ov23ligwZDQVD0VfuWNa",
14179
+ grafanaUrl: "https://faro-collector-prod-us-east-0.grafana.net/collect/7a3ba473cee2025c68513667024316b8",
14180
+ // For grafana tracing
14181
+ grafanaAppName: "Symbols Staging",
14167
14182
  typesenseCollectionName: "docs",
14168
14183
  typesenseApiKey: "awmcVpbWqZi9IUgmvslp1C5LKDU8tMjA",
14169
14184
  typesenseHost: "tl2qpnwxev4cjm36p-1.a1.typesense.net",
@@ -14177,6 +14192,9 @@ var CONFIG = {
14177
14192
  basedProject: "platform-v2-sm",
14178
14193
  basedOrg: "symbols",
14179
14194
  githubClientId: "Ov23liFAlOEIXtX3dBtR",
14195
+ grafanaUrl: "https://faro-collector-prod-us-east-0.grafana.net/collect/5c1089f3c3eea4ec5658e05c3f53baae",
14196
+ // For grafana tracing
14197
+ grafanaAppName: "Symbols",
14180
14198
  typesenseCollectionName: "docs",
14181
14199
  typesenseApiKey: "awmcVpbWqZi9IUgmvslp1C5LKDU8tMjA",
14182
14200
  typesenseHost: "tl2qpnwxev4cjm36p-1.a1.typesense.net",
@@ -14203,6 +14221,7 @@ var getConfig = () => {
14203
14221
  basedProject: process.env.SYMBOLS_APP_BASED_PROJECT || envConfig.basedProject,
14204
14222
  basedOrg: process.env.SYMBOLS_APP_BASED_ORG || envConfig.basedOrg,
14205
14223
  githubClientId: process.env.SYMBOLS_APP_GITHUB_CLIENT_ID || envConfig.githubClientId,
14224
+ grafanaUrl: process.env.SYMBOLS_APP_GRAFANA_URL || envConfig.grafanaUrl,
14206
14225
  typesenseCollectionName: process.env.TYPESENSE_COLLECTION_NAME || envConfig.typesenseCollectionName,
14207
14226
  typesenseApiKey: process.env.TYPESENSE_API_KEY || envConfig.typesenseApiKey,
14208
14227
  typesenseHost: process.env.TYPESENSE_HOST || envConfig.typesenseHost,
@@ -15222,10 +15241,12 @@ var AuthService = class extends BaseService {
15222
15241
  throw new Error(`Password change confirmation failed: ${error.message}`, { cause: error });
15223
15242
  }
15224
15243
  }
15225
- async getMe() {
15244
+ async getMe(options = {}) {
15226
15245
  this._requireReady("getMe");
15227
15246
  try {
15228
- const response = await this._request("/auth/me", {
15247
+ const session = this._resolvePluginSession(options.session);
15248
+ const endpoint = session ? `/auth/me?session=${encodeURIComponent(session)}` : "/auth/me";
15249
+ const response = await this._request(endpoint, {
15229
15250
  method: "GET",
15230
15251
  methodName: "getMe"
15231
15252
  });
@@ -22119,8 +22140,8 @@ var CollabClient = class {
22119
22140
  __publicField(this, "_buffer", []);
22120
22141
  __publicField(this, "_flushTimer", null);
22121
22142
  __publicField(this, "_clientId", nanoid());
22122
- __publicField(this, "_outboxStore", null);
22123
- // Dexie table
22143
+ __publicField(this, "_outboxStore", createMemoryOutbox());
22144
+ // Dexie table fallback
22124
22145
  __publicField(this, "_readyResolve");
22125
22146
  __publicField(this, "ready", new Promise((res) => this._readyResolve = res));
22126
22147
  /* ---------- private handlers ---------- */
@@ -22162,6 +22183,12 @@ var CollabClient = class {
22162
22183
  await this._outboxStore.clear();
22163
22184
  }
22164
22185
  });
22186
+ __publicField(this, "_onLiveMode", (flag) => {
22187
+ this.live = flag;
22188
+ });
22189
+ __publicField(this, "_onError", (e) => {
22190
+ console.warn("[collab] socket error", e);
22191
+ });
22165
22192
  Object.assign(this, { jwt, projectId, branch, live });
22166
22193
  this.ydoc = new Doc();
22167
22194
  const hasIndexedDB = typeof globalThis.indexedDB !== "undefined";
@@ -22174,14 +22201,11 @@ var CollabClient = class {
22174
22201
  console.warn("[CollabClient] Failed to load IndexeddbPersistence:", err);
22175
22202
  });
22176
22203
  }
22177
- if (typeof window === "undefined" || !hasIndexedDB) {
22178
- this._outboxStore = createMemoryOutbox();
22179
- } else {
22204
+ if (typeof window !== "undefined" && hasIndexedDB) {
22180
22205
  createDexieOutbox(`${projectId}:${branch}`).then((outboxStore) => {
22181
22206
  this._outboxStore = outboxStore;
22182
22207
  }).catch((err) => {
22183
22208
  console.warn("[CollabClient] Failed to load Dexie:", err);
22184
- this._outboxStore = createMemoryOutbox();
22185
22209
  });
22186
22210
  }
22187
22211
  this.socket = lookup2(environment_default.socketUrl, {
@@ -22191,9 +22215,7 @@ var CollabClient = class {
22191
22215
  reconnectionAttempts: Infinity,
22192
22216
  reconnectionDelayMax: 4e3
22193
22217
  });
22194
- this.socket.on("snapshot", this._onSnapshot).on("ops", this._onOps).on("commit", this._onCommit).on("liveMode", (flag) => {
22195
- this.live = flag;
22196
- }).on("connect", this._onConnect).on("error", (e) => console.warn("[collab] socket error", e));
22218
+ this.socket.on("snapshot", this._onSnapshot).on("ops", this._onOps).on("commit", this._onCommit).on("liveMode", this._onLiveMode).on("connect", this._onConnect).on("error", this._onError);
22197
22219
  this._prevJson = this.ydoc.getMap("root").toJSON();
22198
22220
  this.ydoc.on("afterTransaction", (tr) => {
22199
22221
  if (tr.origin === "remote") {
@@ -22240,6 +22262,42 @@ var CollabClient = class {
22240
22262
  });
22241
22263
  this._buffer.length = 0;
22242
22264
  }
22265
+ dispose() {
22266
+ var _a;
22267
+ clearTimeout(this._flushTimer);
22268
+ this._flushTimer = null;
22269
+ this._buffer.length = 0;
22270
+ if ((_a = this._outboxStore) == null ? void 0 : _a.clear) {
22271
+ try {
22272
+ const result = this._outboxStore.clear();
22273
+ if (result && typeof result.catch === "function") {
22274
+ result.catch(() => {
22275
+ });
22276
+ }
22277
+ } catch (error) {
22278
+ console.warn("[CollabClient] Failed to clear outbox store during dispose:", error);
22279
+ }
22280
+ }
22281
+ if (this.socket) {
22282
+ this.socket.off("snapshot", this._onSnapshot);
22283
+ this.socket.off("ops", this._onOps);
22284
+ this.socket.off("commit", this._onCommit);
22285
+ this.socket.off("liveMode", this._onLiveMode);
22286
+ this.socket.off("connect", this._onConnect);
22287
+ this.socket.off("error", this._onError);
22288
+ this.socket.removeAllListeners();
22289
+ this.socket.disconnect();
22290
+ this.socket = null;
22291
+ }
22292
+ if (this.ydoc) {
22293
+ this.ydoc.destroy();
22294
+ this.ydoc = null;
22295
+ }
22296
+ if (typeof this._readyResolve === "function") {
22297
+ this._readyResolve();
22298
+ this._readyResolve = null;
22299
+ }
22300
+ }
22243
22301
  };
22244
22302
  function createMemoryOutbox() {
22245
22303
  const store = /* @__PURE__ */ new Map();
@@ -28798,12 +28856,20 @@ var CollabService = class extends BaseService {
28798
28856
  this._client = null;
28799
28857
  this._stateManager = null;
28800
28858
  this._connected = false;
28859
+ this._connecting = false;
28860
+ this._connectPromise = null;
28861
+ this._connectionMeta = null;
28862
+ this._pendingConnectReject = null;
28801
28863
  this._undoStack = [];
28802
28864
  this._redoStack = [];
28803
28865
  this._isUndoRedo = false;
28804
28866
  this._pendingOps = [];
28867
+ this._onSocketConnect = this._onSocketConnect.bind(this);
28868
+ this._onSocketDisconnect = this._onSocketDisconnect.bind(this);
28869
+ this._onSocketError = this._onSocketError.bind(this);
28805
28870
  }
28806
28871
  init({ context }) {
28872
+ super.init({ context });
28807
28873
  if (context == null ? void 0 : context.state) {
28808
28874
  try {
28809
28875
  this._stateManager = new RootStateManager(context.state);
@@ -28867,86 +28933,196 @@ var CollabService = class extends BaseService {
28867
28933
  }
28868
28934
  /* ---------- Connection Management ---------- */
28869
28935
  async connect(options = {}) {
28870
- var _a, _b, _c, _d, _e, _f;
28871
- this._ensureStateManager();
28872
- const {
28873
- authToken: jwt,
28874
- projectId,
28875
- branch = "main",
28876
- pro
28877
- } = {
28878
- ...this._context,
28879
- ...options
28880
- };
28881
- if (!projectId) {
28882
- const state = (_a = this._stateManager) == null ? void 0 : _a.root;
28883
- const el = state.__element;
28884
- el.call("openNotification", {
28885
- type: "error",
28886
- title: "projectId is required",
28887
- message: "projectId is required for CollabService connection"
28888
- });
28889
- throw new Error("projectId is required for CollabService connection");
28936
+ if (this._connectPromise) {
28937
+ return this._connectPromise;
28890
28938
  }
28891
- if (this._client) {
28892
- await this.disconnect();
28893
- }
28894
- this._client = new CollabClient({
28895
- jwt,
28896
- projectId,
28897
- branch,
28898
- live: Boolean(pro)
28899
- });
28900
- await new Promise((resolve) => {
28901
- var _a2, _b2;
28902
- if ((_a2 = this._client.socket) == null ? void 0 : _a2.connected) {
28903
- resolve();
28904
- } else {
28905
- (_b2 = this._client.socket) == null ? void 0 : _b2.once("connect", resolve);
28939
+ this._connectPromise = (async () => {
28940
+ var _a;
28941
+ this._connecting = true;
28942
+ this._connected = false;
28943
+ this._ensureStateManager();
28944
+ const mergedOptions = {
28945
+ ...this._context,
28946
+ ...options
28947
+ };
28948
+ let { authToken: jwt } = mergedOptions;
28949
+ const {
28950
+ projectId,
28951
+ branch = "main",
28952
+ pro
28953
+ } = mergedOptions;
28954
+ if (!jwt && this._tokenManager) {
28955
+ try {
28956
+ jwt = await this._tokenManager.ensureValidToken();
28957
+ } catch (error) {
28958
+ console.warn("[CollabService] Failed to obtain auth token from token manager", error);
28959
+ }
28960
+ if (!jwt && typeof this._tokenManager.getAccessToken === "function") {
28961
+ jwt = this._tokenManager.getAccessToken();
28962
+ }
28906
28963
  }
28907
- });
28908
- (_b = this._client.socket) == null ? void 0 : _b.on("ops", ({ changes }) => {
28909
- console.log(`ops event`);
28910
- this._stateManager.applyChanges(changes, { fromSocket: true });
28911
- });
28912
- (_c = this._client.socket) == null ? void 0 : _c.on("commit", ({ version: version2 }) => {
28913
- if (version2) {
28914
- this._stateManager.setVersion(version2);
28964
+ if (!jwt) {
28965
+ throw new Error("[CollabService] Cannot connect without auth token");
28915
28966
  }
28916
- rootBus.emit("checkpoint:done", { version: version2, origin: "auto" });
28917
- });
28918
- (_d = this._client.socket) == null ? void 0 : _d.on("clients", this._handleClientsEvent.bind(this));
28919
- (_e = this._client.socket) == null ? void 0 : _e.on(
28920
- "bundle:done",
28921
- this._handleBundleDoneEvent.bind(this)
28922
- );
28923
- (_f = this._client.socket) == null ? void 0 : _f.on(
28924
- "bundle:error",
28925
- this._handleBundleErrorEvent.bind(this)
28926
- );
28927
- if (this._pendingOps.length) {
28928
- console.log(
28929
- `[CollabService] Flushing ${this._pendingOps.length} offline operation batch(es)`
28930
- );
28931
- this._pendingOps.forEach(({ changes, granularChanges, orders }) => {
28932
- this.socket.emit("ops", { changes, granularChanges, orders, ts: Date.now() });
28967
+ this._context = {
28968
+ ...this._context,
28969
+ authToken: jwt,
28970
+ projectId,
28971
+ branch,
28972
+ pro
28973
+ };
28974
+ if (!projectId) {
28975
+ const state = (_a = this._stateManager) == null ? void 0 : _a.root;
28976
+ const el = state.__element;
28977
+ el.call("openNotification", {
28978
+ type: "error",
28979
+ title: "projectId is required",
28980
+ message: "projectId is required for CollabService connection"
28981
+ });
28982
+ throw new Error("projectId is required for CollabService connection");
28983
+ }
28984
+ if (this._client) {
28985
+ await this.disconnect();
28986
+ }
28987
+ this._client = new CollabClient({
28988
+ jwt,
28989
+ projectId,
28990
+ branch,
28991
+ live: Boolean(pro)
28992
+ });
28993
+ const { socket } = this._client;
28994
+ try {
28995
+ await new Promise((resolve, reject) => {
28996
+ if (!socket) {
28997
+ reject(new Error("[CollabService] Socket instance missing"));
28998
+ return;
28999
+ }
29000
+ if (socket.connected) {
29001
+ resolve();
29002
+ return;
29003
+ }
29004
+ const cleanup = () => {
29005
+ socket.off("connect", handleConnect);
29006
+ socket.off("connect_error", handleError);
29007
+ socket.off("error", handleError);
29008
+ socket.off("disconnect", handleDisconnect);
29009
+ if (this._pendingConnectReject === handleError) {
29010
+ this._pendingConnectReject = null;
29011
+ }
29012
+ };
29013
+ const handleConnect = () => {
29014
+ cleanup();
29015
+ resolve();
29016
+ };
29017
+ const handleError = (error) => {
29018
+ cleanup();
29019
+ reject(
29020
+ error instanceof Error ? error : new Error(String(error || "Unknown connection error"))
29021
+ );
29022
+ };
29023
+ const handleDisconnect = (reason) => {
29024
+ handleError(
29025
+ reason instanceof Error ? reason : new Error(
29026
+ `[CollabService] Socket disconnected before connect: ${reason || "unknown"}`
29027
+ )
29028
+ );
29029
+ };
29030
+ this._pendingConnectReject = handleError;
29031
+ socket.once("connect", handleConnect);
29032
+ socket.once("connect_error", handleError);
29033
+ socket.once("error", handleError);
29034
+ socket.once("disconnect", handleDisconnect);
29035
+ });
29036
+ } catch (error) {
29037
+ socket == null ? void 0 : socket.disconnect();
29038
+ this._client = null;
29039
+ this._connectionMeta = null;
29040
+ throw error;
29041
+ }
29042
+ this._attachSocketLifecycleListeners();
29043
+ if (socket == null ? void 0 : socket.connected) {
29044
+ this._onSocketConnect();
29045
+ }
29046
+ socket == null ? void 0 : socket.on("ops", ({ changes }) => {
29047
+ console.log(`ops event`);
29048
+ this._stateManager.applyChanges(changes, { fromSocket: true });
29049
+ });
29050
+ socket == null ? void 0 : socket.on("commit", ({ version: version2 }) => {
29051
+ if (version2) {
29052
+ this._stateManager.setVersion(version2);
29053
+ }
29054
+ rootBus.emit("checkpoint:done", { version: version2, origin: "auto" });
28933
29055
  });
28934
- this._pendingOps.length = 0;
29056
+ socket == null ? void 0 : socket.on("clients", this._handleClientsEvent.bind(this));
29057
+ socket == null ? void 0 : socket.on(
29058
+ "bundle:done",
29059
+ this._handleBundleDoneEvent.bind(this)
29060
+ );
29061
+ socket == null ? void 0 : socket.on(
29062
+ "bundle:error",
29063
+ this._handleBundleErrorEvent.bind(this)
29064
+ );
29065
+ if (this._pendingOps.length) {
29066
+ console.log(
29067
+ `[CollabService] Flushing ${this._pendingOps.length} offline operation batch(es)`
29068
+ );
29069
+ this._pendingOps.forEach(({ changes, granularChanges, orders }) => {
29070
+ this.socket.emit("ops", { changes, granularChanges, orders, ts: Date.now() });
29071
+ });
29072
+ this._pendingOps.length = 0;
29073
+ }
29074
+ await this._client.ready;
29075
+ this._connectionMeta = {
29076
+ projectId,
29077
+ branch,
29078
+ live: Boolean(pro)
29079
+ };
29080
+ return this.getConnectionInfo();
29081
+ })();
29082
+ try {
29083
+ return await this._connectPromise;
29084
+ } finally {
29085
+ this._connecting = false;
29086
+ this._connectPromise = null;
28935
29087
  }
28936
- this._connected = true;
28937
29088
  }
28938
29089
  disconnect() {
28939
29090
  var _a;
28940
29091
  if ((_a = this._client) == null ? void 0 : _a.socket) {
28941
- this._client.socket.disconnect();
29092
+ if (this._pendingConnectReject) {
29093
+ this._pendingConnectReject(new Error("[CollabService] Connection attempt aborted"));
29094
+ this._pendingConnectReject = null;
29095
+ }
29096
+ this._detachSocketLifecycleListeners();
29097
+ if (typeof this._client.dispose === "function") {
29098
+ this._client.dispose();
29099
+ } else {
29100
+ this._client.socket.disconnect();
29101
+ }
28942
29102
  }
28943
29103
  this._client = null;
28944
29104
  this._connected = false;
29105
+ this._connecting = false;
29106
+ this._connectionMeta = null;
29107
+ this._pendingConnectReject = null;
28945
29108
  console.log("[CollabService] Disconnected");
28946
29109
  }
28947
29110
  isConnected() {
28948
29111
  var _a, _b;
28949
- return this._connected && ((_b = (_a = this._client) == null ? void 0 : _a.socket) == null ? void 0 : _b.connected);
29112
+ return Boolean(this._connected && ((_b = (_a = this._client) == null ? void 0 : _a.socket) == null ? void 0 : _b.connected));
29113
+ }
29114
+ getConnectionInfo() {
29115
+ var _a, _b, _c, _d, _e, _f;
29116
+ return {
29117
+ connected: this.isConnected(),
29118
+ connecting: this._connecting,
29119
+ projectId: (_b = (_a = this._connectionMeta) == null ? void 0 : _a.projectId) != null ? _b : null,
29120
+ branch: (_d = (_c = this._connectionMeta) == null ? void 0 : _c.branch) != null ? _d : null,
29121
+ live: (_f = (_e = this._connectionMeta) == null ? void 0 : _e.live) != null ? _f : null,
29122
+ pendingOps: this._pendingOps.length,
29123
+ undoStackSize: this.getUndoStackSize(),
29124
+ redoStackSize: this.getRedoStackSize()
29125
+ };
28950
29126
  }
28951
29127
  /* convenient shortcuts */
28952
29128
  get ydoc() {
@@ -29313,6 +29489,38 @@ var CollabService = class extends BaseService {
29313
29489
  rootBus.emit("bundle:error", { project, ticket, error });
29314
29490
  }
29315
29491
  /* ---------- Manual checkpoint ---------- */
29492
+ _attachSocketLifecycleListeners() {
29493
+ var _a;
29494
+ const socket = (_a = this._client) == null ? void 0 : _a.socket;
29495
+ if (!socket) {
29496
+ return;
29497
+ }
29498
+ socket.on("connect", this._onSocketConnect);
29499
+ socket.on("disconnect", this._onSocketDisconnect);
29500
+ socket.on("connect_error", this._onSocketError);
29501
+ }
29502
+ _detachSocketLifecycleListeners() {
29503
+ var _a;
29504
+ const socket = (_a = this._client) == null ? void 0 : _a.socket;
29505
+ if (!socket) {
29506
+ return;
29507
+ }
29508
+ socket.off("connect", this._onSocketConnect);
29509
+ socket.off("disconnect", this._onSocketDisconnect);
29510
+ socket.off("connect_error", this._onSocketError);
29511
+ }
29512
+ _onSocketConnect() {
29513
+ this._connected = true;
29514
+ }
29515
+ _onSocketDisconnect(reason) {
29516
+ this._connected = false;
29517
+ if (reason && reason !== "io client disconnect") {
29518
+ console.warn("[CollabService] Socket disconnected", reason);
29519
+ }
29520
+ }
29521
+ _onSocketError(error) {
29522
+ console.warn("[CollabService] Socket connection error", error);
29523
+ }
29316
29524
  /**
29317
29525
  * Manually request a checkpoint / commit of buffered operations on the server.
29318
29526
  * Resolves with the new version number once the backend confirms via the
@@ -29491,7 +29699,8 @@ var ProjectService = class extends BaseService {
29491
29699
  const {
29492
29700
  branch = "main",
29493
29701
  version: version2 = "latest",
29494
- includeHistory = false
29702
+ includeHistory = false,
29703
+ headers
29495
29704
  } = options;
29496
29705
  const queryParams = new URLSearchParams({
29497
29706
  branch,
@@ -29503,7 +29712,8 @@ var ProjectService = class extends BaseService {
29503
29712
  `/projects/key/${key}/data?${queryParams}`,
29504
29713
  {
29505
29714
  method: "GET",
29506
- methodName: "getProjectDataByKey"
29715
+ methodName: "getProjectDataByKey",
29716
+ ...headers ? { headers } : {}
29507
29717
  }
29508
29718
  );
29509
29719
  if (response.success) {
@@ -29694,7 +29904,7 @@ var ProjectService = class extends BaseService {
29694
29904
  if (!projectId || !email || !role) {
29695
29905
  throw new Error("Project ID, email, and role are required");
29696
29906
  }
29697
- const { name, callbackUrl } = options;
29907
+ const { name, callbackUrl, headers } = options;
29698
29908
  const defaultCallbackUrl = typeof window === "undefined" ? "https://app.symbols.com/accept-invite" : `${window.location.origin}/accept-invite`;
29699
29909
  try {
29700
29910
  const requestBody = {
@@ -29708,6 +29918,7 @@ var ProjectService = class extends BaseService {
29708
29918
  const response = await this._request(`/projects/${projectId}/invite`, {
29709
29919
  method: "POST",
29710
29920
  body: JSON.stringify(requestBody),
29921
+ ...headers ? { headers } : {},
29711
29922
  methodName: "inviteMember"
29712
29923
  });
29713
29924
  if (response.success) {
@@ -29869,7 +30080,7 @@ var ProjectService = class extends BaseService {
29869
30080
  if (!Array.isArray(changes)) {
29870
30081
  throw new Error("Changes must be an array");
29871
30082
  }
29872
- const { message, branch = "main", type = "patch" } = options;
30083
+ const { message, branch = "main", type = "patch", headers } = options;
29873
30084
  const state = this._context && this._context.state;
29874
30085
  const { granularChanges, orders: preprocessorOrders } = preprocessChanges(state, changes, options);
29875
30086
  const derivedOrders = options.orders || (preprocessorOrders && preprocessorOrders.length ? preprocessorOrders : state ? computeOrdersForTuples(state, granularChanges) : []);
@@ -29885,6 +30096,7 @@ var ProjectService = class extends BaseService {
29885
30096
  type,
29886
30097
  ...derivedOrders && derivedOrders.length ? { orders: derivedOrders } : {}
29887
30098
  }),
30099
+ ...headers ? { headers } : {},
29888
30100
  methodName: "applyProjectChanges"
29889
30101
  });
29890
30102
  if (response.success) {
@@ -29907,7 +30119,8 @@ var ProjectService = class extends BaseService {
29907
30119
  const {
29908
30120
  branch = "main",
29909
30121
  version: version2 = "latest",
29910
- includeHistory = false
30122
+ includeHistory = false,
30123
+ headers
29911
30124
  } = options;
29912
30125
  const queryParams = new URLSearchParams({
29913
30126
  branch,
@@ -29919,7 +30132,8 @@ var ProjectService = class extends BaseService {
29919
30132
  `/projects/${projectId}/data?${queryParams}`,
29920
30133
  {
29921
30134
  method: "GET",
29922
- methodName: "getProjectData"
30135
+ methodName: "getProjectData",
30136
+ ...headers ? { headers } : {}
29923
30137
  }
29924
30138
  );
29925
30139
  if (response.success) {
@@ -29938,7 +30152,7 @@ var ProjectService = class extends BaseService {
29938
30152
  if (!projectId) {
29939
30153
  throw new Error("Project ID is required");
29940
30154
  }
29941
- const { branch = "main", page = 1, limit = 50 } = options;
30155
+ const { branch = "main", page = 1, limit = 50, headers } = options;
29942
30156
  const queryParams = new URLSearchParams({
29943
30157
  branch,
29944
30158
  page: page.toString(),
@@ -29949,7 +30163,8 @@ var ProjectService = class extends BaseService {
29949
30163
  `/projects/${projectId}/versions?${queryParams}`,
29950
30164
  {
29951
30165
  method: "GET",
29952
- methodName: "getProjectVersions"
30166
+ methodName: "getProjectVersions",
30167
+ ...headers ? { headers } : {}
29953
30168
  }
29954
30169
  );
29955
30170
  if (response.success) {
@@ -29972,7 +30187,7 @@ var ProjectService = class extends BaseService {
29972
30187
  if (!version2) {
29973
30188
  throw new Error("Version is required");
29974
30189
  }
29975
- const { message, branch = "main", type = "patch" } = options;
30190
+ const { message, branch = "main", type = "patch", headers } = options;
29976
30191
  try {
29977
30192
  const response = await this._request(`/projects/${projectId}/restore`, {
29978
30193
  method: "POST",
@@ -29982,6 +30197,7 @@ var ProjectService = class extends BaseService {
29982
30197
  branch,
29983
30198
  type
29984
30199
  }),
30200
+ ...headers ? { headers } : {},
29985
30201
  methodName: "restoreProjectVersion"
29986
30202
  });
29987
30203
  if (response.success) {
@@ -30131,7 +30347,7 @@ var ProjectService = class extends BaseService {
30131
30347
  // ==================== RECENT PROJECT METHODS ====================
30132
30348
  async getRecentProjects(options = {}) {
30133
30349
  this._requireReady("getRecentProjects");
30134
- const { limit = 20 } = options;
30350
+ const { limit = 20, headers } = options;
30135
30351
  const queryString = new URLSearchParams({
30136
30352
  limit: limit.toString()
30137
30353
  }).toString();
@@ -30139,6 +30355,7 @@ var ProjectService = class extends BaseService {
30139
30355
  try {
30140
30356
  const response = await this._request(url2, {
30141
30357
  method: "GET",
30358
+ ...headers ? { headers } : {},
30142
30359
  methodName: "getRecentProjects"
30143
30360
  });
30144
30361
  if (response.success) {
@@ -30,6 +30,9 @@ var CONFIG = {
30
30
  // For based api
31
31
  githubClientId: "Ov23liAFrsR0StbAO6PO",
32
32
  // For github api
33
+ grafanaUrl: "https://faro-collector-prod-us-east-0.grafana.net/collect/aef64330db80bdfeaac084317bf72f99",
34
+ // For grafana tracing
35
+ grafanaAppName: "Localhost Symbols",
33
36
  // Environment-specific feature toggles (override common)
34
37
  features: {
35
38
  betaFeatures: true
@@ -45,6 +48,9 @@ var CONFIG = {
45
48
  socketUrl: "https://dev.api.symbols.app",
46
49
  apiUrl: "https://dev.api.symbols.app",
47
50
  githubClientId: "Ov23liHxyWFBxS8f1gnF",
51
+ grafanaUrl: "https://faro-collector-prod-us-east-0.grafana.net/collect/7a3ba473cee2025c68513667024316b8",
52
+ // For grafana tracing
53
+ grafanaAppName: "Symbols Dev",
48
54
  typesenseCollectionName: "docs",
49
55
  typesenseApiKey: "awmcVpbWqZi9IUgmvslp1C5LKDU8tMjA",
50
56
  typesenseHost: "tl2qpnwxev4cjm36p-1.a1.typesense.net",
@@ -58,6 +64,9 @@ var CONFIG = {
58
64
  basedProject: "platform-v2-sm",
59
65
  basedOrg: "symbols",
60
66
  githubClientId: "Ov23liHxyWFBxS8f1gnF",
67
+ grafanaUrl: "https://faro-collector-prod-us-east-0.grafana.net/collect/7a3ba473cee2025c68513667024316b8",
68
+ // For grafana tracing
69
+ grafanaAppName: "Symbols Test",
61
70
  typesenseCollectionName: "docs",
62
71
  typesenseApiKey: "awmcVpbWqZi9IUgmvslp1C5LKDU8tMjA",
63
72
  typesenseHost: "tl2qpnwxev4cjm36p-1.a1.typesense.net",
@@ -68,6 +77,9 @@ var CONFIG = {
68
77
  socketUrl: "https://upcoming.api.symbols.app",
69
78
  apiUrl: "https://upcoming.api.symbols.app",
70
79
  githubClientId: "Ov23liWF7NvdZ056RV5J",
80
+ grafanaUrl: "https://faro-collector-prod-us-east-0.grafana.net/collect/7a3ba473cee2025c68513667024316b8",
81
+ // For grafana tracing
82
+ grafanaAppName: "Symbols Upcoming",
71
83
  typesenseCollectionName: "docs",
72
84
  typesenseApiKey: "awmcVpbWqZi9IUgmvslp1C5LKDU8tMjA",
73
85
  typesenseHost: "tl2qpnwxev4cjm36p-1.a1.typesense.net",
@@ -81,6 +93,9 @@ var CONFIG = {
81
93
  basedProject: "platform-v2-sm",
82
94
  basedOrg: "symbols",
83
95
  githubClientId: "Ov23ligwZDQVD0VfuWNa",
96
+ grafanaUrl: "https://faro-collector-prod-us-east-0.grafana.net/collect/7a3ba473cee2025c68513667024316b8",
97
+ // For grafana tracing
98
+ grafanaAppName: "Symbols Staging",
84
99
  typesenseCollectionName: "docs",
85
100
  typesenseApiKey: "awmcVpbWqZi9IUgmvslp1C5LKDU8tMjA",
86
101
  typesenseHost: "tl2qpnwxev4cjm36p-1.a1.typesense.net",
@@ -94,6 +109,9 @@ var CONFIG = {
94
109
  basedProject: "platform-v2-sm",
95
110
  basedOrg: "symbols",
96
111
  githubClientId: "Ov23liFAlOEIXtX3dBtR",
112
+ grafanaUrl: "https://faro-collector-prod-us-east-0.grafana.net/collect/5c1089f3c3eea4ec5658e05c3f53baae",
113
+ // For grafana tracing
114
+ grafanaAppName: "Symbols",
97
115
  typesenseCollectionName: "docs",
98
116
  typesenseApiKey: "awmcVpbWqZi9IUgmvslp1C5LKDU8tMjA",
99
117
  typesenseHost: "tl2qpnwxev4cjm36p-1.a1.typesense.net",
@@ -120,6 +138,7 @@ var getConfig = () => {
120
138
  basedProject: process.env.SYMBOLS_APP_BASED_PROJECT || envConfig.basedProject,
121
139
  basedOrg: process.env.SYMBOLS_APP_BASED_ORG || envConfig.basedOrg,
122
140
  githubClientId: process.env.SYMBOLS_APP_GITHUB_CLIENT_ID || envConfig.githubClientId,
141
+ grafanaUrl: process.env.SYMBOLS_APP_GRAFANA_URL || envConfig.grafanaUrl,
123
142
  typesenseCollectionName: process.env.TYPESENSE_COLLECTION_NAME || envConfig.typesenseCollectionName,
124
143
  typesenseApiKey: process.env.TYPESENSE_API_KEY || envConfig.typesenseApiKey,
125
144
  typesenseHost: process.env.TYPESENSE_HOST || envConfig.typesenseHost,