@audius/sdk 1.0.17 → 1.0.19
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/api/File.d.ts +4 -1
- package/dist/api/entityManager.d.ts +3 -16
- package/dist/index.cjs.js +169 -117
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +169 -117
- package/dist/index.esm.js.map +1 -1
- package/dist/legacy.js +169 -117
- package/dist/legacy.js.map +1 -1
- package/dist/native-libs.js +169 -117
- package/dist/native-libs.js.map +1 -1
- package/dist/services/dataContracts/EntityManagerClient.d.ts +7 -1
- package/package.json +2 -2
- package/src/AudiusLibs.ts +1 -1
- package/src/NativeAudiusLibs.ts +1 -1
- package/src/api/File.ts +48 -2
- package/src/api/entityManager.ts +9 -18
- package/src/services/dataContracts/EntityManagerClient.ts +7 -1
|
@@ -5,7 +5,13 @@ export declare enum Action {
|
|
|
5
5
|
CREATE = "Create",
|
|
6
6
|
UPDATE = "Update",
|
|
7
7
|
DELETE = "Delete",
|
|
8
|
-
VERIFY = "Verify"
|
|
8
|
+
VERIFY = "Verify",
|
|
9
|
+
FOLLOW = "Follow",
|
|
10
|
+
UNFOLLOW = "Unfollow",
|
|
11
|
+
SAVE = "Save",
|
|
12
|
+
UNSAVE = "Unsave",
|
|
13
|
+
REPOST = "Repost",
|
|
14
|
+
UNREPOST = "Unrepost"
|
|
9
15
|
}
|
|
10
16
|
export declare enum EntityType {
|
|
11
17
|
PLAYLIST = "Playlist",
|
package/package.json
CHANGED
package/src/AudiusLibs.ts
CHANGED
|
@@ -654,7 +654,7 @@ export class AudiusLibs {
|
|
|
654
654
|
this.Account = new Account(this.User, ...services)
|
|
655
655
|
this.Track = new Track(...services)
|
|
656
656
|
this.Playlist = new Playlists(...services)
|
|
657
|
-
this.File = new File(this.User, ...services)
|
|
657
|
+
this.File = new File(this.User, this.ServiceProvider, ...services)
|
|
658
658
|
this.Rewards = new Rewards(this.ServiceProvider, ...services)
|
|
659
659
|
this.Reactions = new Reactions(...services)
|
|
660
660
|
this.EntityManager = new EntityManager(...services)
|
package/src/NativeAudiusLibs.ts
CHANGED
|
@@ -600,7 +600,7 @@ export class AudiusLibs {
|
|
|
600
600
|
this.Account = new Account(this.User, ...services)
|
|
601
601
|
this.Track = new Track(...services)
|
|
602
602
|
this.Playlist = new Playlists(...services)
|
|
603
|
-
this.File = new File(this.User, ...services)
|
|
603
|
+
this.File = new File(this.User, this.ServiceProvider, ...services)
|
|
604
604
|
this.Rewards = new Rewards(this.ServiceProvider, ...services)
|
|
605
605
|
this.Reactions = new Reactions(...services)
|
|
606
606
|
this.EntityManager = new EntityManager(...services)
|
package/src/api/File.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { raceRequests } from '../utils/network'
|
|
|
6
6
|
import retry from 'async-retry'
|
|
7
7
|
import type { Users } from './Users'
|
|
8
8
|
import type { Nullable } from '../utils'
|
|
9
|
+
import type { ServiceProvider } from './ServiceProvider'
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Downloads a file using an element in the DOM
|
|
@@ -24,11 +25,17 @@ const downloadURL = (url: string, filename: string) => {
|
|
|
24
25
|
|
|
25
26
|
export class File extends Base {
|
|
26
27
|
User: Users
|
|
28
|
+
ServiceProvider: ServiceProvider
|
|
27
29
|
|
|
28
|
-
constructor(
|
|
30
|
+
constructor(
|
|
31
|
+
user: Users,
|
|
32
|
+
serviceProvider: ServiceProvider,
|
|
33
|
+
...args: BaseConstructorArgs
|
|
34
|
+
) {
|
|
29
35
|
super(...args)
|
|
30
36
|
|
|
31
37
|
this.User = user
|
|
38
|
+
this.ServiceProvider = serviceProvider
|
|
32
39
|
}
|
|
33
40
|
|
|
34
41
|
/**
|
|
@@ -46,6 +53,45 @@ export class File extends Base {
|
|
|
46
53
|
responseType: ResponseType = 'blob',
|
|
47
54
|
trackId = null,
|
|
48
55
|
premiumContentHeaders = {}
|
|
56
|
+
) {
|
|
57
|
+
try {
|
|
58
|
+
const replicaSetAttempt = await this.fetchCIDInternal(
|
|
59
|
+
cid,
|
|
60
|
+
creatorNodeGateways,
|
|
61
|
+
callback,
|
|
62
|
+
responseType,
|
|
63
|
+
trackId,
|
|
64
|
+
premiumContentHeaders
|
|
65
|
+
)
|
|
66
|
+
return replicaSetAttempt
|
|
67
|
+
} catch (e) {
|
|
68
|
+
// In the case we can't find the CID from anywhere in the user's replica set,
|
|
69
|
+
// retry the whole network
|
|
70
|
+
console.error(e)
|
|
71
|
+
const allCreatorNodes = await this.ServiceProvider.listCreatorNodes()
|
|
72
|
+
const allCreatorNodeEndpoints = allCreatorNodes.map((node) =>
|
|
73
|
+
urlJoin(node.endpoint, 'ipfs')
|
|
74
|
+
)
|
|
75
|
+
// Re-throw whatever error might happen here
|
|
76
|
+
const allNodesAttempt = await this.fetchCIDInternal(
|
|
77
|
+
cid,
|
|
78
|
+
allCreatorNodeEndpoints,
|
|
79
|
+
callback,
|
|
80
|
+
responseType,
|
|
81
|
+
trackId,
|
|
82
|
+
premiumContentHeaders
|
|
83
|
+
)
|
|
84
|
+
return allNodesAttempt
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
async fetchCIDInternal(
|
|
89
|
+
cid: string,
|
|
90
|
+
creatorNodeGateways: string[],
|
|
91
|
+
callback: Nullable<(url: string) => void> = null,
|
|
92
|
+
responseType: ResponseType = 'blob',
|
|
93
|
+
trackId = null,
|
|
94
|
+
premiumContentHeaders = {}
|
|
49
95
|
) {
|
|
50
96
|
const urls: string[] = []
|
|
51
97
|
|
|
@@ -123,7 +169,7 @@ export class File extends Base {
|
|
|
123
169
|
minTimeout: 500,
|
|
124
170
|
maxTimeout: 4000,
|
|
125
171
|
factor: 3,
|
|
126
|
-
retries:
|
|
172
|
+
retries: 3,
|
|
127
173
|
onRetry: (err: any, i) => {
|
|
128
174
|
// eslint-disable-next-line no-console
|
|
129
175
|
console.log(`FetchCID attempt ${i} error: ${err}`)
|
package/src/api/entityManager.ts
CHANGED
|
@@ -1,23 +1,9 @@
|
|
|
1
1
|
import { Base, Services } from './base'
|
|
2
2
|
import type { PlaylistMetadata } from '../services/creatorNode'
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
DELETE = 'Delete',
|
|
8
|
-
FOLLOW = 'Follow',
|
|
9
|
-
UNFOLLOW = 'Unfollow',
|
|
10
|
-
SAVE = 'Save',
|
|
11
|
-
UNSAVE = 'Unsave',
|
|
12
|
-
REPOST = 'Repost',
|
|
13
|
-
UNREPOST = 'Unrepost'
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export enum EntityType {
|
|
17
|
-
TRACK = 'Track',
|
|
18
|
-
PLAYLIST = 'Playlist',
|
|
19
|
-
USER = 'User'
|
|
20
|
-
}
|
|
3
|
+
import {
|
|
4
|
+
Action,
|
|
5
|
+
EntityType
|
|
6
|
+
} from '../services/dataContracts/EntityManagerClient'
|
|
21
7
|
|
|
22
8
|
export type EntityManagerSuccessResponse = {
|
|
23
9
|
blockHash: string
|
|
@@ -111,6 +97,11 @@ export class EntityManager extends Base {
|
|
|
111
97
|
unsavePlaylist = this.createSocialMethod(EntityType.PLAYLIST, Action.UNSAVE)
|
|
112
98
|
repostTrack = this.createSocialMethod(EntityType.TRACK, Action.REPOST)
|
|
113
99
|
unrepostTrack = this.createSocialMethod(EntityType.TRACK, Action.UNREPOST)
|
|
100
|
+
repostPlaylist = this.createSocialMethod(EntityType.PLAYLIST, Action.REPOST)
|
|
101
|
+
unrepostPlaylist = this.createSocialMethod(
|
|
102
|
+
EntityType.PLAYLIST,
|
|
103
|
+
Action.UNREPOST
|
|
104
|
+
)
|
|
114
105
|
|
|
115
106
|
/** Playlist */
|
|
116
107
|
|
|
@@ -10,7 +10,13 @@ export enum Action {
|
|
|
10
10
|
CREATE = 'Create',
|
|
11
11
|
UPDATE = 'Update',
|
|
12
12
|
DELETE = 'Delete',
|
|
13
|
-
VERIFY = 'Verify'
|
|
13
|
+
VERIFY = 'Verify',
|
|
14
|
+
FOLLOW = 'Follow',
|
|
15
|
+
UNFOLLOW = 'Unfollow',
|
|
16
|
+
SAVE = 'Save',
|
|
17
|
+
UNSAVE = 'Unsave',
|
|
18
|
+
REPOST = 'Repost',
|
|
19
|
+
UNREPOST = 'Unrepost'
|
|
14
20
|
}
|
|
15
21
|
|
|
16
22
|
export enum EntityType {
|