@coasys/ad4m 0.13.0-test-6 → 0.13.0-test-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/lib/index.cjs +111 -36
- package/lib/index.js +111 -36
- package/lib/src/model/Ad4mModel.d.ts +15 -0
- package/lib/src/model/Ad4mModel.js +94 -28
- package/lib/src/model/Ad4mModel.test.js +1434 -688
- package/lib/src/model/ModelQueryBuilder.js +17 -8
- package/lib/src/model/Subject.js +6 -6
- package/lib/src/model/hydration-batch.d.ts +34 -0
- package/lib/src/model/hydration-batch.js +147 -0
- package/lib/src/model/hydration-batching.test.d.ts +7 -0
- package/lib/src/model/hydration-batching.test.js +456 -0
- package/lib/src/model/model-manifest.d.ts +41 -0
- package/lib/src/model/model-manifest.js +11 -0
- package/lib/src/model/query-cache.test.d.ts +1 -0
- package/lib/src/model/query-cache.test.js +43 -0
- package/lib/src/model/query-sparql-batch.d.ts +17 -0
- package/lib/src/model/query-sparql-batch.js +260 -0
- package/lib/src/model/query-sparql.test.d.ts +1 -0
- package/lib/src/model/query-sparql.test.js +312 -0
- package/lib/src/model/relation-filtering.test.js +15 -15
- package/lib/src/model/subscription-delta.test.d.ts +24 -0
- package/lib/src/model/subscription-delta.test.js +180 -0
- package/lib/src/model/subscription-pool.d.ts +39 -0
- package/lib/src/model/subscription-pool.js +165 -0
- package/lib/src/perspectives/PerspectiveClient.test.d.ts +1 -0
- package/lib/src/perspectives/PerspectiveClient.test.js +224 -0
- package/lib/src/perspectives/PerspectiveResolver.d.ts +0 -1
- package/lib/src/perspectives/PerspectiveResolver.js +0 -11
- package/lib/src/runtime/RuntimeResolver.d.ts +28 -1
- package/lib/src/runtime/RuntimeResolver.js +197 -4
- package/lib/src/schema.gql +27 -1
- package/lib/src/shacl/SHACLShape.test.js +82 -0
- package/package.json +8 -11
- package/src/model/Ad4mModel.ts +97 -26
- package/src/model/ModelQueryBuilder.ts +17 -7
- package/lib/src/model/query-surreal.d.ts +0 -44
- package/lib/src/model/query-surreal.js +0 -249
- package/lib/src/model/surreal-utils.d.ts +0 -42
- package/lib/src/model/surreal-utils.js +0 -128
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import { PerspectiveClient } from "./PerspectiveClient";
|
|
2
|
+
import { PerspectiveHandle, PerspectiveState } from "./PerspectiveHandle";
|
|
3
|
+
/**
|
|
4
|
+
* Focused unit tests for PerspectiveClient proxy cache behaviour.
|
|
5
|
+
* Uses a mock Apollo client to isolate cache logic from network.
|
|
6
|
+
*/
|
|
7
|
+
// Minimal mock Apollo client that returns controllable results
|
|
8
|
+
function createMockApolloClient(overrides = {}) {
|
|
9
|
+
return {
|
|
10
|
+
query: overrides.query || jest.fn().mockResolvedValue({ data: {} }),
|
|
11
|
+
mutate: overrides.mutate || jest.fn().mockResolvedValue({ data: {} }),
|
|
12
|
+
subscribe: overrides.subscribe || jest.fn().mockReturnValue({
|
|
13
|
+
subscribe: jest.fn()
|
|
14
|
+
}),
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function makeHandle(uuid, name, state = PerspectiveState.Private) {
|
|
18
|
+
const h = new PerspectiveHandle(uuid, name, state);
|
|
19
|
+
return h;
|
|
20
|
+
}
|
|
21
|
+
describe('PerspectiveClient proxy cache', () => {
|
|
22
|
+
it('byUUID returns the same proxy reference on cache hit', async () => {
|
|
23
|
+
const handle = makeHandle('uuid-1', 'Test');
|
|
24
|
+
const mockClient = createMockApolloClient({
|
|
25
|
+
query: jest.fn().mockResolvedValue({
|
|
26
|
+
data: { perspective: handle }
|
|
27
|
+
}),
|
|
28
|
+
});
|
|
29
|
+
const client = new PerspectiveClient(mockClient, false);
|
|
30
|
+
const p1 = await client.byUUID('uuid-1');
|
|
31
|
+
const p2 = await client.byUUID('uuid-1');
|
|
32
|
+
expect(p1).toBe(p2);
|
|
33
|
+
// Only one query should have been made (second is cache hit)
|
|
34
|
+
expect(mockClient.query).toHaveBeenCalledTimes(1);
|
|
35
|
+
});
|
|
36
|
+
it('byUUID returns null for non-existent perspectives', async () => {
|
|
37
|
+
const mockClient = createMockApolloClient({
|
|
38
|
+
query: jest.fn().mockResolvedValue({
|
|
39
|
+
data: { perspective: null }
|
|
40
|
+
}),
|
|
41
|
+
});
|
|
42
|
+
const client = new PerspectiveClient(mockClient, false);
|
|
43
|
+
const p = await client.byUUID('non-existent');
|
|
44
|
+
expect(p).toBeNull();
|
|
45
|
+
});
|
|
46
|
+
it('all() populates cache so subsequent byUUID is a hit', async () => {
|
|
47
|
+
const handles = [
|
|
48
|
+
makeHandle('uuid-a', 'A'),
|
|
49
|
+
makeHandle('uuid-b', 'B'),
|
|
50
|
+
];
|
|
51
|
+
const queryFn = jest.fn()
|
|
52
|
+
.mockResolvedValueOnce({ data: { perspectives: handles } });
|
|
53
|
+
const mockClient = createMockApolloClient({ query: queryFn });
|
|
54
|
+
const client = new PerspectiveClient(mockClient, false);
|
|
55
|
+
const all = await client.all();
|
|
56
|
+
expect(all.length).toBe(2);
|
|
57
|
+
// byUUID should be a cache hit — no additional query
|
|
58
|
+
const pa = await client.byUUID('uuid-a');
|
|
59
|
+
expect(pa).toBe(all[0]);
|
|
60
|
+
expect(queryFn).toHaveBeenCalledTimes(1); // only the all() query
|
|
61
|
+
});
|
|
62
|
+
it('add() populates cache', async () => {
|
|
63
|
+
const handle = makeHandle('uuid-new', 'New');
|
|
64
|
+
const mockClient = createMockApolloClient({
|
|
65
|
+
mutate: jest.fn().mockResolvedValue({
|
|
66
|
+
data: { perspectiveAdd: handle }
|
|
67
|
+
}),
|
|
68
|
+
});
|
|
69
|
+
const client = new PerspectiveClient(mockClient, false);
|
|
70
|
+
const added = await client.add('New');
|
|
71
|
+
expect(added.uuid).toBe('uuid-new');
|
|
72
|
+
// byUUID should hit cache
|
|
73
|
+
const fetched = await client.byUUID('uuid-new');
|
|
74
|
+
expect(fetched).toBe(added);
|
|
75
|
+
});
|
|
76
|
+
it('update() evicts and recreates cached proxy', async () => {
|
|
77
|
+
const originalHandle = makeHandle('uuid-u', 'Original');
|
|
78
|
+
const updatedHandle = makeHandle('uuid-u', 'Updated');
|
|
79
|
+
const queryFn = jest.fn().mockResolvedValue({
|
|
80
|
+
data: { perspective: originalHandle }
|
|
81
|
+
});
|
|
82
|
+
const mutateFn = jest.fn().mockResolvedValue({
|
|
83
|
+
data: { perspectiveUpdate: updatedHandle }
|
|
84
|
+
});
|
|
85
|
+
const mockClient = createMockApolloClient({
|
|
86
|
+
query: queryFn,
|
|
87
|
+
mutate: mutateFn,
|
|
88
|
+
});
|
|
89
|
+
const client = new PerspectiveClient(mockClient, false);
|
|
90
|
+
const original = await client.byUUID('uuid-u');
|
|
91
|
+
expect(original.name).toBe('Original');
|
|
92
|
+
const updated = await client.update('uuid-u', 'Updated');
|
|
93
|
+
expect(updated).not.toBe(original); // new reference after eviction
|
|
94
|
+
expect(updated.name).toBe('Updated');
|
|
95
|
+
expect(original.name).toBe('Original'); // old reference retains stale data
|
|
96
|
+
});
|
|
97
|
+
it('remove() evicts from cache', async () => {
|
|
98
|
+
const handle = makeHandle('uuid-r', 'ToRemove');
|
|
99
|
+
const queryFn = jest.fn().mockResolvedValue({
|
|
100
|
+
data: { perspective: handle }
|
|
101
|
+
});
|
|
102
|
+
const mutateFn = jest.fn().mockResolvedValue({
|
|
103
|
+
data: { perspectiveRemove: true }
|
|
104
|
+
});
|
|
105
|
+
const mockClient = createMockApolloClient({
|
|
106
|
+
query: queryFn,
|
|
107
|
+
mutate: mutateFn,
|
|
108
|
+
});
|
|
109
|
+
const client = new PerspectiveClient(mockClient, false);
|
|
110
|
+
const p = await client.byUUID('uuid-r');
|
|
111
|
+
expect(p).toBeTruthy();
|
|
112
|
+
expect(queryFn).toHaveBeenCalledTimes(1);
|
|
113
|
+
await client.remove('uuid-r');
|
|
114
|
+
// byUUID should miss cache and query again
|
|
115
|
+
const handle2 = makeHandle('uuid-r', 'Recreated');
|
|
116
|
+
queryFn.mockResolvedValueOnce({ data: { perspective: handle2 } });
|
|
117
|
+
const p2 = await client.byUUID('uuid-r');
|
|
118
|
+
expect(p2).not.toBe(p);
|
|
119
|
+
expect(p2.name).toBe('Recreated');
|
|
120
|
+
expect(queryFn).toHaveBeenCalledTimes(2);
|
|
121
|
+
});
|
|
122
|
+
it('getOrCreateProxy does not re-register listeners on cache hit', async () => {
|
|
123
|
+
// Verify that getting the same proxy twice does not create duplicate subscriptions
|
|
124
|
+
const handle = makeHandle('uuid-dup', 'NoDuplicates');
|
|
125
|
+
const subscribeCalls = [];
|
|
126
|
+
const subscribeFn = jest.fn().mockImplementation((opts) => {
|
|
127
|
+
// Track subscription query names
|
|
128
|
+
const queryStr = opts.query?.loc?.source?.body || '';
|
|
129
|
+
subscribeCalls.push(queryStr);
|
|
130
|
+
return {
|
|
131
|
+
subscribe: jest.fn()
|
|
132
|
+
};
|
|
133
|
+
});
|
|
134
|
+
const queryFn = jest.fn()
|
|
135
|
+
.mockResolvedValueOnce({ data: { perspectives: [handle] } });
|
|
136
|
+
const mockClient = createMockApolloClient({
|
|
137
|
+
query: queryFn,
|
|
138
|
+
subscribe: subscribeFn,
|
|
139
|
+
});
|
|
140
|
+
const client = new PerspectiveClient(mockClient, false);
|
|
141
|
+
const all = await client.all();
|
|
142
|
+
const firstProxy = all[0];
|
|
143
|
+
// Record how many subscribe calls happened from PerspectiveProxy constructor
|
|
144
|
+
const callsAfterFirst = subscribeFn.mock.calls.length;
|
|
145
|
+
// Get same proxy again via all() — should be cache hit, no new constructor call
|
|
146
|
+
queryFn.mockResolvedValueOnce({ data: { perspectives: [handle] } });
|
|
147
|
+
const all2 = await client.all();
|
|
148
|
+
const secondProxy = all2[0];
|
|
149
|
+
expect(secondProxy).toBe(firstProxy);
|
|
150
|
+
// No additional subscribe calls should have been made
|
|
151
|
+
expect(subscribeFn.mock.calls.length).toBe(callsAfterFirst);
|
|
152
|
+
});
|
|
153
|
+
it('all() updates existing cached proxies with fresh data', async () => {
|
|
154
|
+
const handle1 = makeHandle('uuid-f', 'OldName');
|
|
155
|
+
const handle2 = makeHandle('uuid-f', 'FreshName');
|
|
156
|
+
const queryFn = jest.fn()
|
|
157
|
+
.mockResolvedValueOnce({ data: { perspective: handle1 } })
|
|
158
|
+
.mockResolvedValueOnce({ data: { perspectives: [handle2] } });
|
|
159
|
+
const mockClient = createMockApolloClient({ query: queryFn });
|
|
160
|
+
const client = new PerspectiveClient(mockClient, false);
|
|
161
|
+
const original = await client.byUUID('uuid-f');
|
|
162
|
+
expect(original.name).toBe('OldName');
|
|
163
|
+
const all = await client.all();
|
|
164
|
+
const refreshed = all.find(p => p.uuid === 'uuid-f');
|
|
165
|
+
expect(refreshed).toBe(original); // same reference
|
|
166
|
+
expect(refreshed.name).toBe('FreshName'); // updated in-place
|
|
167
|
+
expect(original.name).toBe('FreshName'); // original ref also updated
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
describe('PerspectiveProxy getClassShape sh:in URI-decoding', () => {
|
|
171
|
+
// This tests the sh:in parsing logic in getClassShape() which was fixed
|
|
172
|
+
// to URI-decode values from the Rust executor's SPARQL results
|
|
173
|
+
function parseShInValue(raw) {
|
|
174
|
+
// Reproduce the exact parsing logic from PerspectiveProxy.getClassShape()
|
|
175
|
+
try {
|
|
176
|
+
if (raw.startsWith('literal:string:')) {
|
|
177
|
+
raw = decodeURIComponent(raw.substring('literal:string:'.length));
|
|
178
|
+
}
|
|
179
|
+
return JSON.parse(raw);
|
|
180
|
+
}
|
|
181
|
+
catch {
|
|
182
|
+
return undefined;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
it('parses plain JSON sh:in values', () => {
|
|
186
|
+
const result = parseShInValue('[{"value":"a"},{"value":"b","label":"B"}]');
|
|
187
|
+
expect(result).toEqual([
|
|
188
|
+
{ value: 'a' },
|
|
189
|
+
{ value: 'b', label: 'B' },
|
|
190
|
+
]);
|
|
191
|
+
});
|
|
192
|
+
it('strips literal:string: prefix and parses', () => {
|
|
193
|
+
const result = parseShInValue('literal:string:[{"value":"x"},{"value":"y"}]');
|
|
194
|
+
expect(result).toEqual([
|
|
195
|
+
{ value: 'x' },
|
|
196
|
+
{ value: 'y' },
|
|
197
|
+
]);
|
|
198
|
+
});
|
|
199
|
+
it('URI-decodes encoded sh:in values from Rust executor', () => {
|
|
200
|
+
// Rust executor may URI-encode the JSON when returning SPARQL results
|
|
201
|
+
const encoded = 'literal:string:' + encodeURIComponent('[{"value":"hello world"},{"value":"a&b"}]');
|
|
202
|
+
const result = parseShInValue(encoded);
|
|
203
|
+
expect(result).toEqual([
|
|
204
|
+
{ value: 'hello world' },
|
|
205
|
+
{ value: 'a&b' },
|
|
206
|
+
]);
|
|
207
|
+
});
|
|
208
|
+
it('handles double-encoded brackets and quotes', () => {
|
|
209
|
+
const encoded = 'literal:string:%5B%7B%22value%22%3A%22active%22%7D%2C%7B%22value%22%3A%22inactive%22%7D%5D';
|
|
210
|
+
const result = parseShInValue(encoded);
|
|
211
|
+
expect(result).toEqual([
|
|
212
|
+
{ value: 'active' },
|
|
213
|
+
{ value: 'inactive' },
|
|
214
|
+
]);
|
|
215
|
+
});
|
|
216
|
+
it('returns undefined for malformed JSON', () => {
|
|
217
|
+
const result = parseShInValue('literal:string:not-json');
|
|
218
|
+
expect(result).toBeUndefined();
|
|
219
|
+
});
|
|
220
|
+
it('handles already-decoded values without prefix', () => {
|
|
221
|
+
const result = parseShInValue('[{"value":"test"}]');
|
|
222
|
+
expect(result).toEqual([{ value: 'test' }]);
|
|
223
|
+
});
|
|
224
|
+
});
|
|
@@ -22,7 +22,6 @@ export default class PerspectiveResolver {
|
|
|
22
22
|
perspectivePublishSnapshot(uuid: string): String | null;
|
|
23
23
|
perspectiveQueryLinks(uuid: string, query: LinkQuery): LinkExpression[];
|
|
24
24
|
perspectiveQueryProlog(uuid: string, query: string): Promise<string>;
|
|
25
|
-
perspectiveQuerySurrealDB(uuid: string, query: string): Promise<string>;
|
|
26
25
|
perspectiveSubscribeQuery(uuid: string, query: string): Promise<QuerySubscription>;
|
|
27
26
|
perspectiveAdd(name: string, pubSub: any): PerspectiveHandle;
|
|
28
27
|
perspectiveUpdate(uuid: string, name: string, pubSub: any): PerspectiveHandle;
|
|
@@ -87,9 +87,6 @@ let PerspectiveResolver = class PerspectiveResolver {
|
|
|
87
87
|
async perspectiveQueryProlog(uuid, query) {
|
|
88
88
|
return `[{"X": 1}]`;
|
|
89
89
|
}
|
|
90
|
-
async perspectiveQuerySurrealDB(uuid, query) {
|
|
91
|
-
return `[]`;
|
|
92
|
-
}
|
|
93
90
|
async perspectiveSubscribeQuery(uuid, query) {
|
|
94
91
|
const result = `[{"X": 1}]`;
|
|
95
92
|
return {
|
|
@@ -277,14 +274,6 @@ __decorate([
|
|
|
277
274
|
__metadata("design:paramtypes", [String, String]),
|
|
278
275
|
__metadata("design:returntype", Promise)
|
|
279
276
|
], PerspectiveResolver.prototype, "perspectiveQueryProlog", null);
|
|
280
|
-
__decorate([
|
|
281
|
-
Query(returns => String),
|
|
282
|
-
__param(0, Arg('uuid')),
|
|
283
|
-
__param(1, Arg('query')),
|
|
284
|
-
__metadata("design:type", Function),
|
|
285
|
-
__metadata("design:paramtypes", [String, String]),
|
|
286
|
-
__metadata("design:returntype", Promise)
|
|
287
|
-
], PerspectiveResolver.prototype, "perspectiveQuerySurrealDB", null);
|
|
288
277
|
__decorate([
|
|
289
278
|
Mutation(returns => QuerySubscription),
|
|
290
279
|
__param(0, Arg('uuid')),
|
|
@@ -68,6 +68,9 @@ export declare class UserStatistics {
|
|
|
68
68
|
did: string;
|
|
69
69
|
lastSeen?: string;
|
|
70
70
|
perspectiveCount: number;
|
|
71
|
+
remainingCredits: string;
|
|
72
|
+
freeAccess: boolean;
|
|
73
|
+
hotWalletAddress?: string;
|
|
71
74
|
}
|
|
72
75
|
export declare class VerificationRequestResult {
|
|
73
76
|
success: boolean;
|
|
@@ -79,13 +82,24 @@ export declare class HostingUserInfo {
|
|
|
79
82
|
email: string;
|
|
80
83
|
remainingCredits: string;
|
|
81
84
|
hotWalletAddress?: string;
|
|
82
|
-
|
|
85
|
+
freeAccess: boolean;
|
|
86
|
+
constructor(email: string, remainingCredits: string, hotWalletAddress?: string, freeAccess?: boolean);
|
|
83
87
|
}
|
|
84
88
|
export declare class PaymentRequestResult {
|
|
85
89
|
success: boolean;
|
|
86
90
|
message: string;
|
|
87
91
|
constructor(success: boolean, message: string);
|
|
88
92
|
}
|
|
93
|
+
export declare class ComputeLogEntry {
|
|
94
|
+
id: number;
|
|
95
|
+
userEmail: string;
|
|
96
|
+
timestamp: string;
|
|
97
|
+
operation: string;
|
|
98
|
+
summary?: string;
|
|
99
|
+
cost: number;
|
|
100
|
+
creditsAfter: number;
|
|
101
|
+
constructor(id: number, userEmail: string, timestamp: string, operation: string, cost: number, creditsAfter: number, summary?: string);
|
|
102
|
+
}
|
|
89
103
|
/**
|
|
90
104
|
* Resolver classes are used here to define the GraphQL schema
|
|
91
105
|
* (through the type-graphql annotations)
|
|
@@ -129,6 +143,8 @@ export default class RuntimeResolver {
|
|
|
129
143
|
runtimeImportPerspective(filePath: string): boolean;
|
|
130
144
|
runtimeMultiUserEnabled(): boolean;
|
|
131
145
|
runtimeSetMultiUserEnabled(enabled: boolean): boolean;
|
|
146
|
+
runtimeFreeHostingEnabled(): boolean;
|
|
147
|
+
runtimeSetFreeHostingEnabled(enabled: boolean): boolean;
|
|
132
148
|
runtimeListUsers(): UserStatistics[];
|
|
133
149
|
runtimeRequestLoginVerification(email: string, appInfo?: AuthInfoInput): VerificationRequestResult;
|
|
134
150
|
runtimeVerifyEmailCode(email: string, code: string, verificationType: string): string;
|
|
@@ -141,6 +157,17 @@ export default class RuntimeResolver {
|
|
|
141
157
|
runtimeEmailTestClearCodes(): boolean;
|
|
142
158
|
runtimeEmailTestSetExpiry(email: string, verificationType: string, expiresAt: number): boolean;
|
|
143
159
|
runtimeHostingUserInfo(): HostingUserInfo;
|
|
160
|
+
runtimeComputeLog(since?: string, limit?: number, userEmail?: string): ComputeLogEntry[];
|
|
144
161
|
runtimeSetHotWalletAddress(address: string): boolean;
|
|
145
162
|
runtimeRequestPayment(amountHOT: string): PaymentRequestResult;
|
|
163
|
+
runtimeSetUserCredits(email: string, amount: number): boolean;
|
|
164
|
+
runtimeSetUserFreeAccess(email: string, enabled: boolean): boolean;
|
|
165
|
+
runtimeReinstallUnytDna(): PaymentRequestResult;
|
|
166
|
+
runtimeSendHot(recipient: string, amount: string): PaymentRequestResult;
|
|
167
|
+
runtimeSetUnytMembraneProof(proof: string): PaymentRequestResult;
|
|
168
|
+
runtimeHotWalletBalance(): string;
|
|
169
|
+
runtimeHotWalletHistory(page?: number, perPage?: number): string;
|
|
170
|
+
runtimeHotAgentPubkey(): string;
|
|
171
|
+
runtimeUnytAgentKey(): string;
|
|
172
|
+
runtimeUnytVersionInfo(): string;
|
|
146
173
|
}
|
|
@@ -289,6 +289,18 @@ __decorate([
|
|
|
289
289
|
Field(type => Int),
|
|
290
290
|
__metadata("design:type", Number)
|
|
291
291
|
], UserStatistics.prototype, "perspectiveCount", void 0);
|
|
292
|
+
__decorate([
|
|
293
|
+
Field(),
|
|
294
|
+
__metadata("design:type", String)
|
|
295
|
+
], UserStatistics.prototype, "remainingCredits", void 0);
|
|
296
|
+
__decorate([
|
|
297
|
+
Field(),
|
|
298
|
+
__metadata("design:type", Boolean)
|
|
299
|
+
], UserStatistics.prototype, "freeAccess", void 0);
|
|
300
|
+
__decorate([
|
|
301
|
+
Field({ nullable: true }),
|
|
302
|
+
__metadata("design:type", String)
|
|
303
|
+
], UserStatistics.prototype, "hotWalletAddress", void 0);
|
|
292
304
|
UserStatistics = __decorate([
|
|
293
305
|
ObjectType()
|
|
294
306
|
], UserStatistics);
|
|
@@ -316,10 +328,11 @@ VerificationRequestResult = __decorate([
|
|
|
316
328
|
], VerificationRequestResult);
|
|
317
329
|
export { VerificationRequestResult };
|
|
318
330
|
let HostingUserInfo = class HostingUserInfo {
|
|
319
|
-
constructor(email, remainingCredits, hotWalletAddress) {
|
|
331
|
+
constructor(email, remainingCredits, hotWalletAddress, freeAccess = false) {
|
|
320
332
|
this.email = email;
|
|
321
333
|
this.remainingCredits = remainingCredits;
|
|
322
334
|
this.hotWalletAddress = hotWalletAddress;
|
|
335
|
+
this.freeAccess = freeAccess;
|
|
323
336
|
}
|
|
324
337
|
};
|
|
325
338
|
__decorate([
|
|
@@ -334,9 +347,13 @@ __decorate([
|
|
|
334
347
|
Field({ nullable: true }),
|
|
335
348
|
__metadata("design:type", String)
|
|
336
349
|
], HostingUserInfo.prototype, "hotWalletAddress", void 0);
|
|
350
|
+
__decorate([
|
|
351
|
+
Field(),
|
|
352
|
+
__metadata("design:type", Boolean)
|
|
353
|
+
], HostingUserInfo.prototype, "freeAccess", void 0);
|
|
337
354
|
HostingUserInfo = __decorate([
|
|
338
355
|
ObjectType(),
|
|
339
|
-
__metadata("design:paramtypes", [String, String, String])
|
|
356
|
+
__metadata("design:paramtypes", [String, String, String, Boolean])
|
|
340
357
|
], HostingUserInfo);
|
|
341
358
|
export { HostingUserInfo };
|
|
342
359
|
let PaymentRequestResult = class PaymentRequestResult {
|
|
@@ -358,6 +375,50 @@ PaymentRequestResult = __decorate([
|
|
|
358
375
|
__metadata("design:paramtypes", [Boolean, String])
|
|
359
376
|
], PaymentRequestResult);
|
|
360
377
|
export { PaymentRequestResult };
|
|
378
|
+
let ComputeLogEntry = class ComputeLogEntry {
|
|
379
|
+
constructor(id, userEmail, timestamp, operation, cost, creditsAfter, summary) {
|
|
380
|
+
this.id = id;
|
|
381
|
+
this.userEmail = userEmail;
|
|
382
|
+
this.timestamp = timestamp;
|
|
383
|
+
this.operation = operation;
|
|
384
|
+
this.cost = cost;
|
|
385
|
+
this.creditsAfter = creditsAfter;
|
|
386
|
+
this.summary = summary;
|
|
387
|
+
}
|
|
388
|
+
};
|
|
389
|
+
__decorate([
|
|
390
|
+
Field(),
|
|
391
|
+
__metadata("design:type", Number)
|
|
392
|
+
], ComputeLogEntry.prototype, "id", void 0);
|
|
393
|
+
__decorate([
|
|
394
|
+
Field(),
|
|
395
|
+
__metadata("design:type", String)
|
|
396
|
+
], ComputeLogEntry.prototype, "userEmail", void 0);
|
|
397
|
+
__decorate([
|
|
398
|
+
Field(),
|
|
399
|
+
__metadata("design:type", String)
|
|
400
|
+
], ComputeLogEntry.prototype, "timestamp", void 0);
|
|
401
|
+
__decorate([
|
|
402
|
+
Field(),
|
|
403
|
+
__metadata("design:type", String)
|
|
404
|
+
], ComputeLogEntry.prototype, "operation", void 0);
|
|
405
|
+
__decorate([
|
|
406
|
+
Field({ nullable: true }),
|
|
407
|
+
__metadata("design:type", String)
|
|
408
|
+
], ComputeLogEntry.prototype, "summary", void 0);
|
|
409
|
+
__decorate([
|
|
410
|
+
Field(),
|
|
411
|
+
__metadata("design:type", Number)
|
|
412
|
+
], ComputeLogEntry.prototype, "cost", void 0);
|
|
413
|
+
__decorate([
|
|
414
|
+
Field(),
|
|
415
|
+
__metadata("design:type", Number)
|
|
416
|
+
], ComputeLogEntry.prototype, "creditsAfter", void 0);
|
|
417
|
+
ComputeLogEntry = __decorate([
|
|
418
|
+
ObjectType(),
|
|
419
|
+
__metadata("design:paramtypes", [Number, String, String, String, Number, Number, String])
|
|
420
|
+
], ComputeLogEntry);
|
|
421
|
+
export { ComputeLogEntry };
|
|
361
422
|
/**
|
|
362
423
|
* Resolver classes are used here to define the GraphQL schema
|
|
363
424
|
* (through the type-graphql annotations)
|
|
@@ -513,12 +574,20 @@ let RuntimeResolver = class RuntimeResolver {
|
|
|
513
574
|
runtimeSetMultiUserEnabled(enabled) {
|
|
514
575
|
return enabled;
|
|
515
576
|
}
|
|
577
|
+
runtimeFreeHostingEnabled() {
|
|
578
|
+
return true;
|
|
579
|
+
}
|
|
580
|
+
runtimeSetFreeHostingEnabled(enabled) {
|
|
581
|
+
return enabled;
|
|
582
|
+
}
|
|
516
583
|
runtimeListUsers() {
|
|
517
584
|
return [{
|
|
518
585
|
email: "test@example.com",
|
|
519
586
|
did: "did:key:test123",
|
|
520
587
|
lastSeen: new Date().toISOString(),
|
|
521
|
-
perspectiveCount: 5
|
|
588
|
+
perspectiveCount: 5,
|
|
589
|
+
remainingCredits: "0",
|
|
590
|
+
freeAccess: false
|
|
522
591
|
}];
|
|
523
592
|
}
|
|
524
593
|
runtimeRequestLoginVerification(email, appInfo) {
|
|
@@ -568,7 +637,10 @@ let RuntimeResolver = class RuntimeResolver {
|
|
|
568
637
|
}
|
|
569
638
|
// Hosting mutations & queries
|
|
570
639
|
runtimeHostingUserInfo() {
|
|
571
|
-
return new HostingUserInfo("test@example.com", "100000000", null);
|
|
640
|
+
return new HostingUserInfo("test@example.com", "100000000", null, false);
|
|
641
|
+
}
|
|
642
|
+
runtimeComputeLog(since, limit, userEmail) {
|
|
643
|
+
return [];
|
|
572
644
|
}
|
|
573
645
|
runtimeSetHotWalletAddress(address) {
|
|
574
646
|
return true;
|
|
@@ -576,6 +648,36 @@ let RuntimeResolver = class RuntimeResolver {
|
|
|
576
648
|
runtimeRequestPayment(amountHOT) {
|
|
577
649
|
return new PaymentRequestResult(true, "Mock payment of " + amountHOT + " base units credited");
|
|
578
650
|
}
|
|
651
|
+
runtimeSetUserCredits(email, amount) {
|
|
652
|
+
return true;
|
|
653
|
+
}
|
|
654
|
+
runtimeSetUserFreeAccess(email, enabled) {
|
|
655
|
+
return true;
|
|
656
|
+
}
|
|
657
|
+
runtimeReinstallUnytDna() {
|
|
658
|
+
return new PaymentRequestResult(true, "");
|
|
659
|
+
}
|
|
660
|
+
runtimeSendHot(recipient, amount) {
|
|
661
|
+
return new PaymentRequestResult(true, "");
|
|
662
|
+
}
|
|
663
|
+
runtimeSetUnytMembraneProof(proof) {
|
|
664
|
+
return new PaymentRequestResult(true, "");
|
|
665
|
+
}
|
|
666
|
+
runtimeHotWalletBalance() {
|
|
667
|
+
return "";
|
|
668
|
+
}
|
|
669
|
+
runtimeHotWalletHistory(page, perPage) {
|
|
670
|
+
return "";
|
|
671
|
+
}
|
|
672
|
+
runtimeHotAgentPubkey() {
|
|
673
|
+
return "";
|
|
674
|
+
}
|
|
675
|
+
runtimeUnytAgentKey() {
|
|
676
|
+
return "";
|
|
677
|
+
}
|
|
678
|
+
runtimeUnytVersionInfo() {
|
|
679
|
+
return "";
|
|
680
|
+
}
|
|
579
681
|
};
|
|
580
682
|
__decorate([
|
|
581
683
|
Mutation(returns => Boolean),
|
|
@@ -822,6 +924,19 @@ __decorate([
|
|
|
822
924
|
__metadata("design:paramtypes", [Boolean]),
|
|
823
925
|
__metadata("design:returntype", Boolean)
|
|
824
926
|
], RuntimeResolver.prototype, "runtimeSetMultiUserEnabled", null);
|
|
927
|
+
__decorate([
|
|
928
|
+
Query(returns => Boolean),
|
|
929
|
+
__metadata("design:type", Function),
|
|
930
|
+
__metadata("design:paramtypes", []),
|
|
931
|
+
__metadata("design:returntype", Boolean)
|
|
932
|
+
], RuntimeResolver.prototype, "runtimeFreeHostingEnabled", null);
|
|
933
|
+
__decorate([
|
|
934
|
+
Mutation(returns => Boolean),
|
|
935
|
+
__param(0, Arg("enabled")),
|
|
936
|
+
__metadata("design:type", Function),
|
|
937
|
+
__metadata("design:paramtypes", [Boolean]),
|
|
938
|
+
__metadata("design:returntype", Boolean)
|
|
939
|
+
], RuntimeResolver.prototype, "runtimeSetFreeHostingEnabled", null);
|
|
825
940
|
__decorate([
|
|
826
941
|
Query(returns => [UserStatistics]),
|
|
827
942
|
__metadata("design:type", Function),
|
|
@@ -909,6 +1024,15 @@ __decorate([
|
|
|
909
1024
|
__metadata("design:paramtypes", []),
|
|
910
1025
|
__metadata("design:returntype", HostingUserInfo)
|
|
911
1026
|
], RuntimeResolver.prototype, "runtimeHostingUserInfo", null);
|
|
1027
|
+
__decorate([
|
|
1028
|
+
Query(returns => [ComputeLogEntry]),
|
|
1029
|
+
__param(0, Arg("since", { nullable: true })),
|
|
1030
|
+
__param(1, Arg("limit", { nullable: true })),
|
|
1031
|
+
__param(2, Arg("userEmail", { nullable: true })),
|
|
1032
|
+
__metadata("design:type", Function),
|
|
1033
|
+
__metadata("design:paramtypes", [String, Number, String]),
|
|
1034
|
+
__metadata("design:returntype", Array)
|
|
1035
|
+
], RuntimeResolver.prototype, "runtimeComputeLog", null);
|
|
912
1036
|
__decorate([
|
|
913
1037
|
Mutation(returns => Boolean),
|
|
914
1038
|
__param(0, Arg("address")),
|
|
@@ -923,6 +1047,75 @@ __decorate([
|
|
|
923
1047
|
__metadata("design:paramtypes", [String]),
|
|
924
1048
|
__metadata("design:returntype", PaymentRequestResult)
|
|
925
1049
|
], RuntimeResolver.prototype, "runtimeRequestPayment", null);
|
|
1050
|
+
__decorate([
|
|
1051
|
+
Mutation(returns => Boolean),
|
|
1052
|
+
__param(0, Arg("email")),
|
|
1053
|
+
__param(1, Arg("amount")),
|
|
1054
|
+
__metadata("design:type", Function),
|
|
1055
|
+
__metadata("design:paramtypes", [String, Number]),
|
|
1056
|
+
__metadata("design:returntype", Boolean)
|
|
1057
|
+
], RuntimeResolver.prototype, "runtimeSetUserCredits", null);
|
|
1058
|
+
__decorate([
|
|
1059
|
+
Mutation(returns => Boolean),
|
|
1060
|
+
__param(0, Arg("email")),
|
|
1061
|
+
__param(1, Arg("enabled")),
|
|
1062
|
+
__metadata("design:type", Function),
|
|
1063
|
+
__metadata("design:paramtypes", [String, Boolean]),
|
|
1064
|
+
__metadata("design:returntype", Boolean)
|
|
1065
|
+
], RuntimeResolver.prototype, "runtimeSetUserFreeAccess", null);
|
|
1066
|
+
__decorate([
|
|
1067
|
+
Mutation(returns => PaymentRequestResult),
|
|
1068
|
+
__metadata("design:type", Function),
|
|
1069
|
+
__metadata("design:paramtypes", []),
|
|
1070
|
+
__metadata("design:returntype", PaymentRequestResult)
|
|
1071
|
+
], RuntimeResolver.prototype, "runtimeReinstallUnytDna", null);
|
|
1072
|
+
__decorate([
|
|
1073
|
+
Mutation(returns => PaymentRequestResult),
|
|
1074
|
+
__param(0, Arg("recipient")),
|
|
1075
|
+
__param(1, Arg("amount")),
|
|
1076
|
+
__metadata("design:type", Function),
|
|
1077
|
+
__metadata("design:paramtypes", [String, String]),
|
|
1078
|
+
__metadata("design:returntype", PaymentRequestResult)
|
|
1079
|
+
], RuntimeResolver.prototype, "runtimeSendHot", null);
|
|
1080
|
+
__decorate([
|
|
1081
|
+
Mutation(returns => PaymentRequestResult),
|
|
1082
|
+
__param(0, Arg("proof")),
|
|
1083
|
+
__metadata("design:type", Function),
|
|
1084
|
+
__metadata("design:paramtypes", [String]),
|
|
1085
|
+
__metadata("design:returntype", PaymentRequestResult)
|
|
1086
|
+
], RuntimeResolver.prototype, "runtimeSetUnytMembraneProof", null);
|
|
1087
|
+
__decorate([
|
|
1088
|
+
Query(returns => String),
|
|
1089
|
+
__metadata("design:type", Function),
|
|
1090
|
+
__metadata("design:paramtypes", []),
|
|
1091
|
+
__metadata("design:returntype", String)
|
|
1092
|
+
], RuntimeResolver.prototype, "runtimeHotWalletBalance", null);
|
|
1093
|
+
__decorate([
|
|
1094
|
+
Query(returns => String),
|
|
1095
|
+
__param(0, Arg("page", { nullable: true })),
|
|
1096
|
+
__param(1, Arg("perPage", { nullable: true })),
|
|
1097
|
+
__metadata("design:type", Function),
|
|
1098
|
+
__metadata("design:paramtypes", [Number, Number]),
|
|
1099
|
+
__metadata("design:returntype", String)
|
|
1100
|
+
], RuntimeResolver.prototype, "runtimeHotWalletHistory", null);
|
|
1101
|
+
__decorate([
|
|
1102
|
+
Query(returns => String),
|
|
1103
|
+
__metadata("design:type", Function),
|
|
1104
|
+
__metadata("design:paramtypes", []),
|
|
1105
|
+
__metadata("design:returntype", String)
|
|
1106
|
+
], RuntimeResolver.prototype, "runtimeHotAgentPubkey", null);
|
|
1107
|
+
__decorate([
|
|
1108
|
+
Query(returns => String),
|
|
1109
|
+
__metadata("design:type", Function),
|
|
1110
|
+
__metadata("design:paramtypes", []),
|
|
1111
|
+
__metadata("design:returntype", String)
|
|
1112
|
+
], RuntimeResolver.prototype, "runtimeUnytAgentKey", null);
|
|
1113
|
+
__decorate([
|
|
1114
|
+
Query(returns => String),
|
|
1115
|
+
__metadata("design:type", Function),
|
|
1116
|
+
__metadata("design:paramtypes", []),
|
|
1117
|
+
__metadata("design:returntype", String)
|
|
1118
|
+
], RuntimeResolver.prototype, "runtimeUnytVersionInfo", null);
|
|
926
1119
|
RuntimeResolver = __decorate([
|
|
927
1120
|
Resolver()
|
|
928
1121
|
], RuntimeResolver);
|
package/lib/src/schema.gql
CHANGED
|
@@ -93,6 +93,16 @@ input CapabilityInput {
|
|
|
93
93
|
with: ResourceInput!
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
+
type ComputeLogEntry {
|
|
97
|
+
cost: Float!
|
|
98
|
+
creditsAfter: Float!
|
|
99
|
+
id: Float!
|
|
100
|
+
operation: String!
|
|
101
|
+
summary: String
|
|
102
|
+
timestamp: String!
|
|
103
|
+
userEmail: String!
|
|
104
|
+
}
|
|
105
|
+
|
|
96
106
|
# The javascript `Date` as string. Type represents date and time as the ISO Date string.
|
|
97
107
|
scalar DateTime
|
|
98
108
|
|
|
@@ -146,6 +156,7 @@ type ExpressionRendered {
|
|
|
146
156
|
|
|
147
157
|
type HostingUserInfo {
|
|
148
158
|
email: String!
|
|
159
|
+
freeAccess: Boolean!
|
|
149
160
|
hotWalletAddress: String
|
|
150
161
|
remainingCredits: String!
|
|
151
162
|
}
|
|
@@ -380,6 +391,7 @@ type Mutation {
|
|
|
380
391
|
runtimeLoginUser(email: String!, password: String!): String!
|
|
381
392
|
runtimeOpenLink(url: String!): Boolean!
|
|
382
393
|
runtimeQuit: Boolean!
|
|
394
|
+
runtimeReinstallUnytDna: PaymentRequestResult!
|
|
383
395
|
runtimeRemoveFriends(dids: [String!]!): [String!]!
|
|
384
396
|
runtimeRemoveKnownLinkLanguageTemplates(addresses: [String!]!): [String!]!
|
|
385
397
|
runtimeRemoveNotification(id: String!): Boolean!
|
|
@@ -387,9 +399,14 @@ type Mutation {
|
|
|
387
399
|
runtimeRequestLoginVerification(appInfo: AuthInfoInput, email: String!): VerificationRequestResult!
|
|
388
400
|
runtimeRequestPayment(amountHOT: String!): PaymentRequestResult!
|
|
389
401
|
runtimeRestartHolochain: Boolean!
|
|
402
|
+
runtimeSendHot(amount: String!, recipient: String!): PaymentRequestResult!
|
|
403
|
+
runtimeSetFreeHostingEnabled(enabled: Boolean!): Boolean!
|
|
390
404
|
runtimeSetHotWalletAddress(address: String!): Boolean!
|
|
391
405
|
runtimeSetMultiUserEnabled(enabled: Boolean!): Boolean!
|
|
392
406
|
runtimeSetStatus(status: PerspectiveInput!): Boolean!
|
|
407
|
+
runtimeSetUnytMembraneProof(proof: String!): PaymentRequestResult!
|
|
408
|
+
runtimeSetUserCredits(amount: Float!, email: String!): Boolean!
|
|
409
|
+
runtimeSetUserFreeAccess(email: String!, enabled: Boolean!): Boolean!
|
|
393
410
|
runtimeTestEmail(to: String!): Boolean!
|
|
394
411
|
runtimeUpdateNotification(id: String!, notification: NotificationInput!): Boolean!
|
|
395
412
|
runtimeVerifyEmailCode(code: String!, email: String!, verificationType: String!): String!
|
|
@@ -495,14 +512,18 @@ type Query {
|
|
|
495
512
|
perspective(uuid: String!): PerspectiveHandle
|
|
496
513
|
perspectiveQueryLinks(query: LinkQuery!, uuid: String!): [LinkExpression!]
|
|
497
514
|
perspectiveQueryProlog(query: String!, uuid: String!): String!
|
|
498
|
-
perspectiveQuerySurrealDB(query: String!, uuid: String!): String!
|
|
499
515
|
perspectiveSnapshot(uuid: String!): Perspective
|
|
500
516
|
perspectives: [PerspectiveHandle!]!
|
|
517
|
+
runtimeComputeLog(limit: Float, since: String, userEmail: String): [ComputeLogEntry!]!
|
|
518
|
+
runtimeFreeHostingEnabled: Boolean!
|
|
501
519
|
runtimeFriendStatus(did: String!): PerspectiveExpression
|
|
502
520
|
runtimeFriends: [String!]!
|
|
503
521
|
runtimeGetNetworkMetrics: String!
|
|
504
522
|
runtimeHcAgentInfos: String!
|
|
505
523
|
runtimeHostingUserInfo: HostingUserInfo!
|
|
524
|
+
runtimeHotAgentPubkey: String!
|
|
525
|
+
runtimeHotWalletBalance: String!
|
|
526
|
+
runtimeHotWalletHistory(page: Float, perPage: Float): String!
|
|
506
527
|
runtimeInfo: RuntimeInfo!
|
|
507
528
|
runtimeKnownLinkLanguageTemplates: [String!]!
|
|
508
529
|
runtimeListUsers: [UserStatistics!]!
|
|
@@ -510,6 +531,8 @@ type Query {
|
|
|
510
531
|
runtimeMessageOutbox(filter: String): [SentMessage!]!
|
|
511
532
|
runtimeMultiUserEnabled: Boolean!
|
|
512
533
|
runtimeNotifications: [Notification!]!
|
|
534
|
+
runtimeUnytAgentKey: String!
|
|
535
|
+
runtimeUnytVersionInfo: String!
|
|
513
536
|
runtimeVerifyStringSignedByDid(data: String!, did: String!, didSigningKeyId: String!, signedData: String!): Boolean!
|
|
514
537
|
}
|
|
515
538
|
|
|
@@ -585,8 +608,11 @@ type UserCreationResult {
|
|
|
585
608
|
type UserStatistics {
|
|
586
609
|
did: String!
|
|
587
610
|
email: String!
|
|
611
|
+
freeAccess: Boolean!
|
|
612
|
+
hotWalletAddress: String
|
|
588
613
|
lastSeen: String
|
|
589
614
|
perspectiveCount: Int!
|
|
615
|
+
remainingCredits: String!
|
|
590
616
|
}
|
|
591
617
|
|
|
592
618
|
type VerificationRequestResult {
|