From 58cf7d0fb9e842ae514be70561a59d42dab37b82 Mon Sep 17 00:00:00 2001 From: Steve Date: Wed, 11 Sep 2024 12:05:36 -0400 Subject: [PATCH] feat: Added new query methods to listing files --- src/core/files/list.ts | 8 +++++++- src/core/pinataSDK.ts | 25 +++++++++++++++++++++++++ src/core/types.ts | 7 ++++++- 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/src/core/files/list.ts b/src/core/files/list.ts index 2dcc2d7..9f152d0 100644 --- a/src/core/files/list.ts +++ b/src/core/files/list.ts @@ -82,9 +82,15 @@ export const listFiles = async ( const params = new URLSearchParams(); if (options) { - const { limit, pageToken, cidPending } = options; + const { name, group, cid, order, limit, mimeType, pageToken, cidPending } = + options; if (limit) params.append("limit", limit.toString()); + if (name) params.append("name", name); + if (group) params.append("group", group); + if (cid) params.append("cid", cid); + if (mimeType) params.append("mimeType", mimeType); + if (order) params.append("order", order); if (pageToken) params.append("pageToken", pageToken); if (cidPending) params.append("cidPending", "true"); } diff --git a/src/core/pinataSDK.ts b/src/core/pinataSDK.ts index d987146..c2148f5 100644 --- a/src/core/pinataSDK.ts +++ b/src/core/pinataSDK.ts @@ -275,6 +275,31 @@ class FilterFiles { this.config = config; } + name(name: string): FilterFiles { + this.query.name = name; + return this; + } + + group(group: string): FilterFiles { + this.query.group = group; + return this; + } + + cid(cid: string): FilterFiles { + this.query.cid = cid; + return this; + } + + mimeType(mimeType: string): FilterFiles { + this.query.mimeType = mimeType; + return this; + } + + order(order: "ASC" | "DESC"): FilterFiles { + this.query.order = order; + return this; + } + limit(limit: number): FilterFiles { this.query.limit = limit; return this; diff --git a/src/core/types.ts b/src/core/types.ts index 225696e..0a98d8c 100644 --- a/src/core/types.ts +++ b/src/core/types.ts @@ -73,9 +73,14 @@ export type FileListResponse = { }; export type FileListQuery = { + name?: string; + group?: string; + mimeType?: string; + cid?: string; + cidPending?: boolean; + order?: "ASC" | "DESC"; limit?: number; pageToken?: string; - cidPending?: boolean; }; export type PinJobQuery = {