@hypercerts-org/sdk-core 0.7.0-beta.0 → 0.8.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/dist/index.cjs +37 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +8 -3
- package/dist/index.mjs +37 -7
- package/dist/index.mjs.map +1 -1
- package/dist/types.d.ts +8 -3
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -2270,6 +2270,7 @@ class HypercertOperationsImpl extends eventemitter3.EventEmitter {
|
|
|
2270
2270
|
// Step 2: Create rights record
|
|
2271
2271
|
this.emitProgress(params.onProgress, { name: "createRights", status: "start" });
|
|
2272
2272
|
const rightsRecord = {
|
|
2273
|
+
$type: lexicon.HYPERCERT_COLLECTIONS.RIGHTS,
|
|
2273
2274
|
rightsName: params.rights.name,
|
|
2274
2275
|
rightsType: params.rights.type,
|
|
2275
2276
|
rightsDescription: params.rights.description,
|
|
@@ -2298,6 +2299,7 @@ class HypercertOperationsImpl extends eventemitter3.EventEmitter {
|
|
|
2298
2299
|
// Step 3: Create hypercert record
|
|
2299
2300
|
this.emitProgress(params.onProgress, { name: "createHypercert", status: "start" });
|
|
2300
2301
|
const hypercertRecord = {
|
|
2302
|
+
$type: lexicon.HYPERCERT_COLLECTIONS.CLAIM,
|
|
2301
2303
|
title: params.title,
|
|
2302
2304
|
description: params.description,
|
|
2303
2305
|
workScope: params.workScope,
|
|
@@ -2645,6 +2647,7 @@ class HypercertOperationsImpl extends eventemitter3.EventEmitter {
|
|
|
2645
2647
|
* await repo.hypercerts.attachLocation(hypercertUri, {
|
|
2646
2648
|
* value: "San Francisco, CA",
|
|
2647
2649
|
* name: "SF Bay Area",
|
|
2650
|
+
* srs: "EPSG:4326",
|
|
2648
2651
|
* });
|
|
2649
2652
|
* ```
|
|
2650
2653
|
*
|
|
@@ -2663,32 +2666,54 @@ class HypercertOperationsImpl extends eventemitter3.EventEmitter {
|
|
|
2663
2666
|
*/
|
|
2664
2667
|
async attachLocation(hypercertUri, location) {
|
|
2665
2668
|
try {
|
|
2666
|
-
//
|
|
2667
|
-
|
|
2669
|
+
// Validate required srs field
|
|
2670
|
+
if (!location.srs) {
|
|
2671
|
+
throw new ValidationError("srs (Spatial Reference System) is required. Example: 'EPSG:4326' for WGS84 coordinates, or 'http://www.opengis.net/def/crs/OGC/1.3/CRS84' for CRS84.");
|
|
2672
|
+
}
|
|
2673
|
+
// Validate that hypercert exists (unused but confirms hypercert is valid)
|
|
2674
|
+
await this.get(hypercertUri);
|
|
2668
2675
|
const createdAt = new Date().toISOString();
|
|
2669
|
-
|
|
2676
|
+
// Determine location type and prepare location data
|
|
2677
|
+
let locationData;
|
|
2678
|
+
let locationType;
|
|
2670
2679
|
if (location.geojson) {
|
|
2680
|
+
// Upload GeoJSON as a blob
|
|
2671
2681
|
const arrayBuffer = await location.geojson.arrayBuffer();
|
|
2672
2682
|
const uint8Array = new Uint8Array(arrayBuffer);
|
|
2673
2683
|
const uploadResult = await this.agent.com.atproto.repo.uploadBlob(uint8Array, {
|
|
2674
2684
|
encoding: location.geojson.type || "application/geo+json",
|
|
2675
2685
|
});
|
|
2676
2686
|
if (uploadResult.success) {
|
|
2677
|
-
|
|
2687
|
+
locationData = {
|
|
2678
2688
|
$type: "blob",
|
|
2679
2689
|
ref: { $link: uploadResult.data.blob.ref.toString() },
|
|
2680
2690
|
mimeType: uploadResult.data.blob.mimeType,
|
|
2681
2691
|
size: uploadResult.data.blob.size,
|
|
2682
2692
|
};
|
|
2693
|
+
locationType = "geojson-point";
|
|
2694
|
+
}
|
|
2695
|
+
else {
|
|
2696
|
+
throw new NetworkError("Failed to upload GeoJSON blob");
|
|
2683
2697
|
}
|
|
2684
2698
|
}
|
|
2699
|
+
else {
|
|
2700
|
+
// Use value as a URI reference
|
|
2701
|
+
locationData = {
|
|
2702
|
+
$type: "app.certified.defs#uri",
|
|
2703
|
+
uri: location.value,
|
|
2704
|
+
};
|
|
2705
|
+
locationType = "coordinate-decimal";
|
|
2706
|
+
}
|
|
2707
|
+
// Build location record according to app.certified.location lexicon
|
|
2685
2708
|
const locationRecord = {
|
|
2686
|
-
|
|
2687
|
-
|
|
2709
|
+
$type: lexicon.HYPERCERT_COLLECTIONS.LOCATION,
|
|
2710
|
+
lpVersion: "1.0",
|
|
2711
|
+
srs: location.srs,
|
|
2712
|
+
locationType,
|
|
2713
|
+
location: locationData,
|
|
2688
2714
|
createdAt,
|
|
2689
2715
|
name: location.name,
|
|
2690
2716
|
description: location.description,
|
|
2691
|
-
srs: location.srs,
|
|
2692
2717
|
};
|
|
2693
2718
|
const validation = this.lexiconRegistry.validate(lexicon.HYPERCERT_COLLECTIONS.LOCATION, locationRecord);
|
|
2694
2719
|
if (!validation.valid) {
|
|
@@ -2775,10 +2800,12 @@ class HypercertOperationsImpl extends eventemitter3.EventEmitter {
|
|
|
2775
2800
|
try {
|
|
2776
2801
|
const createdAt = new Date().toISOString();
|
|
2777
2802
|
const contributionRecord = {
|
|
2803
|
+
$type: lexicon.HYPERCERT_COLLECTIONS.CONTRIBUTION,
|
|
2778
2804
|
contributors: params.contributors,
|
|
2779
2805
|
role: params.role,
|
|
2780
2806
|
createdAt,
|
|
2781
2807
|
description: params.description,
|
|
2808
|
+
hypercert: { uri: "", cid: "" }, // Will be set below if hypercertUri provided
|
|
2782
2809
|
};
|
|
2783
2810
|
if (params.hypercertUri) {
|
|
2784
2811
|
const hypercert = await this.get(params.hypercertUri);
|
|
@@ -2839,6 +2866,7 @@ class HypercertOperationsImpl extends eventemitter3.EventEmitter {
|
|
|
2839
2866
|
const hypercert = await this.get(params.hypercertUri);
|
|
2840
2867
|
const createdAt = new Date().toISOString();
|
|
2841
2868
|
const measurementRecord = {
|
|
2869
|
+
$type: lexicon.HYPERCERT_COLLECTIONS.MEASUREMENT,
|
|
2842
2870
|
hypercert: { uri: hypercert.uri, cid: hypercert.cid },
|
|
2843
2871
|
measurers: params.measurers,
|
|
2844
2872
|
metric: params.metric,
|
|
@@ -2894,6 +2922,7 @@ class HypercertOperationsImpl extends eventemitter3.EventEmitter {
|
|
|
2894
2922
|
const subject = await this.get(params.subjectUri);
|
|
2895
2923
|
const createdAt = new Date().toISOString();
|
|
2896
2924
|
const evaluationRecord = {
|
|
2925
|
+
$type: lexicon.HYPERCERT_COLLECTIONS.EVALUATION,
|
|
2897
2926
|
subject: { uri: subject.uri, cid: subject.cid },
|
|
2898
2927
|
evaluators: params.evaluators,
|
|
2899
2928
|
summary: params.summary,
|
|
@@ -2968,6 +2997,7 @@ class HypercertOperationsImpl extends eventemitter3.EventEmitter {
|
|
|
2968
2997
|
}
|
|
2969
2998
|
}
|
|
2970
2999
|
const collectionRecord = {
|
|
3000
|
+
$type: lexicon.HYPERCERT_COLLECTIONS.COLLECTION,
|
|
2971
3001
|
title: params.title,
|
|
2972
3002
|
claims: params.claims.map((c) => ({ claim: { uri: c.uri, cid: c.cid }, weight: c.weight })),
|
|
2973
3003
|
createdAt,
|