@medialane/sdk 0.9.2 → 0.10.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 +62 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +31 -1
- package/dist/index.d.ts +31 -1
- package/dist/index.js +62 -17
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2663,6 +2663,21 @@ var ApiClient = class {
|
|
|
2663
2663
|
del(path) {
|
|
2664
2664
|
return this.request(path, { method: "DELETE" });
|
|
2665
2665
|
}
|
|
2666
|
+
async checkResponse(res, options) {
|
|
2667
|
+
if (options?.allow404 && res.status === 404) return null;
|
|
2668
|
+
if (options?.allow403 && res.status === 403) return null;
|
|
2669
|
+
if (!res.ok) {
|
|
2670
|
+
const text = await res.text().catch(() => res.statusText);
|
|
2671
|
+
let message = text;
|
|
2672
|
+
try {
|
|
2673
|
+
const body = JSON.parse(text);
|
|
2674
|
+
if (body.error) message = body.error;
|
|
2675
|
+
} catch {
|
|
2676
|
+
}
|
|
2677
|
+
throw new MedialaneApiError(res.status, message);
|
|
2678
|
+
}
|
|
2679
|
+
return res.json();
|
|
2680
|
+
}
|
|
2666
2681
|
// ─── Orders ────────────────────────────────────────────────────────────────
|
|
2667
2682
|
getOrders(query = {}) {
|
|
2668
2683
|
const params = new URLSearchParams();
|
|
@@ -2871,7 +2886,7 @@ var ApiClient = class {
|
|
|
2871
2886
|
},
|
|
2872
2887
|
body: JSON.stringify({ contractAddress, walletAddress })
|
|
2873
2888
|
});
|
|
2874
|
-
return
|
|
2889
|
+
return this.checkResponse(res);
|
|
2875
2890
|
}
|
|
2876
2891
|
/**
|
|
2877
2892
|
* Path 3: Manual off-chain claim request (email-based).
|
|
@@ -2886,8 +2901,7 @@ var ApiClient = class {
|
|
|
2886
2901
|
async getCollectionProfile(contractAddress) {
|
|
2887
2902
|
const url = `${this.baseUrl.replace(/\/$/, "")}/v1/collections/${normalizeAddress(contractAddress)}/profile`;
|
|
2888
2903
|
const res = await fetch(url, { headers: this.baseHeaders });
|
|
2889
|
-
|
|
2890
|
-
return res.json();
|
|
2904
|
+
return this.checkResponse(res, { allow404: true });
|
|
2891
2905
|
}
|
|
2892
2906
|
/**
|
|
2893
2907
|
* Update collection profile. Requires Clerk JWT for ownership check.
|
|
@@ -2903,15 +2917,14 @@ var ApiClient = class {
|
|
|
2903
2917
|
},
|
|
2904
2918
|
body: JSON.stringify(data)
|
|
2905
2919
|
});
|
|
2906
|
-
return
|
|
2920
|
+
return this.checkResponse(res);
|
|
2907
2921
|
}
|
|
2908
2922
|
async getGatedContent(contractAddress, clerkToken) {
|
|
2909
2923
|
const url = `${this.baseUrl.replace(/\/$/, "")}/v1/collections/${normalizeAddress(contractAddress)}/gated-content`;
|
|
2910
2924
|
const res = await fetch(url, {
|
|
2911
2925
|
headers: { ...this.baseHeaders, "Authorization": `Bearer ${clerkToken}` }
|
|
2912
2926
|
});
|
|
2913
|
-
|
|
2914
|
-
return res.json();
|
|
2927
|
+
return this.checkResponse(res, { allow404: true, allow403: true });
|
|
2915
2928
|
}
|
|
2916
2929
|
// ─── Creator Profiles ───────────────────────────────────────────────────────
|
|
2917
2930
|
/** List all creators with an approved username. */
|
|
@@ -2922,20 +2935,18 @@ var ApiClient = class {
|
|
|
2922
2935
|
if (opts.limit) params.set("limit", String(opts.limit));
|
|
2923
2936
|
const url = `${this.baseUrl.replace(/\/$/, "")}/v1/creators?${params}`;
|
|
2924
2937
|
const res = await fetch(url, { headers: this.baseHeaders });
|
|
2925
|
-
return
|
|
2938
|
+
return this.checkResponse(res);
|
|
2926
2939
|
}
|
|
2927
2940
|
async getCreatorProfile(walletAddress) {
|
|
2928
2941
|
const url = `${this.baseUrl.replace(/\/$/, "")}/v1/creators/${normalizeAddress(walletAddress)}/profile`;
|
|
2929
2942
|
const res = await fetch(url, { headers: this.baseHeaders });
|
|
2930
|
-
|
|
2931
|
-
return res.json();
|
|
2943
|
+
return this.checkResponse(res, { allow404: true });
|
|
2932
2944
|
}
|
|
2933
2945
|
/** Resolve a username slug to a creator profile (public). */
|
|
2934
2946
|
async getCreatorByUsername(username) {
|
|
2935
2947
|
const url = `${this.baseUrl.replace(/\/$/, "")}/v1/creators/by-username/${encodeURIComponent(username.toLowerCase().trim())}`;
|
|
2936
2948
|
const res = await fetch(url, { headers: this.baseHeaders });
|
|
2937
|
-
|
|
2938
|
-
return res.json();
|
|
2949
|
+
return this.checkResponse(res, { allow404: true });
|
|
2939
2950
|
}
|
|
2940
2951
|
/**
|
|
2941
2952
|
* Update creator profile. Requires Clerk JWT; wallet must match authenticated user.
|
|
@@ -2951,7 +2962,42 @@ var ApiClient = class {
|
|
|
2951
2962
|
},
|
|
2952
2963
|
body: JSON.stringify(data)
|
|
2953
2964
|
});
|
|
2954
|
-
return
|
|
2965
|
+
return this.checkResponse(res);
|
|
2966
|
+
}
|
|
2967
|
+
// ─── Collection Slug Claims ───────────────────────────────────────────────────
|
|
2968
|
+
/** Check if a collection slug is available (public, no auth). */
|
|
2969
|
+
async checkCollectionSlugAvailability(slug) {
|
|
2970
|
+
const url = `${this.baseUrl.replace(/\/$/, "")}/v1/collection-slug-claims/check/${encodeURIComponent(slug.toLowerCase().trim())}`;
|
|
2971
|
+
const res = await fetch(url, { headers: this.baseHeaders });
|
|
2972
|
+
return this.checkResponse(res);
|
|
2973
|
+
}
|
|
2974
|
+
/** Submit a slug claim for a collection. Requires Clerk JWT — caller must be the collection owner. */
|
|
2975
|
+
async submitCollectionSlugClaim(contractAddress, slug, clerkToken, notifyEmail) {
|
|
2976
|
+
const url = `${this.baseUrl.replace(/\/$/, "")}/v1/collection-slug-claims`;
|
|
2977
|
+
const res = await fetch(url, {
|
|
2978
|
+
method: "POST",
|
|
2979
|
+
headers: {
|
|
2980
|
+
"x-api-key": this.baseHeaders["x-api-key"] ?? "",
|
|
2981
|
+
"Content-Type": "application/json",
|
|
2982
|
+
Authorization: `Bearer ${clerkToken}`
|
|
2983
|
+
},
|
|
2984
|
+
body: JSON.stringify({ contractAddress, slug, notifyEmail })
|
|
2985
|
+
});
|
|
2986
|
+
return this.checkResponse(res);
|
|
2987
|
+
}
|
|
2988
|
+
/** Returns all slug claims submitted by the authenticated wallet. Requires Clerk JWT. */
|
|
2989
|
+
async getMyCollectionSlugClaims(clerkToken) {
|
|
2990
|
+
const url = `${this.baseUrl.replace(/\/$/, "")}/v1/collection-slug-claims/me`;
|
|
2991
|
+
const res = await fetch(url, {
|
|
2992
|
+
headers: { ...this.baseHeaders, Authorization: `Bearer ${clerkToken}` }
|
|
2993
|
+
});
|
|
2994
|
+
return this.checkResponse(res);
|
|
2995
|
+
}
|
|
2996
|
+
/** Resolve a collection slug to a full collection. Returns null if not found. */
|
|
2997
|
+
async getCollectionBySlug(slug) {
|
|
2998
|
+
const url = `${this.baseUrl.replace(/\/$/, "")}/v1/collections/by-slug/${encodeURIComponent(slug.toLowerCase().trim())}`;
|
|
2999
|
+
const res = await fetch(url, { headers: this.baseHeaders });
|
|
3000
|
+
return this.checkResponse(res, { allow404: true });
|
|
2955
3001
|
}
|
|
2956
3002
|
// ─── User Wallet ─────────────────────────────────────────────────────────────
|
|
2957
3003
|
/**
|
|
@@ -2968,7 +3014,7 @@ var ApiClient = class {
|
|
|
2968
3014
|
"Authorization": `Bearer ${clerkToken}`
|
|
2969
3015
|
}
|
|
2970
3016
|
});
|
|
2971
|
-
return
|
|
3017
|
+
return this.checkResponse(res);
|
|
2972
3018
|
}
|
|
2973
3019
|
/**
|
|
2974
3020
|
* Get the authenticated user's stored wallet address from the backend DB.
|
|
@@ -2980,8 +3026,7 @@ var ApiClient = class {
|
|
|
2980
3026
|
const res = await fetch(url, {
|
|
2981
3027
|
headers: { "Authorization": `Bearer ${clerkToken}` }
|
|
2982
3028
|
});
|
|
2983
|
-
|
|
2984
|
-
return res.json();
|
|
3029
|
+
return this.checkResponse(res, { allow404: true });
|
|
2985
3030
|
}
|
|
2986
3031
|
// ─── Remix Licensing ─────────────────────────────────────────────────────────
|
|
2987
3032
|
/**
|
|
@@ -3039,7 +3084,7 @@ var ApiClient = class {
|
|
|
3039
3084
|
const res = await fetch(url, {
|
|
3040
3085
|
headers: { ...this.baseHeaders, "Authorization": `Bearer ${clerkToken}` }
|
|
3041
3086
|
});
|
|
3042
|
-
return
|
|
3087
|
+
return this.checkResponse(res);
|
|
3043
3088
|
}
|
|
3044
3089
|
/**
|
|
3045
3090
|
* Get a single remix offer. Clerk JWT optional (price/currency hidden for non-participants).
|
|
@@ -3049,7 +3094,7 @@ var ApiClient = class {
|
|
|
3049
3094
|
const headers = { ...this.baseHeaders };
|
|
3050
3095
|
if (clerkToken) headers["Authorization"] = `Bearer ${clerkToken}`;
|
|
3051
3096
|
const res = await fetch(url, { headers });
|
|
3052
|
-
return
|
|
3097
|
+
return this.checkResponse(res);
|
|
3053
3098
|
}
|
|
3054
3099
|
/**
|
|
3055
3100
|
* Creator approves a remix offer (authorises the requester to mint). Requires Clerk JWT.
|