@hypercerts-org/sdk-core 0.4.0-beta.0 → 0.6.0-beta.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/README.md +459 -79
- package/dist/index.cjs +128 -47
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +28 -9
- package/dist/index.mjs +128 -47
- package/dist/index.mjs.map +1 -1
- package/dist/types.cjs +3 -2
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.ts +28 -9
- package/dist/types.mjs +3 -2
- package/dist/types.mjs.map +1 -1
- package/package.json +9 -5
- package/.turbo/turbo-build.log +0 -328
- package/.turbo/turbo-test.log +0 -118
- package/CHANGELOG.md +0 -22
- package/eslint.config.mjs +0 -22
- package/rollup.config.js +0 -75
- package/src/auth/OAuthClient.ts +0 -497
- package/src/core/SDK.ts +0 -410
- package/src/core/config.ts +0 -243
- package/src/core/errors.ts +0 -257
- package/src/core/interfaces.ts +0 -324
- package/src/core/types.ts +0 -281
- package/src/errors.ts +0 -57
- package/src/index.ts +0 -107
- package/src/lexicons.ts +0 -64
- package/src/repository/BlobOperationsImpl.ts +0 -199
- package/src/repository/CollaboratorOperationsImpl.ts +0 -396
- package/src/repository/HypercertOperationsImpl.ts +0 -1146
- package/src/repository/LexiconRegistry.ts +0 -332
- package/src/repository/OrganizationOperationsImpl.ts +0 -234
- package/src/repository/ProfileOperationsImpl.ts +0 -281
- package/src/repository/RecordOperationsImpl.ts +0 -340
- package/src/repository/Repository.ts +0 -482
- package/src/repository/interfaces.ts +0 -897
- package/src/repository/types.ts +0 -111
- package/src/services/hypercerts/types.ts +0 -87
- package/src/storage/InMemorySessionStore.ts +0 -127
- package/src/storage/InMemoryStateStore.ts +0 -146
- package/src/storage.ts +0 -63
- package/src/testing/index.ts +0 -67
- package/src/testing/mocks.ts +0 -142
- package/src/testing/stores.ts +0 -285
- package/src/testing.ts +0 -64
- package/src/types.ts +0 -86
- package/tests/auth/OAuthClient.test.ts +0 -164
- package/tests/core/SDK.test.ts +0 -176
- package/tests/core/errors.test.ts +0 -81
- package/tests/repository/BlobOperationsImpl.test.ts +0 -154
- package/tests/repository/CollaboratorOperationsImpl.test.ts +0 -438
- package/tests/repository/HypercertOperationsImpl.test.ts +0 -652
- package/tests/repository/LexiconRegistry.test.ts +0 -192
- package/tests/repository/OrganizationOperationsImpl.test.ts +0 -242
- package/tests/repository/ProfileOperationsImpl.test.ts +0 -254
- package/tests/repository/RecordOperationsImpl.test.ts +0 -375
- package/tests/repository/Repository.test.ts +0 -149
- package/tests/utils/fixtures.ts +0 -117
- package/tests/utils/mocks.ts +0 -109
- package/tests/utils/repository-fixtures.ts +0 -78
- package/tsconfig.json +0 -11
- package/tsconfig.tsbuildinfo +0 -1
- package/vitest.config.ts +0 -30
|
@@ -1,897 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Repository interfaces - Operation contracts for repository functionality.
|
|
3
|
-
*
|
|
4
|
-
* This module defines the interfaces for all repository operations,
|
|
5
|
-
* providing clear contracts for record management, blob handling,
|
|
6
|
-
* profile management, and domain-specific operations.
|
|
7
|
-
*
|
|
8
|
-
* @packageDocumentation
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import type { EventEmitter } from "eventemitter3";
|
|
12
|
-
import type { HypercertCollection, HypercertEvidence, HypercertClaim } from "../services/hypercerts/types.js";
|
|
13
|
-
import type {
|
|
14
|
-
CreateResult,
|
|
15
|
-
UpdateResult,
|
|
16
|
-
PaginatedList,
|
|
17
|
-
ListParams,
|
|
18
|
-
RepositoryRole,
|
|
19
|
-
RepositoryAccessGrant,
|
|
20
|
-
OrganizationInfo,
|
|
21
|
-
ProgressStep,
|
|
22
|
-
} from "./types.js";
|
|
23
|
-
|
|
24
|
-
// ============================================================================
|
|
25
|
-
// Hypercert Operation Types
|
|
26
|
-
// ============================================================================
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Parameters for creating a new hypercert.
|
|
30
|
-
*
|
|
31
|
-
* This interface defines all the data needed to create a hypercert
|
|
32
|
-
* along with optional related records (location, contributions, evidence).
|
|
33
|
-
*
|
|
34
|
-
* @example Minimal hypercert
|
|
35
|
-
* ```typescript
|
|
36
|
-
* const params: CreateHypercertParams = {
|
|
37
|
-
* title: "Community Garden Project",
|
|
38
|
-
* description: "Established a 1-acre community garden serving 50 families",
|
|
39
|
-
* workScope: "Food Security",
|
|
40
|
-
* workTimeframeFrom: "2024-01-01",
|
|
41
|
-
* workTimeframeTo: "2024-06-30",
|
|
42
|
-
* rights: {
|
|
43
|
-
* name: "Attribution",
|
|
44
|
-
* type: "license",
|
|
45
|
-
* description: "CC-BY-4.0",
|
|
46
|
-
* },
|
|
47
|
-
* };
|
|
48
|
-
* ```
|
|
49
|
-
*
|
|
50
|
-
* @example Full hypercert with all options
|
|
51
|
-
* ```typescript
|
|
52
|
-
* const params: CreateHypercertParams = {
|
|
53
|
-
* title: "Reforestation Initiative",
|
|
54
|
-
* description: "Planted 10,000 trees in deforested areas",
|
|
55
|
-
* shortDescription: "10K trees planted",
|
|
56
|
-
* workScope: "Environmental Restoration",
|
|
57
|
-
* workTimeframeFrom: "2024-01-01",
|
|
58
|
-
* workTimeframeTo: "2024-12-31",
|
|
59
|
-
* rights: {
|
|
60
|
-
* name: "Open Impact",
|
|
61
|
-
* type: "impact-rights",
|
|
62
|
-
* description: "Transferable impact rights",
|
|
63
|
-
* },
|
|
64
|
-
* image: coverImageBlob,
|
|
65
|
-
* location: {
|
|
66
|
-
* value: "Amazon Rainforest, Brazil",
|
|
67
|
-
* name: "Amazon Basin",
|
|
68
|
-
* description: "Southern Amazon region",
|
|
69
|
-
* },
|
|
70
|
-
* contributions: [
|
|
71
|
-
* {
|
|
72
|
-
* contributors: ["did:plc:lead-org"],
|
|
73
|
-
* role: "coordinator",
|
|
74
|
-
* description: "Project coordination and funding",
|
|
75
|
-
* },
|
|
76
|
-
* {
|
|
77
|
-
* contributors: ["did:plc:local-partner"],
|
|
78
|
-
* role: "implementer",
|
|
79
|
-
* description: "On-ground planting and monitoring",
|
|
80
|
-
* },
|
|
81
|
-
* ],
|
|
82
|
-
* evidence: [
|
|
83
|
-
* {
|
|
84
|
-
* uri: "https://example.com/satellite-data",
|
|
85
|
-
* description: "Satellite imagery showing reforestation progress",
|
|
86
|
-
* },
|
|
87
|
-
* ],
|
|
88
|
-
* onProgress: (step) => console.log(`${step.name}: ${step.status}`),
|
|
89
|
-
* };
|
|
90
|
-
* ```
|
|
91
|
-
*/
|
|
92
|
-
export interface CreateHypercertParams {
|
|
93
|
-
/**
|
|
94
|
-
* Title of the hypercert.
|
|
95
|
-
*
|
|
96
|
-
* Should be concise but descriptive of the impact claim.
|
|
97
|
-
*/
|
|
98
|
-
title: string;
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Detailed description of the impact.
|
|
102
|
-
*
|
|
103
|
-
* Can include methodology, outcomes, and other relevant details.
|
|
104
|
-
* Supports markdown formatting.
|
|
105
|
-
*/
|
|
106
|
-
description: string;
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Scope of work or impact area.
|
|
110
|
-
*
|
|
111
|
-
* @example "Climate Action", "Education", "Healthcare"
|
|
112
|
-
*/
|
|
113
|
-
workScope: string;
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Start date of the work period.
|
|
117
|
-
*
|
|
118
|
-
* ISO 8601 date format (YYYY-MM-DD).
|
|
119
|
-
*/
|
|
120
|
-
workTimeframeFrom: string;
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* End date of the work period.
|
|
124
|
-
*
|
|
125
|
-
* ISO 8601 date format (YYYY-MM-DD).
|
|
126
|
-
*/
|
|
127
|
-
workTimeframeTo: string;
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Rights associated with the hypercert.
|
|
131
|
-
*/
|
|
132
|
-
rights: {
|
|
133
|
-
/**
|
|
134
|
-
* Name of the rights.
|
|
135
|
-
*
|
|
136
|
-
* @example "Attribution", "Impact Rights", "Public Domain"
|
|
137
|
-
*/
|
|
138
|
-
name: string;
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Type of rights.
|
|
142
|
-
*
|
|
143
|
-
* @example "license", "impact-rights", "ownership"
|
|
144
|
-
*/
|
|
145
|
-
type: string;
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* Description of the rights terms.
|
|
149
|
-
*
|
|
150
|
-
* @example "CC-BY-4.0", "Transferable impact rights"
|
|
151
|
-
*/
|
|
152
|
-
description: string;
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* Optional short description for display in lists/cards.
|
|
157
|
-
*
|
|
158
|
-
* Should be under 200 characters.
|
|
159
|
-
*/
|
|
160
|
-
shortDescription?: string;
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* Optional cover image for the hypercert.
|
|
164
|
-
*
|
|
165
|
-
* Recommended size: 1200x630 pixels (social media preview ratio).
|
|
166
|
-
*/
|
|
167
|
-
image?: Blob;
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Optional geographic location of the impact.
|
|
171
|
-
*/
|
|
172
|
-
location?: {
|
|
173
|
-
/**
|
|
174
|
-
* Location value/address.
|
|
175
|
-
*
|
|
176
|
-
* @example "San Francisco, CA, USA"
|
|
177
|
-
*/
|
|
178
|
-
value: string;
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* Human-readable location name.
|
|
182
|
-
*
|
|
183
|
-
* @example "SF Bay Area"
|
|
184
|
-
*/
|
|
185
|
-
name?: string;
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* Description of the location scope.
|
|
189
|
-
*/
|
|
190
|
-
description?: string;
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* Spatial Reference System identifier.
|
|
194
|
-
*
|
|
195
|
-
* @example "EPSG:4326" for WGS84
|
|
196
|
-
*/
|
|
197
|
-
srs?: string;
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* GeoJSON file as a Blob for precise boundaries.
|
|
201
|
-
*/
|
|
202
|
-
geojson?: Blob;
|
|
203
|
-
};
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* Optional list of contributions to the impact.
|
|
207
|
-
*
|
|
208
|
-
* Use this to credit multiple contributors with different roles.
|
|
209
|
-
*/
|
|
210
|
-
contributions?: Array<{
|
|
211
|
-
/**
|
|
212
|
-
* DIDs of the contributors.
|
|
213
|
-
*/
|
|
214
|
-
contributors: string[];
|
|
215
|
-
|
|
216
|
-
/**
|
|
217
|
-
* Role in the contribution.
|
|
218
|
-
*
|
|
219
|
-
* @example "coordinator", "implementer", "funder", "volunteer"
|
|
220
|
-
*/
|
|
221
|
-
role: string;
|
|
222
|
-
|
|
223
|
-
/**
|
|
224
|
-
* Description of the contribution.
|
|
225
|
-
*/
|
|
226
|
-
description?: string;
|
|
227
|
-
}>;
|
|
228
|
-
|
|
229
|
-
/**
|
|
230
|
-
* Optional evidence supporting the impact claim.
|
|
231
|
-
*/
|
|
232
|
-
evidence?: HypercertEvidence[];
|
|
233
|
-
|
|
234
|
-
/**
|
|
235
|
-
* Optional callback for progress updates during creation.
|
|
236
|
-
*
|
|
237
|
-
* Called for each step of the creation process (image upload,
|
|
238
|
-
* record creation, attachment linking, etc.).
|
|
239
|
-
*/
|
|
240
|
-
onProgress?: (step: ProgressStep) => void;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
/**
|
|
244
|
-
* Result of creating a hypercert.
|
|
245
|
-
*
|
|
246
|
-
* Contains URIs and CIDs for all created records.
|
|
247
|
-
*/
|
|
248
|
-
export interface CreateHypercertResult {
|
|
249
|
-
/**
|
|
250
|
-
* AT-URI of the main hypercert record.
|
|
251
|
-
*/
|
|
252
|
-
hypercertUri: string;
|
|
253
|
-
|
|
254
|
-
/**
|
|
255
|
-
* AT-URI of the associated rights record.
|
|
256
|
-
*/
|
|
257
|
-
rightsUri: string;
|
|
258
|
-
|
|
259
|
-
/**
|
|
260
|
-
* CID of the hypercert record.
|
|
261
|
-
*/
|
|
262
|
-
hypercertCid: string;
|
|
263
|
-
|
|
264
|
-
/**
|
|
265
|
-
* CID of the rights record.
|
|
266
|
-
*/
|
|
267
|
-
rightsCid: string;
|
|
268
|
-
|
|
269
|
-
/**
|
|
270
|
-
* AT-URI of the location record, if location was provided.
|
|
271
|
-
*/
|
|
272
|
-
locationUri?: string;
|
|
273
|
-
|
|
274
|
-
/**
|
|
275
|
-
* AT-URIs of contribution records, if contributions were provided.
|
|
276
|
-
*/
|
|
277
|
-
contributionUris?: string[];
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
// ============================================================================
|
|
281
|
-
// Operation Interfaces
|
|
282
|
-
// ============================================================================
|
|
283
|
-
|
|
284
|
-
/**
|
|
285
|
-
* Low-level record operations for AT Protocol CRUD.
|
|
286
|
-
*
|
|
287
|
-
* Use this interface for direct access to AT Protocol records when
|
|
288
|
-
* the high-level APIs don't meet your needs.
|
|
289
|
-
*
|
|
290
|
-
* @example
|
|
291
|
-
* ```typescript
|
|
292
|
-
* // Create a record
|
|
293
|
-
* const { uri, cid } = await repo.records.create({
|
|
294
|
-
* collection: "org.example.mytype",
|
|
295
|
-
* record: { foo: "bar", createdAt: new Date().toISOString() },
|
|
296
|
-
* });
|
|
297
|
-
*
|
|
298
|
-
* // Get a record
|
|
299
|
-
* const { value } = await repo.records.get({
|
|
300
|
-
* collection: "org.example.mytype",
|
|
301
|
-
* rkey: "abc123",
|
|
302
|
-
* });
|
|
303
|
-
*
|
|
304
|
-
* // Update a record
|
|
305
|
-
* await repo.records.update({
|
|
306
|
-
* collection: "org.example.mytype",
|
|
307
|
-
* rkey: "abc123",
|
|
308
|
-
* record: { ...value, foo: "updated" },
|
|
309
|
-
* });
|
|
310
|
-
*
|
|
311
|
-
* // List records
|
|
312
|
-
* const { records, cursor } = await repo.records.list({
|
|
313
|
-
* collection: "org.example.mytype",
|
|
314
|
-
* limit: 50,
|
|
315
|
-
* });
|
|
316
|
-
*
|
|
317
|
-
* // Delete a record
|
|
318
|
-
* await repo.records.delete({
|
|
319
|
-
* collection: "org.example.mytype",
|
|
320
|
-
* rkey: "abc123",
|
|
321
|
-
* });
|
|
322
|
-
* ```
|
|
323
|
-
*/
|
|
324
|
-
export interface RecordOperations {
|
|
325
|
-
/**
|
|
326
|
-
* Creates a new record in a collection.
|
|
327
|
-
*
|
|
328
|
-
* @param params - Creation parameters
|
|
329
|
-
* @param params.collection - NSID of the collection (e.g., "org.hypercerts.hypercert")
|
|
330
|
-
* @param params.record - Record data (must conform to collection's lexicon)
|
|
331
|
-
* @param params.rkey - Optional record key. Auto-generated if not provided.
|
|
332
|
-
* @returns Promise resolving to the created record's URI and CID
|
|
333
|
-
*/
|
|
334
|
-
create(params: { collection: string; record: unknown; rkey?: string }): Promise<CreateResult>;
|
|
335
|
-
|
|
336
|
-
/**
|
|
337
|
-
* Updates an existing record.
|
|
338
|
-
*
|
|
339
|
-
* @param params - Update parameters
|
|
340
|
-
* @param params.collection - NSID of the collection
|
|
341
|
-
* @param params.rkey - Record key to update
|
|
342
|
-
* @param params.record - New record data (replaces entire record)
|
|
343
|
-
* @returns Promise resolving to the updated record's URI and CID
|
|
344
|
-
*/
|
|
345
|
-
update(params: { collection: string; rkey: string; record: unknown }): Promise<UpdateResult>;
|
|
346
|
-
|
|
347
|
-
/**
|
|
348
|
-
* Gets a single record by collection and key.
|
|
349
|
-
*
|
|
350
|
-
* @param params - Get parameters
|
|
351
|
-
* @param params.collection - NSID of the collection
|
|
352
|
-
* @param params.rkey - Record key
|
|
353
|
-
* @returns Promise resolving to the record's URI, CID, and value
|
|
354
|
-
*/
|
|
355
|
-
get(params: { collection: string; rkey: string }): Promise<{ uri: string; cid: string; value: unknown }>;
|
|
356
|
-
|
|
357
|
-
/**
|
|
358
|
-
* Lists records in a collection with pagination.
|
|
359
|
-
*
|
|
360
|
-
* @param params - List parameters
|
|
361
|
-
* @param params.collection - NSID of the collection
|
|
362
|
-
* @param params.limit - Maximum records to return (default varies by server)
|
|
363
|
-
* @param params.cursor - Pagination cursor from previous response
|
|
364
|
-
* @returns Promise resolving to paginated list of records
|
|
365
|
-
*/
|
|
366
|
-
list(params: {
|
|
367
|
-
collection: string;
|
|
368
|
-
limit?: number;
|
|
369
|
-
cursor?: string;
|
|
370
|
-
}): Promise<PaginatedList<{ uri: string; cid: string; value: unknown }>>;
|
|
371
|
-
|
|
372
|
-
/**
|
|
373
|
-
* Deletes a record.
|
|
374
|
-
*
|
|
375
|
-
* @param params - Delete parameters
|
|
376
|
-
* @param params.collection - NSID of the collection
|
|
377
|
-
* @param params.rkey - Record key to delete
|
|
378
|
-
*/
|
|
379
|
-
delete(params: { collection: string; rkey: string }): Promise<void>;
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
/**
|
|
383
|
-
* Blob operations for binary data handling.
|
|
384
|
-
*
|
|
385
|
-
* Blobs are used for images, files, and other binary content.
|
|
386
|
-
* They are referenced from records using blob references.
|
|
387
|
-
*
|
|
388
|
-
* @example
|
|
389
|
-
* ```typescript
|
|
390
|
-
* // Upload an image
|
|
391
|
-
* const imageBlob = new Blob([imageData], { type: "image/jpeg" });
|
|
392
|
-
* const { ref, mimeType, size } = await repo.blobs.upload(imageBlob);
|
|
393
|
-
*
|
|
394
|
-
* // Use the ref in a record
|
|
395
|
-
* await repo.records.create({
|
|
396
|
-
* collection: "org.example.post",
|
|
397
|
-
* record: {
|
|
398
|
-
* text: "Hello!",
|
|
399
|
-
* image: ref, // { $link: "bafyrei..." }
|
|
400
|
-
* },
|
|
401
|
-
* });
|
|
402
|
-
*
|
|
403
|
-
* // Retrieve a blob
|
|
404
|
-
* const { data, mimeType } = await repo.blobs.get(ref.$link);
|
|
405
|
-
* ```
|
|
406
|
-
*/
|
|
407
|
-
export interface BlobOperations {
|
|
408
|
-
/**
|
|
409
|
-
* Uploads a blob to the server.
|
|
410
|
-
*
|
|
411
|
-
* @param blob - The blob to upload
|
|
412
|
-
* @returns Promise resolving to blob reference and metadata
|
|
413
|
-
*/
|
|
414
|
-
upload(blob: Blob): Promise<{
|
|
415
|
-
/**
|
|
416
|
-
* Blob reference to use in records.
|
|
417
|
-
*
|
|
418
|
-
* Contains `$link` property with the CID.
|
|
419
|
-
*/
|
|
420
|
-
ref: { $link: string };
|
|
421
|
-
|
|
422
|
-
/**
|
|
423
|
-
* MIME type of the uploaded blob.
|
|
424
|
-
*/
|
|
425
|
-
mimeType: string;
|
|
426
|
-
|
|
427
|
-
/**
|
|
428
|
-
* Size of the blob in bytes.
|
|
429
|
-
*/
|
|
430
|
-
size: number;
|
|
431
|
-
}>;
|
|
432
|
-
|
|
433
|
-
/**
|
|
434
|
-
* Retrieves a blob by its CID.
|
|
435
|
-
*
|
|
436
|
-
* @param cid - Content Identifier of the blob
|
|
437
|
-
* @returns Promise resolving to blob data and MIME type
|
|
438
|
-
*/
|
|
439
|
-
get(cid: string): Promise<{
|
|
440
|
-
/**
|
|
441
|
-
* Raw blob data as Uint8Array.
|
|
442
|
-
*/
|
|
443
|
-
data: Uint8Array;
|
|
444
|
-
|
|
445
|
-
/**
|
|
446
|
-
* MIME type of the blob.
|
|
447
|
-
*/
|
|
448
|
-
mimeType: string;
|
|
449
|
-
}>;
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
/**
|
|
453
|
-
* Profile operations for user profile management.
|
|
454
|
-
*
|
|
455
|
-
* @example
|
|
456
|
-
* ```typescript
|
|
457
|
-
* // Get profile
|
|
458
|
-
* const profile = await repo.profile.get();
|
|
459
|
-
* console.log(profile.displayName);
|
|
460
|
-
*
|
|
461
|
-
* // Update profile
|
|
462
|
-
* await repo.profile.update({
|
|
463
|
-
* displayName: "New Name",
|
|
464
|
-
* description: "Updated bio",
|
|
465
|
-
* });
|
|
466
|
-
*
|
|
467
|
-
* // Update avatar
|
|
468
|
-
* await repo.profile.update({
|
|
469
|
-
* avatar: new Blob([avatarData], { type: "image/png" }),
|
|
470
|
-
* });
|
|
471
|
-
*
|
|
472
|
-
* // Clear a field by passing null
|
|
473
|
-
* await repo.profile.update({
|
|
474
|
-
* website: null, // Removes website
|
|
475
|
-
* });
|
|
476
|
-
* ```
|
|
477
|
-
*/
|
|
478
|
-
export interface ProfileOperations {
|
|
479
|
-
/**
|
|
480
|
-
* Gets the repository's profile.
|
|
481
|
-
*
|
|
482
|
-
* @returns Promise resolving to profile data
|
|
483
|
-
*/
|
|
484
|
-
get(): Promise<{
|
|
485
|
-
/**
|
|
486
|
-
* User's handle (e.g., "alice.bsky.social").
|
|
487
|
-
*/
|
|
488
|
-
handle: string;
|
|
489
|
-
|
|
490
|
-
/**
|
|
491
|
-
* Display name.
|
|
492
|
-
*/
|
|
493
|
-
displayName?: string;
|
|
494
|
-
|
|
495
|
-
/**
|
|
496
|
-
* Profile description/bio.
|
|
497
|
-
*/
|
|
498
|
-
description?: string;
|
|
499
|
-
|
|
500
|
-
/**
|
|
501
|
-
* Avatar image URL or blob reference.
|
|
502
|
-
*/
|
|
503
|
-
avatar?: string;
|
|
504
|
-
|
|
505
|
-
/**
|
|
506
|
-
* Banner image URL or blob reference.
|
|
507
|
-
*/
|
|
508
|
-
banner?: string;
|
|
509
|
-
|
|
510
|
-
/**
|
|
511
|
-
* Website URL.
|
|
512
|
-
*/
|
|
513
|
-
website?: string;
|
|
514
|
-
}>;
|
|
515
|
-
|
|
516
|
-
/**
|
|
517
|
-
* Updates the repository's profile.
|
|
518
|
-
*
|
|
519
|
-
* Pass `null` to clear a field. Omitted fields are unchanged.
|
|
520
|
-
*
|
|
521
|
-
* @param params - Fields to update
|
|
522
|
-
* @returns Promise resolving to update result
|
|
523
|
-
*/
|
|
524
|
-
update(params: {
|
|
525
|
-
displayName?: string | null;
|
|
526
|
-
description?: string | null;
|
|
527
|
-
avatar?: Blob | null;
|
|
528
|
-
banner?: Blob | null;
|
|
529
|
-
website?: string | null;
|
|
530
|
-
}): Promise<UpdateResult>;
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
/**
|
|
534
|
-
* Events emitted by hypercert operations.
|
|
535
|
-
*
|
|
536
|
-
* Use these to track progress of complex operations or react
|
|
537
|
-
* to record changes.
|
|
538
|
-
*/
|
|
539
|
-
export interface HypercertEvents {
|
|
540
|
-
/**
|
|
541
|
-
* Emitted when a hypercert record is created.
|
|
542
|
-
*/
|
|
543
|
-
recordCreated: { uri: string; cid: string };
|
|
544
|
-
|
|
545
|
-
/**
|
|
546
|
-
* Emitted when a hypercert record is updated.
|
|
547
|
-
*/
|
|
548
|
-
recordUpdated: { uri: string; cid: string };
|
|
549
|
-
|
|
550
|
-
/**
|
|
551
|
-
* Emitted when a rights record is created.
|
|
552
|
-
*/
|
|
553
|
-
rightsCreated: { uri: string; cid: string };
|
|
554
|
-
|
|
555
|
-
/**
|
|
556
|
-
* Emitted when a location is attached to a hypercert.
|
|
557
|
-
*/
|
|
558
|
-
locationAttached: { uri: string; cid: string; hypercertUri: string };
|
|
559
|
-
|
|
560
|
-
/**
|
|
561
|
-
* Emitted when a contribution record is created.
|
|
562
|
-
*/
|
|
563
|
-
contributionCreated: { uri: string; cid: string };
|
|
564
|
-
|
|
565
|
-
/**
|
|
566
|
-
* Emitted when evidence is added to a hypercert.
|
|
567
|
-
*/
|
|
568
|
-
evidenceAdded: { uri: string; cid: string };
|
|
569
|
-
|
|
570
|
-
/**
|
|
571
|
-
* Emitted when a collection is created.
|
|
572
|
-
*/
|
|
573
|
-
collectionCreated: { uri: string; cid: string };
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
/**
|
|
577
|
-
* High-level hypercert operations.
|
|
578
|
-
*
|
|
579
|
-
* Provides a convenient API for creating and managing hypercerts
|
|
580
|
-
* with automatic handling of related records (rights, locations,
|
|
581
|
-
* contributions, etc.).
|
|
582
|
-
*
|
|
583
|
-
* Extends EventEmitter to provide progress events.
|
|
584
|
-
*
|
|
585
|
-
* @example Basic usage
|
|
586
|
-
* ```typescript
|
|
587
|
-
* // Create a hypercert
|
|
588
|
-
* const result = await repo.hypercerts.create({
|
|
589
|
-
* title: "Impact Project",
|
|
590
|
-
* description: "Description...",
|
|
591
|
-
* workScope: "Climate",
|
|
592
|
-
* workTimeframeFrom: "2024-01-01",
|
|
593
|
-
* workTimeframeTo: "2024-12-31",
|
|
594
|
-
* rights: { name: "CC-BY", type: "license", description: "..." },
|
|
595
|
-
* });
|
|
596
|
-
*
|
|
597
|
-
* // List hypercerts
|
|
598
|
-
* const { records } = await repo.hypercerts.list({ limit: 20 });
|
|
599
|
-
*
|
|
600
|
-
* // Get a specific hypercert
|
|
601
|
-
* const hypercert = await repo.hypercerts.get(result.hypercertUri);
|
|
602
|
-
* ```
|
|
603
|
-
*
|
|
604
|
-
* @example With events
|
|
605
|
-
* ```typescript
|
|
606
|
-
* repo.hypercerts.on("recordCreated", ({ uri }) => {
|
|
607
|
-
* console.log(`Created: ${uri}`);
|
|
608
|
-
* });
|
|
609
|
-
* ```
|
|
610
|
-
*/
|
|
611
|
-
export interface HypercertOperations extends EventEmitter<HypercertEvents> {
|
|
612
|
-
/**
|
|
613
|
-
* Creates a new hypercert with all related records.
|
|
614
|
-
*
|
|
615
|
-
* @param params - Creation parameters
|
|
616
|
-
* @returns Promise resolving to URIs and CIDs of created records
|
|
617
|
-
*/
|
|
618
|
-
create(params: CreateHypercertParams): Promise<CreateHypercertResult>;
|
|
619
|
-
|
|
620
|
-
/**
|
|
621
|
-
* Updates an existing hypercert.
|
|
622
|
-
*
|
|
623
|
-
* @param params - Update parameters
|
|
624
|
-
* @param params.uri - AT-URI of the hypercert to update
|
|
625
|
-
* @param params.updates - Fields to update
|
|
626
|
-
* @param params.image - New image, or `null` to remove
|
|
627
|
-
* @returns Promise resolving to update result
|
|
628
|
-
*/
|
|
629
|
-
update(params: {
|
|
630
|
-
uri: string;
|
|
631
|
-
updates: Partial<Omit<HypercertClaim, "$type" | "createdAt" | "rights">>;
|
|
632
|
-
image?: Blob | null;
|
|
633
|
-
}): Promise<UpdateResult>;
|
|
634
|
-
|
|
635
|
-
/**
|
|
636
|
-
* Gets a hypercert by URI.
|
|
637
|
-
*
|
|
638
|
-
* @param uri - AT-URI of the hypercert
|
|
639
|
-
* @returns Promise resolving to hypercert data
|
|
640
|
-
*/
|
|
641
|
-
get(uri: string): Promise<{ uri: string; cid: string; record: HypercertClaim }>;
|
|
642
|
-
|
|
643
|
-
/**
|
|
644
|
-
* Lists hypercerts with pagination.
|
|
645
|
-
*
|
|
646
|
-
* @param params - Optional pagination parameters
|
|
647
|
-
* @returns Promise resolving to paginated list
|
|
648
|
-
*/
|
|
649
|
-
list(params?: ListParams): Promise<PaginatedList<{ uri: string; cid: string; record: HypercertClaim }>>;
|
|
650
|
-
|
|
651
|
-
/**
|
|
652
|
-
* Deletes a hypercert.
|
|
653
|
-
*
|
|
654
|
-
* Note: This does not automatically delete related records
|
|
655
|
-
* (rights, locations, contributions).
|
|
656
|
-
*
|
|
657
|
-
* @param uri - AT-URI of the hypercert to delete
|
|
658
|
-
*/
|
|
659
|
-
delete(uri: string): Promise<void>;
|
|
660
|
-
|
|
661
|
-
/**
|
|
662
|
-
* Attaches a location to an existing hypercert.
|
|
663
|
-
*
|
|
664
|
-
* @param uri - AT-URI of the hypercert
|
|
665
|
-
* @param location - Location data
|
|
666
|
-
* @returns Promise resolving to location record result
|
|
667
|
-
*/
|
|
668
|
-
attachLocation(
|
|
669
|
-
uri: string,
|
|
670
|
-
location: {
|
|
671
|
-
value: string;
|
|
672
|
-
name?: string;
|
|
673
|
-
description?: string;
|
|
674
|
-
srs?: string;
|
|
675
|
-
geojson?: Blob;
|
|
676
|
-
},
|
|
677
|
-
): Promise<CreateResult>;
|
|
678
|
-
|
|
679
|
-
/**
|
|
680
|
-
* Adds evidence to an existing hypercert.
|
|
681
|
-
*
|
|
682
|
-
* @param uri - AT-URI of the hypercert
|
|
683
|
-
* @param evidence - Array of evidence items to add
|
|
684
|
-
* @returns Promise resolving to update result
|
|
685
|
-
*/
|
|
686
|
-
addEvidence(uri: string, evidence: HypercertEvidence[]): Promise<UpdateResult>;
|
|
687
|
-
|
|
688
|
-
/**
|
|
689
|
-
* Creates a contribution record.
|
|
690
|
-
*
|
|
691
|
-
* @param params - Contribution parameters
|
|
692
|
-
* @returns Promise resolving to contribution record result
|
|
693
|
-
*/
|
|
694
|
-
addContribution(params: {
|
|
695
|
-
hypercertUri?: string;
|
|
696
|
-
contributors: string[];
|
|
697
|
-
role: string;
|
|
698
|
-
description?: string;
|
|
699
|
-
}): Promise<CreateResult>;
|
|
700
|
-
|
|
701
|
-
/**
|
|
702
|
-
* Creates a measurement record for a hypercert.
|
|
703
|
-
*
|
|
704
|
-
* @param params - Measurement parameters
|
|
705
|
-
* @returns Promise resolving to measurement record result
|
|
706
|
-
*/
|
|
707
|
-
addMeasurement(params: {
|
|
708
|
-
hypercertUri: string;
|
|
709
|
-
measurers: string[];
|
|
710
|
-
metric: string;
|
|
711
|
-
value: string;
|
|
712
|
-
methodUri?: string;
|
|
713
|
-
evidenceUris?: string[];
|
|
714
|
-
}): Promise<CreateResult>;
|
|
715
|
-
|
|
716
|
-
/**
|
|
717
|
-
* Creates an evaluation record.
|
|
718
|
-
*
|
|
719
|
-
* @param params - Evaluation parameters
|
|
720
|
-
* @returns Promise resolving to evaluation record result
|
|
721
|
-
*/
|
|
722
|
-
addEvaluation(params: { subjectUri: string; evaluators: string[]; summary: string }): Promise<CreateResult>;
|
|
723
|
-
|
|
724
|
-
/**
|
|
725
|
-
* Creates a collection of hypercerts.
|
|
726
|
-
*
|
|
727
|
-
* @param params - Collection parameters
|
|
728
|
-
* @returns Promise resolving to collection record result
|
|
729
|
-
*/
|
|
730
|
-
createCollection(params: {
|
|
731
|
-
title: string;
|
|
732
|
-
claims: Array<{ uri: string; cid: string; weight: string }>;
|
|
733
|
-
shortDescription?: string;
|
|
734
|
-
coverPhoto?: Blob;
|
|
735
|
-
}): Promise<CreateResult>;
|
|
736
|
-
|
|
737
|
-
/**
|
|
738
|
-
* Gets a collection by URI.
|
|
739
|
-
*
|
|
740
|
-
* @param uri - AT-URI of the collection
|
|
741
|
-
* @returns Promise resolving to collection data
|
|
742
|
-
*/
|
|
743
|
-
getCollection(uri: string): Promise<{ uri: string; cid: string; record: HypercertCollection }>;
|
|
744
|
-
|
|
745
|
-
/**
|
|
746
|
-
* Lists collections with pagination.
|
|
747
|
-
*
|
|
748
|
-
* @param params - Optional pagination parameters
|
|
749
|
-
* @returns Promise resolving to paginated list
|
|
750
|
-
*/
|
|
751
|
-
listCollections(
|
|
752
|
-
params?: ListParams,
|
|
753
|
-
): Promise<PaginatedList<{ uri: string; cid: string; record: HypercertCollection }>>;
|
|
754
|
-
}
|
|
755
|
-
|
|
756
|
-
/**
|
|
757
|
-
* Collaborator operations for SDS access control.
|
|
758
|
-
*
|
|
759
|
-
* **SDS Only**: These operations are only available on Shared Data Servers.
|
|
760
|
-
*
|
|
761
|
-
* @example
|
|
762
|
-
* ```typescript
|
|
763
|
-
* // Grant access
|
|
764
|
-
* await repo.collaborators.grant({
|
|
765
|
-
* userDid: "did:plc:new-user",
|
|
766
|
-
* role: "editor",
|
|
767
|
-
* });
|
|
768
|
-
*
|
|
769
|
-
* // List collaborators
|
|
770
|
-
* const collaborators = await repo.collaborators.list();
|
|
771
|
-
*
|
|
772
|
-
* // Check access
|
|
773
|
-
* const hasAccess = await repo.collaborators.hasAccess("did:plc:someone");
|
|
774
|
-
* const role = await repo.collaborators.getRole("did:plc:someone");
|
|
775
|
-
*
|
|
776
|
-
* // Get current user permissions
|
|
777
|
-
* const permissions = await repo.collaborators.getPermissions();
|
|
778
|
-
* if (permissions.admin) {
|
|
779
|
-
* // Can manage collaborators
|
|
780
|
-
* }
|
|
781
|
-
*
|
|
782
|
-
* // Transfer ownership
|
|
783
|
-
* await repo.collaborators.transferOwnership({
|
|
784
|
-
* newOwnerDid: "did:plc:new-owner",
|
|
785
|
-
* });
|
|
786
|
-
*
|
|
787
|
-
* // Revoke access
|
|
788
|
-
* await repo.collaborators.revoke({ userDid: "did:plc:former-user" });
|
|
789
|
-
* ```
|
|
790
|
-
*/
|
|
791
|
-
export interface CollaboratorOperations {
|
|
792
|
-
/**
|
|
793
|
-
* Grants repository access to a user.
|
|
794
|
-
*
|
|
795
|
-
* @param params - Grant parameters
|
|
796
|
-
* @param params.userDid - DID of the user to grant access to
|
|
797
|
-
* @param params.role - Role to assign
|
|
798
|
-
*/
|
|
799
|
-
grant(params: { userDid: string; role: RepositoryRole }): Promise<void>;
|
|
800
|
-
|
|
801
|
-
/**
|
|
802
|
-
* Revokes repository access from a user.
|
|
803
|
-
*
|
|
804
|
-
* @param params - Revoke parameters
|
|
805
|
-
* @param params.userDid - DID of the user to revoke access from
|
|
806
|
-
*/
|
|
807
|
-
revoke(params: { userDid: string }): Promise<void>;
|
|
808
|
-
|
|
809
|
-
/**
|
|
810
|
-
* Lists all collaborators on the repository.
|
|
811
|
-
*
|
|
812
|
-
* @returns Promise resolving to array of access grants
|
|
813
|
-
*/
|
|
814
|
-
list(): Promise<RepositoryAccessGrant[]>;
|
|
815
|
-
|
|
816
|
-
/**
|
|
817
|
-
* Checks if a user has any access to the repository.
|
|
818
|
-
*
|
|
819
|
-
* @param userDid - DID to check
|
|
820
|
-
* @returns Promise resolving to boolean
|
|
821
|
-
*/
|
|
822
|
-
hasAccess(userDid: string): Promise<boolean>;
|
|
823
|
-
|
|
824
|
-
/**
|
|
825
|
-
* Gets the role assigned to a user.
|
|
826
|
-
*
|
|
827
|
-
* @param userDid - DID to check
|
|
828
|
-
* @returns Promise resolving to role, or `null` if no access
|
|
829
|
-
*/
|
|
830
|
-
getRole(userDid: string): Promise<RepositoryRole | null>;
|
|
831
|
-
|
|
832
|
-
/**
|
|
833
|
-
* Gets the current user's permissions for this repository.
|
|
834
|
-
*
|
|
835
|
-
* @returns Promise resolving to permission flags
|
|
836
|
-
*/
|
|
837
|
-
getPermissions(): Promise<import("../core/types.js").CollaboratorPermissions>;
|
|
838
|
-
|
|
839
|
-
/**
|
|
840
|
-
* Transfers repository ownership to another user.
|
|
841
|
-
*
|
|
842
|
-
* **WARNING**: This action is irreversible. The new owner will have
|
|
843
|
-
* full control of the repository.
|
|
844
|
-
*
|
|
845
|
-
* @param params - Transfer parameters
|
|
846
|
-
* @param params.newOwnerDid - DID of the user to transfer ownership to
|
|
847
|
-
*/
|
|
848
|
-
transferOwnership(params: { newOwnerDid: string }): Promise<void>;
|
|
849
|
-
}
|
|
850
|
-
|
|
851
|
-
/**
|
|
852
|
-
* Organization operations for SDS organization management.
|
|
853
|
-
*
|
|
854
|
-
* **SDS Only**: These operations are only available on Shared Data Servers.
|
|
855
|
-
*
|
|
856
|
-
* @example
|
|
857
|
-
* ```typescript
|
|
858
|
-
* // Create an organization
|
|
859
|
-
* const org = await repo.organizations.create({
|
|
860
|
-
* name: "My Team",
|
|
861
|
-
* description: "A team for impact projects",
|
|
862
|
-
* });
|
|
863
|
-
*
|
|
864
|
-
* // List organizations
|
|
865
|
-
* const orgs = await repo.organizations.list();
|
|
866
|
-
*
|
|
867
|
-
* // Get organization details
|
|
868
|
-
* const orgInfo = await repo.organizations.get(org.did);
|
|
869
|
-
* ```
|
|
870
|
-
*/
|
|
871
|
-
export interface OrganizationOperations {
|
|
872
|
-
/**
|
|
873
|
-
* Creates a new organization.
|
|
874
|
-
*
|
|
875
|
-
* @param params - Organization parameters
|
|
876
|
-
* @param params.name - Organization name
|
|
877
|
-
* @param params.description - Optional description
|
|
878
|
-
* @param params.handle - Optional custom handle
|
|
879
|
-
* @returns Promise resolving to organization info
|
|
880
|
-
*/
|
|
881
|
-
create(params: { name: string; description?: string; handle?: string }): Promise<OrganizationInfo>;
|
|
882
|
-
|
|
883
|
-
/**
|
|
884
|
-
* Gets an organization by DID.
|
|
885
|
-
*
|
|
886
|
-
* @param did - Organization DID
|
|
887
|
-
* @returns Promise resolving to organization info, or `null` if not found
|
|
888
|
-
*/
|
|
889
|
-
get(did: string): Promise<OrganizationInfo | null>;
|
|
890
|
-
|
|
891
|
-
/**
|
|
892
|
-
* Lists organizations the current user has access to.
|
|
893
|
-
*
|
|
894
|
-
* @returns Promise resolving to array of organization info
|
|
895
|
-
*/
|
|
896
|
-
list(): Promise<OrganizationInfo[]>;
|
|
897
|
-
}
|