@symbo.ls/sdk 2.32.19 → 2.32.25

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 (37) hide show
  1. package/dist/cjs/services/AuthService.js +6 -0
  2. package/dist/cjs/services/BaseService.js +1 -1
  3. package/dist/cjs/services/CollabService.js +24 -6
  4. package/dist/cjs/utils/changePreprocessor.js +58 -2
  5. package/dist/cjs/utils/services.js +1 -0
  6. package/dist/esm/index.js +887 -806
  7. package/dist/esm/services/AdminService.js +1 -1
  8. package/dist/esm/services/AuthService.js +7 -1
  9. package/dist/esm/services/BaseService.js +1 -1
  10. package/dist/esm/services/BranchService.js +1 -1
  11. package/dist/esm/services/CollabService.js +180 -106
  12. package/dist/esm/services/DnsService.js +1 -1
  13. package/dist/esm/services/FileService.js +1 -1
  14. package/dist/esm/services/PaymentService.js +1 -1
  15. package/dist/esm/services/PlanService.js +1 -1
  16. package/dist/esm/services/ProjectService.js +59 -3
  17. package/dist/esm/services/PullRequestService.js +1 -1
  18. package/dist/esm/services/ScreenshotService.js +1 -1
  19. package/dist/esm/services/SubscriptionService.js +1 -1
  20. package/dist/esm/services/TrackingService.js +701 -701
  21. package/dist/esm/services/index.js +886 -806
  22. package/dist/esm/utils/CollabClient.js +95 -95
  23. package/dist/esm/utils/changePreprocessor.js +58 -2
  24. package/dist/esm/utils/jsonDiff.js +26 -26
  25. package/dist/esm/utils/services.js +1 -0
  26. package/dist/esm/utils/validation.js +2 -2
  27. package/dist/node/services/AuthService.js +6 -0
  28. package/dist/node/services/BaseService.js +1 -1
  29. package/dist/node/services/CollabService.js +24 -6
  30. package/dist/node/utils/changePreprocessor.js +58 -2
  31. package/dist/node/utils/services.js +1 -0
  32. package/package.json +6 -6
  33. package/src/services/AuthService.js +7 -0
  34. package/src/services/BaseService.js +1 -1
  35. package/src/services/CollabService.js +27 -6
  36. package/src/utils/changePreprocessor.js +76 -2
  37. package/src/utils/services.js +1 -0
@@ -337,6 +337,12 @@ class AuthService extends import_BaseService.BaseService {
337
337
  throw new Error(`Failed to get user profile: ${error.message}`, { cause: error });
338
338
  }
339
339
  }
340
+ getAuthToken() {
341
+ if (!this._tokenManager) {
342
+ return null;
343
+ }
344
+ return this._tokenManager.getAccessToken();
345
+ }
340
346
  /**
341
347
  * Get stored authentication state (backward compatibility method)
342
348
  * Replaces AuthService.getStoredAuthState()
@@ -122,7 +122,7 @@ class BaseService {
122
122
  }
123
123
  }
124
124
  _requireAuth() {
125
- if (!this._context.authToken) {
125
+ if (!this.getAuthToken()) {
126
126
  throw new Error("Authentication required");
127
127
  }
128
128
  }
@@ -243,8 +243,19 @@ class CollabService extends import_BaseService.BaseService {
243
243
  console.log(
244
244
  `[CollabService] Flushing ${this._pendingOps.length} offline operation batch(es)`
245
245
  );
246
- this._pendingOps.forEach(({ changes, granularChanges, orders }) => {
247
- this.socket.emit("ops", { changes, granularChanges, orders, ts: Date.now() });
246
+ this._pendingOps.forEach(({ changes, granularChanges, orders, options: opOptions }) => {
247
+ const { message } = opOptions || {};
248
+ const ts = Date.now();
249
+ const payload = {
250
+ changes,
251
+ granularChanges,
252
+ orders,
253
+ ts
254
+ };
255
+ if (message) {
256
+ payload.message = message;
257
+ }
258
+ this.socket.emit("ops", payload);
248
259
  });
249
260
  this._pendingOps.length = 0;
250
261
  }
@@ -355,6 +366,7 @@ class CollabService extends import_BaseService.BaseService {
355
366
  tuples,
356
367
  Array.isArray(tuples) ? [] : {}
357
368
  ) : (0, import_utils.deepStringifyFunctions)(tuples, Array.isArray(tuples) ? [] : {});
369
+ const { message } = options;
358
370
  if (!this.isConnected()) {
359
371
  console.warn("[CollabService] Not connected, queuing real-time update");
360
372
  this._pendingOps.push({
@@ -366,18 +378,24 @@ class CollabService extends import_BaseService.BaseService {
366
378
  return;
367
379
  }
368
380
  if ((_c = this.socket) == null ? void 0 : _c.connected) {
381
+ const ts = Date.now();
369
382
  console.log("[CollabService] Sending operations to the backend", {
370
383
  changes: stringifiedTuples,
371
384
  granularChanges: stringifiedGranularTuples,
372
385
  orders,
373
- ts: Date.now()
386
+ ts,
387
+ message
374
388
  });
375
- this.socket.emit("ops", {
389
+ const payload = {
376
390
  changes: stringifiedTuples,
377
391
  granularChanges: stringifiedGranularTuples,
378
392
  orders,
379
- ts: Date.now()
380
- });
393
+ ts
394
+ };
395
+ if (message) {
396
+ payload.message = message;
397
+ }
398
+ this.socket.emit("ops", payload);
381
399
  }
382
400
  return { success: true };
383
401
  }
@@ -35,6 +35,48 @@ function getByPathSafe(root, path) {
35
35
  return null;
36
36
  }
37
37
  }
38
+ function resolveNextValueFromTuples(tuples, path) {
39
+ if (!Array.isArray(tuples) || !Array.isArray(path)) {
40
+ return null;
41
+ }
42
+ for (let i = tuples.length - 1; i >= 0; i--) {
43
+ const t = tuples[i];
44
+ if (!Array.isArray(t) || t.length < 3) {
45
+ continue;
46
+ }
47
+ const [action, tuplePath, tupleValue] = t;
48
+ if (action !== "update" && action !== "set" || !Array.isArray(tuplePath)) {
49
+ continue;
50
+ }
51
+ if (tuplePath.length > path.length) {
52
+ continue;
53
+ }
54
+ let isPrefix = true;
55
+ for (let j = 0; j < tuplePath.length; j++) {
56
+ if (tuplePath[j] !== path[j]) {
57
+ isPrefix = false;
58
+ break;
59
+ }
60
+ }
61
+ if (!isPrefix) {
62
+ continue;
63
+ }
64
+ if (tuplePath.length === path.length) {
65
+ return tupleValue;
66
+ }
67
+ let current = tupleValue;
68
+ for (let j = tuplePath.length; j < path.length; j++) {
69
+ if (current == null) {
70
+ return null;
71
+ }
72
+ current = current[path[j]];
73
+ }
74
+ if (current !== null) {
75
+ return current;
76
+ }
77
+ }
78
+ return null;
79
+ }
38
80
  function preprocessChanges(root, tuples = [], options = {}) {
39
81
  const expandTuple = (t) => {
40
82
  const [action, path, value] = t || [];
@@ -109,7 +151,21 @@ function preprocessChanges(root, tuples = [], options = {}) {
109
151
  return Array.isArray(tuples) ? tuples.slice() : [];
110
152
  }
111
153
  })();
112
- const baseOrders = (0, import_ordering.computeOrdersForTuples)(root, granularChanges);
154
+ const hydratedGranularChanges = granularChanges.map((t) => {
155
+ if (!Array.isArray(t) || t.length < 3) {
156
+ return t;
157
+ }
158
+ const [action, path] = t;
159
+ if (action !== "update" && action !== "set" || !Array.isArray(path)) {
160
+ return t;
161
+ }
162
+ const nextValue = resolveNextValueFromTuples(tuples, path);
163
+ if (nextValue === null) {
164
+ return t;
165
+ }
166
+ return [action, path, nextValue];
167
+ });
168
+ const baseOrders = (0, import_ordering.computeOrdersForTuples)(root, hydratedGranularChanges);
113
169
  const preferOrdersMap = /* @__PURE__ */ new Map();
114
170
  for (let i = 0; i < tuples.length; i++) {
115
171
  const t = tuples[i];
@@ -139,5 +195,5 @@ function preprocessChanges(root, tuples = [], options = {}) {
139
195
  mergedOrders.push(v);
140
196
  }
141
197
  }
142
- return { granularChanges, orders: mergedOrders };
198
+ return { granularChanges: hydratedGranularChanges, orders: mergedOrders };
143
199
  }
@@ -42,6 +42,7 @@ const SERVICE_METHODS = {
42
42
  // Core service methods (new - replaces most based/auth functionality)
43
43
  // Auth methods
44
44
  getStoredAuthState: "auth",
45
+ getAuthToken: "auth",
45
46
  register: "auth",
46
47
  login: "auth",
47
48
  logout: "auth",