@polyv/request-plugin-polyv-business 2.1.0 → 2.3.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/README.md CHANGED
@@ -68,6 +68,20 @@ requester.get('/api/data', {}, {
68
68
  });
69
69
  ```
70
70
 
71
+ ## 保利威域名配置
72
+
73
+ 提供 `PickDomainInfo` 范型生成域名配置类型,`formatDomainInfo` 格式化域名配置,如果没有传入相关的配置则使用内部默认值。
74
+
75
+ ```ts
76
+ import { type PickDomainInfo } from '@polyv/request-plugin-polyv-business';
77
+
78
+ type MyDomainInfo = PickDomainInfo<'chatWsDomain' | 'chatApiDomain' | 'polyvApiDomain'>;
79
+
80
+ const myDomainInfo: MyDomainInfo = { ... };
81
+
82
+ formatDomainInfo(myDomainInfo).chatApiDomain;
83
+ ```
84
+
71
85
  ## 插件处理逻辑
72
86
 
73
87
  1. 插件会在请求中自动插入业务相关的参数,如 `sourceType`、`sourceId`、`channelId`、`viewerId`、`unionId` 等
package/domain.d.ts ADDED
@@ -0,0 +1,200 @@
1
+ /** 点播相关域名 */
2
+ interface VodDomainInfo {
3
+ /**
4
+ * 点播图片静态资源域名
5
+ * @internal
6
+ * @ignore
7
+ * @default https://img.videocc.net
8
+ */
9
+ vodImgStatic?: string;
10
+ /**
11
+ * 点播视频静态资源域名
12
+ * @internal
13
+ * @ignore
14
+ * @default https://static.polyv.net
15
+ */
16
+ vodStaticDomain?: string;
17
+ /**
18
+ * 点播授权验证域名
19
+ * @internal
20
+ * @ignore
21
+ * @default https://v3.polyv.net
22
+ */
23
+ vodAuthDomain?: string;
24
+ /**
25
+ * 点播加密域名
26
+ * @internal
27
+ * @ignore
28
+ * @default https://v.polyv.net
29
+ */
30
+ vodEncryptDomain?: string;
31
+ /**
32
+ * 点播测试域名
33
+ * @internal
34
+ * @ignore
35
+ * @default https://beta.polyv.net
36
+ */
37
+ vodBetaDomain?: string;
38
+ /**
39
+ * 点播 hls 域名
40
+ * @internal
41
+ * @ignore
42
+ * @default https://hls.videocc.net
43
+ */
44
+ vodHlsDomain?: string;
45
+ /**
46
+ * 点播 rtas 采集域名
47
+ * @internal
48
+ * @ignore
49
+ * @default https://prtas.videocc.net
50
+ */
51
+ vodRtasDomain?: string;
52
+ /**
53
+ * 点播 rtas 采集域名-备份
54
+ * @internal
55
+ * @ignore
56
+ * @default https://prtas-2.videocc.net
57
+ */
58
+ vodRtasDomain2?: string;
59
+ /**
60
+ * 点播播放器短点续播域名
61
+ * @internal
62
+ * @ignore
63
+ * @default https://script.polyv.net
64
+ */
65
+ vodScriptDomain?: string;
66
+ }
67
+ /** sdk 相关域名 */
68
+ interface WebSdkDomainInfo {
69
+ /**
70
+ * 播放器 sdk 域名,仅用来加载播放器
71
+ * @default https://player.polyv.net
72
+ */
73
+ playerSdkDomain?: string;
74
+ /**
75
+ * web sdk 域名
76
+ * @default https://websdk.videocc.net
77
+ */
78
+ webSdkDomain?: string;
79
+ /**
80
+ * web sdk 测试域名
81
+ * @default https://polyv-frontend-sdk-test-01.oss-cn-shenzhen.aliyuncs.com
82
+ */
83
+ webSdkTestDomain?: string;
84
+ }
85
+ /**
86
+ * 域名配置对象类型
87
+ */
88
+ export interface DomainInfo extends VodDomainInfo, WebSdkDomainInfo {
89
+ /**
90
+ * 观看页域名
91
+ * @default https://live.polyv.cn
92
+ */
93
+ watchPageDomain?: string;
94
+ /**
95
+ * V2 观看接口 api 域名
96
+ * @default https://live.polyv.cn
97
+ */
98
+ watchApiDomain?: string;
99
+ /**
100
+ * 后台 api 域名
101
+ * @internal
102
+ * @ignore
103
+ * @default https://live.polyv.net
104
+ */
105
+ backstageApiDomain?: string;
106
+ /**
107
+ * 直播 api 域名
108
+ * @internal
109
+ * @ignore
110
+ * @default https://live.polyv.net
111
+ */
112
+ liveApiDomain?: string;
113
+ /**
114
+ * polyv api 相关接口域名
115
+ * @default https://api.polyv.net
116
+ */
117
+ polyvApiDomain?: string;
118
+ /**
119
+ * 观看页 api 接口域名
120
+ * @default https://watch-api.polyv.cn
121
+ */
122
+ polyvWatchApiDomain?: string;
123
+ /**
124
+ * normal api 接口域名
125
+ * @default https://live-normal.polyv.net
126
+ */
127
+ normalApiDomain?: string;
128
+ /**
129
+ * rtas 采集域名
130
+ * @default https://rtas.videocc.net
131
+ */
132
+ rtasDomain?: string;
133
+ /**
134
+ * rtas 采集域名-备用
135
+ * @internal
136
+ * @ignore
137
+ * @default https://rtas-2.videocc.net
138
+ */
139
+ rtasDomain2?: string;
140
+ /**
141
+ * elog 采集域名
142
+ * @internal
143
+ * @ignore
144
+ * @default https://elog.polyv.net
145
+ */
146
+ elogDomain?: string;
147
+ /**
148
+ * 聊天室 websocket 域名
149
+ * @default chat.polyv.net
150
+ */
151
+ chatWsDomain?: string;
152
+ /**
153
+ * 聊天室 api 域名
154
+ * @default https://apichat.polyv.net
155
+ */
156
+ chatApiDomain?: string;
157
+ /**
158
+ * 静态域名
159
+ * @internal
160
+ * @ignore
161
+ * @default https://liveimages.videocc.net
162
+ */
163
+ staticDomain?: string;
164
+ /**
165
+ * 资源域名
166
+ * @internal
167
+ * @ignore
168
+ * @default https://s1.videocc.net
169
+ */
170
+ resourceDomain?: string;
171
+ /**
172
+ * 播放器基础域名
173
+ * @internal
174
+ * @ignore
175
+ * @default https://player.polyv.net
176
+ */
177
+ playerBasicDomain?: string;
178
+ /**
179
+ * 直播 json 域名
180
+ * @internal
181
+ * @ignore
182
+ * @default https://livejson.polyv.net
183
+ */
184
+ liveJsonDomain?: string;
185
+ }
186
+ /**
187
+ * 选择域名信息
188
+ */
189
+ export type PickDomainInfo<K extends keyof DomainInfo> = Pick<DomainInfo, K>;
190
+ /**
191
+ * 生成默认域名信息
192
+ * @returns
193
+ */
194
+ export declare function generateDefaultDomainInfo(): Required<DomainInfo>;
195
+ /**
196
+ * 格式化域名信息
197
+ * @param domainInfo 域名信息
198
+ */
199
+ export declare function formatDomainInfo<T extends DomainInfo>(domainInfo?: T): Required<T>;
200
+ export {};
package/domain.js ADDED
@@ -0,0 +1,52 @@
1
+ /**
2
+ * 生成默认域名信息
3
+ * @returns
4
+ */
5
+ export function generateDefaultDomainInfo() {
6
+ return {
7
+ watchPageDomain: 'https://live.polyv.cn',
8
+ // 后台 api 相关域名
9
+ watchApiDomain: 'https://live.polyv.cn',
10
+ backstageApiDomain: 'https://live.polyv.net',
11
+ liveApiDomain: 'https://live.polyv.net',
12
+ polyvApiDomain: 'https://api.polyv.net',
13
+ polyvWatchApiDomain: 'https://watch-api.polyv.cn',
14
+ normalApiDomain: 'https://live-normal.polyv.net',
15
+ rtasDomain: 'https://rtas.videocc.net',
16
+ rtasDomain2: 'https://rtas-2.videocc.net',
17
+ elogDomain: 'https://elog.polyv.net',
18
+ // 聊天室相关域名
19
+ chatWsDomain: 'chat.polyv.net',
20
+ chatApiDomain: 'https://apichat.polyv.net',
21
+ // 静态资源域名
22
+ staticDomain: 'https://liveimages.videocc.net',
23
+ resourceDomain: 'https://s1.videocc.net',
24
+ playerBasicDomain: 'https://player.polyv.net',
25
+ // 直播播放器相关域名
26
+ liveJsonDomain: 'https://livejson.polyv.net',
27
+ // 点播播放器相关域名
28
+ vodImgStatic: 'https://img.videocc.net',
29
+ vodStaticDomain: 'https://static.polyv.net',
30
+ vodAuthDomain: 'https://v3.polyv.net',
31
+ vodEncryptDomain: 'https://v.polyv.net',
32
+ vodBetaDomain: 'https://beta.polyv.net',
33
+ vodHlsDomain: 'https://hls.videocc.net',
34
+ vodRtasDomain: 'https://prtas.videocc.net',
35
+ vodRtasDomain2: 'https://prtas-2.videocc.net',
36
+ vodScriptDomain: ' https://script.polyv.net',
37
+ // sdk 链接相关域名
38
+ playerSdkDomain: 'https://player.polyv.net',
39
+ webSdkDomain: 'https://websdk.videocc.net',
40
+ webSdkTestDomain: 'https://polyv-frontend-sdk-test-01.oss-cn-shenzhen.aliyuncs.com',
41
+ };
42
+ }
43
+ /**
44
+ * 格式化域名信息
45
+ * @param domainInfo 域名信息
46
+ */
47
+ export function formatDomainInfo(domainInfo) {
48
+ return {
49
+ ...generateDefaultDomainInfo(),
50
+ ...(domainInfo || {}),
51
+ };
52
+ }
package/index.d.ts CHANGED
@@ -2,3 +2,4 @@ export * from './judge';
2
2
  export * from './polyv-business';
3
3
  export * from './types';
4
4
  export * from './request-options';
5
+ export * from './domain';
package/index.js CHANGED
@@ -2,3 +2,4 @@ export * from './judge';
2
2
  export * from './polyv-business';
3
3
  export * from './types';
4
4
  export * from './request-options';
5
+ export * from './domain';
package/judge.d.ts CHANGED
@@ -17,7 +17,7 @@ export declare function isWatchViewerRequest(url: string): boolean;
17
17
  /**
18
18
  * 是否频道接口
19
19
  *
20
- * 判断地址:/live/v4/channel
20
+ * 判断地址:/live/v4/channel、/live/v3/channel
21
21
  *
22
22
  * 插入参数:channelId
23
23
  */
package/judge.js CHANGED
@@ -21,12 +21,12 @@ export function isWatchViewerRequest(url) {
21
21
  /**
22
22
  * 是否频道接口
23
23
  *
24
- * 判断地址:/live/v4/channel
24
+ * 判断地址:/live/v4/channel、/live/v3/channel
25
25
  *
26
26
  * 插入参数:channelId
27
27
  */
28
28
  export function isChannelRequest(url) {
29
- return url.indexOf('/live/v4/channel') !== -1;
29
+ return /\/live\/v[34]\/channel/.test(url);
30
30
  }
31
31
  /**
32
32
  * 是否 v3 接口,/live/v3 开头的接口,使用 'token' 入参
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@polyv/request-plugin-polyv-business",
3
- "version": "2.1.0",
3
+ "version": "2.3.0",
4
4
  "main": "./index.js",
5
5
  "dependencies": {
6
- "@polyv/request-core": "2.1.0",
7
- "@polyv/request-plugin-authorize-token": "2.1.0",
8
- "@polyv/request-plugin-global-params": "2.1.0"
6
+ "@polyv/request-core": "2.3.0",
7
+ "@polyv/request-plugin-authorize-token": "2.3.0",
8
+ "@polyv/request-plugin-global-params": "2.3.0"
9
9
  },
10
10
  "types": "./index.d.ts"
11
11
  }