holosphere 1.1.19 → 2.0.0-alpha0
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.
- package/.env.example +36 -0
- package/.eslintrc.json +16 -0
- package/.prettierrc.json +7 -0
- package/README.md +476 -531
- package/bin/holosphere-activitypub.js +158 -0
- package/cleanup-test-data.js +204 -0
- package/examples/demo.html +1333 -0
- package/examples/example-bot.js +197 -0
- package/package.json +47 -87
- package/scripts/check-bundle-size.js +54 -0
- package/scripts/check-quest-ids.js +77 -0
- package/scripts/import-holons.js +578 -0
- package/scripts/publish-to-relay.js +101 -0
- package/scripts/read-example.js +186 -0
- package/scripts/relay-diagnostic.js +59 -0
- package/scripts/relay-example.js +179 -0
- package/scripts/resync-to-relay.js +245 -0
- package/scripts/revert-import.js +196 -0
- package/scripts/test-hybrid-mode.js +108 -0
- package/scripts/test-local-storage.js +63 -0
- package/scripts/test-nostr-direct.js +55 -0
- package/scripts/test-read-data.js +45 -0
- package/scripts/test-write-read.js +63 -0
- package/scripts/verify-import.js +95 -0
- package/scripts/verify-relay-data.js +139 -0
- package/src/ai/aggregation.js +319 -0
- package/src/ai/breakdown.js +511 -0
- package/src/ai/classifier.js +217 -0
- package/src/ai/council.js +228 -0
- package/src/ai/embeddings.js +279 -0
- package/src/ai/federation-ai.js +324 -0
- package/src/ai/h3-ai.js +955 -0
- package/src/ai/index.js +112 -0
- package/src/ai/json-ops.js +225 -0
- package/src/ai/llm-service.js +205 -0
- package/src/ai/nl-query.js +223 -0
- package/src/ai/relationships.js +353 -0
- package/src/ai/schema-extractor.js +218 -0
- package/src/ai/spatial.js +293 -0
- package/src/ai/tts.js +194 -0
- package/src/content/social-protocols.js +168 -0
- package/src/core/holosphere.js +273 -0
- package/src/crypto/secp256k1.js +259 -0
- package/src/federation/discovery.js +334 -0
- package/src/federation/hologram.js +1042 -0
- package/src/federation/registry.js +386 -0
- package/src/hierarchical/upcast.js +110 -0
- package/src/index.js +2669 -0
- package/src/schema/validator.js +91 -0
- package/src/spatial/h3-operations.js +110 -0
- package/src/storage/backend-factory.js +125 -0
- package/src/storage/backend-interface.js +142 -0
- package/src/storage/backends/activitypub/server.js +653 -0
- package/src/storage/backends/activitypub-backend.js +272 -0
- package/src/storage/backends/gundb-backend.js +233 -0
- package/src/storage/backends/nostr-backend.js +136 -0
- package/src/storage/filesystem-storage-browser.js +41 -0
- package/src/storage/filesystem-storage.js +138 -0
- package/src/storage/global-tables.js +81 -0
- package/src/storage/gun-async.js +281 -0
- package/src/storage/gun-wrapper.js +221 -0
- package/src/storage/indexeddb-storage.js +122 -0
- package/src/storage/key-storage-simple.js +76 -0
- package/src/storage/key-storage.js +136 -0
- package/src/storage/memory-storage.js +59 -0
- package/src/storage/migration.js +338 -0
- package/src/storage/nostr-async.js +811 -0
- package/src/storage/nostr-client.js +939 -0
- package/src/storage/nostr-wrapper.js +211 -0
- package/src/storage/outbox-queue.js +208 -0
- package/src/storage/persistent-storage.js +109 -0
- package/src/storage/sync-service.js +164 -0
- package/src/subscriptions/manager.js +142 -0
- package/test-ai-real-api.js +202 -0
- package/tests/unit/ai/aggregation.test.js +295 -0
- package/tests/unit/ai/breakdown.test.js +446 -0
- package/tests/unit/ai/classifier.test.js +294 -0
- package/tests/unit/ai/council.test.js +262 -0
- package/tests/unit/ai/embeddings.test.js +384 -0
- package/tests/unit/ai/federation-ai.test.js +344 -0
- package/tests/unit/ai/h3-ai.test.js +458 -0
- package/tests/unit/ai/index.test.js +304 -0
- package/tests/unit/ai/json-ops.test.js +307 -0
- package/tests/unit/ai/llm-service.test.js +390 -0
- package/tests/unit/ai/nl-query.test.js +383 -0
- package/tests/unit/ai/relationships.test.js +311 -0
- package/tests/unit/ai/schema-extractor.test.js +384 -0
- package/tests/unit/ai/spatial.test.js +279 -0
- package/tests/unit/ai/tts.test.js +279 -0
- package/tests/unit/content.test.js +332 -0
- package/tests/unit/contract/core.test.js +88 -0
- package/tests/unit/contract/crypto.test.js +198 -0
- package/tests/unit/contract/data.test.js +223 -0
- package/tests/unit/contract/federation.test.js +181 -0
- package/tests/unit/contract/hierarchical.test.js +113 -0
- package/tests/unit/contract/schema.test.js +114 -0
- package/tests/unit/contract/social.test.js +217 -0
- package/tests/unit/contract/spatial.test.js +110 -0
- package/tests/unit/contract/subscriptions.test.js +128 -0
- package/tests/unit/contract/utils.test.js +159 -0
- package/tests/unit/core.test.js +152 -0
- package/tests/unit/crypto.test.js +328 -0
- package/tests/unit/federation.test.js +234 -0
- package/tests/unit/gun-async.test.js +252 -0
- package/tests/unit/hierarchical.test.js +399 -0
- package/tests/unit/integration/scenario-01-geographic-storage.test.js +74 -0
- package/tests/unit/integration/scenario-02-federation.test.js +76 -0
- package/tests/unit/integration/scenario-03-subscriptions.test.js +102 -0
- package/tests/unit/integration/scenario-04-validation.test.js +129 -0
- package/tests/unit/integration/scenario-05-hierarchy.test.js +125 -0
- package/tests/unit/integration/scenario-06-social.test.js +135 -0
- package/tests/unit/integration/scenario-07-persistence.test.js +130 -0
- package/tests/unit/integration/scenario-08-authorization.test.js +161 -0
- package/tests/unit/integration/scenario-09-cross-dimensional.test.js +139 -0
- package/tests/unit/integration/scenario-10-cross-holosphere-capabilities.test.js +357 -0
- package/tests/unit/integration/scenario-11-cross-holosphere-federation.test.js +410 -0
- package/tests/unit/integration/scenario-12-capability-federated-read.test.js +719 -0
- package/tests/unit/performance/benchmark.test.js +85 -0
- package/tests/unit/schema.test.js +213 -0
- package/tests/unit/spatial.test.js +158 -0
- package/tests/unit/storage.test.js +195 -0
- package/tests/unit/subscriptions.test.js +328 -0
- package/tests/unit/test-data-permanence-debug.js +197 -0
- package/tests/unit/test-data-permanence.js +340 -0
- package/tests/unit/test-key-persistence-fixed.js +148 -0
- package/tests/unit/test-key-persistence.js +172 -0
- package/tests/unit/test-relay-permanence.js +376 -0
- package/tests/unit/test-second-node.js +95 -0
- package/tests/unit/test-simple-write.js +89 -0
- package/vite.config.js +49 -0
- package/vitest.config.js +20 -0
- package/FEDERATION.md +0 -213
- package/compute.js +0 -298
- package/content.js +0 -1022
- package/federation.js +0 -1234
- package/global.js +0 -736
- package/hexlib.js +0 -335
- package/hologram.js +0 -183
- package/holosphere-bundle.esm.js +0 -34549
- package/holosphere-bundle.js +0 -34580
- package/holosphere-bundle.min.js +0 -49
- package/holosphere.d.ts +0 -604
- package/holosphere.js +0 -739
- package/node.js +0 -246
- package/schema.js +0 -139
- package/utils.js +0 -302
package/holosphere.d.ts
DELETED
|
@@ -1,604 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Federation propagation options interface
|
|
3
|
-
*/
|
|
4
|
-
interface PropagationOptions {
|
|
5
|
-
/** Whether to use holograms instead of duplicating data (default: true) */
|
|
6
|
-
useHolograms?: boolean;
|
|
7
|
-
/** Specific target spaces to propagate to (default: all federated spaces) */
|
|
8
|
-
targetSpaces?: string[];
|
|
9
|
-
/** Password for accessing the source holon (if needed) */
|
|
10
|
-
password?: string | null;
|
|
11
|
-
/** Whether to automatically propagate to parent hexagons (default: true) */
|
|
12
|
-
propagateToParents?: boolean;
|
|
13
|
-
/** Maximum number of parent levels to propagate to (default: 15) */
|
|
14
|
-
maxParentLevels?: number;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Put options interface
|
|
19
|
-
*/
|
|
20
|
-
interface PutOptions {
|
|
21
|
-
/** Whether to automatically propagate to federated spaces (default: false) */
|
|
22
|
-
autoPropagate?: boolean;
|
|
23
|
-
/** Additional options to pass to propagate */
|
|
24
|
-
propagationOptions?: PropagationOptions;
|
|
25
|
-
/** Whether to disable hologram redirection logic when putting data (default: false) */
|
|
26
|
-
disableHologramRedirection?: boolean;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Get options interface
|
|
31
|
-
*/
|
|
32
|
-
interface GetOptions {
|
|
33
|
-
/** Whether to automatically resolve holograms (default: true) */
|
|
34
|
-
resolveHolograms?: boolean;
|
|
35
|
-
/** Options passed to the schema validator */
|
|
36
|
-
validationOptions?: object;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Resolve Hologram options interface
|
|
41
|
-
*/
|
|
42
|
-
interface ResolveHologramOptions {
|
|
43
|
-
/** Whether to follow nested holograms (default: true) */
|
|
44
|
-
followHolograms?: boolean;
|
|
45
|
-
/** Internal use: Tracks visited souls to prevent loops */
|
|
46
|
-
visited?: Set<string>;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Represents a Hologram object, typically containing an id and a soul path.
|
|
51
|
-
*/
|
|
52
|
-
interface Hologram {
|
|
53
|
-
id: string;
|
|
54
|
-
soul: string;
|
|
55
|
-
[key: string]: any; // Allow other properties, e.g., _federation
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Federation info interface
|
|
60
|
-
*/
|
|
61
|
-
interface FederationInfo {
|
|
62
|
-
/** Identifier of the holon */
|
|
63
|
-
id: string;
|
|
64
|
-
/** Name of the holon */
|
|
65
|
-
name: string;
|
|
66
|
-
/** List of federated space IDs (spaces this holon federates with) */
|
|
67
|
-
federation: string[];
|
|
68
|
-
/** List of spaces to notify about changes */
|
|
69
|
-
notify: string[];
|
|
70
|
-
/** Timestamp of last update */
|
|
71
|
-
timestamp: number;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Options for federated data retrieval
|
|
76
|
-
*/
|
|
77
|
-
interface GetFederatedOptions {
|
|
78
|
-
/** Whether to aggregate results by ID */
|
|
79
|
-
aggregate?: boolean;
|
|
80
|
-
/** Field to use as ID */
|
|
81
|
-
idField?: string;
|
|
82
|
-
/** Fields to sum during aggregation */
|
|
83
|
-
sumFields?: string[];
|
|
84
|
-
/** Array fields to concatenate during aggregation */
|
|
85
|
-
concatArrays?: string[];
|
|
86
|
-
/** Whether to remove duplicates in concatenated arrays */
|
|
87
|
-
removeDuplicates?: boolean;
|
|
88
|
-
/** Custom merge function for aggregation */
|
|
89
|
-
mergeStrategy?: (items: any[]) => any;
|
|
90
|
-
/** Whether to include local data */
|
|
91
|
-
includeLocal?: boolean;
|
|
92
|
-
/** Whether to include federated data */
|
|
93
|
-
includeFederated?: boolean;
|
|
94
|
-
/** Whether to resolve federation references */
|
|
95
|
-
resolveReferences?: boolean;
|
|
96
|
-
/** Maximum number of federated spaces to query */
|
|
97
|
-
maxFederatedSpaces?: number;
|
|
98
|
-
/** Timeout in milliseconds for federated queries */
|
|
99
|
-
timeout?: number;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Results from a propagation operation
|
|
104
|
-
*/
|
|
105
|
-
interface PropagationResult {
|
|
106
|
-
/** Number of successfully propagated items */
|
|
107
|
-
success: number;
|
|
108
|
-
/** Number of errors encountered */
|
|
109
|
-
errors: number;
|
|
110
|
-
/** Details about errors */
|
|
111
|
-
errorDetails: Array<{ space: string, error: string }>;
|
|
112
|
-
/** Whether any propagation occurred */
|
|
113
|
-
propagated: boolean;
|
|
114
|
-
/** Whether references were used */
|
|
115
|
-
referencesUsed: boolean;
|
|
116
|
-
/** Error message if applicable */
|
|
117
|
-
error?: string;
|
|
118
|
-
/** Information message if applicable */
|
|
119
|
-
message?: string;
|
|
120
|
-
/** Parent propagation results */
|
|
121
|
-
parentPropagation?: {
|
|
122
|
-
/** Number of successfully propagated items to parents */
|
|
123
|
-
success: number;
|
|
124
|
-
/** Number of errors encountered during parent propagation */
|
|
125
|
-
errors: number;
|
|
126
|
-
/** Number of parent propagations skipped */
|
|
127
|
-
skipped: number;
|
|
128
|
-
/** Messages from parent propagation */
|
|
129
|
-
messages: string[];
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Result from a put operation
|
|
135
|
-
*/
|
|
136
|
-
interface PutResult {
|
|
137
|
-
/** Indicates if the put operation was successful */
|
|
138
|
-
success: boolean;
|
|
139
|
-
/** Indicates if the data ultimately put at the path was a hologram */
|
|
140
|
-
isHologramAtPath?: boolean;
|
|
141
|
-
/** The final holon where data was put (after potential redirection) */
|
|
142
|
-
pathHolon: string;
|
|
143
|
-
/** The final lens where data was put (after potential redirection) */
|
|
144
|
-
pathLens: string;
|
|
145
|
-
/** The final key under which data was put (after potential redirection) */
|
|
146
|
-
pathKey: string;
|
|
147
|
-
/** Result of any automatic propagation, if it occurred */
|
|
148
|
-
propagationResult?: PropagationResult | null;
|
|
149
|
-
/** Error message if the put operation failed at some point */
|
|
150
|
-
error?: string;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
declare class HoloSphere {
|
|
154
|
-
private appname;
|
|
155
|
-
private strict;
|
|
156
|
-
private validator;
|
|
157
|
-
public gun;
|
|
158
|
-
private sea;
|
|
159
|
-
private openai?;
|
|
160
|
-
private subscriptions;
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* Initializes a new instance of the HoloSphere class.
|
|
164
|
-
* @param {string} appname - The name of the application.
|
|
165
|
-
* @param {boolean} strict - Whether to enforce strict schema validation.
|
|
166
|
-
* @param {string|null} openaikey - The OpenAI API key.
|
|
167
|
-
* @param {object|null} gunInstance - The Gun instance to use.
|
|
168
|
-
*/
|
|
169
|
-
constructor(appname: string, strict?: boolean, openaikey?: string | null, gunInstance?: any);
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* Gets the Gun instance.
|
|
173
|
-
* @returns {any} - The Gun instance.
|
|
174
|
-
*/
|
|
175
|
-
getGun(): any;
|
|
176
|
-
|
|
177
|
-
// ================================ SCHEMA FUNCTIONS ================================
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* Sets the JSON schema for a specific lens.
|
|
181
|
-
* @param {string} lens - The lens identifier.
|
|
182
|
-
* @param {object} schema - The JSON schema to set.
|
|
183
|
-
* @returns {Promise<boolean>} - Resolves when the schema is set.
|
|
184
|
-
*/
|
|
185
|
-
setSchema(lens: string, schema: object): Promise<boolean>;
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* Retrieves the JSON schema for a specific lens.
|
|
189
|
-
* @param {string} lens - The lens identifier.
|
|
190
|
-
* @returns {Promise<object|null>} - The retrieved schema or null if not found.
|
|
191
|
-
*/
|
|
192
|
-
getSchema(lens: string): Promise<object | null>;
|
|
193
|
-
|
|
194
|
-
// ================================ CONTENT FUNCTIONS ================================
|
|
195
|
-
|
|
196
|
-
/**
|
|
197
|
-
* Stores content in the specified holon and lens.
|
|
198
|
-
* @param {string} holon - The holon identifier.
|
|
199
|
-
* @param {string} lens - The lens under which to store the content.
|
|
200
|
-
* @param {object} data - The data to store.
|
|
201
|
-
* @param {string} [password] - Optional password for private holon.
|
|
202
|
-
* @param {PutOptions} [options] - Additional options
|
|
203
|
-
* @returns {Promise<any>} - Returns result object if successful
|
|
204
|
-
*/
|
|
205
|
-
put(holon: string, lens: string, data: object, password?: string | null, options?: PutOptions): Promise<PutResult>;
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* Retrieves content from the specified holon and lens.
|
|
209
|
-
* @param {string} holon - The holon identifier.
|
|
210
|
-
* @param {string} lens - The lens from which to retrieve content.
|
|
211
|
-
* @param {string} key - The specific key to retrieve.
|
|
212
|
-
* @param {string} [password] - Optional password for private holon.
|
|
213
|
-
* @param {GetOptions} [options] - Additional options
|
|
214
|
-
* @returns {Promise<any|null>} - The retrieved content or null if not found.
|
|
215
|
-
*/
|
|
216
|
-
get(holon: string, lens: string, key: string, password?: string | null, options?: GetOptions): Promise<any | null>;
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
* Retrieves a node directly using its soul path
|
|
220
|
-
* @param {string} soul - The soul path of the node
|
|
221
|
-
* @returns {Promise<any>} - The retrieved node or null if not found.
|
|
222
|
-
*/
|
|
223
|
-
getNodeBySoul(soul: string): Promise<any>;
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* Propagates data to federated holons
|
|
227
|
-
* @param {string} holon - The holon identifier
|
|
228
|
-
* @param {string} lens - The lens identifier
|
|
229
|
-
* @param {object} data - The data to propagate
|
|
230
|
-
* @param {PropagationOptions} [options] - Propagation options
|
|
231
|
-
* @returns {Promise<PropagationResult>} - Result with success count and errors
|
|
232
|
-
*/
|
|
233
|
-
propagate(holon: string, lens: string, data: object, options?: PropagationOptions): Promise<PropagationResult>;
|
|
234
|
-
|
|
235
|
-
/**
|
|
236
|
-
* Retrieves all content from the specified holon and lens.
|
|
237
|
-
* @param {string} holon - The holon identifier.
|
|
238
|
-
* @param {string} lens - The lens from which to retrieve content.
|
|
239
|
-
* @param {string} [password] - Optional password for private holon.
|
|
240
|
-
* @returns {Promise<Array<any>>} - The retrieved content.
|
|
241
|
-
*/
|
|
242
|
-
getAll(holon: string, lens: string, password?: string | null): Promise<Array<any>>;
|
|
243
|
-
|
|
244
|
-
/**
|
|
245
|
-
* Deletes a specific key from a given holon and lens.
|
|
246
|
-
* @param {string} holon - The holon identifier.
|
|
247
|
-
* @param {string} lens - The lens from which to delete the key.
|
|
248
|
-
* @param {string} key - The specific key to delete.
|
|
249
|
-
* @param {string} [password] - Optional password for private holon.
|
|
250
|
-
* @returns {Promise<boolean>} - Returns true if successful
|
|
251
|
-
*/
|
|
252
|
-
delete(holon: string, lens: string, key: string, password?: string | null): Promise<boolean>;
|
|
253
|
-
|
|
254
|
-
/**
|
|
255
|
-
* Deletes all keys from a given holon and lens.
|
|
256
|
-
* @param {string} holon - The holon identifier.
|
|
257
|
-
* @param {string} lens - The lens from which to delete all keys.
|
|
258
|
-
* @param {string} [password] - Optional password for private holon.
|
|
259
|
-
* @returns {Promise<boolean>} - Returns true if successful
|
|
260
|
-
*/
|
|
261
|
-
deleteAll(holon: string, lens: string, password?: string | null): Promise<boolean>;
|
|
262
|
-
|
|
263
|
-
// ================================ NODE FUNCTIONS ================================
|
|
264
|
-
|
|
265
|
-
/**
|
|
266
|
-
* Stores a specific gun node in a given holon and lens.
|
|
267
|
-
* @param {string} holon - The holon identifier.
|
|
268
|
-
* @param {string} lens - The lens under which to store the node.
|
|
269
|
-
* @param {object} data - The node to store.
|
|
270
|
-
* @returns {Promise<boolean>} - Returns true if successful
|
|
271
|
-
*/
|
|
272
|
-
putNode(holon: string, lens: string, data: object): Promise<boolean>;
|
|
273
|
-
|
|
274
|
-
/**
|
|
275
|
-
* Retrieves a specific gun node from the specified holon and lens.
|
|
276
|
-
* @param {string} holon - The holon identifier.
|
|
277
|
-
* @param {string} lens - The lens identifier.
|
|
278
|
-
* @param {string} key - The specific key to retrieve.
|
|
279
|
-
* @returns {Promise<any|null>} - The retrieved node or null if not found.
|
|
280
|
-
*/
|
|
281
|
-
getNode(holon: string, lens: string, key: string): Promise<any | null>;
|
|
282
|
-
|
|
283
|
-
/**
|
|
284
|
-
* Gets a Gun reference to a node by its soul
|
|
285
|
-
* @param {string} soul - The soul path
|
|
286
|
-
* @returns {any} - A Gun reference to the node
|
|
287
|
-
*/
|
|
288
|
-
getNodeRef(soul: string): any;
|
|
289
|
-
|
|
290
|
-
/**
|
|
291
|
-
* Deletes a specific gun node from a given holon and lens.
|
|
292
|
-
* @param {string} holon - The holon identifier.
|
|
293
|
-
* @param {string} lens - The lens identifier.
|
|
294
|
-
* @param {string} key - The key of the node to delete.
|
|
295
|
-
* @returns {Promise<boolean>} - Returns true if successful
|
|
296
|
-
*/
|
|
297
|
-
deleteNode(holon: string, lens: string, key: string): Promise<boolean>;
|
|
298
|
-
|
|
299
|
-
// ================================ HOLOGRAM FUNCTIONS ================================
|
|
300
|
-
|
|
301
|
-
/**
|
|
302
|
-
* Creates a soul hologram object for a data item.
|
|
303
|
-
* @param {string} holon - The holon where the original data is stored.
|
|
304
|
-
* @param {string} lens - The lens where the original data is stored.
|
|
305
|
-
* @param {object} data - The data to create a hologram for. Must have an 'id' field.
|
|
306
|
-
* @returns {Hologram} - A hologram object containing id and soul.
|
|
307
|
-
*/
|
|
308
|
-
createHologram(holon: string, lens: string, data: { id: string, [key: string]: any }): Hologram;
|
|
309
|
-
|
|
310
|
-
/**
|
|
311
|
-
* Checks if an object is a hologram (has id and soul).
|
|
312
|
-
* @param {any} data - The data to check.
|
|
313
|
-
* @returns {boolean} - True if the object is considered a hologram.
|
|
314
|
-
*/
|
|
315
|
-
isHologram(data: any): data is Hologram;
|
|
316
|
-
|
|
317
|
-
/**
|
|
318
|
-
* Resolves a hologram to its actual data by following its soul path.
|
|
319
|
-
* @param {Hologram} hologram - The hologram object to resolve.
|
|
320
|
-
* @param {ResolveHologramOptions} [options] - Options for resolution.
|
|
321
|
-
* @returns {Promise<object|null>} - The resolved data, null if not found, or the original hologram in case of loops/errors.
|
|
322
|
-
*/
|
|
323
|
-
resolveHologram(hologram: Hologram, options?: ResolveHologramOptions): Promise<object | null>;
|
|
324
|
-
|
|
325
|
-
// ================================ GLOBAL FUNCTIONS ================================
|
|
326
|
-
|
|
327
|
-
/**
|
|
328
|
-
* Stores data in a global (non-holon-specific) table.
|
|
329
|
-
* @param {string} tableName - The table name to store data in.
|
|
330
|
-
* @param {object} data - The data to store. If it has an 'id' field, it will be used as the key.
|
|
331
|
-
* @param {string} [password] - Optional password for private holon.
|
|
332
|
-
* @returns {Promise<void>}
|
|
333
|
-
*/
|
|
334
|
-
putGlobal(tableName: string, data: object, password?: string | null): Promise<void>;
|
|
335
|
-
|
|
336
|
-
/**
|
|
337
|
-
* Retrieves a specific key from a global table.
|
|
338
|
-
* @param {string} tableName - The table name to retrieve from.
|
|
339
|
-
* @param {string} key - The key to retrieve.
|
|
340
|
-
* @param {string} [password] - Optional password for private holon.
|
|
341
|
-
* @returns {Promise<any|null>} - The parsed data for the key or null if not found.
|
|
342
|
-
*/
|
|
343
|
-
getGlobal(tableName: string, key: string, password?: string | null): Promise<any | null>;
|
|
344
|
-
|
|
345
|
-
/**
|
|
346
|
-
* Retrieves all data from a global table.
|
|
347
|
-
* @param {string} tableName - The table name to retrieve data from.
|
|
348
|
-
* @param {string} [password] - Optional password for private holon.
|
|
349
|
-
* @returns {Promise<Array<any>>} - The parsed data from the table as an array.
|
|
350
|
-
*/
|
|
351
|
-
getAllGlobal(tableName: string, password?: string | null): Promise<Array<any>>;
|
|
352
|
-
|
|
353
|
-
/**
|
|
354
|
-
* Deletes a specific key from a global table.
|
|
355
|
-
* @param {string} tableName - The table name to delete from.
|
|
356
|
-
* @param {string} key - The key to delete.
|
|
357
|
-
* @param {string} [password] - Optional password for private holon.
|
|
358
|
-
* @returns {Promise<boolean>} - Returns true if successful
|
|
359
|
-
*/
|
|
360
|
-
deleteGlobal(tableName: string, key: string, password?: string | null): Promise<boolean>;
|
|
361
|
-
|
|
362
|
-
/**
|
|
363
|
-
* Deletes an entire global table.
|
|
364
|
-
* @param {string} tableName - The table name to delete.
|
|
365
|
-
* @param {string} [password] - Optional password for private holon.
|
|
366
|
-
* @returns {Promise<boolean>} - Returns true if successful
|
|
367
|
-
*/
|
|
368
|
-
deleteAllGlobal(tableName: string, password?: string | null): Promise<boolean>;
|
|
369
|
-
|
|
370
|
-
// ================================ COMPUTE FUNCTIONS ================================
|
|
371
|
-
|
|
372
|
-
/**
|
|
373
|
-
* Computes operations across multiple layers up the hierarchy
|
|
374
|
-
* @param {string} holon - Starting holon identifier
|
|
375
|
-
* @param {string} lens - The lens to compute
|
|
376
|
-
* @param {object} options - Computation options
|
|
377
|
-
* @param {number} [maxLevels=15] - Maximum levels to compute up
|
|
378
|
-
* @param {string} [password] - Optional password for private holons
|
|
379
|
-
* @returns {Promise<Array<any>>} - Computation results
|
|
380
|
-
*/
|
|
381
|
-
computeHierarchy(holon: string, lens: string, options: object, maxLevels?: number, password?: string | null): Promise<Array<any>>;
|
|
382
|
-
|
|
383
|
-
/**
|
|
384
|
-
* Computes operations on content within a holon and lens for one layer up.
|
|
385
|
-
* @param {string} holon - The holon identifier.
|
|
386
|
-
* @param {string} lens - The lens to compute.
|
|
387
|
-
* @param {object|string} options - Computation options or operation name
|
|
388
|
-
* @param {string} [password] - Optional password for private holons
|
|
389
|
-
* @returns {Promise<any>} - Computation result
|
|
390
|
-
*/
|
|
391
|
-
compute(holon: string, lens: string, options: object|string, password?: string | null): Promise<any>;
|
|
392
|
-
|
|
393
|
-
/**
|
|
394
|
-
* Upcasts content to parent holonagons recursively using federation and soul references.
|
|
395
|
-
* @param {string} holon - The current holon identifier.
|
|
396
|
-
* @param {string} lens - The lens under which to upcast.
|
|
397
|
-
* @param {object} content - The content to upcast.
|
|
398
|
-
* @param {number} [maxLevels=15] - Maximum levels to upcast.
|
|
399
|
-
* @returns {Promise<object>} - The original content.
|
|
400
|
-
*/
|
|
401
|
-
upcast(holon: string, lens: string, content: object, maxLevels?: number): Promise<object>;
|
|
402
|
-
|
|
403
|
-
/**
|
|
404
|
-
* Updates the parent holon with a new report.
|
|
405
|
-
* @param {string} id - The child holon identifier.
|
|
406
|
-
* @param {string} report - The report to update.
|
|
407
|
-
* @returns {Promise<object>} - The updated parent information.
|
|
408
|
-
*/
|
|
409
|
-
updateParent(id: string, report: string): Promise<object>;
|
|
410
|
-
|
|
411
|
-
// ================================ LOCATION FUNCTIONS ================================
|
|
412
|
-
|
|
413
|
-
/**
|
|
414
|
-
* Converts latitude and longitude to a holon identifier.
|
|
415
|
-
* @param {number} lat - The latitude.
|
|
416
|
-
* @param {number} lng - The longitude.
|
|
417
|
-
* @param {number} resolution - The resolution level.
|
|
418
|
-
* @returns {Promise<string>} - The resulting holon identifier.
|
|
419
|
-
*/
|
|
420
|
-
getHolon(lat: number, lng: number, resolution: number): Promise<string>;
|
|
421
|
-
|
|
422
|
-
/**
|
|
423
|
-
* Retrieves all containing holonagons at all scales for given coordinates.
|
|
424
|
-
* @param {number} lat - The latitude.
|
|
425
|
-
* @param {number} lng - The longitude.
|
|
426
|
-
* @returns {Array<string>} - List of holon identifiers.
|
|
427
|
-
*/
|
|
428
|
-
getScalespace(lat: number, lng: number): string[];
|
|
429
|
-
|
|
430
|
-
/**
|
|
431
|
-
* Retrieves all containing holonagons at all scales for a given holon.
|
|
432
|
-
* @param {string} holon - The holon identifier.
|
|
433
|
-
* @returns {Array<string>} - List of holon identifiers.
|
|
434
|
-
*/
|
|
435
|
-
getHolonScalespace(holon: string): string[];
|
|
436
|
-
|
|
437
|
-
// ================================ SUBSCRIPTION FUNCTIONS ================================
|
|
438
|
-
|
|
439
|
-
/**
|
|
440
|
-
* Subscribes to changes in a specific holon and lens.
|
|
441
|
-
* @param {string} holon - The holon identifier.
|
|
442
|
-
* @param {string} lens - The lens to subscribe to.
|
|
443
|
-
* @param {function} callback - The callback to execute on changes.
|
|
444
|
-
* @returns {Promise<object>} - Subscription object with unsubscribe method
|
|
445
|
-
*/
|
|
446
|
-
subscribe(holon: string, lens: string, callback: (data: any, key?: string) => void): Promise<{ unsubscribe: () => void }>;
|
|
447
|
-
|
|
448
|
-
// ================================ FEDERATION FUNCTIONS ================================
|
|
449
|
-
|
|
450
|
-
/**
|
|
451
|
-
* Creates a federation relationship between two holons
|
|
452
|
-
* @param {string} holonId1 - The first holon ID
|
|
453
|
-
* @param {string} holonId2 - The second holon ID
|
|
454
|
-
* @param {string} [password1] - Optional password for the first holon
|
|
455
|
-
* @param {string} [password2] - Optional password for the second holon
|
|
456
|
-
* @param {boolean} [bidirectional=true] - Whether to set up bidirectional notifications automatically
|
|
457
|
-
* @param {object} [lensConfig] - Optional lens-specific configuration
|
|
458
|
-
* @param {string[]} [lensConfig.federate] - List of lenses to federate (default: all)
|
|
459
|
-
* @param {string[]} [lensConfig.notify] - List of lenses to notify (default: all)
|
|
460
|
-
* @returns {Promise<boolean>} - True if federation was created successfully
|
|
461
|
-
*/
|
|
462
|
-
federate(holonId1: string, holonId2: string, password1?: string | null, password2?: string | null, bidirectional?: boolean, lensConfig?: { federate?: string[], notify?: string[] }): Promise<boolean>;
|
|
463
|
-
|
|
464
|
-
/**
|
|
465
|
-
* Subscribes to federation notifications for a holon
|
|
466
|
-
* @param {string} holonId - The holon ID to subscribe to
|
|
467
|
-
* @param {string} [password] - Optional password for the holon
|
|
468
|
-
* @param {function} callback - The callback to execute on notifications
|
|
469
|
-
* @param {object} [options] - Subscription options
|
|
470
|
-
* @returns {Promise<object>} - Subscription object with unsubscribe() method
|
|
471
|
-
*/
|
|
472
|
-
subscribeFederation(holonId: string, password: string | null, callback: (data: any, federatedSpace?: string, lens?: string) => void, options?: { lenses?: string[], throttle?: number }): Promise<{ unsubscribe: () => void, getSubscriptionCount: () => number }>;
|
|
473
|
-
|
|
474
|
-
/**
|
|
475
|
-
* Gets federation info for a holon
|
|
476
|
-
* @param {string} holonId - The holon ID
|
|
477
|
-
* @param {string} [password] - Optional password for the holon
|
|
478
|
-
* @returns {Promise<FederationInfo|null>} - Federation info or null if not found
|
|
479
|
-
*/
|
|
480
|
-
getFederation(holonId: string, password?: string | null): Promise<FederationInfo | null>;
|
|
481
|
-
|
|
482
|
-
/**
|
|
483
|
-
* Retrieves the lens-specific configuration for a federation link between two holons.
|
|
484
|
-
* @param {string} holonId - The ID of the source holon.
|
|
485
|
-
* @param {string} targetHolonId - The ID of the target holon in the federation link.
|
|
486
|
-
* @param {string} [password] - Optional password for the source holon.
|
|
487
|
-
* @returns {Promise<{ federate: string[], notify: string[] } | null>} - An object with 'federate' and 'notify' arrays, or null if not found.
|
|
488
|
-
*/
|
|
489
|
-
getFederatedConfig(holonId: string, targetHolonId: string, password?: string | null): Promise<{ federate: string[], notify: string[] } | null>;
|
|
490
|
-
|
|
491
|
-
/**
|
|
492
|
-
* Removes a federation relationship between holons
|
|
493
|
-
* @param {string} holonId1 - The first holon ID
|
|
494
|
-
* @param {string} holonId2 - The second holon ID
|
|
495
|
-
* @param {string} [password1] - Optional password for the first holon
|
|
496
|
-
* @param {string} [password2] - Optional password for the second holon
|
|
497
|
-
* @returns {Promise<boolean>} - True if federation was removed successfully
|
|
498
|
-
*/
|
|
499
|
-
unfederate(holonId1: string, holonId2: string, password1?: string | null, password2?: string | null): Promise<boolean>;
|
|
500
|
-
|
|
501
|
-
/**
|
|
502
|
-
* Removes a notification relationship between two spaces
|
|
503
|
-
* @param {string} holonId1 - The space to modify (remove from its notify list)
|
|
504
|
-
* @param {string} holonId2 - The space to be removed from notifications
|
|
505
|
-
* @param {string} [password1] - Optional password for the first space
|
|
506
|
-
* @returns {Promise<boolean>} - True if notification was removed successfully
|
|
507
|
-
*/
|
|
508
|
-
removeNotify(holonId1: string, holonId2: string, password1?: string | null): Promise<boolean>;
|
|
509
|
-
|
|
510
|
-
/**
|
|
511
|
-
* Get and aggregate data from federated holons
|
|
512
|
-
* @param {string} holon - The holon name
|
|
513
|
-
* @param {string} lens - The lens name
|
|
514
|
-
* @param {GetFederatedOptions} [options] - Options for retrieval and aggregation
|
|
515
|
-
* @returns {Promise<Array<any>>} - Combined array of local and federated data
|
|
516
|
-
*/
|
|
517
|
-
getFederated(holon: string, lens: string, options?: GetFederatedOptions): Promise<Array<any>>;
|
|
518
|
-
|
|
519
|
-
/**
|
|
520
|
-
* Tracks a federated message across different chats
|
|
521
|
-
* @param {string} originalChatId - The ID of the original chat
|
|
522
|
-
* @param {string} messageId - The ID of the original message
|
|
523
|
-
* @param {string} federatedChatId - The ID of the federated chat
|
|
524
|
-
* @param {string} federatedMessageId - The ID of the message in the federated chat
|
|
525
|
-
* @param {string} [type] - The type of message (e.g., 'quest', 'announcement')
|
|
526
|
-
* @returns {Promise<void>}
|
|
527
|
-
*/
|
|
528
|
-
federateMessage(originalChatId: string, messageId: string, federatedChatId: string, federatedMessageId: string, type?: string): Promise<void>;
|
|
529
|
-
|
|
530
|
-
/**
|
|
531
|
-
* Gets all federated messages for a given original message
|
|
532
|
-
* @param {string} originalChatId - The ID of the original chat
|
|
533
|
-
* @param {string} messageId - The ID of the original message
|
|
534
|
-
* @returns {Promise<object|null>} - The tracking information for the message
|
|
535
|
-
*/
|
|
536
|
-
getFederatedMessages(originalChatId: string, messageId: string): Promise<object | null>;
|
|
537
|
-
|
|
538
|
-
/**
|
|
539
|
-
* Updates a federated message across all federated chats
|
|
540
|
-
* @param {string} originalChatId - The ID of the original chat
|
|
541
|
-
* @param {string} messageId - The ID of the original message
|
|
542
|
-
* @param {Function} updateCallback - Function to update the message in each chat
|
|
543
|
-
* @returns {Promise<void>}
|
|
544
|
-
*/
|
|
545
|
-
updateFederatedMessages(originalChatId: string, messageId: string, updateCallback: (chatId: string, messageId: string) => Promise<void>): Promise<void>;
|
|
546
|
-
|
|
547
|
-
/**
|
|
548
|
-
* Resets the federation settings for a holon
|
|
549
|
-
* @param {string} holonId - The holon ID
|
|
550
|
-
* @param {string} [password] - Optional password for the holon
|
|
551
|
-
* @returns {Promise<boolean>} - True if federation was reset successfully
|
|
552
|
-
*/
|
|
553
|
-
resetFederation(holonId: string, password?: string | null): Promise<boolean>;
|
|
554
|
-
|
|
555
|
-
// ================================ RADISK FUNCTIONS ================================
|
|
556
|
-
|
|
557
|
-
/**
|
|
558
|
-
* Configures radisk storage options for GunDB.
|
|
559
|
-
* @param {object} options - Radisk configuration options
|
|
560
|
-
* @param {string} [options.file='./radata'] - Directory for radisk storage
|
|
561
|
-
* @param {boolean} [options.radisk=true] - Whether to enable radisk storage
|
|
562
|
-
* @param {number} [options.until] - Timestamp until which to keep data
|
|
563
|
-
* @param {number} [options.retry] - Number of retries for failed operations
|
|
564
|
-
* @param {number} [options.timeout] - Timeout for operations in milliseconds
|
|
565
|
-
*/
|
|
566
|
-
configureRadisk(options?: {
|
|
567
|
-
file?: string;
|
|
568
|
-
radisk?: boolean;
|
|
569
|
-
until?: number;
|
|
570
|
-
retry?: number;
|
|
571
|
-
timeout?: number;
|
|
572
|
-
}): void;
|
|
573
|
-
|
|
574
|
-
/**
|
|
575
|
-
* Gets radisk storage statistics and information.
|
|
576
|
-
* @returns {object} Radisk statistics including file path, enabled status, and storage info
|
|
577
|
-
*/
|
|
578
|
-
getRadiskStats(): {
|
|
579
|
-
enabled: boolean;
|
|
580
|
-
filePath: string;
|
|
581
|
-
retry: number;
|
|
582
|
-
timeout: number;
|
|
583
|
-
until: number | null;
|
|
584
|
-
peers: string[];
|
|
585
|
-
localStorage: boolean;
|
|
586
|
-
error?: string;
|
|
587
|
-
};
|
|
588
|
-
|
|
589
|
-
// ================================ UTILITY FUNCTIONS ================================
|
|
590
|
-
|
|
591
|
-
/**
|
|
592
|
-
* Generates a unique ID for data items
|
|
593
|
-
* @returns {string} A unique ID
|
|
594
|
-
*/
|
|
595
|
-
generateId(): string;
|
|
596
|
-
|
|
597
|
-
/**
|
|
598
|
-
* Closes the HoloSphere instance and cleans up resources.
|
|
599
|
-
* @returns {Promise<void>}
|
|
600
|
-
*/
|
|
601
|
-
close(): Promise<void>;
|
|
602
|
-
}
|
|
603
|
-
|
|
604
|
-
export default HoloSphere;
|