holosphere 2.0.0-alpha7 → 2.0.0-alpha9

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 (327) hide show
  1. package/CHANGELOG.md +446 -0
  2. package/FEATURES.md +431 -0
  3. package/LICENSE +29 -166
  4. package/LICENSE-AGPL.md +180 -0
  5. package/dist/cdn/holosphere.min.js +55 -0
  6. package/dist/cdn/holosphere.min.js.map +1 -0
  7. package/dist/cjs/holosphere.cjs +1 -1
  8. package/dist/esm/holosphere.js +1 -1
  9. package/dist/{index-C-IlLYlk.cjs → index-DDGt_V9o.cjs} +2 -2
  10. package/dist/{index-C-IlLYlk.cjs.map → index-DDGt_V9o.cjs.map} +1 -1
  11. package/dist/{index-d6f4RJBM.js → index-DJXftyvB.js} +2253 -387
  12. package/dist/index-DJXftyvB.js.map +1 -0
  13. package/dist/index-DMbdcMtK.cjs +18 -0
  14. package/dist/index-DMbdcMtK.cjs.map +1 -0
  15. package/dist/{index-jmTHEbR2.js → index-DeZ1xz_s.js} +2 -2
  16. package/dist/{index-jmTHEbR2.js.map → index-DeZ1xz_s.js.map} +1 -1
  17. package/dist/{indexeddb-storage-D8kOl0oK.js → indexeddb-storage-BFt6hMeF.js} +48 -4
  18. package/dist/indexeddb-storage-BFt6hMeF.js.map +1 -0
  19. package/dist/{indexeddb-storage-a8GipaDr.cjs → indexeddb-storage-BK5tv4Sh.cjs} +2 -2
  20. package/dist/indexeddb-storage-BK5tv4Sh.cjs.map +1 -0
  21. package/dist/{memory-storage-DBQK622V.js → memory-storage-C9HuoL2E.js} +44 -4
  22. package/dist/memory-storage-C9HuoL2E.js.map +1 -0
  23. package/dist/{memory-storage-gfRovk2O.cjs → memory-storage-Dao7jfYG.cjs} +2 -2
  24. package/dist/memory-storage-Dao7jfYG.cjs.map +1 -0
  25. package/dist/{secp256k1-BCAPF45D.cjs → secp256k1-BbKzbLtD.cjs} +2 -2
  26. package/dist/{secp256k1-BCAPF45D.cjs.map → secp256k1-BbKzbLtD.cjs.map} +1 -1
  27. package/dist/{secp256k1-DYm_CMqW.js → secp256k1-CreY7Pcl.js} +2 -2
  28. package/dist/{secp256k1-DYm_CMqW.js.map → secp256k1-CreY7Pcl.js.map} +1 -1
  29. package/docs/api/ai_aggregation.js.html +333 -0
  30. package/docs/api/ai_breakdown.js.html +524 -0
  31. package/docs/api/ai_classifier.js.html +231 -0
  32. package/docs/api/ai_council.js.html +246 -0
  33. package/docs/api/ai_embeddings.js.html +304 -0
  34. package/docs/api/ai_federation-ai.js.html +338 -0
  35. package/docs/api/ai_h3-ai.js.html +970 -0
  36. package/docs/api/ai_index.js.html +124 -0
  37. package/docs/api/ai_json-ops.js.html +241 -0
  38. package/docs/api/ai_llm-service.js.html +239 -0
  39. package/docs/api/ai_nl-query.js.html +236 -0
  40. package/docs/api/ai_relationships.js.html +367 -0
  41. package/docs/api/ai_schema-extractor.js.html +235 -0
  42. package/docs/api/ai_spatial.js.html +307 -0
  43. package/docs/api/ai_tts.js.html +214 -0
  44. package/docs/api/content_social-protocols.js.html +180 -0
  45. package/docs/api/core_holosphere.js.html +757 -0
  46. package/docs/api/crypto_nostr-utils.js.html +306 -0
  47. package/docs/api/crypto_secp256k1.js.html +267 -0
  48. package/docs/api/data/search.json +1 -0
  49. package/docs/api/federation_discovery.js.html +337 -0
  50. package/docs/api/federation_handshake.js.html +478 -0
  51. package/docs/api/federation_hologram.js.html +1053 -0
  52. package/docs/api/federation_registry.js.html +389 -0
  53. package/docs/api/fonts/Inconsolata-Regular.ttf +0 -0
  54. package/docs/api/fonts/OpenSans-Regular.ttf +0 -0
  55. package/docs/api/fonts/WorkSans-Bold.ttf +0 -0
  56. package/docs/api/global.html +3 -0
  57. package/docs/api/hierarchical_upcast.js.html +128 -0
  58. package/docs/api/index.html +265 -0
  59. package/docs/api/index.js.html +1868 -0
  60. package/docs/api/lib_ai-methods.js.html +660 -0
  61. package/docs/api/lib_contract-methods.js.html +445 -0
  62. package/docs/api/lib_errors.js.html +56 -0
  63. package/docs/api/lib_federation-methods.js.html +348 -0
  64. package/docs/api/lib_index.js.html +33 -0
  65. package/docs/api/module-ai.html +5 -0
  66. package/docs/api/module-ai_aggregation-SmartAggregation.html +6 -0
  67. package/docs/api/module-ai_aggregation.SmartAggregation.html +3 -0
  68. package/docs/api/module-ai_aggregation.html +3 -0
  69. package/docs/api/module-ai_breakdown-TaskBreakdown.html +5 -0
  70. package/docs/api/module-ai_breakdown.TaskBreakdown.html +3 -0
  71. package/docs/api/module-ai_breakdown.html +3 -0
  72. package/docs/api/module-ai_classifier-Classifier.html +6 -0
  73. package/docs/api/module-ai_classifier.Classifier.html +3 -0
  74. package/docs/api/module-ai_classifier.html +3 -0
  75. package/docs/api/module-ai_council-Council.html +6 -0
  76. package/docs/api/module-ai_council.Council.html +3 -0
  77. package/docs/api/module-ai_council.html +3 -0
  78. package/docs/api/module-ai_embeddings-Embeddings.html +5 -0
  79. package/docs/api/module-ai_embeddings.Embeddings.html +3 -0
  80. package/docs/api/module-ai_embeddings.html +3 -0
  81. package/docs/api/module-ai_federation-ai-FederationAdvisor.html +6 -0
  82. package/docs/api/module-ai_federation-ai.FederationAdvisor.html +3 -0
  83. package/docs/api/module-ai_federation-ai.html +3 -0
  84. package/docs/api/module-ai_h3-ai-H3AI.html +6 -0
  85. package/docs/api/module-ai_h3-ai.H3AI.html +3 -0
  86. package/docs/api/module-ai_h3-ai.html +3 -0
  87. package/docs/api/module-ai_json-ops-JSONOps.html +5 -0
  88. package/docs/api/module-ai_json-ops.JSONOps.html +3 -0
  89. package/docs/api/module-ai_json-ops.html +3 -0
  90. package/docs/api/module-ai_llm-service-LLMService.html +5 -0
  91. package/docs/api/module-ai_llm-service.LLMService.html +3 -0
  92. package/docs/api/module-ai_llm-service.html +3 -0
  93. package/docs/api/module-ai_nl-query-NLQuery.html +5 -0
  94. package/docs/api/module-ai_nl-query.NLQuery.html +3 -0
  95. package/docs/api/module-ai_nl-query.html +3 -0
  96. package/docs/api/module-ai_relationships-RelationshipDiscovery.html +6 -0
  97. package/docs/api/module-ai_relationships.RelationshipDiscovery.html +3 -0
  98. package/docs/api/module-ai_relationships.html +3 -0
  99. package/docs/api/module-ai_schema-extractor-SchemaExtractor.html +5 -0
  100. package/docs/api/module-ai_schema-extractor.SchemaExtractor.html +3 -0
  101. package/docs/api/module-ai_schema-extractor.html +3 -0
  102. package/docs/api/module-ai_spatial-SpatialAnalysis.html +6 -0
  103. package/docs/api/module-ai_spatial.SpatialAnalysis.html +3 -0
  104. package/docs/api/module-ai_spatial.html +3 -0
  105. package/docs/api/module-ai_tts-TTS.html +5 -0
  106. package/docs/api/module-ai_tts.TTS.html +3 -0
  107. package/docs/api/module-ai_tts.html +3 -0
  108. package/docs/api/module-content_social-protocols.html +3 -0
  109. package/docs/api/module-core_holosphere-HoloSphere.html +6 -0
  110. package/docs/api/module-core_holosphere.HoloSphere.html +3 -0
  111. package/docs/api/module-core_holosphere.html +3 -0
  112. package/docs/api/module-crypto_nostr-utils.html +3 -0
  113. package/docs/api/module-crypto_secp256k1.html +3 -0
  114. package/docs/api/module-federation_hologram.html +3 -0
  115. package/docs/api/module-hierarchical_upcast.html +3 -0
  116. package/docs/api/module-holosphere-HoloSphereBase.html +3 -0
  117. package/docs/api/module-holosphere.html +3 -0
  118. package/docs/api/module-lib_ai-methods.html +3 -0
  119. package/docs/api/module-lib_contract-methods.html +3 -0
  120. package/docs/api/module-lib_errors-AuthorizationError.html +3 -0
  121. package/docs/api/module-lib_errors-ValidationError.html +3 -0
  122. package/docs/api/module-lib_errors.AuthorizationError.html +3 -0
  123. package/docs/api/module-lib_errors.ValidationError.html +3 -0
  124. package/docs/api/module-lib_errors.html +3 -0
  125. package/docs/api/module-lib_federation-methods.html +3 -0
  126. package/docs/api/module-lib_index.html +3 -0
  127. package/docs/api/module-schema_validator-ValidationError.html +3 -0
  128. package/docs/api/module-schema_validator.ValidationError.html +3 -0
  129. package/docs/api/module-schema_validator.html +3 -0
  130. package/docs/api/module-spatial_h3-operations.html +4 -0
  131. package/docs/api/module-storage_backend-factory.BackendFactory.html +3 -0
  132. package/docs/api/module-storage_backend-factory.html +3 -0
  133. package/docs/api/module-storage_backend-interface-StorageBackend.html +3 -0
  134. package/docs/api/module-storage_backend-interface.StorageBackend.html +3 -0
  135. package/docs/api/module-storage_backend-interface.html +3 -0
  136. package/docs/api/module-storage_backends_activitypub-backend-ActivityPubBackend.html +7 -0
  137. package/docs/api/module-storage_backends_activitypub-backend.ActivityPubBackend.html +3 -0
  138. package/docs/api/module-storage_backends_activitypub-backend.html +3 -0
  139. package/docs/api/module-storage_backends_activitypub_server-ActivityPubServer.html +8 -0
  140. package/docs/api/module-storage_backends_activitypub_server.ActivityPubServer.html +3 -0
  141. package/docs/api/module-storage_backends_activitypub_server.html +3 -0
  142. package/docs/api/module-storage_backends_gundb-backend-GunDBBackend.html +7 -0
  143. package/docs/api/module-storage_backends_gundb-backend.GunDBBackend.html +3 -0
  144. package/docs/api/module-storage_backends_gundb-backend.html +3 -0
  145. package/docs/api/module-storage_backends_nostr-backend-NostrBackend.html +8 -0
  146. package/docs/api/module-storage_backends_nostr-backend.NostrBackend.html +3 -0
  147. package/docs/api/module-storage_backends_nostr-backend.html +3 -0
  148. package/docs/api/module-storage_filesystem-storage-FileSystemStorage.html +5 -0
  149. package/docs/api/module-storage_filesystem-storage-browser-FileSystemStorage.html +3 -0
  150. package/docs/api/module-storage_filesystem-storage-browser.FileSystemStorage.html +3 -0
  151. package/docs/api/module-storage_filesystem-storage-browser.html +3 -0
  152. package/docs/api/module-storage_filesystem-storage.FileSystemStorage.html +3 -0
  153. package/docs/api/module-storage_filesystem-storage.html +3 -0
  154. package/docs/api/module-storage_global-tables.html +3 -0
  155. package/docs/api/module-storage_gun-async.html +3 -0
  156. package/docs/api/module-storage_gun-auth-GunAuth.html +5 -0
  157. package/docs/api/module-storage_gun-auth.GunAuth.html +3 -0
  158. package/docs/api/module-storage_gun-auth.html +3 -0
  159. package/docs/api/module-storage_gun-federation.html +3 -0
  160. package/docs/api/module-storage_gun-references-GunReferenceHandler.html +5 -0
  161. package/docs/api/module-storage_gun-references.GunReferenceHandler.html +3 -0
  162. package/docs/api/module-storage_gun-references.html +3 -0
  163. package/docs/api/module-storage_gun-schema-GunSchemaValidator.html +5 -0
  164. package/docs/api/module-storage_gun-schema.GunSchemaValidator.html +3 -0
  165. package/docs/api/module-storage_gun-schema.html +3 -0
  166. package/docs/api/module-storage_gun-wrapper.html +11 -0
  167. package/docs/api/module-storage_indexeddb-storage-IndexedDBStorage.html +5 -0
  168. package/docs/api/module-storage_indexeddb-storage.IndexedDBStorage.html +3 -0
  169. package/docs/api/module-storage_indexeddb-storage.html +3 -0
  170. package/docs/api/module-storage_key-storage-simple.html +3 -0
  171. package/docs/api/module-storage_key-storage.html +4 -0
  172. package/docs/api/module-storage_memory-storage-MemoryStorage.html +5 -0
  173. package/docs/api/module-storage_memory-storage.MemoryStorage.html +3 -0
  174. package/docs/api/module-storage_memory-storage.html +3 -0
  175. package/docs/api/module-storage_migration-MigrationTool.html +6 -0
  176. package/docs/api/module-storage_migration.MigrationTool.html +3 -0
  177. package/docs/api/module-storage_migration.html +3 -0
  178. package/docs/api/module-storage_nostr-async.html +18 -0
  179. package/docs/api/module-storage_nostr-client-LRUCache.html +3 -0
  180. package/docs/api/module-storage_nostr-client-NostrClient.html +7 -0
  181. package/docs/api/module-storage_nostr-client.NostrClient.html +15 -0
  182. package/docs/api/module-storage_nostr-client.html +6 -0
  183. package/docs/api/module-storage_nostr-wrapper.html +3 -0
  184. package/docs/api/module-storage_outbox-queue-OutboxQueue.html +4 -0
  185. package/docs/api/module-storage_outbox-queue.OutboxQueue.html +3 -0
  186. package/docs/api/module-storage_outbox-queue.html +3 -0
  187. package/docs/api/module-storage_persistent-storage-PersistentStorage.html +3 -0
  188. package/docs/api/module-storage_persistent-storage.html +4 -0
  189. package/docs/api/module-storage_sync-service-SyncService.html +5 -0
  190. package/docs/api/module-storage_sync-service.SyncService.html +3 -0
  191. package/docs/api/module-storage_sync-service.html +3 -0
  192. package/docs/api/module-storage_unified-storage.html +3 -0
  193. package/docs/api/module-subscriptions_manager.SubscriptionRegistry.html +3 -0
  194. package/docs/api/module-subscriptions_manager.html +3 -0
  195. package/docs/api/schema_validator.js.html +113 -0
  196. package/docs/api/scripts/core.js +726 -0
  197. package/docs/api/scripts/core.min.js +23 -0
  198. package/docs/api/scripts/resize.js +90 -0
  199. package/docs/api/scripts/search.js +265 -0
  200. package/docs/api/scripts/search.min.js +6 -0
  201. package/docs/api/scripts/third-party/Apache-License-2.0.txt +202 -0
  202. package/docs/api/scripts/third-party/fuse.js +9 -0
  203. package/docs/api/scripts/third-party/hljs-line-num-original.js +369 -0
  204. package/docs/api/scripts/third-party/hljs-line-num.js +1 -0
  205. package/docs/api/scripts/third-party/hljs-original.js +5171 -0
  206. package/docs/api/scripts/third-party/hljs.js +1 -0
  207. package/docs/api/scripts/third-party/popper.js +5 -0
  208. package/docs/api/scripts/third-party/tippy.js +1 -0
  209. package/docs/api/scripts/third-party/tocbot.js +672 -0
  210. package/docs/api/scripts/third-party/tocbot.min.js +1 -0
  211. package/docs/api/spatial_h3-operations.js.html +129 -0
  212. package/docs/api/storage_backend-factory.js.html +133 -0
  213. package/docs/api/storage_backend-interface.js.html +164 -0
  214. package/docs/api/storage_backends_activitypub-backend.js.html +298 -0
  215. package/docs/api/storage_backends_activitypub_server.js.html +678 -0
  216. package/docs/api/storage_backends_gundb-backend.js.html +878 -0
  217. package/docs/api/storage_backends_nostr-backend.js.html +254 -0
  218. package/docs/api/storage_filesystem-storage-browser.js.html +83 -0
  219. package/docs/api/storage_filesystem-storage.js.html +207 -0
  220. package/docs/api/storage_global-tables.js.html +116 -0
  221. package/docs/api/storage_gun-async.js.html +344 -0
  222. package/docs/api/storage_gun-auth.js.html +376 -0
  223. package/docs/api/storage_gun-federation.js.html +788 -0
  224. package/docs/api/storage_gun-references.js.html +212 -0
  225. package/docs/api/storage_gun-schema.js.html +309 -0
  226. package/docs/api/storage_gun-wrapper.js.html +645 -0
  227. package/docs/api/storage_indexeddb-storage.js.html +224 -0
  228. package/docs/api/storage_key-storage-simple.js.html +102 -0
  229. package/docs/api/storage_key-storage.js.html +171 -0
  230. package/docs/api/storage_memory-storage.js.html +128 -0
  231. package/docs/api/storage_migration.js.html +354 -0
  232. package/docs/api/storage_nostr-async.js.html +1076 -0
  233. package/docs/api/storage_nostr-client.js.html +1598 -0
  234. package/docs/api/storage_nostr-wrapper.js.html +218 -0
  235. package/docs/api/storage_outbox-queue.js.html +248 -0
  236. package/docs/api/storage_persistent-storage.js.html +160 -0
  237. package/docs/api/storage_sync-service.js.html +201 -0
  238. package/docs/api/storage_unified-storage.js.html +157 -0
  239. package/docs/api/styles/clean-jsdoc-theme-base.css +1159 -0
  240. package/docs/api/styles/clean-jsdoc-theme-dark.css +412 -0
  241. package/docs/api/styles/clean-jsdoc-theme-light.css +482 -0
  242. package/docs/api/styles/clean-jsdoc-theme-scrollbar.css +30 -0
  243. package/docs/api/styles/clean-jsdoc-theme-without-scrollbar.min.css +1 -0
  244. package/docs/api/styles/clean-jsdoc-theme.min.css +1 -0
  245. package/docs/api/subscriptions_manager.js.html +162 -0
  246. package/examples/holosphere-widget.js +1242 -0
  247. package/examples/widget-demo.html +274 -0
  248. package/examples/widget.html +703 -0
  249. package/jsdoc.json +26 -0
  250. package/package.json +16 -3
  251. package/src/ai/aggregation.js +13 -2
  252. package/src/ai/breakdown.js +12 -2
  253. package/src/ai/classifier.js +14 -3
  254. package/src/ai/council.js +22 -7
  255. package/src/ai/embeddings.js +37 -15
  256. package/src/ai/federation-ai.js +13 -2
  257. package/src/ai/h3-ai.js +14 -2
  258. package/src/ai/index.js +16 -7
  259. package/src/ai/json-ops.js +18 -5
  260. package/src/ai/llm-service.js +62 -31
  261. package/src/ai/nl-query.js +12 -2
  262. package/src/ai/relationships.js +13 -2
  263. package/src/ai/schema-extractor.js +24 -10
  264. package/src/ai/spatial.js +13 -2
  265. package/src/ai/tts.js +25 -8
  266. package/src/cdn-entry.js +22 -0
  267. package/src/content/social-protocols.js +34 -25
  268. package/src/contracts/chain-manager.js +68 -40
  269. package/src/contracts/deployer.js +70 -42
  270. package/src/contracts/event-listener.js +61 -29
  271. package/src/contracts/holon-contracts.js +46 -31
  272. package/src/contracts/index.js +5 -6
  273. package/src/contracts/networks.js +19 -14
  274. package/src/contracts/operations.js +58 -41
  275. package/src/contracts/queries.js +70 -21
  276. package/src/core/holosphere.js +37 -8
  277. package/src/crypto/nostr-utils.js +105 -65
  278. package/src/crypto/secp256k1.js +7 -2
  279. package/src/federation/handshake.js +23 -11
  280. package/src/federation/hologram.js +9 -1
  281. package/src/hierarchical/upcast.js +34 -20
  282. package/src/index.js +671 -7
  283. package/src/lib/ai-methods.js +352 -3
  284. package/src/lib/contract-methods.js +152 -3
  285. package/src/lib/errors.js +31 -1
  286. package/src/lib/federation-methods.js +110 -3
  287. package/src/lib/index.js +9 -5
  288. package/src/schema/validator.js +22 -3
  289. package/src/spatial/h3-operations.js +17 -1
  290. package/src/storage/backend-factory.js +7 -2
  291. package/src/storage/backend-interface.js +21 -2
  292. package/src/storage/backends/activitypub/server.js +25 -3
  293. package/src/storage/backends/activitypub-backend.js +25 -2
  294. package/src/storage/backends/gundb-backend.js +322 -11
  295. package/src/storage/backends/nostr-backend.js +116 -1
  296. package/src/storage/filesystem-storage-browser.js +42 -2
  297. package/src/storage/filesystem-storage.js +72 -5
  298. package/src/storage/global-tables.js +7 -2
  299. package/src/storage/gun-async.js +20 -11
  300. package/src/storage/gun-auth.js +15 -4
  301. package/src/storage/gun-federation.js +14 -5
  302. package/src/storage/gun-references.js +16 -5
  303. package/src/storage/gun-schema.js +25 -10
  304. package/src/storage/gun-wrapper.js +160 -49
  305. package/src/storage/indexeddb-storage.js +65 -4
  306. package/src/storage/key-storage-simple.js +32 -9
  307. package/src/storage/key-storage.js +45 -13
  308. package/src/storage/memory-storage.js +65 -4
  309. package/src/storage/migration.js +20 -7
  310. package/src/storage/nostr-async.js +195 -90
  311. package/src/storage/nostr-client.js +173 -49
  312. package/src/storage/nostr-wrapper.js +6 -2
  313. package/src/storage/outbox-queue.js +55 -18
  314. package/src/storage/persistent-storage.js +56 -13
  315. package/src/storage/sync-service.js +51 -17
  316. package/src/storage/unified-storage.js +38 -3
  317. package/src/subscriptions/manager.js +33 -16
  318. package/vite.config.cdn.js +60 -0
  319. package/dist/index-Bvwyvd0T.cjs +0 -5
  320. package/dist/index-Bvwyvd0T.cjs.map +0 -1
  321. package/dist/index-d6f4RJBM.js.map +0 -1
  322. package/dist/indexeddb-storage-D8kOl0oK.js.map +0 -1
  323. package/dist/indexeddb-storage-a8GipaDr.cjs.map +0 -1
  324. package/dist/memory-storage-DBQK622V.js.map +0 -1
  325. package/dist/memory-storage-gfRovk2O.cjs.map +0 -1
  326. /package/{cleanup-test-data.js → scripts/cleanup-test-data.js} +0 -0
  327. /package/{test-ai-real-api.js → scripts/test-ai-real-api.js} +0 -0
package/src/index.js CHANGED
@@ -1,6 +1,14 @@
1
1
  /**
2
- * HoloSphere - Holonic Geospatial Communication Infrastructure
3
- * Public API
2
+ * @fileoverview HoloSphere - Holonic Geospatial Communication Infrastructure
3
+ *
4
+ * This is the main entry point for the HoloSphere library, providing a comprehensive
5
+ * distributed P2P geospatial communication system. It combines H3 hexagonal indexing
6
+ * for spatial organization, Nostr protocol for distributed storage, smart contracts
7
+ * for fund distribution, and AI services for intelligent data processing.
8
+ *
9
+ * @module holosphere
10
+ * @author HoloSphere Team
11
+ * @license MIT
4
12
  */
5
13
 
6
14
  import { HoloSphere as HoloSphereCore } from './core/holosphere.js';
@@ -51,16 +59,36 @@ import { withFederationMethods } from './lib/federation-methods.js';
51
59
  import { AuthorizationError } from './lib/errors.js';
52
60
 
53
61
  /**
54
- * Base HoloSphere class with core data operations
62
+ * Base HoloSphere class with core data operations.
63
+ * Extends HoloSphereCore with schema validation, caching, subscriptions, and AI capabilities.
64
+ *
65
+ * @class HoloSphereBase
66
+ * @extends HoloSphereCore
55
67
  */
56
68
  class HoloSphereBase extends HoloSphereCore {
69
+ /**
70
+ * Creates a new HoloSphereBase instance.
71
+ *
72
+ * @param {Object} config - Configuration options
73
+ * @param {string} config.appName - Application namespace for data isolation
74
+ * @param {string} [config.backend='nostr'] - Storage backend type ('nostr', 'gundb', 'activitypub')
75
+ * @param {string[]} [config.relays] - Nostr relay URLs for distributed storage
76
+ * @param {string} [config.openaiKey] - OpenAI API key for AI services
77
+ * @param {Object} [config.aiOptions] - AI service configuration
78
+ * @param {string} [config.aiOptions.model] - OpenAI model to use
79
+ * @param {number} [config.aiOptions.temperature] - Temperature for AI responses
80
+ */
57
81
  constructor(config) {
58
82
  super(config);
83
+ /** @type {Map<string, {schema: Object, strict: boolean, timestamp: number}>} */
59
84
  this.schemas = new Map();
85
+ /** @type {Map<string, any>} */
60
86
  this._cache = new Map();
87
+ /** @type {subscriptions.SubscriptionRegistry} */
61
88
  this.subscriptionRegistry = new subscriptions.SubscriptionRegistry();
62
89
 
63
90
  // Initialize AI services if openaiKey is provided or OPENAI_API_KEY env var is set
91
+ /** @type {Object|null} */
64
92
  this._ai = null;
65
93
  const openaiKey = config.openaiKey || this._getEnv('OPENAI_API_KEY');
66
94
  if (openaiKey) {
@@ -73,9 +101,17 @@ class HoloSphereBase extends HoloSphereCore {
73
101
  }
74
102
 
75
103
  // Contracts module (lazy initialized)
104
+ /** @type {Object|null} */
76
105
  this._contracts = null;
77
106
  }
78
107
 
108
+ /**
109
+ * Gets an environment variable value (Node.js only).
110
+ *
111
+ * @private
112
+ * @param {string} name - Environment variable name
113
+ * @returns {string|undefined} Environment variable value or undefined
114
+ */
79
115
  _getEnv(name) {
80
116
  if (typeof process !== 'undefined' && process.env) {
81
117
  return process.env[name];
@@ -83,12 +119,28 @@ class HoloSphereBase extends HoloSphereCore {
83
119
  return undefined;
84
120
  }
85
121
 
122
+ /**
123
+ * Parses a string value to a float.
124
+ *
125
+ * @private
126
+ * @param {string|undefined|null} value - Value to parse
127
+ * @returns {number|undefined} Parsed float or undefined if invalid
128
+ */
86
129
  _parseFloat(value) {
87
130
  if (value === undefined || value === null) return undefined;
88
131
  const parsed = parseFloat(value);
89
132
  return isNaN(parsed) ? undefined : parsed;
90
133
  }
91
134
 
135
+ /**
136
+ * Initializes AI services with the provided API key.
137
+ *
138
+ * @private
139
+ * @param {string} apiKey - OpenAI API key
140
+ * @param {Object} [options={}] - AI configuration options
141
+ * @param {string} [options.model] - OpenAI model to use
142
+ * @param {number} [options.temperature] - Temperature for AI responses
143
+ */
92
144
  _initializeAI(apiKey, options = {}) {
93
145
  const llmOptions = {
94
146
  ...options.llm,
@@ -119,33 +171,87 @@ class HoloSphereBase extends HoloSphereCore {
119
171
  this._ai.h3ai = new H3AI(this._ai.llm, this);
120
172
  }
121
173
 
174
+ /**
175
+ * Checks if AI services are initialized.
176
+ *
177
+ * @returns {boolean} True if AI services are available
178
+ */
122
179
  hasAI() {
123
180
  return this._ai !== null;
124
181
  }
125
182
 
183
+ /**
184
+ * Gets the initialized AI services object.
185
+ *
186
+ * @returns {Object|null} AI services object containing llm, embeddings, etc., or null if not initialized
187
+ */
126
188
  getAIServices() {
127
189
  return this._ai;
128
190
  }
129
191
 
130
192
  // === Spatial Operations ===
193
+
194
+ /**
195
+ * Converts geographic coordinates to an H3 holon ID.
196
+ *
197
+ * @param {number} lat - Latitude (-90 to 90)
198
+ * @param {number} lng - Longitude (-180 to 180)
199
+ * @param {number} resolution - H3 resolution level (0-15)
200
+ * @returns {Promise<string>} H3 cell ID representing the holon
201
+ */
131
202
  async toHolon(lat, lng, resolution) {
132
203
  return spatial.toHolon(lat, lng, resolution);
133
204
  }
134
205
 
206
+ /**
207
+ * Gets all parent holons at higher resolutions.
208
+ *
209
+ * @param {string} holonId - H3 cell ID
210
+ * @param {number} [maxResolution] - Maximum resolution to traverse up to
211
+ * @returns {Promise<string[]>} Array of parent H3 cell IDs
212
+ */
135
213
  async getParents(holonId, maxResolution) {
136
214
  return spatial.getParents(holonId, maxResolution);
137
215
  }
138
216
 
217
+ /**
218
+ * Gets all child holons at the next resolution level.
219
+ *
220
+ * @param {string} holonId - H3 cell ID
221
+ * @returns {Promise<string[]>} Array of child H3 cell IDs
222
+ */
139
223
  async getChildren(holonId) {
140
224
  return spatial.getChildren(holonId);
141
225
  }
142
226
 
227
+ /**
228
+ * Validates if a string is a valid H3 cell ID.
229
+ *
230
+ * @param {string} holonId - String to validate
231
+ * @returns {boolean} True if valid H3 cell ID
232
+ */
143
233
  isValidH3(holonId) {
144
234
  return spatial.isValidH3(holonId);
145
235
  }
146
236
 
147
237
  // === Data Operations ===
148
238
 
239
+ /**
240
+ * Writes data to a specific holon and lens.
241
+ *
242
+ * @param {string} holonId - H3 cell ID for the holon
243
+ * @param {string} lensName - Name of the lens (data category)
244
+ * @param {Object} data - Data object to write (must have or will be assigned an id)
245
+ * @param {Object} [options={}] - Write options
246
+ * @param {string} [options.capabilityToken] - Capability token for authorization
247
+ * @param {boolean} [options.validate=true] - Whether to validate against schema
248
+ * @param {boolean} [options.strict] - Override schema strict mode
249
+ * @param {boolean} [options.autoPropagate=true] - Whether to propagate to federated holons
250
+ * @param {Object} [options.propagationOptions] - Options for propagation
251
+ * @returns {Promise<boolean>} True if write succeeded
252
+ * @throws {ValidationError} If holonId, lensName, or data is invalid
253
+ * @throws {AuthorizationError} If capability token is invalid
254
+ */
149
255
  async write(holonId, lensName, data, options = {}) {
150
256
  if (!holonId || typeof holonId !== 'string') {
151
257
  throw new ValidationError('ValidationError: holonId must be a non-empty string');
@@ -170,6 +276,7 @@ class HoloSphereBase extends HoloSphereCore {
170
276
  }
171
277
 
172
278
  const path = storage.buildPath(this.config.appName, holonId, lensName, data.id);
279
+ this._log('DEBUG', 'write', { holonId, lensName, dataId: data.id, path });
173
280
  const existingData = await storage.read(this.client, path);
174
281
 
175
282
  // Handle hologram writes
@@ -264,6 +371,15 @@ class HoloSphereBase extends HoloSphereCore {
264
371
  return true;
265
372
  }
266
373
 
374
+ /**
375
+ * Recursively resolves holograms (references) to their source data.
376
+ * Handles circular reference detection and local overrides.
377
+ *
378
+ * @private
379
+ * @param {Object|Array|null} data - Data that may contain holograms
380
+ * @param {Set<string>} [visited=new Set()] - Set of visited paths for circular detection
381
+ * @returns {Promise<Object|Array|null>} Resolved data with holograms replaced by source data
382
+ */
267
383
  async _resolveHolograms(data, visited = new Set()) {
268
384
  if (!data) return data;
269
385
 
@@ -286,10 +402,17 @@ class HoloSphereBase extends HoloSphereCore {
286
402
  data.target.lensName,
287
403
  data.target.dataId
288
404
  );
405
+ this._log('DEBUG', 'resolving hologram', {
406
+ hologramId: data.id,
407
+ sourcePath,
408
+ targetHolon: data.target.holonId,
409
+ targetLens: data.target.lensName,
410
+ targetDataId: data.target.dataId
411
+ });
289
412
 
290
413
  // Circular reference detection
291
414
  if (visited.has(sourcePath)) {
292
- console.warn(`Circular hologram reference detected: ${sourcePath}`);
415
+ this._log('WARN', 'Circular hologram reference detected', { sourcePath });
293
416
  return null;
294
417
  }
295
418
  visited.add(sourcePath);
@@ -301,6 +424,7 @@ class HoloSphereBase extends HoloSphereCore {
301
424
  }
302
425
 
303
426
  const sourceData = await storage.read(this.client, sourcePath, resolveOptions);
427
+ this._log('DEBUG', 'hologram source fetched', { found: !!sourceData, sourcePath });
304
428
  if (sourceData) {
305
429
  // If source is also a hologram, recursively resolve it
306
430
  let resolvedSource = sourceData;
@@ -348,6 +472,19 @@ class HoloSphereBase extends HoloSphereCore {
348
472
  return data;
349
473
  }
350
474
 
475
+ /**
476
+ * Reads data from a specific holon and lens.
477
+ *
478
+ * @param {string} holonId - H3 cell ID for the holon
479
+ * @param {string} lensName - Name of the lens (data category)
480
+ * @param {string|null} [dataId=null] - Specific data ID, or null to read all
481
+ * @param {Object} [options={}] - Read options
482
+ * @param {string} [options.capabilityToken] - Capability token for authorization
483
+ * @param {boolean} [options.resolveHolograms=true] - Whether to resolve hologram references
484
+ * @returns {Promise<Object|Array|null>} Data object, array of objects, or null if not found
485
+ * @throws {ValidationError} If holonId or lensName is invalid
486
+ * @throws {AuthorizationError} If capability token is invalid
487
+ */
351
488
  async read(holonId, lensName, dataId = null, options = {}) {
352
489
  if (!holonId || typeof holonId !== 'string') {
353
490
  throw new ValidationError('ValidationError: holonId must be a non-empty string');
@@ -369,14 +506,19 @@ class HoloSphereBase extends HoloSphereCore {
369
506
 
370
507
  if (dataId) {
371
508
  const path = storage.buildPath(this.config.appName, holonId, lensName, dataId);
509
+ this._log('DEBUG', 'read', { holonId, lensName, dataId, path });
372
510
  result = await storage.read(this.client, path);
511
+ this._log('DEBUG', 'read result', { found: !!result, isHologram: result?.hologram === true });
373
512
  } else {
374
513
  const path = storage.buildPath(this.config.appName, holonId, lensName);
514
+ this._log('DEBUG', 'readAll', { holonId, lensName, path });
375
515
  result = await storage.readAll(this.client, path);
516
+ this._log('DEBUG', 'readAll result', { count: Array.isArray(result) ? result.length : 0 });
376
517
  }
377
518
 
378
519
  const { resolveHolograms = true } = options;
379
- if (resolveHolograms) {
520
+ if (resolveHolograms && result) {
521
+ this._log('DEBUG', 'resolving holograms', { itemCount: Array.isArray(result) ? result.length : 1 });
380
522
  result = await this._resolveHolograms(result);
381
523
  }
382
524
 
@@ -388,6 +530,21 @@ class HoloSphereBase extends HoloSphereCore {
388
530
  return result;
389
531
  }
390
532
 
533
+ /**
534
+ * Updates existing data in a specific holon and lens.
535
+ *
536
+ * @param {string} holonId - H3 cell ID for the holon
537
+ * @param {string} lensName - Name of the lens (data category)
538
+ * @param {string} dataId - ID of the data to update
539
+ * @param {Object} updates - Object containing fields to update
540
+ * @param {Object} [options={}] - Update options
541
+ * @param {string} [options.capabilityToken] - Capability token for authorization
542
+ * @param {boolean} [options.validate=true] - Whether to validate against schema
543
+ * @param {boolean} [options.strict] - Override schema strict mode
544
+ * @returns {Promise<boolean>} True if update succeeded, false if data not found
545
+ * @throws {ValidationError} If holonId, lensName, dataId, or updates is invalid
546
+ * @throws {AuthorizationError} If capability token is invalid
547
+ */
391
548
  async update(holonId, lensName, dataId, updates, options = {}) {
392
549
  if (!holonId || typeof holonId !== 'string') {
393
550
  throw new ValidationError('ValidationError: holonId must be a non-empty string');
@@ -449,6 +606,18 @@ class HoloSphereBase extends HoloSphereCore {
449
606
  return true;
450
607
  }
451
608
 
609
+ /**
610
+ * Deletes data from a specific holon and lens.
611
+ *
612
+ * @param {string} holonId - H3 cell ID for the holon
613
+ * @param {string} lensName - Name of the lens (data category)
614
+ * @param {string} dataId - ID of the data to delete
615
+ * @param {Object} [options={}] - Delete options
616
+ * @param {string} [options.capabilityToken] - Capability token for authorization
617
+ * @returns {Promise<boolean>} True if deletion succeeded, false if data not found
618
+ * @throws {ValidationError} If holonId, lensName, or dataId is invalid
619
+ * @throws {AuthorizationError} If not owner and no valid capability token
620
+ */
452
621
  async delete(holonId, lensName, dataId, options = {}) {
453
622
  if (!holonId || typeof holonId !== 'string') {
454
623
  throw new ValidationError('ValidationError: holonId must be a non-empty string');
@@ -500,41 +669,108 @@ class HoloSphereBase extends HoloSphereCore {
500
669
  }
501
670
 
502
671
  // === Global Tables ===
672
+
673
+ /**
674
+ * Writes data to a global table (not holon-specific).
675
+ *
676
+ * @param {string} table - Name of the global table
677
+ * @param {Object} data - Data object to write (must have an id field)
678
+ * @returns {Promise<boolean>} True if write succeeded
679
+ */
503
680
  async writeGlobal(table, data) {
504
681
  return globalTables.writeGlobal(this.client, this.config.appName, table, data);
505
682
  }
506
683
 
684
+ /**
685
+ * Reads data from a global table.
686
+ *
687
+ * @param {string} table - Name of the global table
688
+ * @param {string|null} [key=null] - Specific key to read, or null to read all
689
+ * @returns {Promise<Object|Array|null>} Data object, array of objects, or null
690
+ */
507
691
  async readGlobal(table, key = null) {
508
692
  return globalTables.readGlobal(this.client, this.config.appName, table, key);
509
693
  }
510
694
 
695
+ /**
696
+ * Updates data in a global table.
697
+ *
698
+ * @param {string} table - Name of the global table
699
+ * @param {string} key - Key of the data to update
700
+ * @param {Object} updates - Object containing fields to update
701
+ * @returns {Promise<boolean>} True if update succeeded
702
+ */
511
703
  async updateGlobal(table, key, updates) {
512
704
  return globalTables.updateGlobal(this.client, this.config.appName, table, key, updates);
513
705
  }
514
706
 
707
+ /**
708
+ * Deletes data from a global table.
709
+ *
710
+ * @param {string} table - Name of the global table
711
+ * @param {string} key - Key of the data to delete
712
+ * @returns {Promise<boolean>} True if deletion succeeded
713
+ */
515
714
  async deleteGlobal(table, key) {
516
715
  return globalTables.deleteGlobal(this.client, this.config.appName, table, key);
517
716
  }
518
717
 
718
+ /**
719
+ * Gets all data from a global table.
720
+ *
721
+ * @param {string} table - Name of the global table
722
+ * @returns {Promise<Array>} Array of all data objects in the table
723
+ */
519
724
  async getAllGlobal(table) {
520
725
  return globalTables.getAllGlobal(this.client, this.config.appName, table);
521
726
  }
522
727
 
728
+ /**
729
+ * Deletes all data from a global table.
730
+ *
731
+ * @param {string} table - Name of the global table
732
+ * @returns {Promise<boolean>} True if deletion succeeded
733
+ */
523
734
  async deleteAllGlobal(table) {
524
735
  return globalTables.deleteAllGlobal(this.client, this.config.appName, table);
525
736
  }
526
737
 
527
738
  // === Batch Operations ===
739
+
740
+ /**
741
+ * Gets all data from a specific holon and lens.
742
+ *
743
+ * @param {string} holonId - H3 cell ID for the holon
744
+ * @param {string} lensName - Name of the lens (data category)
745
+ * @returns {Promise<Array|null>} Array of data objects or null
746
+ */
528
747
  async getAll(holonId, lensName) {
529
748
  return this.read(holonId, lensName, null);
530
749
  }
531
750
 
751
+ /**
752
+ * Deletes all data from a specific holon and lens.
753
+ *
754
+ * @param {string} holonId - H3 cell ID for the holon
755
+ * @param {string} lensName - Name of the lens (data category)
756
+ * @returns {Promise<boolean>} True if deletion succeeded
757
+ */
532
758
  async deleteAll(holonId, lensName) {
533
759
  const path = storage.buildPath(this.config.appName, holonId, lensName);
534
760
  return storage.deleteAll(this.client, path);
535
761
  }
536
762
 
537
763
  // === Schema Operations ===
764
+
765
+ /**
766
+ * Sets a JSON Schema for validating data in a specific lens.
767
+ *
768
+ * @param {string} lensName - Name of the lens to associate the schema with
769
+ * @param {Object|string} schemaInput - JSON Schema object or URI reference
770
+ * @param {boolean} [strict=false] - If true, validation will reject additional properties
771
+ * @returns {Promise<void>}
772
+ * @throws {ValidationError} If lensName is invalid or schema format is invalid
773
+ */
538
774
  async setSchema(lensName, schemaInput, strict = false) {
539
775
  if (!lensName || typeof lensName !== 'string') {
540
776
  throw new ValidationError('ValidationError: lensName must be a non-empty string');
@@ -572,17 +808,44 @@ class HoloSphereBase extends HoloSphereCore {
572
808
  this.schemas.set(lensName, { schema: schemaObj, strict, timestamp: Date.now() });
573
809
  }
574
810
 
811
+ /**
812
+ * Gets the JSON Schema for a specific lens.
813
+ *
814
+ * @param {string} lensName - Name of the lens
815
+ * @returns {Promise<Object|null>} The schema object or null if not set
816
+ */
575
817
  async getSchema(lensName) {
576
818
  const schemaObj = this.schemas.get(lensName);
577
819
  return schemaObj ? schemaObj.schema : null;
578
820
  }
579
821
 
822
+ /**
823
+ * Clears the JSON Schema for a specific lens.
824
+ *
825
+ * @param {string} lensName - Name of the lens
826
+ * @returns {Promise<void>}
827
+ */
580
828
  async clearSchema(lensName) {
581
829
  this.schemas.delete(lensName);
582
830
  // Returns undefined for contract compliance
583
831
  }
584
832
 
585
833
  // === Federation Operations ===
834
+
835
+ /**
836
+ * Sets up federation between two holons for a specific lens.
837
+ * Federation enables data sharing and synchronization between holons.
838
+ *
839
+ * @param {string} sourceHolon - Source holon H3 cell ID
840
+ * @param {string} targetHolon - Target holon H3 cell ID
841
+ * @param {string} lensName - Name of the lens to federate
842
+ * @param {Object} [options={}] - Federation options
843
+ * @param {string} [options.direction='outbound'] - Direction: 'inbound', 'outbound', or 'bidirectional'
844
+ * @param {string} [options.mode='reference'] - Mode: 'reference' (hologram) or 'copy'
845
+ * @param {Function} [options.filter] - Filter function to select which data to federate
846
+ * @returns {Promise<boolean>} True if federation was set up successfully
847
+ * @throws {Error} If trying to federate a holon with itself or invalid direction
848
+ */
586
849
  async federate(sourceHolon, targetHolon, lensName, options = {}) {
587
850
  const { direction = 'outbound', mode = 'reference', filter = null } = options;
588
851
 
@@ -616,6 +879,18 @@ class HoloSphereBase extends HoloSphereCore {
616
879
  return true;
617
880
  }
618
881
 
882
+ /**
883
+ * Propagates existing data from one holon to another.
884
+ *
885
+ * @private
886
+ * @param {string} fromHolon - Source holon H3 cell ID
887
+ * @param {string} toHolon - Target holon H3 cell ID
888
+ * @param {string} lensName - Name of the lens
889
+ * @param {Object} [options={}] - Propagation options
890
+ * @param {string} [options.mode='reference'] - Mode: 'reference' or 'copy'
891
+ * @param {Function} [options.filter] - Filter function to select data
892
+ * @returns {Promise<void>}
893
+ */
619
894
  async _propagateExistingData(fromHolon, toHolon, lensName, options = {}) {
620
895
  const { mode = 'reference', filter = null } = options;
621
896
  const existingData = await this.read(fromHolon, lensName, null, { resolveHolograms: false });
@@ -639,6 +914,15 @@ class HoloSphereBase extends HoloSphereCore {
639
914
  }
640
915
  }
641
916
 
917
+ /**
918
+ * Gets federated data from a holon, optionally resolving holograms.
919
+ *
920
+ * @param {string} holonId - H3 cell ID for the holon
921
+ * @param {string} lensName - Name of the lens
922
+ * @param {Object} [options={}] - Options
923
+ * @param {boolean} [options.resolveHolograms=true] - Whether to resolve hologram references
924
+ * @returns {Promise<Array|null>} Array of data objects or null
925
+ */
642
926
  async getFederatedData(holonId, lensName, options = {}) {
643
927
  const { resolveHolograms = true } = options;
644
928
  const path = storage.buildPath(this.config.appName, holonId, lensName);
@@ -650,6 +934,14 @@ class HoloSphereBase extends HoloSphereCore {
650
934
  return this._resolveHolograms(data);
651
935
  }
652
936
 
937
+ /**
938
+ * Removes federation between two holons for a specific lens.
939
+ *
940
+ * @param {string} sourceHolon - Source holon H3 cell ID
941
+ * @param {string} targetHolon - Target holon H3 cell ID
942
+ * @param {string} lensName - Name of the lens
943
+ * @returns {Promise<boolean>} Always returns true (idempotent operation)
944
+ */
653
945
  async unfederate(sourceHolon, targetHolon, lensName) {
654
946
  // Remove federation config for this relationship - idempotent
655
947
  const configPath = storage.buildPath(this.config.appName, sourceHolon, lensName, '_federation');
@@ -661,6 +953,15 @@ class HoloSphereBase extends HoloSphereCore {
661
953
  return true;
662
954
  }
663
955
 
956
+ /**
957
+ * Updates local override values on a hologram.
958
+ *
959
+ * @param {string} holonId - H3 cell ID where the hologram exists
960
+ * @param {string} lensName - Name of the lens
961
+ * @param {string} dataId - ID of the hologram
962
+ * @param {Object} overrides - Object containing local override values
963
+ * @returns {Promise<boolean>} True if update succeeded
964
+ */
664
965
  async updateHologramOverrides(holonId, lensName, dataId, overrides) {
665
966
  return federation.updateHologramOverrides(
666
967
  this.client,
@@ -672,6 +973,15 @@ class HoloSphereBase extends HoloSphereCore {
672
973
  );
673
974
  }
674
975
 
976
+ /**
977
+ * Creates a hologram (reference) object structure.
978
+ *
979
+ * @param {string} sourceHolon - Source holon H3 cell ID where the original data lives
980
+ * @param {string} lensName - Name of the lens
981
+ * @param {Object} data - Data object containing the id to reference
982
+ * @param {string} [targetHolon=null] - Target holon for the hologram, defaults to sourceHolon
983
+ * @returns {Object} Hologram object structure
984
+ */
675
985
  createHologram(sourceHolon, lensName, data, targetHolon = null) {
676
986
  return federation.createHologram(
677
987
  sourceHolon,
@@ -682,6 +992,14 @@ class HoloSphereBase extends HoloSphereCore {
682
992
  );
683
993
  }
684
994
 
995
+ /**
996
+ * Gets all active holograms (references) pointing to a specific data item.
997
+ *
998
+ * @param {string} holonId - H3 cell ID of the source holon
999
+ * @param {string} lensName - Name of the lens
1000
+ * @param {string} dataId - ID of the source data
1001
+ * @returns {Promise<Array>} Array of active hologram references
1002
+ */
685
1003
  async getActiveHolograms(holonId, lensName, dataId) {
686
1004
  // Read the source data and return its activeHolograms list
687
1005
  const path = storage.buildPath(this.config.appName, holonId, lensName, dataId);
@@ -692,6 +1010,15 @@ class HoloSphereBase extends HoloSphereCore {
692
1010
  return sourceData._meta.activeHolograms;
693
1011
  }
694
1012
 
1013
+ /**
1014
+ * Removes an active hologram reference from a source data item.
1015
+ *
1016
+ * @param {string} sourceHolon - Source holon H3 cell ID
1017
+ * @param {string} lensName - Name of the lens
1018
+ * @param {string} dataId - ID of the source data
1019
+ * @param {string} targetHolon - Target holon where the hologram exists
1020
+ * @returns {Promise<boolean>} True if removal succeeded
1021
+ */
695
1022
  async removeActiveHologram(sourceHolon, lensName, dataId, targetHolon) {
696
1023
  return federation.removeActiveHologram(
697
1024
  this.client,
@@ -703,6 +1030,15 @@ class HoloSphereBase extends HoloSphereCore {
703
1030
  );
704
1031
  }
705
1032
 
1033
+ /**
1034
+ * Deletes a hologram and cleans up its references.
1035
+ *
1036
+ * @param {string} holonId - H3 cell ID where the hologram exists
1037
+ * @param {string} lensName - Name of the lens
1038
+ * @param {string} dataId - ID of the hologram to delete
1039
+ * @param {Object} [options={}] - Delete options
1040
+ * @returns {Promise<boolean>} True if deletion succeeded
1041
+ */
706
1042
  async deleteHologram(holonId, lensName, dataId, options = {}) {
707
1043
  return federation.deleteHologram(
708
1044
  this.client,
@@ -714,6 +1050,17 @@ class HoloSphereBase extends HoloSphereCore {
714
1050
  );
715
1051
  }
716
1052
 
1053
+ /**
1054
+ * Propagates data from source holon to target holon.
1055
+ *
1056
+ * @param {Object} data - Data to propagate
1057
+ * @param {string} sourceHolon - Source holon H3 cell ID
1058
+ * @param {string} targetHolon - Target holon H3 cell ID
1059
+ * @param {string} lensName - Name of the lens
1060
+ * @param {Object} [options={}] - Propagation options
1061
+ * @param {string} [options.mode='reference'] - Mode: 'reference' creates hologram, 'copy' duplicates data
1062
+ * @returns {Promise<Object>} Result of propagation
1063
+ */
717
1064
  async propagateData(data, sourceHolon, targetHolon, lensName, options = {}) {
718
1065
  // Extract mode from options, default to 'reference' for hologram creation
719
1066
  const mode = options.mode || 'reference';
@@ -728,22 +1075,55 @@ class HoloSphereBase extends HoloSphereCore {
728
1075
  );
729
1076
  }
730
1077
 
1078
+ /**
1079
+ * Resolves a hologram to its source data.
1080
+ *
1081
+ * @param {Object} hologram - Hologram object to resolve
1082
+ * @param {Object} [options={}] - Resolution options
1083
+ * @returns {Promise<Object|null>} Resolved data or null if source not found
1084
+ */
731
1085
  async resolveHologram(hologram, options = {}) {
732
1086
  return federation.resolveHologram(this.client, hologram, new Set(), [], { ...options, appname: this.config.appName });
733
1087
  }
734
1088
 
1089
+ /**
1090
+ * Checks if an object is a hologram (unresolved reference).
1091
+ *
1092
+ * @param {Object} data - Data object to check
1093
+ * @returns {boolean} True if the object is a hologram
1094
+ */
735
1095
  isHologram(data) {
736
1096
  return federation.isHologram(data);
737
1097
  }
738
1098
 
1099
+ /**
1100
+ * Checks if an object is a resolved hologram (has _hologram metadata).
1101
+ *
1102
+ * @param {Object} data - Data object to check
1103
+ * @returns {boolean} True if the object is a resolved hologram
1104
+ */
739
1105
  isResolvedHologram(data) {
740
1106
  return federation.isResolvedHologram(data);
741
1107
  }
742
1108
 
1109
+ /**
1110
+ * Gets the source information from a hologram or resolved hologram.
1111
+ *
1112
+ * @param {Object} data - Hologram or resolved hologram object
1113
+ * @returns {Object|null} Source information or null
1114
+ */
743
1115
  getHologramSource(data) {
744
1116
  return federation.getHologramSource(data);
745
1117
  }
746
1118
 
1119
+ /**
1120
+ * Cleans up circular hologram references in a holon.
1121
+ *
1122
+ * @param {string} holonId - H3 cell ID of the holon
1123
+ * @param {string} lensName - Name of the lens
1124
+ * @param {Object} [options={}] - Cleanup options
1125
+ * @returns {Promise<Object>} Cleanup results
1126
+ */
747
1127
  async cleanupCircularHolograms(holonId, lensName, options = {}) {
748
1128
  return federation.cleanupCircularHolograms(
749
1129
  this.client,
@@ -754,6 +1134,15 @@ class HoloSphereBase extends HoloSphereCore {
754
1134
  );
755
1135
  }
756
1136
 
1137
+ /**
1138
+ * Cleans up circular hologram references for specific data IDs.
1139
+ *
1140
+ * @param {string} holonId - H3 cell ID of the holon
1141
+ * @param {string} lensName - Name of the lens
1142
+ * @param {string[]} dataIds - Array of data IDs to check
1143
+ * @param {Object} [options={}] - Cleanup options
1144
+ * @returns {Promise<Object>} Cleanup results
1145
+ */
757
1146
  async cleanupCircularHologramsByIds(holonId, lensName, dataIds, options = {}) {
758
1147
  return federation.cleanupCircularHologramsByIds(
759
1148
  this.client,
@@ -765,6 +1154,17 @@ class HoloSphereBase extends HoloSphereCore {
765
1154
  );
766
1155
  }
767
1156
 
1157
+ /**
1158
+ * Propagates data to all federated holons.
1159
+ *
1160
+ * @param {string} holonId - Source holon H3 cell ID
1161
+ * @param {string} lensName - Name of the lens
1162
+ * @param {Object} data - Data to propagate
1163
+ * @param {Object} [options={}] - Propagation options
1164
+ * @param {boolean} [options.useHolograms=true] - Whether to create holograms
1165
+ * @param {boolean} [options.resolveExisting=true] - Whether to resolve existing data
1166
+ * @returns {Promise<Array|undefined>} Array of propagation results or undefined if no targets
1167
+ */
768
1168
  async propagate(holonId, lensName, data, options = {}) {
769
1169
  const federationData = await this.getFederation(holonId);
770
1170
  // getFederation returns an object with federated array, not an array directly
@@ -788,6 +1188,13 @@ class HoloSphereBase extends HoloSphereCore {
788
1188
  return results;
789
1189
  }
790
1190
 
1191
+ /**
1192
+ * Gets the federation configuration for a holon.
1193
+ *
1194
+ * @param {string} holonId - H3 cell ID of the holon
1195
+ * @returns {Promise<Object|null>} Federation configuration object or null
1196
+ * @throws {Error} If holonId is not provided
1197
+ */
791
1198
  async getFederation(holonId) {
792
1199
  if (!holonId) {
793
1200
  throw new Error('getFederation: Missing holon ID');
@@ -808,8 +1215,22 @@ class HoloSphereBase extends HoloSphereCore {
808
1215
  return data;
809
1216
  }
810
1217
 
1218
+ /**
1219
+ * Establishes a holon-level federation relationship.
1220
+ *
1221
+ * @param {string} sourceHolon - Source holon H3 cell ID
1222
+ * @param {string} targetHolon - Target holon H3 cell ID
1223
+ * @param {Object} [options={}] - Federation options
1224
+ * @param {Object} [options.lensConfig] - Lens configuration for federation
1225
+ * @param {string[]} [options.lensConfig.inbound] - Lenses for inbound federation
1226
+ * @param {string[]} [options.lensConfig.outbound] - Lenses for outbound federation
1227
+ * @param {string} [options.partnerName] - Human-readable name for the partner holon
1228
+ * @param {boolean} [options.skipPropagation=false] - Skip propagating existing data
1229
+ * @returns {Promise<boolean>} True if federation was established
1230
+ * @throws {Error} If trying to federate a holon with itself
1231
+ */
811
1232
  async federateHolon(sourceHolon, targetHolon, options = {}) {
812
- const { lensConfig = { inbound: [], outbound: [] }, partnerName = null } = options;
1233
+ const { lensConfig = { inbound: [], outbound: [] }, partnerName = null, skipPropagation = false } = options;
813
1234
 
814
1235
  if (sourceHolon === targetHolon) {
815
1236
  throw new Error('Cannot federate a holon with itself');
@@ -866,7 +1287,8 @@ class HoloSphereBase extends HoloSphereCore {
866
1287
  const success = await this.writeGlobal('federation', federationData);
867
1288
  this.clearCache('federation');
868
1289
 
869
- if (success) {
1290
+ // Only propagate existing data if skipPropagation is false
1291
+ if (success && !skipPropagation) {
870
1292
  for (const lens of (lensConfig.inbound || [])) {
871
1293
  await this.federate(targetHolon, sourceHolon, lens, { direction: 'outbound', mode: 'reference' });
872
1294
  }
@@ -878,6 +1300,13 @@ class HoloSphereBase extends HoloSphereCore {
878
1300
  return success;
879
1301
  }
880
1302
 
1303
+ /**
1304
+ * Removes a holon-level federation relationship.
1305
+ *
1306
+ * @param {string} sourceHolon - Source holon H3 cell ID
1307
+ * @param {string} targetHolon - Target holon H3 cell ID
1308
+ * @returns {Promise<boolean>} True if unfederation succeeded, false if no federation existed
1309
+ */
881
1310
  async unfederateHolon(sourceHolon, targetHolon) {
882
1311
  const federationData = await this.readGlobal('federation', sourceHolon);
883
1312
  if (!federationData) return false;
@@ -907,6 +1336,13 @@ class HoloSphereBase extends HoloSphereCore {
907
1336
  return success;
908
1337
  }
909
1338
 
1339
+ /**
1340
+ * Gets the federation configuration between two holons.
1341
+ *
1342
+ * @param {string} sourceHolon - Source holon H3 cell ID
1343
+ * @param {string} targetHolon - Target holon H3 cell ID
1344
+ * @returns {Promise<Object|null>} Lens configuration or null
1345
+ */
910
1346
  async getFederatedConfig(sourceHolon, targetHolon) {
911
1347
  const federationData = await this.readGlobal('federation', sourceHolon);
912
1348
  if (!federationData || !federationData.lensConfig) return null;
@@ -914,11 +1350,33 @@ class HoloSphereBase extends HoloSphereCore {
914
1350
  }
915
1351
 
916
1352
  // === Hierarchical Operations ===
1353
+
1354
+ /**
1355
+ * Performs hierarchical upcast aggregation.
1356
+ * Aggregates data from child holons up to parent holons in the H3 hierarchy.
1357
+ *
1358
+ * @param {string} holonId - Starting holon H3 cell ID
1359
+ * @param {string} lensName - Name of the lens
1360
+ * @param {string} dataId - ID of the data to upcast
1361
+ * @param {Object} [options={}] - Upcast options
1362
+ * @returns {Promise<Object>} Aggregation result
1363
+ */
917
1364
  async upcast(holonId, lensName, dataId, options = {}) {
918
1365
  return hierarchical.upcast(this, holonId, lensName, dataId, options);
919
1366
  }
920
1367
 
921
1368
  // === Subscriptions ===
1369
+
1370
+ /**
1371
+ * Subscribes to real-time updates for a holon and lens.
1372
+ *
1373
+ * @param {string} holonId - H3 cell ID for the holon
1374
+ * @param {string} lensName - Name of the lens
1375
+ * @param {Function} callback - Callback function called with updated data
1376
+ * @param {Object} [options={}] - Subscription options
1377
+ * @returns {{unsubscribe: Function}} Subscription object with unsubscribe method
1378
+ * @throws {TypeError} If callback is not a function
1379
+ */
922
1380
  subscribe(holonId, lensName, callback, options = {}) {
923
1381
  if (typeof callback !== 'function') {
924
1382
  throw new TypeError('callback must be a function');
@@ -953,6 +1411,15 @@ class HoloSphereBase extends HoloSphereCore {
953
1411
  };
954
1412
  }
955
1413
 
1414
+ /**
1415
+ * Subscribes to real-time updates for a global table.
1416
+ *
1417
+ * @param {string} table - Name of the global table
1418
+ * @param {string} key - Key to subscribe to
1419
+ * @param {Function} callback - Callback function called with updated data
1420
+ * @param {Object} [options={}] - Subscription options
1421
+ * @returns {Promise<{unsubscribe: Function}>} Subscription object
1422
+ */
956
1423
  async subscribeGlobal(table, key, callback, options = {}) {
957
1424
  return globalTables.subscribeGlobal(
958
1425
  this.client,
@@ -965,27 +1432,78 @@ class HoloSphereBase extends HoloSphereCore {
965
1432
  }
966
1433
 
967
1434
  // === Crypto Operations ===
1435
+
1436
+ /**
1437
+ * Derives a public key from a private key.
1438
+ *
1439
+ * @param {string} privateKey - Hex-encoded private key
1440
+ * @returns {Promise<string>} Hex-encoded public key
1441
+ */
968
1442
  async getPublicKey(privateKey) {
969
1443
  return crypto.getPublicKey(privateKey);
970
1444
  }
971
1445
 
1446
+ /**
1447
+ * Signs content with a private key.
1448
+ *
1449
+ * @param {string|Object} content - Content to sign
1450
+ * @param {string} privateKey - Hex-encoded private key
1451
+ * @returns {Promise<string>} Hex-encoded signature
1452
+ */
972
1453
  async sign(content, privateKey) {
973
1454
  return crypto.sign(content, privateKey);
974
1455
  }
975
1456
 
1457
+ /**
1458
+ * Verifies a signature against content and public key.
1459
+ *
1460
+ * @param {string|Object} content - Original content
1461
+ * @param {string} signature - Hex-encoded signature
1462
+ * @param {string} publicKey - Hex-encoded public key
1463
+ * @returns {Promise<boolean>} True if signature is valid
1464
+ */
976
1465
  async verify(content, signature, publicKey) {
977
1466
  return crypto.verify(content, signature, publicKey);
978
1467
  }
979
1468
 
1469
+ /**
1470
+ * Issues a capability token for authorization.
1471
+ *
1472
+ * @param {string[]} permissions - Array of permissions ('read', 'write', 'delete')
1473
+ * @param {Object} scope - Scope of the capability (holonId, lensName, etc.)
1474
+ * @param {string} recipient - Public key of the recipient
1475
+ * @param {Object} [options] - Additional options
1476
+ * @returns {Promise<string>} Signed capability token
1477
+ */
980
1478
  async issueCapability(permissions, scope, recipient, options) {
981
1479
  return crypto.issueCapability(permissions, scope, recipient, options);
982
1480
  }
983
1481
 
1482
+ /**
1483
+ * Verifies a capability token.
1484
+ *
1485
+ * @param {string} token - Capability token to verify
1486
+ * @param {string} requiredPermission - Required permission to check
1487
+ * @param {Object} scope - Scope to verify against
1488
+ * @returns {Promise<boolean>} True if token is valid and has required permission
1489
+ */
984
1490
  async verifyCapability(token, requiredPermission, scope) {
985
1491
  return crypto.verifyCapability(token, requiredPermission, scope);
986
1492
  }
987
1493
 
988
1494
  // === Social Protocol Operations ===
1495
+
1496
+ /**
1497
+ * Publishes a Nostr event to a holon.
1498
+ *
1499
+ * @param {Object} event - Nostr event object
1500
+ * @param {number} event.kind - Event kind
1501
+ * @param {string} event.content - Event content
1502
+ * @param {Array} [event.tags] - Event tags
1503
+ * @param {string} holonId - H3 cell ID for the holon
1504
+ * @param {string} [lensName='social'] - Name of the lens
1505
+ * @returns {Promise<boolean>} True if publish succeeded
1506
+ */
989
1507
  async publishNostr(event, holonId, lensName = 'social') {
990
1508
  // Validate Nostr event format
991
1509
  social.validateNostrEvent(event, true, true); // partial=true, throwOnError=true
@@ -1007,6 +1525,16 @@ class HoloSphereBase extends HoloSphereCore {
1007
1525
  return true;
1008
1526
  }
1009
1527
 
1528
+ /**
1529
+ * Publishes an ActivityPub object to a holon.
1530
+ *
1531
+ * @param {Object} object - ActivityPub object
1532
+ * @param {string} object.type - ActivityPub type (Note, Article, etc.)
1533
+ * @param {string} [object.actor] - Actor ID (defaults to client public key)
1534
+ * @param {string} holonId - H3 cell ID for the holon
1535
+ * @param {string} [lensName='social'] - Name of the lens
1536
+ * @returns {Promise<boolean>} True if publish succeeded
1537
+ */
1010
1538
  async publishActivityPub(object, holonId, lensName = 'social') {
1011
1539
  // Validate ActivityPub object format
1012
1540
  social.validateActivityPubObject(object, true); // throwOnError=true
@@ -1018,6 +1546,18 @@ class HoloSphereBase extends HoloSphereCore {
1018
1546
  return this.write(holonId, lensName, activity);
1019
1547
  }
1020
1548
 
1549
+ /**
1550
+ * Queries social protocol data from a holon.
1551
+ *
1552
+ * @param {string} holonId - H3 cell ID for the holon
1553
+ * @param {Object} [options={}] - Query options
1554
+ * @param {string} [options.lens='social'] - Name of the lens
1555
+ * @param {string} [options.protocol] - Filter by protocol ('nostr', 'activitypub', 'all')
1556
+ * @param {string} [options.type] - Filter by content type
1557
+ * @param {number} [options.since] - Filter events after this timestamp
1558
+ * @param {number} [options.until] - Filter events before this timestamp
1559
+ * @returns {Promise<Array>} Array of matching social items
1560
+ */
1021
1561
  async querySocial(holonId, options = {}) {
1022
1562
  const lensName = options.lens || 'social';
1023
1563
  const data = await this.read(holonId, lensName);
@@ -1035,6 +1575,19 @@ class HoloSphereBase extends HoloSphereCore {
1035
1575
  });
1036
1576
  }
1037
1577
 
1578
+ /**
1579
+ * Verifies a Nostr event signature.
1580
+ *
1581
+ * @param {Object} event - Nostr event to verify
1582
+ * @param {string} event.id - Event ID
1583
+ * @param {string} event.pubkey - Author public key
1584
+ * @param {number} event.created_at - Creation timestamp
1585
+ * @param {number} event.kind - Event kind
1586
+ * @param {Array} event.tags - Event tags
1587
+ * @param {string} event.content - Event content
1588
+ * @param {string} event.sig - Event signature
1589
+ * @returns {Promise<boolean>} True if event signature is valid
1590
+ */
1038
1591
  async verifyNostrEvent(event) {
1039
1592
  // Extract only standard Nostr event fields for verification
1040
1593
  // (nostr-tools can't serialize events with extra properties like 'protocol')
@@ -1044,6 +1597,19 @@ class HoloSphereBase extends HoloSphereCore {
1044
1597
  }
1045
1598
 
1046
1599
  // === Metrics ===
1600
+
1601
+ /**
1602
+ * Gets performance metrics for this HoloSphere instance.
1603
+ *
1604
+ * @returns {Object} Metrics object
1605
+ * @returns {number} return.reads - Number of read operations
1606
+ * @returns {number} return.writes - Number of write operations
1607
+ * @returns {number} return.deletes - Number of delete operations
1608
+ * @returns {number} return.federations - Number of federation operations
1609
+ * @returns {number} return.subscriptions - Number of active subscriptions
1610
+ * @returns {number} return.avgReadTime - Average read time in milliseconds
1611
+ * @returns {number} return.avgWriteTime - Average write time in milliseconds
1612
+ */
1047
1613
  metrics() {
1048
1614
  const reads = this._metrics.reads || 0;
1049
1615
  const writes = this._metrics.writes || 0;
@@ -1062,59 +1628,157 @@ class HoloSphereBase extends HoloSphereCore {
1062
1628
  }
1063
1629
 
1064
1630
  // === Aliases ===
1631
+
1632
+ /**
1633
+ * Alias for {@link HoloSphereBase#write}.
1634
+ * @param {string} holonId - H3 cell ID for the holon
1635
+ * @param {string} lensName - Name of the lens
1636
+ * @param {Object} data - Data to write
1637
+ * @param {Object} [options] - Write options
1638
+ * @returns {Promise<boolean>}
1639
+ */
1065
1640
  async put(holonId, lensName, data, options = {}) {
1066
1641
  return this.write(holonId, lensName, data, options);
1067
1642
  }
1068
1643
 
1644
+ /**
1645
+ * Alias for {@link HoloSphereBase#read}.
1646
+ * @param {string} holonId - H3 cell ID for the holon
1647
+ * @param {string} lensName - Name of the lens
1648
+ * @param {string|null} [dataId] - Specific data ID or null
1649
+ * @param {Object} [options] - Read options
1650
+ * @returns {Promise<Object|Array|null>}
1651
+ */
1069
1652
  async get(holonId, lensName, dataId = null, options = {}) {
1070
1653
  return this.read(holonId, lensName, dataId, options);
1071
1654
  }
1072
1655
 
1656
+ /**
1657
+ * Alias for {@link HoloSphereBase#delete}.
1658
+ * @param {string} holonId - H3 cell ID for the holon
1659
+ * @param {string} lensName - Name of the lens
1660
+ * @param {string} dataId - Data ID to delete
1661
+ * @param {Object} [options] - Delete options
1662
+ * @returns {Promise<boolean>}
1663
+ */
1073
1664
  async remove(holonId, lensName, dataId, options = {}) {
1074
1665
  return this.delete(holonId, lensName, dataId, options);
1075
1666
  }
1076
1667
 
1668
+ /**
1669
+ * Alias for {@link HoloSphereBase#writeGlobal}.
1670
+ * @param {string} table - Global table name
1671
+ * @param {Object} data - Data to write
1672
+ * @returns {Promise<boolean>}
1673
+ */
1077
1674
  async putGlobal(table, data) {
1078
1675
  return this.writeGlobal(table, data);
1079
1676
  }
1080
1677
 
1678
+ /**
1679
+ * Alias for {@link HoloSphereBase#readGlobal}.
1680
+ * @param {string} table - Global table name
1681
+ * @param {string|null} [key] - Key to read
1682
+ * @returns {Promise<Object|Array|null>}
1683
+ */
1081
1684
  async getGlobal(table, key = null) {
1082
1685
  return this.readGlobal(table, key);
1083
1686
  }
1084
1687
 
1688
+ /**
1689
+ * Alias for {@link HoloSphereBase#deleteGlobal}.
1690
+ * @param {string} table - Global table name
1691
+ * @param {string} key - Key to delete
1692
+ * @returns {Promise<boolean>}
1693
+ */
1085
1694
  async removeGlobal(table, key) {
1086
1695
  return this.deleteGlobal(table, key);
1087
1696
  }
1088
1697
 
1698
+ /**
1699
+ * Alias for {@link HoloSphereBase#setSchema}.
1700
+ * @param {string} lensName - Lens name
1701
+ * @param {Object|string} schemaObj - Schema object or URI
1702
+ * @param {boolean} [strict] - Strict mode
1703
+ * @returns {Promise<void>}
1704
+ */
1089
1705
  async defineSchema(lensName, schemaObj, strict = false) {
1090
1706
  return this.setSchema(lensName, schemaObj, strict);
1091
1707
  }
1092
1708
 
1709
+ /**
1710
+ * Alias for {@link HoloSphereBase#getSchema}.
1711
+ * @param {string} lensName - Lens name
1712
+ * @returns {Promise<Object|null>}
1713
+ */
1093
1714
  async fetchSchema(lensName) {
1094
1715
  return this.getSchema(lensName);
1095
1716
  }
1096
1717
 
1718
+ /**
1719
+ * Alias for {@link HoloSphereBase#clearSchema}.
1720
+ * @param {string} lensName - Lens name
1721
+ * @returns {Promise<void>}
1722
+ */
1097
1723
  async removeSchema(lensName) {
1098
1724
  return this.clearSchema(lensName);
1099
1725
  }
1100
1726
 
1727
+ /**
1728
+ * Alias for {@link HoloSphereBase#write}.
1729
+ * @param {string} holonId - H3 cell ID for the holon
1730
+ * @param {string} lensName - Name of the lens
1731
+ * @param {Object} data - Data to write
1732
+ * @param {Object} [options] - Write options
1733
+ * @returns {Promise<boolean>}
1734
+ */
1101
1735
  async store(holonId, lensName, data, options = {}) {
1102
1736
  return this.write(holonId, lensName, data, options);
1103
1737
  }
1104
1738
 
1739
+ /**
1740
+ * Alias for {@link HoloSphereBase#read}.
1741
+ * @param {string} holonId - H3 cell ID for the holon
1742
+ * @param {string} lensName - Name of the lens
1743
+ * @param {string|null} [dataId] - Specific data ID or null
1744
+ * @param {Object} [options] - Read options
1745
+ * @returns {Promise<Object|Array|null>}
1746
+ */
1105
1747
  async fetch(holonId, lensName, dataId = null, options = {}) {
1106
1748
  return this.read(holonId, lensName, dataId, options);
1107
1749
  }
1108
1750
 
1751
+ /**
1752
+ * Alias for {@link HoloSphereBase#write}.
1753
+ * @param {string} holonId - H3 cell ID for the holon
1754
+ * @param {string} lensName - Name of the lens
1755
+ * @param {Object} data - Data to write
1756
+ * @param {Object} [options] - Write options
1757
+ * @returns {Promise<boolean>}
1758
+ */
1109
1759
  async save(holonId, lensName, data, options = {}) {
1110
1760
  return this.write(holonId, lensName, data, options);
1111
1761
  }
1112
1762
 
1763
+ /**
1764
+ * Alias for {@link HoloSphereBase#read}.
1765
+ * @param {string} holonId - H3 cell ID for the holon
1766
+ * @param {string} lensName - Name of the lens
1767
+ * @param {string|null} [dataId] - Specific data ID or null
1768
+ * @param {Object} [options] - Read options
1769
+ * @returns {Promise<Object|Array|null>}
1770
+ */
1113
1771
  async load(holonId, lensName, dataId = null, options = {}) {
1114
1772
  return this.read(holonId, lensName, dataId, options);
1115
1773
  }
1116
1774
 
1117
1775
  // === Cache ===
1776
+
1777
+ /**
1778
+ * Clears the internal cache.
1779
+ *
1780
+ * @param {string|null} [pattern=null] - If provided, only clear cache entries matching this pattern
1781
+ */
1118
1782
  clearCache(pattern = null) {
1119
1783
  if (pattern) {
1120
1784
  for (const key of this._cache.keys()) {