@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,3 @@
|
|
|
1
|
+
import { AccessLinkOptions, AnalyticsQuery, CidVersion, DeleteResponse, FileListItem, FileListResponse, GetGroupOptions, GroupCIDOptions, GroupListResponse, GroupOptions, GroupResponseItem, PinByCIDResponse, PinQueueItem, PinQueueResponse, PinataConfig, PinataMetadata, SignedUploadUrlOptions, SwapCidOptions, SwapCidResponse, SwapHistoryOptions, TimeIntervalAnalyticsQuery, TimeIntervalAnalyticsResponse, TimePeriodItem, TopAnalyticsItem, TopAnalyticsQuery, TopAnalyticsResponse, UpdateFileOptions, UpdateGroupFilesResponse, UpdateGroupOptions, UploadCIDOptions, UploadOptions, UploadResponse } from "./types.js";
|
|
2
|
+
import { PinataAdapter } from "./adapter-interface.js";
|
|
3
|
+
import { pinataAdapter } from "./adapter.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import { pinataAdapter } from "./adapter.js";
|
|
@@ -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, AnalyticsQuery, CidVersion, DeleteResponse, FileListItem, FileListResponse, GetGroupOptions, GroupCIDOptions, GroupListResponse, GroupOptions, GroupResponseItem, PinByCIDResponse, PinQueueItem, PinQueueResponse, PinataConfig, PinataMetadata, SignedUploadUrlOptions, SwapCidOptions, SwapCidResponse, SwapHistoryOptions, TimeIntervalAnalyticsQuery, TimeIntervalAnalyticsResponse, TimePeriodItem, TopAnalyticsItem, TopAnalyticsQuery, TopAnalyticsResponse, UpdateFileOptions, UpdateGroupFilesResponse, UpdateGroupOptions, UploadCIDOptions, UploadOptions, UploadResponse };
|
|
308
|
+
//# sourceMappingURL=types.d.ts.map
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PinnerConfig } from "./config.js";
|
|
2
2
|
import { UploadInput, UploadOperation, UploadOptions, UploadProgress, UploadResult } from "./types/upload.js";
|
|
3
|
-
import { RemoteAddOptions, RemoteLsOptions, RemotePin, RemotePins } from "./types/pin.js";
|
|
3
|
+
import { AbortOptions, RemoteAddOptions, RemoteLsOptions, RemotePin, RemotePins } from "./types/pin.js";
|
|
4
4
|
import { Pinner } from "./pinner.js";
|
|
5
5
|
import { UploadManager } from "./upload/manager.js";
|
|
6
6
|
import { CarPreprocessOptions, CarPreprocessResult, destroyCarPreprocessor, isCarFile, preprocessToCar } from "./upload/car.js";
|
|
@@ -11,6 +11,8 @@ import { UnstorageBlockstoreOptions, setDriverFactory } from "./blockstore/unsto
|
|
|
11
11
|
import { createBlockstore, createDatastore } from "./blockstore/unstorage.js";
|
|
12
12
|
import "./blockstore/index.js";
|
|
13
13
|
import { asyncGeneratorToReadableStream, calculateStreamSize, readableStreamToAsyncIterable, streamToBlob } from "./utils/stream.js";
|
|
14
|
-
import {
|
|
14
|
+
import { PinataAdapter } from "./adapters/pinata/v2/adapter-interface.js";
|
|
15
|
+
import { pinataAdapter } from "./adapters/pinata/v2/adapter.js";
|
|
16
|
+
import { PinataLegacyAdapter, pinataLegacyAdapter } from "./adapters/pinata/legacy/adapter.js";
|
|
15
17
|
import "./adapters/pinata/index.js";
|
|
16
|
-
export { AuthenticationError, type CarPreprocessOptions, type CarPreprocessResult, ConfigurationError, EmptyFileError, FILE_EXTENSION_CAR, MIME_TYPE_CAR, MIME_TYPE_OCTET_STREAM, NetworkError, NotFoundError, PinError, 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, preprocessToCar, readableStreamToAsyncIterable, setDriverFactory, streamToBlob };
|
|
18
|
+
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/esm/index.js
CHANGED
|
@@ -8,7 +8,8 @@ import { AuthenticationError, ConfigurationError, EmptyFileError, NetworkError,
|
|
|
8
8
|
import { UploadManager } from "./upload/manager.js";
|
|
9
9
|
import { Pinner } from "./pinner.js";
|
|
10
10
|
import { isAuthenticationError, isRetryable } from "./types/type-guards.js";
|
|
11
|
-
import { pinataAdapter } from "./adapters/pinata/adapter.js";
|
|
11
|
+
import { pinataAdapter } from "./adapters/pinata/v2/adapter.js";
|
|
12
|
+
import { pinataLegacyAdapter } from "./adapters/pinata/legacy/adapter.js";
|
|
12
13
|
import "./adapters/pinata/index.js";
|
|
13
14
|
|
|
14
|
-
export { AuthenticationError, ConfigurationError, EmptyFileError, FILE_EXTENSION_CAR, MIME_TYPE_CAR, MIME_TYPE_OCTET_STREAM, NetworkError, NotFoundError, PinError, Pinner, PinnerError, RateLimitError, TimeoutError, UploadError, UploadManager, ValidationError, asyncGeneratorToReadableStream, calculateStreamSize, createBlockstore, createDatastore, destroyCarPreprocessor, isAuthenticationError, isCarFile, isRetryable, pinataAdapter, preprocessToCar, readableStreamToAsyncIterable, setDriverFactory, streamToBlob };
|
|
15
|
+
export { AuthenticationError, ConfigurationError, EmptyFileError, FILE_EXTENSION_CAR, MIME_TYPE_CAR, MIME_TYPE_OCTET_STREAM, NetworkError, NotFoundError, PinError, Pinner, PinnerError, RateLimitError, TimeoutError, UploadError, UploadManager, ValidationError, asyncGeneratorToReadableStream, calculateStreamSize, createBlockstore, createDatastore, destroyCarPreprocessor, isAuthenticationError, isCarFile, isRetryable, pinataAdapter, pinataLegacyAdapter, preprocessToCar, readableStreamToAsyncIterable, setDriverFactory, streamToBlob };
|
package/dist/esm/pin/client.js
CHANGED
|
@@ -63,13 +63,15 @@ var PinClient = class {
|
|
|
63
63
|
}, { signal: options?.signal });
|
|
64
64
|
}
|
|
65
65
|
async *rm(cid, options) {
|
|
66
|
-
const
|
|
67
|
-
const response = await client.pinsGet({ cid: [cid.toString()] }, { signal: options?.signal });
|
|
66
|
+
const response = await this.getClient().pinsGet({ cid: [cid.toString()] }, { signal: options?.signal });
|
|
68
67
|
await Promise.all([...response.results].map(async (result) => {
|
|
69
|
-
return
|
|
68
|
+
return this.rmByRequestId(result.requestid, options);
|
|
70
69
|
}));
|
|
71
70
|
yield cid;
|
|
72
71
|
}
|
|
72
|
+
async rmByRequestId(requestId, options) {
|
|
73
|
+
await this.getClient().pinsRequestidDelete({ requestid: requestId }, { signal: options?.signal });
|
|
74
|
+
}
|
|
73
75
|
mapResponse(response) {
|
|
74
76
|
return {
|
|
75
77
|
cid: CID.parse(response.pin.cid),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","names":[],"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.js","names":[],"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,IAAI,mBAAmB,wBAAwB;AASvD,OAAK,SAAS,IAAI,2BANI,IAAI,cAAc;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;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,WAAW,CACD,QAC5B,EAAE,KAAK,CAAC,IAAI,UAAU,CAAC,EAAE,EACzB,EAAE,QAAQ,SAAS,QAAQ,CAC5B;AAGD,QAAM,QAAQ,IACZ,CAAC,GAAG,SAAS,QAAQ,CAAC,IAAI,OAAO,WAAW;AAC1C,UAAO,KAAK,cAAc,OAAO,WAAW,QAAQ;IACpD,CACH;AAED,QAAM;;CAGR,MAAM,cAAc,WAAmB,SAAuC;AAE5E,QADe,KAAK,WAAW,CAClB,oBACX,EAAE,WAAW,WAAW,EACxB,EAAE,QAAQ,SAAS,QAAQ,CAC5B;;CAGH,AAAQ,YAAY,UAAgC;AAClD,SAAO;GACL,KAAK,IAAI,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/esm/pinner.d.ts
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
|
*/
|
package/dist/esm/pinner.js
CHANGED
|
@@ -113,6 +113,12 @@ var Pinner = class {
|
|
|
113
113
|
for await (const _ of generator);
|
|
114
114
|
}
|
|
115
115
|
/**
|
|
116
|
+
* Remove a pin by request ID. The block may be deleted when garbage collection is run.
|
|
117
|
+
*/
|
|
118
|
+
async unpinByRequestId(requestId, options) {
|
|
119
|
+
return this.pins.rmByRequestId(requestId, options);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
116
122
|
* Destroy the client and cleanup resources.
|
|
117
123
|
*/
|
|
118
124
|
destroy() {
|
package/dist/esm/pinner.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pinner.js","names":[],"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,IAAI,cAAc,OAAO;AAC9C,OAAK,QAAQ,IAAI,UAAU,OAAO;;;;;CAMpC,IAAI,OAAmB;AACrB,SAAO,KAAK;;;;;;;;CASd,IAAI,SAAiC;AACnC,MAAI,CAAC,KAAK,SAAS;GACjB,MAAM,mBAAmB,6BAA6B,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,IAAI,kBAAkB,KAAK;AAE5C,WAAO,QAAQ,IAAI,QAAQ,KAAK;MAEnC,CAAC;;AAEJ,SAAO,KAAK;;;;;;CAOd,MAAM,cACJ,MACA,SACuB;AAEvB,UADkB,MAAM,KAAK,OAAO,MAAM,QAAQ,EACjC;;;;;;;;CASnB,MAAM,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port { 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,IAAI,cAAc,OAAO;AAC9C,OAAK,QAAQ,IAAI,UAAU,OAAO;;;;;CAMpC,IAAI,OAAmB;AACrB,SAAO,KAAK;;;;;;;;CASd,IAAI,SAAiC;AACnC,MAAI,CAAC,KAAK,SAAS;GACjB,MAAM,mBAAmB,6BAA6B,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,IAAI,kBAAkB,KAAK;AAE5C,WAAO,QAAQ,IAAI,QAAQ,KAAK;MAEnC,CAAC;;AAEJ,SAAO,KAAK;;;;;;CAOd,MAAM,cACJ,MACA,SACuB;AAEvB,UADkB,MAAM,KAAK,OAAO,MAAM,QAAQ,EACjC;;;;;;;;CASnB,MAAM,iBACJ,OACA,SACuB;AACvB,SAAO,KAAK,cAAc,iBAAiB,OAAO,QAAQ;;;;;CAM5D,MAAM,gBACJ,OACA,SAC0B;AAC1B,SAAO,KAAK,cAAc,gBAAgB,OAAO,QAAQ;;;;;;CAO3D,MAAM,UACJ,MACA,SAC0B;AAC1B,SAAO,KAAK,cAAc,UAAU,MAAM,QAAQ;;;;;CAMpD,MAAM,UACJ,KACA,SAC+C;EAC/C,MAAM,SAAS,OAAO,QAAQ,WAAW,IAAI,MAAM,IAAI,GAAG;AAC1D,SAAO,KAAK,KAAK,IAAI,QAAQ,QAAQ;;;;;CAMvC,MAAM,SAAS,SAAiD;EAC9D,MAAM,OAAoB,EAAE;AAC5B,aAAW,MAAM,OAAO,KAAK,KAAK,GAAG,QAAQ,CAC3C,MAAK,KAAK,IAAI;AAEhB,SAAO;;;;;CAMT,MAAM,aAAa,KAAuC;EACxD,MAAM,SAAS,OAAO,QAAQ,WAAW,IAAI,MAAM,IAAI,GAAG;AAC1D,SAAO,KAAK,KAAK,IAAI,OAAO;;;;;CAM9B,MAAM,SAAS,KAAqC;EAClD,MAAM,SAAS,OAAO,QAAQ,WAAW,IAAI,MAAM,IAAI,GAAG;AAC1D,SAAO,KAAK,KAAK,SAAS,OAAO;;;;;CAMnC,MAAM,eACJ,KACA,UACe;EACf,MAAM,SAAS,OAAO,QAAQ,WAAW,IAAI,MAAM,IAAI,GAAG;AAC1D,SAAO,KAAK,KAAK,YAAY,QAAQ,SAAS;;;;;CAMhD,MAAM,MAAM,KAAmB,SAAuC;EACpE,MAAM,SAAS,OAAO,QAAQ,WAAW,IAAI,MAAM,IAAI,GAAG;EAC1D,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"}
|
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Default API endpoint URL for the pinning service.
|
|
4
4
|
*/
|
|
5
|
-
const DEFAULT_ENDPOINT = "https://
|
|
5
|
+
const DEFAULT_ENDPOINT = "https://ipfs.pinner.xyz";
|
|
6
|
+
/**
|
|
7
|
+
* Default IPFS gateway URL for content retrieval.
|
|
8
|
+
*/
|
|
9
|
+
const DEFAULT_GATEWAY = "https://dweb.link";
|
|
6
10
|
/**
|
|
7
11
|
* Default TUS upload size threshold (100MB).
|
|
8
12
|
* Files larger than this will use TUS protocol for resumable uploads.
|
|
@@ -25,5 +29,5 @@ const DEFAULT_BLOCKSTORE_BASE = "pinner:";
|
|
|
25
29
|
const DEFAULT_BLOCKSTORE_FS_BASE = "./.pinner-blocks";
|
|
26
30
|
|
|
27
31
|
//#endregion
|
|
28
|
-
export { DEFAULT_BLOCKSTORE_BASE, DEFAULT_BLOCKSTORE_FS_BASE, DEFAULT_BLOCKSTORE_PREFIX, DEFAULT_ENDPOINT, TUS_SIZE_THRESHOLD };
|
|
32
|
+
export { DEFAULT_BLOCKSTORE_BASE, DEFAULT_BLOCKSTORE_FS_BASE, DEFAULT_BLOCKSTORE_PREFIX, DEFAULT_ENDPOINT, DEFAULT_GATEWAY, TUS_SIZE_THRESHOLD };
|
|
29
33
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","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.js","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/esm/types/pin.d.ts
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 };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lumeweb/pinner",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -57,9 +57,9 @@
|
|
|
57
57
|
"progress-events": "^1.0.1",
|
|
58
58
|
"tus-js-client": "4.3.1",
|
|
59
59
|
"unstorage": "^1.17.3",
|
|
60
|
-
"@lumeweb/uppy-post-upload": "0.1.0",
|
|
61
60
|
"@lumeweb/portal-sdk": "0.1.0",
|
|
62
|
-
"@lumeweb/query-builder": "0.1.0"
|
|
61
|
+
"@lumeweb/query-builder": "0.1.0",
|
|
62
|
+
"@lumeweb/uppy-post-upload": "0.1.0"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@mswjs/interceptors": "^0.40.0",
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
const require_builder = require('./builder.cjs');
|
|
3
|
-
const require_list_builder = require('./list-builder.cjs');
|
|
4
|
-
let multiformats_cid = require("multiformats/cid");
|
|
5
|
-
|
|
6
|
-
//#region src/adapters/pinata/adapter.ts
|
|
7
|
-
/**
|
|
8
|
-
* Creates a Pinata-compatible adapter for the Pinner client.
|
|
9
|
-
*/
|
|
10
|
-
function pinataAdapter(pinner) {
|
|
11
|
-
return {
|
|
12
|
-
upload: {
|
|
13
|
-
file(file) {
|
|
14
|
-
return require_builder.createUploadBuilder(pinner, file);
|
|
15
|
-
},
|
|
16
|
-
fileArray(files) {
|
|
17
|
-
return require_builder.createFileArrayUploadBuilder(pinner, files);
|
|
18
|
-
},
|
|
19
|
-
json(data) {
|
|
20
|
-
return require_builder.createJsonUploadBuilder(pinner, data);
|
|
21
|
-
},
|
|
22
|
-
base64(base64String) {
|
|
23
|
-
return require_builder.createBase64UploadBuilder(pinner, base64String);
|
|
24
|
-
},
|
|
25
|
-
url(urlString) {
|
|
26
|
-
return require_builder.createUrlUploadBuilder(pinner, urlString);
|
|
27
|
-
},
|
|
28
|
-
cid(cidString) {
|
|
29
|
-
return require_builder.createCidUploadBuilder(pinner, cidString);
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
async pinByHash(cid, options) {
|
|
33
|
-
const cidObj = multiformats_cid.CID.parse(cid);
|
|
34
|
-
const generator = await pinner.pinByHash(cidObj, {
|
|
35
|
-
name: options?.name,
|
|
36
|
-
metadata: options?.keyvalues
|
|
37
|
-
});
|
|
38
|
-
for await (const _ of generator);
|
|
39
|
-
},
|
|
40
|
-
async unpin(cid) {
|
|
41
|
-
await pinner.unpin(cid);
|
|
42
|
-
},
|
|
43
|
-
async getPinStatus(cid) {
|
|
44
|
-
const cidObj = multiformats_cid.CID.parse(cid);
|
|
45
|
-
const remotePin = await pinner.getPinStatus(cidObj);
|
|
46
|
-
return {
|
|
47
|
-
id: cidObj.toString(),
|
|
48
|
-
ipfsPinHash: cidObj.toString(),
|
|
49
|
-
size: remotePin.size || 0,
|
|
50
|
-
userId: "",
|
|
51
|
-
datePinned: remotePin.created.toISOString(),
|
|
52
|
-
metadata: {
|
|
53
|
-
name: remotePin.name,
|
|
54
|
-
keyvalues: remotePin.metadata
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
},
|
|
58
|
-
async isPinned(cid) {
|
|
59
|
-
const cidObj = multiformats_cid.CID.parse(cid);
|
|
60
|
-
return pinner.isPinned(cidObj);
|
|
61
|
-
},
|
|
62
|
-
async setPinMetadata(cid, metadata) {
|
|
63
|
-
const cidObj = multiformats_cid.CID.parse(cid);
|
|
64
|
-
await pinner.setPinMetadata(cidObj, metadata);
|
|
65
|
-
},
|
|
66
|
-
files: {
|
|
67
|
-
list() {
|
|
68
|
-
return require_list_builder.createListBuilder(pinner);
|
|
69
|
-
},
|
|
70
|
-
async get(id) {
|
|
71
|
-
const pin = (await pinner.listPins()).find((p) => p.cid.toString() === id);
|
|
72
|
-
if (!pin) throw new Error(`Pin not found: ${id}`);
|
|
73
|
-
return {
|
|
74
|
-
id: pin.cid.toString(),
|
|
75
|
-
ipfsPinHash: pin.cid.toString(),
|
|
76
|
-
size: pin.size || 0,
|
|
77
|
-
name: pin.name || "",
|
|
78
|
-
cid: pin.cid.toString(),
|
|
79
|
-
createdAt: pin.created.toISOString()
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
//#endregion
|
|
87
|
-
exports.pinataAdapter = pinataAdapter;
|
|
88
|
-
//# sourceMappingURL=adapter.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.cjs","names":["createUploadBuilder","createFileArrayUploadBuilder","createJsonUploadBuilder","createBase64UploadBuilder","createUrlUploadBuilder","createCidUploadBuilder","CID","createListBuilder"],"sources":["../../../../src/adapters/pinata/adapter.ts"],"sourcesContent":["import type { Pinner } from \"@/pinner\";\nimport {\n createBase64UploadBuilder,\n createCidUploadBuilder,\n createFileArrayUploadBuilder,\n createJsonUploadBuilder,\n createUploadBuilder,\n createUrlUploadBuilder,\n} from \"./builder\";\nimport { createListBuilder } from \"./list-builder\";\nimport type {\n PinataFile,\n PinataListBuilder,\n PinataPin,\n PinataUploadBuilder,\n PinataUploadResult,\n PinByHashOptions,\n} from \"@/types/pinata\";\nimport { CID } from \"multiformats/cid\";\n\n/**\n * Creates a Pinata-compatible adapter for the Pinner client.\n * This allows users to migrate from Pinata SDK with minimal code changes.\n */\nexport interface PinataAdapter {\n upload: {\n file(file: File): PinataUploadBuilder<PinataUploadResult>;\n fileArray(files: File[]): PinataUploadBuilder<PinataUploadResult>;\n json(data: object): PinataUploadBuilder<PinataUploadResult>;\n base64(base64String: string): PinataUploadBuilder<PinataUploadResult>;\n url(urlString: string): PinataUploadBuilder<PinataUploadResult>;\n cid(cidString: string): PinataUploadBuilder<void>;\n };\n\n pinByHash(cid: string, options?: PinByHashOptions): Promise<void>;\n unpin(cid: string): Promise<void>;\n getPinStatus(cid: string): Promise<PinataPin>;\n isPinned(cid: string): Promise<boolean>;\n setPinMetadata(cid: string, metadata: Record<string, string>): Promise<void>;\n\n files: {\n list(): PinataListBuilder<PinataFile[]>;\n get(id: string): Promise<PinataFile>;\n };\n}\n\n/**\n * Creates a Pinata-compatible adapter for the Pinner client.\n */\nexport function pinataAdapter(pinner: Pinner): PinataAdapter {\n return {\n upload: {\n file(file: File): PinataUploadBuilder<PinataUploadResult> {\n return createUploadBuilder(pinner, file);\n },\n fileArray(files: File[]): PinataUploadBuilder<PinataUploadResult> {\n return createFileArrayUploadBuilder(pinner, files);\n },\n json(data: object): PinataUploadBuilder<PinataUploadResult> {\n return createJsonUploadBuilder(pinner, data);\n },\n base64(base64String: string): PinataUploadBuilder<PinataUploadResult> {\n return createBase64UploadBuilder(pinner, base64String);\n },\n url(urlString: string): PinataUploadBuilder<PinataUploadResult> {\n return createUrlUploadBuilder(pinner, urlString);\n },\n cid(cidString: string): PinataUploadBuilder<void> {\n return createCidUploadBuilder(pinner, cidString);\n },\n },\n\n async pinByHash(cid: string, options?: PinByHashOptions): Promise<void> {\n const cidObj = CID.parse(cid);\n const generatorPromise = pinner.pinByHash(cidObj, {\n name: options?.name,\n metadata: options?.keyvalues,\n });\n\n const generator = await generatorPromise;\n for await (const _ of generator) {\n // Pin operation in progress\n }\n },\n\n async unpin(cid: string): Promise<void> {\n await pinner.unpin(cid);\n },\n\n async getPinStatus(cid: string): Promise<PinataPin> {\n const cidObj = CID.parse(cid);\n const remotePin = await pinner.getPinStatus(cidObj);\n\n return {\n id: cidObj.toString(),\n ipfsPinHash: cidObj.toString(),\n size: remotePin.size || 0,\n userId: \"\",\n datePinned: remotePin.created.toISOString(),\n metadata: {\n name: remotePin.name,\n keyvalues: remotePin.metadata,\n },\n };\n },\n\n async isPinned(cid: string): Promise<boolean> {\n const cidObj = CID.parse(cid);\n return pinner.isPinned(cidObj);\n },\n\n async setPinMetadata(\n cid: string,\n metadata: Record<string, string>,\n ): Promise<void> {\n const cidObj = CID.parse(cid);\n await pinner.setPinMetadata(cidObj, metadata);\n },\n\n files: {\n list(): PinataListBuilder<PinataFile[]> {\n return createListBuilder(pinner);\n },\n async get(id: string): Promise<PinataFile> {\n const pins = await pinner.listPins();\n const pin = pins.find((p) => p.cid.toString() === id);\n\n if (!pin) {\n throw new Error(`Pin not found: ${id}`);\n }\n\n return {\n id: pin.cid.toString(),\n ipfsPinHash: pin.cid.toString(),\n size: pin.size || 0,\n name: pin.name || \"\",\n cid: pin.cid.toString(),\n createdAt: pin.created.toISOString(),\n };\n },\n },\n };\n}\n"],"m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