@pinata/sdk 1.1.26 → 1.2.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/.babelrc CHANGED
@@ -1,4 +1,5 @@
1
1
  {
2
- "presets": [["@babel/env", { "modules": "commonjs" }]],
3
- "plugins": ["add-module-exports"]
4
- }
2
+ "presets": [["@babel/env", { "modules": "commonjs" , "useBuiltIns": "usage"}] ],
3
+ "plugins": ["add-module-exports", "@babel/plugin-transform-runtime"]
4
+ }
5
+
package/.nvmrc CHANGED
@@ -1 +1 @@
1
- v6.10
1
+ v10.24
package/README.md CHANGED
@@ -47,6 +47,7 @@ Once you've set up your instance, using the Pinata SDK is easy. Simply call your
47
47
  * Data
48
48
  * [testAuthentication](#testAuthentication-anchor)
49
49
  * [pinList](#pinList-anchor)
50
+ * [getFilesByCount](#getFilesByCount-anchor)
50
51
  * [userPinnedDataTotal](#userPinnedDataTotal-anchor)
51
52
  <br />
52
53
 
@@ -388,7 +389,7 @@ pinata.testAuthentication().then((result) => {
388
389
 
389
390
  <a name="pinList-anchor"></a>
390
391
  ### `pinList`
391
- Retrieve pin records for your Pinata account
392
+ Retrieve pin records for your Pinata account. In order to get the next page you have to manipulate `pageLimit` and `pageOffset` filter to get the next page. This method no longer return the total count of pins. We highly encourage you to use the auto-pagination method [getFilesByCount](#getFilesByCount-anchor).
392
393
 
393
394
  ##### `pinata.pinList(filters)`
394
395
  ##### Params
@@ -462,14 +463,73 @@ As an example, the following filter would only find records whose name contains
462
463
  }
463
464
  ```
464
465
 
466
+ Our libraries support auto-pagination. This feature easily handles fetching large lists of resources without having to manually paginate results and perform subsequent requests.
465
467
 
466
-
467
- #### Response
468
+ To use the auto-pagination feature in Node 10+, simply iterate over a "list" call with the parameters you need in a for await loop.
469
+
470
+ <a name="getFilesByCount-anchor"></a>
471
+ ### `getFilesByCount-anchor`
472
+ This method support auto-pagination. This feature easily handles fetching large lists of pin records for your Pinata account without having to manually paginate results and perform subsequent requests. To use the auto-pagination feature in Node 10+.
473
+
474
+ ##### `pinata.getFilesByCount(filters, count)`
475
+ ##### Params
476
+ * `filters` (optional): An object that can consist of the following optional query parameters:
477
+ * `hashContains` (optional): A string of alphanumeric characters that desires hashes must contain
478
+ * `pinStart` (optional): The earliest date the content is allowed to have been pinned. Must be a valid [ISO_8601](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString) date.
479
+ * `pinEnd` (optional): The earliest date the content is allowed to have been pinned. Must be a valid [ISO_8601](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString) date.
480
+ * `unpinStart` (optional): The earlist date the content is allowed to have been unpinned. Must be a valid [ISO_8601](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString) date.
481
+ * `unpinEnd` (optional): The latest date the content is allowed to have been unpinned. Must be a valid [ISO_8601](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString) date.
482
+ * `pinSizeMin` (optional): The minimum byte size that pin record you're looking for can have
483
+ * `pinSizeMax` (optional): The maximum byte size that pin record you're looking for can have
484
+ * `status` (optional): Filter pins using one of the following options
485
+ * `'all'` (Records for both pinned and unpinned content will be returned)
486
+ * `'pinned'` (Only records for pinned content will be returned)
487
+ * `'unpinned'` (Only records for unpinned content will be returned)
488
+ * `metadata` (optional): A JSON object that can be used to find records for content that had optional metadata included when it was added to Pinata. The metadata object is formatted as follows:
489
+ * `count` (optional): A Number that specifies how many pins you want. if no number is provided then it will pull all the pins based on your filter
490
+
491
+ ##### Metadata filter object formatting
468
492
  ```
469
493
  {
470
- count: (this is the total number of pin records that exist for the query filters you passed in),
471
- rows: [
472
- {
494
+ name: 'exampleName',
495
+ keyvalues: {
496
+ testKeyValue: {
497
+ value: 'exampleFilterValue',
498
+ op: 'exampleFilterOperation'
499
+ },
500
+ testKeyValue2: {
501
+ value: 'exampleFilterValue2',
502
+ op: 'exampleFilterOperation2'
503
+ }
504
+ }
505
+ }
506
+ ```
507
+ Filter explanations:
508
+ * `name` (optional): If provided, any records returned must have a name that contains the string provided for the 'name'.
509
+ * `keyvalues` (optional): Each keyvalue provided in this object have both a `value` and `op`
510
+ * `value` (required): This is the value which will be filtered on
511
+ * `op` (required): This is the filter operation that will be applied to the `value` that was provided. Valid op values are:
512
+ * `'gt'` (greater than the value provided)
513
+ * `'gte'` (greater than or equal to the value provided)
514
+ * `'lt'` (less than the value provided)
515
+ * `'lte'` (less than or equal to the value provided)
516
+ * `'ne'` (not equal to the value provided)
517
+ * `'eq'` (equal to the value provided)
518
+ * `'between'` (between the two values provided) - NOTE - This also requires a `secondValue` be provided as seen in the example below
519
+ * `'notBetween'` (not between the two values provided) - NOTE - This also requires a `secondValue` be provided as seen in the example below
520
+ * `'like'` (like the value provided)
521
+ * `'notLike'` (not like the value provided)
522
+ * `'iLike'` (case insensitive version of `like`)
523
+ * `'notILike'` (case insensitive version of `notLike`)
524
+ * `'regexp'` (filter the value provided based on a provided regular expression)
525
+ * `'iRegexp'` (case insensitive version of regexp)
526
+
527
+ ```
528
+
529
+ #### Response
530
+ ```
531
+ [
532
+ {
473
533
  id: (the id of your pin instance record),
474
534
  ipfs_pin_hash: (the IPFS multi-hash for the content you pinned),
475
535
  size: (this is how large (in bytes) the content pinned is),
@@ -491,11 +551,15 @@ As an example, the following filter would only find records whose name contains
491
551
  .
492
552
  .
493
553
  .
494
- ]
495
- }
554
+ ]
555
+
496
556
  ```
497
557
  ##### Example Code
558
+
498
559
  ```javascript
560
+ const pinataSDK = require('@pinata/sdk');
561
+ const pinata = pinataSDK('yourPinataApiKey', 'yourPinataSecretApiKey');
562
+
499
563
  const metadataFilter = {
500
564
  name: 'exampleName',
501
565
  keyvalues: {
@@ -516,13 +580,17 @@ const filters = {
516
580
  pageOffset: 0,
517
581
  metadata: metadataFilter
518
582
  };
519
- pinata.pinList(filters).then((result) => {
520
- //handle results here
521
- console.log(result);
522
- }).catch((err) => {
523
- //handle error here
524
- console.log(err);
525
- });
583
+
584
+ // more reference at [for await ...](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of)
585
+ for await (const item of pinata.getFilesByCount(filters, 35)) {
586
+ // ...(item) perform any task with the current item in the array of 35
587
+ }
588
+
589
+
590
+ for await (const item of pinata.getFilesByCount(filters)) {
591
+ // ...(item) perform any task with the current item the array is determined by all your pins
592
+ }
593
+
526
594
  ```
527
595
 
528
596
  <a name="userPinnedDataTotal-anchor"></a>