holosphere 1.1.10 → 1.1.11
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/.cursor/rules/futura.mdc +55 -0
- package/FEDERATION.md +17 -17
- package/compute.js +289 -0
- package/content.js +797 -0
- package/examples/federation.js +98 -90
- package/examples/{references.js → holograms.js} +49 -51
- package/federation.js +272 -208
- package/global.js +560 -0
- package/hologram.js +156 -0
- package/holosphere.d.ts +94 -7
- package/holosphere.js +172 -1565
- package/node.js +155 -0
- package/package.json +2 -5
- package/schema.js +132 -0
- package/test/auth.test.js +55 -37
- package/test/delete.test.js +15 -12
- package/test/federation.test.js +179 -0
- package/test/hologram.test.js +316 -0
- package/test/subscription.test.js +105 -70
- package/utils.js +290 -0
- package/test/reference.test.js +0 -211
package/test/reference.test.js
DELETED
|
@@ -1,211 +0,0 @@
|
|
|
1
|
-
import HoloSphere from '../holosphere.js';
|
|
2
|
-
import { jest } from '@jest/globals';
|
|
3
|
-
|
|
4
|
-
// Configure timeout
|
|
5
|
-
jest.setTimeout(30000); // 30 second timeout
|
|
6
|
-
|
|
7
|
-
// Setup
|
|
8
|
-
describe('HoloSphere Reference System', () => {
|
|
9
|
-
let holoSphere;
|
|
10
|
-
|
|
11
|
-
beforeEach(async () => {
|
|
12
|
-
// Create a new HoloSphere instance for each test
|
|
13
|
-
holoSphere = new HoloSphere('testApp');
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
afterEach(async () => {
|
|
17
|
-
// Clean up after each test
|
|
18
|
-
if (holoSphere) {
|
|
19
|
-
await holoSphere.close();
|
|
20
|
-
// Wait for connections to close
|
|
21
|
-
await new Promise(resolve => setTimeout(resolve, 500));
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
test('should create and parse a reference correctly', async () => {
|
|
26
|
-
// Test data
|
|
27
|
-
const holon = 'testHolon';
|
|
28
|
-
const lens = 'testLens';
|
|
29
|
-
const data = {
|
|
30
|
-
id: 'test-data-123',
|
|
31
|
-
title: 'Test Data',
|
|
32
|
-
content: 'This is test content'
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
// Create a reference
|
|
36
|
-
const reference = holoSphere.createReference(holon, lens, data);
|
|
37
|
-
|
|
38
|
-
// Validate reference structure
|
|
39
|
-
expect(reference).toBeTruthy();
|
|
40
|
-
expect(reference.id).toBe(data.id);
|
|
41
|
-
expect(reference.soul).toBe(`testApp/${holon}/${lens}/${data.id}`);
|
|
42
|
-
|
|
43
|
-
// Test soul path parsing
|
|
44
|
-
const soulInfo = holoSphere.parseSoulPath(reference.soul);
|
|
45
|
-
expect(soulInfo).toBeTruthy();
|
|
46
|
-
expect(soulInfo.appname).toBe('testApp');
|
|
47
|
-
expect(soulInfo.holon).toBe(holon);
|
|
48
|
-
expect(soulInfo.lens).toBe(lens);
|
|
49
|
-
expect(soulInfo.key).toBe(data.id);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
test('should detect different types of references correctly', async () => {
|
|
53
|
-
// Soul reference
|
|
54
|
-
const soulReference = {
|
|
55
|
-
id: 'test-data-123',
|
|
56
|
-
soul: 'testApp/testHolon/testLens/test-data-123'
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
// Legacy federation reference
|
|
60
|
-
const legacyReference = {
|
|
61
|
-
id: 'test-data-456',
|
|
62
|
-
_federation: {
|
|
63
|
-
isReference: true,
|
|
64
|
-
origin: 'originHolon',
|
|
65
|
-
lens: 'originLens'
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
// Regular data (not a reference)
|
|
70
|
-
const regularData = {
|
|
71
|
-
id: 'test-data-789',
|
|
72
|
-
title: 'Regular Data',
|
|
73
|
-
content: 'This is not a reference'
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
// Test reference detection
|
|
77
|
-
expect(holoSphere.isReference(soulReference)).toBe(true);
|
|
78
|
-
expect(holoSphere.isReference(legacyReference)).toBe(true);
|
|
79
|
-
expect(holoSphere.isReference(regularData)).toBe(false);
|
|
80
|
-
expect(holoSphere.isReference(null)).toBe(false);
|
|
81
|
-
expect(holoSphere.isReference(undefined)).toBe(false);
|
|
82
|
-
expect(holoSphere.isReference("not an object")).toBe(false);
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
test('should store and retrieve references properly', async () => {
|
|
86
|
-
// Original data
|
|
87
|
-
const originalData = {
|
|
88
|
-
id: 'original-123',
|
|
89
|
-
title: 'Original Data',
|
|
90
|
-
content: 'This is the original content'
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
// Store original data
|
|
94
|
-
await holoSphere.put('originHolon', 'testLens', originalData);
|
|
95
|
-
|
|
96
|
-
// Create a reference to the original data
|
|
97
|
-
const reference = holoSphere.createReference('originHolon', 'testLens', originalData);
|
|
98
|
-
|
|
99
|
-
// Store the reference in a different holon
|
|
100
|
-
await holoSphere.put('referenceHolon', 'testLens', reference);
|
|
101
|
-
|
|
102
|
-
// Retrieve the reference with resolution enabled (default)
|
|
103
|
-
const resolvedData = await holoSphere.get('referenceHolon', 'testLens', 'original-123');
|
|
104
|
-
|
|
105
|
-
// Verify the original data is present
|
|
106
|
-
expect(resolvedData).toBeTruthy();
|
|
107
|
-
expect(resolvedData.title).toBe(originalData.title);
|
|
108
|
-
expect(resolvedData.content).toBe(originalData.content);
|
|
109
|
-
|
|
110
|
-
// Verify the federation metadata is present
|
|
111
|
-
expect(resolvedData._federation).toBeTruthy();
|
|
112
|
-
expect(resolvedData._federation.isReference).toBe(true);
|
|
113
|
-
expect(resolvedData._federation.resolved).toBe(true);
|
|
114
|
-
expect(resolvedData._federation.soul).toBe(reference.soul);
|
|
115
|
-
expect(resolvedData._federation.timestamp).toBeGreaterThan(0);
|
|
116
|
-
|
|
117
|
-
// Retrieve the reference without resolution
|
|
118
|
-
const unresolvedData = await holoSphere.get('referenceHolon', 'testLens', 'original-123', null, {
|
|
119
|
-
resolveReferences: false
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
// Verify we got the actual reference
|
|
123
|
-
expect(unresolvedData).toBeTruthy();
|
|
124
|
-
expect(unresolvedData.id).toBe('original-123');
|
|
125
|
-
expect(unresolvedData.soul).toBe(reference.soul);
|
|
126
|
-
expect(unresolvedData.title).toBeUndefined();
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
test('should update original data and have references reflect the changes', async () => {
|
|
130
|
-
// Original data
|
|
131
|
-
const originalData = {
|
|
132
|
-
id: 'original-456',
|
|
133
|
-
title: 'Original Data',
|
|
134
|
-
content: 'This content will be updated'
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
// Store original data
|
|
138
|
-
await holoSphere.put('originHolon', 'testLens', originalData);
|
|
139
|
-
|
|
140
|
-
// Create a reference
|
|
141
|
-
const reference = holoSphere.createReference('originHolon', 'testLens', originalData);
|
|
142
|
-
|
|
143
|
-
// Store the reference in a different holon
|
|
144
|
-
await holoSphere.put('referenceHolon', 'testLens', reference);
|
|
145
|
-
|
|
146
|
-
// Update the original data
|
|
147
|
-
const updatedData = {
|
|
148
|
-
...originalData,
|
|
149
|
-
title: 'Updated Data',
|
|
150
|
-
content: 'This content has been updated'
|
|
151
|
-
};
|
|
152
|
-
await holoSphere.put('originHolon', 'testLens', updatedData);
|
|
153
|
-
|
|
154
|
-
// Retrieve the reference
|
|
155
|
-
const resolvedData = await holoSphere.get('referenceHolon', 'testLens', 'original-456');
|
|
156
|
-
|
|
157
|
-
// Verify the reference resolves to the updated data
|
|
158
|
-
expect(resolvedData).toBeTruthy();
|
|
159
|
-
expect(resolvedData.title).toBe('Updated Data');
|
|
160
|
-
expect(resolvedData.content).toBe('This content has been updated');
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
test('should create and use manual references across holons', async () => {
|
|
164
|
-
// Original data to reference
|
|
165
|
-
const originalData = {
|
|
166
|
-
id: 'federated-123',
|
|
167
|
-
title: 'Federated Data',
|
|
168
|
-
content: 'This content should be referenced'
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
// Store original data
|
|
172
|
-
await holoSphere.put('sourceHolon', 'testLens', originalData);
|
|
173
|
-
|
|
174
|
-
// Create a reference to the original data
|
|
175
|
-
const reference = holoSphere.createReference('sourceHolon', 'testLens', originalData);
|
|
176
|
-
|
|
177
|
-
// Store reference in the target holon
|
|
178
|
-
await holoSphere.put('targetHolon', 'testLens', reference);
|
|
179
|
-
|
|
180
|
-
// Retrieve the reference with resolution
|
|
181
|
-
const resolvedData = await holoSphere.get('targetHolon', 'testLens', 'federated-123');
|
|
182
|
-
|
|
183
|
-
// Verify the reference was resolved to the original data
|
|
184
|
-
expect(resolvedData).toBeTruthy();
|
|
185
|
-
expect(resolvedData.title).toBe('Federated Data');
|
|
186
|
-
expect(resolvedData.content).toBe('This content should be referenced');
|
|
187
|
-
expect(resolvedData._federation).toBeTruthy();
|
|
188
|
-
expect(resolvedData._federation.isReference).toBe(true);
|
|
189
|
-
expect(resolvedData._federation.resolved).toBe(true);
|
|
190
|
-
expect(resolvedData._federation.soul).toBe(reference.soul);
|
|
191
|
-
|
|
192
|
-
// Update original data
|
|
193
|
-
const updatedData = {
|
|
194
|
-
...originalData,
|
|
195
|
-
title: 'Updated Data',
|
|
196
|
-
content: 'This content has been updated'
|
|
197
|
-
};
|
|
198
|
-
await holoSphere.put('sourceHolon', 'testLens', updatedData);
|
|
199
|
-
|
|
200
|
-
// Add a delay to ensure data is updated
|
|
201
|
-
await new Promise(resolve => setTimeout(resolve, 500));
|
|
202
|
-
|
|
203
|
-
// Retrieve the reference again
|
|
204
|
-
const updatedResolvedData = await holoSphere.get('targetHolon', 'testLens', 'federated-123');
|
|
205
|
-
|
|
206
|
-
// Verify the update was reflected via the reference
|
|
207
|
-
expect(updatedResolvedData).toBeTruthy();
|
|
208
|
-
expect(updatedResolvedData.title).toBe('Updated Data');
|
|
209
|
-
expect(updatedResolvedData.content).toBe('This content has been updated');
|
|
210
|
-
});
|
|
211
|
-
});
|