@hypercerts-org/sdk-core 0.10.0-beta.2 → 0.10.0-beta.4
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/CHANGELOG.md +25 -0
- package/README.md +5 -0
- package/dist/index.cjs +11 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +37 -16
- package/dist/index.mjs +11 -10
- package/dist/index.mjs.map +1 -1
- package/dist/types.d.ts +37 -16
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1083,22 +1083,27 @@ interface CreateHypercertParams {
|
|
|
1083
1083
|
description: string;
|
|
1084
1084
|
/**
|
|
1085
1085
|
* Scope of work or impact area.
|
|
1086
|
+
* Logical scope of the work using label-based conditions. All labels in `withinAllOf` must apply; at least one label in `withinAnyOf` must apply if provided; no label in `withinNoneOf` may apply.
|
|
1086
1087
|
*
|
|
1087
1088
|
* @example "Climate Action", "Education", "Healthcare"
|
|
1088
1089
|
*/
|
|
1089
|
-
workScope
|
|
1090
|
+
workScope?: {
|
|
1091
|
+
withinAllOf?: string[];
|
|
1092
|
+
withinAnyOf?: string[];
|
|
1093
|
+
withinNoneOf?: string[];
|
|
1094
|
+
};
|
|
1090
1095
|
/**
|
|
1091
1096
|
* Start date of the work period.
|
|
1092
1097
|
*
|
|
1093
1098
|
* ISO 8601 date format (YYYY-MM-DD).
|
|
1094
1099
|
*/
|
|
1095
|
-
|
|
1100
|
+
startDate: string;
|
|
1096
1101
|
/**
|
|
1097
1102
|
* End date of the work period.
|
|
1098
1103
|
*
|
|
1099
1104
|
* ISO 8601 date format (YYYY-MM-DD).
|
|
1100
1105
|
*/
|
|
1101
|
-
|
|
1106
|
+
endDate: string;
|
|
1102
1107
|
/**
|
|
1103
1108
|
* Rights associated with the hypercert.
|
|
1104
1109
|
*/
|
|
@@ -1198,6 +1203,22 @@ interface CreateHypercertParams {
|
|
|
1198
1203
|
*/
|
|
1199
1204
|
onProgress?: (step: ProgressStep) => void;
|
|
1200
1205
|
}
|
|
1206
|
+
interface CreateOrganizationParams {
|
|
1207
|
+
/**
|
|
1208
|
+
* Name of the organization
|
|
1209
|
+
*/
|
|
1210
|
+
name: string;
|
|
1211
|
+
/**
|
|
1212
|
+
* The handle of the organization without attaching the SDS domain
|
|
1213
|
+
*
|
|
1214
|
+
* @example: "gainforest" for "gainforest.sds.hypercerts.org"
|
|
1215
|
+
*/
|
|
1216
|
+
handlePrefix: string;
|
|
1217
|
+
/**
|
|
1218
|
+
* Optional description of the organization
|
|
1219
|
+
*/
|
|
1220
|
+
description?: string;
|
|
1221
|
+
}
|
|
1201
1222
|
/**
|
|
1202
1223
|
* Result of creating a hypercert.
|
|
1203
1224
|
*
|
|
@@ -1769,6 +1790,16 @@ interface HypercertOperations extends EventEmitter<HypercertEvents> {
|
|
|
1769
1790
|
* await repo.collaborators.revoke({ userDid: "did:plc:former-user" });
|
|
1770
1791
|
* ```
|
|
1771
1792
|
*/
|
|
1793
|
+
interface GrantAccessParams {
|
|
1794
|
+
/**
|
|
1795
|
+
* DID of the user to grant access to
|
|
1796
|
+
*/
|
|
1797
|
+
userDid: string;
|
|
1798
|
+
/**
|
|
1799
|
+
* Role to assign
|
|
1800
|
+
*/
|
|
1801
|
+
role: RepositoryRole;
|
|
1802
|
+
}
|
|
1772
1803
|
interface CollaboratorOperations {
|
|
1773
1804
|
/**
|
|
1774
1805
|
* Grants repository access to a user.
|
|
@@ -1777,10 +1808,7 @@ interface CollaboratorOperations {
|
|
|
1777
1808
|
* @param params.userDid - DID of the user to grant access to
|
|
1778
1809
|
* @param params.role - Role to assign
|
|
1779
1810
|
*/
|
|
1780
|
-
grant(params:
|
|
1781
|
-
userDid: string;
|
|
1782
|
-
role: RepositoryRole;
|
|
1783
|
-
}): Promise<void>;
|
|
1811
|
+
grant(params: GrantAccessParams): Promise<void>;
|
|
1784
1812
|
/**
|
|
1785
1813
|
* Revokes repository access from a user.
|
|
1786
1814
|
*
|
|
@@ -1862,17 +1890,10 @@ interface OrganizationOperations {
|
|
|
1862
1890
|
/**
|
|
1863
1891
|
* Creates a new organization.
|
|
1864
1892
|
*
|
|
1865
|
-
* @param params - Organization parameters
|
|
1866
|
-
* @param params.name - Organization name
|
|
1867
|
-
* @param params.description - Optional description
|
|
1868
|
-
* @param params.handle - Optional custom handle
|
|
1893
|
+
* @param params - Organization creation parameters
|
|
1869
1894
|
* @returns Promise resolving to organization info
|
|
1870
1895
|
*/
|
|
1871
|
-
create(params:
|
|
1872
|
-
name: string;
|
|
1873
|
-
description?: string;
|
|
1874
|
-
handle?: string;
|
|
1875
|
-
}): Promise<OrganizationInfo>;
|
|
1896
|
+
create(params: CreateOrganizationParams): Promise<OrganizationInfo>;
|
|
1876
1897
|
/**
|
|
1877
1898
|
* Gets an organization by DID.
|
|
1878
1899
|
*
|
package/dist/index.mjs
CHANGED
|
@@ -3152,8 +3152,8 @@ class HypercertOperationsImpl extends EventEmitter {
|
|
|
3152
3152
|
shortDescription: params.shortDescription,
|
|
3153
3153
|
description: params.description,
|
|
3154
3154
|
workScope: params.workScope,
|
|
3155
|
-
|
|
3156
|
-
|
|
3155
|
+
startDate: params.startDate,
|
|
3156
|
+
endDate: params.endDate,
|
|
3157
3157
|
rights: { uri: rightsUri, cid: rightsCid },
|
|
3158
3158
|
createdAt,
|
|
3159
3159
|
};
|
|
@@ -3163,7 +3163,7 @@ class HypercertOperationsImpl extends EventEmitter {
|
|
|
3163
3163
|
if (params.evidence && params.evidence.length > 0) {
|
|
3164
3164
|
hypercertRecord.evidence = params.evidence;
|
|
3165
3165
|
}
|
|
3166
|
-
const hypercertValidation = validate(hypercertRecord, HYPERCERT_COLLECTIONS.CLAIM, "
|
|
3166
|
+
const hypercertValidation = validate(hypercertRecord, HYPERCERT_COLLECTIONS.CLAIM, "main", false);
|
|
3167
3167
|
if (!hypercertValidation.success) {
|
|
3168
3168
|
throw new ValidationError(`Invalid hypercert record: ${hypercertValidation.error?.message}`);
|
|
3169
3169
|
}
|
|
@@ -3499,11 +3499,6 @@ class HypercertOperationsImpl extends EventEmitter {
|
|
|
3499
3499
|
if (!result.success) {
|
|
3500
3500
|
throw new NetworkError("Failed to get hypercert");
|
|
3501
3501
|
}
|
|
3502
|
-
// Validate with lexicon (more lenient - doesn't require $type)
|
|
3503
|
-
const validation = validate(result.data.value, HYPERCERT_COLLECTIONS.CLAIM, "main", false);
|
|
3504
|
-
if (!validation.success) {
|
|
3505
|
-
throw new ValidationError(`Invalid hypercert record format: ${validation.error?.message}`);
|
|
3506
|
-
}
|
|
3507
3502
|
return {
|
|
3508
3503
|
uri: result.data.uri,
|
|
3509
3504
|
cid: result.data.cid ?? "",
|
|
@@ -3669,7 +3664,7 @@ class HypercertOperationsImpl extends EventEmitter {
|
|
|
3669
3664
|
else {
|
|
3670
3665
|
// Use value as a URI reference
|
|
3671
3666
|
locationData = {
|
|
3672
|
-
$type: "
|
|
3667
|
+
$type: "org.hypercerts.defs#uri",
|
|
3673
3668
|
uri: location.value,
|
|
3674
3669
|
};
|
|
3675
3670
|
locationType = "coordinate-decimal";
|
|
@@ -4030,7 +4025,7 @@ class HypercertOperationsImpl extends EventEmitter {
|
|
|
4030
4025
|
throw new NetworkError("Failed to get collection");
|
|
4031
4026
|
}
|
|
4032
4027
|
// Validate with lexicon registry (more lenient - doesn't require $type)
|
|
4033
|
-
const validation = validate(result.data.value, HYPERCERT_COLLECTIONS.COLLECTION, "
|
|
4028
|
+
const validation = validate(result.data.value, HYPERCERT_COLLECTIONS.COLLECTION, "main", false);
|
|
4034
4029
|
if (!validation.success) {
|
|
4035
4030
|
throw new ValidationError(`Invalid collection record format: ${validation.error?.message}`);
|
|
4036
4031
|
}
|
|
@@ -4599,6 +4594,12 @@ class OrganizationOperationsImpl {
|
|
|
4599
4594
|
if (!userDid) {
|
|
4600
4595
|
throw new NetworkError("No authenticated user found");
|
|
4601
4596
|
}
|
|
4597
|
+
if (!params.handlePrefix) {
|
|
4598
|
+
throw new ValidationError("Missing handlePrefix");
|
|
4599
|
+
}
|
|
4600
|
+
if (!params.name) {
|
|
4601
|
+
throw new ValidationError("Missing name");
|
|
4602
|
+
}
|
|
4602
4603
|
const response = await this.session.fetchHandler(`${this.serverUrl}/xrpc/com.sds.organization.create`, {
|
|
4603
4604
|
method: "POST",
|
|
4604
4605
|
headers: { "Content-Type": "application/json" },
|