@pinata/sdk 1.2.1 → 2.0.0-beta.2

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.
Files changed (75) hide show
  1. package/.babelrc +1 -1
  2. package/.eslintrc +7 -7
  3. package/.husky/pre-commit +6 -0
  4. package/.nvmrc +1 -1
  5. package/README.md +3 -3
  6. package/lib/pinata-sdk.js +906 -839
  7. package/lib/pinata-sdk.min.js +5 -5
  8. package/package.json +83 -71
  9. package/src/commands/data/getFilesByCount/{getFilesByCount.js → getFilesByCount.ts} +8 -9
  10. package/src/commands/data/index.ts +4 -0
  11. package/src/commands/data/pinList/pinList.ts +77 -0
  12. package/src/commands/data/pinList/{queryBuilder.js → queryBuilder.ts} +6 -16
  13. package/src/commands/data/{testAuthentication.js → testAuthentication.ts} +8 -9
  14. package/src/commands/data/{userPinnedDataTotal.js → userPinnedDataTotal.ts} +4 -9
  15. package/src/commands/pinning/{hashMetadata.js → hashMetadata.ts} +9 -11
  16. package/src/commands/pinning/index.ts +8 -0
  17. package/src/commands/pinning/{pinByHash.js → pinByHash.ts} +22 -11
  18. package/src/commands/pinning/pinFileToIPFS.ts +118 -0
  19. package/src/commands/pinning/pinFromFS.ts +50 -0
  20. package/src/commands/pinning/{pinJSONToIPFS.js → pinJSONToIPFS.ts} +5 -11
  21. package/src/commands/pinning/pinJobs/{pinJobs.js → pinJobs.ts} +23 -9
  22. package/src/commands/pinning/pinJobs/{queryBuilder.js → queryBuilder.ts} +2 -8
  23. package/src/commands/pinning/{unpin.js → unpin.ts} +3 -9
  24. package/src/{constants.js → constants.ts} +0 -0
  25. package/src/index.ts +120 -0
  26. package/src/third-party/base-path-converter.d.ts +3 -0
  27. package/src/third-party/is-ipfs.d.ts +5 -0
  28. package/src/util/{errorResponse.js → errorResponse.ts} +1 -1
  29. package/src/util/{validators.js → validators.ts} +21 -33
  30. package/test/commands/data/getFilesByCount/{getFilesByCount.test.js → getFilesByCount.test.ts} +23 -22
  31. package/test/commands/data/pinList/{pinList.test.js → pinList.test.ts} +25 -26
  32. package/test/commands/data/pinList/{queryBuilder.test.js → queryBuilder.test.ts} +9 -10
  33. package/test/commands/data/pinlist-sample-api.ts +540 -0
  34. package/test/commands/data/{testAuthentication.test.js → testAuthentication.test.ts} +13 -13
  35. package/test/commands/data/{userPinnedDataTotal.test.js → userPinnedDataTotal.test.ts} +4 -4
  36. package/test/commands/pinning/{hashMetadata.test.js → hashMetadata.test.ts} +7 -8
  37. package/test/commands/pinning/{pinByHash.test.js → pinByHash.test.ts} +4 -5
  38. package/test/commands/pinning/{pinFileToIPFS.test.js → pinFileToIPFS.test.ts} +9 -11
  39. package/test/commands/pinning/{pinFromFS.js → pinFromFS.ts} +5 -6
  40. package/test/commands/pinning/{pinJSONToIPFS.test.js → pinJSONToIPFS.test.ts} +4 -5
  41. package/test/commands/pinning/pinJobs/{pinJobs.test.js → pinJobs.test.ts} +4 -4
  42. package/test/commands/pinning/pinJobs/{queryBuilder.test.js → queryBuilder.test.ts} +5 -5
  43. package/test/commands/pinning/{unpin.test.js → unpin.test.ts} +4 -5
  44. package/test/util/validators.test.ts +234 -0
  45. package/tsconfig.json +2 -2
  46. package/types/commands/data/getFilesByCount/getFilesByCount.d.ts +4 -2
  47. package/types/commands/data/index.d.ts +4 -0
  48. package/types/commands/data/pinList/pinList.d.ts +45 -8
  49. package/types/commands/data/pinList/queryBuilder.d.ts +1 -7
  50. package/types/commands/data/testAuthentication.d.ts +5 -7
  51. package/types/commands/data/userPinnedDataTotal.d.ts +2 -7
  52. package/types/commands/pinning/hashMetadata.d.ts +3 -9
  53. package/types/commands/pinning/index.d.ts +8 -0
  54. package/types/commands/pinning/pinByHash.d.ts +14 -9
  55. package/types/commands/pinning/pinFileToIPFS.d.ts +25 -9
  56. package/types/commands/pinning/pinFromFS.d.ts +3 -9
  57. package/types/commands/pinning/pinJSONToIPFS.d.ts +3 -9
  58. package/types/commands/pinning/pinJobs/pinJobs.d.ts +20 -8
  59. package/types/commands/pinning/pinJobs/queryBuilder.d.ts +1 -7
  60. package/types/commands/pinning/unpin.d.ts +2 -8
  61. package/types/constants.d.ts +2 -2
  62. package/types/index.d.ts +37 -165
  63. package/types/util/errorResponse.d.ts +1 -1
  64. package/types/util/validators.d.ts +23 -46
  65. package/webpack.config.js +50 -53
  66. package/src/commands/data/pinList/pinList.js +0 -34
  67. package/src/commands/pinning/hashPinPolicy.js +0 -51
  68. package/src/commands/pinning/pinFileToIPFS.js +0 -53
  69. package/src/commands/pinning/pinFromFS.js +0 -100
  70. package/src/commands/pinning/userPinPolicy.js +0 -40
  71. package/src/index.js +0 -307
  72. package/test/commands/data/pinlist-sample-api.js +0 -540
  73. package/test/commands/pinning/hashPinPolicy.test.js +0 -65
  74. package/test/commands/pinning/userPinPolicy.test.js +0 -80
  75. package/test/util/validators.test.js +0 -234
package/.babelrc CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "presets": [["@babel/env", { "modules": "commonjs" , "useBuiltIns": "usage"}] ],
2
+ "presets": ["@babel/preset-typescript", ["@babel/env", { "modules": "commonjs" , "useBuiltIns": "usage"}] ],
3
3
  "plugins": ["add-module-exports", "@babel/plugin-transform-runtime"]
4
4
  }
5
5
 
package/.eslintrc CHANGED
@@ -1,9 +1,13 @@
1
1
  {
2
-
2
+ "extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
3
+ "parser": "@typescript-eslint/parser",
4
+ "plugins": ["@typescript-eslint"],
5
+ "root": true,
3
6
  "env": {
4
7
  "browser": true,
5
8
  "es6": true,
6
- "node": true
9
+ "node": true,
10
+ "jest": true
7
11
  },
8
12
 
9
13
  "globals": {
@@ -16,14 +20,10 @@
16
20
  "before": true,
17
21
  "it": true,
18
22
  "expect": true,
19
- "sinon": true
23
+ "sinon": true
20
24
  },
21
25
 
22
- "parser": "babel-eslint",
23
26
 
24
- "plugins": [
25
-
26
- ],
27
27
 
28
28
  "rules": {
29
29
  "block-scoped-var": 2,
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env sh
2
+ . "$(dirname -- "$0")/_/husky.sh"
3
+
4
+ npm run lint:fix
5
+ npm test
6
+ npm build
package/.nvmrc CHANGED
@@ -1 +1 @@
1
- v10.24
1
+ v14.0
package/README.md CHANGED
@@ -20,20 +20,20 @@ In the example below we provided with 3 ways to call the pinata SDK.
20
20
  ```javascript
21
21
  // Use the api keys by providing the strings directly
22
22
  const pinataSDK = require('@pinata/sdk');
23
- const pinata = pinataSDK('yourPinataApiKey', 'yourPinataSecretApiKey');
23
+ const pinata = new pinataSDK('yourPinataApiKey', 'yourPinataSecretApiKey');
24
24
  ```
25
25
 
26
26
  ```javascript
27
27
  // Use the api keys by specifying your api key and api secret
28
28
  const pinataSDK = require('@pinata/sdk');
29
- const pinata = pinataSDK({ pinataApiKey: 'yourPinataApiKey', pinataSecretApiKey: 'yourPinataSecretApiKey' });
29
+ const pinata = new pinataSDK({ pinataApiKey: 'yourPinataApiKey', pinataSecretApiKey: 'yourPinataSecretApiKey' });
30
30
 
31
31
  ```
32
32
 
33
33
  ```javascript
34
34
  // Use the JWT key
35
35
  const pinataSDK = require('@pinata/sdk');
36
- const pinata = pinataSDK({ pinataJWTKey: 'yourPinataJWTKey'});
36
+ const pinata = new pinataSDK({ pinataJWTKey: 'yourPinataJWTKey'});
37
37
  ```
38
38
 
39
39
  Quickly test that you can connect to the API with the following call: