@proofchain/sdk 1.2.0 → 2.0.0
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/LICENSE +21 -0
- package/README.md +254 -114
- package/dist/index.d.mts +2501 -276
- package/dist/index.d.ts +2501 -276
- package/dist/index.js +2031 -275
- package/dist/index.mjs +2004 -271
- package/package.json +43 -19
- package/src/client.ts +0 -312
- package/src/contract.ts +0 -212
- package/src/index.ts +0 -65
- package/src/types.ts +0 -228
- package/tsconfig.json +0 -18
package/dist/index.d.mts
CHANGED
|
@@ -1,328 +1,2553 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
message: string;
|
|
1
|
+
/**
|
|
2
|
+
* HTTP Client for ProofChain API
|
|
3
|
+
*/
|
|
4
|
+
interface HttpClientOptions {
|
|
5
|
+
apiKey: string;
|
|
6
|
+
baseUrl?: string;
|
|
7
|
+
timeout?: number;
|
|
8
|
+
maxRetries?: number;
|
|
10
9
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
declare class HttpClient {
|
|
11
|
+
private apiKey;
|
|
12
|
+
private baseUrl;
|
|
13
|
+
private timeout;
|
|
14
|
+
private maxRetries;
|
|
15
|
+
constructor(options: HttpClientOptions);
|
|
16
|
+
private getHeaders;
|
|
17
|
+
private handleResponse;
|
|
18
|
+
private fetchWithRetry;
|
|
19
|
+
request<T>(method: string, path: string, options?: {
|
|
20
|
+
body?: unknown;
|
|
21
|
+
params?: Record<string, string | number | undefined>;
|
|
22
|
+
}): Promise<T>;
|
|
23
|
+
requestMultipart<T>(path: string, formData: FormData): Promise<T>;
|
|
24
|
+
getRaw(path: string): Promise<ArrayBuffer>;
|
|
25
|
+
get<T>(path: string, params?: Record<string, string | number | undefined>): Promise<T>;
|
|
26
|
+
post<T>(path: string, body?: unknown): Promise<T>;
|
|
27
|
+
put<T>(path: string, body?: unknown): Promise<T>;
|
|
28
|
+
patch<T>(path: string, body?: unknown): Promise<T>;
|
|
29
|
+
delete<T>(path: string): Promise<T>;
|
|
15
30
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* ProofChain SDK Types
|
|
34
|
+
*/
|
|
35
|
+
type AttestationMode = 'direct' | 'batch' | 'channel';
|
|
36
|
+
type EventStatus = 'pending' | 'queued' | 'confirmed' | 'settled' | 'failed';
|
|
37
|
+
type ChannelState = 'open' | 'syncing' | 'settling' | 'settled' | 'closed';
|
|
38
|
+
interface AttestationResult {
|
|
39
|
+
id: string;
|
|
40
|
+
ipfsHash: string;
|
|
41
|
+
documentHash: string;
|
|
42
|
+
gatewayUrl: string;
|
|
43
|
+
verifyUrl: string;
|
|
44
|
+
certificateId: string;
|
|
45
|
+
status: EventStatus;
|
|
46
|
+
attestationMode: AttestationMode;
|
|
47
|
+
timestamp: string;
|
|
48
|
+
blockchainTx?: string;
|
|
49
|
+
proof?: string[];
|
|
21
50
|
}
|
|
22
|
-
interface
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
51
|
+
interface Event {
|
|
52
|
+
id: string;
|
|
53
|
+
eventType: string;
|
|
54
|
+
userId: string;
|
|
55
|
+
ipfsHash: string;
|
|
56
|
+
documentHash?: string;
|
|
57
|
+
gatewayUrl: string;
|
|
58
|
+
certificateId: string;
|
|
59
|
+
status: EventStatus;
|
|
60
|
+
attestationMode: AttestationMode;
|
|
61
|
+
timestamp: string;
|
|
62
|
+
data?: Record<string, unknown>;
|
|
63
|
+
blockchainTx?: string;
|
|
64
|
+
batchId?: string;
|
|
65
|
+
channelId?: string;
|
|
26
66
|
}
|
|
27
|
-
interface
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
67
|
+
interface Channel {
|
|
68
|
+
channelId: string;
|
|
69
|
+
name: string;
|
|
70
|
+
state: ChannelState;
|
|
71
|
+
createdAt: string;
|
|
31
72
|
}
|
|
32
|
-
interface
|
|
33
|
-
|
|
34
|
-
|
|
73
|
+
interface ChannelStatus {
|
|
74
|
+
channelId: string;
|
|
75
|
+
name: string;
|
|
76
|
+
state: ChannelState;
|
|
77
|
+
eventCount: number;
|
|
78
|
+
syncedCount: number;
|
|
79
|
+
pendingCount: number;
|
|
80
|
+
createdAt: string;
|
|
81
|
+
lastActivity?: string;
|
|
82
|
+
lastSettlement?: string;
|
|
83
|
+
merkleRoot?: string;
|
|
35
84
|
}
|
|
36
|
-
interface
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
85
|
+
interface Settlement {
|
|
86
|
+
channelId: string;
|
|
87
|
+
txHash: string;
|
|
88
|
+
merkleRoot: string;
|
|
89
|
+
eventCount: number;
|
|
90
|
+
blockNumber: number;
|
|
91
|
+
gasUsed: number;
|
|
92
|
+
settledAt: string;
|
|
40
93
|
}
|
|
41
|
-
interface
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
94
|
+
interface Certificate {
|
|
95
|
+
certificateId: string;
|
|
96
|
+
recipientName: string;
|
|
97
|
+
recipientEmail?: string;
|
|
98
|
+
title: string;
|
|
99
|
+
description?: string;
|
|
100
|
+
ipfsHash: string;
|
|
101
|
+
verifyUrl: string;
|
|
102
|
+
qrCodeUrl: string;
|
|
103
|
+
issuedAt: string;
|
|
104
|
+
expiresAt?: string;
|
|
105
|
+
revoked: boolean;
|
|
106
|
+
revokedAt?: string;
|
|
107
|
+
revocationReason?: string;
|
|
108
|
+
metadata?: Record<string, unknown>;
|
|
109
|
+
blockchainTx?: string;
|
|
46
110
|
}
|
|
47
|
-
interface
|
|
111
|
+
interface Webhook {
|
|
48
112
|
id: string;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
data?: Record<string, unknown>;
|
|
113
|
+
url: string;
|
|
114
|
+
events: string[];
|
|
115
|
+
active: boolean;
|
|
116
|
+
createdAt: string;
|
|
117
|
+
lastTriggered?: string;
|
|
118
|
+
failureCount: number;
|
|
56
119
|
}
|
|
57
|
-
interface
|
|
58
|
-
|
|
120
|
+
interface VerificationResult {
|
|
121
|
+
valid: boolean;
|
|
122
|
+
ipfsHash: string;
|
|
123
|
+
documentHash?: string;
|
|
124
|
+
timestamp?: string;
|
|
125
|
+
certificateId?: string;
|
|
126
|
+
blockchainTx?: string;
|
|
127
|
+
blockNumber?: number;
|
|
128
|
+
attestationMode?: AttestationMode;
|
|
129
|
+
proofVerified: boolean;
|
|
130
|
+
message: string;
|
|
131
|
+
}
|
|
132
|
+
interface SearchResult {
|
|
59
133
|
total: number;
|
|
134
|
+
page: number;
|
|
60
135
|
limit: number;
|
|
61
|
-
|
|
136
|
+
events: Event[];
|
|
62
137
|
}
|
|
63
|
-
interface
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
138
|
+
interface UsageStats {
|
|
139
|
+
periodStart: string;
|
|
140
|
+
periodEnd: string;
|
|
141
|
+
eventsCreated: number;
|
|
142
|
+
documentsAttested: number;
|
|
143
|
+
verifications: number;
|
|
144
|
+
apiCalls: number;
|
|
145
|
+
storageBytes: number;
|
|
146
|
+
channelsCreated: number;
|
|
147
|
+
settlements: number;
|
|
68
148
|
}
|
|
69
|
-
interface
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
149
|
+
interface TenantInfo {
|
|
150
|
+
tenantId: string;
|
|
151
|
+
name: string;
|
|
152
|
+
subdomain: string;
|
|
153
|
+
plan: string;
|
|
154
|
+
createdAt: string;
|
|
155
|
+
apiKeysCount: number;
|
|
156
|
+
eventsCount: number;
|
|
157
|
+
storageUsedBytes: number;
|
|
78
158
|
}
|
|
79
|
-
interface
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
159
|
+
interface StreamAck {
|
|
160
|
+
sequence: number;
|
|
161
|
+
channelId: string;
|
|
162
|
+
received: boolean;
|
|
83
163
|
}
|
|
84
|
-
interface
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
onchain_synced?: boolean;
|
|
164
|
+
interface AttestRequest {
|
|
165
|
+
file: File | Blob | Buffer | ArrayBuffer;
|
|
166
|
+
filename?: string;
|
|
167
|
+
userId: string;
|
|
168
|
+
eventType?: string;
|
|
169
|
+
metadata?: Record<string, unknown>;
|
|
170
|
+
encrypt?: boolean;
|
|
92
171
|
}
|
|
93
|
-
interface
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
172
|
+
interface CreateEventRequest {
|
|
173
|
+
eventType: string;
|
|
174
|
+
userId: string;
|
|
175
|
+
data?: Record<string, unknown>;
|
|
176
|
+
source?: string;
|
|
98
177
|
}
|
|
99
|
-
interface
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
178
|
+
interface ListEventsRequest {
|
|
179
|
+
userId?: string;
|
|
180
|
+
eventType?: string;
|
|
181
|
+
status?: string;
|
|
182
|
+
startDate?: string;
|
|
183
|
+
endDate?: string;
|
|
184
|
+
limit?: number;
|
|
185
|
+
offset?: number;
|
|
103
186
|
}
|
|
104
|
-
interface
|
|
105
|
-
|
|
106
|
-
|
|
187
|
+
interface SearchRequest {
|
|
188
|
+
query: string;
|
|
189
|
+
userId?: string;
|
|
190
|
+
eventType?: string;
|
|
191
|
+
startDate?: string;
|
|
192
|
+
endDate?: string;
|
|
193
|
+
limit?: number;
|
|
194
|
+
page?: number;
|
|
107
195
|
}
|
|
108
|
-
interface
|
|
109
|
-
id: string;
|
|
196
|
+
interface CreateChannelRequest {
|
|
110
197
|
name: string;
|
|
111
198
|
description?: string;
|
|
112
|
-
order: number;
|
|
113
|
-
step_type: 'event_count' | 'event_match' | 'unique_values' | 'cumulative' | 'streak' | 'manual';
|
|
114
|
-
event_type?: string;
|
|
115
|
-
event_types?: string[];
|
|
116
|
-
criteria?: Record<string, unknown>;
|
|
117
|
-
required_data_fields?: Record<string, unknown>;
|
|
118
|
-
step_points?: number;
|
|
119
|
-
icon_url?: string;
|
|
120
|
-
is_optional: boolean;
|
|
121
199
|
}
|
|
122
|
-
interface
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
200
|
+
interface StreamEventRequest {
|
|
201
|
+
eventType: string;
|
|
202
|
+
userId: string;
|
|
203
|
+
data?: Record<string, unknown>;
|
|
204
|
+
source?: string;
|
|
205
|
+
}
|
|
206
|
+
interface IssueCertificateRequest {
|
|
207
|
+
recipientName: string;
|
|
208
|
+
recipientEmail?: string;
|
|
209
|
+
title: string;
|
|
126
210
|
description?: string;
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
current_completions: number;
|
|
145
|
-
reward_points?: number;
|
|
146
|
-
is_public: boolean;
|
|
147
|
-
is_featured: boolean;
|
|
148
|
-
tags: string[];
|
|
149
|
-
steps: QuestStep[];
|
|
150
|
-
created_at: string;
|
|
211
|
+
metadata?: Record<string, unknown>;
|
|
212
|
+
expiresAt?: string;
|
|
213
|
+
}
|
|
214
|
+
interface ListCertificatesRequest {
|
|
215
|
+
recipientEmail?: string;
|
|
216
|
+
limit?: number;
|
|
217
|
+
offset?: number;
|
|
218
|
+
}
|
|
219
|
+
interface CreateWebhookRequest {
|
|
220
|
+
url: string;
|
|
221
|
+
events: string[];
|
|
222
|
+
secret?: string;
|
|
223
|
+
}
|
|
224
|
+
interface UpdateWebhookRequest {
|
|
225
|
+
url?: string;
|
|
226
|
+
events?: string[];
|
|
227
|
+
active?: boolean;
|
|
151
228
|
}
|
|
152
|
-
interface
|
|
229
|
+
interface VaultFile {
|
|
230
|
+
id: string;
|
|
231
|
+
filename: string;
|
|
232
|
+
mimeType: string;
|
|
233
|
+
size: number;
|
|
234
|
+
ipfsHash: string;
|
|
235
|
+
userId: string;
|
|
236
|
+
folderId?: string;
|
|
237
|
+
accessMode: 'private' | 'public' | 'shared';
|
|
238
|
+
createdAt: string;
|
|
239
|
+
updatedAt?: string;
|
|
240
|
+
}
|
|
241
|
+
interface VaultFolder {
|
|
153
242
|
id: string;
|
|
154
243
|
name: string;
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
image_url?: string;
|
|
158
|
-
issued_at?: string;
|
|
159
|
-
claimed: boolean;
|
|
160
|
-
claim_url?: string;
|
|
161
|
-
metadata: Record<string, unknown>;
|
|
244
|
+
parentId?: string;
|
|
245
|
+
createdAt: string;
|
|
162
246
|
}
|
|
163
|
-
interface
|
|
247
|
+
interface VaultListResponse {
|
|
248
|
+
files: VaultFile[];
|
|
249
|
+
folders: VaultFolder[];
|
|
250
|
+
totalFiles: number;
|
|
251
|
+
totalSize: number;
|
|
252
|
+
}
|
|
253
|
+
interface VaultStats {
|
|
254
|
+
totalFiles: number;
|
|
255
|
+
totalFolders: number;
|
|
256
|
+
totalSize: number;
|
|
257
|
+
usedQuota: number;
|
|
258
|
+
maxQuota: number;
|
|
259
|
+
}
|
|
260
|
+
interface VaultUploadRequest {
|
|
261
|
+
file: File | Blob | Buffer | ArrayBuffer;
|
|
262
|
+
filename?: string;
|
|
263
|
+
userId: string;
|
|
264
|
+
folderId?: string;
|
|
265
|
+
accessMode?: 'private' | 'public' | 'shared';
|
|
266
|
+
}
|
|
267
|
+
interface SearchFilters {
|
|
268
|
+
query?: string;
|
|
269
|
+
eventTypes?: string[];
|
|
270
|
+
eventSources?: string[];
|
|
271
|
+
userIds?: string[];
|
|
272
|
+
status?: string;
|
|
273
|
+
hasDocument?: boolean;
|
|
274
|
+
hasBlockchainProof?: boolean;
|
|
275
|
+
fromDate?: string;
|
|
276
|
+
toDate?: string;
|
|
277
|
+
}
|
|
278
|
+
interface SearchQueryRequest {
|
|
279
|
+
filters?: SearchFilters;
|
|
280
|
+
offset?: number;
|
|
281
|
+
limit?: number;
|
|
282
|
+
includeData?: boolean;
|
|
283
|
+
}
|
|
284
|
+
interface SearchResponse {
|
|
285
|
+
total: number;
|
|
286
|
+
offset: number;
|
|
287
|
+
limit: number;
|
|
288
|
+
results: Event[];
|
|
289
|
+
}
|
|
290
|
+
interface Facet {
|
|
291
|
+
key: string;
|
|
292
|
+
count: number;
|
|
293
|
+
}
|
|
294
|
+
interface FacetsResponse {
|
|
295
|
+
eventTypes: Facet[];
|
|
296
|
+
eventSources: Facet[];
|
|
297
|
+
statuses: Facet[];
|
|
298
|
+
users: Facet[];
|
|
299
|
+
}
|
|
300
|
+
interface SearchStats {
|
|
301
|
+
periodDays: number;
|
|
302
|
+
totalEvents: number;
|
|
303
|
+
uniqueUsers: number;
|
|
304
|
+
eventsPerDay: number;
|
|
305
|
+
totalStorageBytes: number;
|
|
306
|
+
}
|
|
307
|
+
interface CertificateVerifyResult {
|
|
308
|
+
certificateId: string;
|
|
309
|
+
status: 'VALID' | 'REVOKED' | 'EXPIRED' | 'NOT_FOUND';
|
|
310
|
+
recipientName: string;
|
|
311
|
+
title: string;
|
|
312
|
+
issuedAt: string;
|
|
313
|
+
expiresAt?: string;
|
|
314
|
+
revokedAt?: string;
|
|
315
|
+
revocationReason?: string;
|
|
316
|
+
ipfsHash: string;
|
|
317
|
+
verifyUrl: string;
|
|
318
|
+
blockchain?: Record<string, unknown>;
|
|
319
|
+
}
|
|
320
|
+
interface ProofVerifyResult {
|
|
321
|
+
valid: boolean;
|
|
322
|
+
message: string;
|
|
323
|
+
verifiedAt: string;
|
|
324
|
+
}
|
|
325
|
+
interface BatchVerifyResult {
|
|
326
|
+
batchId: string;
|
|
327
|
+
merkleRoot: string;
|
|
328
|
+
totalEvents: number;
|
|
329
|
+
blockchainTx?: string;
|
|
330
|
+
blockNumber?: number;
|
|
331
|
+
verified: boolean;
|
|
332
|
+
}
|
|
333
|
+
interface EventBatchProof {
|
|
334
|
+
eventId: string;
|
|
335
|
+
certificateId: string;
|
|
336
|
+
batchId: string;
|
|
337
|
+
leafIndex: number;
|
|
338
|
+
merkleProof: string[];
|
|
339
|
+
merkleRoot: string;
|
|
340
|
+
blockchainTx?: string;
|
|
341
|
+
verified: boolean;
|
|
342
|
+
}
|
|
343
|
+
interface ApiKey {
|
|
164
344
|
id: string;
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
step_progress: Record<string, {
|
|
174
|
-
count: number;
|
|
175
|
-
unique_values?: string[];
|
|
176
|
-
completed?: boolean;
|
|
177
|
-
completed_at?: string;
|
|
178
|
-
}>;
|
|
179
|
-
started_at?: string;
|
|
180
|
-
completed_at?: string;
|
|
181
|
-
expires_at?: string;
|
|
182
|
-
completion_count: number;
|
|
183
|
-
reward_earned_id?: string;
|
|
184
|
-
reward_issued_at?: string;
|
|
185
|
-
reward?: RewardInfo;
|
|
186
|
-
}
|
|
187
|
-
interface QuestWithProgress {
|
|
188
|
-
quest: Quest;
|
|
189
|
-
progress?: UserQuestProgress;
|
|
190
|
-
}
|
|
191
|
-
interface QuestStepCompletionResult {
|
|
192
|
-
step_index: number;
|
|
193
|
-
step_completed: boolean;
|
|
194
|
-
quest_completed: boolean;
|
|
195
|
-
current_count: number;
|
|
196
|
-
target_count: number;
|
|
197
|
-
points_earned: number;
|
|
345
|
+
name: string;
|
|
346
|
+
keyPrefix: string;
|
|
347
|
+
permissions: string[];
|
|
348
|
+
createdAt: string;
|
|
349
|
+
lastUsedAt?: string;
|
|
350
|
+
expiresAt?: string;
|
|
351
|
+
isActive: boolean;
|
|
352
|
+
key?: string;
|
|
198
353
|
}
|
|
354
|
+
interface BlockchainStats {
|
|
355
|
+
totalTransactions: number;
|
|
356
|
+
totalGasUsed: number;
|
|
357
|
+
totalEventsAttested: number;
|
|
358
|
+
pendingEvents: number;
|
|
359
|
+
lastTransaction?: string;
|
|
360
|
+
contractAddress?: string;
|
|
361
|
+
chainId: number;
|
|
362
|
+
chainName: string;
|
|
363
|
+
}
|
|
364
|
+
interface BlockchainProof {
|
|
365
|
+
certificateId: string;
|
|
366
|
+
verified: boolean;
|
|
367
|
+
txHash?: string;
|
|
368
|
+
blockNumber?: number;
|
|
369
|
+
merkleRoot?: string;
|
|
370
|
+
merkleProof?: string[];
|
|
371
|
+
leafIndex?: number;
|
|
372
|
+
chainName: string;
|
|
373
|
+
}
|
|
374
|
+
interface CreateApiKeyRequest {
|
|
375
|
+
name: string;
|
|
376
|
+
permissions?: string[];
|
|
377
|
+
expiresInDays?: number;
|
|
378
|
+
}
|
|
379
|
+
interface ProofChainOptions {
|
|
380
|
+
apiKey: string;
|
|
381
|
+
baseUrl?: string;
|
|
382
|
+
timeout?: number;
|
|
383
|
+
maxRetries?: number;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* Vault Resource - File storage operations
|
|
388
|
+
*/
|
|
199
389
|
|
|
200
|
-
declare class
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
390
|
+
declare class VaultResource {
|
|
391
|
+
private http;
|
|
392
|
+
constructor(http: HttpClient);
|
|
393
|
+
/**
|
|
394
|
+
* List files and folders in the vault.
|
|
395
|
+
*/
|
|
396
|
+
list(folderId?: string): Promise<VaultListResponse>;
|
|
397
|
+
/**
|
|
398
|
+
* Upload a file to the vault.
|
|
399
|
+
*/
|
|
400
|
+
upload(request: VaultUploadRequest): Promise<VaultFile>;
|
|
401
|
+
/**
|
|
402
|
+
* Get file details.
|
|
403
|
+
*/
|
|
404
|
+
get(fileId: string): Promise<VaultFile>;
|
|
405
|
+
/**
|
|
406
|
+
* Download a file.
|
|
407
|
+
*/
|
|
408
|
+
download(fileId: string): Promise<ArrayBuffer>;
|
|
409
|
+
/**
|
|
410
|
+
* Delete a file.
|
|
411
|
+
*/
|
|
412
|
+
delete(fileId: string): Promise<void>;
|
|
413
|
+
/**
|
|
414
|
+
* Move a file to a folder.
|
|
415
|
+
*/
|
|
416
|
+
move(fileId: string, folderId: string): Promise<VaultFile>;
|
|
417
|
+
/**
|
|
418
|
+
* Create a folder.
|
|
419
|
+
*/
|
|
420
|
+
createFolder(name: string, parentId?: string): Promise<VaultFolder>;
|
|
421
|
+
/**
|
|
422
|
+
* Delete a folder.
|
|
423
|
+
*/
|
|
424
|
+
deleteFolder(folderId: string): Promise<void>;
|
|
425
|
+
/**
|
|
426
|
+
* Get vault statistics.
|
|
427
|
+
*/
|
|
428
|
+
stats(): Promise<VaultStats>;
|
|
429
|
+
/**
|
|
430
|
+
* Create a shareable link.
|
|
431
|
+
*/
|
|
432
|
+
share(fileId: string, expiresInHours?: number): Promise<{
|
|
433
|
+
url: string;
|
|
434
|
+
expiresAt: string;
|
|
435
|
+
}>;
|
|
204
436
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
health(): Promise<HealthResponse>;
|
|
214
|
-
requestChallenge(walletAddress: string): Promise<ChallengeResponse>;
|
|
215
|
-
verifySignature(walletAddress: string, signature: string, message: string): Promise<AuthResponse>;
|
|
216
|
-
createEvent(event: EventCreate): Promise<Event>;
|
|
217
|
-
getEvents(userId: string, options?: {
|
|
218
|
-
limit?: number;
|
|
219
|
-
offset?: number;
|
|
220
|
-
eventType?: string;
|
|
221
|
-
fetchData?: boolean;
|
|
222
|
-
}): Promise<EventsListResponse>;
|
|
223
|
-
queryEvents(userId: string, query: EventQuery): Promise<EventsListResponse>;
|
|
224
|
-
rebuildMerkleTree(userId: string): Promise<MerkleTree>;
|
|
225
|
-
getMerkleRoot(userId: string): Promise<MerkleTree>;
|
|
226
|
-
getMerkleProof(userId: string, ipfsHash: string): Promise<MerkleProof>;
|
|
227
|
-
verifyMerkleProof(leaf: string, proof: string[], root: string): Promise<VerifyProofResponse>;
|
|
228
|
-
linkWallet(request: LinkWalletRequest): Promise<Wallet>;
|
|
229
|
-
getWalletStatus(userId: string): Promise<WalletStatus>;
|
|
230
|
-
/**
|
|
231
|
-
* List available quests for a user
|
|
232
|
-
* @param userId - End user external ID
|
|
233
|
-
* @param options - Filter options
|
|
234
|
-
*/
|
|
235
|
-
getAvailableQuests(userId: string, options?: {
|
|
236
|
-
category?: string;
|
|
237
|
-
limit?: number;
|
|
238
|
-
}): Promise<QuestWithProgress[]>;
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* Search Resource - Advanced search operations
|
|
440
|
+
*/
|
|
441
|
+
|
|
442
|
+
declare class SearchResource {
|
|
443
|
+
private http;
|
|
444
|
+
constructor(http: HttpClient);
|
|
239
445
|
/**
|
|
240
|
-
*
|
|
241
|
-
* @param questId - Quest ID
|
|
446
|
+
* Search events with filters.
|
|
242
447
|
*/
|
|
243
|
-
|
|
448
|
+
query(request?: SearchQueryRequest): Promise<SearchResponse>;
|
|
244
449
|
/**
|
|
245
|
-
*
|
|
246
|
-
* @param questId - Quest ID
|
|
247
|
-
* @param userId - End user external ID
|
|
450
|
+
* Quick search across all fields.
|
|
248
451
|
*/
|
|
249
|
-
|
|
452
|
+
quick(query: string, limit?: number): Promise<SearchResponse>;
|
|
250
453
|
/**
|
|
251
|
-
* Get
|
|
252
|
-
* @param questId - Quest ID
|
|
253
|
-
* @param userId - End user external ID
|
|
454
|
+
* Get events for a specific user.
|
|
254
455
|
*/
|
|
255
|
-
|
|
456
|
+
byUser(userId: string, limit?: number, offset?: number): Promise<SearchResponse>;
|
|
256
457
|
/**
|
|
257
|
-
* Get
|
|
258
|
-
|
|
259
|
-
|
|
458
|
+
* Get event by certificate ID.
|
|
459
|
+
*/
|
|
460
|
+
byCertificate(certificateId: string): Promise<Event>;
|
|
461
|
+
/**
|
|
462
|
+
* Get faceted aggregations.
|
|
260
463
|
*/
|
|
261
|
-
|
|
464
|
+
facets(fromDate?: string, toDate?: string): Promise<FacetsResponse>;
|
|
262
465
|
/**
|
|
263
|
-
*
|
|
264
|
-
* @param questId - Quest ID
|
|
265
|
-
* @param userId - End user external ID
|
|
266
|
-
* @param stepIndex - Step index (0-based)
|
|
267
|
-
* @param options - Completion options
|
|
466
|
+
* Get search statistics.
|
|
268
467
|
*/
|
|
269
|
-
|
|
270
|
-
count?: number;
|
|
271
|
-
value?: string;
|
|
272
|
-
}): Promise<QuestStepCompletionResult>;
|
|
468
|
+
stats(): Promise<SearchStats>;
|
|
273
469
|
}
|
|
274
470
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
471
|
+
/**
|
|
472
|
+
* Verify Resource - Public verification operations
|
|
473
|
+
*/
|
|
474
|
+
|
|
475
|
+
declare class VerifyResource {
|
|
476
|
+
private http;
|
|
477
|
+
constructor(http: HttpClient);
|
|
478
|
+
/**
|
|
479
|
+
* Verify a certificate by ID.
|
|
480
|
+
*/
|
|
481
|
+
certificate(certificateId: string): Promise<CertificateVerifyResult>;
|
|
482
|
+
/**
|
|
483
|
+
* Verify an event by IPFS hash.
|
|
484
|
+
*/
|
|
485
|
+
event(ipfsHash: string): Promise<Record<string, unknown>>;
|
|
486
|
+
/**
|
|
487
|
+
* Verify a Merkle proof.
|
|
488
|
+
*/
|
|
489
|
+
proof(leaf: string, proof: string[], root: string): Promise<ProofVerifyResult>;
|
|
490
|
+
/**
|
|
491
|
+
* Verify a batch by ID.
|
|
492
|
+
*/
|
|
493
|
+
batch(batchId: string): Promise<BatchVerifyResult>;
|
|
494
|
+
/**
|
|
495
|
+
* Get batch proof for an event.
|
|
496
|
+
*/
|
|
497
|
+
eventBatchProof(eventId: string): Promise<EventBatchProof>;
|
|
498
|
+
/**
|
|
499
|
+
* Batch verify multiple items.
|
|
500
|
+
*/
|
|
501
|
+
batchVerify(items: Array<{
|
|
502
|
+
type: string;
|
|
503
|
+
id: string;
|
|
504
|
+
}>): Promise<Record<string, unknown>>;
|
|
280
505
|
}
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
506
|
+
|
|
507
|
+
/**
|
|
508
|
+
* Tenant Resource - Tenant management operations
|
|
509
|
+
*/
|
|
510
|
+
|
|
511
|
+
declare class TenantResource {
|
|
512
|
+
private http;
|
|
513
|
+
constructor(http: HttpClient);
|
|
514
|
+
/**
|
|
515
|
+
* List all API keys.
|
|
516
|
+
*/
|
|
517
|
+
listApiKeys(): Promise<ApiKey[]>;
|
|
518
|
+
/**
|
|
519
|
+
* Create a new API key.
|
|
520
|
+
*/
|
|
521
|
+
createApiKey(request: CreateApiKeyRequest): Promise<ApiKey>;
|
|
522
|
+
/**
|
|
523
|
+
* Delete an API key.
|
|
524
|
+
*/
|
|
525
|
+
deleteApiKey(keyId: string): Promise<void>;
|
|
526
|
+
/**
|
|
527
|
+
* Get detailed usage statistics.
|
|
528
|
+
*/
|
|
529
|
+
usageDetailed(fromDate?: string, toDate?: string): Promise<Record<string, unknown>>;
|
|
530
|
+
/**
|
|
531
|
+
* Get tenant context.
|
|
532
|
+
*/
|
|
533
|
+
context(): Promise<Record<string, unknown>>;
|
|
534
|
+
/**
|
|
535
|
+
* Get blockchain statistics.
|
|
536
|
+
*/
|
|
537
|
+
blockchainStats(): Promise<BlockchainStats>;
|
|
538
|
+
/**
|
|
539
|
+
* Verify a certificate on the blockchain.
|
|
540
|
+
*/
|
|
541
|
+
blockchainVerify(certificateId: string): Promise<BlockchainProof>;
|
|
542
|
+
/**
|
|
543
|
+
* List blockchain certificates.
|
|
544
|
+
*/
|
|
545
|
+
blockchainCertificates(limit?: number, offset?: number): Promise<Record<string, unknown>>;
|
|
546
|
+
/**
|
|
547
|
+
* Force batch settlement.
|
|
548
|
+
*/
|
|
549
|
+
forceBatch(): Promise<Record<string, unknown>>;
|
|
550
|
+
/**
|
|
551
|
+
* Settle all pending events.
|
|
552
|
+
*/
|
|
553
|
+
settleAll(): Promise<Record<string, unknown>>;
|
|
554
|
+
/**
|
|
555
|
+
* Settle a specific event.
|
|
556
|
+
*/
|
|
557
|
+
settleEvent(eventId: string): Promise<Record<string, unknown>>;
|
|
314
558
|
}
|
|
315
559
|
|
|
316
560
|
/**
|
|
317
|
-
*
|
|
318
|
-
* All Rights Reserved.
|
|
561
|
+
* Passport API Client
|
|
319
562
|
*
|
|
320
|
-
*
|
|
321
|
-
* This software is the exclusive property of MegaWatts Solutions.
|
|
322
|
-
* Unauthorized copying, distribution, or use is strictly prohibited.
|
|
323
|
-
* See LICENSE file for full terms.
|
|
563
|
+
* Manage user passports, templates, badges, and achievements.
|
|
324
564
|
*/
|
|
325
565
|
|
|
326
|
-
|
|
566
|
+
interface Passport {
|
|
567
|
+
id: string;
|
|
568
|
+
tenant_id: string;
|
|
569
|
+
user_id: string;
|
|
570
|
+
wallet_address?: string;
|
|
571
|
+
level: number;
|
|
572
|
+
points: number;
|
|
573
|
+
experience: number;
|
|
574
|
+
traits: Record<string, any>;
|
|
575
|
+
custom_metadata: Record<string, any>;
|
|
576
|
+
on_chain_token_id?: string;
|
|
577
|
+
on_chain_tx_hash?: string;
|
|
578
|
+
created_at: string;
|
|
579
|
+
last_updated_at: string;
|
|
580
|
+
}
|
|
581
|
+
interface PassportWithFields extends Passport {
|
|
582
|
+
template_id?: string;
|
|
583
|
+
template_name?: string;
|
|
584
|
+
field_values: FieldValue[];
|
|
585
|
+
}
|
|
586
|
+
interface FieldValue {
|
|
587
|
+
field_key: string;
|
|
588
|
+
field_name: string;
|
|
589
|
+
value: any;
|
|
590
|
+
data_type: string;
|
|
591
|
+
computed_at?: string;
|
|
592
|
+
manually_set: boolean;
|
|
593
|
+
}
|
|
594
|
+
interface PassportTemplate {
|
|
595
|
+
id: string;
|
|
596
|
+
tenant_id: string;
|
|
597
|
+
name: string;
|
|
598
|
+
description?: string;
|
|
599
|
+
slug: string;
|
|
600
|
+
icon_url?: string;
|
|
601
|
+
is_default: boolean;
|
|
602
|
+
is_active: boolean;
|
|
603
|
+
created_at: string;
|
|
604
|
+
updated_at: string;
|
|
605
|
+
fields: TemplateField[];
|
|
606
|
+
}
|
|
607
|
+
interface TemplateField {
|
|
608
|
+
id: string;
|
|
609
|
+
template_id: string;
|
|
610
|
+
name: string;
|
|
611
|
+
field_key: string;
|
|
612
|
+
description?: string;
|
|
613
|
+
data_type: string;
|
|
614
|
+
default_value?: any;
|
|
615
|
+
formula?: string;
|
|
616
|
+
formula_type?: string;
|
|
617
|
+
aggregation?: string;
|
|
618
|
+
event_filter?: Record<string, any>;
|
|
619
|
+
display_format?: string;
|
|
620
|
+
icon?: string;
|
|
621
|
+
color?: string;
|
|
622
|
+
sort_order: number;
|
|
623
|
+
is_visible: boolean;
|
|
624
|
+
is_computed: boolean;
|
|
625
|
+
created_at: string;
|
|
626
|
+
}
|
|
627
|
+
interface Badge {
|
|
628
|
+
id: string;
|
|
629
|
+
tenant_id: string;
|
|
630
|
+
badge_id: string;
|
|
631
|
+
name: string;
|
|
632
|
+
description?: string;
|
|
633
|
+
icon_url?: string;
|
|
634
|
+
rarity: string;
|
|
635
|
+
requirements: Record<string, any>;
|
|
636
|
+
created_at: string;
|
|
637
|
+
}
|
|
638
|
+
interface Achievement {
|
|
639
|
+
id: string;
|
|
640
|
+
tenant_id: string;
|
|
641
|
+
achievement_id: string;
|
|
642
|
+
name: string;
|
|
643
|
+
description?: string;
|
|
644
|
+
category?: string;
|
|
645
|
+
points_reward: number;
|
|
646
|
+
requirements: Record<string, any>;
|
|
647
|
+
created_at: string;
|
|
648
|
+
}
|
|
649
|
+
interface UserBadge {
|
|
650
|
+
id: string;
|
|
651
|
+
passport_id: string;
|
|
652
|
+
badge_id: string;
|
|
653
|
+
badge: Badge;
|
|
654
|
+
earned_at: string;
|
|
655
|
+
metadata?: Record<string, any>;
|
|
656
|
+
}
|
|
657
|
+
interface UserAchievement {
|
|
658
|
+
id: string;
|
|
659
|
+
passport_id: string;
|
|
660
|
+
achievement_id: string;
|
|
661
|
+
achievement: Achievement;
|
|
662
|
+
earned_at: string;
|
|
663
|
+
progress: number;
|
|
664
|
+
completed: boolean;
|
|
665
|
+
}
|
|
666
|
+
interface PassportHistory {
|
|
667
|
+
id: string;
|
|
668
|
+
passport_id: string;
|
|
669
|
+
event_type: string;
|
|
670
|
+
old_value?: any;
|
|
671
|
+
new_value?: any;
|
|
672
|
+
change_reason?: string;
|
|
673
|
+
created_at: string;
|
|
674
|
+
}
|
|
675
|
+
interface CreatePassportRequest {
|
|
676
|
+
user_id: string;
|
|
677
|
+
wallet_address?: string;
|
|
678
|
+
level?: number;
|
|
679
|
+
points?: number;
|
|
680
|
+
experience?: number;
|
|
681
|
+
traits?: Record<string, any>;
|
|
682
|
+
custom_metadata?: Record<string, any>;
|
|
683
|
+
}
|
|
684
|
+
interface UpdatePassportRequest {
|
|
685
|
+
wallet_address?: string;
|
|
686
|
+
level?: number;
|
|
687
|
+
points?: number;
|
|
688
|
+
experience?: number;
|
|
689
|
+
traits?: Record<string, any>;
|
|
690
|
+
custom_metadata?: Record<string, any>;
|
|
691
|
+
}
|
|
692
|
+
interface CreateTemplateRequest {
|
|
693
|
+
name: string;
|
|
694
|
+
description?: string;
|
|
695
|
+
slug: string;
|
|
696
|
+
icon_url?: string;
|
|
697
|
+
is_default?: boolean;
|
|
698
|
+
fields?: CreateTemplateFieldRequest[];
|
|
699
|
+
}
|
|
700
|
+
interface CreateTemplateFieldRequest {
|
|
701
|
+
name: string;
|
|
702
|
+
field_key: string;
|
|
703
|
+
description?: string;
|
|
704
|
+
data_type?: string;
|
|
705
|
+
default_value?: any;
|
|
706
|
+
formula?: string;
|
|
707
|
+
formula_type?: string;
|
|
708
|
+
aggregation?: string;
|
|
709
|
+
event_filter?: Record<string, any>;
|
|
710
|
+
display_format?: string;
|
|
711
|
+
icon?: string;
|
|
712
|
+
color?: string;
|
|
713
|
+
sort_order?: number;
|
|
714
|
+
is_visible?: boolean;
|
|
715
|
+
is_computed?: boolean;
|
|
716
|
+
}
|
|
717
|
+
interface CreateBadgeRequest {
|
|
718
|
+
badge_id: string;
|
|
719
|
+
name: string;
|
|
720
|
+
description?: string;
|
|
721
|
+
icon_url?: string;
|
|
722
|
+
rarity?: string;
|
|
723
|
+
requirements?: Record<string, any>;
|
|
724
|
+
}
|
|
725
|
+
interface CreateAchievementRequest {
|
|
726
|
+
achievement_id: string;
|
|
727
|
+
name: string;
|
|
728
|
+
description?: string;
|
|
729
|
+
category?: string;
|
|
730
|
+
points_reward?: number;
|
|
731
|
+
requirements?: Record<string, any>;
|
|
732
|
+
}
|
|
733
|
+
interface ListOptions {
|
|
734
|
+
limit?: number;
|
|
735
|
+
offset?: number;
|
|
736
|
+
}
|
|
737
|
+
declare class PassportClient {
|
|
738
|
+
private http;
|
|
739
|
+
constructor(http: HttpClient);
|
|
740
|
+
/**
|
|
741
|
+
* List all passports for the tenant
|
|
742
|
+
*/
|
|
743
|
+
list(options?: ListOptions): Promise<Passport[]>;
|
|
744
|
+
/**
|
|
745
|
+
* Get a passport by user ID
|
|
746
|
+
*/
|
|
747
|
+
get(userId: string): Promise<Passport>;
|
|
748
|
+
/**
|
|
749
|
+
* Get a passport with all field values
|
|
750
|
+
*/
|
|
751
|
+
getWithFields(userId: string): Promise<PassportWithFields>;
|
|
752
|
+
/**
|
|
753
|
+
* Create a new passport for a user
|
|
754
|
+
*/
|
|
755
|
+
create(data: CreatePassportRequest): Promise<Passport>;
|
|
756
|
+
/**
|
|
757
|
+
* Update a passport
|
|
758
|
+
*/
|
|
759
|
+
update(userId: string, data: UpdatePassportRequest): Promise<Passport>;
|
|
760
|
+
/**
|
|
761
|
+
* Delete a passport
|
|
762
|
+
*/
|
|
763
|
+
delete(userId: string): Promise<void>;
|
|
764
|
+
/**
|
|
765
|
+
* Add points to a passport
|
|
766
|
+
*/
|
|
767
|
+
addPoints(userId: string, points: number, reason?: string): Promise<Passport>;
|
|
768
|
+
/**
|
|
769
|
+
* Level up a passport
|
|
770
|
+
*/
|
|
771
|
+
levelUp(userId: string): Promise<Passport>;
|
|
772
|
+
/**
|
|
773
|
+
* Link a wallet address to a passport
|
|
774
|
+
*/
|
|
775
|
+
linkWallet(userId: string, walletAddress: string): Promise<Passport>;
|
|
776
|
+
/**
|
|
777
|
+
* Get all field values for a passport
|
|
778
|
+
*/
|
|
779
|
+
getFieldValues(userId: string): Promise<FieldValue[]>;
|
|
780
|
+
/**
|
|
781
|
+
* Set a field value manually
|
|
782
|
+
*/
|
|
783
|
+
setFieldValue(userId: string, fieldKey: string, value: any): Promise<void>;
|
|
784
|
+
/**
|
|
785
|
+
* Recompute all computed field values
|
|
786
|
+
*/
|
|
787
|
+
recomputeFields(userId: string): Promise<{
|
|
788
|
+
updated_fields: Record<string, any>;
|
|
789
|
+
}>;
|
|
790
|
+
/**
|
|
791
|
+
* Assign a template to a passport
|
|
792
|
+
*/
|
|
793
|
+
assignTemplate(userId: string, templateId: string): Promise<void>;
|
|
794
|
+
/**
|
|
795
|
+
* List all passport templates
|
|
796
|
+
*/
|
|
797
|
+
listTemplates(): Promise<PassportTemplate[]>;
|
|
798
|
+
/**
|
|
799
|
+
* Get a template by ID
|
|
800
|
+
*/
|
|
801
|
+
getTemplate(templateId: string): Promise<PassportTemplate>;
|
|
802
|
+
/**
|
|
803
|
+
* Create a new template
|
|
804
|
+
*/
|
|
805
|
+
createTemplate(data: CreateTemplateRequest): Promise<PassportTemplate>;
|
|
806
|
+
/**
|
|
807
|
+
* Add a field to a template
|
|
808
|
+
*/
|
|
809
|
+
addTemplateField(templateId: string, field: CreateTemplateFieldRequest): Promise<TemplateField>;
|
|
810
|
+
/**
|
|
811
|
+
* Delete a template
|
|
812
|
+
*/
|
|
813
|
+
deleteTemplate(templateId: string): Promise<void>;
|
|
814
|
+
/**
|
|
815
|
+
* List all badges
|
|
816
|
+
*/
|
|
817
|
+
listBadges(): Promise<Badge[]>;
|
|
818
|
+
/**
|
|
819
|
+
* Create a badge
|
|
820
|
+
*/
|
|
821
|
+
createBadge(data: CreateBadgeRequest): Promise<Badge>;
|
|
822
|
+
/**
|
|
823
|
+
* Award a badge to a user
|
|
824
|
+
*/
|
|
825
|
+
awardBadge(userId: string, badgeId: string, metadata?: Record<string, any>): Promise<UserBadge>;
|
|
826
|
+
/**
|
|
827
|
+
* Get badges earned by a user
|
|
828
|
+
*/
|
|
829
|
+
getUserBadges(userId: string): Promise<UserBadge[]>;
|
|
830
|
+
/**
|
|
831
|
+
* List all achievements
|
|
832
|
+
*/
|
|
833
|
+
listAchievements(): Promise<Achievement[]>;
|
|
834
|
+
/**
|
|
835
|
+
* Create an achievement
|
|
836
|
+
*/
|
|
837
|
+
createAchievement(data: CreateAchievementRequest): Promise<Achievement>;
|
|
838
|
+
/**
|
|
839
|
+
* Get achievements for a user
|
|
840
|
+
*/
|
|
841
|
+
getUserAchievements(userId: string): Promise<UserAchievement[]>;
|
|
842
|
+
/**
|
|
843
|
+
* Update achievement progress
|
|
844
|
+
*/
|
|
845
|
+
updateAchievementProgress(userId: string, achievementId: string, progress: number): Promise<UserAchievement>;
|
|
846
|
+
/**
|
|
847
|
+
* Get passport history/activity log
|
|
848
|
+
*/
|
|
849
|
+
getHistory(userId: string, options?: ListOptions): Promise<PassportHistory[]>;
|
|
850
|
+
/**
|
|
851
|
+
* Get passport data for a user using Passport V2 API.
|
|
852
|
+
* This integrates with custom data views for dynamic computation.
|
|
853
|
+
*
|
|
854
|
+
* @param userId - The user ID
|
|
855
|
+
* @param passportId - Optional specific passport definition ID
|
|
856
|
+
* @returns Passport data with computed fields from data view
|
|
857
|
+
*/
|
|
858
|
+
getPassportV2(userId: string, passportId?: string): Promise<PassportV2Data>;
|
|
859
|
+
/**
|
|
860
|
+
* Get passport view data for a user (alias for getPassportV2).
|
|
861
|
+
*
|
|
862
|
+
* @param userId - The user ID
|
|
863
|
+
* @param passportId - Optional specific passport definition ID
|
|
864
|
+
* @returns Passport data with computed fields from data view
|
|
865
|
+
*/
|
|
866
|
+
getPassportView(userId: string, passportId?: string): Promise<PassportV2Data>;
|
|
867
|
+
/**
|
|
868
|
+
* Get user milestones from Passport V2.
|
|
869
|
+
*
|
|
870
|
+
* @param userId - The user ID
|
|
871
|
+
* @param passportId - Optional passport ID to filter milestones
|
|
872
|
+
* @returns List of milestones achieved by the user
|
|
873
|
+
*/
|
|
874
|
+
getMilestones(userId: string, passportId?: string): Promise<Milestone[]>;
|
|
875
|
+
/**
|
|
876
|
+
* List available data views that can be used for passports.
|
|
877
|
+
* Includes built-in views and custom data views.
|
|
878
|
+
*
|
|
879
|
+
* @returns List of available views with their columns
|
|
880
|
+
*/
|
|
881
|
+
listAvailableViews(): Promise<AvailableView[]>;
|
|
882
|
+
/**
|
|
883
|
+
* List passport definitions for the tenant.
|
|
884
|
+
*
|
|
885
|
+
* @returns List of passport definitions
|
|
886
|
+
*/
|
|
887
|
+
listPassportDefinitions(): Promise<PassportDefinition[]>;
|
|
888
|
+
/**
|
|
889
|
+
* Create a new passport definition linked to a data view.
|
|
890
|
+
*
|
|
891
|
+
* @param definition - The passport definition to create
|
|
892
|
+
* @returns Created passport definition
|
|
893
|
+
*
|
|
894
|
+
* @example
|
|
895
|
+
* ```typescript
|
|
896
|
+
* const passport = await client.passports.createPassportDefinition({
|
|
897
|
+
* name: 'Fan Engagement Passport',
|
|
898
|
+
* description: 'Track fan engagement metrics',
|
|
899
|
+
* data_view_id: 'builtin-fan-profile', // or custom view UUID
|
|
900
|
+
* display_columns: ['fan_score', 'loyalty_tier', 'total_events'],
|
|
901
|
+
* column_labels: {
|
|
902
|
+
* fan_score: 'Engagement Score',
|
|
903
|
+
* loyalty_tier: 'Tier',
|
|
904
|
+
* total_events: 'Activities'
|
|
905
|
+
* }
|
|
906
|
+
* });
|
|
907
|
+
* ```
|
|
908
|
+
*/
|
|
909
|
+
createPassportDefinition(definition: CreatePassportDefinitionRequest): Promise<PassportDefinition>;
|
|
910
|
+
}
|
|
911
|
+
interface PassportV2Data {
|
|
912
|
+
user_id: string;
|
|
913
|
+
passport: PassportDefinition;
|
|
914
|
+
data: Record<string, PassportFieldValue>;
|
|
915
|
+
milestones: Milestone[];
|
|
916
|
+
generated_at: string;
|
|
917
|
+
}
|
|
918
|
+
interface PassportFieldValue {
|
|
919
|
+
label: string;
|
|
920
|
+
value: any;
|
|
921
|
+
format?: string;
|
|
922
|
+
}
|
|
923
|
+
interface PassportDefinition {
|
|
924
|
+
id: string;
|
|
925
|
+
tenant_id: string;
|
|
926
|
+
name: string;
|
|
927
|
+
description?: string;
|
|
928
|
+
slug?: string;
|
|
929
|
+
data_view_id?: string;
|
|
930
|
+
data_view_name?: string;
|
|
931
|
+
display_columns: string[];
|
|
932
|
+
column_labels: Record<string, string>;
|
|
933
|
+
column_formats: Record<string, string>;
|
|
934
|
+
is_default: boolean;
|
|
935
|
+
is_active: boolean;
|
|
936
|
+
is_public: boolean;
|
|
937
|
+
created_at: string;
|
|
938
|
+
threshold_count: number;
|
|
939
|
+
}
|
|
940
|
+
interface Milestone {
|
|
941
|
+
id: string;
|
|
942
|
+
name: string;
|
|
943
|
+
description?: string;
|
|
944
|
+
milestone_type: string;
|
|
945
|
+
icon_url?: string;
|
|
946
|
+
badge_color?: string;
|
|
947
|
+
points_reward: number;
|
|
948
|
+
triggered_at: string;
|
|
949
|
+
value_at_trigger?: any;
|
|
950
|
+
}
|
|
951
|
+
interface AvailableView {
|
|
952
|
+
id: string;
|
|
953
|
+
name: string;
|
|
954
|
+
view_name: string;
|
|
955
|
+
description?: string;
|
|
956
|
+
is_builtin: boolean;
|
|
957
|
+
is_custom_computation?: boolean;
|
|
958
|
+
view_type?: string;
|
|
959
|
+
columns: ViewColumn[];
|
|
960
|
+
}
|
|
961
|
+
interface ViewColumn {
|
|
962
|
+
name: string;
|
|
963
|
+
type: string;
|
|
964
|
+
computation_type?: string;
|
|
965
|
+
}
|
|
966
|
+
interface CreatePassportDefinitionRequest {
|
|
967
|
+
name: string;
|
|
968
|
+
description?: string;
|
|
969
|
+
slug?: string;
|
|
970
|
+
data_view_id?: string;
|
|
971
|
+
display_columns?: string[];
|
|
972
|
+
column_labels?: Record<string, string>;
|
|
973
|
+
column_formats?: Record<string, string>;
|
|
974
|
+
is_default?: boolean;
|
|
975
|
+
is_public?: boolean;
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
/**
|
|
979
|
+
* Wallet Management API Client
|
|
980
|
+
*
|
|
981
|
+
* Manage CDP wallets, NFTs, and token swaps for end-users.
|
|
982
|
+
*/
|
|
983
|
+
|
|
984
|
+
interface Wallet {
|
|
985
|
+
wallet_id: string;
|
|
986
|
+
address: string;
|
|
987
|
+
user_id: string;
|
|
988
|
+
wallet_type: 'eoa' | 'smart' | 'solana';
|
|
989
|
+
network: string;
|
|
990
|
+
name?: string;
|
|
991
|
+
status: string;
|
|
992
|
+
created_at: string;
|
|
993
|
+
metadata?: Record<string, any>;
|
|
994
|
+
supports_export?: boolean;
|
|
995
|
+
owner_wallet_id?: string;
|
|
996
|
+
is_deployed?: boolean;
|
|
997
|
+
}
|
|
998
|
+
interface DualWallets {
|
|
999
|
+
user_id: string;
|
|
1000
|
+
asset_wallet: Wallet;
|
|
1001
|
+
smart_wallet: Wallet;
|
|
1002
|
+
network: string;
|
|
1003
|
+
}
|
|
1004
|
+
interface WalletBalance {
|
|
1005
|
+
wallet_id: string;
|
|
1006
|
+
address: string;
|
|
1007
|
+
network: string;
|
|
1008
|
+
balances: TokenBalance[];
|
|
1009
|
+
}
|
|
1010
|
+
interface TokenBalance {
|
|
1011
|
+
token: string;
|
|
1012
|
+
symbol: string;
|
|
1013
|
+
balance: string;
|
|
1014
|
+
decimals: number;
|
|
1015
|
+
usd_value?: number;
|
|
1016
|
+
}
|
|
1017
|
+
interface NFT {
|
|
1018
|
+
id: string;
|
|
1019
|
+
wallet_id: string;
|
|
1020
|
+
contract_address: string;
|
|
1021
|
+
token_id: string;
|
|
1022
|
+
network: string;
|
|
1023
|
+
name?: string;
|
|
1024
|
+
description?: string;
|
|
1025
|
+
image_url?: string;
|
|
1026
|
+
metadata?: Record<string, any>;
|
|
1027
|
+
source: string;
|
|
1028
|
+
acquired_at: string;
|
|
1029
|
+
}
|
|
1030
|
+
interface SwapQuote {
|
|
1031
|
+
from_token: string;
|
|
1032
|
+
to_token: string;
|
|
1033
|
+
from_amount: string;
|
|
1034
|
+
to_amount: string;
|
|
1035
|
+
exchange_rate: string;
|
|
1036
|
+
price_impact: string;
|
|
1037
|
+
gas_estimate: string;
|
|
1038
|
+
expires_at: string;
|
|
1039
|
+
}
|
|
1040
|
+
interface SwapResult {
|
|
1041
|
+
transaction_hash: string;
|
|
1042
|
+
status: string;
|
|
1043
|
+
from_token: string;
|
|
1044
|
+
to_token: string;
|
|
1045
|
+
from_amount: string;
|
|
1046
|
+
to_amount: string;
|
|
1047
|
+
gas_used: string;
|
|
1048
|
+
}
|
|
1049
|
+
interface WalletStats {
|
|
1050
|
+
total_wallets: number;
|
|
1051
|
+
by_type: Record<string, number>;
|
|
1052
|
+
by_network: Record<string, number>;
|
|
1053
|
+
}
|
|
1054
|
+
interface ComprehensiveWalletInfo {
|
|
1055
|
+
wallet_id: string;
|
|
1056
|
+
address: string;
|
|
1057
|
+
user_id: string;
|
|
1058
|
+
wallet_type: string;
|
|
1059
|
+
network: string;
|
|
1060
|
+
name?: string;
|
|
1061
|
+
status: string;
|
|
1062
|
+
supports_export: boolean;
|
|
1063
|
+
created_at: string;
|
|
1064
|
+
metadata?: Record<string, any>;
|
|
1065
|
+
owner_wallet_id?: string;
|
|
1066
|
+
owner_address?: string;
|
|
1067
|
+
is_deployed?: boolean;
|
|
1068
|
+
balances?: {
|
|
1069
|
+
address: string;
|
|
1070
|
+
network: string;
|
|
1071
|
+
tokens: TokenBalance[];
|
|
1072
|
+
fetched_at: string;
|
|
1073
|
+
};
|
|
1074
|
+
nfts?: {
|
|
1075
|
+
total: number;
|
|
1076
|
+
items: NFT[];
|
|
1077
|
+
};
|
|
1078
|
+
activity?: {
|
|
1079
|
+
recent_swaps: SwapResult[];
|
|
1080
|
+
total_swaps: number;
|
|
1081
|
+
};
|
|
1082
|
+
}
|
|
1083
|
+
interface UserWalletSummary {
|
|
1084
|
+
user_id: string;
|
|
1085
|
+
total_wallets: number;
|
|
1086
|
+
total_nfts: number;
|
|
1087
|
+
total_swaps: number;
|
|
1088
|
+
wallets: Array<{
|
|
1089
|
+
wallet_id: string;
|
|
1090
|
+
address: string;
|
|
1091
|
+
wallet_type: string;
|
|
1092
|
+
network: string;
|
|
1093
|
+
name?: string;
|
|
1094
|
+
supports_export: boolean;
|
|
1095
|
+
created_at: string;
|
|
1096
|
+
owner_wallet_id?: string;
|
|
1097
|
+
is_deployed?: boolean;
|
|
1098
|
+
balances?: {
|
|
1099
|
+
address: string;
|
|
1100
|
+
network: string;
|
|
1101
|
+
tokens: TokenBalance[];
|
|
1102
|
+
fetched_at: string;
|
|
1103
|
+
};
|
|
1104
|
+
}>;
|
|
1105
|
+
}
|
|
1106
|
+
interface CreateWalletRequest {
|
|
1107
|
+
user_id: string;
|
|
1108
|
+
wallet_type?: 'eoa' | 'smart' | 'solana';
|
|
1109
|
+
network?: string;
|
|
1110
|
+
name?: string;
|
|
1111
|
+
metadata?: Record<string, any>;
|
|
1112
|
+
}
|
|
1113
|
+
interface CreateDualWalletsRequest {
|
|
1114
|
+
user_id: string;
|
|
1115
|
+
network?: string;
|
|
1116
|
+
name_prefix?: string;
|
|
1117
|
+
}
|
|
1118
|
+
interface SwapQuoteRequest {
|
|
1119
|
+
from_token: string;
|
|
1120
|
+
to_token: string;
|
|
1121
|
+
from_amount: string;
|
|
1122
|
+
network?: string;
|
|
1123
|
+
slippage_bps?: number;
|
|
1124
|
+
}
|
|
1125
|
+
interface ExecuteSwapRequest {
|
|
1126
|
+
wallet_id: string;
|
|
1127
|
+
from_token: string;
|
|
1128
|
+
to_token: string;
|
|
1129
|
+
from_amount: string;
|
|
1130
|
+
network?: string;
|
|
1131
|
+
slippage_bps?: number;
|
|
1132
|
+
}
|
|
1133
|
+
interface AddNFTRequest {
|
|
1134
|
+
contract_address: string;
|
|
1135
|
+
token_id: string;
|
|
1136
|
+
network: string;
|
|
1137
|
+
metadata?: Record<string, any>;
|
|
1138
|
+
source?: string;
|
|
1139
|
+
}
|
|
1140
|
+
interface TransferRequest {
|
|
1141
|
+
from_address: string;
|
|
1142
|
+
to_address: string;
|
|
1143
|
+
amount: string;
|
|
1144
|
+
token?: string;
|
|
1145
|
+
network?: string;
|
|
1146
|
+
}
|
|
1147
|
+
interface TransferResult {
|
|
1148
|
+
tx_hash: string;
|
|
1149
|
+
from: string;
|
|
1150
|
+
to: string;
|
|
1151
|
+
amount: string;
|
|
1152
|
+
token: string;
|
|
1153
|
+
network: string;
|
|
1154
|
+
status: string;
|
|
1155
|
+
}
|
|
1156
|
+
declare class WalletClient {
|
|
1157
|
+
private http;
|
|
1158
|
+
constructor(http: HttpClient);
|
|
1159
|
+
/**
|
|
1160
|
+
* Create a single wallet for a user
|
|
1161
|
+
*/
|
|
1162
|
+
create(data: CreateWalletRequest): Promise<Wallet>;
|
|
1163
|
+
/**
|
|
1164
|
+
* Get a wallet by ID
|
|
1165
|
+
*/
|
|
1166
|
+
get(walletId: string): Promise<Wallet>;
|
|
1167
|
+
/**
|
|
1168
|
+
* List wallets for a user
|
|
1169
|
+
*/
|
|
1170
|
+
listByUser(userId: string): Promise<Wallet[]>;
|
|
1171
|
+
/**
|
|
1172
|
+
* Get wallet statistics
|
|
1173
|
+
*/
|
|
1174
|
+
stats(): Promise<WalletStats>;
|
|
1175
|
+
/**
|
|
1176
|
+
* Create dual wallets (EOA asset wallet + Smart Account) for a user
|
|
1177
|
+
*/
|
|
1178
|
+
createDual(data: CreateDualWalletsRequest): Promise<DualWallets>;
|
|
1179
|
+
/**
|
|
1180
|
+
* Bulk create dual wallets for multiple users
|
|
1181
|
+
*/
|
|
1182
|
+
createDualBulk(userIds: string[], network?: string): Promise<DualWallets[]>;
|
|
1183
|
+
/**
|
|
1184
|
+
* Get wallet balance
|
|
1185
|
+
*/
|
|
1186
|
+
getBalance(walletId: string): Promise<WalletBalance>;
|
|
1187
|
+
/**
|
|
1188
|
+
* Get comprehensive wallet information in a single call.
|
|
1189
|
+
*
|
|
1190
|
+
* Returns everything about a wallet:
|
|
1191
|
+
* - Basic wallet details (address, type, network)
|
|
1192
|
+
* - Token balances (native + ERC20)
|
|
1193
|
+
* - NFT holdings with metadata
|
|
1194
|
+
* - Recent activity (swaps, transfers)
|
|
1195
|
+
*
|
|
1196
|
+
* @param walletId - Wallet ID to query
|
|
1197
|
+
* @param options - Control what data is included
|
|
1198
|
+
*/
|
|
1199
|
+
getInfo(walletId: string, options?: {
|
|
1200
|
+
includeBalances?: boolean;
|
|
1201
|
+
includeNfts?: boolean;
|
|
1202
|
+
includeActivity?: boolean;
|
|
1203
|
+
}): Promise<ComprehensiveWalletInfo>;
|
|
1204
|
+
/**
|
|
1205
|
+
* Get comprehensive summary of all wallets for a user.
|
|
1206
|
+
*
|
|
1207
|
+
* Returns all wallets (EOA + Smart) with aggregated stats:
|
|
1208
|
+
* - Total NFTs across all wallets
|
|
1209
|
+
* - Total swaps executed
|
|
1210
|
+
* - Token balances (optional)
|
|
1211
|
+
*
|
|
1212
|
+
* @param userId - User ID to query
|
|
1213
|
+
* @param includeBalances - Include token balances (requires Alchemy)
|
|
1214
|
+
*/
|
|
1215
|
+
getUserSummary(userId: string, includeBalances?: boolean): Promise<UserWalletSummary>;
|
|
1216
|
+
/**
|
|
1217
|
+
* Export private key for an EOA wallet (requires acknowledgment)
|
|
1218
|
+
*/
|
|
1219
|
+
exportKey(walletId: string): Promise<{
|
|
1220
|
+
private_key: string;
|
|
1221
|
+
warning: string;
|
|
1222
|
+
}>;
|
|
1223
|
+
/**
|
|
1224
|
+
* Transfer tokens from one address to another.
|
|
1225
|
+
*
|
|
1226
|
+
* @param request - Transfer details
|
|
1227
|
+
* @returns Transaction result with hash and status
|
|
1228
|
+
*
|
|
1229
|
+
* @example
|
|
1230
|
+
* ```typescript
|
|
1231
|
+
* const result = await client.wallets.transfer({
|
|
1232
|
+
* from_address: '0x123...',
|
|
1233
|
+
* to_address: '0x456...',
|
|
1234
|
+
* amount: '0.1',
|
|
1235
|
+
* token: 'ETH',
|
|
1236
|
+
* network: 'base-sepolia',
|
|
1237
|
+
* });
|
|
1238
|
+
* console.log('TX Hash:', result.tx_hash);
|
|
1239
|
+
* ```
|
|
1240
|
+
*/
|
|
1241
|
+
transfer(request: TransferRequest): Promise<TransferResult>;
|
|
1242
|
+
/**
|
|
1243
|
+
* Get a swap quote
|
|
1244
|
+
*/
|
|
1245
|
+
getSwapQuote(request: SwapQuoteRequest): Promise<SwapQuote>;
|
|
1246
|
+
/**
|
|
1247
|
+
* Execute a token swap
|
|
1248
|
+
*/
|
|
1249
|
+
executeSwap(request: ExecuteSwapRequest): Promise<SwapResult>;
|
|
1250
|
+
/**
|
|
1251
|
+
* Get NFTs for a wallet
|
|
1252
|
+
*/
|
|
1253
|
+
getNFTs(walletId: string): Promise<NFT[]>;
|
|
1254
|
+
/**
|
|
1255
|
+
* Get all NFTs for a user (across all wallets)
|
|
1256
|
+
*/
|
|
1257
|
+
getUserNFTs(userId: string): Promise<NFT[]>;
|
|
1258
|
+
/**
|
|
1259
|
+
* Add an NFT to wallet tracking
|
|
1260
|
+
*/
|
|
1261
|
+
addNFT(walletId: string, nft: AddNFTRequest): Promise<NFT>;
|
|
1262
|
+
}
|
|
1263
|
+
|
|
1264
|
+
/**
|
|
1265
|
+
* End Users API Client
|
|
1266
|
+
*
|
|
1267
|
+
* Manage end-users discovered from events - profiles, segments, and activity.
|
|
1268
|
+
*/
|
|
1269
|
+
|
|
1270
|
+
interface EndUser {
|
|
1271
|
+
id: string;
|
|
1272
|
+
external_id: string;
|
|
1273
|
+
email?: string;
|
|
1274
|
+
first_name?: string;
|
|
1275
|
+
last_name?: string;
|
|
1276
|
+
display_name?: string;
|
|
1277
|
+
avatar_url?: string;
|
|
1278
|
+
phone?: string;
|
|
1279
|
+
date_of_birth?: string;
|
|
1280
|
+
country?: string;
|
|
1281
|
+
city?: string;
|
|
1282
|
+
timezone?: string;
|
|
1283
|
+
language?: string;
|
|
1284
|
+
bio?: string;
|
|
1285
|
+
wallet_address?: string;
|
|
1286
|
+
wallet_source?: string;
|
|
1287
|
+
status: string;
|
|
1288
|
+
total_events: number;
|
|
1289
|
+
first_event_at?: string;
|
|
1290
|
+
last_event_at?: string;
|
|
1291
|
+
event_types: string[];
|
|
1292
|
+
segments: string[];
|
|
1293
|
+
tags: Record<string, any>;
|
|
1294
|
+
points_balance: number;
|
|
1295
|
+
lifetime_points: number;
|
|
1296
|
+
attributes: Record<string, any>;
|
|
1297
|
+
created_at: string;
|
|
1298
|
+
discovered_at?: string;
|
|
1299
|
+
}
|
|
1300
|
+
interface EndUserListResponse {
|
|
1301
|
+
users: EndUser[];
|
|
1302
|
+
total: number;
|
|
1303
|
+
page: number;
|
|
1304
|
+
page_size: number;
|
|
1305
|
+
has_more: boolean;
|
|
1306
|
+
}
|
|
1307
|
+
interface UserActivity {
|
|
1308
|
+
event_id: string;
|
|
1309
|
+
event_type: string;
|
|
1310
|
+
timestamp: string;
|
|
1311
|
+
data: Record<string, any>;
|
|
1312
|
+
}
|
|
1313
|
+
interface UserActivityResponse {
|
|
1314
|
+
user_id: string;
|
|
1315
|
+
activities: UserActivity[];
|
|
1316
|
+
total: number;
|
|
1317
|
+
page: number;
|
|
1318
|
+
page_size: number;
|
|
1319
|
+
}
|
|
1320
|
+
interface CreateEndUserRequest {
|
|
1321
|
+
external_id: string;
|
|
1322
|
+
email?: string;
|
|
1323
|
+
first_name?: string;
|
|
1324
|
+
last_name?: string;
|
|
1325
|
+
display_name?: string;
|
|
1326
|
+
phone?: string;
|
|
1327
|
+
date_of_birth?: string;
|
|
1328
|
+
country?: string;
|
|
1329
|
+
city?: string;
|
|
1330
|
+
timezone?: string;
|
|
1331
|
+
language?: string;
|
|
1332
|
+
bio?: string;
|
|
1333
|
+
wallet_address?: string;
|
|
1334
|
+
segments?: string[];
|
|
1335
|
+
tags?: Record<string, any>;
|
|
1336
|
+
attributes?: Record<string, any>;
|
|
1337
|
+
}
|
|
1338
|
+
interface UpdateEndUserRequest {
|
|
1339
|
+
email?: string;
|
|
1340
|
+
first_name?: string;
|
|
1341
|
+
last_name?: string;
|
|
1342
|
+
display_name?: string;
|
|
1343
|
+
avatar_url?: string;
|
|
1344
|
+
phone?: string;
|
|
1345
|
+
date_of_birth?: string;
|
|
1346
|
+
country?: string;
|
|
1347
|
+
city?: string;
|
|
1348
|
+
timezone?: string;
|
|
1349
|
+
language?: string;
|
|
1350
|
+
bio?: string;
|
|
1351
|
+
segments?: string[];
|
|
1352
|
+
tags?: Record<string, any>;
|
|
1353
|
+
attributes?: Record<string, any>;
|
|
1354
|
+
}
|
|
1355
|
+
interface ListEndUsersOptions {
|
|
1356
|
+
page?: number;
|
|
1357
|
+
page_size?: number;
|
|
1358
|
+
search?: string;
|
|
1359
|
+
status?: string;
|
|
1360
|
+
segment?: string;
|
|
1361
|
+
has_wallet?: boolean;
|
|
1362
|
+
sort_by?: string;
|
|
1363
|
+
sort_order?: 'asc' | 'desc';
|
|
1364
|
+
}
|
|
1365
|
+
interface LinkWalletRequest {
|
|
1366
|
+
wallet_address: string;
|
|
1367
|
+
wallet_source?: string;
|
|
1368
|
+
signature?: string;
|
|
1369
|
+
}
|
|
1370
|
+
interface MergeUsersRequest {
|
|
1371
|
+
source_user_id: string;
|
|
1372
|
+
target_user_id: string;
|
|
1373
|
+
}
|
|
1374
|
+
declare class EndUsersClient {
|
|
1375
|
+
private http;
|
|
1376
|
+
constructor(http: HttpClient);
|
|
1377
|
+
/**
|
|
1378
|
+
* List end-users with pagination and filters
|
|
1379
|
+
*/
|
|
1380
|
+
list(options?: ListEndUsersOptions): Promise<EndUserListResponse>;
|
|
1381
|
+
/**
|
|
1382
|
+
* Get an end-user by ID
|
|
1383
|
+
*/
|
|
1384
|
+
get(userId: string): Promise<EndUser>;
|
|
1385
|
+
/**
|
|
1386
|
+
* Get an end-user by external ID
|
|
1387
|
+
*/
|
|
1388
|
+
getByExternalId(externalId: string): Promise<EndUser>;
|
|
1389
|
+
/**
|
|
1390
|
+
* Create an end-user manually
|
|
1391
|
+
*/
|
|
1392
|
+
create(data: CreateEndUserRequest): Promise<EndUser>;
|
|
1393
|
+
/**
|
|
1394
|
+
* Update an end-user profile
|
|
1395
|
+
*/
|
|
1396
|
+
update(userId: string, data: UpdateEndUserRequest): Promise<EndUser>;
|
|
1397
|
+
/**
|
|
1398
|
+
* Delete an end-user
|
|
1399
|
+
*/
|
|
1400
|
+
delete(userId: string): Promise<void>;
|
|
1401
|
+
/**
|
|
1402
|
+
* Link a wallet to an end-user
|
|
1403
|
+
*/
|
|
1404
|
+
linkWallet(userId: string, request: LinkWalletRequest): Promise<EndUser>;
|
|
1405
|
+
/**
|
|
1406
|
+
* Unlink wallet from an end-user
|
|
1407
|
+
*/
|
|
1408
|
+
unlinkWallet(userId: string): Promise<EndUser>;
|
|
1409
|
+
/**
|
|
1410
|
+
* Get user activity/events
|
|
1411
|
+
*/
|
|
1412
|
+
getActivity(userId: string, options?: {
|
|
1413
|
+
page?: number;
|
|
1414
|
+
page_size?: number;
|
|
1415
|
+
event_type?: string;
|
|
1416
|
+
}): Promise<UserActivityResponse>;
|
|
1417
|
+
/**
|
|
1418
|
+
* Add points to a user
|
|
1419
|
+
*/
|
|
1420
|
+
addPoints(userId: string, points: number, reason?: string): Promise<EndUser>;
|
|
1421
|
+
/**
|
|
1422
|
+
* Add a segment to a user
|
|
1423
|
+
*/
|
|
1424
|
+
addSegment(userId: string, segment: string): Promise<EndUser>;
|
|
1425
|
+
/**
|
|
1426
|
+
* Remove a segment from a user
|
|
1427
|
+
*/
|
|
1428
|
+
removeSegment(userId: string, segment: string): Promise<EndUser>;
|
|
1429
|
+
/**
|
|
1430
|
+
* Merge two users (moves all data from source to target)
|
|
1431
|
+
*/
|
|
1432
|
+
merge(request: MergeUsersRequest): Promise<EndUser>;
|
|
1433
|
+
/**
|
|
1434
|
+
* Export users as CSV
|
|
1435
|
+
*/
|
|
1436
|
+
export(options?: {
|
|
1437
|
+
segment?: string;
|
|
1438
|
+
format?: 'csv' | 'json';
|
|
1439
|
+
}): Promise<Blob>;
|
|
1440
|
+
}
|
|
1441
|
+
|
|
1442
|
+
/**
|
|
1443
|
+
* Rewards API Client
|
|
1444
|
+
*
|
|
1445
|
+
* Manage reward definitions, earned rewards, and NFT minting.
|
|
1446
|
+
*/
|
|
1447
|
+
|
|
1448
|
+
interface RewardDefinition {
|
|
1449
|
+
id: string;
|
|
1450
|
+
name: string;
|
|
1451
|
+
slug: string;
|
|
1452
|
+
description?: string;
|
|
1453
|
+
reward_type: 'nft' | 'points' | 'token' | 'badge';
|
|
1454
|
+
value?: number;
|
|
1455
|
+
value_currency?: string;
|
|
1456
|
+
token_contract_address?: string;
|
|
1457
|
+
token_symbol?: string;
|
|
1458
|
+
token_decimals: number;
|
|
1459
|
+
token_chain: string;
|
|
1460
|
+
nft_minting_strategy?: string;
|
|
1461
|
+
nft_pre_mint_count?: number;
|
|
1462
|
+
nft_minted_pool_count: number;
|
|
1463
|
+
nft_is_soulbound: boolean;
|
|
1464
|
+
passport_threshold_id?: string;
|
|
1465
|
+
trigger_type: string;
|
|
1466
|
+
trigger_config?: Record<string, any>;
|
|
1467
|
+
max_per_user?: number;
|
|
1468
|
+
max_total?: number;
|
|
1469
|
+
current_issued: number;
|
|
1470
|
+
is_active: boolean;
|
|
1471
|
+
icon_url?: string;
|
|
1472
|
+
badge_color?: string;
|
|
1473
|
+
created_at: string;
|
|
1474
|
+
}
|
|
1475
|
+
interface EarnedReward {
|
|
1476
|
+
id: string;
|
|
1477
|
+
user_id: string;
|
|
1478
|
+
user_external_id: string;
|
|
1479
|
+
reward_name: string;
|
|
1480
|
+
reward_type: string;
|
|
1481
|
+
status: string;
|
|
1482
|
+
nft_token_id?: number;
|
|
1483
|
+
nft_tx_hash?: string;
|
|
1484
|
+
earned_at: string;
|
|
1485
|
+
distributed_at?: string;
|
|
1486
|
+
}
|
|
1487
|
+
interface RewardAsset {
|
|
1488
|
+
id: string;
|
|
1489
|
+
definition_id: string;
|
|
1490
|
+
asset_type: string;
|
|
1491
|
+
file_path: string;
|
|
1492
|
+
mime_type: string;
|
|
1493
|
+
file_size: number;
|
|
1494
|
+
metadata?: Record<string, any>;
|
|
1495
|
+
created_at: string;
|
|
1496
|
+
}
|
|
1497
|
+
interface CreateRewardDefinitionRequest {
|
|
1498
|
+
name: string;
|
|
1499
|
+
slug: string;
|
|
1500
|
+
description?: string;
|
|
1501
|
+
campaign_id?: string;
|
|
1502
|
+
reward_type?: 'nft' | 'points' | 'token' | 'badge';
|
|
1503
|
+
value?: number;
|
|
1504
|
+
value_currency?: string;
|
|
1505
|
+
token_contract_address?: string;
|
|
1506
|
+
token_symbol?: string;
|
|
1507
|
+
token_decimals?: number;
|
|
1508
|
+
token_chain?: string;
|
|
1509
|
+
nft_metadata_template?: Record<string, any>;
|
|
1510
|
+
nft_is_soulbound?: boolean;
|
|
1511
|
+
nft_validity_days?: number;
|
|
1512
|
+
nft_minting_strategy?: 'mint_on_earn' | 'pre_mint_pool' | 'lazy_mint';
|
|
1513
|
+
nft_pre_mint_count?: number;
|
|
1514
|
+
passport_threshold_id?: string;
|
|
1515
|
+
trigger_type?: 'event_count' | 'event_match' | 'threshold' | 'manual' | 'custom_code';
|
|
1516
|
+
trigger_config?: Record<string, any>;
|
|
1517
|
+
max_per_user?: number;
|
|
1518
|
+
max_total?: number;
|
|
1519
|
+
is_active?: boolean;
|
|
1520
|
+
icon_url?: string;
|
|
1521
|
+
badge_color?: string;
|
|
1522
|
+
is_public?: boolean;
|
|
1523
|
+
}
|
|
1524
|
+
interface ManualRewardRequest {
|
|
1525
|
+
definition_id: string;
|
|
1526
|
+
user_ids: string[];
|
|
1527
|
+
trigger_data?: Record<string, any>;
|
|
1528
|
+
distribute_immediately?: boolean;
|
|
1529
|
+
}
|
|
1530
|
+
interface ListRewardsOptions {
|
|
1531
|
+
is_active?: boolean;
|
|
1532
|
+
reward_type?: string;
|
|
1533
|
+
limit?: number;
|
|
1534
|
+
offset?: number;
|
|
1535
|
+
}
|
|
1536
|
+
declare class RewardsClient {
|
|
1537
|
+
private http;
|
|
1538
|
+
constructor(http: HttpClient);
|
|
1539
|
+
/**
|
|
1540
|
+
* List reward definitions
|
|
1541
|
+
*/
|
|
1542
|
+
listDefinitions(options?: ListRewardsOptions): Promise<RewardDefinition[]>;
|
|
1543
|
+
/**
|
|
1544
|
+
* Get a reward definition by ID
|
|
1545
|
+
*/
|
|
1546
|
+
getDefinition(definitionId: string): Promise<RewardDefinition>;
|
|
1547
|
+
/**
|
|
1548
|
+
* Create a reward definition
|
|
1549
|
+
*/
|
|
1550
|
+
createDefinition(data: CreateRewardDefinitionRequest): Promise<RewardDefinition>;
|
|
1551
|
+
/**
|
|
1552
|
+
* Update a reward definition
|
|
1553
|
+
*/
|
|
1554
|
+
updateDefinition(definitionId: string, data: Partial<CreateRewardDefinitionRequest>): Promise<RewardDefinition>;
|
|
1555
|
+
/**
|
|
1556
|
+
* Delete a reward definition
|
|
1557
|
+
*/
|
|
1558
|
+
deleteDefinition(definitionId: string): Promise<void>;
|
|
1559
|
+
/**
|
|
1560
|
+
* Activate a reward definition
|
|
1561
|
+
*/
|
|
1562
|
+
activateDefinition(definitionId: string): Promise<RewardDefinition>;
|
|
1563
|
+
/**
|
|
1564
|
+
* Deactivate a reward definition
|
|
1565
|
+
*/
|
|
1566
|
+
deactivateDefinition(definitionId: string): Promise<RewardDefinition>;
|
|
1567
|
+
/**
|
|
1568
|
+
* List earned rewards
|
|
1569
|
+
*/
|
|
1570
|
+
listEarned(options?: {
|
|
1571
|
+
user_id?: string;
|
|
1572
|
+
definition_id?: string;
|
|
1573
|
+
status?: string;
|
|
1574
|
+
limit?: number;
|
|
1575
|
+
offset?: number;
|
|
1576
|
+
}): Promise<EarnedReward[]>;
|
|
1577
|
+
/**
|
|
1578
|
+
* Get earned rewards for a user
|
|
1579
|
+
*/
|
|
1580
|
+
getUserRewards(userId: string): Promise<EarnedReward[]>;
|
|
1581
|
+
/**
|
|
1582
|
+
* Manually award rewards to users
|
|
1583
|
+
*/
|
|
1584
|
+
awardManual(request: ManualRewardRequest): Promise<EarnedReward[]>;
|
|
1585
|
+
/**
|
|
1586
|
+
* Distribute pending rewards (mint NFTs, transfer tokens)
|
|
1587
|
+
*/
|
|
1588
|
+
distributePending(earnedRewardId: string): Promise<EarnedReward>;
|
|
1589
|
+
/**
|
|
1590
|
+
* Upload an asset for a reward (image, metadata JSON)
|
|
1591
|
+
*/
|
|
1592
|
+
uploadAsset(definitionId: string, file: Blob, assetType: 'image' | 'metadata' | 'animation'): Promise<RewardAsset>;
|
|
1593
|
+
/**
|
|
1594
|
+
* List assets for a reward definition
|
|
1595
|
+
*/
|
|
1596
|
+
listAssets(definitionId: string): Promise<RewardAsset[]>;
|
|
1597
|
+
}
|
|
1598
|
+
|
|
1599
|
+
/**
|
|
1600
|
+
* Quests API Client
|
|
1601
|
+
*
|
|
1602
|
+
* Manage quests, steps, and user progress tracking.
|
|
1603
|
+
*/
|
|
1604
|
+
|
|
1605
|
+
interface Quest {
|
|
1606
|
+
id: string;
|
|
1607
|
+
name: string;
|
|
1608
|
+
slug: string;
|
|
1609
|
+
description?: string;
|
|
1610
|
+
short_description?: string;
|
|
1611
|
+
icon_url?: string;
|
|
1612
|
+
banner_url?: string;
|
|
1613
|
+
category?: string;
|
|
1614
|
+
difficulty?: string;
|
|
1615
|
+
estimated_time?: string;
|
|
1616
|
+
is_ordered: boolean;
|
|
1617
|
+
is_repeatable: boolean;
|
|
1618
|
+
repeat_cooldown_hours?: number;
|
|
1619
|
+
max_completions_per_user?: number;
|
|
1620
|
+
starts_at?: string;
|
|
1621
|
+
ends_at?: string;
|
|
1622
|
+
time_limit_hours?: number;
|
|
1623
|
+
prerequisite_quest_ids: string[];
|
|
1624
|
+
max_participants?: number;
|
|
1625
|
+
max_completions?: number;
|
|
1626
|
+
reward_definition_id?: string;
|
|
1627
|
+
reward_points?: number;
|
|
1628
|
+
is_public: boolean;
|
|
1629
|
+
is_featured: boolean;
|
|
1630
|
+
tags: string[];
|
|
1631
|
+
status: 'draft' | 'active' | 'paused' | 'completed' | 'archived';
|
|
1632
|
+
steps: QuestStep[];
|
|
1633
|
+
total_participants: number;
|
|
1634
|
+
total_completions: number;
|
|
1635
|
+
created_at: string;
|
|
1636
|
+
updated_at: string;
|
|
1637
|
+
}
|
|
1638
|
+
interface QuestStep {
|
|
1639
|
+
id: string;
|
|
1640
|
+
quest_id: string;
|
|
1641
|
+
name: string;
|
|
1642
|
+
description?: string;
|
|
1643
|
+
order: number;
|
|
1644
|
+
step_type: 'event' | 'manual' | 'external' | 'compound';
|
|
1645
|
+
event_type?: string;
|
|
1646
|
+
event_types?: string[];
|
|
1647
|
+
criteria?: Record<string, any>;
|
|
1648
|
+
required_data_fields?: string[];
|
|
1649
|
+
step_points?: number;
|
|
1650
|
+
icon_url?: string;
|
|
1651
|
+
is_optional: boolean;
|
|
1652
|
+
}
|
|
1653
|
+
interface UserQuestProgress {
|
|
1654
|
+
id: string;
|
|
1655
|
+
user_id: string;
|
|
1656
|
+
quest_id: string;
|
|
1657
|
+
quest_name: string;
|
|
1658
|
+
status: 'not_started' | 'in_progress' | 'completed' | 'failed' | 'expired';
|
|
1659
|
+
started_at?: string;
|
|
1660
|
+
completed_at?: string;
|
|
1661
|
+
expires_at?: string;
|
|
1662
|
+
completion_count: number;
|
|
1663
|
+
current_step_order: number;
|
|
1664
|
+
step_progress: StepProgress[];
|
|
1665
|
+
points_earned: number;
|
|
1666
|
+
reward_earned: boolean;
|
|
1667
|
+
}
|
|
1668
|
+
interface StepProgress {
|
|
1669
|
+
step_id: string;
|
|
1670
|
+
step_name: string;
|
|
1671
|
+
order: number;
|
|
1672
|
+
status: 'pending' | 'in_progress' | 'completed' | 'skipped';
|
|
1673
|
+
completed_at?: string;
|
|
1674
|
+
event_id?: string;
|
|
1675
|
+
}
|
|
1676
|
+
interface QuestWithProgress extends Quest {
|
|
1677
|
+
user_progress?: UserQuestProgress;
|
|
1678
|
+
}
|
|
1679
|
+
interface CreateQuestRequest {
|
|
1680
|
+
name: string;
|
|
1681
|
+
slug?: string;
|
|
1682
|
+
description?: string;
|
|
1683
|
+
short_description?: string;
|
|
1684
|
+
icon_url?: string;
|
|
1685
|
+
banner_url?: string;
|
|
1686
|
+
category?: string;
|
|
1687
|
+
difficulty?: string;
|
|
1688
|
+
estimated_time?: string;
|
|
1689
|
+
is_ordered?: boolean;
|
|
1690
|
+
is_repeatable?: boolean;
|
|
1691
|
+
repeat_cooldown_hours?: number;
|
|
1692
|
+
max_completions_per_user?: number;
|
|
1693
|
+
starts_at?: string;
|
|
1694
|
+
ends_at?: string;
|
|
1695
|
+
time_limit_hours?: number;
|
|
1696
|
+
prerequisite_quest_ids?: string[];
|
|
1697
|
+
max_participants?: number;
|
|
1698
|
+
max_completions?: number;
|
|
1699
|
+
reward_definition_id?: string;
|
|
1700
|
+
reward_points?: number;
|
|
1701
|
+
is_public?: boolean;
|
|
1702
|
+
is_featured?: boolean;
|
|
1703
|
+
tags?: string[];
|
|
1704
|
+
steps: CreateQuestStepRequest[];
|
|
1705
|
+
}
|
|
1706
|
+
interface CreateQuestStepRequest {
|
|
1707
|
+
name: string;
|
|
1708
|
+
description?: string;
|
|
1709
|
+
order?: number;
|
|
1710
|
+
step_type?: 'event' | 'manual' | 'external' | 'compound';
|
|
1711
|
+
event_type?: string;
|
|
1712
|
+
event_types?: string[];
|
|
1713
|
+
criteria?: Record<string, any>;
|
|
1714
|
+
required_data_fields?: string[];
|
|
1715
|
+
step_points?: number;
|
|
1716
|
+
icon_url?: string;
|
|
1717
|
+
is_optional?: boolean;
|
|
1718
|
+
}
|
|
1719
|
+
interface ListQuestsOptions {
|
|
1720
|
+
status?: string;
|
|
1721
|
+
category?: string;
|
|
1722
|
+
is_public?: boolean;
|
|
1723
|
+
is_featured?: boolean;
|
|
1724
|
+
limit?: number;
|
|
1725
|
+
offset?: number;
|
|
1726
|
+
}
|
|
1727
|
+
declare class QuestsClient {
|
|
1728
|
+
private http;
|
|
1729
|
+
constructor(http: HttpClient);
|
|
1730
|
+
/**
|
|
1731
|
+
* List quests
|
|
1732
|
+
*/
|
|
1733
|
+
list(options?: ListQuestsOptions): Promise<Quest[]>;
|
|
1734
|
+
/**
|
|
1735
|
+
* Get a quest by ID
|
|
1736
|
+
*/
|
|
1737
|
+
get(questId: string): Promise<Quest>;
|
|
1738
|
+
/**
|
|
1739
|
+
* Get a quest by slug
|
|
1740
|
+
*/
|
|
1741
|
+
getBySlug(slug: string): Promise<Quest>;
|
|
1742
|
+
/**
|
|
1743
|
+
* Create a quest
|
|
1744
|
+
*/
|
|
1745
|
+
create(data: CreateQuestRequest): Promise<Quest>;
|
|
1746
|
+
/**
|
|
1747
|
+
* Update a quest
|
|
1748
|
+
*/
|
|
1749
|
+
update(questId: string, data: Partial<CreateQuestRequest>): Promise<Quest>;
|
|
1750
|
+
/**
|
|
1751
|
+
* Delete a quest
|
|
1752
|
+
*/
|
|
1753
|
+
delete(questId: string): Promise<void>;
|
|
1754
|
+
/**
|
|
1755
|
+
* Activate a quest
|
|
1756
|
+
*/
|
|
1757
|
+
activate(questId: string): Promise<Quest>;
|
|
1758
|
+
/**
|
|
1759
|
+
* Pause a quest
|
|
1760
|
+
*/
|
|
1761
|
+
pause(questId: string): Promise<Quest>;
|
|
1762
|
+
/**
|
|
1763
|
+
* Archive a quest
|
|
1764
|
+
*/
|
|
1765
|
+
archive(questId: string): Promise<Quest>;
|
|
1766
|
+
/**
|
|
1767
|
+
* Get quest with user progress
|
|
1768
|
+
*/
|
|
1769
|
+
getWithProgress(questId: string, userId: string): Promise<QuestWithProgress>;
|
|
1770
|
+
/**
|
|
1771
|
+
* List quests with progress for a user
|
|
1772
|
+
*/
|
|
1773
|
+
listWithProgress(userId: string, options?: ListQuestsOptions): Promise<QuestWithProgress[]>;
|
|
1774
|
+
/**
|
|
1775
|
+
* Start a quest for a user
|
|
1776
|
+
*/
|
|
1777
|
+
startQuest(questId: string, userId: string): Promise<UserQuestProgress>;
|
|
1778
|
+
/**
|
|
1779
|
+
* Get user's progress on a quest
|
|
1780
|
+
*/
|
|
1781
|
+
getUserProgress(questId: string, userId: string): Promise<UserQuestProgress>;
|
|
1782
|
+
/**
|
|
1783
|
+
* Complete a step manually
|
|
1784
|
+
*/
|
|
1785
|
+
completeStep(questId: string, userId: string, stepId: string): Promise<UserQuestProgress>;
|
|
1786
|
+
/**
|
|
1787
|
+
* Get all quest progress for a user
|
|
1788
|
+
*/
|
|
1789
|
+
getAllUserProgress(userId: string): Promise<UserQuestProgress[]>;
|
|
1790
|
+
/**
|
|
1791
|
+
* Add a step to a quest
|
|
1792
|
+
*/
|
|
1793
|
+
addStep(questId: string, step: CreateQuestStepRequest): Promise<QuestStep>;
|
|
1794
|
+
/**
|
|
1795
|
+
* Update a step
|
|
1796
|
+
*/
|
|
1797
|
+
updateStep(questId: string, stepId: string, data: Partial<CreateQuestStepRequest>): Promise<QuestStep>;
|
|
1798
|
+
/**
|
|
1799
|
+
* Delete a step
|
|
1800
|
+
*/
|
|
1801
|
+
deleteStep(questId: string, stepId: string): Promise<void>;
|
|
1802
|
+
/**
|
|
1803
|
+
* Reorder steps
|
|
1804
|
+
*/
|
|
1805
|
+
reorderSteps(questId: string, stepIds: string[]): Promise<Quest>;
|
|
1806
|
+
}
|
|
1807
|
+
|
|
1808
|
+
/**
|
|
1809
|
+
* Schema Validation API Client
|
|
1810
|
+
*
|
|
1811
|
+
* Manage event schemas for data validation.
|
|
1812
|
+
*/
|
|
1813
|
+
|
|
1814
|
+
interface Schema {
|
|
1815
|
+
id: string;
|
|
1816
|
+
name: string;
|
|
1817
|
+
version: string;
|
|
1818
|
+
display_name?: string;
|
|
1819
|
+
description?: string;
|
|
1820
|
+
status: 'draft' | 'active' | 'deprecated';
|
|
1821
|
+
is_default: boolean;
|
|
1822
|
+
usage_count: number;
|
|
1823
|
+
created_at?: string;
|
|
1824
|
+
updated_at?: string;
|
|
1825
|
+
}
|
|
1826
|
+
interface SchemaDetail extends Schema {
|
|
1827
|
+
schema_definition: Record<string, any>;
|
|
1828
|
+
yaml_content: string;
|
|
1829
|
+
}
|
|
1830
|
+
interface SchemaField {
|
|
1831
|
+
name: string;
|
|
1832
|
+
type: string;
|
|
1833
|
+
required?: boolean;
|
|
1834
|
+
description?: string;
|
|
1835
|
+
default?: any;
|
|
1836
|
+
min?: number;
|
|
1837
|
+
max?: number;
|
|
1838
|
+
pattern?: string;
|
|
1839
|
+
values?: string[];
|
|
1840
|
+
}
|
|
1841
|
+
interface ValidationResult {
|
|
1842
|
+
valid: boolean;
|
|
1843
|
+
schema_name: string;
|
|
1844
|
+
schema_version?: string;
|
|
1845
|
+
errors: ValidationError$1[];
|
|
1846
|
+
}
|
|
1847
|
+
interface ValidationError$1 {
|
|
1848
|
+
field: string;
|
|
1849
|
+
message: string;
|
|
1850
|
+
value?: any;
|
|
1851
|
+
}
|
|
1852
|
+
interface SchemaListResponse {
|
|
1853
|
+
schemas: Schema[];
|
|
1854
|
+
total: number;
|
|
1855
|
+
}
|
|
1856
|
+
interface CreateSchemaRequest {
|
|
1857
|
+
yaml_content: string;
|
|
1858
|
+
}
|
|
1859
|
+
interface ValidateDataRequest {
|
|
1860
|
+
schema_name: string;
|
|
1861
|
+
schema_version?: string;
|
|
1862
|
+
data: Record<string, any>;
|
|
1863
|
+
}
|
|
1864
|
+
interface ListSchemasOptions {
|
|
1865
|
+
status?: 'draft' | 'active' | 'deprecated';
|
|
1866
|
+
search?: string;
|
|
1867
|
+
limit?: number;
|
|
1868
|
+
offset?: number;
|
|
1869
|
+
}
|
|
1870
|
+
declare class SchemasClient {
|
|
1871
|
+
private http;
|
|
1872
|
+
constructor(http: HttpClient);
|
|
1873
|
+
/**
|
|
1874
|
+
* List schemas
|
|
1875
|
+
*/
|
|
1876
|
+
list(options?: ListSchemasOptions): Promise<SchemaListResponse>;
|
|
1877
|
+
/**
|
|
1878
|
+
* Get a schema by name and optional version
|
|
1879
|
+
*/
|
|
1880
|
+
get(name: string, version?: string): Promise<SchemaDetail>;
|
|
1881
|
+
/**
|
|
1882
|
+
* Create a schema from YAML content
|
|
1883
|
+
*
|
|
1884
|
+
* Example YAML:
|
|
1885
|
+
* ```yaml
|
|
1886
|
+
* name: my_event
|
|
1887
|
+
* version: "1.0"
|
|
1888
|
+
* description: My custom event schema
|
|
1889
|
+
*
|
|
1890
|
+
* fields:
|
|
1891
|
+
* user_id:
|
|
1892
|
+
* type: string
|
|
1893
|
+
* required: true
|
|
1894
|
+
* amount:
|
|
1895
|
+
* type: number
|
|
1896
|
+
* min: 0
|
|
1897
|
+
* status:
|
|
1898
|
+
* type: enum
|
|
1899
|
+
* values: [pending, completed, failed]
|
|
1900
|
+
* ```
|
|
1901
|
+
*/
|
|
1902
|
+
create(yamlContent: string): Promise<SchemaDetail>;
|
|
1903
|
+
/**
|
|
1904
|
+
* Update a schema (creates new version)
|
|
1905
|
+
*/
|
|
1906
|
+
update(name: string, yamlContent: string): Promise<SchemaDetail>;
|
|
1907
|
+
/**
|
|
1908
|
+
* Delete a schema
|
|
1909
|
+
*/
|
|
1910
|
+
delete(name: string, version?: string): Promise<void>;
|
|
1911
|
+
/**
|
|
1912
|
+
* Activate a schema (make it available for validation)
|
|
1913
|
+
*/
|
|
1914
|
+
activate(name: string, version?: string): Promise<Schema>;
|
|
1915
|
+
/**
|
|
1916
|
+
* Deprecate a schema
|
|
1917
|
+
*/
|
|
1918
|
+
deprecate(name: string, version?: string): Promise<Schema>;
|
|
1919
|
+
/**
|
|
1920
|
+
* Set a schema as the default for its name
|
|
1921
|
+
*/
|
|
1922
|
+
setDefault(name: string, version: string): Promise<Schema>;
|
|
1923
|
+
/**
|
|
1924
|
+
* Validate data against a schema
|
|
1925
|
+
*/
|
|
1926
|
+
validate(request: ValidateDataRequest): Promise<ValidationResult>;
|
|
1927
|
+
/**
|
|
1928
|
+
* Validate data against multiple schemas
|
|
1929
|
+
*/
|
|
1930
|
+
validateMultiple(schemaNames: string[], data: Record<string, any>): Promise<ValidationResult[]>;
|
|
1931
|
+
/**
|
|
1932
|
+
* Get schema usage statistics
|
|
1933
|
+
*/
|
|
1934
|
+
getUsageStats(name: string): Promise<{
|
|
1935
|
+
total_validations: number;
|
|
1936
|
+
successful_validations: number;
|
|
1937
|
+
failed_validations: number;
|
|
1938
|
+
last_used_at?: string;
|
|
1939
|
+
}>;
|
|
1940
|
+
/**
|
|
1941
|
+
* Clone a schema with a new name
|
|
1942
|
+
*/
|
|
1943
|
+
clone(sourceName: string, newName: string, newVersion?: string): Promise<SchemaDetail>;
|
|
1944
|
+
}
|
|
1945
|
+
|
|
1946
|
+
/**
|
|
1947
|
+
* Data Views Client
|
|
1948
|
+
*
|
|
1949
|
+
* Client for managing and executing custom data views with multi-computation support.
|
|
1950
|
+
*/
|
|
1951
|
+
|
|
1952
|
+
interface DataViewColumn {
|
|
1953
|
+
name: string;
|
|
1954
|
+
type: string;
|
|
1955
|
+
}
|
|
1956
|
+
interface DataViewInfo {
|
|
1957
|
+
id: string;
|
|
1958
|
+
name: string;
|
|
1959
|
+
view_name: string;
|
|
1960
|
+
description: string;
|
|
1961
|
+
is_builtin: boolean;
|
|
1962
|
+
columns: DataViewColumn[];
|
|
1963
|
+
}
|
|
1964
|
+
interface DataViewListResponse {
|
|
1965
|
+
own_views: DataViewSummary[];
|
|
1966
|
+
public_views: DataViewSummary[];
|
|
1967
|
+
builtin_views: DataViewSummary[];
|
|
1968
|
+
}
|
|
1969
|
+
interface DataViewSummary {
|
|
1970
|
+
name: string;
|
|
1971
|
+
display_name?: string;
|
|
1972
|
+
description: string;
|
|
1973
|
+
view_type?: string;
|
|
1974
|
+
source_categories?: string[];
|
|
1975
|
+
}
|
|
1976
|
+
interface DataViewDetail {
|
|
1977
|
+
id: string;
|
|
1978
|
+
name: string;
|
|
1979
|
+
display_name: string;
|
|
1980
|
+
description: string;
|
|
1981
|
+
view_type: string;
|
|
1982
|
+
computation: DataViewComputation | DataViewComputation[];
|
|
1983
|
+
source_categories: string[];
|
|
1984
|
+
is_public: boolean;
|
|
1985
|
+
created_at: string;
|
|
1986
|
+
updated_at: string;
|
|
1987
|
+
}
|
|
1988
|
+
interface DataViewComputation {
|
|
1989
|
+
type: 'count' | 'score' | 'aggregate' | 'latest' | 'tier' | 'time_decay';
|
|
1990
|
+
name?: string;
|
|
1991
|
+
event_types?: string[];
|
|
1992
|
+
time_window_days?: number;
|
|
1993
|
+
event_weights?: Record<string, number>;
|
|
1994
|
+
max_score?: number;
|
|
1995
|
+
decay_rate?: number;
|
|
1996
|
+
field?: string;
|
|
1997
|
+
operation?: 'sum' | 'avg' | 'min' | 'max' | 'count';
|
|
1998
|
+
group_by?: string;
|
|
1999
|
+
limit?: number;
|
|
2000
|
+
fields?: string[];
|
|
2001
|
+
tiers?: TierDefinition[];
|
|
2002
|
+
score_source?: string;
|
|
2003
|
+
}
|
|
2004
|
+
interface TierDefinition {
|
|
2005
|
+
name: string;
|
|
2006
|
+
min: number;
|
|
2007
|
+
max: number;
|
|
2008
|
+
}
|
|
2009
|
+
interface DataViewExecuteResult {
|
|
2010
|
+
view_name: string;
|
|
2011
|
+
display_name: string;
|
|
2012
|
+
identifier: string;
|
|
2013
|
+
identifier_type: 'wallet' | 'user_id';
|
|
2014
|
+
data: Record<string, unknown>;
|
|
2015
|
+
computed_at: string;
|
|
2016
|
+
total_events: number;
|
|
2017
|
+
}
|
|
2018
|
+
interface DataViewPreviewRequest {
|
|
2019
|
+
wallet_address: string;
|
|
2020
|
+
computation: DataViewComputation | DataViewComputation[];
|
|
2021
|
+
time_window_days?: number;
|
|
2022
|
+
limit?: number;
|
|
2023
|
+
}
|
|
2024
|
+
interface DataViewPreviewResult {
|
|
2025
|
+
preview: true;
|
|
2026
|
+
wallet_address: string;
|
|
2027
|
+
computation_type: string;
|
|
2028
|
+
result: Record<string, unknown>;
|
|
2029
|
+
events_processed: number;
|
|
2030
|
+
time_window_days: number;
|
|
2031
|
+
}
|
|
2032
|
+
interface CreateDataViewRequest {
|
|
2033
|
+
name: string;
|
|
2034
|
+
display_name: string;
|
|
2035
|
+
description: string;
|
|
2036
|
+
view_type?: string;
|
|
2037
|
+
computation: DataViewComputation | DataViewComputation[];
|
|
2038
|
+
source_categories?: string[];
|
|
2039
|
+
is_public?: boolean;
|
|
2040
|
+
}
|
|
2041
|
+
interface UpdateDataViewRequest {
|
|
2042
|
+
display_name?: string;
|
|
2043
|
+
description?: string;
|
|
2044
|
+
computation?: DataViewComputation | DataViewComputation[];
|
|
2045
|
+
source_categories?: string[];
|
|
2046
|
+
is_public?: boolean;
|
|
2047
|
+
}
|
|
2048
|
+
interface FanProfileView {
|
|
2049
|
+
wallet_address: string;
|
|
2050
|
+
fan_score: number;
|
|
2051
|
+
total_events: number;
|
|
2052
|
+
event_breakdown: Record<string, number>;
|
|
2053
|
+
first_seen: string;
|
|
2054
|
+
last_seen: string;
|
|
2055
|
+
loyalty_tier: string;
|
|
2056
|
+
computed_at: string;
|
|
2057
|
+
}
|
|
2058
|
+
interface ActivitySummaryView {
|
|
2059
|
+
wallet_address: string;
|
|
2060
|
+
total_events: number;
|
|
2061
|
+
event_count_by_type: Record<string, number>;
|
|
2062
|
+
last_activity: string;
|
|
2063
|
+
active_days: number;
|
|
2064
|
+
period_days: number;
|
|
2065
|
+
computed_at: string;
|
|
2066
|
+
}
|
|
2067
|
+
interface EventMetadata {
|
|
2068
|
+
event_types: Array<{
|
|
2069
|
+
event_type: string;
|
|
2070
|
+
count: number;
|
|
2071
|
+
last_seen: string;
|
|
2072
|
+
}>;
|
|
2073
|
+
total_events: number;
|
|
2074
|
+
categories: string[];
|
|
2075
|
+
}
|
|
2076
|
+
interface ViewTemplate {
|
|
2077
|
+
id: string;
|
|
2078
|
+
name: string;
|
|
2079
|
+
description: string;
|
|
2080
|
+
computation: DataViewComputation;
|
|
2081
|
+
}
|
|
2082
|
+
/**
|
|
2083
|
+
* Data Views client for managing and executing custom data views.
|
|
2084
|
+
*
|
|
2085
|
+
* @example
|
|
2086
|
+
* ```typescript
|
|
2087
|
+
* const client = new ProofChain({ apiKey: 'your-api-key' });
|
|
2088
|
+
*
|
|
2089
|
+
* // List available views
|
|
2090
|
+
* const views = await client.dataViews.list();
|
|
2091
|
+
*
|
|
2092
|
+
* // Execute a view for a wallet
|
|
2093
|
+
* const result = await client.dataViews.execute('0x123...', 'fan_score');
|
|
2094
|
+
*
|
|
2095
|
+
* // Preview a computation
|
|
2096
|
+
* const preview = await client.dataViews.preview({
|
|
2097
|
+
* wallet_address: '0x123...',
|
|
2098
|
+
* computation: {
|
|
2099
|
+
* type: 'score',
|
|
2100
|
+
* event_weights: { purchase: 10, login: 1 },
|
|
2101
|
+
* max_score: 1000
|
|
2102
|
+
* }
|
|
2103
|
+
* });
|
|
2104
|
+
* ```
|
|
2105
|
+
*/
|
|
2106
|
+
declare class DataViewsClient {
|
|
2107
|
+
private http;
|
|
2108
|
+
constructor(http: HttpClient);
|
|
2109
|
+
/**
|
|
2110
|
+
* List all available data views.
|
|
2111
|
+
* Returns own views, public views from other tenants, and builtin views.
|
|
2112
|
+
*/
|
|
2113
|
+
list(): Promise<DataViewListResponse>;
|
|
2114
|
+
/**
|
|
2115
|
+
* Get detailed information about a specific data view.
|
|
2116
|
+
*/
|
|
2117
|
+
get(viewName: string): Promise<DataViewDetail>;
|
|
2118
|
+
/**
|
|
2119
|
+
* Create a new custom data view.
|
|
2120
|
+
*
|
|
2121
|
+
* @example
|
|
2122
|
+
* ```typescript
|
|
2123
|
+
* const view = await client.dataViews.create({
|
|
2124
|
+
* name: 'engagement_score',
|
|
2125
|
+
* display_name: 'User Engagement Score',
|
|
2126
|
+
* description: 'Weighted score based on user activity',
|
|
2127
|
+
* view_type: 'multi-computation',
|
|
2128
|
+
* computation: [
|
|
2129
|
+
* {
|
|
2130
|
+
* type: 'score',
|
|
2131
|
+
* name: 'activity_score',
|
|
2132
|
+
* event_types: ['page_view', 'purchase'],
|
|
2133
|
+
* event_weights: { page_view: 1, purchase: 10 },
|
|
2134
|
+
* max_score: 1000
|
|
2135
|
+
* },
|
|
2136
|
+
* {
|
|
2137
|
+
* type: 'tier',
|
|
2138
|
+
* name: 'loyalty_tier',
|
|
2139
|
+
* score_source: 'activity_score',
|
|
2140
|
+
* tiers: [
|
|
2141
|
+
* { name: 'Bronze', min: 0, max: 100 },
|
|
2142
|
+
* { name: 'Silver', min: 100, max: 500 },
|
|
2143
|
+
* { name: 'Gold', min: 500, max: 1000 }
|
|
2144
|
+
* ]
|
|
2145
|
+
* }
|
|
2146
|
+
* ]
|
|
2147
|
+
* });
|
|
2148
|
+
* ```
|
|
2149
|
+
*/
|
|
2150
|
+
create(request: CreateDataViewRequest): Promise<DataViewDetail>;
|
|
2151
|
+
/**
|
|
2152
|
+
* Update an existing data view.
|
|
2153
|
+
*/
|
|
2154
|
+
update(viewName: string, request: UpdateDataViewRequest): Promise<DataViewDetail>;
|
|
2155
|
+
/**
|
|
2156
|
+
* Delete a data view.
|
|
2157
|
+
*/
|
|
2158
|
+
delete(viewName: string): Promise<void>;
|
|
2159
|
+
/**
|
|
2160
|
+
* Execute a data view for a specific user.
|
|
2161
|
+
*
|
|
2162
|
+
* The identifier can be either:
|
|
2163
|
+
* - A wallet address (0x...) - queries web3-bound events
|
|
2164
|
+
* - A user_id - queries all events for that user
|
|
2165
|
+
*
|
|
2166
|
+
* @example
|
|
2167
|
+
* ```typescript
|
|
2168
|
+
* // By user ID
|
|
2169
|
+
* const result = await client.dataViews.execute('user-123', 'fan_score');
|
|
2170
|
+
*
|
|
2171
|
+
* // By wallet address
|
|
2172
|
+
* const result = await client.dataViews.execute('0x123...abc', 'fan_score');
|
|
2173
|
+
*
|
|
2174
|
+
* console.log('Data:', result.data);
|
|
2175
|
+
* console.log('Events processed:', result.total_events);
|
|
2176
|
+
* ```
|
|
2177
|
+
*/
|
|
2178
|
+
execute(identifier: string, viewName: string): Promise<DataViewExecuteResult>;
|
|
2179
|
+
/**
|
|
2180
|
+
* Preview a data view computation without saving it.
|
|
2181
|
+
* Useful for testing computation configurations before creating a view.
|
|
2182
|
+
*
|
|
2183
|
+
* @example
|
|
2184
|
+
* ```typescript
|
|
2185
|
+
* const preview = await client.dataViews.preview({
|
|
2186
|
+
* wallet_address: '0x123...',
|
|
2187
|
+
* computation: {
|
|
2188
|
+
* type: 'score',
|
|
2189
|
+
* event_types: ['purchase', 'login'],
|
|
2190
|
+
* event_weights: { purchase: 10, login: 1 },
|
|
2191
|
+
* max_score: 1000
|
|
2192
|
+
* },
|
|
2193
|
+
* time_window_days: 30
|
|
2194
|
+
* });
|
|
2195
|
+
* ```
|
|
2196
|
+
*/
|
|
2197
|
+
preview(request: DataViewPreviewRequest): Promise<DataViewPreviewResult>;
|
|
2198
|
+
/**
|
|
2199
|
+
* Get the fan profile view for a wallet.
|
|
2200
|
+
* This is a builtin view that aggregates user activity into a profile.
|
|
2201
|
+
*/
|
|
2202
|
+
getFanProfile(walletAddress: string): Promise<FanProfileView>;
|
|
2203
|
+
/**
|
|
2204
|
+
* Get the activity summary view for a wallet.
|
|
2205
|
+
* This is a builtin view that summarizes user activity over time.
|
|
2206
|
+
*/
|
|
2207
|
+
getActivitySummary(walletAddress: string, days?: number): Promise<ActivitySummaryView>;
|
|
2208
|
+
/**
|
|
2209
|
+
* Get event metadata including available event types and their counts.
|
|
2210
|
+
* Useful for building dynamic UIs that show available event types.
|
|
2211
|
+
*/
|
|
2212
|
+
getEventMetadata(): Promise<EventMetadata>;
|
|
2213
|
+
/**
|
|
2214
|
+
* Get available view templates for creating new views.
|
|
2215
|
+
* Templates provide pre-configured computation patterns.
|
|
2216
|
+
*/
|
|
2217
|
+
getTemplates(): Promise<ViewTemplate[]>;
|
|
2218
|
+
}
|
|
2219
|
+
|
|
2220
|
+
/**
|
|
2221
|
+
* ProofChain Client
|
|
2222
|
+
*/
|
|
2223
|
+
|
|
2224
|
+
/**
|
|
2225
|
+
* Documents resource for attestation operations.
|
|
2226
|
+
*/
|
|
2227
|
+
declare class DocumentsResource {
|
|
2228
|
+
private http;
|
|
2229
|
+
constructor(http: HttpClient);
|
|
2230
|
+
/**
|
|
2231
|
+
* Attest a document file.
|
|
2232
|
+
*/
|
|
2233
|
+
attest(request: AttestRequest): Promise<AttestationResult>;
|
|
2234
|
+
/**
|
|
2235
|
+
* Get a document by its IPFS hash.
|
|
2236
|
+
*/
|
|
2237
|
+
get(ipfsHash: string): Promise<Event>;
|
|
2238
|
+
}
|
|
2239
|
+
/**
|
|
2240
|
+
* Events resource for event operations.
|
|
2241
|
+
*/
|
|
2242
|
+
declare class EventsResource {
|
|
2243
|
+
private http;
|
|
2244
|
+
constructor(http: HttpClient);
|
|
2245
|
+
/**
|
|
2246
|
+
* Create a new attestation event.
|
|
2247
|
+
*/
|
|
2248
|
+
create(request: CreateEventRequest): Promise<Event>;
|
|
2249
|
+
/**
|
|
2250
|
+
* Get an event by ID.
|
|
2251
|
+
*/
|
|
2252
|
+
get(eventId: string): Promise<Event>;
|
|
2253
|
+
/**
|
|
2254
|
+
* List events with optional filters.
|
|
2255
|
+
*/
|
|
2256
|
+
list(request?: ListEventsRequest): Promise<Event[]>;
|
|
2257
|
+
/**
|
|
2258
|
+
* Search events by query.
|
|
2259
|
+
*/
|
|
2260
|
+
search(request: SearchRequest): Promise<SearchResult>;
|
|
2261
|
+
/**
|
|
2262
|
+
* Get an event by its IPFS hash.
|
|
2263
|
+
*/
|
|
2264
|
+
byHash(ipfsHash: string): Promise<Event>;
|
|
2265
|
+
/**
|
|
2266
|
+
* Create multiple events in a batch.
|
|
2267
|
+
*
|
|
2268
|
+
* Note: For high-throughput ingestion, use the IngestionClient instead.
|
|
2269
|
+
* This method is a convenience wrapper that creates events sequentially.
|
|
2270
|
+
*
|
|
2271
|
+
* @param events - Array of event requests
|
|
2272
|
+
* @returns Array of created events
|
|
2273
|
+
*/
|
|
2274
|
+
createBatch(events: CreateEventRequest[]): Promise<Event[]>;
|
|
2275
|
+
}
|
|
2276
|
+
/**
|
|
2277
|
+
* Channels resource for state channel operations.
|
|
2278
|
+
*/
|
|
2279
|
+
declare class ChannelsResource {
|
|
2280
|
+
private http;
|
|
2281
|
+
constructor(http: HttpClient);
|
|
2282
|
+
/**
|
|
2283
|
+
* Create a new state channel.
|
|
2284
|
+
*/
|
|
2285
|
+
create(request: CreateChannelRequest): Promise<Channel>;
|
|
2286
|
+
/**
|
|
2287
|
+
* Get a channel by ID.
|
|
2288
|
+
*/
|
|
2289
|
+
get(channelId: string): Promise<Channel>;
|
|
2290
|
+
/**
|
|
2291
|
+
* Get detailed status of a channel.
|
|
2292
|
+
*/
|
|
2293
|
+
status(channelId: string): Promise<ChannelStatus>;
|
|
2294
|
+
/**
|
|
2295
|
+
* List all channels.
|
|
2296
|
+
*/
|
|
2297
|
+
list(limit?: number, offset?: number): Promise<Channel[]>;
|
|
2298
|
+
/**
|
|
2299
|
+
* Stream an event to a channel.
|
|
2300
|
+
*/
|
|
2301
|
+
stream(channelId: string, request: StreamEventRequest): Promise<StreamAck>;
|
|
2302
|
+
/**
|
|
2303
|
+
* Stream multiple events in a single request.
|
|
2304
|
+
*/
|
|
2305
|
+
streamBatch(channelId: string, events: StreamEventRequest[]): Promise<Record<string, unknown>>;
|
|
2306
|
+
/**
|
|
2307
|
+
* Settle a channel on-chain.
|
|
2308
|
+
*/
|
|
2309
|
+
settle(channelId: string): Promise<Settlement>;
|
|
2310
|
+
/**
|
|
2311
|
+
* Close a channel.
|
|
2312
|
+
*/
|
|
2313
|
+
close(channelId: string): Promise<Channel>;
|
|
2314
|
+
}
|
|
2315
|
+
/**
|
|
2316
|
+
* Certificates resource for certificate operations.
|
|
2317
|
+
*/
|
|
2318
|
+
declare class CertificatesResource {
|
|
2319
|
+
private http;
|
|
2320
|
+
constructor(http: HttpClient);
|
|
2321
|
+
/**
|
|
2322
|
+
* Issue a new certificate.
|
|
2323
|
+
*/
|
|
2324
|
+
issue(request: IssueCertificateRequest): Promise<Certificate>;
|
|
2325
|
+
/**
|
|
2326
|
+
* Get a certificate by ID.
|
|
2327
|
+
*/
|
|
2328
|
+
get(certificateId: string): Promise<Certificate>;
|
|
2329
|
+
/**
|
|
2330
|
+
* List certificates.
|
|
2331
|
+
*/
|
|
2332
|
+
list(request?: ListCertificatesRequest): Promise<Certificate[]>;
|
|
2333
|
+
/**
|
|
2334
|
+
* Revoke a certificate.
|
|
2335
|
+
*/
|
|
2336
|
+
revoke(certificateId: string, reason?: string): Promise<Certificate>;
|
|
2337
|
+
/**
|
|
2338
|
+
* Verify a certificate.
|
|
2339
|
+
*/
|
|
2340
|
+
verify(certificateId: string): Promise<Record<string, unknown>>;
|
|
2341
|
+
}
|
|
2342
|
+
/**
|
|
2343
|
+
* Webhooks resource for webhook operations.
|
|
2344
|
+
*/
|
|
2345
|
+
declare class WebhooksResource {
|
|
2346
|
+
private http;
|
|
2347
|
+
constructor(http: HttpClient);
|
|
2348
|
+
/**
|
|
2349
|
+
* Create a new webhook.
|
|
2350
|
+
*/
|
|
2351
|
+
create(request: CreateWebhookRequest): Promise<Webhook>;
|
|
2352
|
+
/**
|
|
2353
|
+
* Get a webhook by ID.
|
|
2354
|
+
*/
|
|
2355
|
+
get(webhookId: string): Promise<Webhook>;
|
|
2356
|
+
/**
|
|
2357
|
+
* List all webhooks.
|
|
2358
|
+
*/
|
|
2359
|
+
list(): Promise<Webhook[]>;
|
|
2360
|
+
/**
|
|
2361
|
+
* Update a webhook.
|
|
2362
|
+
*/
|
|
2363
|
+
update(webhookId: string, request: UpdateWebhookRequest): Promise<Webhook>;
|
|
2364
|
+
/**
|
|
2365
|
+
* Delete a webhook.
|
|
2366
|
+
*/
|
|
2367
|
+
delete(webhookId: string): Promise<void>;
|
|
2368
|
+
/**
|
|
2369
|
+
* Send a test event to a webhook.
|
|
2370
|
+
*/
|
|
2371
|
+
test(webhookId: string): Promise<Record<string, unknown>>;
|
|
2372
|
+
}
|
|
2373
|
+
/**
|
|
2374
|
+
* Main ProofChain client.
|
|
2375
|
+
*/
|
|
2376
|
+
declare class ProofChain {
|
|
2377
|
+
private http;
|
|
2378
|
+
/** Documents resource for attestation operations */
|
|
2379
|
+
documents: DocumentsResource;
|
|
2380
|
+
/** Events resource for event operations */
|
|
2381
|
+
events: EventsResource;
|
|
2382
|
+
/** Channels resource for state channel operations */
|
|
2383
|
+
channels: ChannelsResource;
|
|
2384
|
+
/** Certificates resource for certificate operations */
|
|
2385
|
+
certificates: CertificatesResource;
|
|
2386
|
+
/** Webhooks resource for webhook operations */
|
|
2387
|
+
webhooks: WebhooksResource;
|
|
2388
|
+
/** Vault resource for file storage operations */
|
|
2389
|
+
vault: VaultResource;
|
|
2390
|
+
/** Search resource for advanced search operations */
|
|
2391
|
+
search: SearchResource;
|
|
2392
|
+
/** Verify resource for public verification operations */
|
|
2393
|
+
verifyResource: VerifyResource;
|
|
2394
|
+
/** Tenant resource for tenant management operations */
|
|
2395
|
+
tenant: TenantResource;
|
|
2396
|
+
/** Passport client for user passport operations */
|
|
2397
|
+
passports: PassportClient;
|
|
2398
|
+
/** Wallet client for CDP wallet operations */
|
|
2399
|
+
wallets: WalletClient;
|
|
2400
|
+
/** End users client for user management */
|
|
2401
|
+
users: EndUsersClient;
|
|
2402
|
+
/** Rewards client for reward definitions and distribution */
|
|
2403
|
+
rewards: RewardsClient;
|
|
2404
|
+
/** Quests client for quest management */
|
|
2405
|
+
quests: QuestsClient;
|
|
2406
|
+
/** Schemas client for event schema validation */
|
|
2407
|
+
schemas: SchemasClient;
|
|
2408
|
+
/** Data Views client for custom data view operations */
|
|
2409
|
+
dataViews: DataViewsClient;
|
|
2410
|
+
constructor(options: ProofChainOptions);
|
|
2411
|
+
/**
|
|
2412
|
+
* Create a client from environment variables.
|
|
2413
|
+
* Reads PROOFCHAIN_API_KEY and optionally PROOFCHAIN_BASE_URL.
|
|
2414
|
+
*/
|
|
2415
|
+
static fromEnv(): ProofChain;
|
|
2416
|
+
/**
|
|
2417
|
+
* Verify a document or event by its IPFS hash.
|
|
2418
|
+
*/
|
|
2419
|
+
verify(ipfsHash: string): Promise<VerificationResult>;
|
|
2420
|
+
/**
|
|
2421
|
+
* Get information about the current tenant.
|
|
2422
|
+
*/
|
|
2423
|
+
tenantInfo(): Promise<TenantInfo>;
|
|
2424
|
+
/**
|
|
2425
|
+
* Get API usage statistics.
|
|
2426
|
+
*/
|
|
2427
|
+
usage(period?: string): Promise<UsageStats>;
|
|
2428
|
+
}
|
|
2429
|
+
|
|
2430
|
+
/**
|
|
2431
|
+
* High-Performance Ingestion Client
|
|
2432
|
+
*
|
|
2433
|
+
* Uses the Rust ingestion API at ingest.proofchain.co.za for maximum throughput.
|
|
2434
|
+
* Supports single events, batch events, and WebSocket streaming.
|
|
2435
|
+
*/
|
|
2436
|
+
interface IngestEventRequest {
|
|
2437
|
+
userId: string;
|
|
2438
|
+
eventType: string;
|
|
2439
|
+
data?: Record<string, unknown>;
|
|
2440
|
+
eventSource?: string;
|
|
2441
|
+
schemaIds?: string[];
|
|
2442
|
+
}
|
|
2443
|
+
interface IngestEventResponse {
|
|
2444
|
+
eventId: string;
|
|
2445
|
+
certificateId: string;
|
|
2446
|
+
status: string;
|
|
2447
|
+
queuePosition?: number;
|
|
2448
|
+
estimatedConfirmation?: string;
|
|
2449
|
+
}
|
|
2450
|
+
interface BatchIngestRequest {
|
|
2451
|
+
events: IngestEventRequest[];
|
|
2452
|
+
}
|
|
2453
|
+
interface BatchIngestResponse {
|
|
2454
|
+
totalEvents: number;
|
|
2455
|
+
queued: number;
|
|
2456
|
+
failed: number;
|
|
2457
|
+
results: IngestEventResponse[];
|
|
2458
|
+
}
|
|
2459
|
+
interface IngestionClientOptions {
|
|
2460
|
+
apiKey: string;
|
|
2461
|
+
ingestUrl?: string;
|
|
2462
|
+
timeout?: number;
|
|
2463
|
+
}
|
|
2464
|
+
/**
|
|
2465
|
+
* High-performance ingestion client for the Rust ingestion API.
|
|
2466
|
+
*
|
|
2467
|
+
* @example
|
|
2468
|
+
* ```typescript
|
|
2469
|
+
* const ingestion = new IngestionClient({ apiKey: 'your-api-key' });
|
|
2470
|
+
*
|
|
2471
|
+
* // Single event
|
|
2472
|
+
* const result = await ingestion.ingest({
|
|
2473
|
+
* userId: 'user-123',
|
|
2474
|
+
* eventType: 'purchase',
|
|
2475
|
+
* data: { amount: 99.99, product: 'widget' }
|
|
2476
|
+
* });
|
|
2477
|
+
*
|
|
2478
|
+
* // Batch events (up to 1000)
|
|
2479
|
+
* const batchResult = await ingestion.ingestBatch({
|
|
2480
|
+
* events: [
|
|
2481
|
+
* { userId: 'user-1', eventType: 'click', data: { page: '/home' } },
|
|
2482
|
+
* { userId: 'user-2', eventType: 'click', data: { page: '/products' } },
|
|
2483
|
+
* ]
|
|
2484
|
+
* });
|
|
2485
|
+
* ```
|
|
2486
|
+
*/
|
|
2487
|
+
declare class IngestionClient {
|
|
2488
|
+
private apiKey;
|
|
2489
|
+
private ingestUrl;
|
|
2490
|
+
private timeout;
|
|
2491
|
+
constructor(options: IngestionClientOptions);
|
|
2492
|
+
private getHeaders;
|
|
2493
|
+
private handleResponse;
|
|
2494
|
+
/**
|
|
2495
|
+
* Ingest a single event using the high-performance Rust API.
|
|
2496
|
+
* Events are attested immediately upon ingestion.
|
|
2497
|
+
*/
|
|
2498
|
+
ingest(request: IngestEventRequest): Promise<IngestEventResponse>;
|
|
2499
|
+
/**
|
|
2500
|
+
* Ingest multiple events in a single request (up to 1000 events).
|
|
2501
|
+
* More efficient than individual calls for bulk data.
|
|
2502
|
+
*/
|
|
2503
|
+
ingestBatch(request: BatchIngestRequest): Promise<BatchIngestResponse>;
|
|
2504
|
+
/**
|
|
2505
|
+
* Get the status of an event by ID.
|
|
2506
|
+
*/
|
|
2507
|
+
getEventStatus(eventId: string): Promise<{
|
|
2508
|
+
status: string;
|
|
2509
|
+
ipfsHash?: string;
|
|
2510
|
+
}>;
|
|
2511
|
+
}
|
|
2512
|
+
|
|
2513
|
+
/**
|
|
2514
|
+
* ProofChain SDK Error Classes
|
|
2515
|
+
*/
|
|
2516
|
+
declare class ProofChainError extends Error {
|
|
2517
|
+
statusCode?: number;
|
|
2518
|
+
responseBody?: Record<string, unknown>;
|
|
2519
|
+
constructor(message: string, statusCode?: number, responseBody?: Record<string, unknown>);
|
|
2520
|
+
}
|
|
2521
|
+
declare class AuthenticationError extends ProofChainError {
|
|
2522
|
+
constructor(message?: string);
|
|
2523
|
+
}
|
|
2524
|
+
declare class AuthorizationError extends ProofChainError {
|
|
2525
|
+
constructor(message?: string);
|
|
2526
|
+
}
|
|
2527
|
+
declare class NotFoundError extends ProofChainError {
|
|
2528
|
+
constructor(message?: string);
|
|
2529
|
+
}
|
|
2530
|
+
interface ValidationErrorDetail {
|
|
2531
|
+
field: string;
|
|
2532
|
+
message: string;
|
|
2533
|
+
}
|
|
2534
|
+
declare class ValidationError extends ProofChainError {
|
|
2535
|
+
errors: ValidationErrorDetail[];
|
|
2536
|
+
constructor(message?: string, errors?: ValidationErrorDetail[]);
|
|
2537
|
+
}
|
|
2538
|
+
declare class RateLimitError extends ProofChainError {
|
|
2539
|
+
retryAfter?: number;
|
|
2540
|
+
constructor(retryAfter?: number);
|
|
2541
|
+
}
|
|
2542
|
+
declare class ServerError extends ProofChainError {
|
|
2543
|
+
constructor(message?: string, statusCode?: number);
|
|
2544
|
+
}
|
|
2545
|
+
declare class NetworkError extends ProofChainError {
|
|
2546
|
+
cause?: Error;
|
|
2547
|
+
constructor(message?: string, cause?: Error);
|
|
2548
|
+
}
|
|
2549
|
+
declare class TimeoutError extends ProofChainError {
|
|
2550
|
+
constructor(message?: string);
|
|
2551
|
+
}
|
|
327
2552
|
|
|
328
|
-
export {
|
|
2553
|
+
export { type Achievement, type ActivitySummaryView, type AddNFTRequest, type ApiKey, type AttestRequest, type AttestationMode, type AttestationResult, AuthenticationError, AuthorizationError, type AvailableView, type Badge, type BatchIngestRequest, type BatchIngestResponse, type BatchVerifyResult, type BlockchainProof, type BlockchainStats, type Certificate, type CertificateVerifyResult, CertificatesResource, type Channel, type ChannelState, type ChannelStatus, ChannelsResource, type ComprehensiveWalletInfo, type CreateAchievementRequest, type CreateApiKeyRequest, type CreateBadgeRequest, type CreateChannelRequest, type CreateDataViewRequest, type CreateDualWalletsRequest, type CreateEndUserRequest, type CreateEventRequest, type CreatePassportDefinitionRequest, type CreatePassportRequest, type CreateQuestRequest, type CreateQuestStepRequest, type CreateRewardDefinitionRequest, type CreateSchemaRequest, type CreateTemplateFieldRequest, type CreateTemplateRequest, type CreateWalletRequest, type CreateWebhookRequest, type DataViewColumn, type DataViewComputation, type DataViewDetail, type DataViewExecuteResult, type DataViewInfo, type DataViewListResponse, type DataViewPreviewRequest, type DataViewPreviewResult, type DataViewSummary, DataViewsClient, DocumentsResource, type DualWallets, type EarnedReward, type EndUser, type EndUserListResponse, EndUsersClient, type Event, type EventBatchProof, type EventMetadata, type EventStatus, EventsResource, type ExecuteSwapRequest, type Facet, type FacetsResponse, type FanProfileView, type FieldValue, type IngestEventRequest, type IngestEventResponse, IngestionClient, type IngestionClientOptions, type IssueCertificateRequest, type LinkWalletRequest, type ListCertificatesRequest, type ListEndUsersOptions, type ListEventsRequest, type ListQuestsOptions, type ListRewardsOptions, type ListSchemasOptions, type ManualRewardRequest, type MergeUsersRequest, type Milestone, type NFT, NetworkError, NotFoundError, type Passport, PassportClient, type PassportDefinition, type PassportFieldValue, type PassportHistory, type PassportTemplate, type PassportV2Data, type PassportWithFields, ProofChain, ProofChainError, type ProofChainOptions, type ProofVerifyResult, type Quest, type QuestStep, type QuestWithProgress, QuestsClient, RateLimitError, type RewardAsset, type RewardDefinition, RewardsClient, type Schema, type SchemaDetail, type SchemaField, type SchemaListResponse, type ValidationError$1 as SchemaValidationError, SchemasClient, type SearchFilters, type SearchQueryRequest, type SearchRequest, SearchResource, type SearchResponse, type SearchResult, type SearchStats, ServerError, type Settlement, type StepProgress, type StreamAck, type StreamEventRequest, type SwapQuote, type SwapQuoteRequest, type SwapResult, type TemplateField, type TenantInfo, TenantResource, type TierDefinition, TimeoutError, type TokenBalance, type TransferRequest, type TransferResult, type UpdateDataViewRequest, type UpdateEndUserRequest, type UpdatePassportRequest, type UpdateWebhookRequest, type UsageStats, type UserAchievement, type UserActivity, type UserActivityResponse, type UserBadge, type UserQuestProgress, type UserWalletSummary, type ValidateDataRequest, ValidationError, type ValidationErrorDetail, type ValidationResult, type VaultFile, type VaultFolder, type VaultListResponse, VaultResource, type VaultStats, type VaultUploadRequest, type VerificationResult, VerifyResource, type ViewColumn, type ViewTemplate, type Wallet, type WalletBalance, WalletClient, type WalletStats, type Webhook, WebhooksResource };
|