pinata 1.7.2 → 1.8.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/dist/index.d.mts CHANGED
@@ -123,7 +123,7 @@ type SignedUrlOptions = {
123
123
  expires: number;
124
124
  gateway?: string;
125
125
  };
126
- type GatewayAnalyticsQuery = {
126
+ type AnalyticsQuery = {
127
127
  gateway_domain: string;
128
128
  start_date: string;
129
129
  end_date: string;
@@ -136,16 +136,19 @@ type GatewayAnalyticsQuery = {
136
136
  limit?: number;
137
137
  sort_order?: "asc" | "desc";
138
138
  };
139
- type TopGatewayAnalyticsQuery = GatewayAnalyticsQuery & {
139
+ type TopAnalyticsQuery = AnalyticsQuery & {
140
140
  sort_by: "requests" | "bandwidth";
141
141
  attribute: "cid" | "country" | "region" | "user_agent" | "referer" | "file_name";
142
142
  };
143
- type TopGatewayAnalyticsItem = {
143
+ type TopAnalyticsResponse = {
144
+ data: TopAnalyticsItem[];
145
+ };
146
+ type TopAnalyticsItem = {
144
147
  value: string;
145
148
  requests: number;
146
149
  bandwidth: number;
147
150
  };
148
- type TimeIntervalGatewayAnalyticsQuery = GatewayAnalyticsQuery & {
151
+ type TimeIntervalAnalyticsQuery = AnalyticsQuery & {
149
152
  sort_by?: "requests" | "bandwidth";
150
153
  date_interval: "day" | "week";
151
154
  };
@@ -154,7 +157,7 @@ type TimePeriodItem = {
154
157
  requests: number;
155
158
  bandwidth: number;
156
159
  };
157
- type TimeIntervalGatewayAnalyticsResponse = {
160
+ type TimeIntervalAnalyticsResponse = {
158
161
  total_requests: number;
159
162
  total_bandwidth: number;
160
163
  time_periods: TimePeriodItem[];
@@ -301,6 +304,7 @@ declare class PinataSDK {
301
304
  gateways: Gateways;
302
305
  keys: Keys;
303
306
  groups: Groups;
307
+ analytics: Analytics;
304
308
  constructor(config?: PinataConfig);
305
309
  setNewHeaders(headers: Record<string, string>): void;
306
310
  setNewJwt(jwt: string): void;
@@ -429,5 +433,70 @@ declare class FilterGroups {
429
433
  [Symbol.asyncIterator](): AsyncGenerator<GroupResponseItem, void, unknown>;
430
434
  all(): Promise<GroupResponseItem[]>;
431
435
  }
436
+ declare class Analytics {
437
+ config: PinataConfig | undefined;
438
+ requests: AnalyticsRequests;
439
+ bandwidth: AnalyticsBandwidth;
440
+ constructor(config?: PinataConfig);
441
+ updateConfig(newConfig: PinataConfig): void;
442
+ summary(options: {
443
+ domain: string;
444
+ start: string;
445
+ end: string;
446
+ interval: "day" | "week";
447
+ }): TimeIntervalAnalyticsBuilder;
448
+ }
449
+ declare class AnalyticsFilter {
450
+ protected config: PinataConfig | undefined;
451
+ protected query: TopAnalyticsQuery;
452
+ constructor(config: PinataConfig | undefined, domain: string, start: string, end: string);
453
+ cid(cid?: string): this;
454
+ fileName(fileName?: string): this;
455
+ userAgent(userAgent?: string): this;
456
+ country(country?: string): this;
457
+ region(region?: string): this;
458
+ referer(referer?: string): this;
459
+ limit(limit: number): this;
460
+ sort(order: "asc" | "desc"): this;
461
+ days(numberOfDays: number): this;
462
+ then(onfulfilled?: ((value: TopAnalyticsResponse) => any) | null): Promise<any>;
463
+ }
464
+ declare class AnalyticsRequests extends AnalyticsFilter {
465
+ constructor(config?: PinataConfig);
466
+ updateConfig(newConfig: PinataConfig): void;
467
+ customDates(start?: string, end?: string): this;
468
+ from(domain: string): this;
469
+ }
470
+ declare class AnalyticsBandwidth extends AnalyticsFilter {
471
+ constructor(config?: PinataConfig);
472
+ updateConfig(newConfig: PinataConfig): void;
473
+ customDates(start?: string, end?: string): this;
474
+ from(domain: string): this;
475
+ }
476
+ declare class AnalyticsBuilder<T extends AnalyticsQuery, R> {
477
+ protected config: PinataConfig | undefined;
478
+ protected query: T;
479
+ private requestCount;
480
+ private lastRequestTime;
481
+ private readonly MAX_REQUESTS_PER_MINUTE;
482
+ private readonly MINUTE_IN_MS;
483
+ constructor(config: PinataConfig | undefined, query: T);
484
+ cid(cid: string): this;
485
+ fileName(fileName: string): this;
486
+ userAgent(userAgent: string): this;
487
+ country(country: string): this;
488
+ region(region: string): this;
489
+ referer(referer: string): this;
490
+ limit(limit: number): this;
491
+ sort(order: "asc" | "desc"): this;
492
+ protected getAnalytics(): Promise<R>;
493
+ then(onfulfilled?: ((value: R) => any) | null): Promise<any>;
494
+ }
495
+ declare class TimeIntervalAnalyticsBuilder extends AnalyticsBuilder<TimeIntervalAnalyticsQuery, TimeIntervalAnalyticsResponse> {
496
+ constructor(config: PinataConfig | undefined, domain: string, start: string, end: string, dateInterval: "day" | "week");
497
+ sortBy(sortBy: "requests" | "bandwidth"): this;
498
+ protected getAnalytics(): Promise<TimeIntervalAnalyticsResponse>;
499
+ all(): Promise<TimeIntervalAnalyticsResponse>;
500
+ }
432
501
 
433
- export { type AuthTestResponse, type ContainsCIDResponse, type ContentType, type DataEndponts, type DeleteResponse, type Endpoints, type FileListItem, type FileListQuery, type FileListResponse, type FileObject, type GatewayAnalyticsQuery, type GetCIDResponse, type GetGroupOptions, type GroupCIDOptions, type GroupListResponse, type GroupOptions, type GroupQueryOptions, type GroupResponseItem, type JsonBody, type KeyListItem, type KeyListQuery, type KeyListResponse, type KeyOptions, type KeyPermissions, type KeyResponse, type OptimizeImageOptions, type PinJobItem, type PinJobQuery, type PinJobResponse, type PinataConfig, type PinataMetadata, PinataSDK, type PinningEndpoints, type RevokeKeyResponse, type SignatureOptions, type SignatureResponse, type SignedUrlOptions, type SwapCidOptions, type SwapCidResponse, type SwapHistoryOptions, type TimeIntervalGatewayAnalyticsQuery, type TimeIntervalGatewayAnalyticsResponse, type TimePeriodItem, type TopGatewayAnalyticsItem, type TopGatewayAnalyticsQuery, type UpdateFileOptions, type UpdateGroupFilesResponse, type UpdateGroupOptions, type UploadOptions, type UploadResponse, type UserPinnedDataResponse };
502
+ export { type AnalyticsQuery, type AuthTestResponse, type ContainsCIDResponse, type ContentType, type DataEndponts, type DeleteResponse, type Endpoints, type FileListItem, type FileListQuery, type FileListResponse, type FileObject, type GetCIDResponse, type GetGroupOptions, type GroupCIDOptions, type GroupListResponse, type GroupOptions, type GroupQueryOptions, type GroupResponseItem, type JsonBody, type KeyListItem, type KeyListQuery, type KeyListResponse, type KeyOptions, type KeyPermissions, type KeyResponse, type OptimizeImageOptions, type PinJobItem, type PinJobQuery, type PinJobResponse, type PinataConfig, type PinataMetadata, PinataSDK, type PinningEndpoints, type RevokeKeyResponse, type SignatureOptions, type SignatureResponse, type SignedUrlOptions, type SwapCidOptions, type SwapCidResponse, type SwapHistoryOptions, type TimeIntervalAnalyticsQuery, type TimeIntervalAnalyticsResponse, type TimePeriodItem, type TopAnalyticsItem, type TopAnalyticsQuery, type TopAnalyticsResponse, type UpdateFileOptions, type UpdateGroupFilesResponse, type UpdateGroupOptions, type UploadOptions, type UploadResponse, type UserPinnedDataResponse };
package/dist/index.d.ts CHANGED
@@ -123,7 +123,7 @@ type SignedUrlOptions = {
123
123
  expires: number;
124
124
  gateway?: string;
125
125
  };
126
- type GatewayAnalyticsQuery = {
126
+ type AnalyticsQuery = {
127
127
  gateway_domain: string;
128
128
  start_date: string;
129
129
  end_date: string;
@@ -136,16 +136,19 @@ type GatewayAnalyticsQuery = {
136
136
  limit?: number;
137
137
  sort_order?: "asc" | "desc";
138
138
  };
139
- type TopGatewayAnalyticsQuery = GatewayAnalyticsQuery & {
139
+ type TopAnalyticsQuery = AnalyticsQuery & {
140
140
  sort_by: "requests" | "bandwidth";
141
141
  attribute: "cid" | "country" | "region" | "user_agent" | "referer" | "file_name";
142
142
  };
143
- type TopGatewayAnalyticsItem = {
143
+ type TopAnalyticsResponse = {
144
+ data: TopAnalyticsItem[];
145
+ };
146
+ type TopAnalyticsItem = {
144
147
  value: string;
145
148
  requests: number;
146
149
  bandwidth: number;
147
150
  };
148
- type TimeIntervalGatewayAnalyticsQuery = GatewayAnalyticsQuery & {
151
+ type TimeIntervalAnalyticsQuery = AnalyticsQuery & {
149
152
  sort_by?: "requests" | "bandwidth";
150
153
  date_interval: "day" | "week";
151
154
  };
@@ -154,7 +157,7 @@ type TimePeriodItem = {
154
157
  requests: number;
155
158
  bandwidth: number;
156
159
  };
157
- type TimeIntervalGatewayAnalyticsResponse = {
160
+ type TimeIntervalAnalyticsResponse = {
158
161
  total_requests: number;
159
162
  total_bandwidth: number;
160
163
  time_periods: TimePeriodItem[];
@@ -301,6 +304,7 @@ declare class PinataSDK {
301
304
  gateways: Gateways;
302
305
  keys: Keys;
303
306
  groups: Groups;
307
+ analytics: Analytics;
304
308
  constructor(config?: PinataConfig);
305
309
  setNewHeaders(headers: Record<string, string>): void;
306
310
  setNewJwt(jwt: string): void;
@@ -429,5 +433,70 @@ declare class FilterGroups {
429
433
  [Symbol.asyncIterator](): AsyncGenerator<GroupResponseItem, void, unknown>;
430
434
  all(): Promise<GroupResponseItem[]>;
431
435
  }
436
+ declare class Analytics {
437
+ config: PinataConfig | undefined;
438
+ requests: AnalyticsRequests;
439
+ bandwidth: AnalyticsBandwidth;
440
+ constructor(config?: PinataConfig);
441
+ updateConfig(newConfig: PinataConfig): void;
442
+ summary(options: {
443
+ domain: string;
444
+ start: string;
445
+ end: string;
446
+ interval: "day" | "week";
447
+ }): TimeIntervalAnalyticsBuilder;
448
+ }
449
+ declare class AnalyticsFilter {
450
+ protected config: PinataConfig | undefined;
451
+ protected query: TopAnalyticsQuery;
452
+ constructor(config: PinataConfig | undefined, domain: string, start: string, end: string);
453
+ cid(cid?: string): this;
454
+ fileName(fileName?: string): this;
455
+ userAgent(userAgent?: string): this;
456
+ country(country?: string): this;
457
+ region(region?: string): this;
458
+ referer(referer?: string): this;
459
+ limit(limit: number): this;
460
+ sort(order: "asc" | "desc"): this;
461
+ days(numberOfDays: number): this;
462
+ then(onfulfilled?: ((value: TopAnalyticsResponse) => any) | null): Promise<any>;
463
+ }
464
+ declare class AnalyticsRequests extends AnalyticsFilter {
465
+ constructor(config?: PinataConfig);
466
+ updateConfig(newConfig: PinataConfig): void;
467
+ customDates(start?: string, end?: string): this;
468
+ from(domain: string): this;
469
+ }
470
+ declare class AnalyticsBandwidth extends AnalyticsFilter {
471
+ constructor(config?: PinataConfig);
472
+ updateConfig(newConfig: PinataConfig): void;
473
+ customDates(start?: string, end?: string): this;
474
+ from(domain: string): this;
475
+ }
476
+ declare class AnalyticsBuilder<T extends AnalyticsQuery, R> {
477
+ protected config: PinataConfig | undefined;
478
+ protected query: T;
479
+ private requestCount;
480
+ private lastRequestTime;
481
+ private readonly MAX_REQUESTS_PER_MINUTE;
482
+ private readonly MINUTE_IN_MS;
483
+ constructor(config: PinataConfig | undefined, query: T);
484
+ cid(cid: string): this;
485
+ fileName(fileName: string): this;
486
+ userAgent(userAgent: string): this;
487
+ country(country: string): this;
488
+ region(region: string): this;
489
+ referer(referer: string): this;
490
+ limit(limit: number): this;
491
+ sort(order: "asc" | "desc"): this;
492
+ protected getAnalytics(): Promise<R>;
493
+ then(onfulfilled?: ((value: R) => any) | null): Promise<any>;
494
+ }
495
+ declare class TimeIntervalAnalyticsBuilder extends AnalyticsBuilder<TimeIntervalAnalyticsQuery, TimeIntervalAnalyticsResponse> {
496
+ constructor(config: PinataConfig | undefined, domain: string, start: string, end: string, dateInterval: "day" | "week");
497
+ sortBy(sortBy: "requests" | "bandwidth"): this;
498
+ protected getAnalytics(): Promise<TimeIntervalAnalyticsResponse>;
499
+ all(): Promise<TimeIntervalAnalyticsResponse>;
500
+ }
432
501
 
433
- export { type AuthTestResponse, type ContainsCIDResponse, type ContentType, type DataEndponts, type DeleteResponse, type Endpoints, type FileListItem, type FileListQuery, type FileListResponse, type FileObject, type GatewayAnalyticsQuery, type GetCIDResponse, type GetGroupOptions, type GroupCIDOptions, type GroupListResponse, type GroupOptions, type GroupQueryOptions, type GroupResponseItem, type JsonBody, type KeyListItem, type KeyListQuery, type KeyListResponse, type KeyOptions, type KeyPermissions, type KeyResponse, type OptimizeImageOptions, type PinJobItem, type PinJobQuery, type PinJobResponse, type PinataConfig, type PinataMetadata, PinataSDK, type PinningEndpoints, type RevokeKeyResponse, type SignatureOptions, type SignatureResponse, type SignedUrlOptions, type SwapCidOptions, type SwapCidResponse, type SwapHistoryOptions, type TimeIntervalGatewayAnalyticsQuery, type TimeIntervalGatewayAnalyticsResponse, type TimePeriodItem, type TopGatewayAnalyticsItem, type TopGatewayAnalyticsQuery, type UpdateFileOptions, type UpdateGroupFilesResponse, type UpdateGroupOptions, type UploadOptions, type UploadResponse, type UserPinnedDataResponse };
502
+ export { type AnalyticsQuery, type AuthTestResponse, type ContainsCIDResponse, type ContentType, type DataEndponts, type DeleteResponse, type Endpoints, type FileListItem, type FileListQuery, type FileListResponse, type FileObject, type GetCIDResponse, type GetGroupOptions, type GroupCIDOptions, type GroupListResponse, type GroupOptions, type GroupQueryOptions, type GroupResponseItem, type JsonBody, type KeyListItem, type KeyListQuery, type KeyListResponse, type KeyOptions, type KeyPermissions, type KeyResponse, type OptimizeImageOptions, type PinJobItem, type PinJobQuery, type PinJobResponse, type PinataConfig, type PinataMetadata, PinataSDK, type PinningEndpoints, type RevokeKeyResponse, type SignatureOptions, type SignatureResponse, type SignedUrlOptions, type SwapCidOptions, type SwapCidResponse, type SwapHistoryOptions, type TimeIntervalAnalyticsQuery, type TimeIntervalAnalyticsResponse, type TimePeriodItem, type TopAnalyticsItem, type TopAnalyticsQuery, type TopAnalyticsResponse, type UpdateFileOptions, type UpdateGroupFilesResponse, type UpdateGroupOptions, type UploadOptions, type UploadResponse, type UserPinnedDataResponse };