pinata 0.1.10 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +89 -1
- package/dist/index.d.ts +89 -1
- package/dist/index.js +772 -314
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +772 -314
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -3,6 +3,7 @@ type PinataConfig = {
|
|
|
3
3
|
pinataGateway?: string;
|
|
4
4
|
pinataGatewayKey?: string;
|
|
5
5
|
customHeaders?: Record<string, string>;
|
|
6
|
+
endpointUrl?: string;
|
|
6
7
|
};
|
|
7
8
|
type AuthTestResponse = {
|
|
8
9
|
message: string;
|
|
@@ -123,6 +124,42 @@ type GetCIDResponse = {
|
|
|
123
124
|
data?: JSON | string | Blob | null;
|
|
124
125
|
contentType: ContentType;
|
|
125
126
|
};
|
|
127
|
+
type GatewayAnalyticsQuery = {
|
|
128
|
+
gateway_domain: string;
|
|
129
|
+
start_date: string;
|
|
130
|
+
end_date: string;
|
|
131
|
+
cid?: string;
|
|
132
|
+
file_name?: string;
|
|
133
|
+
user_agent?: string;
|
|
134
|
+
country?: string;
|
|
135
|
+
region?: string;
|
|
136
|
+
referer?: string;
|
|
137
|
+
limit?: number;
|
|
138
|
+
sort_order?: "asc" | "desc";
|
|
139
|
+
};
|
|
140
|
+
type TopGatewayAnalyticsQuery = GatewayAnalyticsQuery & {
|
|
141
|
+
sort_by: "requests" | "bandwidth";
|
|
142
|
+
attribute: "cid" | "country" | "region" | "user_agent" | "referer" | "file_name";
|
|
143
|
+
};
|
|
144
|
+
type TopGatewayAnalyticsItem = {
|
|
145
|
+
value: string;
|
|
146
|
+
requests: number;
|
|
147
|
+
bandwidth: number;
|
|
148
|
+
};
|
|
149
|
+
type TimeIntervalGatewayAnalyticsQuery = GatewayAnalyticsQuery & {
|
|
150
|
+
sort_by?: "requests" | "bandwidth";
|
|
151
|
+
date_interval: "day" | "week";
|
|
152
|
+
};
|
|
153
|
+
type TimePeriodItem = {
|
|
154
|
+
period_start_time: string;
|
|
155
|
+
requests: number;
|
|
156
|
+
bandwidth: number;
|
|
157
|
+
};
|
|
158
|
+
type TimeIntervalGatewayAnalyticsResponse = {
|
|
159
|
+
total_requests: number;
|
|
160
|
+
total_bandwidth: number;
|
|
161
|
+
time_periods: TimePeriodItem[];
|
|
162
|
+
};
|
|
126
163
|
type UserPinnedDataResponse = {
|
|
127
164
|
pin_count: number;
|
|
128
165
|
pin_size_total: number;
|
|
@@ -241,6 +278,7 @@ declare class PinataSDK {
|
|
|
241
278
|
groups: Groups;
|
|
242
279
|
signatures: Signatures;
|
|
243
280
|
constructor(config?: PinataConfig);
|
|
281
|
+
setNewHeaders(headers: Record<string, string>): void;
|
|
244
282
|
testAuthentication(): Promise<AuthTestResponse>;
|
|
245
283
|
unpin(files: string[]): Promise<UnpinResponse[]>;
|
|
246
284
|
listFiles(): FilterFiles;
|
|
@@ -267,6 +305,7 @@ declare class UploadBuilder<T> {
|
|
|
267
305
|
declare class Upload {
|
|
268
306
|
config: PinataConfig | undefined;
|
|
269
307
|
constructor(config?: PinataConfig);
|
|
308
|
+
updateConfig(newConfig: PinataConfig): void;
|
|
270
309
|
file(file: FileObject, options?: UploadOptions): UploadBuilder<PinResponse>;
|
|
271
310
|
fileArray(files: FileObject[], options?: UploadOptions): UploadBuilder<PinResponse>;
|
|
272
311
|
base64(base64String: string, options?: UploadOptions): UploadBuilder<PinResponse>;
|
|
@@ -300,8 +339,22 @@ declare class FilterFiles {
|
|
|
300
339
|
declare class Gateways {
|
|
301
340
|
config: PinataConfig | undefined;
|
|
302
341
|
constructor(config?: PinataConfig);
|
|
342
|
+
updateConfig(newConfig: PinataConfig): void;
|
|
303
343
|
get(cid: string): Promise<GetCIDResponse>;
|
|
304
344
|
convert(url: string): Promise<string>;
|
|
345
|
+
topUsageAnalytics(options: {
|
|
346
|
+
domain: string;
|
|
347
|
+
start: string;
|
|
348
|
+
end: string;
|
|
349
|
+
sortBy: "requests" | "bandwidth";
|
|
350
|
+
attribute: "cid" | "country" | "region" | "user_agent" | "referer" | "file_name";
|
|
351
|
+
}): TopGatewayAnalyticsBuilder;
|
|
352
|
+
dateIntervalAnalytics(options: {
|
|
353
|
+
domain: string;
|
|
354
|
+
start: string;
|
|
355
|
+
end: string;
|
|
356
|
+
interval: "day" | "week";
|
|
357
|
+
}): TimeIntervalGatewayAnalyticsBuilder;
|
|
305
358
|
}
|
|
306
359
|
declare class FilterPinJobs {
|
|
307
360
|
private config;
|
|
@@ -324,12 +377,14 @@ declare class FilterPinJobs {
|
|
|
324
377
|
declare class Usage {
|
|
325
378
|
config: PinataConfig | undefined;
|
|
326
379
|
constructor(config?: PinataConfig);
|
|
380
|
+
updateConfig(newConfig: PinataConfig): void;
|
|
327
381
|
pinnedFileCount(): Promise<number>;
|
|
328
382
|
totalStorageSize(): Promise<number>;
|
|
329
383
|
}
|
|
330
384
|
declare class Keys {
|
|
331
385
|
config: PinataConfig | undefined;
|
|
332
386
|
constructor(config?: PinataConfig);
|
|
387
|
+
updateConfig(newConfig: PinataConfig): void;
|
|
333
388
|
create(options: KeyOptions): Promise<KeyResponse>;
|
|
334
389
|
list(): FilterKeys;
|
|
335
390
|
revoke(keys: string[]): Promise<RevokeKeyResponse[]>;
|
|
@@ -355,6 +410,7 @@ declare class FilterKeys {
|
|
|
355
410
|
declare class Groups {
|
|
356
411
|
config: PinataConfig | undefined;
|
|
357
412
|
constructor(config?: PinataConfig);
|
|
413
|
+
updateConfig(newConfig: PinataConfig): void;
|
|
358
414
|
create(options: GroupOptions): Promise<GroupResponseItem>;
|
|
359
415
|
list(): FilterGroups;
|
|
360
416
|
get(options: GetGroupOptions): Promise<GroupResponseItem>;
|
|
@@ -382,9 +438,41 @@ declare class FilterGroups {
|
|
|
382
438
|
declare class Signatures {
|
|
383
439
|
config: PinataConfig | undefined;
|
|
384
440
|
constructor(config?: PinataConfig);
|
|
441
|
+
updateConfig(newConfig: PinataConfig): void;
|
|
385
442
|
add(options: SignatureOptions): Promise<SignatureResponse>;
|
|
386
443
|
get(cid: string): Promise<SignatureResponse>;
|
|
387
444
|
delete(cid: string): Promise<string>;
|
|
388
445
|
}
|
|
446
|
+
declare class GatewayAnalyticsBuilder<T extends GatewayAnalyticsQuery, R> {
|
|
447
|
+
protected config: PinataConfig | undefined;
|
|
448
|
+
protected query: T;
|
|
449
|
+
private requestCount;
|
|
450
|
+
private lastRequestTime;
|
|
451
|
+
private readonly MAX_REQUESTS_PER_MINUTE;
|
|
452
|
+
private readonly MINUTE_IN_MS;
|
|
453
|
+
constructor(config: PinataConfig | undefined, query: T);
|
|
454
|
+
cid(cid: string): this;
|
|
455
|
+
fileName(fileName: string): this;
|
|
456
|
+
userAgent(userAgent: string): this;
|
|
457
|
+
country(country: string): this;
|
|
458
|
+
region(region: string): this;
|
|
459
|
+
referer(referer: string): this;
|
|
460
|
+
limit(limit: number): this;
|
|
461
|
+
sort(order: "asc" | "desc"): this;
|
|
462
|
+
private rateLimit;
|
|
463
|
+
protected getAnalytics(): Promise<R>;
|
|
464
|
+
then(onfulfilled?: ((value: R) => any) | null): Promise<any>;
|
|
465
|
+
}
|
|
466
|
+
declare class TopGatewayAnalyticsBuilder extends GatewayAnalyticsBuilder<TopGatewayAnalyticsQuery, TopGatewayAnalyticsItem[]> {
|
|
467
|
+
constructor(config: PinataConfig | undefined, domain: string, start: string, end: string, sortBy: "requests" | "bandwidth", attribute: "cid" | "country" | "region" | "user_agent" | "referer" | "file_name");
|
|
468
|
+
protected getAnalytics(): Promise<TopGatewayAnalyticsItem[]>;
|
|
469
|
+
all(): Promise<TopGatewayAnalyticsItem[]>;
|
|
470
|
+
}
|
|
471
|
+
declare class TimeIntervalGatewayAnalyticsBuilder extends GatewayAnalyticsBuilder<TimeIntervalGatewayAnalyticsQuery, TimeIntervalGatewayAnalyticsResponse> {
|
|
472
|
+
constructor(config: PinataConfig | undefined, domain: string, start: string, end: string, dateInterval: "day" | "week");
|
|
473
|
+
sortBy(sortBy: "requests" | "bandwidth"): this;
|
|
474
|
+
protected getAnalytics(): Promise<TimeIntervalGatewayAnalyticsResponse>;
|
|
475
|
+
all(): Promise<TimeIntervalGatewayAnalyticsResponse>;
|
|
476
|
+
}
|
|
389
477
|
|
|
390
|
-
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 SignatureOptions, type SignatureResponse, type UnpinResponse, type UpdateGroupOptions, type UploadCIDOptions, type UploadOptions, type UserPinnedDataResponse };
|
|
478
|
+
export { type AuthTestResponse, type ContentType, type DataEndponts, type Endpoints, type FileObject, type GatewayAnalyticsQuery, 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 SignatureOptions, type SignatureResponse, type TimeIntervalGatewayAnalyticsQuery, type TimeIntervalGatewayAnalyticsResponse, type TimePeriodItem, type TopGatewayAnalyticsItem, type TopGatewayAnalyticsQuery, type UnpinResponse, type UpdateGroupOptions, type UploadCIDOptions, type UploadOptions, type UserPinnedDataResponse };
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ type PinataConfig = {
|
|
|
3
3
|
pinataGateway?: string;
|
|
4
4
|
pinataGatewayKey?: string;
|
|
5
5
|
customHeaders?: Record<string, string>;
|
|
6
|
+
endpointUrl?: string;
|
|
6
7
|
};
|
|
7
8
|
type AuthTestResponse = {
|
|
8
9
|
message: string;
|
|
@@ -123,6 +124,42 @@ type GetCIDResponse = {
|
|
|
123
124
|
data?: JSON | string | Blob | null;
|
|
124
125
|
contentType: ContentType;
|
|
125
126
|
};
|
|
127
|
+
type GatewayAnalyticsQuery = {
|
|
128
|
+
gateway_domain: string;
|
|
129
|
+
start_date: string;
|
|
130
|
+
end_date: string;
|
|
131
|
+
cid?: string;
|
|
132
|
+
file_name?: string;
|
|
133
|
+
user_agent?: string;
|
|
134
|
+
country?: string;
|
|
135
|
+
region?: string;
|
|
136
|
+
referer?: string;
|
|
137
|
+
limit?: number;
|
|
138
|
+
sort_order?: "asc" | "desc";
|
|
139
|
+
};
|
|
140
|
+
type TopGatewayAnalyticsQuery = GatewayAnalyticsQuery & {
|
|
141
|
+
sort_by: "requests" | "bandwidth";
|
|
142
|
+
attribute: "cid" | "country" | "region" | "user_agent" | "referer" | "file_name";
|
|
143
|
+
};
|
|
144
|
+
type TopGatewayAnalyticsItem = {
|
|
145
|
+
value: string;
|
|
146
|
+
requests: number;
|
|
147
|
+
bandwidth: number;
|
|
148
|
+
};
|
|
149
|
+
type TimeIntervalGatewayAnalyticsQuery = GatewayAnalyticsQuery & {
|
|
150
|
+
sort_by?: "requests" | "bandwidth";
|
|
151
|
+
date_interval: "day" | "week";
|
|
152
|
+
};
|
|
153
|
+
type TimePeriodItem = {
|
|
154
|
+
period_start_time: string;
|
|
155
|
+
requests: number;
|
|
156
|
+
bandwidth: number;
|
|
157
|
+
};
|
|
158
|
+
type TimeIntervalGatewayAnalyticsResponse = {
|
|
159
|
+
total_requests: number;
|
|
160
|
+
total_bandwidth: number;
|
|
161
|
+
time_periods: TimePeriodItem[];
|
|
162
|
+
};
|
|
126
163
|
type UserPinnedDataResponse = {
|
|
127
164
|
pin_count: number;
|
|
128
165
|
pin_size_total: number;
|
|
@@ -241,6 +278,7 @@ declare class PinataSDK {
|
|
|
241
278
|
groups: Groups;
|
|
242
279
|
signatures: Signatures;
|
|
243
280
|
constructor(config?: PinataConfig);
|
|
281
|
+
setNewHeaders(headers: Record<string, string>): void;
|
|
244
282
|
testAuthentication(): Promise<AuthTestResponse>;
|
|
245
283
|
unpin(files: string[]): Promise<UnpinResponse[]>;
|
|
246
284
|
listFiles(): FilterFiles;
|
|
@@ -267,6 +305,7 @@ declare class UploadBuilder<T> {
|
|
|
267
305
|
declare class Upload {
|
|
268
306
|
config: PinataConfig | undefined;
|
|
269
307
|
constructor(config?: PinataConfig);
|
|
308
|
+
updateConfig(newConfig: PinataConfig): void;
|
|
270
309
|
file(file: FileObject, options?: UploadOptions): UploadBuilder<PinResponse>;
|
|
271
310
|
fileArray(files: FileObject[], options?: UploadOptions): UploadBuilder<PinResponse>;
|
|
272
311
|
base64(base64String: string, options?: UploadOptions): UploadBuilder<PinResponse>;
|
|
@@ -300,8 +339,22 @@ declare class FilterFiles {
|
|
|
300
339
|
declare class Gateways {
|
|
301
340
|
config: PinataConfig | undefined;
|
|
302
341
|
constructor(config?: PinataConfig);
|
|
342
|
+
updateConfig(newConfig: PinataConfig): void;
|
|
303
343
|
get(cid: string): Promise<GetCIDResponse>;
|
|
304
344
|
convert(url: string): Promise<string>;
|
|
345
|
+
topUsageAnalytics(options: {
|
|
346
|
+
domain: string;
|
|
347
|
+
start: string;
|
|
348
|
+
end: string;
|
|
349
|
+
sortBy: "requests" | "bandwidth";
|
|
350
|
+
attribute: "cid" | "country" | "region" | "user_agent" | "referer" | "file_name";
|
|
351
|
+
}): TopGatewayAnalyticsBuilder;
|
|
352
|
+
dateIntervalAnalytics(options: {
|
|
353
|
+
domain: string;
|
|
354
|
+
start: string;
|
|
355
|
+
end: string;
|
|
356
|
+
interval: "day" | "week";
|
|
357
|
+
}): TimeIntervalGatewayAnalyticsBuilder;
|
|
305
358
|
}
|
|
306
359
|
declare class FilterPinJobs {
|
|
307
360
|
private config;
|
|
@@ -324,12 +377,14 @@ declare class FilterPinJobs {
|
|
|
324
377
|
declare class Usage {
|
|
325
378
|
config: PinataConfig | undefined;
|
|
326
379
|
constructor(config?: PinataConfig);
|
|
380
|
+
updateConfig(newConfig: PinataConfig): void;
|
|
327
381
|
pinnedFileCount(): Promise<number>;
|
|
328
382
|
totalStorageSize(): Promise<number>;
|
|
329
383
|
}
|
|
330
384
|
declare class Keys {
|
|
331
385
|
config: PinataConfig | undefined;
|
|
332
386
|
constructor(config?: PinataConfig);
|
|
387
|
+
updateConfig(newConfig: PinataConfig): void;
|
|
333
388
|
create(options: KeyOptions): Promise<KeyResponse>;
|
|
334
389
|
list(): FilterKeys;
|
|
335
390
|
revoke(keys: string[]): Promise<RevokeKeyResponse[]>;
|
|
@@ -355,6 +410,7 @@ declare class FilterKeys {
|
|
|
355
410
|
declare class Groups {
|
|
356
411
|
config: PinataConfig | undefined;
|
|
357
412
|
constructor(config?: PinataConfig);
|
|
413
|
+
updateConfig(newConfig: PinataConfig): void;
|
|
358
414
|
create(options: GroupOptions): Promise<GroupResponseItem>;
|
|
359
415
|
list(): FilterGroups;
|
|
360
416
|
get(options: GetGroupOptions): Promise<GroupResponseItem>;
|
|
@@ -382,9 +438,41 @@ declare class FilterGroups {
|
|
|
382
438
|
declare class Signatures {
|
|
383
439
|
config: PinataConfig | undefined;
|
|
384
440
|
constructor(config?: PinataConfig);
|
|
441
|
+
updateConfig(newConfig: PinataConfig): void;
|
|
385
442
|
add(options: SignatureOptions): Promise<SignatureResponse>;
|
|
386
443
|
get(cid: string): Promise<SignatureResponse>;
|
|
387
444
|
delete(cid: string): Promise<string>;
|
|
388
445
|
}
|
|
446
|
+
declare class GatewayAnalyticsBuilder<T extends GatewayAnalyticsQuery, R> {
|
|
447
|
+
protected config: PinataConfig | undefined;
|
|
448
|
+
protected query: T;
|
|
449
|
+
private requestCount;
|
|
450
|
+
private lastRequestTime;
|
|
451
|
+
private readonly MAX_REQUESTS_PER_MINUTE;
|
|
452
|
+
private readonly MINUTE_IN_MS;
|
|
453
|
+
constructor(config: PinataConfig | undefined, query: T);
|
|
454
|
+
cid(cid: string): this;
|
|
455
|
+
fileName(fileName: string): this;
|
|
456
|
+
userAgent(userAgent: string): this;
|
|
457
|
+
country(country: string): this;
|
|
458
|
+
region(region: string): this;
|
|
459
|
+
referer(referer: string): this;
|
|
460
|
+
limit(limit: number): this;
|
|
461
|
+
sort(order: "asc" | "desc"): this;
|
|
462
|
+
private rateLimit;
|
|
463
|
+
protected getAnalytics(): Promise<R>;
|
|
464
|
+
then(onfulfilled?: ((value: R) => any) | null): Promise<any>;
|
|
465
|
+
}
|
|
466
|
+
declare class TopGatewayAnalyticsBuilder extends GatewayAnalyticsBuilder<TopGatewayAnalyticsQuery, TopGatewayAnalyticsItem[]> {
|
|
467
|
+
constructor(config: PinataConfig | undefined, domain: string, start: string, end: string, sortBy: "requests" | "bandwidth", attribute: "cid" | "country" | "region" | "user_agent" | "referer" | "file_name");
|
|
468
|
+
protected getAnalytics(): Promise<TopGatewayAnalyticsItem[]>;
|
|
469
|
+
all(): Promise<TopGatewayAnalyticsItem[]>;
|
|
470
|
+
}
|
|
471
|
+
declare class TimeIntervalGatewayAnalyticsBuilder extends GatewayAnalyticsBuilder<TimeIntervalGatewayAnalyticsQuery, TimeIntervalGatewayAnalyticsResponse> {
|
|
472
|
+
constructor(config: PinataConfig | undefined, domain: string, start: string, end: string, dateInterval: "day" | "week");
|
|
473
|
+
sortBy(sortBy: "requests" | "bandwidth"): this;
|
|
474
|
+
protected getAnalytics(): Promise<TimeIntervalGatewayAnalyticsResponse>;
|
|
475
|
+
all(): Promise<TimeIntervalGatewayAnalyticsResponse>;
|
|
476
|
+
}
|
|
389
477
|
|
|
390
|
-
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 SignatureOptions, type SignatureResponse, type UnpinResponse, type UpdateGroupOptions, type UploadCIDOptions, type UploadOptions, type UserPinnedDataResponse };
|
|
478
|
+
export { type AuthTestResponse, type ContentType, type DataEndponts, type Endpoints, type FileObject, type GatewayAnalyticsQuery, 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 SignatureOptions, type SignatureResponse, type TimeIntervalGatewayAnalyticsQuery, type TimeIntervalGatewayAnalyticsResponse, type TimePeriodItem, type TopGatewayAnalyticsItem, type TopGatewayAnalyticsQuery, type UnpinResponse, type UpdateGroupOptions, type UploadCIDOptions, type UploadOptions, type UserPinnedDataResponse };
|