holosphere 1.1.6 → 1.1.7

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/holosphere.d.ts CHANGED
@@ -1,43 +1,468 @@
1
+ /**
2
+ * Federation propagation options interface
3
+ */
4
+ interface PropagationOptions {
5
+ /** Whether to use references instead of duplicating data (default: true) */
6
+ useReferences?: 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
+ }
12
+
13
+ /**
14
+ * Put options interface
15
+ */
16
+ interface PutOptions {
17
+ /** Whether to automatically propagate to federated spaces (default: false) */
18
+ autoPropagate?: boolean;
19
+ /** Additional options to pass to propagate */
20
+ propagationOptions?: PropagationOptions;
21
+ }
22
+
23
+ /**
24
+ * Get options interface
25
+ */
26
+ interface GetOptions {
27
+ /** Whether to automatically resolve federation references (default: true) */
28
+ resolveReferences?: boolean;
29
+ }
30
+
31
+ /**
32
+ * Federation info interface
33
+ */
34
+ interface FederationInfo {
35
+ /** Identifier of the holon */
36
+ id: string;
37
+ /** Name of the holon */
38
+ name: string;
39
+ /** List of federated space IDs (spaces this holon federates with) */
40
+ federation: string[];
41
+ /** List of spaces to notify about changes */
42
+ notify: string[];
43
+ /** Timestamp of last update */
44
+ timestamp: number;
45
+ }
46
+
47
+ /**
48
+ * Options for federated data retrieval
49
+ */
50
+ interface GetFederatedOptions {
51
+ /** Whether to aggregate results by ID */
52
+ aggregate?: boolean;
53
+ /** Field to use as ID */
54
+ idField?: string;
55
+ /** Fields to sum during aggregation */
56
+ sumFields?: string[];
57
+ /** Array fields to concatenate during aggregation */
58
+ concatArrays?: string[];
59
+ /** Whether to remove duplicates in concatenated arrays */
60
+ removeDuplicates?: boolean;
61
+ /** Custom merge function for aggregation */
62
+ mergeStrategy?: (items: any[]) => any;
63
+ /** Whether to include local data */
64
+ includeLocal?: boolean;
65
+ /** Whether to include federated data */
66
+ includeFederated?: boolean;
67
+ /** Whether to resolve federation references */
68
+ resolveReferences?: boolean;
69
+ /** Maximum number of federated spaces to query */
70
+ maxFederatedSpaces?: number;
71
+ /** Timeout in milliseconds for federated queries */
72
+ timeout?: number;
73
+ }
74
+
75
+ /**
76
+ * Results from a propagation operation
77
+ */
78
+ interface PropagationResult {
79
+ /** Number of successfully propagated items */
80
+ success: number;
81
+ /** Number of errors encountered */
82
+ errors: number;
83
+ /** Details about errors */
84
+ errorDetails: Array<{ space: string, error: string }>;
85
+ /** Whether any propagation occurred */
86
+ propagated: boolean;
87
+ /** Whether references were used */
88
+ referencesUsed: boolean;
89
+ /** Error message if applicable */
90
+ error?: string;
91
+ /** Information message if applicable */
92
+ message?: string;
93
+ }
94
+
1
95
  declare class HoloSphere {
2
96
  private appname;
3
97
  private strict;
4
98
  private validator;
5
99
  private gun;
100
+ private sea;
6
101
  private openai?;
102
+ private subscriptions;
103
+
7
104
  /**
8
105
  * Initializes a new instance of the HoloSphere class.
9
106
  * @param {string} appname - The name of the application.
10
107
  * @param {boolean} strict - Whether to enforce strict schema validation.
11
108
  * @param {string|null} openaikey - The OpenAI API key.
109
+ * @param {object|null} gunInstance - The Gun instance to use.
110
+ */
111
+ constructor(appname: string, strict?: boolean, openaikey?: string | null, gunInstance?: any);
112
+
113
+ // ================================ SCHEMA FUNCTIONS ================================
114
+
115
+ /**
116
+ * Sets the JSON schema for a specific lens.
117
+ * @param {string} lens - The lens identifier.
118
+ * @param {object} schema - The JSON schema to set.
119
+ * @returns {Promise<boolean>} - Resolves when the schema is set.
12
120
  */
13
- constructor(appname: string, strict?: boolean, openaikey?: string | null);
14
121
  setSchema(lens: string, schema: object): Promise<boolean>;
122
+
123
+ /**
124
+ * Retrieves the JSON schema for a specific lens.
125
+ * @param {string} lens - The lens identifier.
126
+ * @returns {Promise<object|null>} - The retrieved schema or null if not found.
127
+ */
15
128
  getSchema(lens: string): Promise<object | null>;
16
- put(holon: string, lens: string, data: object): Promise<boolean>;
17
- get(holon: string, lens: string, key: string): Promise<any | null>;
18
- getAll(holon: string, lens: string): Promise<Array<any>>;
19
- delete(holon: string, lens: string, key: string): Promise<void>;
20
- deleteAll(holon: string, lens: string): Promise<boolean>;
21
- putNode(holon: string, lens: string, node: object): Promise<boolean>;
129
+
130
+ // ================================ CONTENT FUNCTIONS ================================
131
+
132
+ /**
133
+ * Stores content in the specified holon and lens.
134
+ * @param {string} holon - The holon identifier.
135
+ * @param {string} lens - The lens under which to store the content.
136
+ * @param {object} data - The data to store.
137
+ * @param {string} [password] - Optional password for private holon.
138
+ * @param {PutOptions} [options] - Additional options
139
+ * @returns {Promise<any>} - Returns result object if successful
140
+ */
141
+ put(holon: string, lens: string, data: object, password?: string | null, options?: PutOptions): Promise<any>;
142
+
143
+ /**
144
+ * Retrieves content from the specified holon and lens.
145
+ * @param {string} holon - The holon identifier.
146
+ * @param {string} lens - The lens from which to retrieve content.
147
+ * @param {string} key - The specific key to retrieve.
148
+ * @param {string} [password] - Optional password for private holon.
149
+ * @param {GetOptions} [options] - Additional options
150
+ * @returns {Promise<any|null>} - The retrieved content or null if not found.
151
+ */
152
+ get(holon: string, lens: string, key: string, password?: string | null, options?: GetOptions): Promise<any | null>;
153
+
154
+ /**
155
+ * Retrieves a node directly using its soul path
156
+ * @param {string} soul - The soul path of the node
157
+ * @returns {Promise<any>} - The retrieved node or null if not found.
158
+ */
159
+ getNodeBySoul(soul: string): Promise<any>;
160
+
161
+ /**
162
+ * Propagates data to federated holons
163
+ * @param {string} holon - The holon identifier
164
+ * @param {string} lens - The lens identifier
165
+ * @param {object} data - The data to propagate
166
+ * @param {PropagationOptions} [options] - Propagation options
167
+ * @returns {Promise<PropagationResult>} - Result with success count and errors
168
+ */
169
+ propagate(holon: string, lens: string, data: object, options?: PropagationOptions): Promise<PropagationResult>;
170
+
171
+ /**
172
+ * Retrieves all content from the specified holon and lens.
173
+ * @param {string} holon - The holon identifier.
174
+ * @param {string} lens - The lens from which to retrieve content.
175
+ * @param {string} [password] - Optional password for private holon.
176
+ * @returns {Promise<Array<any>>} - The retrieved content.
177
+ */
178
+ getAll(holon: string, lens: string, password?: string | null): Promise<Array<any>>;
179
+
180
+ /**
181
+ * Deletes a specific key from a given holon and lens.
182
+ * @param {string} holon - The holon identifier.
183
+ * @param {string} lens - The lens from which to delete the key.
184
+ * @param {string} key - The specific key to delete.
185
+ * @param {string} [password] - Optional password for private holon.
186
+ * @returns {Promise<boolean>} - Returns true if successful
187
+ */
188
+ delete(holon: string, lens: string, key: string, password?: string | null): Promise<boolean>;
189
+
190
+ /**
191
+ * Deletes all keys from a given holon and lens.
192
+ * @param {string} holon - The holon identifier.
193
+ * @param {string} lens - The lens from which to delete all keys.
194
+ * @param {string} [password] - Optional password for private holon.
195
+ * @returns {Promise<boolean>} - Returns true if successful
196
+ */
197
+ deleteAll(holon: string, lens: string, password?: string | null): Promise<boolean>;
198
+
199
+ // ================================ NODE FUNCTIONS ================================
200
+
201
+ /**
202
+ * Stores a specific gun node in a given holon and lens.
203
+ * @param {string} holon - The holon identifier.
204
+ * @param {string} lens - The lens under which to store the node.
205
+ * @param {object} data - The node to store.
206
+ * @returns {Promise<boolean>} - Returns true if successful
207
+ */
208
+ putNode(holon: string, lens: string, data: object): Promise<boolean>;
209
+
210
+ /**
211
+ * Retrieves a specific gun node from the specified holon and lens.
212
+ * @param {string} holon - The holon identifier.
213
+ * @param {string} lens - The lens identifier.
214
+ * @param {string} key - The specific key to retrieve.
215
+ * @returns {Promise<any|null>} - The retrieved node or null if not found.
216
+ */
22
217
  getNode(holon: string, lens: string, key: string): Promise<any | null>;
218
+
219
+ /**
220
+ * Gets a Gun reference to a node by its soul
221
+ * @param {string} soul - The soul path
222
+ * @returns {any} - A Gun reference to the node
223
+ */
224
+ getNodeRef(soul: string): any;
225
+
226
+ /**
227
+ * Deletes a specific gun node from a given holon and lens.
228
+ * @param {string} holon - The holon identifier.
229
+ * @param {string} lens - The lens identifier.
230
+ * @param {string} key - The key of the node to delete.
231
+ * @returns {Promise<boolean>} - Returns true if successful
232
+ */
23
233
  deleteNode(holon: string, lens: string, key: string): Promise<boolean>;
24
- putGlobal(tableName: string, data: object): Promise<void>;
25
- getGlobal(tableName: string, key: string): Promise<object | null>;
26
- getAllGlobal(tableName: string): Promise<object | null>;
27
- deleteGlobal(tableName: string, key: string): Promise<void>;
28
- deleteAllGlobal(tableName: string): Promise<void>;
234
+
235
+ // ================================ GLOBAL FUNCTIONS ================================
236
+
237
+ /**
238
+ * Stores data in a global (non-holon-specific) table.
239
+ * @param {string} tableName - The table name to store data in.
240
+ * @param {object} data - The data to store. If it has an 'id' field, it will be used as the key.
241
+ * @param {string} [password] - Optional password for private holon.
242
+ * @returns {Promise<void>}
243
+ */
244
+ putGlobal(tableName: string, data: object, password?: string | null): Promise<void>;
245
+
246
+ /**
247
+ * Retrieves a specific key from a global table.
248
+ * @param {string} tableName - The table name to retrieve from.
249
+ * @param {string} key - The key to retrieve.
250
+ * @param {string} [password] - Optional password for private holon.
251
+ * @returns {Promise<any|null>} - The parsed data for the key or null if not found.
252
+ */
253
+ getGlobal(tableName: string, key: string, password?: string | null): Promise<any | null>;
254
+
255
+ /**
256
+ * Retrieves all data from a global table.
257
+ * @param {string} tableName - The table name to retrieve data from.
258
+ * @param {string} [password] - Optional password for private holon.
259
+ * @returns {Promise<Array<any>>} - The parsed data from the table as an array.
260
+ */
261
+ getAllGlobal(tableName: string, password?: string | null): Promise<Array<any>>;
262
+
263
+ /**
264
+ * Deletes a specific key from a global table.
265
+ * @param {string} tableName - The table name to delete from.
266
+ * @param {string} key - The key to delete.
267
+ * @param {string} [password] - Optional password for private holon.
268
+ * @returns {Promise<boolean>} - Returns true if successful
269
+ */
270
+ deleteGlobal(tableName: string, key: string, password?: string | null): Promise<boolean>;
271
+
272
+ /**
273
+ * Deletes an entire global table.
274
+ * @param {string} tableName - The table name to delete.
275
+ * @param {string} [password] - Optional password for private holon.
276
+ * @returns {Promise<boolean>} - Returns true if successful
277
+ */
278
+ deleteAllGlobal(tableName: string, password?: string | null): Promise<boolean>;
279
+
280
+ // ================================ COMPUTE FUNCTIONS ================================
281
+
282
+ /**
283
+ * Computes operations across multiple layers up the hierarchy
284
+ * @param {string} holon - Starting holon identifier
285
+ * @param {string} lens - The lens to compute
286
+ * @param {object} options - Computation options
287
+ * @param {number} [maxLevels=15] - Maximum levels to compute up
288
+ * @param {string} [password] - Optional password for private holons
289
+ * @returns {Promise<Array<any>>} - Computation results
290
+ */
291
+ computeHierarchy(holon: string, lens: string, options: object, maxLevels?: number, password?: string | null): Promise<Array<any>>;
292
+
293
+ /**
294
+ * Computes operations on content within a holon and lens for one layer up.
295
+ * @param {string} holon - The holon identifier.
296
+ * @param {string} lens - The lens to compute.
297
+ * @param {object|string} options - Computation options or operation name
298
+ * @param {string} [password] - Optional password for private holons
299
+ * @returns {Promise<any>} - Computation result
300
+ */
301
+ compute(holon: string, lens: string, options: object|string, password?: string | null): Promise<any>;
302
+
303
+ /**
304
+ * Upcasts content to parent holonagons recursively using federation and soul references.
305
+ * @param {string} holon - The current holon identifier.
306
+ * @param {string} lens - The lens under which to upcast.
307
+ * @param {object} content - The content to upcast.
308
+ * @param {number} [maxLevels=15] - Maximum levels to upcast.
309
+ * @returns {Promise<object>} - The original content.
310
+ */
311
+ upcast(holon: string, lens: string, content: object, maxLevels?: number): Promise<object>;
312
+
313
+ /**
314
+ * Updates the parent holon with a new report.
315
+ * @param {string} id - The child holon identifier.
316
+ * @param {string} report - The report to update.
317
+ * @returns {Promise<object>} - The updated parent information.
318
+ */
319
+ updateParent(id: string, report: string): Promise<object>;
320
+
321
+ // ================================ LOCATION FUNCTIONS ================================
322
+
323
+ /**
324
+ * Converts latitude and longitude to a holon identifier.
325
+ * @param {number} lat - The latitude.
326
+ * @param {number} lng - The longitude.
327
+ * @param {number} resolution - The resolution level.
328
+ * @returns {Promise<string>} - The resulting holon identifier.
329
+ */
29
330
  getHolon(lat: number, lng: number, resolution: number): Promise<string>;
331
+
332
+ /**
333
+ * Retrieves all containing holonagons at all scales for given coordinates.
334
+ * @param {number} lat - The latitude.
335
+ * @param {number} lng - The longitude.
336
+ * @returns {Array<string>} - List of holon identifiers.
337
+ */
30
338
  getScalespace(lat: number, lng: number): string[];
339
+
340
+ /**
341
+ * Retrieves all containing holonagons at all scales for a given holon.
342
+ * @param {string} holon - The holon identifier.
343
+ * @returns {Array<string>} - List of holon identifiers.
344
+ */
31
345
  getHolonScalespace(holon: string): string[];
32
- compute(holon: string, lens: string, operation: string): Promise<void>;
33
- private parse;
34
- subscribe(holon: string, lens: string, callback: (data: any, key: string) => void): void;
35
- subscribeGlobal(tableName: string, callback: (data: any, key: string) => void): void;
346
+
347
+ // ================================ SUBSCRIPTION FUNCTIONS ================================
348
+
349
+ /**
350
+ * Subscribes to changes in a specific holon and lens.
351
+ * @param {string} holon - The holon identifier.
352
+ * @param {string} lens - The lens to subscribe to.
353
+ * @param {function} callback - The callback to execute on changes.
354
+ * @returns {Promise<object>} - Subscription object with unsubscribe method
355
+ */
356
+ subscribe(holon: string, lens: string, callback: (data: any, key?: string) => void): Promise<{ unsubscribe: () => void }>;
357
+
358
+ // ================================ FEDERATION FUNCTIONS ================================
359
+
360
+ /**
361
+ * Creates a federation relationship between two holons
362
+ * @param {string} holonId1 - The first holon ID
363
+ * @param {string} holonId2 - The second holon ID
364
+ * @param {string} [password1] - Optional password for the first holon
365
+ * @param {string} [password2] - Optional password for the second holon
366
+ * @param {boolean} [bidirectional=true] - Whether to set up bidirectional notifications automatically
367
+ * @returns {Promise<boolean>} - True if federation was created successfully
368
+ */
369
+ federate(holonId1: string, holonId2: string, password1?: string | null, password2?: string | null, bidirectional?: boolean): Promise<boolean>;
370
+
371
+ /**
372
+ * Subscribes to federation notifications for a holon
373
+ * @param {string} holonId - The holon ID to subscribe to
374
+ * @param {string} [password] - Optional password for the holon
375
+ * @param {function} callback - The callback to execute on notifications
376
+ * @param {object} [options] - Subscription options
377
+ * @returns {Promise<object>} - Subscription object with unsubscribe() method
378
+ */
379
+ subscribeFederation(holonId: string, password: string | null, callback: (data: any, federatedSpace?: string, lens?: string) => void, options?: { lenses?: string[], throttle?: number }): Promise<{ unsubscribe: () => void, getSubscriptionCount: () => number }>;
380
+
381
+ /**
382
+ * Gets federation info for a holon
383
+ * @param {string} holonId - The holon ID
384
+ * @param {string} [password] - Optional password for the holon
385
+ * @returns {Promise<FederationInfo|null>} - Federation info or null if not found
386
+ */
387
+ getFederation(holonId: string, password?: string | null): Promise<FederationInfo | null>;
388
+
389
+ /**
390
+ * Removes a federation relationship between holons
391
+ * @param {string} holonId1 - The first holon ID
392
+ * @param {string} holonId2 - The second holon ID
393
+ * @param {string} [password1] - Optional password for the first holon
394
+ * @param {string} [password2] - Optional password for the second holon
395
+ * @returns {Promise<boolean>} - True if federation was removed successfully
396
+ */
397
+ unfederate(holonId1: string, holonId2: string, password1?: string | null, password2?: string | null): Promise<boolean>;
398
+
399
+ /**
400
+ * Removes a notification relationship between two spaces
401
+ * @param {string} holonId1 - The space to modify (remove from its notify list)
402
+ * @param {string} holonId2 - The space to be removed from notifications
403
+ * @param {string} [password1] - Optional password for the first space
404
+ * @returns {Promise<boolean>} - True if notification was removed successfully
405
+ */
406
+ removeNotify(holonId1: string, holonId2: string, password1?: string | null): Promise<boolean>;
407
+
408
+ /**
409
+ * Get and aggregate data from federated holons
410
+ * @param {string} holon - The holon name
411
+ * @param {string} lens - The lens name
412
+ * @param {GetFederatedOptions} [options] - Options for retrieval and aggregation
413
+ * @returns {Promise<Array<any>>} - Combined array of local and federated data
414
+ */
415
+ getFederated(holon: string, lens: string, options?: GetFederatedOptions): Promise<Array<any>>;
416
+
417
+ /**
418
+ * Tracks a federated message across different chats
419
+ * @param {string} originalChatId - The ID of the original chat
420
+ * @param {string} messageId - The ID of the original message
421
+ * @param {string} federatedChatId - The ID of the federated chat
422
+ * @param {string} federatedMessageId - The ID of the message in the federated chat
423
+ * @param {string} [type] - The type of message (e.g., 'quest', 'announcement')
424
+ * @returns {Promise<void>}
425
+ */
426
+ federateMessage(originalChatId: string, messageId: string, federatedChatId: string, federatedMessageId: string, type?: string): Promise<void>;
427
+
428
+ /**
429
+ * Gets all federated messages for a given original message
430
+ * @param {string} originalChatId - The ID of the original chat
431
+ * @param {string} messageId - The ID of the original message
432
+ * @returns {Promise<object|null>} - The tracking information for the message
433
+ */
434
+ getFederatedMessages(originalChatId: string, messageId: string): Promise<object | null>;
435
+
436
+ /**
437
+ * Updates a federated message across all federated chats
438
+ * @param {string} originalChatId - The ID of the original chat
439
+ * @param {string} messageId - The ID of the original message
440
+ * @param {Function} updateCallback - Function to update the message in each chat
441
+ * @returns {Promise<void>}
442
+ */
443
+ updateFederatedMessages(originalChatId: string, messageId: string, updateCallback: (chatId: string, messageId: string) => Promise<void>): Promise<void>;
444
+
445
+ /**
446
+ * Resets the federation settings for a holon
447
+ * @param {string} holonId - The holon ID
448
+ * @param {string} [password] - Optional password for the holon
449
+ * @returns {Promise<boolean>} - True if federation was reset successfully
450
+ */
451
+ resetFederation(holonId: string, password?: string | null): Promise<boolean>;
452
+
453
+ // ================================ UTILITY FUNCTIONS ================================
454
+
455
+ /**
456
+ * Generates a unique ID for data items
457
+ * @returns {string} A unique ID
458
+ */
459
+ generateId(): string;
460
+
36
461
  /**
37
- * Summarizes provided history text using OpenAI.
38
- * @param {string} history - The history text to summarize.
39
- * @returns {Promise<string>} - The summarized text.
462
+ * Closes the HoloSphere instance and cleans up resources.
463
+ * @returns {Promise<void>}
40
464
  */
41
- private summarize;
465
+ close(): Promise<void>;
42
466
  }
467
+
43
468
  export default HoloSphere;