@medialane/sdk 0.137.0 → 0.138.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 CHANGED
@@ -280,11 +280,12 @@ token.balances?.forEach((b: ApiTokenBalance) => {
280
280
 
281
281
  ```typescript
282
282
  // All collections: newest first by default
283
- const collections = await client.api.getCollections();
283
+ const collections = await client.api.listCollections();
284
284
 
285
- // With sort and pagination
286
- const byVolume = await client.api.getCollections(1, 20, undefined, "volume");
287
- const verified = await client.api.getCollections(1, 18, true, "recent");
285
+ // Filter, sort and paginate in one query
286
+ const byVolume = await client.api.listCollections({ page: 1, limit: 20, sort: "volume" });
287
+ const featured = await client.api.listCollections({ limit: 18, isFeatured: true, sort: "recent" });
288
+ const myDrops = await client.api.listCollections({ owner: "0x...", service: "drop-collection" });
288
289
 
289
290
  // Sort options: "recent" | "supply" | "floor" | "volume" | "name"
290
291
  const collection = await client.api.getCollection(contract);
@@ -1238,6 +1238,7 @@ interface ApiCollectionsListQuery {
1238
1238
  sort?: CollectionSort;
1239
1239
  isFeatured?: boolean;
1240
1240
  hideEmpty?: boolean;
1241
+ standard?: string;
1241
1242
  chain?: ChainFilter;
1242
1243
  }
1243
1244
  interface ApiPricingRule {
@@ -1296,8 +1297,6 @@ declare class ApiClient {
1296
1297
  getToken(contract: string, tokenId: string, wait?: boolean): Promise<ApiResponse<ApiToken>>;
1297
1298
  getTokensByOwner(address: string, page?: number, limit?: number): Promise<ApiResponse<ApiToken[]>>;
1298
1299
  getTokenHistory(contract: string, tokenId: string, page?: number, limit?: number): Promise<ApiResponse<ApiActivity[]>>;
1299
- getCollections(page?: number, limit?: number, isKnown?: boolean, sort?: CollectionSort, service?: string, chain?: ChainFilter, standard?: string): Promise<ApiResponse<ApiCollection[]>>;
1300
- getCollectionsByOwner(owner: string, page?: number, limit?: number): Promise<ApiResponse<ApiCollection[]>>;
1301
1300
  getCollection(contract: string): Promise<ApiResponse<ApiCollection>>;
1302
1301
  getCollectionTokens(contract: string, page?: number, limit?: number, sort?: CollectionTokensSort): Promise<ApiResponse<ApiToken[]>>;
1303
1302
  getActivities(query?: ApiActivitiesQuery): Promise<ApiResponse<ApiActivity[]>>;
@@ -1491,11 +1490,6 @@ declare class ApiClient {
1491
1490
  confirmRemixOffer(id: string, params: ConfirmRemixOfferParams, siwsToken: string): Promise<ApiResponse<ApiRemixOffer>>;
1492
1491
  rejectRemixOffer(id: string, siwsToken: string): Promise<ApiResponse<ApiRemixOffer>>;
1493
1492
  extendRemixOffer(id: string, days: number, siwsToken: string): Promise<ApiResponse<ApiRemixOffer>>;
1494
- getPopCollections(opts?: {
1495
- page?: number;
1496
- limit?: number;
1497
- sort?: CollectionSort;
1498
- }): Promise<ApiResponse<ApiCollection[]>>;
1499
1493
  getPopEligibility(collection: string, wallet: string): Promise<PopClaimStatus>;
1500
1494
  getPopEligibilityBatch(collection: string, wallets: string[]): Promise<PopBatchEligibilityItem[]>;
1501
1495
  getCoins(opts?: ApiCoinsQuery): Promise<ApiResponse<ApiCoin[]>>;
@@ -1509,16 +1503,12 @@ declare class ApiClient {
1509
1503
  image?: string | null;
1510
1504
  description?: string | null;
1511
1505
  }, siwsToken: string): Promise<ApiResponse<ApiCoin>>;
1512
- getDropCollections(opts?: {
1513
- page?: number;
1514
- limit?: number;
1515
- sort?: CollectionSort;
1516
- }): Promise<ApiResponse<ApiCollection[]>>;
1517
1506
  getDropMintStatus(collection: string, wallet: string): Promise<DropMintStatus>;
1518
1507
  getDropInfo(contract: string): Promise<ApiDropInfo | null>;
1519
1508
  getDropState(contract: string): Promise<ApiDropState>;
1520
1509
  getTicket(contract: string, tokenId: string): Promise<ApiTierOnchain>;
1521
1510
  getTicketCount(contract: string): Promise<number>;
1511
+ getClubMembershipCount(contract: string): Promise<number>;
1522
1512
  getClubMembership(contract: string, tokenId: string): Promise<ApiTierOnchain>;
1523
1513
  isClubMember(contract: string, tokenId: string, wallet: string): Promise<boolean>;
1524
1514
  getIpNftTokenData(contract: string, tokenId: string): Promise<ApiIpNftTokenData | null>;
@@ -1238,6 +1238,7 @@ interface ApiCollectionsListQuery {
1238
1238
  sort?: CollectionSort;
1239
1239
  isFeatured?: boolean;
1240
1240
  hideEmpty?: boolean;
1241
+ standard?: string;
1241
1242
  chain?: ChainFilter;
1242
1243
  }
1243
1244
  interface ApiPricingRule {
@@ -1296,8 +1297,6 @@ declare class ApiClient {
1296
1297
  getToken(contract: string, tokenId: string, wait?: boolean): Promise<ApiResponse<ApiToken>>;
1297
1298
  getTokensByOwner(address: string, page?: number, limit?: number): Promise<ApiResponse<ApiToken[]>>;
1298
1299
  getTokenHistory(contract: string, tokenId: string, page?: number, limit?: number): Promise<ApiResponse<ApiActivity[]>>;
1299
- getCollections(page?: number, limit?: number, isKnown?: boolean, sort?: CollectionSort, service?: string, chain?: ChainFilter, standard?: string): Promise<ApiResponse<ApiCollection[]>>;
1300
- getCollectionsByOwner(owner: string, page?: number, limit?: number): Promise<ApiResponse<ApiCollection[]>>;
1301
1300
  getCollection(contract: string): Promise<ApiResponse<ApiCollection>>;
1302
1301
  getCollectionTokens(contract: string, page?: number, limit?: number, sort?: CollectionTokensSort): Promise<ApiResponse<ApiToken[]>>;
1303
1302
  getActivities(query?: ApiActivitiesQuery): Promise<ApiResponse<ApiActivity[]>>;
@@ -1491,11 +1490,6 @@ declare class ApiClient {
1491
1490
  confirmRemixOffer(id: string, params: ConfirmRemixOfferParams, siwsToken: string): Promise<ApiResponse<ApiRemixOffer>>;
1492
1491
  rejectRemixOffer(id: string, siwsToken: string): Promise<ApiResponse<ApiRemixOffer>>;
1493
1492
  extendRemixOffer(id: string, days: number, siwsToken: string): Promise<ApiResponse<ApiRemixOffer>>;
1494
- getPopCollections(opts?: {
1495
- page?: number;
1496
- limit?: number;
1497
- sort?: CollectionSort;
1498
- }): Promise<ApiResponse<ApiCollection[]>>;
1499
1493
  getPopEligibility(collection: string, wallet: string): Promise<PopClaimStatus>;
1500
1494
  getPopEligibilityBatch(collection: string, wallets: string[]): Promise<PopBatchEligibilityItem[]>;
1501
1495
  getCoins(opts?: ApiCoinsQuery): Promise<ApiResponse<ApiCoin[]>>;
@@ -1509,16 +1503,12 @@ declare class ApiClient {
1509
1503
  image?: string | null;
1510
1504
  description?: string | null;
1511
1505
  }, siwsToken: string): Promise<ApiResponse<ApiCoin>>;
1512
- getDropCollections(opts?: {
1513
- page?: number;
1514
- limit?: number;
1515
- sort?: CollectionSort;
1516
- }): Promise<ApiResponse<ApiCollection[]>>;
1517
1506
  getDropMintStatus(collection: string, wallet: string): Promise<DropMintStatus>;
1518
1507
  getDropInfo(contract: string): Promise<ApiDropInfo | null>;
1519
1508
  getDropState(contract: string): Promise<ApiDropState>;
1520
1509
  getTicket(contract: string, tokenId: string): Promise<ApiTierOnchain>;
1521
1510
  getTicketCount(contract: string): Promise<number>;
1511
+ getClubMembershipCount(contract: string): Promise<number>;
1522
1512
  getClubMembership(contract: string, tokenId: string): Promise<ApiTierOnchain>;
1523
1513
  isClubMember(contract: string, tokenId: string, wallet: string): Promise<boolean>;
1524
1514
  getIpNftTokenData(contract: string, tokenId: string): Promise<ApiIpNftTokenData | null>;
package/dist/index.cjs CHANGED
@@ -239,7 +239,13 @@ var DEFAULT_MAX_DELAY_MS = 5e3;
239
239
  function sleep(ms) {
240
240
  return new Promise((resolve) => setTimeout(resolve, ms));
241
241
  }
242
- async function withRetry(fn, opts) {
242
+ function isRetryableFor(method, err) {
243
+ if (err instanceof MedialaneApiError && err.status === 429) return true;
244
+ const isRead = method === "GET" || method === "HEAD";
245
+ if (!isRead) return false;
246
+ return err instanceof MedialaneApiError && err.status >= 500 || err instanceof TypeError;
247
+ }
248
+ async function withRetry(fn, opts, method = "GET") {
243
249
  const maxAttempts = opts?.maxAttempts ?? DEFAULT_MAX_ATTEMPTS;
244
250
  const baseDelayMs = opts?.baseDelayMs ?? DEFAULT_BASE_DELAY_MS;
245
251
  const maxDelayMs = opts?.maxDelayMs ?? DEFAULT_MAX_DELAY_MS;
@@ -249,11 +255,7 @@ async function withRetry(fn, opts) {
249
255
  return await fn();
250
256
  } catch (err) {
251
257
  lastError = err;
252
- if (err instanceof MedialaneApiError && err.status < 500 && err.status !== 429) {
253
- throw err;
254
- }
255
- const isRetryable = err instanceof MedialaneApiError && (err.status >= 500 || err.status === 429) || err instanceof TypeError;
256
- if (!isRetryable || attempt === maxAttempts - 1) {
258
+ if (!isRetryableFor(method, err) || attempt === maxAttempts - 1) {
257
259
  throw err;
258
260
  }
259
261
  const retryAfterMs = err instanceof MedialaneApiError ? err.retryAfterMs : void 0;
@@ -334,7 +336,7 @@ var ApiClient = class {
334
336
  );
335
337
  }
336
338
  return response;
337
- }, this.retryOptions);
339
+ }, this.retryOptions, (init?.method ?? "GET").toUpperCase());
338
340
  if (allowed(res.status)) return null;
339
341
  return res.json();
340
342
  }
@@ -402,19 +404,6 @@ var ApiClient = class {
402
404
  `/v1/tokens/${contract}/${tokenId}/history?page=${page}&limit=${limit}`
403
405
  );
404
406
  }
405
- getCollections(page = 1, limit = 20, isKnown, sort, service, chain, standard) {
406
- const params = new URLSearchParams({ page: String(page), limit: String(limit) });
407
- if (isKnown !== void 0) params.set("isKnown", String(isKnown));
408
- if (sort) params.set("sort", sort);
409
- if (service) params.set("service", service);
410
- if (chain) params.set("chain", chain);
411
- if (standard) params.set("standard", standard);
412
- return this.get(`/v1/collections?${params}`);
413
- }
414
- getCollectionsByOwner(owner, page = 1, limit = 50) {
415
- const params = new URLSearchParams({ owner: this.addr(owner), page: String(page), limit: String(limit) });
416
- return this.get(`/v1/collections?${params}`);
417
- }
418
407
  getCollection(contract) {
419
408
  return this.get(`/v1/collections/${this.addr(contract)}`);
420
409
  }
@@ -886,9 +875,6 @@ var ApiClient = class {
886
875
  headers: { "Authorization": `Bearer ${siwsToken}` }
887
876
  });
888
877
  }
889
- getPopCollections(opts = {}) {
890
- return this.getCollections(opts.page ?? 1, opts.limit ?? 20, void 0, opts.sort, "pop-protocol");
891
- }
892
878
  async getPopEligibility(collection, wallet) {
893
879
  const res = await this.get(
894
880
  `/v1/pop/eligibility/${this.addr(collection)}/${this.addr(wallet)}`
@@ -938,9 +924,6 @@ var ApiClient = class {
938
924
  headers: this.bearer(siwsToken)
939
925
  });
940
926
  }
941
- getDropCollections(opts = {}) {
942
- return this.getCollections(opts.page ?? 1, opts.limit ?? 20, void 0, opts.sort, "drop-collection");
943
- }
944
927
  async getDropMintStatus(collection, wallet) {
945
928
  const res = await this.get(
946
929
  `/v1/drop/mint-status/${this.addr(collection)}/${this.addr(wallet)}`
@@ -967,6 +950,10 @@ var ApiClient = class {
967
950
  const res = await this.get(`/v1/tickets/${this.addr(contract)}/count`);
968
951
  return res.data.count;
969
952
  }
953
+ async getClubMembershipCount(contract) {
954
+ const res = await this.get(`/v1/club/${this.addr(contract)}/count`);
955
+ return res.data.count;
956
+ }
970
957
  async getClubMembership(contract, tokenId) {
971
958
  const res = await this.get(`/v1/club/${this.addr(contract)}/${tokenId}`);
972
959
  return res.data;
@@ -1050,6 +1037,7 @@ var ApiClient = class {
1050
1037
  if (query.sort) params.set("sort", query.sort);
1051
1038
  if (query.isFeatured !== void 0) params.set("isFeatured", String(query.isFeatured));
1052
1039
  if (query.hideEmpty !== void 0) params.set("hideEmpty", String(query.hideEmpty));
1040
+ if (query.standard) params.set("standard", query.standard);
1053
1041
  if (query.chain) params.set("chain", query.chain);
1054
1042
  const qs = params.toString();
1055
1043
  return this.get(`/v1/collections${qs ? `?${qs}` : ""}`);