@lumeweb/pinner 0.1.0 → 0.1.1
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 +35 -18
- package/dist/cjs/adapters/pinata/index.cjs +6 -3
- package/dist/cjs/adapters/pinata/legacy/adapter.cjs +83 -0
- package/dist/cjs/adapters/pinata/legacy/adapter.cjs.map +1 -0
- package/dist/cjs/adapters/pinata/legacy/adapter.d.cts +74 -0
- package/dist/cjs/adapters/pinata/legacy/index.cjs +1 -0
- package/dist/cjs/adapters/pinata/shared/index.cjs +1 -0
- package/dist/cjs/adapters/pinata/shared/types.d.cts +218 -0
- package/dist/cjs/adapters/pinata/shared/utils.cjs +83 -0
- package/dist/cjs/adapters/pinata/shared/utils.cjs.map +1 -0
- package/dist/cjs/adapters/pinata/v2/adapter-interface.d.cts +198 -0
- package/dist/cjs/adapters/pinata/v2/adapter.cjs +636 -0
- package/dist/cjs/adapters/pinata/v2/adapter.cjs.map +1 -0
- package/dist/cjs/adapters/pinata/v2/adapter.d.cts +17 -0
- package/dist/cjs/adapters/pinata/v2/index.cjs +1 -0
- package/dist/cjs/adapters/pinata/v2/types.d.cts +308 -0
- package/dist/cjs/index.cjs +3 -1
- package/dist/cjs/index.d.cts +5 -3
- package/dist/cjs/pin/client.cjs +5 -3
- package/dist/cjs/pin/client.cjs.map +1 -1
- package/dist/cjs/pinner.cjs +6 -0
- package/dist/cjs/pinner.cjs.map +1 -1
- package/dist/cjs/pinner.d.cts +4 -0
- package/dist/cjs/types/constants.cjs +6 -1
- package/dist/cjs/types/constants.cjs.map +1 -1
- package/dist/cjs/types/pin.d.cts +4 -0
- package/dist/esm/adapters/pinata/index.d.ts +7 -4
- package/dist/esm/adapters/pinata/index.js +6 -3
- package/dist/esm/adapters/pinata/legacy/adapter.d.ts +74 -0
- package/dist/esm/adapters/pinata/legacy/adapter.js +83 -0
- package/dist/esm/adapters/pinata/legacy/adapter.js.map +1 -0
- package/dist/esm/adapters/pinata/legacy/index.d.ts +1 -0
- package/dist/esm/adapters/pinata/legacy/index.js +1 -0
- package/dist/esm/adapters/pinata/shared/index.d.ts +2 -0
- package/dist/esm/adapters/pinata/shared/index.js +1 -0
- package/dist/esm/adapters/pinata/shared/types.d.ts +218 -0
- package/dist/esm/adapters/pinata/shared/utils.d.ts +1 -0
- package/dist/esm/adapters/pinata/shared/utils.js +78 -0
- package/dist/esm/adapters/pinata/shared/utils.js.map +1 -0
- package/dist/esm/adapters/pinata/v2/adapter-interface.d.ts +198 -0
- package/dist/esm/adapters/pinata/v2/adapter.d.ts +17 -0
- package/dist/esm/adapters/pinata/v2/adapter.js +636 -0
- package/dist/esm/adapters/pinata/v2/adapter.js.map +1 -0
- package/dist/esm/adapters/pinata/v2/index.d.ts +3 -0
- package/dist/esm/adapters/pinata/v2/index.js +1 -0
- package/dist/esm/adapters/pinata/v2/types.d.ts +308 -0
- package/dist/esm/index.d.ts +5 -3
- package/dist/esm/index.js +3 -2
- package/dist/esm/pin/client.js +5 -3
- package/dist/esm/pin/client.js.map +1 -1
- package/dist/esm/pinner.d.ts +4 -0
- package/dist/esm/pinner.js +6 -0
- package/dist/esm/pinner.js.map +1 -1
- package/dist/esm/types/constants.js +6 -2
- package/dist/esm/types/constants.js.map +1 -1
- package/dist/esm/types/pin.d.ts +4 -0
- package/package.json +3 -3
- package/dist/cjs/adapters/pinata/adapter.cjs +0 -88
- package/dist/cjs/adapters/pinata/adapter.cjs.map +0 -1
- package/dist/cjs/adapters/pinata/adapter.d.cts +0 -35
- package/dist/cjs/adapters/pinata/builder.cjs +0 -194
- package/dist/cjs/adapters/pinata/builder.cjs.map +0 -1
- package/dist/cjs/adapters/pinata/list-builder.cjs +0 -52
- package/dist/cjs/adapters/pinata/list-builder.cjs.map +0 -1
- package/dist/cjs/types/pinata.d.cts +0 -99
- package/dist/esm/adapters/pinata/adapter.d.ts +0 -35
- package/dist/esm/adapters/pinata/adapter.js +0 -87
- package/dist/esm/adapters/pinata/adapter.js.map +0 -1
- package/dist/esm/adapters/pinata/builder.d.ts +0 -1
- package/dist/esm/adapters/pinata/builder.js +0 -187
- package/dist/esm/adapters/pinata/builder.js.map +0 -1
- package/dist/esm/adapters/pinata/list-builder.d.ts +0 -1
- package/dist/esm/adapters/pinata/list-builder.js +0 -51
- package/dist/esm/adapters/pinata/list-builder.js.map +0 -1
- package/dist/esm/types/pinata.d.ts +0 -99
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.cjs","names":["parseCID","DEFAULT_GATEWAY"],"sources":["../../../../../src/adapters/pinata/v2/adapter.ts"],"sourcesContent":["/**\n * Pinata SDK 2.x Adapter Implementation\n * Provides compatibility with Pinata SDK 2.x API\n *\n * Source: https://github.com/PinataCloud/pinata/commit/cdc0c06116aaadaf7c4b287a2673cd23b6ba1125\n * - src/core/pinataSDK.ts\n * - src/core/types/index.ts\n * - src/core/classes/index.ts\n *\n * Copyright © 2024 Pinata Cloud Technologies\n * Type definitions and API interfaces adapted from Pinata SDK for compatibility.\n * Original Pinata SDK: https://github.com/PinataCloud/pinata\n */\n\nimport type { Pinner } from \"@/pinner\";\nimport type {\n\tPinataConfig,\n\tUploadResponse,\n\tUploadOptions,\n\tUploadCIDOptions,\n\tPinByCIDResponse,\n\tSignedUploadUrlOptions,\n\tFileListItem,\n\tFileListQuery,\n\tFileListResponse,\n\tUpdateFileOptions,\n\tDeleteResponse,\n\tPinQueueQuery,\n\tPinQueueResponse,\n\tSwapCidOptions,\n\tSwapCidResponse,\n\tSwapHistoryOptions,\n\tAccessLinkOptions,\n\tGroupOptions,\n\tUpdateGroupOptions,\n\tGetGroupOptions,\n\tGroupResponseItem,\n\tGroupCIDOptions,\n\tUpdateGroupFilesResponse,\n\tTopAnalyticsQuery,\n\tTopAnalyticsResponse,\n\tTimeIntervalAnalyticsQuery,\n\tTimeIntervalAnalyticsResponse,\n} from \"./types\";\nimport type {\n\tPinataAdapter,\n\tPublicUpload,\n\tPrivateUpload,\n\tPublicFiles,\n\tPrivateFiles,\n\tPublicGateways,\n\tPrivateGateways,\n\tPublicGroups,\n\tPrivateGroups,\n\tAnalytics,\n\tUploadBuilder,\n\tFilterFiles,\n\tFilterQueue,\n\tFilterGroups,\n} from \"./adapter-interface\";\nimport { parseCID, notSupported } from \"../shared/utils\";\nimport { DEFAULT_GATEWAY } from \"@/types/constants\";\n\n/**\n * Implementation of UploadBuilder\n */\nclass UploadBuilderImpl<TResult> implements UploadBuilder<TResult> {\n\tprivate _name?: string;\n\tprivate _keyvalues?: Record<string, string>;\n\n\tconstructor(\n\t\tprivate pinner: Pinner,\n\t\tprivate executeFn: (name?: string, keyvalues?: Record<string, string>) => Promise<TResult>,\n\t) {}\n\n\tname(name: string): this {\n\t\tthis._name = name;\n\t\treturn this;\n\t}\n\n\tkeyvalues(keyvalues: Record<string, string>): this {\n\t\tthis._keyvalues = keyvalues;\n\t\treturn this;\n\t}\n\n\tasync execute(): Promise<TResult> {\n\t\treturn this.executeFn(this._name, this._keyvalues);\n\t}\n}\n\n/**\n * Implementation of FilterFiles\n */\nclass FilterFilesImpl implements FilterFiles {\n\tprivate query: FileListQuery = {};\n\tprivate currentPageToken: string | undefined;\n\tprivate privacy: \"public\" | \"private\";\n\n\tconstructor(\n\t\tprivate pinner: Pinner,\n\t\tprivacy: \"public\" | \"private\",\n\t) {\n\t\tthis.privacy = privacy;\n\t}\n\n\tname(name: string): FilterFiles {\n\t\tthis.query.name = name;\n\t\treturn this;\n\t}\n\n\tgroup(group: string): FilterFiles {\n\t\tthis.query.group = group;\n\t\treturn this;\n\t}\n\n\tcid(cid: string): FilterFiles {\n\t\tthis.query.cid = cid;\n\t\treturn this;\n\t}\n\n\tmimeType(mimeType: string): FilterFiles {\n\t\tthis.query.mimeType = mimeType;\n\t\treturn this;\n\t}\n\n\torder(order: \"ASC\" | \"DESC\"): FilterFiles {\n\t\tthis.query.order = order;\n\t\treturn this;\n\t}\n\n\tlimit(limit: number): FilterFiles {\n\t\tthis.query.limit = limit;\n\t\treturn this;\n\t}\n\n\tcidPending(cidPending: boolean): FilterFiles {\n\t\tthis.query.cidPending = cidPending;\n\t\treturn this;\n\t}\n\n\tkeyvalues(keyvalues: Record<string, string>): FilterFiles {\n\t\tthis.query.metadata = keyvalues;\n\t\treturn this;\n\t}\n\n\tnoGroup(noGroup: boolean): FilterFiles {\n\t\tthis.query.noGroup = noGroup;\n\t\treturn this;\n\t}\n\n\tpageToken(pageToken: string): FilterFiles {\n\t\tthis.query.pageToken = Number.parseInt(pageToken, 10);\n\t\treturn this;\n\t}\n\n\tthen(\n\t\tonfulfilled?: ((value: FileListResponse) => any) | null,\n\t\tonrejected?: ((reason: any) => any) | null,\n\t): Promise<any> {\n\t\treturn this.fetchPage().then(onfulfilled, onrejected);\n\t}\n\n\tprivate async fetchPage(): Promise<FileListResponse> {\n\t\tconst pins = await this.pinner.listPins({\n\t\t\tlimit: this.query.limit,\n\t\t});\n\n\t\treturn {\n\t\t\tfiles: pins.map((pin) => ({\n\t\t\t\tid: pin.cid.toString(),\n\t\t\t\tname: pin.name || null,\n\t\t\t\tcid: pin.cid.toString(),\n\t\t\t\tsize: pin.size || 0,\n\t\t\t\tnumber_of_files: 1,\n\t\t\t\tmime_type: \"application/octet-stream\",\n\t\t\t\tkeyvalues: pin.metadata || {},\n\t\t\t\tgroup_id: null,\n\t\t\t\tcreated_at: pin.created.toISOString(),\n\t\t\t})),\n\t\t\tnext_page_token: this.currentPageToken || \"\",\n\t\t};\n\t}\n\n\tasync *[Symbol.asyncIterator](): AsyncGenerator<FileListItem, void, unknown> {\n\t\twhile (true) {\n\t\t\tconst items = await this.fetchPage();\n\t\t\tfor (const item of items.files) {\n\t\t\t\tyield item;\n\t\t\t}\n\t\t\tif (!this.currentPageToken) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tasync all(): Promise<FileListItem[]> {\n\t\tconst allItems: FileListItem[] = [];\n\t\tfor await (const item of this) {\n\t\t\tallItems.push(item);\n\t\t}\n\t\treturn allItems;\n\t}\n}\n\n/**\n * Implementation of FilterQueue\n */\nclass FilterQueueImpl implements FilterQueue {\n\tprivate query: PinQueueQuery = {};\n\tprivate currentPageToken: string | undefined;\n\n\tconstructor(private pinner: Pinner) {}\n\n\tcid(cid: string): FilterQueue {\n\t\tthis.query.cid = cid;\n\t\treturn this;\n\t}\n\n\tstatus(\n\t\tstatus:\n\t\t\t| \"prechecking\"\n\t\t\t| \"retrieving\"\n\t\t\t| \"expired\"\n\t\t\t| \"backfilled\"\n\t\t\t| \"over_free_limit\"\n\t\t\t| \"over_max_size\"\n\t\t\t| \"invalid_object\"\n\t\t\t| \"bad_host_node\",\n\t): FilterQueue {\n\t\tthis.query.status = status;\n\t\treturn this;\n\t}\n\n\tpageLimit(limit: number): FilterQueue {\n\t\tthis.query.limit = limit;\n\t\treturn this;\n\t}\n\n\tpageToken(pageToken: string): FilterQueue {\n\t\tthis.query.pageToken = pageToken;\n\t\treturn this;\n\t}\n\n\tsort(sort: \"ASC\" | \"DSC\"): FilterQueue {\n\t\tthis.query.sort = sort;\n\t\treturn this;\n\t}\n\n\tthen(\n\t\tonfulfilled?: ((value: PinQueueResponse) => any) | null,\n\t\tonrejected?: ((reason: any) => any) | null,\n\t): Promise<any> {\n\t\treturn this.fetchPage().then(onfulfilled, onrejected);\n\t}\n\n\tprivate async fetchPage(): Promise<PinQueueResponse> {\n\t\tconst pins = await this.pinner.listPins({\n\t\t\tlimit: this.query.limit,\n\t\t});\n\n\t\treturn {\n\t\t\tjobs: pins.map((pin) => ({\n\t\t\t\tid: pin.cid.toString(),\n\t\t\t\tcid: pin.cid.toString(),\n\t\t\t\tdate_queued: pin.created.toISOString(),\n\t\t\t\tname: pin.name || \"\",\n\t\t\t\tstatus: pin.status || \"pinned\",\n\t\t\t\tkeyvalues: pin.metadata || {},\n\t\t\t\thost_nodes: [],\n\t\t\t\tpin_policy: {\n\t\t\t\t\tregions: [],\n\t\t\t\t\tversion: 1,\n\t\t\t\t},\n\t\t\t})),\n\t\t\tnext_page_token: this.currentPageToken || \"\",\n\t\t};\n\t}\n\n\tasync *[Symbol.asyncIterator](): AsyncGenerator<\n\t\timport(\"./types\").PinQueueItem,\n\t\tvoid,\n\t\tunknown\n\t> {\n\t\twhile (true) {\n\t\t\tconst items = await this.fetchPage();\n\t\t\tfor (const item of items.jobs) {\n\t\t\t\tyield item;\n\t\t\t}\n\t\t\tif (!this.currentPageToken) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tasync all(): Promise<import(\"./types\").PinQueueItem[]> {\n\t\tconst allItems: import(\"./types\").PinQueueItem[] = [];\n\t\tfor await (const item of this) {\n\t\t\tallItems.push(item);\n\t\t}\n\t\treturn allItems;\n\t}\n}\n\n/**\n * Implementation of FilterGroups\n */\nclass FilterGroupsImpl implements FilterGroups {\n\tprivate currentPageToken: string | undefined;\n\tprivate privacy: \"public\" | \"private\";\n\n\tconstructor(private pinner: Pinner, privacy: \"public\" | \"private\") {\n\t\tthis.privacy = privacy;\n\t}\n\n\tname(name: string): FilterGroups {\n\t\t// Pinner doesn't support groups, return empty\n\t\treturn this;\n\t}\n\n\tlimit(limit: number): FilterGroups {\n\t\treturn this;\n\t}\n\n\tpageToken(pageToken: string): FilterGroups {\n\t\tthis.currentPageToken = pageToken;\n\t\treturn this;\n\t}\n\n\tisPublic(isPublic: boolean): FilterGroups {\n\t\treturn this;\n\t}\n\n\tthen(\n\t\tonfulfilled?: ((value: import(\"./types\").GroupListResponse) => any) | null,\n\t\tonrejected?: ((reason: any) => any) | null,\n\t): Promise<any> {\n\t\treturn this.fetchPage().then(onfulfilled, onrejected);\n\t}\n\n\tprivate async fetchPage(): Promise<import(\"./types\").GroupListResponse> {\n\t\t// Pinner doesn't support groups\n\t\treturn {\n\t\t\tgroups: [],\n\t\t\tnext_page_token: this.currentPageToken || \"\",\n\t\t};\n\t}\n\n\tasync *[Symbol.asyncIterator](): AsyncGenerator<GroupResponseItem, void, unknown> {\n\t\tconst items = await this.fetchPage();\n\t\tfor (const item of items.groups) {\n\t\t\tyield item;\n\t\t}\n\t}\n\n\tasync all(): Promise<GroupResponseItem[]> {\n\t\tconst allItems: GroupResponseItem[] = [];\n\t\tfor await (const item of this) {\n\t\t\tallItems.push(item);\n\t\t}\n\t\treturn allItems;\n\t}\n}\n\n/**\n * Implementation of PublicUpload\n */\nclass PublicUploadImpl implements PublicUpload {\n\tconstructor(\n\t\tprivate pinner: Pinner,\n\t\tprivate config?: PinataConfig,\n\t) {}\n\n\tfile(file: File, options?: UploadOptions): UploadBuilder<UploadResponse> {\n\t\treturn new UploadBuilderImpl(this.pinner, async (name, keyvalues) => {\n\t\t\tconst result = await this.pinner.uploadAndWait(file, {\n\t\t\t\tname: name || options?.metadata?.name,\n\t\t\t\tkeyvalues: keyvalues || options?.metadata?.keyvalues,\n\t\t\t});\n\n\t\t\treturn {\n\t\t\t\tid: result.cid,\n\t\t\t\tname: file.name,\n\t\t\t\tcid: result.cid,\n\t\t\t\tsize: result.size,\n\t\t\t\tcreated_at: result.createdAt.toISOString(),\n\t\t\t\tnumber_of_files: 1,\n\t\t\t\tmime_type: file.type || \"application/octet-stream\",\n\t\t\t\tgroup_id: null,\n\t\t\t\tkeyvalues: keyvalues || options?.metadata?.keyvalues || {},\n\t\t\t\tvectorized: false,\n\t\t\t\tnetwork: \"public\",\n\t\t\t};\n\t\t});\n\t}\n\n\tfileArray(\n\t\tfiles: File[],\n\t\toptions?: UploadOptions,\n\t): UploadBuilder<UploadResponse> {\n\t\treturn new UploadBuilderImpl(this.pinner, async (name, keyvalues) => {\n\t\t\tconst operation = await this.pinner.uploadDirectory(files, {\n\t\t\t\tname: name || options?.metadata?.name,\n\t\t\t\tkeyvalues: keyvalues || options?.metadata?.keyvalues,\n\t\t\t});\n\t\t\tconst result = await operation.result;\n\n\t\t\treturn {\n\t\t\t\tid: result.cid,\n\t\t\t\tname: name || options?.metadata?.name || \"directory\",\n\t\t\t\tcid: result.cid,\n\t\t\t\tsize: result.size,\n\t\t\t\tcreated_at: result.createdAt.toISOString(),\n\t\t\t\tnumber_of_files: files.length,\n\t\t\t\tmime_type: \"application/octet-stream\",\n\t\t\t\tgroup_id: null,\n\t\t\t\tkeyvalues: keyvalues || options?.metadata?.keyvalues || {},\n\t\t\t\tvectorized: false,\n\t\t\t\tnetwork: \"public\",\n\t\t\t};\n\t\t});\n\t}\n\n\tbase64(\n\t\tbase64String: string,\n\t\toptions?: UploadOptions,\n\t): UploadBuilder<UploadResponse> {\n\t\treturn new UploadBuilderImpl(this.pinner, async (name, keyvalues) => {\n\t\t\t// Convert base64 to file\n\t\t\tconst binaryString = atob(base64String);\n\t\t\tconst bytes = new Uint8Array(binaryString.length);\n\t\t\tfor (let i = 0; i < binaryString.length; i++) {\n\t\t\t\tbytes[i] = binaryString.charCodeAt(i);\n\t\t\t}\n\t\t\tconst blob = new Blob([bytes], {\n\t\t\t\ttype: \"application/octet-stream\",\n\t\t\t});\n\t\t\tconst file = new File(\n\t\t\t\t[blob],\n\t\t\t\tname || options?.metadata?.name || \"file.bin\",\n\t\t\t\t{ type: \"application/octet-stream\" },\n\t\t\t);\n\n\t\t\tconst result = await this.pinner.uploadAndWait(file, {\n\t\t\t\tname: name || options?.metadata?.name,\n\t\t\t\tkeyvalues: keyvalues || options?.metadata?.keyvalues,\n\t\t\t});\n\n\t\t\treturn {\n\t\t\t\tid: result.cid,\n\t\t\t\tname: file.name,\n\t\t\t\tcid: result.cid,\n\t\t\t\tsize: result.size,\n\t\t\t\tcreated_at: result.createdAt.toISOString(),\n\t\t\t\tnumber_of_files: 1,\n\t\t\t\tmime_type: \"application/octet-stream\",\n\t\t\t\tgroup_id: null,\n\t\t\t\tkeyvalues: keyvalues || options?.metadata?.keyvalues || {},\n\t\t\t\tvectorized: false,\n\t\t\t\tnetwork: \"public\",\n\t\t\t};\n\t\t});\n\t}\n\n\turl(url: string, options?: UploadOptions): UploadBuilder<UploadResponse> {\n\t\treturn new UploadBuilderImpl(this.pinner, async () => {\n\t\t\tnotSupported(\"URL upload\");\n\t\t});\n\t}\n\n\tjson(data: object, options?: UploadOptions): UploadBuilder<UploadResponse> {\n\t\treturn new UploadBuilderImpl(this.pinner, async (name, keyvalues) => {\n\t\t\tconst jsonString = JSON.stringify(data);\n\t\t\tconst file = new File(\n\t\t\t\t[jsonString],\n\t\t\t\tname || options?.metadata?.name || \"data.json\",\n\t\t\t\t{ type: \"application/json\" },\n\t\t\t);\n\n\t\t\tconst result = await this.pinner.uploadAndWait(file, {\n\t\t\t\tname: name || options?.metadata?.name,\n\t\t\t\tkeyvalues: keyvalues || options?.metadata?.keyvalues,\n\t\t\t});\n\n\t\t\treturn {\n\t\t\t\tid: result.cid,\n\t\t\t\tname: file.name,\n\t\t\t\tcid: result.cid,\n\t\t\t\tsize: result.size,\n\t\t\t\tcreated_at: result.createdAt.toISOString(),\n\t\t\t\tnumber_of_files: 1,\n\t\t\t\tmime_type: \"application/json\",\n\t\t\t\tgroup_id: null,\n\t\t\t\tkeyvalues: keyvalues || options?.metadata?.keyvalues || {},\n\t\t\t\tvectorized: false,\n\t\t\t\tnetwork: \"public\",\n\t\t\t};\n\t\t});\n\t}\n\n\tcid(cid: string, options?: UploadCIDOptions): UploadBuilder<PinByCIDResponse> {\n\t\treturn new UploadBuilderImpl(this.pinner, async () => {\n\t\t\tconst cidObj = parseCID(cid);\n\t\t\tconst generator = await this.pinner.pinByHash(cidObj, {\n\t\t\t\tname: options?.metadata?.name,\n\t\t\t\tmetadata: options?.metadata?.keyvalues,\n\t\t\t});\n\n\t\t\tfor await (const _ of generator) {\n\t\t\t\t// Wait for pin to complete\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tid: cid,\n\t\t\t\tcid: cid,\n\t\t\t\tdate_queued: new Date().toISOString(),\n\t\t\t\tname: options?.metadata?.name || \"\",\n\t\t\t\tstatus: \"pinned\",\n\t\t\t\tkeyvalues: options?.metadata?.keyvalues || null,\n\t\t\t\thost_nodes: null,\n\t\t\t\tgroup_id: options?.groupId || null,\n\t\t\t};\n\t\t});\n\t}\n\n\tasync createSignedURL(\n\t\toptions: SignedUploadUrlOptions,\n\t): Promise<string> {\n\t\tnotSupported(\"Signed upload URLs\");\n\t}\n}\n\n/**\n * Implementation of PrivateUpload\n */\nclass PrivateUploadImpl implements PrivateUpload {\n\tconstructor(\n\t\tprivate pinner: Pinner,\n\t\tprivate config?: PinataConfig,\n\t) {}\n\n\tfile(file: File, options?: UploadOptions): UploadBuilder<UploadResponse> {\n\t\treturn new UploadBuilderImpl(this.pinner, async () => {\n\t\t\tnotSupported(\"Private upload\");\n\t\t});\n\t}\n\n\tfileArray(\n\t\tfiles: File[],\n\t\toptions?: UploadOptions,\n\t): UploadBuilder<UploadResponse> {\n\t\treturn new UploadBuilderImpl(this.pinner, async () => {\n\t\t\tnotSupported(\"Private upload\");\n\t\t});\n\t}\n\n\tbase64(\n\t\tbase64String: string,\n\t\toptions?: UploadOptions,\n\t): UploadBuilder<UploadResponse> {\n\t\treturn new UploadBuilderImpl(this.pinner, async () => {\n\t\t\tnotSupported(\"Private upload\");\n\t\t});\n\t}\n\n\turl(url: string, options?: UploadOptions): UploadBuilder<UploadResponse> {\n\t\treturn new UploadBuilderImpl(this.pinner, async () => {\n\t\t\tnotSupported(\"Private upload\");\n\t\t});\n\t}\n\n\tjson(data: object, options?: UploadOptions): UploadBuilder<UploadResponse> {\n\t\treturn new UploadBuilderImpl(this.pinner, async () => {\n\t\t\tnotSupported(\"Private upload\");\n\t\t});\n\t}\n\n\tcid(cid: string, options?: UploadCIDOptions): UploadBuilder<PinByCIDResponse> {\n\t\treturn new UploadBuilderImpl(this.pinner, async () => {\n\t\t\tnotSupported(\"Private upload\");\n\t\t});\n\t}\n\n\tasync createSignedURL(\n\t\toptions: SignedUploadUrlOptions,\n\t): Promise<string> {\n\t\tnotSupported(\"Private upload\");\n\t}\n}\n\n/**\n * Implementation of PublicFiles\n */\nclass PublicFilesImpl implements PublicFiles {\n\tconstructor(\n\t\tprivate pinner: Pinner,\n\t\tprivate config?: PinataConfig,\n\t) {}\n\n\tlist(): FilterFiles {\n\t\treturn new FilterFilesImpl(this.pinner, \"public\");\n\t}\n\n\tasync get(id: string): Promise<FileListItem> {\n\t\tconst cidObj = parseCID(id);\n\t\tconst pin = await this.pinner.getPinStatus(cidObj);\n\n\t\treturn {\n\t\t\tid: pin.cid.toString(),\n\t\t\tname: pin.name || null,\n\t\t\tcid: pin.cid.toString(),\n\t\t\tsize: pin.size || 0,\n\t\t\tnumber_of_files: 1,\n\t\t\tmime_type: \"application/octet-stream\",\n\t\t\tkeyvalues: pin.metadata || {},\n\t\t\tgroup_id: null,\n\t\t\tcreated_at: pin.created.toISOString(),\n\t\t};\n\t}\n\n\tasync delete(files: string[]): Promise<DeleteResponse[]> {\n\t\tconst results: DeleteResponse[] = [];\n\t\tfor (const file of files) {\n\t\t\tawait this.pinner.unpin(file);\n\t\t\tresults.push({ id: file, status: \"deleted\" });\n\t\t}\n\t\treturn results;\n\t}\n\n\tasync update(options: UpdateFileOptions): Promise<FileListItem> {\n\t\tawait this.pinner.setPinMetadata(options.id, options.keyvalues || {});\n\n\t\tconst pin = await this.pinner.getPinStatus(parseCID(options.id));\n\t\treturn {\n\t\t\tid: pin.cid.toString(),\n\t\t\tname: pin.name || null,\n\t\t\tcid: pin.cid.toString(),\n\t\t\tsize: pin.size || 0,\n\t\t\tnumber_of_files: 1,\n\t\t\tmime_type: \"application/octet-stream\",\n\t\t\tkeyvalues: pin.metadata || {},\n\t\t\tgroup_id: null,\n\t\t\tcreated_at: pin.created.toISOString(),\n\t\t};\n\t}\n\n\tasync addSwap(options: SwapCidOptions): Promise<SwapCidResponse> {\n\t\tnotSupported(\"Swap CID\");\n\t}\n\n\tasync getSwapHistory(\n\t\toptions: SwapHistoryOptions,\n\t): Promise<SwapCidResponse[]> {\n\t\treturn [];\n\t}\n\n\tasync deleteSwap(cid: string): Promise<string> {\n\t\tnotSupported(\"Swap CID\");\n\t}\n\n\tqueue(): FilterQueue {\n\t\treturn new FilterQueueImpl(this.pinner);\n\t}\n\n\tasync deletePinRequest(requestId: string): Promise<string> {\n\t\t// Delete pin by request ID (not CID)\n\t\tawait this.pinner.unpinByRequestId(requestId);\n\t\treturn requestId;\n\t}\n}\n\n/**\n * Implementation of PrivateFiles\n */\nclass PrivateFilesImpl implements PrivateFiles {\n\tconstructor(\n\t\tprivate pinner: Pinner,\n\t\tprivate config?: PinataConfig,\n\t) {}\n\n\tlist(): FilterFiles {\n\t\tnotSupported(\"Private files\");\n\t}\n\n\tasync get(id: string): Promise<FileListItem> {\n\t\tnotSupported(\"Private files\");\n\t}\n\n\tasync delete(files: string[]): Promise<DeleteResponse[]> {\n\t\tnotSupported(\"Private files\");\n\t}\n\n\tasync update(options: UpdateFileOptions): Promise<FileListItem> {\n\t\tnotSupported(\"Private files\");\n\t}\n\n\tasync addSwap(options: SwapCidOptions): Promise<SwapCidResponse> {\n\t\tnotSupported(\"Private files\");\n\t}\n\n\tasync getSwapHistory(\n\t\toptions: SwapHistoryOptions,\n\t): Promise<SwapCidResponse[]> {\n\t\tnotSupported(\"Private files\");\n\t}\n\n\tasync deleteSwap(cid: string): Promise<string> {\n\t\tnotSupported(\"Private files\");\n\t}\n\n\tqueue(): FilterQueue {\n\t\tnotSupported(\"Private files\");\n\t}\n\n\tasync deletePinRequest(requestId: string): Promise<string> {\n\t\tnotSupported(\"Private files\");\n\t}\n}\n\n/**\n * Implementation of PublicGateways\n */\nclass PublicGatewaysImpl implements PublicGateways {\n\tconstructor(\n\t\tprivate pinner: Pinner,\n\t\tprivate config?: PinataConfig,\n\t) {}\n\n\tget(cid: string): any {\n\t\t// Return an object that can be used to fetch CID\n\t\treturn {\n\t\t\tcid,\n\t\t\tgateway: this.config?.pinataGateway || DEFAULT_GATEWAY,\n\t\t\turl: `${this.config?.pinataGateway || DEFAULT_GATEWAY}/ipfs/${cid}`,\n\t\t};\n\t}\n\n\tasync convert(\n\t\turl: string,\n\t\tgatewayPrefix?: string,\n\t): Promise<string> {\n\t\t// Convert IPFS URL to gateway URL\n\t\tconst gateway = gatewayPrefix || this.config?.pinataGateway || DEFAULT_GATEWAY;\n\t\treturn url.replace(\"ipfs://\", `${gateway}/ipfs/`);\n\t}\n}\n\n/**\n * Implementation of PrivateGateways\n */\nclass PrivateGatewaysImpl implements PrivateGateways {\n\tconstructor(\n\t\tprivate pinner: Pinner,\n\t\tprivate config?: PinataConfig,\n\t) {}\n\n\tget(cid: string): any {\n\t\tnotSupported(\"Private gateways\");\n\t}\n\n\tcreateAccessLink(options: AccessLinkOptions): any {\n\t\tnotSupported(\"Private gateways\");\n\t}\n}\n\n/**\n * Implementation of PublicGroups\n */\nclass PublicGroupsImpl implements PublicGroups {\n\tconstructor(\n\t\tprivate pinner: Pinner,\n\t\tprivate config?: PinataConfig,\n\t) {}\n\n\tasync create(options: GroupOptions): Promise<GroupResponseItem> {\n\t\tnotSupported(\"Groups\");\n\t}\n\n\tlist(): FilterGroups {\n\t\treturn new FilterGroupsImpl(this.pinner, \"public\");\n\t}\n\n\tasync get(options: GetGroupOptions): Promise<GroupResponseItem> {\n\t\tnotSupported(\"Groups\");\n\t}\n\n\tasync addFiles(\n\t\toptions: GroupCIDOptions,\n\t): Promise<UpdateGroupFilesResponse[]> {\n\t\tnotSupported(\"Groups\");\n\t}\n\n\tasync removeFiles(\n\t\toptions: GroupCIDOptions,\n\t): Promise<UpdateGroupFilesResponse[]> {\n\t\tnotSupported(\"Groups\");\n\t}\n\n\tasync update(options: UpdateGroupOptions): Promise<GroupResponseItem> {\n\t\tnotSupported(\"Groups\");\n\t}\n\n\tasync delete(options: GetGroupOptions): Promise<string> {\n\t\tnotSupported(\"Groups\");\n\t}\n}\n\n/**\n * Implementation of PrivateGroups\n */\nclass PrivateGroupsImpl implements PrivateGroups {\n\tconstructor(\n\t\tprivate pinner: Pinner,\n\t\tprivate config?: PinataConfig,\n\t) {}\n\n\tasync create(options: GroupOptions): Promise<GroupResponseItem> {\n\t\tnotSupported(\"Private groups\");\n\t}\n\n\tlist(): FilterGroups {\n\t\tnotSupported(\"Private groups\");\n\t}\n\n\tasync get(options: GetGroupOptions): Promise<GroupResponseItem> {\n\t\tnotSupported(\"Private groups\");\n\t}\n\n\tasync addFiles(\n\t\toptions: GroupCIDOptions,\n\t): Promise<UpdateGroupFilesResponse[]> {\n\t\tnotSupported(\"Private groups\");\n\t}\n\n\tasync removeFiles(\n\t\toptions: GroupCIDOptions,\n\t): Promise<UpdateGroupFilesResponse[]> {\n\t\tnotSupported(\"Private groups\");\n\t}\n\n\tasync update(options: UpdateGroupOptions): Promise<GroupResponseItem> {\n\t\tnotSupported(\"Private groups\");\n\t}\n\n\tasync delete(options: GetGroupOptions): Promise<string> {\n\t\tnotSupported(\"Private groups\");\n\t}\n}\n\n/**\n * Implementation of Analytics\n */\nclass AnalyticsImpl implements Analytics {\n\tasync requests(query: TopAnalyticsQuery): Promise<TopAnalyticsResponse> {\n\t\t// Pinner doesn't support analytics\n\t\treturn {\n\t\t\tdata: [],\n\t\t};\n\t}\n\n\tasync bandwidth(\n\t\tquery: TimeIntervalAnalyticsQuery,\n\t): Promise<TimeIntervalAnalyticsResponse> {\n\t\t// Pinner doesn't support analytics\n\t\treturn {\n\t\t\ttotal_requests: 0,\n\t\t\ttotal_bandwidth: 0,\n\t\t\ttime_periods: [],\n\t\t};\n\t}\n}\n\n/**\n * Create Pinata Adapter\n *\n * @param pinner - Pinner client instance\n * @param config - Pinata configuration\n * @returns PinataAdapter\n */\nexport function pinataAdapter(\n\tpinner: Pinner,\n\tconfig?: PinataConfig,\n): PinataAdapter {\n\tconst effectiveConfig: PinataConfig = config || {};\n\n\treturn {\n\t\tconfig: effectiveConfig,\n\t\tupdateConfig(newConfig: PinataConfig): void {\n\t\t\tObject.assign(effectiveConfig, newConfig);\n\t\t},\n\n\t\tupload: {\n\t\t\tpublic: new PublicUploadImpl(pinner, effectiveConfig),\n\t\t\tprivate: new PrivateUploadImpl(pinner, effectiveConfig),\n\t\t},\n\n\t\tfiles: {\n\t\t\tpublic: new PublicFilesImpl(pinner, effectiveConfig),\n\t\t\tprivate: new PrivateFilesImpl(pinner, effectiveConfig),\n\t\t},\n\n\t\tgateways: {\n\t\t\tpublic: new PublicGatewaysImpl(pinner, effectiveConfig),\n\t\t\tprivate: new PrivateGatewaysImpl(pinner, effectiveConfig),\n\t\t},\n\n\t\tgroups: {\n\t\t\tpublic: new PublicGroupsImpl(pinner, effectiveConfig),\n\t\t\tprivate: new PrivateGroupsImpl(pinner, effectiveConfig),\n\t\t},\n\n\t\tanalytics: new AnalyticsImpl(),\n\t};\n}\n\n// Re-export interface\nexport type { PinataAdapter } from \"./adapter-interface\";\n"],"mappings":";;;;;;;AAkEA,IAAM,oBAAN,MAAmE;CAClE,AAAQ;CACR,AAAQ;CAER,YACC,AAAQ,QACR,AAAQ,WACP;EAFO;EACA;;CAGT,KAAK,MAAoB;AACxB,OAAK,QAAQ;AACb,SAAO;;CAGR,UAAU,WAAyC;AAClD,OAAK,aAAa;AAClB,SAAO;;CAGR,MAAM,UAA4B;AACjC,SAAO,KAAK,UAAU,KAAK,OAAO,KAAK,WAAW;;;;;;AAOpD,IAAM,kBAAN,MAA6C;CAC5C,AAAQ,QAAuB,EAAE;CACjC,AAAQ;CACR,AAAQ;CAER,YACC,AAAQ,QACR,SACC;EAFO;AAGR,OAAK,UAAU;;CAGhB,KAAK,MAA2B;AAC/B,OAAK,MAAM,OAAO;AAClB,SAAO;;CAGR,MAAM,OAA4B;AACjC,OAAK,MAAM,QAAQ;AACnB,SAAO;;CAGR,IAAI,KAA0B;AAC7B,OAAK,MAAM,MAAM;AACjB,SAAO;;CAGR,SAAS,UAA+B;AACvC,OAAK,MAAM,WAAW;AACtB,SAAO;;CAGR,MAAM,OAAoC;AACzC,OAAK,MAAM,QAAQ;AACnB,SAAO;;CAGR,MAAM,OAA4B;AACjC,OAAK,MAAM,QAAQ;AACnB,SAAO;;CAGR,WAAW,YAAkC;AAC5C,OAAK,MAAM,aAAa;A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Q;GACP,QAAQ,IAAI,iBAAiB,QAAQ,gBAAgB;GACrD,SAAS,IAAI,kBAAkB,QAAQ,gBAAgB;GACvD;EAED,OAAO;GACN,QAAQ,IAAI,gBAAgB,QAAQ,gBAAgB;GACpD,SAAS,IAAI,iBAAiB,QAAQ,gBAAgB;GACtD;EAED,UAAU;GACT,QAAQ,IAAI,mBAAmB,QAAQ,gBAAgB;GACvD,SAAS,IAAI,oBAAoB,QAAQ,gBAAgB;GACzD;EAED,QAAQ;GACP,QAAQ,IAAI,iBAAiB,QAAQ,gBAAgB;GACrD,SAAS,IAAI,kBAAkB,QAAQ,gBAAgB;GACvD;EAED,WAAW,IAAI,eAAe;EAC9B"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Pinner } from "../../../pinner.cjs";
|
|
2
|
+
import { PinataConfig } from "./types.cjs";
|
|
3
|
+
import { PinataAdapter } from "./adapter-interface.cjs";
|
|
4
|
+
|
|
5
|
+
//#region src/adapters/pinata/v2/adapter.d.ts
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Create Pinata Adapter
|
|
9
|
+
*
|
|
10
|
+
* @param pinner - Pinner client instance
|
|
11
|
+
* @param config - Pinata configuration
|
|
12
|
+
* @returns PinataAdapter
|
|
13
|
+
*/
|
|
14
|
+
declare function pinataAdapter(pinner: Pinner, config?: PinataConfig): PinataAdapter;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { pinataAdapter };
|
|
17
|
+
//# sourceMappingURL=adapter.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const require_adapter = require('./adapter.cjs');
|
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
//#region src/adapters/pinata/v2/types.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Pinata SDK 2.x Types
|
|
4
|
+
* Source: https://github.com/PinataCloud/pinata/commit/cdc0c06116aaadaf7c4b287a2673cd23b6ba1125
|
|
5
|
+
* - src/core/types/index.ts
|
|
6
|
+
*
|
|
7
|
+
* Copyright © 2024 Pinata Cloud Technologies
|
|
8
|
+
* Type definitions adapted from Pinata SDK for compatibility.
|
|
9
|
+
* Original Pinata SDK: https://github.com/PinataCloud/pinata
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* CID version type
|
|
13
|
+
*/
|
|
14
|
+
type CidVersion = "v0" | "v1";
|
|
15
|
+
/**
|
|
16
|
+
* Pinata configuration options
|
|
17
|
+
*/
|
|
18
|
+
type PinataConfig = {
|
|
19
|
+
pinataJwt?: string;
|
|
20
|
+
pinataGateway?: string;
|
|
21
|
+
pinataGatewayKey?: string;
|
|
22
|
+
customHeaders?: Record<string, string>;
|
|
23
|
+
endpointUrl?: string;
|
|
24
|
+
uploadUrl?: string;
|
|
25
|
+
legacyUploadUrl?: string;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Pinata metadata
|
|
29
|
+
*/
|
|
30
|
+
type PinataMetadata = {
|
|
31
|
+
name?: string;
|
|
32
|
+
keyvalues?: Record<string, string>;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Upload options
|
|
36
|
+
*/
|
|
37
|
+
type UploadOptions = {
|
|
38
|
+
metadata?: PinataMetadata;
|
|
39
|
+
keys?: string;
|
|
40
|
+
groupId?: string;
|
|
41
|
+
vectorize?: boolean;
|
|
42
|
+
url?: string;
|
|
43
|
+
streamable?: boolean;
|
|
44
|
+
peerAddresses?: string[];
|
|
45
|
+
car?: boolean;
|
|
46
|
+
cid_version?: CidVersion;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Upload response
|
|
50
|
+
*/
|
|
51
|
+
type UploadResponse = {
|
|
52
|
+
id: string;
|
|
53
|
+
name: string;
|
|
54
|
+
cid: string;
|
|
55
|
+
size: number;
|
|
56
|
+
created_at: string;
|
|
57
|
+
number_of_files: number;
|
|
58
|
+
mime_type: string;
|
|
59
|
+
group_id: string | null;
|
|
60
|
+
keyvalues: Record<string, string>;
|
|
61
|
+
vectorized: boolean;
|
|
62
|
+
network: string;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Upload CID options
|
|
66
|
+
*/
|
|
67
|
+
type UploadCIDOptions = {
|
|
68
|
+
metadata?: PinataMetadata;
|
|
69
|
+
peerAddresses?: string[];
|
|
70
|
+
keys?: string;
|
|
71
|
+
groupId?: string;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Pin by CID response
|
|
75
|
+
*/
|
|
76
|
+
type PinByCIDResponse = {
|
|
77
|
+
id: string;
|
|
78
|
+
cid: string;
|
|
79
|
+
date_queued: string;
|
|
80
|
+
name: string;
|
|
81
|
+
status: string;
|
|
82
|
+
keyvalues: Record<string, any> | null;
|
|
83
|
+
host_nodes: string[] | null;
|
|
84
|
+
group_id: string | null;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Signed upload URL options
|
|
88
|
+
*/
|
|
89
|
+
type SignedUploadUrlOptions = {
|
|
90
|
+
date?: number;
|
|
91
|
+
expires: number;
|
|
92
|
+
groupId?: string;
|
|
93
|
+
name?: string;
|
|
94
|
+
keyvalues?: Record<string, string>;
|
|
95
|
+
vectorize?: boolean;
|
|
96
|
+
maxFileSize?: number;
|
|
97
|
+
mimeTypes?: string[];
|
|
98
|
+
streamable?: boolean;
|
|
99
|
+
car?: boolean;
|
|
100
|
+
cid_version?: CidVersion;
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* File list item
|
|
104
|
+
*/
|
|
105
|
+
type FileListItem = {
|
|
106
|
+
id: string;
|
|
107
|
+
name: string | null;
|
|
108
|
+
cid: "pending" | string;
|
|
109
|
+
size: number;
|
|
110
|
+
number_of_files: number;
|
|
111
|
+
mime_type: string;
|
|
112
|
+
keyvalues: Record<string, string>;
|
|
113
|
+
group_id: string | null;
|
|
114
|
+
created_at: string;
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* File list response
|
|
118
|
+
*/
|
|
119
|
+
type FileListResponse = {
|
|
120
|
+
files: FileListItem[];
|
|
121
|
+
next_page_token: string;
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* Update file options
|
|
125
|
+
*/
|
|
126
|
+
type UpdateFileOptions = {
|
|
127
|
+
id: string;
|
|
128
|
+
name?: string;
|
|
129
|
+
keyvalues?: Record<string, string>;
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* Delete response
|
|
133
|
+
*/
|
|
134
|
+
type DeleteResponse = {
|
|
135
|
+
id: string;
|
|
136
|
+
status: string;
|
|
137
|
+
};
|
|
138
|
+
/**
|
|
139
|
+
* Pin queue item
|
|
140
|
+
*/
|
|
141
|
+
type PinQueueItem = {
|
|
142
|
+
id: string;
|
|
143
|
+
cid?: string;
|
|
144
|
+
ipfs_pin_hash?: string;
|
|
145
|
+
date_queued: string;
|
|
146
|
+
name: string;
|
|
147
|
+
status: string;
|
|
148
|
+
keyvalues: any;
|
|
149
|
+
host_nodes: string[];
|
|
150
|
+
pin_policy: {
|
|
151
|
+
regions: {
|
|
152
|
+
id: string;
|
|
153
|
+
desiredReplicationCount: number;
|
|
154
|
+
}[];
|
|
155
|
+
version: number;
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
/**
|
|
159
|
+
* Pin queue response
|
|
160
|
+
*/
|
|
161
|
+
type PinQueueResponse = {
|
|
162
|
+
jobs: PinQueueItem[];
|
|
163
|
+
next_page_token: string;
|
|
164
|
+
};
|
|
165
|
+
/**
|
|
166
|
+
* Swap CID options
|
|
167
|
+
*/
|
|
168
|
+
type SwapCidOptions = {
|
|
169
|
+
cid: string;
|
|
170
|
+
swapCid: string;
|
|
171
|
+
};
|
|
172
|
+
/**
|
|
173
|
+
* Swap history options
|
|
174
|
+
*/
|
|
175
|
+
type SwapHistoryOptions = {
|
|
176
|
+
cid: string;
|
|
177
|
+
domain: string;
|
|
178
|
+
};
|
|
179
|
+
/**
|
|
180
|
+
* Swap CID response
|
|
181
|
+
*/
|
|
182
|
+
type SwapCidResponse = {
|
|
183
|
+
mapped_cid: string;
|
|
184
|
+
created_at: string;
|
|
185
|
+
};
|
|
186
|
+
/**
|
|
187
|
+
* Access link options
|
|
188
|
+
*/
|
|
189
|
+
type AccessLinkOptions = {
|
|
190
|
+
cid: string;
|
|
191
|
+
date?: number;
|
|
192
|
+
expires: number;
|
|
193
|
+
gateway?: string;
|
|
194
|
+
};
|
|
195
|
+
/**
|
|
196
|
+
* Group options
|
|
197
|
+
*/
|
|
198
|
+
type GroupOptions = {
|
|
199
|
+
name: string;
|
|
200
|
+
isPublic?: boolean;
|
|
201
|
+
};
|
|
202
|
+
/**
|
|
203
|
+
* Update group options
|
|
204
|
+
*/
|
|
205
|
+
type UpdateGroupOptions = {
|
|
206
|
+
groupId: string;
|
|
207
|
+
name?: string;
|
|
208
|
+
isPublic?: boolean;
|
|
209
|
+
};
|
|
210
|
+
/**
|
|
211
|
+
* Get group options
|
|
212
|
+
*/
|
|
213
|
+
type GetGroupOptions = {
|
|
214
|
+
groupId: string;
|
|
215
|
+
};
|
|
216
|
+
/**
|
|
217
|
+
* Group response item
|
|
218
|
+
*/
|
|
219
|
+
type GroupResponseItem = {
|
|
220
|
+
id: string;
|
|
221
|
+
is_public: boolean;
|
|
222
|
+
name: string;
|
|
223
|
+
createdAt: string;
|
|
224
|
+
};
|
|
225
|
+
/**
|
|
226
|
+
* Group list response
|
|
227
|
+
*/
|
|
228
|
+
type GroupListResponse = {
|
|
229
|
+
groups: GroupResponseItem[];
|
|
230
|
+
next_page_token: string;
|
|
231
|
+
};
|
|
232
|
+
/**
|
|
233
|
+
* Group CID options
|
|
234
|
+
*/
|
|
235
|
+
type GroupCIDOptions = {
|
|
236
|
+
groupId: string;
|
|
237
|
+
files: string[];
|
|
238
|
+
};
|
|
239
|
+
/**
|
|
240
|
+
* Update group files response
|
|
241
|
+
*/
|
|
242
|
+
type UpdateGroupFilesResponse = {
|
|
243
|
+
id: string;
|
|
244
|
+
status: string;
|
|
245
|
+
};
|
|
246
|
+
/**
|
|
247
|
+
* Analytics query
|
|
248
|
+
*/
|
|
249
|
+
type AnalyticsQuery = {
|
|
250
|
+
gateway_domain: string;
|
|
251
|
+
start_date: string;
|
|
252
|
+
end_date: string;
|
|
253
|
+
cid?: string;
|
|
254
|
+
file_name?: string;
|
|
255
|
+
user_agent?: string;
|
|
256
|
+
country?: string;
|
|
257
|
+
region?: string;
|
|
258
|
+
referer?: string;
|
|
259
|
+
limit?: number;
|
|
260
|
+
sort_order?: "asc" | "desc";
|
|
261
|
+
};
|
|
262
|
+
/**
|
|
263
|
+
* Top analytics query
|
|
264
|
+
*/
|
|
265
|
+
type TopAnalyticsQuery = AnalyticsQuery & {
|
|
266
|
+
sort_by: "requests" | "bandwidth";
|
|
267
|
+
attribute: "cid" | "country" | "region" | "user_agent" | "referer" | "file_name";
|
|
268
|
+
};
|
|
269
|
+
/**
|
|
270
|
+
* Top analytics response
|
|
271
|
+
*/
|
|
272
|
+
type TopAnalyticsResponse = {
|
|
273
|
+
data: TopAnalyticsItem[];
|
|
274
|
+
};
|
|
275
|
+
/**
|
|
276
|
+
* Top analytics item
|
|
277
|
+
*/
|
|
278
|
+
type TopAnalyticsItem = {
|
|
279
|
+
value: string;
|
|
280
|
+
requests: number;
|
|
281
|
+
bandwidth: number;
|
|
282
|
+
};
|
|
283
|
+
/**
|
|
284
|
+
* Time interval analytics query
|
|
285
|
+
*/
|
|
286
|
+
type TimeIntervalAnalyticsQuery = AnalyticsQuery & {
|
|
287
|
+
sort_by?: "requests" | "bandwidth";
|
|
288
|
+
date_interval: "day" | "week";
|
|
289
|
+
};
|
|
290
|
+
/**
|
|
291
|
+
* Time period item
|
|
292
|
+
*/
|
|
293
|
+
type TimePeriodItem = {
|
|
294
|
+
period_start_time: string;
|
|
295
|
+
requests: number;
|
|
296
|
+
bandwidth: number;
|
|
297
|
+
};
|
|
298
|
+
/**
|
|
299
|
+
* Time interval analytics response
|
|
300
|
+
*/
|
|
301
|
+
type TimeIntervalAnalyticsResponse = {
|
|
302
|
+
total_requests: number;
|
|
303
|
+
total_bandwidth: number;
|
|
304
|
+
time_periods: TimePeriodItem[];
|
|
305
|
+
};
|
|
306
|
+
//#endregion
|
|
307
|
+
export { AccessLinkOptions, DeleteResponse, FileListItem, FileListResponse, GetGroupOptions, GroupCIDOptions, GroupListResponse, GroupOptions, GroupResponseItem, PinByCIDResponse, PinQueueItem, PinQueueResponse, PinataConfig, SignedUploadUrlOptions, SwapCidOptions, SwapCidResponse, SwapHistoryOptions, TimeIntervalAnalyticsQuery, TimeIntervalAnalyticsResponse, TopAnalyticsQuery, TopAnalyticsResponse, UpdateFileOptions, UpdateGroupFilesResponse, UpdateGroupOptions, UploadCIDOptions, UploadOptions, UploadResponse };
|
|
308
|
+
//# sourceMappingURL=types.d.cts.map
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -8,7 +8,8 @@ const require_index$1 = require('./errors/index.cjs');
|
|
|
8
8
|
const require_manager = require('./upload/manager.cjs');
|
|
9
9
|
const require_pinner = require('./pinner.cjs');
|
|
10
10
|
const require_type_guards = require('./types/type-guards.cjs');
|
|
11
|
-
const require_adapter = require('./adapters/pinata/adapter.cjs');
|
|
11
|
+
const require_adapter = require('./adapters/pinata/v2/adapter.cjs');
|
|
12
|
+
const require_adapter$1 = require('./adapters/pinata/legacy/adapter.cjs');
|
|
12
13
|
require('./adapters/pinata/index.cjs');
|
|
13
14
|
|
|
14
15
|
exports.AuthenticationError = require_index$1.AuthenticationError;
|
|
@@ -36,6 +37,7 @@ exports.isAuthenticationError = require_type_guards.isAuthenticationError;
|
|
|
36
37
|
exports.isCarFile = require_car.isCarFile;
|
|
37
38
|
exports.isRetryable = require_type_guards.isRetryable;
|
|
38
39
|
exports.pinataAdapter = require_adapter.pinataAdapter;
|
|
40
|
+
exports.pinataLegacyAdapter = require_adapter$1.pinataLegacyAdapter;
|
|
39
41
|
exports.preprocessToCar = require_car.preprocessToCar;
|
|
40
42
|
exports.readableStreamToAsyncIterable = require_stream.readableStreamToAsyncIterable;
|
|
41
43
|
exports.setDriverFactory = require_unstorage_base.setDriverFactory;
|
package/dist/cjs/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PinnerConfig } from "./config.cjs";
|
|
2
2
|
import { UploadInput, UploadOperation, UploadOptions, UploadProgress, UploadResult } from "./types/upload.cjs";
|
|
3
|
-
import { RemoteAddOptions, RemoteLsOptions, RemotePin, RemotePins } from "./types/pin.cjs";
|
|
3
|
+
import { AbortOptions, RemoteAddOptions, RemoteLsOptions, RemotePin, RemotePins } from "./types/pin.cjs";
|
|
4
4
|
import { Pinner } from "./pinner.cjs";
|
|
5
5
|
import { UploadManager } from "./upload/manager.cjs";
|
|
6
6
|
import { CarPreprocessOptions, CarPreprocessResult, destroyCarPreprocessor, isCarFile, preprocessToCar } from "./upload/car.cjs";
|
|
@@ -10,5 +10,7 @@ import { FILE_EXTENSION_CAR, MIME_TYPE_CAR, MIME_TYPE_OCTET_STREAM } from "./typ
|
|
|
10
10
|
import { UnstorageBlockstoreOptions, setDriverFactory } from "./blockstore/unstorage-base.cjs";
|
|
11
11
|
import { createBlockstore, createDatastore } from "./blockstore/unstorage.cjs";
|
|
12
12
|
import { asyncGeneratorToReadableStream, calculateStreamSize, readableStreamToAsyncIterable, streamToBlob } from "./utils/stream.cjs";
|
|
13
|
-
import {
|
|
14
|
-
|
|
13
|
+
import { PinataAdapter } from "./adapters/pinata/v2/adapter-interface.cjs";
|
|
14
|
+
import { pinataAdapter } from "./adapters/pinata/v2/adapter.cjs";
|
|
15
|
+
import { PinataLegacyAdapter, pinataLegacyAdapter } from "./adapters/pinata/legacy/adapter.cjs";
|
|
16
|
+
export { type AbortOptions, AuthenticationError, type CarPreprocessOptions, type CarPreprocessResult, ConfigurationError, EmptyFileError, FILE_EXTENSION_CAR, MIME_TYPE_CAR, MIME_TYPE_OCTET_STREAM, NetworkError, NotFoundError, PinError, type PinataAdapter, type PinataLegacyAdapter, Pinner, type PinnerConfig, PinnerError, RateLimitError, type RemoteAddOptions, type RemoteLsOptions, type RemotePin, type RemotePins, TimeoutError, type UnstorageBlockstoreOptions, UploadError, type UploadInput, UploadManager, type UploadOperation, type UploadOptions, type UploadProgress, type UploadResult, ValidationError, asyncGeneratorToReadableStream, calculateStreamSize, createBlockstore, createDatastore, destroyCarPreprocessor, isAuthenticationError, isCarFile, isRetryable, pinataAdapter, pinataLegacyAdapter, preprocessToCar, readableStreamToAsyncIterable, setDriverFactory, streamToBlob };
|
package/dist/cjs/pin/client.cjs
CHANGED
|
@@ -64,13 +64,15 @@ var PinClient = class {
|
|
|
64
64
|
}, { signal: options?.signal });
|
|
65
65
|
}
|
|
66
66
|
async *rm(cid, options) {
|
|
67
|
-
const
|
|
68
|
-
const response = await client.pinsGet({ cid: [cid.toString()] }, { signal: options?.signal });
|
|
67
|
+
const response = await this.getClient().pinsGet({ cid: [cid.toString()] }, { signal: options?.signal });
|
|
69
68
|
await Promise.all([...response.results].map(async (result) => {
|
|
70
|
-
return
|
|
69
|
+
return this.rmByRequestId(result.requestid, options);
|
|
71
70
|
}));
|
|
72
71
|
yield cid;
|
|
73
72
|
}
|
|
73
|
+
async rmByRequestId(requestId, options) {
|
|
74
|
+
await this.getClient().pinsRequestidDelete({ requestid: requestId }, { signal: options?.signal });
|
|
75
|
+
}
|
|
74
76
|
mapResponse(response) {
|
|
75
77
|
return {
|
|
76
78
|
cid: multiformats_cid.CID.parse(response.pin.cid),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.cjs","names":["ConfigurationError","RemotePinningServiceClient","Configuration","NotFoundError","CID"],"sources":["../../../src/pin/client.ts"],"sourcesContent":["import {\n Configuration,\n type Pin,\n type PinStatus,\n RemotePinningServiceClient,\n} from \"@ipfs-shipyard/pinning-service-client\";\nimport type { PinnerConfig } from \"../config\";\nimport type {\n AbortOptions,\n RemoteAddOptions,\n RemoteLsOptions,\n RemotePin,\n RemotePins,\n} from \"@/types/pin\";\nimport { CID } from \"multiformats/cid\";\nimport { ConfigurationError, NotFoundError } from \"@/errors\";\n\nexport class PinClient implements RemotePins {\n private client: RemotePinningServiceClient | null = null;\n private config: PinnerConfig;\n\n constructor(config: PinnerConfig) {\n this.config = config;\n }\n\n protected getClient(): RemotePinningServiceClient {\n if (this.client) {\n return this.client;\n }\n\n if (!this.config.jwt) {\n throw new ConfigurationError(\"JWT token is required\");\n }\n\n const configuration = new Configuration({\n endpointUrl: this.config.endpoint,\n accessToken: this.config.jwt,\n fetchApi: this.config.fetch ?? fetch,\n });\n\n this.client = new RemotePinningServiceClient(configuration);\n return this.client;\n }\n\n async *add(\n cid: CID,\n options?: RemoteAddOptions,\n ): AsyncGenerator<CID, void, undefined> {\n const client = this.getClient();\n\n const pin: Pin = {\n cid: cid.toString(),\n name: options?.name,\n meta: options?.metadata,\n origins: options?.origins,\n };\n\n await client.pinsPost({ pin }, { signal: options?.signal });\n\n yield cid;\n }\n\n async *ls(\n options?: RemoteLsOptions,\n ): AsyncGenerator<RemotePin, void, undefined> {\n const client = this.getClient();\n const response = await client.pinsGet(this.normalizeListOptions(options), {\n signal: options?.signal,\n });\n\n for (const result of response.results) {\n yield this.mapResponse(result);\n }\n }\n\n async isPinned(cid: CID, options?: AbortOptions): Promise<boolean> {\n try {\n await this.get(cid, options);\n return true;\n } catch {\n return false;\n }\n }\n\n async get(cid: CID, options?: AbortOptions): Promise<RemotePin> {\n const client = this.getClient();\n const response = await client.pinsGet(\n { cid: [cid.toString()] },\n {\n signal: options?.signal,\n },\n );\n\n if (response.results.length === 0) {\n throw new NotFoundError(`Pin not found for CID: ${cid.toString()}`);\n }\n\n return this.mapResponse(response.results[0]);\n }\n\n async setMetadata(\n cid: CID,\n metadata: Record<string, string> | undefined,\n options?: AbortOptions,\n ): Promise<void> {\n const client = this.getClient();\n const response = await client.pinsGet(\n { cid: [cid.toString()] },\n {\n signal: options?.signal,\n },\n );\n\n if (response.results.length === 0) {\n throw new NotFoundError(`Pin not found for CID: ${cid.toString()}`);\n }\n\n const pin = response.results[0];\n await client.pinsRequestidPost(\n {\n requestid: pin.requestid,\n pin: {\n cid: pin.pin.cid,\n name: pin.pin.name,\n meta: metadata,\n origins: pin.pin.origins,\n },\n },\n { signal: options?.signal },\n );\n }\n\n async *rm(\n cid: CID,\n options?: AbortOptions,\n ): AsyncGenerator<CID, void, undefined> {\n const client = this.getClient();\n const response = await client.pinsGet(\n { cid: [cid.toString()] },\n { signal: options?.signal },\n );\n\n await Promise.all(\n [...response.results].map(async (result) => {\n return client.pinsRequestidDelete(\n
|
|
1
|
+
{"version":3,"file":"client.cjs","names":["ConfigurationError","RemotePinningServiceClient","Configuration","NotFoundError","CID"],"sources":["../../../src/pin/client.ts"],"sourcesContent":["import {\n Configuration,\n type Pin,\n type PinStatus,\n RemotePinningServiceClient,\n} from \"@ipfs-shipyard/pinning-service-client\";\nimport type { PinnerConfig } from \"../config\";\nimport type {\n AbortOptions,\n RemoteAddOptions,\n RemoteLsOptions,\n RemotePin,\n RemotePins,\n} from \"@/types/pin\";\nimport { CID } from \"multiformats/cid\";\nimport { ConfigurationError, NotFoundError } from \"@/errors\";\n\nexport class PinClient implements RemotePins {\n private client: RemotePinningServiceClient | null = null;\n private config: PinnerConfig;\n\n constructor(config: PinnerConfig) {\n this.config = config;\n }\n\n protected getClient(): RemotePinningServiceClient {\n if (this.client) {\n return this.client;\n }\n\n if (!this.config.jwt) {\n throw new ConfigurationError(\"JWT token is required\");\n }\n\n const configuration = new Configuration({\n endpointUrl: this.config.endpoint,\n accessToken: this.config.jwt,\n fetchApi: this.config.fetch ?? fetch,\n });\n\n this.client = new RemotePinningServiceClient(configuration);\n return this.client;\n }\n\n async *add(\n cid: CID,\n options?: RemoteAddOptions,\n ): AsyncGenerator<CID, void, undefined> {\n const client = this.getClient();\n\n const pin: Pin = {\n cid: cid.toString(),\n name: options?.name,\n meta: options?.metadata,\n origins: options?.origins,\n };\n\n await client.pinsPost({ pin }, { signal: options?.signal });\n\n yield cid;\n }\n\n async *ls(\n options?: RemoteLsOptions,\n ): AsyncGenerator<RemotePin, void, undefined> {\n const client = this.getClient();\n const response = await client.pinsGet(this.normalizeListOptions(options), {\n signal: options?.signal,\n });\n\n for (const result of response.results) {\n yield this.mapResponse(result);\n }\n }\n\n async isPinned(cid: CID, options?: AbortOptions): Promise<boolean> {\n try {\n await this.get(cid, options);\n return true;\n } catch {\n return false;\n }\n }\n\n async get(cid: CID, options?: AbortOptions): Promise<RemotePin> {\n const client = this.getClient();\n const response = await client.pinsGet(\n { cid: [cid.toString()] },\n {\n signal: options?.signal,\n },\n );\n\n if (response.results.length === 0) {\n throw new NotFoundError(`Pin not found for CID: ${cid.toString()}`);\n }\n\n return this.mapResponse(response.results[0]);\n }\n\n async setMetadata(\n cid: CID,\n metadata: Record<string, string> | undefined,\n options?: AbortOptions,\n ): Promise<void> {\n const client = this.getClient();\n const response = await client.pinsGet(\n { cid: [cid.toString()] },\n {\n signal: options?.signal,\n },\n );\n\n if (response.results.length === 0) {\n throw new NotFoundError(`Pin not found for CID: ${cid.toString()}`);\n }\n\n const pin = response.results[0];\n await client.pinsRequestidPost(\n {\n requestid: pin.requestid,\n pin: {\n cid: pin.pin.cid,\n name: pin.pin.name,\n meta: metadata,\n origins: pin.pin.origins,\n },\n },\n { signal: options?.signal },\n );\n }\n\n async *rm(\n cid: CID,\n options?: AbortOptions,\n ): AsyncGenerator<CID, void, undefined> {\n const client = this.getClient();\n const response = await client.pinsGet(\n { cid: [cid.toString()] },\n { signal: options?.signal },\n );\n\n // Delete all pins for this CID by their request IDs\n await Promise.all(\n [...response.results].map(async (result) => {\n return this.rmByRequestId(result.requestid, options);\n }),\n );\n\n yield cid;\n }\n\n async rmByRequestId(requestId: string, options?: AbortOptions): Promise<void> {\n const client = this.getClient();\n await client.pinsRequestidDelete(\n { requestid: requestId },\n { signal: options?.signal },\n );\n }\n\n private mapResponse(response: PinStatus): RemotePin {\n return {\n cid: CID.parse(response.pin.cid),\n name: response.pin.name,\n status: response.status,\n created: response.created,\n size: response.pin.meta?.size\n ? parseInt(response.pin.meta.size, 10)\n : undefined,\n metadata: response.pin.meta,\n };\n }\n\n private normalizeListOptions(\n options?: RemoteLsOptions,\n ): Record<string, unknown> {\n const request: Record<string, unknown> = {};\n\n if (options?.limit !== undefined) {\n request.limit = options.limit;\n }\n if (options?.cursor !== undefined) {\n request.after = options.cursor;\n }\n if (options?.status !== undefined) {\n request.status = options.status;\n }\n if (options?.name !== undefined) {\n request.name = options.name;\n }\n\n return request;\n }\n}\n"],"mappings":";;;;;;AAiBA,IAAa,YAAb,MAA6C;CAC3C,AAAQ,SAA4C;CACpD,AAAQ;CAER,YAAY,QAAsB;AAChC,OAAK,SAAS;;CAGhB,AAAU,YAAwC;AAChD,MAAI,KAAK,OACP,QAAO,KAAK;AAGd,MAAI,CAAC,KAAK,OAAO,IACf,OAAM,IAAIA,iCAAmB,wBAAwB;AASvD,OAAK,SAAS,IAAIC,iEANI,IAAIC,oDAAc;GACtC,aAAa,KAAK,OAAO;GACzB,aAAa,KAAK,OAAO;GACzB,UAAU,KAAK,OAAO,SAAS;GAChC,CAAC,CAEyD;AAC3D,SAAO,KAAK;;CAGd,OAAO,IACL,KACA,SACsC;EACtC,MAAM,SAAS,KAAK,WAAW;EAE/B,MAAM,MAAW;GACf,KAAK,IAAI,UAAU;GACnB,MAAM,SAAS;GACf,MAAM,SAAS;GACf,SAAS,SAAS;GACnB;AAED,QAAM,OAAO,SAAS,EAAE,KAAK,EAAE,EAAE,QAAQ,SAAS,QAAQ,CAAC;AAE3D,QAAM;;CAGR,OAAO,GACL,SAC4C;EAE5C,MAAM,WAAW,MADF,KAAK,WAAW,CACD,QAAQ,KAAK,qBAAqB,QAAQ,EAAE,EACxE,QAAQ,SAAS,QAClB,CAAC;AAEF,OAAK,MAAM,UAAU,SAAS,QAC5B,OAAM,KAAK,YAAY,OAAO;;CAIlC,MAAM,SAAS,KAAU,SAA0C;AACjE,MAAI;AACF,SAAM,KAAK,IAAI,KAAK,QAAQ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AAQ,YAAY,UAAgC;AAClD,SAAO;GACL,KAAKC,qBAAI,MAAM,SAAS,IAAI,IAAI;GAChC,MAAM,SAAS,IAAI;GACnB,QAAQ,SAAS;GACjB,SAAS,SAAS;GAClB,MAAM,SAAS,IAAI,MAAM,OACrB,SAAS,SAAS,IAAI,KAAK,MAAM,GAAG,GACpC;GACJ,UAAU,SAAS,IAAI;GACxB;;CAGH,AAAQ,qBACN,SACyB;EACzB,MAAM,UAAmC,EAAE;AAE3C,MAAI,SAAS,UAAU,OACrB,SAAQ,QAAQ,QAAQ;AAE1B,MAAI,SAAS,WAAW,OACtB,SAAQ,QAAQ,QAAQ;AAE1B,MAAI,SAAS,WAAW,OACtB,SAAQ,SAAS,QAAQ;AAE3B,MAAI,SAAS,SAAS,OACpB,SAAQ,OAAO,QAAQ;AAGzB,SAAO"}
|
package/dist/cjs/pinner.cjs
CHANGED
|
@@ -114,6 +114,12 @@ var Pinner = class {
|
|
|
114
114
|
for await (const _ of generator);
|
|
115
115
|
}
|
|
116
116
|
/**
|
|
117
|
+
* Remove a pin by request ID. The block may be deleted when garbage collection is run.
|
|
118
|
+
*/
|
|
119
|
+
async unpinByRequestId(requestId, options) {
|
|
120
|
+
return this.pins.rmByRequestId(requestId, options);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
117
123
|
* Destroy the client and cleanup resources.
|
|
118
124
|
*/
|
|
119
125
|
destroy() {
|
package/dist/cjs/pinner.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pinner.cjs","names":["UploadManager","PinClient","createUploadBuilderNamespace","CID"],"sources":["../../src/pinner.ts"],"sourcesContent":["import type { PinnerConfig } from \"./config\";\nimport { UploadManager } from \"./upload\";\nimport { PinClient } from \"./pin\";\nimport type { UploadMethodAndBuilder } from \"@/upload/builder\";\nimport { createUploadBuilderNamespace } from \"@/upload/builder\";\nimport type {\n UploadOperation,\n UploadOptions,\n UploadResult,\n} from \"@/types/upload\";\nimport type { OperationPollingOptions } from \"@lumeweb/portal-sdk\";\nimport type {\n AbortOptions,\n RemoteAddOptions,\n RemoteLsOptions,\n RemotePin,\n RemotePins,\n} from \"@/types/pin\";\nimport { CID } from \"multiformats/cid\";\n\nexport class Pinner {\n private uploadManager: UploadManager;\n private _pins: RemotePins;\n private _upload?: UploadMethodAndBuilder;\n\n constructor(config: PinnerConfig) {\n this.uploadManager = new UploadManager(config);\n this._pins = new PinClient(config);\n }\n\n /**\n * Access the remote pins interface.\n */\n get pins(): RemotePins {\n return this._pins;\n }\n\n /**\n * Upload interface that works as both a method and a builder namespace.\n *\n * As a method: upload(file, options) -> UploadOperation\n * As a property: upload.file(), upload.json(), etc. -> Builder\n */\n get upload(): UploadMethodAndBuilder {\n if (!this._upload) {\n const builderNamespace = createUploadBuilderNamespace(this);\n const uploadMethod = async (\n file: File,\n options?: UploadOptions,\n ): Promise<UploadOperation> => {\n return this.uploadManager.upload(file, options);\n };\n\n this._upload = new Proxy(uploadMethod, {\n get(target, prop) {\n if (prop in builderNamespace) {\n return Reflect.get(builderNamespace, prop);\n }\n return Reflect.get(target, prop);\n },\n }) as UploadMethodAndBuilder;\n }\n return this._upload;\n }\n\n /**\n * Upload a file and wait for completion.\n * Convenience method for simple use cases where controls aren't needed.\n */\n async uploadAndWait(\n file: File,\n options?: UploadOptions,\n ): Promise<UploadResult> {\n const operation = await this.upload(file, options);\n return operation.result;\n }\n\n /**\n * Wait for an operation to complete or reach a settled state.\n * @param input Either an operation ID (number) or an UploadResult\n * @param options Polling options (interval, timeout, settledStates)\n * @returns UploadResult with operation status merged in\n */\n async waitForOperation(\n input: number | UploadResult,\n options?: OperationPollingOptions,\n ): Promise<UploadResult> {\n return this.uploadManager.waitForOperation(input, options);\n }\n\n /**\n * Upload a directory to IPFS.\n */\n async uploadDirectory(\n files: File[],\n options?: UploadOptions,\n ): Promise<UploadOperation> {\n return this.uploadManager.uploadDirectory(files, options);\n }\n\n /**\n * Upload a CAR file without preprocessing.\n * This is useful for passthrough of pre-generated CAR files.\n */\n async uploadCar(\n file: File | ReadableStream<Uint8Array>,\n options?: UploadOptions,\n ): Promise<UploadOperation> {\n return this.uploadManager.uploadCar(file, options);\n }\n\n /**\n * Pin existing content by CID.\n */\n async pinByHash(\n cid: string | CID,\n options?: RemoteAddOptions,\n ): Promise<AsyncGenerator<CID, void, undefined>> {\n const cidObj = typeof cid === \"string\" ? CID.parse(cid) : cid;\n return this.pins.add(cidObj, options);\n }\n\n /**\n * List pinned content.\n */\n async listPins(options?: RemoteLsOptions): Promise<RemotePin[]> {\n const pins: RemotePin[] = [];\n for await (const pin of this.pins.ls(options)) {\n pins.push(pin);\n }\n return pins;\n }\n\n /**\n * Get pin status.\n */\n async getPinStatus(cid: string | CID): Promise<RemotePin> {\n const cidObj = typeof cid === \"string\" ? CID.parse(cid) : cid;\n return this.pins.get(cidObj);\n }\n\n /**\n * Check if content is pinned.\n */\n async isPinned(cid: string | CID): Promise<boolean> {\n const cidObj = typeof cid === \"string\" ? CID.parse(cid) : cid;\n return this.pins.isPinned(cidObj);\n }\n\n /**\n * Update pin metadata.\n */\n async setPinMetadata(\n cid: string | CID,\n metadata: Record<string, string> | undefined,\n ): Promise<void> {\n const cidObj = typeof cid === \"string\" ? CID.parse(cid) : cid;\n return this.pins.setMetadata(cidObj, metadata);\n }\n\n /**\n * Remove a pin. The block may be deleted when garbage collection is run.\n */\n async unpin(cid: string | CID, options?: AbortOptions): Promise<void> {\n const cidObj = typeof cid === \"string\" ? CID.parse(cid) : cid;\n const generator = this.pins.rm(cidObj, options);\n for await (const _ of generator) {\n // Consume the generator to complete the unpin operation\n }\n }\n\n /**\n * Destroy the client and cleanup resources.\n */\n destroy(): void {\n this.uploadManager.destroy();\n }\n}\n"],"mappings":";;;;;;;;;AAoBA,IAAa,SAAb,MAAoB;CAClB,AAAQ;CACR,AAAQ;CACR,AAAQ;CAER,YAAY,QAAsB;AAChC,OAAK,gBAAgB,IAAIA,8BAAc,OAAO;AAC9C,OAAK,QAAQ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D,MAAM,SAAS,OAAO,QAAQ,WAAWA,qBAAI,MAAM,IAAI,GAAG;AAC1D,SAAO,KAAK,KAAK,SAAS,OAAO;;;;;CAMnC,MAAM,eACJ,KACA,UACe;EACf,MAAM,SAAS,OAAO,QAAQ,WAAWA,qBAAI,MAAM,IAAI,GAAG;AAC1D,SAAO,KAAK,KAAK,YAAY,QAAQ,SAAS;;;;;CAMhD,MAAM,MAAM,KAAmB,SAAuC;EACpE,MAAM,SAAS,OAAO,QAAQ,WAAWA,qBAAI,MAAM,IAAI,GAAG;EAC1D,MAAM,YAAY,KAAK,KAAK,GAAG,QAAQ,QAAQ;AAC/C,aAAW,MAAM,KAAK;;;;;CAQxB,UAAgB;AACd,OAAK,cAAc,SAAS"}
|
|
1
|
+
{"version":3,"file":"pinner.cjs","names":["UploadManager","PinClient","createUploadBuilderNamespace","CID"],"sources":["../../src/pinner.ts"],"sourcesContent":["import type { PinnerConfig } from \"./config\";\nimport { UploadManager } from \"./upload\";\nimport { PinClient } from \"./pin\";\nimport type { UploadMethodAndBuilder } from \"@/upload/builder\";\nimport { createUploadBuilderNamespace } from \"@/upload/builder\";\nimport type {\n UploadOperation,\n UploadOptions,\n UploadResult,\n} from \"@/types/upload\";\nimport type { OperationPollingOptions } from \"@lumeweb/portal-sdk\";\nimport type {\n AbortOptions,\n RemoteAddOptions,\n RemoteLsOptions,\n RemotePin,\n RemotePins,\n} from \"@/types/pin\";\nimport { CID } from \"multiformats/cid\";\n\nexport class Pinner {\n private uploadManager: UploadManager;\n private _pins: RemotePins;\n private _upload?: UploadMethodAndBuilder;\n\n constructor(config: PinnerConfig) {\n this.uploadManager = new UploadManager(config);\n this._pins = new PinClient(config);\n }\n\n /**\n * Access the remote pins interface.\n */\n get pins(): RemotePins {\n return this._pins;\n }\n\n /**\n * Upload interface that works as both a method and a builder namespace.\n *\n * As a method: upload(file, options) -> UploadOperation\n * As a property: upload.file(), upload.json(), etc. -> Builder\n */\n get upload(): UploadMethodAndBuilder {\n if (!this._upload) {\n const builderNamespace = createUploadBuilderNamespace(this);\n const uploadMethod = async (\n file: File,\n options?: UploadOptions,\n ): Promise<UploadOperation> => {\n return this.uploadManager.upload(file, options);\n };\n\n this._upload = new Proxy(uploadMethod, {\n get(target, prop) {\n if (prop in builderNamespace) {\n return Reflect.get(builderNamespace, prop);\n }\n return Reflect.get(target, prop);\n },\n }) as UploadMethodAndBuilder;\n }\n return this._upload;\n }\n\n /**\n * Upload a file and wait for completion.\n * Convenience method for simple use cases where controls aren't needed.\n */\n async uploadAndWait(\n file: File,\n options?: UploadOptions,\n ): Promise<UploadResult> {\n const operation = await this.upload(file, options);\n return operation.result;\n }\n\n /**\n * Wait for an operation to complete or reach a settled state.\n * @param input Either an operation ID (number) or an UploadResult\n * @param options Polling options (interval, timeout, settledStates)\n * @returns UploadResult with operation status merged in\n */\n async waitForOperation(\n input: number | UploadResult,\n options?: OperationPollingOptions,\n ): Promise<UploadResult> {\n return this.uploadManager.waitForOperation(input, options);\n }\n\n /**\n * Upload a directory to IPFS.\n */\n async uploadDirectory(\n files: File[],\n options?: UploadOptions,\n ): Promise<UploadOperation> {\n return this.uploadManager.uploadDirectory(files, options);\n }\n\n /**\n * Upload a CAR file without preprocessing.\n * This is useful for passthrough of pre-generated CAR files.\n */\n async uploadCar(\n file: File | ReadableStream<Uint8Array>,\n options?: UploadOptions,\n ): Promise<UploadOperation> {\n return this.uploadManager.uploadCar(file, options);\n }\n\n /**\n * Pin existing content by CID.\n */\n async pinByHash(\n cid: string | CID,\n options?: RemoteAddOptions,\n ): Promise<AsyncGenerator<CID, void, undefined>> {\n const cidObj = typeof cid === \"string\" ? CID.parse(cid) : cid;\n return this.pins.add(cidObj, options);\n }\n\n /**\n * List pinned content.\n */\n async listPins(options?: RemoteLsOptions): Promise<RemotePin[]> {\n const pins: RemotePin[] = [];\n for await (const pin of this.pins.ls(options)) {\n pins.push(pin);\n }\n return pins;\n }\n\n /**\n * Get pin status.\n */\n async getPinStatus(cid: string | CID): Promise<RemotePin> {\n const cidObj = typeof cid === \"string\" ? CID.parse(cid) : cid;\n return this.pins.get(cidObj);\n }\n\n /**\n * Check if content is pinned.\n */\n async isPinned(cid: string | CID): Promise<boolean> {\n const cidObj = typeof cid === \"string\" ? CID.parse(cid) : cid;\n return this.pins.isPinned(cidObj);\n }\n\n /**\n * Update pin metadata.\n */\n async setPinMetadata(\n cid: string | CID,\n metadata: Record<string, string> | undefined,\n ): Promise<void> {\n const cidObj = typeof cid === \"string\" ? CID.parse(cid) : cid;\n return this.pins.setMetadata(cidObj, metadata);\n }\n\n /**\n * Remove a pin. The block may be deleted when garbage collection is run.\n */\n async unpin(cid: string | CID, options?: AbortOptions): Promise<void> {\n const cidObj = typeof cid === \"string\" ? CID.parse(cid) : cid;\n const generator = this.pins.rm(cidObj, options);\n for await (const _ of generator) {\n // Consume the generator to complete the unpin operation\n }\n }\n\n /**\n * Remove a pin by request ID. The block may be deleted when garbage collection is run.\n */\n async unpinByRequestId(requestId: string, options?: AbortOptions): Promise<void> {\n return this.pins.rmByRequestId(requestId, options);\n }\n\n /**\n * Destroy the client and cleanup resources.\n */\n destroy(): void {\n this.uploadManager.destroy();\n }\n}\n"],"mappings":";;;;;;;;;AAoBA,IAAa,SAAb,MAAoB;CAClB,AAAQ;CACR,AAAQ;CACR,AAAQ;CAER,YAAY,QAAsB;AAChC,OAAK,gBAAgB,IAAIA,8BAAc,OAAO;AAC9C,OAAK,QAAQ,IAAIC,yBAAU,OAAO;;;;;CAMpC,IAAI,OAAmB;AACrB,SAAO,KAAK;;;;;;;;CASd,IAAI,SAAiC;AACnC,MAAI,CAAC,KAAK,SAAS;GACjB,MAAM,mBAAmBC,6CAA6B,KAAK;GAC3D,MAAM,eAAe,OACnB,MACA,YAC6B;AAC7B,WAAO,KAAK,cAAc,OAAO,MAAM,QAAQ;;AAGjD,QAAK,UAAU,IAAI,MAAM,cAAc,EACrC,IAAI,QAAQ,MAAM;AAChB,QAAI,QAAQ,iBACV,QAAO,QAAQ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AC1D,MAAM,YAAY,KAAK,KAAK,GAAG,QAAQ,QAAQ;AAC/C,aAAW,MAAM,KAAK;;;;;CAQxB,MAAM,iBAAiB,WAAmB,SAAuC;AAC/E,SAAO,KAAK,KAAK,cAAc,WAAW,QAAQ;;;;;CAMpD,UAAgB;AACd,OAAK,cAAc,SAAS"}
|
package/dist/cjs/pinner.d.cts
CHANGED
|
@@ -67,6 +67,10 @@ declare class Pinner {
|
|
|
67
67
|
* Remove a pin. The block may be deleted when garbage collection is run.
|
|
68
68
|
*/
|
|
69
69
|
unpin(cid: string | CID, options?: AbortOptions): Promise<void>;
|
|
70
|
+
/**
|
|
71
|
+
* Remove a pin by request ID. The block may be deleted when garbage collection is run.
|
|
72
|
+
*/
|
|
73
|
+
unpinByRequestId(requestId: string, options?: AbortOptions): Promise<void>;
|
|
70
74
|
/**
|
|
71
75
|
* Destroy the client and cleanup resources.
|
|
72
76
|
*/
|
|
@@ -3,7 +3,11 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* Default API endpoint URL for the pinning service.
|
|
5
5
|
*/
|
|
6
|
-
const DEFAULT_ENDPOINT = "https://
|
|
6
|
+
const DEFAULT_ENDPOINT = "https://ipfs.pinner.xyz";
|
|
7
|
+
/**
|
|
8
|
+
* Default IPFS gateway URL for content retrieval.
|
|
9
|
+
*/
|
|
10
|
+
const DEFAULT_GATEWAY = "https://dweb.link";
|
|
7
11
|
/**
|
|
8
12
|
* Default TUS upload size threshold (100MB).
|
|
9
13
|
* Files larger than this will use TUS protocol for resumable uploads.
|
|
@@ -30,5 +34,6 @@ exports.DEFAULT_BLOCKSTORE_BASE = DEFAULT_BLOCKSTORE_BASE;
|
|
|
30
34
|
exports.DEFAULT_BLOCKSTORE_FS_BASE = DEFAULT_BLOCKSTORE_FS_BASE;
|
|
31
35
|
exports.DEFAULT_BLOCKSTORE_PREFIX = DEFAULT_BLOCKSTORE_PREFIX;
|
|
32
36
|
exports.DEFAULT_ENDPOINT = DEFAULT_ENDPOINT;
|
|
37
|
+
exports.DEFAULT_GATEWAY = DEFAULT_GATEWAY;
|
|
33
38
|
exports.TUS_SIZE_THRESHOLD = TUS_SIZE_THRESHOLD;
|
|
34
39
|
//# sourceMappingURL=constants.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.cjs","names":[],"sources":["../../../src/types/constants.ts"],"sourcesContent":["/**\n * Default API endpoint URL for the pinning service.\n */\nexport const DEFAULT_ENDPOINT = \"https://
|
|
1
|
+
{"version":3,"file":"constants.cjs","names":[],"sources":["../../../src/types/constants.ts"],"sourcesContent":["/**\n * Default API endpoint URL for the pinning service.\n */\nexport const DEFAULT_ENDPOINT = \"https://ipfs.pinner.xyz\";\n\n/**\n * Default IPFS gateway URL for content retrieval.\n */\nexport const DEFAULT_GATEWAY = \"https://dweb.link\";\n\n/**\n * Default TUS upload size threshold (100MB).\n * Files larger than this will use TUS protocol for resumable uploads.\n */\nexport const TUS_SIZE_THRESHOLD = 100 * 1024 * 1024;\n\n/**\n * Default base path for Helia datastore storage.\n */\nexport const DEFAULT_DATASTORE_BASE = \"pinner-helia-data\";\n\n/**\n * Default key prefix for blockstore keys.\n * This is prepended to CID strings in storage keys.\n */\nexport const DEFAULT_BLOCKSTORE_PREFIX = \"pinner-helia-blocks\";\n\n/**\n * Default base path for blockstore storage driver.\n * For IndexedDB: \"pinner:\" - the database name prefix\n * For filesystem: \"./.pinner-blocks\" - the directory path\n */\nexport const DEFAULT_BLOCKSTORE_BASE = \"pinner:\";\n\n/**\n * Default base path for blockstore filesystem storage driver (Node.js).\n */\nexport const DEFAULT_BLOCKSTORE_FS_BASE = \"./.pinner-blocks\";\n\n/**\n * Default base path for datastore filesystem storage driver (Node.js).\n */\nexport const DEFAULT_DATASTORE_FS_BASE = \"./.pinner-data\";\n"],"mappings":";;;;;AAGA,MAAa,mBAAmB;;;;AAKhC,MAAa,kBAAkB;;;;;AAM/B,MAAa,qBAAqB,MAAM,OAAO;;;;;AAW/C,MAAa,4BAA4B;;;;;;AAOzC,MAAa,0BAA0B;;;;AAKvC,MAAa,6BAA6B"}
|
package/dist/cjs/types/pin.d.cts
CHANGED
|
@@ -68,6 +68,10 @@ interface RemotePins {
|
|
|
68
68
|
* Remove a pin. The block may be deleted when garbage collection is run.
|
|
69
69
|
*/
|
|
70
70
|
rm(cid: CID, options?: AbortOptions): AsyncGenerator<CID, void, undefined>;
|
|
71
|
+
/**
|
|
72
|
+
* Remove a pin by request ID. The block may be deleted when garbage collection is run.
|
|
73
|
+
*/
|
|
74
|
+
rmByRequestId(requestId: string, options?: AbortOptions): Promise<void>;
|
|
71
75
|
}
|
|
72
76
|
//#endregion
|
|
73
77
|
export { AbortOptions, RemoteAddOptions, RemoteLsOptions, RemotePin, RemotePins };
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import "./
|
|
4
|
-
import "./
|
|
1
|
+
import { PinataAdapter } from "./v2/adapter-interface.js";
|
|
2
|
+
import { pinataAdapter } from "./v2/adapter.js";
|
|
3
|
+
import "./v2/index.js";
|
|
4
|
+
import { AnalyticsQuery, FileListItem, FileListQuery, FileListResponse, PinJobItem, PinJobQuery, PinJobResponse, PinataConfig, PinataMetadata, SignedUrlOptions, SwapCidOptions, SwapCidResponse, SwapHistoryOptions, TimeIntervalAnalyticsQuery, TimeIntervalAnalyticsResponse, TimePeriodItem, TopAnalyticsItem, TopAnalyticsQuery, TopAnalyticsResponse, UploadOptions, UploadResponse } from "./shared/types.js";
|
|
5
|
+
import { PinataLegacyAdapter, pinataLegacyAdapter } from "./legacy/adapter.js";
|
|
6
|
+
import "./legacy/index.js";
|
|
7
|
+
import "./shared/index.js";
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
1
|
+
import { createFileListItem, createPinJobItem, createUploadResponse, notSupported, parseCID } from "./shared/utils.js";
|
|
2
|
+
import { pinataAdapter } from "./v2/adapter.js";
|
|
3
|
+
import "./v2/index.js";
|
|
4
|
+
import { pinataLegacyAdapter } from "./legacy/adapter.js";
|
|
5
|
+
import "./legacy/index.js";
|
|
6
|
+
import "./shared/index.js";
|