@symbo.ls/sdk 2.32.6 → 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
@@ -181,7 +181,8 @@ export class ProjectService extends BaseService {
181
181
  const {
182
182
  branch = 'main',
183
183
  version = 'latest',
184
- includeHistory = false
184
+ includeHistory = false,
185
+ headers
185
186
  } = options
186
187
 
187
188
  const queryParams = new URLSearchParams({
@@ -195,7 +196,8 @@ export class ProjectService extends BaseService {
195
196
  `/projects/key/${key}/data?${queryParams}`,
196
197
  {
197
198
  method: 'GET',
198
- methodName: 'getProjectDataByKey'
199
+ methodName: 'getProjectDataByKey',
200
+ ...(headers ? { headers } : {})
199
201
  }
200
202
  )
201
203
 
@@ -401,7 +403,7 @@ export class ProjectService extends BaseService {
401
403
  throw new Error('Project ID, email, and role are required')
402
404
  }
403
405
 
404
- const { name, callbackUrl } = options
406
+ const { name, callbackUrl, headers } = options
405
407
 
406
408
  // Default callbackUrl if not provided
407
409
  const defaultCallbackUrl =
@@ -424,6 +426,7 @@ export class ProjectService extends BaseService {
424
426
  const response = await this._request(`/projects/${projectId}/invite`, {
425
427
  method: 'POST',
426
428
  body: JSON.stringify(requestBody),
429
+ ...(headers ? { headers } : {}),
427
430
  methodName: 'inviteMember'
428
431
  })
429
432
  if (response.success) {
@@ -596,7 +599,7 @@ export class ProjectService extends BaseService {
596
599
  throw new Error('Changes must be an array')
597
600
  }
598
601
 
599
- const { message, branch = 'main', type = 'patch' } = options
602
+ const { message, branch = 'main', type = 'patch', headers } = options
600
603
 
601
604
  // Preprocess into granular changes and derive orders using current state if available
602
605
  const state = this._context && this._context.state
@@ -618,6 +621,7 @@ export class ProjectService extends BaseService {
618
621
  type,
619
622
  ...(derivedOrders && derivedOrders.length ? { orders: derivedOrders } : {})
620
623
  }),
624
+ ...(headers ? { headers } : {}),
621
625
  methodName: 'applyProjectChanges'
622
626
  })
623
627
 
@@ -643,7 +647,8 @@ export class ProjectService extends BaseService {
643
647
  const {
644
648
  branch = 'main',
645
649
  version = 'latest',
646
- includeHistory = false
650
+ includeHistory = false,
651
+ headers
647
652
  } = options
648
653
 
649
654
  const queryParams = new URLSearchParams({
@@ -657,7 +662,8 @@ export class ProjectService extends BaseService {
657
662
  `/projects/${projectId}/data?${queryParams}`,
658
663
  {
659
664
  method: 'GET',
660
- methodName: 'getProjectData'
665
+ methodName: 'getProjectData',
666
+ ...(headers ? { headers } : {})
661
667
  }
662
668
  )
663
669
  if (response.success) {
@@ -678,7 +684,7 @@ export class ProjectService extends BaseService {
678
684
  throw new Error('Project ID is required')
679
685
  }
680
686
 
681
- const { branch = 'main', page = 1, limit = 50 } = options
687
+ const { branch = 'main', page = 1, limit = 50, headers } = options
682
688
 
683
689
  const queryParams = new URLSearchParams({
684
690
  branch,
@@ -691,7 +697,8 @@ export class ProjectService extends BaseService {
691
697
  `/projects/${projectId}/versions?${queryParams}`,
692
698
  {
693
699
  method: 'GET',
694
- methodName: 'getProjectVersions'
700
+ methodName: 'getProjectVersions',
701
+ ...(headers ? { headers } : {})
695
702
  }
696
703
  )
697
704
  if (response.success) {
@@ -716,7 +723,7 @@ export class ProjectService extends BaseService {
716
723
  throw new Error('Version is required')
717
724
  }
718
725
 
719
- const { message, branch = 'main', type = 'patch' } = options
726
+ const { message, branch = 'main', type = 'patch', headers } = options
720
727
 
721
728
  try {
722
729
  const response = await this._request(`/projects/${projectId}/restore`, {
@@ -727,6 +734,7 @@ export class ProjectService extends BaseService {
727
734
  branch,
728
735
  type
729
736
  }),
737
+ ...(headers ? { headers } : {}),
730
738
  methodName: 'restoreProjectVersion'
731
739
  })
732
740
  if (response.success) {
@@ -912,7 +920,7 @@ export class ProjectService extends BaseService {
912
920
  async getRecentProjects (options = {}) {
913
921
  this._requireReady('getRecentProjects')
914
922
 
915
- const { limit = 20 } = options
923
+ const { limit = 20, headers } = options
916
924
  const queryString = new URLSearchParams({
917
925
  limit: limit.toString()
918
926
  }).toString()
@@ -921,6 +929,7 @@ export class ProjectService extends BaseService {
921
929
  try {
922
930
  const response = await this._request(url, {
923
931
  method: 'GET',
932
+ ...(headers ? { headers } : {}),
924
933
  methodName: 'getRecentProjects'
925
934
  })
926
935
 
@@ -24,7 +24,7 @@ export class CollabClient {
24
24
  _buffer = []
25
25
  _flushTimer = null
26
26
  _clientId = nanoid()
27
- _outboxStore = null // Dexie table
27
+ _outboxStore = createMemoryOutbox() // Dexie table fallback
28
28
  _readyResolve
29
29
  ready = new Promise(res => (this._readyResolve = res))
30
30
 
@@ -52,10 +52,7 @@ export class CollabClient {
52
52
  }
53
53
 
54
54
  /* 2️⃣ init Dexie for outbox (browser only) */
55
- if (typeof window === 'undefined' || !hasIndexedDB) {
56
- // In Node.js environments, use a simple in-memory store
57
- this._outboxStore = createMemoryOutbox()
58
- } else {
55
+ if (typeof window !== 'undefined' && hasIndexedDB) {
59
56
  // In browser environments, use Dexie
60
57
  createDexieOutbox(`${projectId}:${branch}`)
61
58
  .then(outboxStore => {
@@ -63,7 +60,6 @@ export class CollabClient {
63
60
  })
64
61
  .catch(err => {
65
62
  console.warn('[CollabClient] Failed to load Dexie:', err)
66
- this._outboxStore = createMemoryOutbox()
67
63
  })
68
64
  }
69
65
 
@@ -81,9 +77,9 @@ export class CollabClient {
81
77
  .on('snapshot', this._onSnapshot)
82
78
  .on('ops', this._onOps)
83
79
  .on('commit', this._onCommit)
84
- .on('liveMode', flag => { this.live = flag })
80
+ .on('liveMode', this._onLiveMode)
85
81
  .on('connect', this._onConnect)
86
- .on('error', e => console.warn('[collab] socket error', e))
82
+ .on('error', this._onError)
87
83
 
88
84
  /* Track last known JSON representation so we can compute granular diffs. */
89
85
  this._prevJson = this.ydoc.getMap('root').toJSON()
@@ -184,6 +180,53 @@ export class CollabClient {
184
180
  })
185
181
  this._buffer.length = 0
186
182
  }
183
+
184
+ dispose () {
185
+ clearTimeout(this._flushTimer)
186
+ this._flushTimer = null
187
+ this._buffer.length = 0
188
+
189
+ if (this._outboxStore?.clear) {
190
+ try {
191
+ const result = this._outboxStore.clear()
192
+ if (result && typeof result.catch === 'function') {
193
+ result.catch(() => {})
194
+ }
195
+ } catch (error) {
196
+ console.warn('[CollabClient] Failed to clear outbox store during dispose:', error)
197
+ }
198
+ }
199
+
200
+ if (this.socket) {
201
+ this.socket.off('snapshot', this._onSnapshot)
202
+ this.socket.off('ops', this._onOps)
203
+ this.socket.off('commit', this._onCommit)
204
+ this.socket.off('liveMode', this._onLiveMode)
205
+ this.socket.off('connect', this._onConnect)
206
+ this.socket.off('error', this._onError)
207
+ this.socket.removeAllListeners()
208
+ this.socket.disconnect()
209
+ this.socket = null
210
+ }
211
+
212
+ if (this.ydoc) {
213
+ this.ydoc.destroy()
214
+ this.ydoc = null
215
+ }
216
+
217
+ if (typeof this._readyResolve === 'function') {
218
+ this._readyResolve()
219
+ this._readyResolve = null
220
+ }
221
+ }
222
+
223
+ _onLiveMode = (flag) => {
224
+ this.live = flag
225
+ }
226
+
227
+ _onError = (e) => {
228
+ console.warn('[collab] socket error', e)
229
+ }
187
230
  }
188
231
 
189
232
  /* ---------- Memory storage helper for Node.js ---------- */