pinata 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +373 -0
- package/dist/index.d.ts +373 -0
- package/dist/index.js +1971 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1934 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +5 -5
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
type PinataConfig = {
|
|
2
|
+
pinataJwt: string;
|
|
3
|
+
pinataGateway?: string;
|
|
4
|
+
pinataGatewayKey?: string;
|
|
5
|
+
};
|
|
6
|
+
type AuthTestResponse = {
|
|
7
|
+
message: string;
|
|
8
|
+
};
|
|
9
|
+
type PinResponse = {
|
|
10
|
+
IpfsHash: string;
|
|
11
|
+
PinSize: number;
|
|
12
|
+
Timestamp: string;
|
|
13
|
+
isDuplicate?: boolean;
|
|
14
|
+
};
|
|
15
|
+
type PinByCIDResponse = {
|
|
16
|
+
id: string;
|
|
17
|
+
ipfsHash: string;
|
|
18
|
+
status: "prechecking" | "retrieving";
|
|
19
|
+
name: string;
|
|
20
|
+
updated?: boolean;
|
|
21
|
+
};
|
|
22
|
+
type FileObject = {
|
|
23
|
+
name: string;
|
|
24
|
+
size: number;
|
|
25
|
+
type: string;
|
|
26
|
+
lastModified: number;
|
|
27
|
+
arrayBuffer: () => Promise<ArrayBuffer>;
|
|
28
|
+
};
|
|
29
|
+
type JsonBody = Record<string, unknown>;
|
|
30
|
+
type PinataMetadata = {
|
|
31
|
+
name?: string;
|
|
32
|
+
keyValues?: Record<string, string | number>;
|
|
33
|
+
};
|
|
34
|
+
type PinataMetadataUpdate = {
|
|
35
|
+
cid: string;
|
|
36
|
+
name?: string;
|
|
37
|
+
keyValues?: Record<string, string | number>;
|
|
38
|
+
};
|
|
39
|
+
type UploadOptions = {
|
|
40
|
+
metadata?: PinataMetadata;
|
|
41
|
+
pinType?: "async" | "sync" | "cidOnly";
|
|
42
|
+
keys?: string;
|
|
43
|
+
groupId?: string;
|
|
44
|
+
cidVersion?: 0 | 1;
|
|
45
|
+
};
|
|
46
|
+
type UploadCIDOptions = {
|
|
47
|
+
metadata?: PinataMetadata;
|
|
48
|
+
peerAddresses?: string[];
|
|
49
|
+
keys?: string;
|
|
50
|
+
groupId?: string;
|
|
51
|
+
};
|
|
52
|
+
type UnpinResponse = {
|
|
53
|
+
hash: string;
|
|
54
|
+
status: string;
|
|
55
|
+
};
|
|
56
|
+
type PinListItem = {
|
|
57
|
+
id: string;
|
|
58
|
+
ipfs_pin_hash: string;
|
|
59
|
+
size: number;
|
|
60
|
+
user_id: string;
|
|
61
|
+
date_pinned: string;
|
|
62
|
+
date_unpinned: string | null;
|
|
63
|
+
metadata: {
|
|
64
|
+
name: string | null;
|
|
65
|
+
keyvalues: {
|
|
66
|
+
[key: string]: any;
|
|
67
|
+
} | null;
|
|
68
|
+
};
|
|
69
|
+
regions: {
|
|
70
|
+
regionId: string;
|
|
71
|
+
currentReplicationCount: number;
|
|
72
|
+
desiredReplicationCount: number;
|
|
73
|
+
}[];
|
|
74
|
+
mime_type: string;
|
|
75
|
+
number_of_files: number;
|
|
76
|
+
};
|
|
77
|
+
type PinListResponse = {
|
|
78
|
+
rows: PinListItem[];
|
|
79
|
+
};
|
|
80
|
+
type PinListQuery = {
|
|
81
|
+
cid?: string;
|
|
82
|
+
pinStart?: string;
|
|
83
|
+
pinEnd?: string;
|
|
84
|
+
pinSizeMin?: number;
|
|
85
|
+
pinSizeMax?: number;
|
|
86
|
+
pageLimit?: number;
|
|
87
|
+
pageOffset?: number;
|
|
88
|
+
name?: string;
|
|
89
|
+
groupId?: string;
|
|
90
|
+
key?: string;
|
|
91
|
+
value?: string | number;
|
|
92
|
+
operator?: "gt" | "gte" | "lt" | "lte" | "ne" | "eq" | "between" | "notBetween" | "like" | "notLike" | "iLike" | "notILike" | "regexp" | "iRegexp";
|
|
93
|
+
};
|
|
94
|
+
type PinJobQuery = {
|
|
95
|
+
sort?: "ASC" | "DSC";
|
|
96
|
+
status?: "prechecking" | "retrieving" | "expired" | "over_free_limit" | "over_max_size" | "invalid_object" | "bad_host_node";
|
|
97
|
+
ipfs_pin_hash?: string;
|
|
98
|
+
limit?: number;
|
|
99
|
+
offset?: number;
|
|
100
|
+
};
|
|
101
|
+
type PinJobItem = {
|
|
102
|
+
id: string;
|
|
103
|
+
ipfs_pin_hash: string;
|
|
104
|
+
date_queued: string;
|
|
105
|
+
name: string;
|
|
106
|
+
status: string;
|
|
107
|
+
keyvalues: any;
|
|
108
|
+
host_nodes: string[];
|
|
109
|
+
pin_policy: {
|
|
110
|
+
regions: {
|
|
111
|
+
id: string;
|
|
112
|
+
desiredReplicationCount: number;
|
|
113
|
+
}[];
|
|
114
|
+
version: number;
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
type PinJobResponse = {
|
|
118
|
+
rows: PinJobItem[];
|
|
119
|
+
};
|
|
120
|
+
type ContentType = "application/json" | "application/xml" | "text/plain" | "text/html" | "text/css" | "text/javascript" | "application/javascript" | "image/jpeg" | "image/png" | "image/gif" | "image/svg+xml" | "audio/mpeg" | "audio/ogg" | "video/mp4" | "application/pdf" | "application/octet-stream" | string | null;
|
|
121
|
+
type GetCIDResponse = {
|
|
122
|
+
data?: JSON | string | Blob | null;
|
|
123
|
+
contentType: ContentType;
|
|
124
|
+
};
|
|
125
|
+
type UserPinnedDataResponse = {
|
|
126
|
+
pin_count: number;
|
|
127
|
+
pin_size_total: number;
|
|
128
|
+
pin_size_with_replications_total: number;
|
|
129
|
+
};
|
|
130
|
+
type KeyPermissions = {
|
|
131
|
+
admin?: boolean;
|
|
132
|
+
endpoints?: Endpoints;
|
|
133
|
+
};
|
|
134
|
+
type Endpoints = {
|
|
135
|
+
data?: DataEndponts;
|
|
136
|
+
pinning?: PinningEndpoints;
|
|
137
|
+
};
|
|
138
|
+
type DataEndponts = {
|
|
139
|
+
pinList?: boolean;
|
|
140
|
+
userPinnedDataTotal?: boolean;
|
|
141
|
+
};
|
|
142
|
+
type PinningEndpoints = {
|
|
143
|
+
hashMetadata?: boolean;
|
|
144
|
+
hashPinPolicy?: boolean;
|
|
145
|
+
pinByHash?: boolean;
|
|
146
|
+
pinFileToIPFS?: boolean;
|
|
147
|
+
pinJSONToIPFS?: boolean;
|
|
148
|
+
pinJobs?: boolean;
|
|
149
|
+
unpin?: boolean;
|
|
150
|
+
userPinPolicy?: boolean;
|
|
151
|
+
};
|
|
152
|
+
type KeyOptions = {
|
|
153
|
+
keyName: string;
|
|
154
|
+
permissions: KeyPermissions;
|
|
155
|
+
maxUses?: number;
|
|
156
|
+
};
|
|
157
|
+
type KeyResponse = {
|
|
158
|
+
JWT: string;
|
|
159
|
+
pinata_api_key: string;
|
|
160
|
+
pinata_api_secret: string;
|
|
161
|
+
};
|
|
162
|
+
type KeyListQuery = {
|
|
163
|
+
revoked?: boolean;
|
|
164
|
+
limitedUse?: boolean;
|
|
165
|
+
exhausted?: boolean;
|
|
166
|
+
name?: string;
|
|
167
|
+
offset?: number;
|
|
168
|
+
};
|
|
169
|
+
type KeyListItem = {
|
|
170
|
+
id: string;
|
|
171
|
+
name: string;
|
|
172
|
+
key: string;
|
|
173
|
+
secret: string;
|
|
174
|
+
max_uses: number;
|
|
175
|
+
uses: number;
|
|
176
|
+
user_id: string;
|
|
177
|
+
scopes: KeyScopes;
|
|
178
|
+
revoked: boolean;
|
|
179
|
+
createdAt: string;
|
|
180
|
+
updatedAt: string;
|
|
181
|
+
};
|
|
182
|
+
type KeyScopes = {
|
|
183
|
+
endpoints: {
|
|
184
|
+
pinning: {
|
|
185
|
+
pinFileToIPFS: boolean;
|
|
186
|
+
pinJSONToIPFS: boolean;
|
|
187
|
+
};
|
|
188
|
+
};
|
|
189
|
+
admin: boolean;
|
|
190
|
+
};
|
|
191
|
+
type KeyListResponse = {
|
|
192
|
+
keys: KeyListItem[];
|
|
193
|
+
count: number;
|
|
194
|
+
};
|
|
195
|
+
type RevokeKeyResponse = {
|
|
196
|
+
key: string;
|
|
197
|
+
status: string;
|
|
198
|
+
};
|
|
199
|
+
type GroupOptions = {
|
|
200
|
+
name: string;
|
|
201
|
+
};
|
|
202
|
+
type UpdateGroupOptions = {
|
|
203
|
+
name: string;
|
|
204
|
+
groupId: string;
|
|
205
|
+
};
|
|
206
|
+
type GetGroupOptions = {
|
|
207
|
+
groupId: string;
|
|
208
|
+
};
|
|
209
|
+
type GroupResponseItem = {
|
|
210
|
+
id: string;
|
|
211
|
+
user_id: string;
|
|
212
|
+
name: string;
|
|
213
|
+
updatedAt: string;
|
|
214
|
+
createdAt: string;
|
|
215
|
+
};
|
|
216
|
+
type GroupQueryOptions = {
|
|
217
|
+
nameContains?: string;
|
|
218
|
+
offset?: number;
|
|
219
|
+
limit?: number;
|
|
220
|
+
};
|
|
221
|
+
type GroupCIDOptions = {
|
|
222
|
+
groupId: string;
|
|
223
|
+
cids: string[];
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
declare class PinataSDK {
|
|
227
|
+
config: PinataConfig | undefined;
|
|
228
|
+
upload: Upload;
|
|
229
|
+
gateways: Gateways;
|
|
230
|
+
usage: Usage;
|
|
231
|
+
keys: Keys;
|
|
232
|
+
groups: Groups;
|
|
233
|
+
constructor(config?: PinataConfig);
|
|
234
|
+
testAuthentication(): Promise<AuthTestResponse>;
|
|
235
|
+
unpin(files: string[]): Promise<UnpinResponse[]>;
|
|
236
|
+
listFiles(): FilterFiles;
|
|
237
|
+
updateMetadata(options: PinataMetadataUpdate): Promise<string>;
|
|
238
|
+
pinJobs(): FilterPinJobs;
|
|
239
|
+
}
|
|
240
|
+
declare class UploadBuilder<T> {
|
|
241
|
+
private config;
|
|
242
|
+
private uploadFunction;
|
|
243
|
+
private args;
|
|
244
|
+
private metadata;
|
|
245
|
+
private keys;
|
|
246
|
+
private peerAddresses;
|
|
247
|
+
private version;
|
|
248
|
+
private groupId;
|
|
249
|
+
constructor(config: PinataConfig | undefined, uploadFunction: (config: PinataConfig | undefined, ...args: any[]) => Promise<T>, ...args: any[]);
|
|
250
|
+
addMetadata(metadata: PinataMetadata): UploadBuilder<T>;
|
|
251
|
+
key(jwt: string): UploadBuilder<T>;
|
|
252
|
+
cidVersion(v: 0 | 1): UploadBuilder<T>;
|
|
253
|
+
group(groupId: string): UploadBuilder<T>;
|
|
254
|
+
peerAddress(peerAddresses: string[]): UploadBuilder<T>;
|
|
255
|
+
then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): Promise<TResult1 | TResult2>;
|
|
256
|
+
}
|
|
257
|
+
declare class Upload {
|
|
258
|
+
config: PinataConfig | undefined;
|
|
259
|
+
constructor(config?: PinataConfig);
|
|
260
|
+
file(file: FileObject, options?: UploadOptions): UploadBuilder<PinResponse>;
|
|
261
|
+
fileArray(files: FileObject[], options?: UploadOptions): UploadBuilder<PinResponse>;
|
|
262
|
+
base64(base64String: string, options?: UploadOptions): UploadBuilder<PinResponse>;
|
|
263
|
+
url(url: string, options?: UploadOptions): UploadBuilder<PinResponse>;
|
|
264
|
+
json(data: object, options?: UploadOptions): UploadBuilder<PinResponse>;
|
|
265
|
+
cid(cid: string, options?: UploadCIDOptions): UploadBuilder<PinByCIDResponse>;
|
|
266
|
+
}
|
|
267
|
+
declare class FilterFiles {
|
|
268
|
+
private config;
|
|
269
|
+
private query;
|
|
270
|
+
private requestCount;
|
|
271
|
+
private lastRequestTime;
|
|
272
|
+
private readonly MAX_REQUESTS_PER_MINUTE;
|
|
273
|
+
private readonly MINUTE_IN_MS;
|
|
274
|
+
constructor(config: PinataConfig | undefined);
|
|
275
|
+
cid(cid: string): FilterFiles;
|
|
276
|
+
pinStart(date: string): FilterFiles;
|
|
277
|
+
pinEnd(date: string): FilterFiles;
|
|
278
|
+
pinSizeMin(size: number): FilterFiles;
|
|
279
|
+
pinSizeMax(size: number): FilterFiles;
|
|
280
|
+
pageLimit(limit: number): FilterFiles;
|
|
281
|
+
pageOffset(offset: number): FilterFiles;
|
|
282
|
+
name(name: string): FilterFiles;
|
|
283
|
+
group(groupId: string): FilterFiles;
|
|
284
|
+
keyValue(key: string, value: string | number, operator?: PinListQuery["operator"]): FilterFiles;
|
|
285
|
+
then(onfulfilled?: ((value: PinListItem[]) => any) | null): Promise<any>;
|
|
286
|
+
private rateLimit;
|
|
287
|
+
[Symbol.asyncIterator](): AsyncGenerator<PinListItem, void, unknown>;
|
|
288
|
+
all(): Promise<PinListItem[]>;
|
|
289
|
+
}
|
|
290
|
+
declare class Gateways {
|
|
291
|
+
config: PinataConfig | undefined;
|
|
292
|
+
constructor(config?: PinataConfig);
|
|
293
|
+
get(cid: string): Promise<GetCIDResponse>;
|
|
294
|
+
convert(url: string): string;
|
|
295
|
+
}
|
|
296
|
+
declare class FilterPinJobs {
|
|
297
|
+
private config;
|
|
298
|
+
private query;
|
|
299
|
+
private requestCount;
|
|
300
|
+
private lastRequestTime;
|
|
301
|
+
private readonly MAX_REQUESTS_PER_MINUTE;
|
|
302
|
+
private readonly MINUTE_IN_MS;
|
|
303
|
+
constructor(config: PinataConfig | undefined);
|
|
304
|
+
cid(cid: string): FilterPinJobs;
|
|
305
|
+
status(status: "prechecking" | "retrieving" | "expired" | "over_free_limit" | "over_max_size" | "invalid_object" | "bad_host_node"): FilterPinJobs;
|
|
306
|
+
pageLimit(limit: number): FilterPinJobs;
|
|
307
|
+
pageOffset(offset: number): FilterPinJobs;
|
|
308
|
+
sort(sort: "ASC" | "DSC"): FilterPinJobs;
|
|
309
|
+
then(onfulfilled?: ((value: PinJobItem[]) => any) | null): Promise<any>;
|
|
310
|
+
private rateLimit;
|
|
311
|
+
[Symbol.asyncIterator](): AsyncGenerator<PinJobItem, void, unknown>;
|
|
312
|
+
all(): Promise<PinJobItem[]>;
|
|
313
|
+
}
|
|
314
|
+
declare class Usage {
|
|
315
|
+
config: PinataConfig | undefined;
|
|
316
|
+
constructor(config?: PinataConfig);
|
|
317
|
+
pinnedFileCount(): Promise<number>;
|
|
318
|
+
totalStorageSize(): Promise<number>;
|
|
319
|
+
}
|
|
320
|
+
declare class Keys {
|
|
321
|
+
config: PinataConfig | undefined;
|
|
322
|
+
constructor(config?: PinataConfig);
|
|
323
|
+
create(options: KeyOptions): Promise<KeyResponse>;
|
|
324
|
+
list(): FilterKeys;
|
|
325
|
+
revoke(keys: string[]): Promise<RevokeKeyResponse[]>;
|
|
326
|
+
}
|
|
327
|
+
declare class FilterKeys {
|
|
328
|
+
private config;
|
|
329
|
+
private query;
|
|
330
|
+
private requestCount;
|
|
331
|
+
private lastRequestTime;
|
|
332
|
+
private readonly MAX_REQUESTS_PER_MINUTE;
|
|
333
|
+
private readonly MINUTE_IN_MS;
|
|
334
|
+
constructor(config: PinataConfig | undefined);
|
|
335
|
+
offset(offset: number): FilterKeys;
|
|
336
|
+
revoked(revoked: boolean): FilterKeys;
|
|
337
|
+
limitedUse(limitedUse: boolean): FilterKeys;
|
|
338
|
+
exhausted(exhausted: boolean): FilterKeys;
|
|
339
|
+
name(name: string): FilterKeys;
|
|
340
|
+
then(onfulfilled?: ((value: KeyListItem[]) => any) | null): Promise<any>;
|
|
341
|
+
private rateLimit;
|
|
342
|
+
[Symbol.asyncIterator](): AsyncGenerator<KeyListItem, void, unknown>;
|
|
343
|
+
all(): Promise<KeyListItem[]>;
|
|
344
|
+
}
|
|
345
|
+
declare class Groups {
|
|
346
|
+
config: PinataConfig | undefined;
|
|
347
|
+
constructor(config?: PinataConfig);
|
|
348
|
+
create(options: GroupOptions): Promise<GroupResponseItem>;
|
|
349
|
+
list(): FilterGroups;
|
|
350
|
+
get(options: GetGroupOptions): Promise<GroupResponseItem>;
|
|
351
|
+
addCids(options: GroupCIDOptions): Promise<string>;
|
|
352
|
+
removeCids(options: GroupCIDOptions): Promise<string>;
|
|
353
|
+
update(options: UpdateGroupOptions): Promise<GroupResponseItem>;
|
|
354
|
+
delete(options: GetGroupOptions): Promise<string>;
|
|
355
|
+
}
|
|
356
|
+
declare class FilterGroups {
|
|
357
|
+
private config;
|
|
358
|
+
private query;
|
|
359
|
+
private requestCount;
|
|
360
|
+
private lastRequestTime;
|
|
361
|
+
private readonly MAX_REQUESTS_PER_MINUTE;
|
|
362
|
+
private readonly MINUTE_IN_MS;
|
|
363
|
+
constructor(config: PinataConfig | undefined);
|
|
364
|
+
offset(offset: number): FilterGroups;
|
|
365
|
+
name(nameContains: string): FilterGroups;
|
|
366
|
+
limit(limit: number): FilterGroups;
|
|
367
|
+
then(onfulfilled?: ((value: GroupResponseItem[]) => any) | null): Promise<any>;
|
|
368
|
+
private rateLimit;
|
|
369
|
+
[Symbol.asyncIterator](): AsyncGenerator<GroupResponseItem, void, unknown>;
|
|
370
|
+
all(): Promise<GroupResponseItem[]>;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
export { type AuthTestResponse, type ContentType, type DataEndponts, type Endpoints, type FileObject, type GetCIDResponse, type GetGroupOptions, type GroupCIDOptions, type GroupOptions, type GroupQueryOptions, type GroupResponseItem, type JsonBody, type KeyListItem, type KeyListQuery, type KeyListResponse, type KeyOptions, type KeyPermissions, type KeyResponse, type PinByCIDResponse, type PinJobItem, type PinJobQuery, type PinJobResponse, type PinListItem, type PinListQuery, type PinListResponse, type PinResponse, type PinataConfig, type PinataMetadata, type PinataMetadataUpdate, PinataSDK, type PinningEndpoints, type RevokeKeyResponse, type UnpinResponse, type UpdateGroupOptions, type UploadCIDOptions, type UploadOptions, type UserPinnedDataResponse };
|