holosphere 2.0.0-alpha10 → 2.0.0-alpha11

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 (29) hide show
  1. package/dist/cjs/holosphere.cjs +1 -1
  2. package/dist/esm/holosphere.js +1 -1
  3. package/dist/{index-DeZ1xz_s.js → index-Bl6rM1NW.js} +2 -2
  4. package/dist/{index-DeZ1xz_s.js.map → index-Bl6rM1NW.js.map} +1 -1
  5. package/dist/{index-DDGt_V9o.cjs → index-Bwg3OzRM.cjs} +2 -2
  6. package/dist/{index-DDGt_V9o.cjs.map → index-Bwg3OzRM.cjs.map} +1 -1
  7. package/dist/{index-DJXftyvB.js → index-D-jZhliX.js} +531 -98
  8. package/dist/index-D-jZhliX.js.map +1 -0
  9. package/dist/index-Dc6Z8Aob.cjs +18 -0
  10. package/dist/index-Dc6Z8Aob.cjs.map +1 -0
  11. package/dist/{indexeddb-storage-BFt6hMeF.js → indexeddb-storage-5eiUNsHC.js} +2 -2
  12. package/dist/{indexeddb-storage-BFt6hMeF.js.map → indexeddb-storage-5eiUNsHC.js.map} +1 -1
  13. package/dist/{indexeddb-storage-BK5tv4Sh.cjs → indexeddb-storage-FNFUVvTJ.cjs} +2 -2
  14. package/dist/{indexeddb-storage-BK5tv4Sh.cjs.map → indexeddb-storage-FNFUVvTJ.cjs.map} +1 -1
  15. package/dist/{memory-storage-C9HuoL2E.js → memory-storage-CI-gfmuG.js} +2 -2
  16. package/dist/{memory-storage-C9HuoL2E.js.map → memory-storage-CI-gfmuG.js.map} +1 -1
  17. package/dist/{memory-storage-Dao7jfYG.cjs → memory-storage-DMt36uZO.cjs} +2 -2
  18. package/dist/{memory-storage-Dao7jfYG.cjs.map → memory-storage-DMt36uZO.cjs.map} +1 -1
  19. package/dist/{secp256k1-CreY7Pcl.js → secp256k1-CEwJNcfV.js} +2 -2
  20. package/dist/{secp256k1-CreY7Pcl.js.map → secp256k1-CEwJNcfV.js.map} +1 -1
  21. package/dist/{secp256k1-BbKzbLtD.cjs → secp256k1-CiEONUnj.cjs} +2 -2
  22. package/dist/{secp256k1-BbKzbLtD.cjs.map → secp256k1-CiEONUnj.cjs.map} +1 -1
  23. package/package.json +1 -1
  24. package/src/index.js +62 -19
  25. package/dist/cdn/holosphere.min.js +0 -55
  26. package/dist/cdn/holosphere.min.js.map +0 -1
  27. package/dist/index-DJXftyvB.js.map +0 -1
  28. package/dist/index-DMbdcMtK.cjs +0 -18
  29. package/dist/index-DMbdcMtK.cjs.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "holosphere",
3
- "version": "2.0.0-alpha10",
3
+ "version": "2.0.0-alpha11",
4
4
  "description": "Holonic geospatial communication infrastructure combining H3 hexagonal indexing with distributed P2P storage",
5
5
  "type": "module",
6
6
  "bin": {
package/src/index.js CHANGED
@@ -276,10 +276,14 @@ class HoloSphereBase extends HoloSphereCore {
276
276
  * @throws {AuthorizationError} If capability token is invalid
277
277
  */
278
278
  async write(holonId, lensName, data, options = {}) {
279
- if (!holonId || typeof holonId !== 'string') {
279
+ // Auto-convert to strings for convenience
280
+ if (holonId != null) holonId = String(holonId);
281
+ if (lensName != null) lensName = String(lensName);
282
+
283
+ if (!holonId) {
280
284
  throw new ValidationError('ValidationError: holonId must be a non-empty string');
281
285
  }
282
- if (!lensName || typeof lensName !== 'string') {
286
+ if (!lensName) {
283
287
  throw new ValidationError('ValidationError: lensName must be a non-empty string');
284
288
  }
285
289
  if (!data || typeof data !== 'object') {
@@ -296,6 +300,9 @@ class HoloSphereBase extends HoloSphereCore {
296
300
 
297
301
  if (!data.id) {
298
302
  data.id = `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
303
+ } else {
304
+ // Auto-convert data.id to string for convenience
305
+ data.id = String(data.id);
299
306
  }
300
307
 
301
308
  // Add metadata
@@ -318,7 +325,7 @@ class HoloSphereBase extends HoloSphereCore {
318
325
  // OPTIMISTIC UPDATE: Store in write cache and clear from delete cache
319
326
  this._writeCache.set(path, { data: { ...data }, timestamp: Date.now() });
320
327
  this._deleteCache.delete(path);
321
- this._log('INFO', '📝 CACHE WRITE', {
328
+ this._log('DEBUG', '📝 CACHE WRITE', {
322
329
  path,
323
330
  dataId: data.id,
324
331
  cacheSize: this._writeCache.size,
@@ -353,7 +360,7 @@ class HoloSphereBase extends HoloSphereCore {
353
360
  */
354
361
  async _syncWriteToRelay(holonId, lensName, data, path, options) {
355
362
  const startTime = Date.now();
356
- this._log('INFO', '🔄 RELAY SYNC START', {
363
+ this._log('DEBUG', '🔄 RELAY SYNC START', {
357
364
  path,
358
365
  dataId: data.id,
359
366
  relays: this.client?.relays?.map(r => r.url) || ['local-only']
@@ -378,7 +385,7 @@ class HoloSphereBase extends HoloSphereCore {
378
385
  if (!this._metrics.totalWriteTime) this._metrics.totalWriteTime = 0;
379
386
  this._metrics.totalWriteTime += duration;
380
387
 
381
- this._log('INFO', '✅ RELAY SYNC SUCCESS', {
388
+ this._log('DEBUG', '✅ RELAY SYNC SUCCESS', {
382
389
  path,
383
390
  dataId: data.id,
384
391
  duration: `${duration}ms`,
@@ -594,10 +601,15 @@ class HoloSphereBase extends HoloSphereCore {
594
601
  * @throws {AuthorizationError} If capability token is invalid
595
602
  */
596
603
  async read(holonId, lensName, dataId = null, options = {}) {
597
- if (!holonId || typeof holonId !== 'string') {
604
+ // Auto-convert to strings for convenience
605
+ if (holonId != null) holonId = String(holonId);
606
+ if (lensName != null) lensName = String(lensName);
607
+ if (dataId != null) dataId = String(dataId);
608
+
609
+ if (!holonId) {
598
610
  throw new ValidationError('ValidationError: holonId must be a non-empty string');
599
611
  }
600
- if (!lensName || typeof lensName !== 'string') {
612
+ if (!lensName) {
601
613
  throw new ValidationError('ValidationError: lensName must be a non-empty string');
602
614
  }
603
615
 
@@ -617,7 +629,7 @@ class HoloSphereBase extends HoloSphereCore {
617
629
 
618
630
  // Check delete cache first - if deleted, return null immediately
619
631
  if (this._deleteCache.has(path)) {
620
- this._log('INFO', '🗑️ CACHE READ: Deleted item', {
632
+ this._log('DEBUG', '🗑️ CACHE READ: Deleted item', {
621
633
  path,
622
634
  source: 'delete-cache',
623
635
  deleteCacheSize: this._deleteCache.size
@@ -628,7 +640,7 @@ class HoloSphereBase extends HoloSphereCore {
628
640
  const cached = this._writeCache.get(path);
629
641
  if (cached) {
630
642
  const cacheAge = Date.now() - cached.timestamp;
631
- this._log('INFO', '⚡ CACHE HIT: Write cache', {
643
+ this._log('DEBUG', '⚡ CACHE HIT: Write cache', {
632
644
  path,
633
645
  source: 'write-cache',
634
646
  cacheAge: `${cacheAge}ms`,
@@ -638,7 +650,7 @@ class HoloSphereBase extends HoloSphereCore {
638
650
  } else {
639
651
  this._log('DEBUG', '📖 CACHE MISS: Reading from storage', { path });
640
652
  result = await storage.read(this.client, path);
641
- this._log('INFO', '💾 STORAGE READ', {
653
+ this._log('DEBUG', '💾 STORAGE READ', {
642
654
  path,
643
655
  source: 'storage',
644
656
  found: !!result,
@@ -782,7 +794,7 @@ class HoloSphereBase extends HoloSphereCore {
782
794
  // OPTIMISTIC UPDATE: Store in write cache and clear from delete cache
783
795
  this._writeCache.set(path, { data: { ...mergedData }, timestamp: Date.now() });
784
796
  this._deleteCache.delete(path);
785
- this._log('INFO', '✏️ CACHE UPDATE', {
797
+ this._log('DEBUG', '✏️ CACHE UPDATE', {
786
798
  path,
787
799
  dataId,
788
800
  updatedFields: Object.keys(updates),
@@ -808,7 +820,7 @@ class HoloSphereBase extends HoloSphereCore {
808
820
  */
809
821
  async _syncUpdateToRelay(holonId, lensName, dataId, mergedData, existingData, path) {
810
822
  const startTime = Date.now();
811
- this._log('INFO', '🔄 UPDATE SYNC START', {
823
+ this._log('DEBUG', '🔄 UPDATE SYNC START', {
812
824
  path,
813
825
  dataId,
814
826
  relays: this.client?.relays?.map(r => r.url) || ['local-only']
@@ -822,7 +834,7 @@ class HoloSphereBase extends HoloSphereCore {
822
834
  if (!this._metrics.totalWriteTime) this._metrics.totalWriteTime = 0;
823
835
  this._metrics.totalWriteTime += duration;
824
836
 
825
- this._log('INFO', '✅ UPDATE SYNC SUCCESS', {
837
+ this._log('DEBUG', '✅ UPDATE SYNC SUCCESS', {
826
838
  path,
827
839
  dataId,
828
840
  duration: `${duration}ms`,
@@ -865,13 +877,18 @@ class HoloSphereBase extends HoloSphereCore {
865
877
  * @throws {AuthorizationError} If not owner and no valid capability token
866
878
  */
867
879
  async delete(holonId, lensName, dataId, options = {}) {
868
- if (!holonId || typeof holonId !== 'string') {
880
+ // Auto-convert to strings for convenience
881
+ if (holonId != null) holonId = String(holonId);
882
+ if (lensName != null) lensName = String(lensName);
883
+ if (dataId != null) dataId = String(dataId);
884
+
885
+ if (!holonId) {
869
886
  throw new ValidationError('ValidationError: holonId must be a non-empty string');
870
887
  }
871
- if (!lensName || typeof lensName !== 'string') {
888
+ if (!lensName) {
872
889
  throw new ValidationError('ValidationError: lensName must be a non-empty string');
873
890
  }
874
- if (!dataId || typeof dataId !== 'string') {
891
+ if (!dataId) {
875
892
  throw new ValidationError('ValidationError: dataId must be a non-empty string');
876
893
  }
877
894
 
@@ -920,7 +937,7 @@ class HoloSphereBase extends HoloSphereCore {
920
937
  // OPTIMISTIC DELETE: Remove from write cache and add to delete cache
921
938
  this._writeCache.delete(path);
922
939
  this._deleteCache.add(path);
923
- this._log('INFO', '🗑️ CACHE DELETE', {
940
+ this._log('DEBUG', '🗑️ CACHE DELETE', {
924
941
  path,
925
942
  dataId,
926
943
  deleteCacheSize: this._deleteCache.size,
@@ -935,14 +952,14 @@ class HoloSphereBase extends HoloSphereCore {
935
952
 
936
953
  // Delete from storage (background unless blocking)
937
954
  const startTime = Date.now();
938
- this._log('INFO', '🔄 DELETE SYNC START', { path, dataId });
955
+ this._log('DEBUG', '🔄 DELETE SYNC START', { path, dataId });
939
956
 
940
957
  const deletePromise = storage.deleteData(this.client, path).then(() => {
941
958
  const duration = Date.now() - startTime;
942
959
  this._metrics.deletes++;
943
960
  // Clear from delete cache after successful sync
944
961
  this._deleteCache.delete(path);
945
- this._log('INFO', '✅ DELETE SYNC SUCCESS', {
962
+ this._log('DEBUG', '✅ DELETE SYNC SUCCESS', {
946
963
  path,
947
964
  dataId,
948
965
  duration: `${duration}ms`,
@@ -983,6 +1000,10 @@ class HoloSphereBase extends HoloSphereCore {
983
1000
  * @returns {Promise<boolean>} True if write succeeded
984
1001
  */
985
1002
  async writeGlobal(table, data) {
1003
+ // Auto-convert to strings for convenience
1004
+ if (table != null) table = String(table);
1005
+ if (data?.id != null) data.id = String(data.id);
1006
+
986
1007
  return globalTables.writeGlobal(this.client, this.config.appName, table, data);
987
1008
  }
988
1009
 
@@ -994,6 +1015,10 @@ class HoloSphereBase extends HoloSphereCore {
994
1015
  * @returns {Promise<Object|Array|null>} Data object, array of objects, or null
995
1016
  */
996
1017
  async readGlobal(table, key = null) {
1018
+ // Auto-convert to strings for convenience
1019
+ if (table != null) table = String(table);
1020
+ if (key != null) key = String(key);
1021
+
997
1022
  return globalTables.readGlobal(this.client, this.config.appName, table, key);
998
1023
  }
999
1024
 
@@ -1006,6 +1031,10 @@ class HoloSphereBase extends HoloSphereCore {
1006
1031
  * @returns {Promise<boolean>} True if update succeeded
1007
1032
  */
1008
1033
  async updateGlobal(table, key, updates) {
1034
+ // Auto-convert to strings for convenience
1035
+ if (table != null) table = String(table);
1036
+ if (key != null) key = String(key);
1037
+
1009
1038
  return globalTables.updateGlobal(this.client, this.config.appName, table, key, updates);
1010
1039
  }
1011
1040
 
@@ -1017,6 +1046,10 @@ class HoloSphereBase extends HoloSphereCore {
1017
1046
  * @returns {Promise<boolean>} True if deletion succeeded
1018
1047
  */
1019
1048
  async deleteGlobal(table, key) {
1049
+ // Auto-convert to strings for convenience
1050
+ if (table != null) table = String(table);
1051
+ if (key != null) key = String(key);
1052
+
1020
1053
  return globalTables.deleteGlobal(this.client, this.config.appName, table, key);
1021
1054
  }
1022
1055
 
@@ -1027,6 +1060,9 @@ class HoloSphereBase extends HoloSphereCore {
1027
1060
  * @returns {Promise<Array>} Array of all data objects in the table
1028
1061
  */
1029
1062
  async getAllGlobal(table) {
1063
+ // Auto-convert to strings for convenience
1064
+ if (table != null) table = String(table);
1065
+
1030
1066
  return globalTables.getAllGlobal(this.client, this.config.appName, table);
1031
1067
  }
1032
1068
 
@@ -1037,6 +1073,9 @@ class HoloSphereBase extends HoloSphereCore {
1037
1073
  * @returns {Promise<boolean>} True if deletion succeeded
1038
1074
  */
1039
1075
  async deleteAllGlobal(table) {
1076
+ // Auto-convert to strings for convenience
1077
+ if (table != null) table = String(table);
1078
+
1040
1079
  return globalTables.deleteAllGlobal(this.client, this.config.appName, table);
1041
1080
  }
1042
1081
 
@@ -1061,6 +1100,10 @@ class HoloSphereBase extends HoloSphereCore {
1061
1100
  * @returns {Promise<boolean>} True if deletion succeeded
1062
1101
  */
1063
1102
  async deleteAll(holonId, lensName) {
1103
+ // Auto-convert to strings for convenience
1104
+ if (holonId != null) holonId = String(holonId);
1105
+ if (lensName != null) lensName = String(lensName);
1106
+
1064
1107
  const path = storage.buildPath(this.config.appName, holonId, lensName);
1065
1108
  return storage.deleteAll(this.client, path);
1066
1109
  }