@pinata/sdk 1.2.0 → 2.0.0-beta.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 +1 -1
- package/.eslintrc +7 -7
- package/.husky/pre-commit +6 -0
- package/.nvmrc +1 -1
- package/README.md +22 -6
- package/lib/pinata-sdk.js +780 -604
- package/lib/pinata-sdk.min.js +5 -5
- package/package.json +83 -71
- package/src/commands/data/getFilesByCount/{getFilesByCount.js → getFilesByCount.ts} +9 -13
- package/src/commands/data/index.ts +4 -0
- package/src/commands/data/pinList/pinList.ts +77 -0
- package/src/commands/data/pinList/{queryBuilder.js → queryBuilder.ts} +6 -16
- package/src/commands/data/{testAuthentication.js → testAuthentication.ts} +10 -18
- package/src/commands/data/userPinnedDataTotal.ts +24 -0
- package/src/commands/pinning/{hashMetadata.js → hashMetadata.ts} +12 -21
- package/src/commands/pinning/index.ts +8 -0
- package/src/commands/pinning/{pinByHash.js → pinByHash.ts} +24 -20
- package/src/commands/pinning/{pinFileToIPFS.js → pinFileToIPFS.ts} +29 -24
- package/src/commands/pinning/{pinFromFS.js → pinFromFS.ts} +17 -39
- package/src/commands/pinning/{pinJSONToIPFS.js → pinJSONToIPFS.ts} +8 -20
- package/src/commands/pinning/pinJobs/pinJobs.ts +50 -0
- package/src/commands/pinning/pinJobs/{queryBuilder.js → queryBuilder.ts} +2 -8
- package/src/commands/pinning/{unpin.js → unpin.ts} +6 -19
- package/src/constants.ts +4 -0
- package/src/index.ts +120 -0
- package/src/third-party/base-path-converter.d.ts +3 -0
- package/src/third-party/is-ipfs.d.ts +5 -0
- package/src/third-party/recursive-fs.d.ts +5 -0
- package/src/util/{errorResponse.js → errorResponse.ts} +1 -1
- package/src/util/validators.ts +175 -0
- package/test/commands/data/getFilesByCount/{getFilesByCount.test.js → getFilesByCount.test.ts} +36 -39
- package/test/commands/data/pinList/pinList.test.ts +102 -0
- package/test/commands/data/pinList/{queryBuilder.test.js → queryBuilder.test.ts} +9 -10
- package/test/commands/data/pinlist-sample-api.ts +540 -0
- package/test/commands/data/testAuthentication.test.ts +34 -0
- package/test/commands/data/userPinnedDataTotal.test.ts +29 -0
- package/test/commands/pinning/hashMetadata.test.ts +76 -0
- package/test/commands/pinning/pinByHash.test.ts +46 -0
- package/test/commands/pinning/pinFileToIPFS.test.ts +53 -0
- package/test/commands/pinning/pinFromFS.ts +32 -0
- package/test/commands/pinning/pinJSONToIPFS.test.ts +42 -0
- package/test/commands/pinning/pinJobs/pinJobs.test.ts +29 -0
- package/test/commands/pinning/pinJobs/{queryBuilder.test.js → queryBuilder.test.ts} +5 -5
- package/test/commands/pinning/{unpin.test.js → unpin.test.ts} +9 -10
- package/test/util/{validators.test.js → validators.test.ts} +60 -18
- package/tsconfig.json +2 -2
- package/types/commands/data/getFilesByCount/getFilesByCount.d.ts +4 -2
- package/types/commands/data/index.d.ts +4 -0
- package/types/commands/data/pinList/pinList.d.ts +45 -8
- package/types/commands/data/pinList/queryBuilder.d.ts +1 -7
- package/types/commands/data/testAuthentication.d.ts +5 -7
- package/types/commands/data/userPinnedDataTotal.d.ts +2 -7
- package/types/commands/pinning/hashMetadata.d.ts +3 -9
- package/types/commands/pinning/hashPinPolicy.d.ts +1 -1
- package/types/commands/pinning/index.d.ts +8 -0
- package/types/commands/pinning/pinByHash.d.ts +14 -9
- package/types/commands/pinning/pinFileToIPFS.d.ts +25 -1
- package/types/commands/pinning/pinFromFS.d.ts +3 -9
- package/types/commands/pinning/pinJSONToIPFS.d.ts +3 -9
- package/types/commands/pinning/pinJobs/pinJobs.d.ts +20 -8
- package/types/commands/pinning/pinJobs/queryBuilder.d.ts +1 -7
- package/types/commands/pinning/unpin.d.ts +2 -8
- package/types/commands/pinning/userPinPolicy.d.ts +1 -1
- package/types/constants.d.ts +2 -1
- package/types/index.d.ts +38 -331
- package/types/util/errorResponse.d.ts +1 -1
- package/types/util/validators.d.ts +43 -26
- package/webpack.config.js +50 -53
- package/src/commands/data/pinList/pinList.js +0 -41
- package/src/commands/data/userPinnedDataTotal.js +0 -36
- package/src/commands/pinning/hashPinPolicy.js +0 -57
- package/src/commands/pinning/pinJobs/pinJobs.js +0 -42
- package/src/commands/pinning/userPinPolicy.js +0 -46
- package/src/constants.js +0 -1
- package/src/index.js +0 -262
- package/src/util/validators.js +0 -118
- package/test/commands/data/pinList/pinList.test.js +0 -98
- package/test/commands/data/pinlist-sample-api.js +0 -540
- package/test/commands/data/testAuthentication.test.js +0 -30
- package/test/commands/data/userPinnedDataTotal.test.js +0 -29
- package/test/commands/pinning/hashMetadata.test.js +0 -77
- package/test/commands/pinning/hashPinPolicy.test.js +0 -65
- package/test/commands/pinning/pinByHash.test.js +0 -47
- package/test/commands/pinning/pinFileToIPFS.test.js +0 -55
- package/test/commands/pinning/pinFromFS.js +0 -33
- package/test/commands/pinning/pinJSONToIPFS.test.js +0 -43
- package/test/commands/pinning/pinJobs/pinJobs.test.js +0 -29
- package/test/commands/pinning/userPinPolicy.test.js +0 -51
|
@@ -0,0 +1,540 @@
|
|
|
1
|
+
import { baseUrl } from '../../../src/constants';
|
|
2
|
+
|
|
3
|
+
export const fakeHeaders = {
|
|
4
|
+
headers: {
|
|
5
|
+
pinata_api_key: 'anykey',
|
|
6
|
+
pinata_secret_api_key: 'anysecret'
|
|
7
|
+
},
|
|
8
|
+
withCredentials: true
|
|
9
|
+
};
|
|
10
|
+
export const statusOk = {
|
|
11
|
+
status: 200
|
|
12
|
+
};
|
|
13
|
+
export const APIData = {
|
|
14
|
+
rows: [
|
|
15
|
+
{
|
|
16
|
+
id: 'b0fbdba0-de78-4736-9211-632633deb7be',
|
|
17
|
+
ipfs_pin_hash: 'QmRLzdxyiT3waRz1i2J1CU4w868VAkcVpAcQ5vAWEmcNHD',
|
|
18
|
+
size: 52960,
|
|
19
|
+
user_id: '6002b716-edbd-40ee-8f64-c50e452ccc3a',
|
|
20
|
+
date_pinned: '2022-10-05T22:46:53.843Z',
|
|
21
|
+
date_unpinned: null,
|
|
22
|
+
metadata: {
|
|
23
|
+
name: 'pin20.png',
|
|
24
|
+
keyvalues: null
|
|
25
|
+
},
|
|
26
|
+
regions: [
|
|
27
|
+
{
|
|
28
|
+
regionId: 'FRA1',
|
|
29
|
+
currentReplicationCount: 1,
|
|
30
|
+
desiredReplicationCount: 1
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
regionId: 'NYC1',
|
|
34
|
+
currentReplicationCount: 1,
|
|
35
|
+
desiredReplicationCount: 1
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
id: 'e5a59111-760c-4f24-8b98-fbb6918d578f',
|
|
41
|
+
ipfs_pin_hash: 'QmQ7M5otCbU3GdRizPNrktBfjP2kxxWMCAsT8X83GfQM6h',
|
|
42
|
+
size: 35318,
|
|
43
|
+
user_id: '6002b716-edbd-40ee-8f64-c50e452ccc3a',
|
|
44
|
+
date_pinned: '2022-10-05T22:46:44.534Z',
|
|
45
|
+
date_unpinned: null,
|
|
46
|
+
metadata: {
|
|
47
|
+
name: 'pin19.png',
|
|
48
|
+
keyvalues: null
|
|
49
|
+
},
|
|
50
|
+
regions: [
|
|
51
|
+
{
|
|
52
|
+
regionId: 'FRA1',
|
|
53
|
+
currentReplicationCount: 1,
|
|
54
|
+
desiredReplicationCount: 1
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
regionId: 'NYC1',
|
|
58
|
+
currentReplicationCount: 1,
|
|
59
|
+
desiredReplicationCount: 1
|
|
60
|
+
}
|
|
61
|
+
]
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
id: 'efb2394a-ba19-4df7-9042-7c30e64cd377',
|
|
65
|
+
ipfs_pin_hash: 'QmRz8F1KiLfw8SHfshhVjjwnSGjQrqspYjHUSBYFhrF6rD',
|
|
66
|
+
size: 66956,
|
|
67
|
+
user_id: '6002b716-edbd-40ee-8f64-c50e452ccc3a',
|
|
68
|
+
date_pinned: '2022-10-05T22:46:33.390Z',
|
|
69
|
+
date_unpinned: null,
|
|
70
|
+
metadata: {
|
|
71
|
+
name: 'pin18.png',
|
|
72
|
+
keyvalues: null
|
|
73
|
+
},
|
|
74
|
+
regions: [
|
|
75
|
+
{
|
|
76
|
+
regionId: 'FRA1',
|
|
77
|
+
currentReplicationCount: 1,
|
|
78
|
+
desiredReplicationCount: 1
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
regionId: 'NYC1',
|
|
82
|
+
currentReplicationCount: 1,
|
|
83
|
+
desiredReplicationCount: 1
|
|
84
|
+
}
|
|
85
|
+
]
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
id: '1b004592-e84b-4cb3-81ec-07850ba8186b',
|
|
89
|
+
ipfs_pin_hash: 'QmauuvrS18r487tLtFHjZoqXFc3xrZLDBQqnpKycs9LPau',
|
|
90
|
+
size: 84599,
|
|
91
|
+
user_id: '6002b716-edbd-40ee-8f64-c50e452ccc3a',
|
|
92
|
+
date_pinned: '2022-10-05T22:46:24.204Z',
|
|
93
|
+
date_unpinned: null,
|
|
94
|
+
metadata: {
|
|
95
|
+
name: 'pin17.png',
|
|
96
|
+
keyvalues: null
|
|
97
|
+
},
|
|
98
|
+
regions: [
|
|
99
|
+
{
|
|
100
|
+
regionId: 'FRA1',
|
|
101
|
+
currentReplicationCount: 1,
|
|
102
|
+
desiredReplicationCount: 1
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
regionId: 'NYC1',
|
|
106
|
+
currentReplicationCount: 1,
|
|
107
|
+
desiredReplicationCount: 1
|
|
108
|
+
}
|
|
109
|
+
]
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
id: 'e1cb1fe1-9d82-4553-90b2-8888d998ff54',
|
|
113
|
+
ipfs_pin_hash: 'QmV9S3Jx1abuA13VwD44CKRRnD7mdhbP4HL9HvjZdYpMZm',
|
|
114
|
+
size: 360611,
|
|
115
|
+
user_id: '6002b716-edbd-40ee-8f64-c50e452ccc3a',
|
|
116
|
+
date_pinned: '2022-10-05T22:46:14.291Z',
|
|
117
|
+
date_unpinned: null,
|
|
118
|
+
metadata: {
|
|
119
|
+
name: 'pin16.png',
|
|
120
|
+
keyvalues: null
|
|
121
|
+
},
|
|
122
|
+
regions: [
|
|
123
|
+
{
|
|
124
|
+
regionId: 'FRA1',
|
|
125
|
+
currentReplicationCount: 1,
|
|
126
|
+
desiredReplicationCount: 1
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
regionId: 'NYC1',
|
|
130
|
+
currentReplicationCount: 1,
|
|
131
|
+
desiredReplicationCount: 1
|
|
132
|
+
}
|
|
133
|
+
]
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
id: '38c0008a-5996-4166-b409-fe1fb699b62f',
|
|
137
|
+
ipfs_pin_hash: 'QmcC1qN1ALkeTrd4wVPgP2R6UsTKBRb7PNL91GwSUYAc2q',
|
|
138
|
+
size: 329724,
|
|
139
|
+
user_id: '6002b716-edbd-40ee-8f64-c50e452ccc3a',
|
|
140
|
+
date_pinned: '2022-10-05T22:45:56.523Z',
|
|
141
|
+
date_unpinned: null,
|
|
142
|
+
metadata: {
|
|
143
|
+
name: 'pin15.png',
|
|
144
|
+
keyvalues: null
|
|
145
|
+
},
|
|
146
|
+
regions: [
|
|
147
|
+
{
|
|
148
|
+
regionId: 'FRA1',
|
|
149
|
+
currentReplicationCount: 1,
|
|
150
|
+
desiredReplicationCount: 1
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
regionId: 'NYC1',
|
|
154
|
+
currentReplicationCount: 1,
|
|
155
|
+
desiredReplicationCount: 1
|
|
156
|
+
}
|
|
157
|
+
]
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
id: '90cddd06-5531-4234-adf5-680fd7c59a62',
|
|
161
|
+
ipfs_pin_hash: 'QmVMM2ogFUFZMnRtcsAj4zgBbAv8MYKRetD3iMNXjHWDqh',
|
|
162
|
+
size: 49229,
|
|
163
|
+
user_id: '6002b716-edbd-40ee-8f64-c50e452ccc3a',
|
|
164
|
+
date_pinned: '2022-10-05T22:45:43.837Z',
|
|
165
|
+
date_unpinned: null,
|
|
166
|
+
metadata: {
|
|
167
|
+
name: 'pin14.png',
|
|
168
|
+
keyvalues: null
|
|
169
|
+
},
|
|
170
|
+
regions: [
|
|
171
|
+
{
|
|
172
|
+
regionId: 'FRA1',
|
|
173
|
+
currentReplicationCount: 1,
|
|
174
|
+
desiredReplicationCount: 1
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
regionId: 'NYC1',
|
|
178
|
+
currentReplicationCount: 1,
|
|
179
|
+
desiredReplicationCount: 1
|
|
180
|
+
}
|
|
181
|
+
]
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
id: '40aff586-32a5-4142-9973-d35a0d596941',
|
|
185
|
+
ipfs_pin_hash: 'QmWTnoGJ7AP2c3USkX42SpG4YdiiWNuQNvcpxR3uy7ZWfM',
|
|
186
|
+
size: 76626,
|
|
187
|
+
user_id: '6002b716-edbd-40ee-8f64-c50e452ccc3a',
|
|
188
|
+
date_pinned: '2022-10-05T22:45:33.758Z',
|
|
189
|
+
date_unpinned: null,
|
|
190
|
+
metadata: {
|
|
191
|
+
name: 'pin13.png',
|
|
192
|
+
keyvalues: null
|
|
193
|
+
},
|
|
194
|
+
regions: [
|
|
195
|
+
{
|
|
196
|
+
regionId: 'FRA1',
|
|
197
|
+
currentReplicationCount: 1,
|
|
198
|
+
desiredReplicationCount: 1
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
regionId: 'NYC1',
|
|
202
|
+
currentReplicationCount: 1,
|
|
203
|
+
desiredReplicationCount: 1
|
|
204
|
+
}
|
|
205
|
+
]
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
id: '38814347-144f-4140-9838-f7fce4d11f21',
|
|
209
|
+
ipfs_pin_hash: 'QmZmUm6smWQqSquvWJr51e14fC6nT4HHsCWXcWKXnhNQH9',
|
|
210
|
+
size: 139412,
|
|
211
|
+
user_id: '6002b716-edbd-40ee-8f64-c50e452ccc3a',
|
|
212
|
+
date_pinned: '2022-10-05T22:45:23.063Z',
|
|
213
|
+
date_unpinned: null,
|
|
214
|
+
metadata: {
|
|
215
|
+
name: 'pin12.png',
|
|
216
|
+
keyvalues: null
|
|
217
|
+
},
|
|
218
|
+
regions: [
|
|
219
|
+
{
|
|
220
|
+
regionId: 'FRA1',
|
|
221
|
+
currentReplicationCount: 1,
|
|
222
|
+
desiredReplicationCount: 1
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
regionId: 'NYC1',
|
|
226
|
+
currentReplicationCount: 1,
|
|
227
|
+
desiredReplicationCount: 1
|
|
228
|
+
}
|
|
229
|
+
]
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
id: '381335b2-f64e-4c95-b5e6-63a6110bf639',
|
|
233
|
+
ipfs_pin_hash: 'QmVcwfTjRki1o7WvCkfMVVfv9oRj3kaFnfWLq62TuAEqD9',
|
|
234
|
+
size: 146257,
|
|
235
|
+
user_id: '6002b716-edbd-40ee-8f64-c50e452ccc3a',
|
|
236
|
+
date_pinned: '2022-10-05T22:45:12.268Z',
|
|
237
|
+
date_unpinned: null,
|
|
238
|
+
metadata: {
|
|
239
|
+
name: 'pin11.png',
|
|
240
|
+
keyvalues: null
|
|
241
|
+
},
|
|
242
|
+
regions: [
|
|
243
|
+
{
|
|
244
|
+
regionId: 'FRA1',
|
|
245
|
+
currentReplicationCount: 1,
|
|
246
|
+
desiredReplicationCount: 1
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
regionId: 'NYC1',
|
|
250
|
+
currentReplicationCount: 1,
|
|
251
|
+
desiredReplicationCount: 1
|
|
252
|
+
}
|
|
253
|
+
]
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
id: 'b1ce6263-b1fb-4831-8c74-6f71b31e72c6',
|
|
257
|
+
ipfs_pin_hash: 'QmSWCZLFjGuWYjxDCvPcyqwA35kdH5RYExex3U2DXrXcfH',
|
|
258
|
+
size: 89932,
|
|
259
|
+
user_id: '6002b716-edbd-40ee-8f64-c50e452ccc3a',
|
|
260
|
+
date_pinned: '2022-10-05T22:45:02.143Z',
|
|
261
|
+
date_unpinned: null,
|
|
262
|
+
metadata: {
|
|
263
|
+
name: 'pin10.png',
|
|
264
|
+
keyvalues: null
|
|
265
|
+
},
|
|
266
|
+
regions: [
|
|
267
|
+
{
|
|
268
|
+
regionId: 'FRA1',
|
|
269
|
+
currentReplicationCount: 1,
|
|
270
|
+
desiredReplicationCount: 1
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
regionId: 'NYC1',
|
|
274
|
+
currentReplicationCount: 1,
|
|
275
|
+
desiredReplicationCount: 1
|
|
276
|
+
}
|
|
277
|
+
]
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
id: '65f89885-9a9c-47f5-8442-63942296f3f3',
|
|
281
|
+
ipfs_pin_hash: 'QmZpTaAAxUdscD6mMkYADYHVRbekhHvXyL6MCCRc4hcM4t',
|
|
282
|
+
size: 121532,
|
|
283
|
+
user_id: '6002b716-edbd-40ee-8f64-c50e452ccc3a',
|
|
284
|
+
date_pinned: '2022-10-05T22:44:50.487Z',
|
|
285
|
+
date_unpinned: null,
|
|
286
|
+
metadata: {
|
|
287
|
+
name: 'pin9.png',
|
|
288
|
+
keyvalues: null
|
|
289
|
+
},
|
|
290
|
+
regions: [
|
|
291
|
+
{
|
|
292
|
+
regionId: 'FRA1',
|
|
293
|
+
currentReplicationCount: 1,
|
|
294
|
+
desiredReplicationCount: 1
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
regionId: 'NYC1',
|
|
298
|
+
currentReplicationCount: 1,
|
|
299
|
+
desiredReplicationCount: 1
|
|
300
|
+
}
|
|
301
|
+
]
|
|
302
|
+
},
|
|
303
|
+
{
|
|
304
|
+
id: 'd74055a9-4b6b-439e-99c0-b4b908d027c7',
|
|
305
|
+
ipfs_pin_hash: 'QmdKakBkbCpdeLTf3NMR382it4kZdo848FTvbSGNmmAmSi',
|
|
306
|
+
size: 80314,
|
|
307
|
+
user_id: '6002b716-edbd-40ee-8f64-c50e452ccc3a',
|
|
308
|
+
date_pinned: '2022-10-05T22:44:38.972Z',
|
|
309
|
+
date_unpinned: null,
|
|
310
|
+
metadata: {
|
|
311
|
+
name: 'pin8.png',
|
|
312
|
+
keyvalues: null
|
|
313
|
+
},
|
|
314
|
+
regions: [
|
|
315
|
+
{
|
|
316
|
+
regionId: 'FRA1',
|
|
317
|
+
currentReplicationCount: 1,
|
|
318
|
+
desiredReplicationCount: 1
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
regionId: 'NYC1',
|
|
322
|
+
currentReplicationCount: 1,
|
|
323
|
+
desiredReplicationCount: 1
|
|
324
|
+
}
|
|
325
|
+
]
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
id: '53a56f84-89c7-4947-979e-8f6e8d584151',
|
|
329
|
+
ipfs_pin_hash: 'QmfLTuCn3iyhgL6iyZqGNovnAkv5ip5oAPFWmPTYXkmFgb',
|
|
330
|
+
size: 115132,
|
|
331
|
+
user_id: '6002b716-edbd-40ee-8f64-c50e452ccc3a',
|
|
332
|
+
date_pinned: '2022-10-05T22:44:28.357Z',
|
|
333
|
+
date_unpinned: null,
|
|
334
|
+
metadata: {
|
|
335
|
+
name: 'pin7.png',
|
|
336
|
+
keyvalues: null
|
|
337
|
+
},
|
|
338
|
+
regions: [
|
|
339
|
+
{
|
|
340
|
+
regionId: 'FRA1',
|
|
341
|
+
currentReplicationCount: 1,
|
|
342
|
+
desiredReplicationCount: 1
|
|
343
|
+
},
|
|
344
|
+
{
|
|
345
|
+
regionId: 'NYC1',
|
|
346
|
+
currentReplicationCount: 1,
|
|
347
|
+
desiredReplicationCount: 1
|
|
348
|
+
}
|
|
349
|
+
]
|
|
350
|
+
},
|
|
351
|
+
{
|
|
352
|
+
id: '7ce5f037-b991-4bcb-b888-6f1dd2f4005c',
|
|
353
|
+
ipfs_pin_hash: 'QmaDVCBZ9sMQ7AFAqGqWqLymcetJBMsH9TuxwmqqZaVRss',
|
|
354
|
+
size: 68293,
|
|
355
|
+
user_id: '6002b716-edbd-40ee-8f64-c50e452ccc3a',
|
|
356
|
+
date_pinned: '2022-10-05T22:44:16.939Z',
|
|
357
|
+
date_unpinned: null,
|
|
358
|
+
metadata: {
|
|
359
|
+
name: 'pin6.png',
|
|
360
|
+
keyvalues: null
|
|
361
|
+
},
|
|
362
|
+
regions: [
|
|
363
|
+
{
|
|
364
|
+
regionId: 'FRA1',
|
|
365
|
+
currentReplicationCount: 1,
|
|
366
|
+
desiredReplicationCount: 1
|
|
367
|
+
},
|
|
368
|
+
{
|
|
369
|
+
regionId: 'NYC1',
|
|
370
|
+
currentReplicationCount: 1,
|
|
371
|
+
desiredReplicationCount: 1
|
|
372
|
+
}
|
|
373
|
+
]
|
|
374
|
+
},
|
|
375
|
+
{
|
|
376
|
+
id: 'b6d9d849-51e4-4ea4-ae01-8c1cc000d0ad',
|
|
377
|
+
ipfs_pin_hash: 'QmNsq42HSV4CAvNLuwe9ZjPkUYQoGiwxXdfyRRLx7Njd7f',
|
|
378
|
+
size: 82560,
|
|
379
|
+
user_id: '6002b716-edbd-40ee-8f64-c50e452ccc3a',
|
|
380
|
+
date_pinned: '2022-10-05T22:44:05.743Z',
|
|
381
|
+
date_unpinned: null,
|
|
382
|
+
metadata: {
|
|
383
|
+
name: 'pin5.png',
|
|
384
|
+
keyvalues: null
|
|
385
|
+
},
|
|
386
|
+
regions: [
|
|
387
|
+
{
|
|
388
|
+
regionId: 'FRA1',
|
|
389
|
+
currentReplicationCount: 1,
|
|
390
|
+
desiredReplicationCount: 1
|
|
391
|
+
},
|
|
392
|
+
{
|
|
393
|
+
regionId: 'NYC1',
|
|
394
|
+
currentReplicationCount: 1,
|
|
395
|
+
desiredReplicationCount: 1
|
|
396
|
+
}
|
|
397
|
+
]
|
|
398
|
+
},
|
|
399
|
+
{
|
|
400
|
+
id: 'ae45ab56-aa22-4ffd-8116-96a5b6bc6fc8',
|
|
401
|
+
ipfs_pin_hash: 'QmT8fjVvMZKEDgPZ3JcYqsZvdZLB1S8qT3FE777BE1R3RL',
|
|
402
|
+
size: 38428,
|
|
403
|
+
user_id: '6002b716-edbd-40ee-8f64-c50e452ccc3a',
|
|
404
|
+
date_pinned: '2022-10-05T22:43:47.227Z',
|
|
405
|
+
date_unpinned: null,
|
|
406
|
+
metadata: {
|
|
407
|
+
name: 'pin4.png',
|
|
408
|
+
keyvalues: null
|
|
409
|
+
},
|
|
410
|
+
regions: [
|
|
411
|
+
{
|
|
412
|
+
regionId: 'FRA1',
|
|
413
|
+
currentReplicationCount: 1,
|
|
414
|
+
desiredReplicationCount: 1
|
|
415
|
+
},
|
|
416
|
+
{
|
|
417
|
+
regionId: 'NYC1',
|
|
418
|
+
currentReplicationCount: 1,
|
|
419
|
+
desiredReplicationCount: 1
|
|
420
|
+
}
|
|
421
|
+
]
|
|
422
|
+
},
|
|
423
|
+
{
|
|
424
|
+
id: '86ee7b32-b723-4ef0-97ef-7efb4386ebcf',
|
|
425
|
+
ipfs_pin_hash: 'QmZCZwCqKG8tsLCeUCCeevdKAQJy53uLCwDuXptg1E9xUa',
|
|
426
|
+
size: 113338,
|
|
427
|
+
user_id: '6002b716-edbd-40ee-8f64-c50e452ccc3a',
|
|
428
|
+
date_pinned: '2022-10-05T22:42:09.658Z',
|
|
429
|
+
date_unpinned: null,
|
|
430
|
+
metadata: {
|
|
431
|
+
name: 'pin3.png',
|
|
432
|
+
keyvalues: null
|
|
433
|
+
},
|
|
434
|
+
regions: [
|
|
435
|
+
{
|
|
436
|
+
regionId: 'FRA1',
|
|
437
|
+
currentReplicationCount: 1,
|
|
438
|
+
desiredReplicationCount: 1
|
|
439
|
+
},
|
|
440
|
+
{
|
|
441
|
+
regionId: 'NYC1',
|
|
442
|
+
currentReplicationCount: 1,
|
|
443
|
+
desiredReplicationCount: 1
|
|
444
|
+
}
|
|
445
|
+
]
|
|
446
|
+
},
|
|
447
|
+
{
|
|
448
|
+
id: '76bb512a-52de-41ab-9008-22b0b0965a59',
|
|
449
|
+
ipfs_pin_hash: 'QmSgwD6mjitrh59koPLpswMtwUZnuASi7durphHuXUQnex',
|
|
450
|
+
size: 23661,
|
|
451
|
+
user_id: '6002b716-edbd-40ee-8f64-c50e452ccc3a',
|
|
452
|
+
date_pinned: '2022-10-05T22:41:57.767Z',
|
|
453
|
+
date_unpinned: null,
|
|
454
|
+
metadata: {
|
|
455
|
+
name: 'pin2.png',
|
|
456
|
+
keyvalues: null
|
|
457
|
+
},
|
|
458
|
+
regions: [
|
|
459
|
+
{
|
|
460
|
+
regionId: 'FRA1',
|
|
461
|
+
currentReplicationCount: 1,
|
|
462
|
+
desiredReplicationCount: 1
|
|
463
|
+
},
|
|
464
|
+
{
|
|
465
|
+
regionId: 'NYC1',
|
|
466
|
+
currentReplicationCount: 1,
|
|
467
|
+
desiredReplicationCount: 1
|
|
468
|
+
}
|
|
469
|
+
]
|
|
470
|
+
},
|
|
471
|
+
{
|
|
472
|
+
id: '0b5ba870-1230-47ba-8298-6de92978ff3f',
|
|
473
|
+
ipfs_pin_hash: 'QmNdoq9LuNmKYCKTWsCaowLWCZxv6K5payarU8i5TB4Bo6',
|
|
474
|
+
size: 6850,
|
|
475
|
+
user_id: '6002b716-edbd-40ee-8f64-c50e452ccc3a',
|
|
476
|
+
date_pinned: '2022-10-05T22:41:45.109Z',
|
|
477
|
+
date_unpinned: null,
|
|
478
|
+
metadata: {
|
|
479
|
+
name: 'pin1.png',
|
|
480
|
+
keyvalues: null
|
|
481
|
+
},
|
|
482
|
+
regions: [
|
|
483
|
+
{
|
|
484
|
+
regionId: 'FRA1',
|
|
485
|
+
currentReplicationCount: 0,
|
|
486
|
+
desiredReplicationCount: 1
|
|
487
|
+
},
|
|
488
|
+
{
|
|
489
|
+
regionId: 'NYC1',
|
|
490
|
+
currentReplicationCount: 1,
|
|
491
|
+
desiredReplicationCount: 1
|
|
492
|
+
}
|
|
493
|
+
]
|
|
494
|
+
}
|
|
495
|
+
]
|
|
496
|
+
};
|
|
497
|
+
|
|
498
|
+
export const pinListAxiosMockPages = {
|
|
499
|
+
firstPage: {
|
|
500
|
+
url: `${baseUrl}/data/pinList?includeCount=false&status=pinned&pageLimit=10&`,
|
|
501
|
+
headers: fakeHeaders,
|
|
502
|
+
response: {
|
|
503
|
+
...statusOk,
|
|
504
|
+
data: {
|
|
505
|
+
rows: APIData.rows.slice(0, 10)
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
},
|
|
509
|
+
secondPage: {
|
|
510
|
+
url: `${baseUrl}/data/pinList?includeCount=false&status=pinned&pageLimit=10&pageOffset=10&`,
|
|
511
|
+
headers: fakeHeaders,
|
|
512
|
+
response: {
|
|
513
|
+
...statusOk,
|
|
514
|
+
data: {
|
|
515
|
+
rows: APIData.rows.slice(10, 20)
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
},
|
|
519
|
+
thirdPageEmpty: {
|
|
520
|
+
url: `${baseUrl}/data/pinList?includeCount=false&status=pinned&pageLimit=10&pageOffset=20&`,
|
|
521
|
+
headers: fakeHeaders,
|
|
522
|
+
response: {
|
|
523
|
+
...statusOk,
|
|
524
|
+
data: {
|
|
525
|
+
rows: []
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
},
|
|
529
|
+
firstPageEmpty: {
|
|
530
|
+
url: `${baseUrl}/data/pinList?includeCount=false&status=pinned&pageLimit=10&`,
|
|
531
|
+
headers: fakeHeaders,
|
|
532
|
+
|
|
533
|
+
response: {
|
|
534
|
+
...statusOk,
|
|
535
|
+
data: {
|
|
536
|
+
rows: []
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import testAuthentication from '../../../src/commands/data/testAuthentication';
|
|
3
|
+
|
|
4
|
+
jest.mock('axios');
|
|
5
|
+
|
|
6
|
+
test('Result other than 200 status is returned', () => {
|
|
7
|
+
const badStatus = {
|
|
8
|
+
status: 700
|
|
9
|
+
};
|
|
10
|
+
(axios.get as jest.Mock).mockResolvedValue(badStatus);
|
|
11
|
+
expect.assertions(1);
|
|
12
|
+
return expect(testAuthentication({ pinataApiKey: 'test', pinataSecretApiKey: 'test' })).rejects.toEqual(
|
|
13
|
+
Error(`unknown server response while authenticating: ${badStatus}`)
|
|
14
|
+
);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
test('200 status is returned', () => {
|
|
18
|
+
const goodStatus = {
|
|
19
|
+
status: 200
|
|
20
|
+
};
|
|
21
|
+
(axios.get as jest.Mock).mockResolvedValue(goodStatus);
|
|
22
|
+
expect.assertions(1);
|
|
23
|
+
return expect(testAuthentication({ pinataApiKey: 'test', pinataSecretApiKey: 'test' })).resolves.toEqual({
|
|
24
|
+
authenticated: true
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
test('Rejection handled', () => {
|
|
29
|
+
(axios.get as jest.Mock).mockRejectedValue('test error');
|
|
30
|
+
expect.assertions(1);
|
|
31
|
+
return expect(testAuthentication({ pinataApiKey: 'test', pinataSecretApiKey: 'test' })).rejects.toEqual(
|
|
32
|
+
'test error'
|
|
33
|
+
);
|
|
34
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import userPinnedDataTotal from '../../../src/commands/data/userPinnedDataTotal';
|
|
3
|
+
|
|
4
|
+
jest.mock('axios');
|
|
5
|
+
|
|
6
|
+
test('Result other than 200 status is returned', () => {
|
|
7
|
+
const badStatus = {
|
|
8
|
+
status: 700
|
|
9
|
+
};
|
|
10
|
+
(axios.get as jest.Mock).mockResolvedValue(badStatus);
|
|
11
|
+
expect.assertions(1);
|
|
12
|
+
expect(userPinnedDataTotal({ pinataApiKey: 'test', pinataSecretApiKey: 'test' })).rejects.toEqual(Error(`unknown server response while attempting to retrieve pinned data total: ${badStatus}`));
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
test('200 status is returned', () => {
|
|
16
|
+
const goodStatus = {
|
|
17
|
+
status: 200,
|
|
18
|
+
data: 'testData'
|
|
19
|
+
};
|
|
20
|
+
(axios.get as jest.Mock).mockResolvedValue(goodStatus);
|
|
21
|
+
expect.assertions(1);
|
|
22
|
+
expect(userPinnedDataTotal({ pinataApiKey: 'test', pinataSecretApiKey: 'test' })).resolves.toEqual(goodStatus.data);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
test('Rejection handled', () => {
|
|
26
|
+
(axios.get as jest.Mock).mockRejectedValue('test error');
|
|
27
|
+
expect.assertions(1);
|
|
28
|
+
expect(userPinnedDataTotal({ pinataApiKey: 'test', pinataSecretApiKey: 'test' })).rejects.toEqual('test error');
|
|
29
|
+
});
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import hashMetadata from '../../../src/commands/pinning/hashMetadata';
|
|
3
|
+
|
|
4
|
+
jest.mock('axios');
|
|
5
|
+
|
|
6
|
+
//common values
|
|
7
|
+
const badHash = 'test';
|
|
8
|
+
const goodHash = 'Qma6e8dovfLyiG2UUfdkSHNPAySzrWLX9qVXb44v1muqcp';
|
|
9
|
+
const metadata = {
|
|
10
|
+
name: 'testname',
|
|
11
|
+
keyvalues: {
|
|
12
|
+
newKey: 'newValue'
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const metadataTwo = {
|
|
17
|
+
name: 'testname',
|
|
18
|
+
keyvalues: {
|
|
19
|
+
newKey: 'newValue',
|
|
20
|
+
secondKey: 'secondValue'
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
test('No ipfsPinHash value provided should error', () => {
|
|
25
|
+
expect(() => {
|
|
26
|
+
hashMetadata({ pinataApiKey: 'test', pinataSecretApiKey: 'test' }, null, metadata);
|
|
27
|
+
}).toThrow();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test('Invalid ipfsPinHash value is provided', () => {
|
|
31
|
+
expect(() => {
|
|
32
|
+
hashMetadata({ pinataApiKey: 'test', pinataSecretApiKey: 'test' }, badHash, metadata);
|
|
33
|
+
}).toThrow();
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test('No metadata object provided should error', () => {
|
|
37
|
+
expect(() => {
|
|
38
|
+
hashMetadata({ pinataApiKey: 'test', pinataSecretApiKey: 'test' }, goodHash);
|
|
39
|
+
}).toThrow();
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
test('One keyvalue pair is added', () => {
|
|
43
|
+
const goodStatus = {
|
|
44
|
+
status: 200,
|
|
45
|
+
data: 'testData'
|
|
46
|
+
};
|
|
47
|
+
(axios.put as jest.Mock).mockResolvedValue(goodStatus);
|
|
48
|
+
expect.assertions(1);
|
|
49
|
+
expect(hashMetadata({ pinataApiKey: 'test', pinataSecretApiKey: 'test' }, goodHash, metadata)).resolves.toEqual(goodStatus.data);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
test('Two keyvalue pairs is added', () => {
|
|
53
|
+
const goodStatus = {
|
|
54
|
+
status: 200,
|
|
55
|
+
data: 'testData'
|
|
56
|
+
};
|
|
57
|
+
(axios.put as jest.Mock).mockResolvedValue(goodStatus);
|
|
58
|
+
expect.assertions(1);
|
|
59
|
+
expect(hashMetadata({ pinataApiKey: 'test', pinataSecretApiKey: 'test' }, goodHash, metadataTwo)).resolves.toEqual(goodStatus.data);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
test('Result other than 200 status is returned', () => {
|
|
63
|
+
const badStatus = {
|
|
64
|
+
status: 700
|
|
65
|
+
};
|
|
66
|
+
(axios.put as jest.Mock).mockResolvedValue(badStatus);
|
|
67
|
+
expect.assertions(1);
|
|
68
|
+
expect(hashMetadata({ pinataApiKey: 'test', pinataSecretApiKey: 'test' }, goodHash, metadata)).rejects.toEqual(Error(`unknown server response while changing pin policy for hash: ${badStatus}`));
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
test('Rejection handled', () => {
|
|
72
|
+
(axios.put as jest.Mock).mockRejectedValue('test error');
|
|
73
|
+
expect.assertions(1);
|
|
74
|
+
expect(hashMetadata({ pinataApiKey: 'test', pinataSecretApiKey: 'test' }, goodHash, metadata)).rejects.toEqual('test error');
|
|
75
|
+
});
|
|
76
|
+
|