@freelog/tools-lib 0.1.77 → 0.1.81

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.
@@ -1,275 +1,276 @@
1
- import * as querystring from 'querystring';
2
-
3
- type TReturnType = string;
4
-
5
- // 市场
6
- interface MarketParamsType {
7
- // nodeID: number;
8
- }
9
-
10
- export function market({}: MarketParamsType = {}): TReturnType {
11
- return `/market`;
12
- }
13
-
14
- // 资源详情
15
- interface ResourceDetailsParamsType {
16
- resourceID: string;
17
- version?: string;
18
- }
19
-
20
- export function resourceDetails({resourceID, ...params}: ResourceDetailsParamsType): TReturnType {
21
- return `/resource/details/${resourceID}${handleQuery(params)}`;
22
- }
23
-
24
- // 资源创建
25
- interface ResourceCreatorParamsType {
26
- }
27
-
28
- export function resourceCreator({}: ResourceCreatorParamsType = {}): TReturnType {
29
- return `/resource/creator`;
30
- }
31
-
32
- // 我的资源
33
- interface MyResourcesParamsType {
34
- }
35
-
36
- export function myResources({}: MyResourcesParamsType = {}): TReturnType {
37
- return `/resource/list`;
38
- }
39
-
40
- // 我的收藏
41
- interface MyCollectsParamsType {
42
- }
43
-
44
- export function myCollects({}: MyCollectsParamsType = {}): TReturnType {
45
- return `/resource/collect`;
46
- }
47
-
48
- // 资源信息
49
- interface ResourceInfoParamsType {
50
- resourceID: string;
51
- }
52
-
53
- export function resourceInfo({resourceID}: ResourceInfoParamsType): TReturnType {
54
- return `/resource/info/${resourceID}`;
55
- }
56
-
57
- // 资源授权
58
- interface ResourceAuthParamsType {
59
- resourceID: string;
60
- }
61
-
62
- export function resourceAuth({resourceID}: ResourceAuthParamsType): TReturnType {
63
- return `/resource/auth/${resourceID}`;
64
- }
65
-
66
- // 资源创建版本
67
- interface ResourceCreateVersionParamsType {
68
- resourceID: string;
69
- }
70
-
71
- export function resourceCreateVersion({resourceID}: ResourceCreateVersionParamsType): TReturnType {
72
- return `/resource/version/creator/${resourceID}`;
73
- }
74
-
75
- // 资源版本信息
76
- interface ResourceVersionParamsType {
77
- resourceID: string;
78
- version: string;
79
- }
80
-
81
- export function resourceVersion({resourceID, version}: ResourceVersionParamsType): TReturnType {
82
- return `/resource/version/info/${resourceID}/${version}`;
83
- }
84
-
85
- // 节点创建
86
- interface NodeCreatorParamsType {
87
- // nodeID: number;
88
- }
89
-
90
- export function nodeCreator({}: NodeCreatorParamsType = {}): TReturnType {
91
- return `/node/creator`;
92
- }
93
-
94
- // 节点管理
95
- interface NodeManagementParamsType {
96
- nodeID: number;
97
- }
98
-
99
- export function nodeManagement({nodeID}: NodeManagementParamsType): TReturnType {
100
- return `/node/formal/${nodeID}`;
101
- }
102
-
103
- // 展品管理
104
- interface ExhibitManagementParamsType {
105
- exhibitID: string;
106
- }
107
-
108
- export function exhibitManagement({exhibitID}: ExhibitManagementParamsType): TReturnType {
109
- return `/node/exhibit/formal/${exhibitID}`;
110
- }
111
-
112
- // 测试节点管理
113
- interface InformNodeManagementParamsType {
114
- nodeID: number;
115
- showPage?: 'exhibit' | 'theme' | 'mappingRule';
116
- }
117
-
118
- export function informNodeManagement({
119
- nodeID,
120
- showPage = 'exhibit',
121
- ...params
122
- }: InformNodeManagementParamsType): TReturnType {
123
- return `/node/informal/${nodeID}${handleQuery({showPage, ...params})}`;
124
- }
125
-
126
- // 测试展品管理
127
- interface InformExhibitManagementParamsType {
128
- exhibitID: string;
129
- }
130
-
131
- export function informExhibitManagement({exhibitID}: InformExhibitManagementParamsType): TReturnType {
132
- return `/node/exhibit/informal/${exhibitID}`;
133
- }
134
-
135
- // 存储空间
136
- interface StorageSpaceParamsType {
137
- bucketName?: string;
138
- }
139
-
140
- export function storageSpace({...params}: StorageSpaceParamsType = {}): TReturnType {
141
- return `/storage${handleQuery(params)}`;
142
- }
143
-
144
- // 对象详情
145
- interface ObjectDetailsParamsType {
146
- bucketName: string;
147
- objectID: string;
148
- }
149
-
150
- export function objectDetails({...params}: ObjectDetailsParamsType): TReturnType {
151
- return `/storage${handleQuery(params)}`;
152
- }
153
-
154
- // 资源创建成功
155
- interface ResourceCreateSuccessParamsType {
156
- resourceID: string;
157
- }
158
-
159
- export function resourceCreateSuccess({resourceID}: ResourceCreateSuccessParamsType) {
160
- return `/result/resource/create/success/${resourceID}`;
161
- }
162
-
163
- // 资源版本创建成功
164
- interface ResourceVersionCreateSuccessParamsType {
165
- resourceID: string;
166
- version: string;
167
- }
168
-
169
- export function resourceVersionCreateSuccess({resourceID, version}: ResourceVersionCreateSuccessParamsType) {
170
- return `/result/resource/version/create/success/${resourceID}/${version}`;
171
- }
172
-
173
- // 节点创建成功
174
- interface NodeCreateSuccessParamsType {
175
- nodeID: number;
176
- }
177
-
178
- export function nodeCreateSuccess({nodeID}: NodeCreateSuccessParamsType) {
179
- return `/result/node/create/success/${nodeID}`;
180
- }
181
-
182
- // 403
183
- interface Exception403ParamsType {
184
- from?: string;
185
- }
186
-
187
- export function exception403({...params}: Exception403ParamsType = {}) {
188
-
189
- let fromUrl: string = params.from || '';
190
- if (!fromUrl) {
191
- const {href, origin} = window.location;
192
- fromUrl = href.replace(origin, '');
193
- }
194
-
195
- return `/exception/403${handleQuery({
196
- from: fromUrl
197
- })}`;
198
- }
199
-
200
- // 登录
201
- interface LoginParamsType {
202
- goTo?: string;
203
- }
204
-
205
- export function login({goTo}: LoginParamsType = {}) {
206
- return `/login${handleQuery({
207
- goTo: goTo ? encodeURIComponent(goTo) : undefined,
208
- })}`;
209
- }
210
-
211
- // 注册
212
- interface LoginParamsType {
213
- goTo?: string;
214
- }
215
-
216
- export function logon({goTo}: LoginParamsType = {}) {
217
- return `/logon${handleQuery({
218
- goTo: goTo ? encodeURIComponent(goTo) : undefined,
219
- })}`;
220
- }
221
-
222
- // 找回密码
223
- interface RetrieveUserPasswordParamsType {
224
- goTo?: string;
225
- }
226
-
227
- export function retrieveUserPassword({goTo}: RetrieveUserPasswordParamsType = {}) {
228
- return `/retrieve${handleQuery({
229
- goTo: goTo ? encodeURIComponent(goTo) : undefined,
230
- })}`;
231
- }
232
-
233
- // 找回支付密码
234
- // interface RetrievePayPasswordParamsType {
235
- // goTo?: string;
236
- // }
237
-
238
- export function retrievePayPassword() {
239
- return `/retrievePayPassword`;
240
- }
241
-
242
- // 钱包
243
- // interface WalletParamsType {
244
- // }
245
-
246
- export function wallet() {
247
- return `/logged/wallet`;
248
- }
249
-
250
- // interface ContractParamsType {
251
- // }
252
-
253
- export function contract() {
254
- return `/logged/contract`;
255
- }
256
-
257
- // interface SettingParamsType {
258
- // }
259
-
260
- export function setting() {
261
- return `/logged/setting`;
262
- }
263
-
264
- function handleQuery(query: object): string {
265
- const obj: any = {};
266
- for (const [key, value] of Object.entries(query)) {
267
- if (key && value) {
268
- obj[key] = value;
269
- }
270
- }
271
- const result: string = querystring.stringify(obj);
272
- return result ? ('?' + result) : '';
273
- }
274
-
275
-
1
+ import * as querystring from 'querystring';
2
+
3
+ type TReturnType = string;
4
+
5
+ // 市场
6
+ interface MarketParamsType {
7
+ // nodeID: number;
8
+ }
9
+
10
+ export function market({}: MarketParamsType = {}): TReturnType {
11
+ return `/market`;
12
+ }
13
+
14
+ // 资源详情
15
+ interface ResourceDetailsParamsType {
16
+ resourceID: string;
17
+ version?: string;
18
+ }
19
+
20
+ export function resourceDetails({resourceID, ...params}: ResourceDetailsParamsType): TReturnType {
21
+ return `/resource/details/${resourceID}${handleQuery(params)}`;
22
+ }
23
+
24
+ // 资源创建
25
+ interface ResourceCreatorParamsType {
26
+ }
27
+
28
+ export function resourceCreator({}: ResourceCreatorParamsType = {}): TReturnType {
29
+ return `/resource/creator`;
30
+ }
31
+
32
+ // 我的资源
33
+ interface MyResourcesParamsType {
34
+ }
35
+
36
+ export function myResources({}: MyResourcesParamsType = {}): TReturnType {
37
+ return `/resource/list`;
38
+ }
39
+
40
+ // 我的收藏
41
+ interface MyCollectsParamsType {
42
+ }
43
+
44
+ export function myCollects({}: MyCollectsParamsType = {}): TReturnType {
45
+ return `/resource/collect`;
46
+ }
47
+
48
+ // 资源信息
49
+ interface ResourceInfoParamsType {
50
+ resourceID: string;
51
+ }
52
+
53
+ export function resourceInfo({resourceID}: ResourceInfoParamsType): TReturnType {
54
+ return `/resource/info/${resourceID}`;
55
+ }
56
+
57
+ // 资源授权
58
+ interface ResourceAuthParamsType {
59
+ resourceID: string;
60
+ }
61
+
62
+ export function resourceAuth({resourceID}: ResourceAuthParamsType): TReturnType {
63
+ return `/resource/auth/${resourceID}`;
64
+ }
65
+
66
+ // 资源创建版本
67
+ interface ResourceCreateVersionParamsType {
68
+ resourceID: string;
69
+ }
70
+
71
+ export function resourceCreateVersion({resourceID}: ResourceCreateVersionParamsType): TReturnType {
72
+ return `/resource/version/creator/${resourceID}`;
73
+ }
74
+
75
+ // 资源版本信息
76
+ interface ResourceVersionParamsType {
77
+ resourceID: string;
78
+ version: string;
79
+ }
80
+
81
+ export function resourceVersion({resourceID, version}: ResourceVersionParamsType): TReturnType {
82
+ return `/resource/version/info/${resourceID}/${version}`;
83
+ }
84
+
85
+ // 节点创建
86
+ interface NodeCreatorParamsType {
87
+ // nodeID: number;
88
+ }
89
+
90
+ export function nodeCreator({}: NodeCreatorParamsType = {}): TReturnType {
91
+ return `/node/creator`;
92
+ }
93
+
94
+ // 节点管理
95
+ interface NodeManagementParamsType {
96
+ nodeID: number;
97
+ }
98
+
99
+ export function nodeManagement({nodeID}: NodeManagementParamsType): TReturnType {
100
+ return `/node/formal/${nodeID}`;
101
+ }
102
+
103
+ // 展品管理
104
+ interface ExhibitManagementParamsType {
105
+ exhibitID: string;
106
+ }
107
+
108
+ export function exhibitManagement({exhibitID}: ExhibitManagementParamsType): TReturnType {
109
+ return `/node/exhibit/formal/${exhibitID}`;
110
+ }
111
+
112
+ // 测试节点管理
113
+ interface InformNodeManagementParamsType {
114
+ nodeID: number;
115
+ showPage?: 'exhibit' | 'theme' | 'mappingRule';
116
+ }
117
+
118
+ export function informNodeManagement({
119
+ nodeID,
120
+ showPage = 'exhibit',
121
+ ...params
122
+ }: InformNodeManagementParamsType): TReturnType {
123
+ return `/node/informal/${nodeID}${handleQuery({showPage, ...params})}`;
124
+ }
125
+
126
+ // 测试展品管理
127
+ interface InformExhibitManagementParamsType {
128
+ exhibitID: string;
129
+ }
130
+
131
+ export function informExhibitManagement({exhibitID}: InformExhibitManagementParamsType): TReturnType {
132
+ return `/node/exhibit/informal/${exhibitID}`;
133
+ }
134
+
135
+ // 存储空间
136
+ interface StorageSpaceParamsType {
137
+ bucketName?: string;
138
+ }
139
+
140
+ export function storageSpace({...params}: StorageSpaceParamsType = {}): TReturnType {
141
+ return `/storage${handleQuery(params)}`;
142
+ }
143
+
144
+ // 对象详情
145
+ interface ObjectDetailsParamsType {
146
+ bucketName: string;
147
+ objectID: string;
148
+ }
149
+
150
+ export function objectDetails({...params}: ObjectDetailsParamsType): TReturnType {
151
+ return `/storage${handleQuery(params)}`;
152
+ }
153
+
154
+ // 资源创建成功
155
+ interface ResourceCreateSuccessParamsType {
156
+ resourceID: string;
157
+ }
158
+
159
+ export function resourceCreateSuccess({resourceID}: ResourceCreateSuccessParamsType) {
160
+ return `/result/resource/create/success/${resourceID}`;
161
+ }
162
+
163
+ // 资源版本创建成功
164
+ interface ResourceVersionCreateSuccessParamsType {
165
+ resourceID: string;
166
+ version: string;
167
+ }
168
+
169
+ export function resourceVersionCreateSuccess({resourceID, version}: ResourceVersionCreateSuccessParamsType) {
170
+ return `/result/resource/version/create/success/${resourceID}/${version}`;
171
+ }
172
+
173
+ // 节点创建成功
174
+ interface NodeCreateSuccessParamsType {
175
+ nodeID: number;
176
+ }
177
+
178
+ export function nodeCreateSuccess({nodeID}: NodeCreateSuccessParamsType) {
179
+ return `/result/node/create/success/${nodeID}`;
180
+ }
181
+
182
+ // 403
183
+ interface Exception403ParamsType {
184
+ from?: string;
185
+ }
186
+
187
+ export function exception403({...params}: Exception403ParamsType = {}) {
188
+
189
+ let fromUrl: string = params.from || '';
190
+ if (!fromUrl) {
191
+ const {href, origin} = window.location;
192
+ fromUrl = href.replace(origin, '');
193
+ }
194
+
195
+ return `/exception/403${handleQuery({
196
+ from: fromUrl
197
+ })}`;
198
+ }
199
+
200
+ // 登录
201
+ interface LoginParamsType {
202
+ goTo?: string;
203
+ }
204
+
205
+ export function login({goTo}: LoginParamsType = {}) {
206
+ return `/login${handleQuery({
207
+ goTo: goTo ? encodeURIComponent(goTo) : undefined,
208
+ })}`;
209
+ }
210
+
211
+ // 注册
212
+ interface LoginParamsType {
213
+ goTo?: string;
214
+ }
215
+
216
+ export function logon({goTo}: LoginParamsType = {}) {
217
+ return `/logon${handleQuery({
218
+ goTo: goTo ? encodeURIComponent(goTo) : undefined,
219
+ })}`;
220
+ }
221
+
222
+ // 找回密码
223
+ interface RetrieveUserPasswordParamsType {
224
+ goTo?: string;
225
+ }
226
+
227
+ export function retrieveUserPassword({goTo}: RetrieveUserPasswordParamsType = {}) {
228
+ return `/retrieve${handleQuery({
229
+ goTo: goTo ? encodeURIComponent(goTo) : undefined,
230
+ })}`;
231
+ }
232
+
233
+ // 找回支付密码
234
+ // interface RetrievePayPasswordParamsType {
235
+ // goTo?: string;
236
+ // }
237
+
238
+ export function retrievePayPassword() {
239
+ return `/retrievePayPassword`;
240
+ }
241
+
242
+ // 我的钱包
243
+ // interface WalletParamsType {
244
+ // }
245
+
246
+ export function wallet() {
247
+ return `/logged/wallet`;
248
+ }
249
+
250
+ // 我的合约
251
+ // interface ContractParamsType {
252
+ // }
253
+
254
+ export function contract() {
255
+ return `/logged/contract`;
256
+ }
257
+
258
+ // 个人设置
259
+ // interface SettingParamsType {
260
+ // }
261
+ export function setting() {
262
+ return `/logged/setting`;
263
+ }
264
+
265
+ function handleQuery(query: object): string {
266
+ const obj: any = {};
267
+ for (const [key, value] of Object.entries(query)) {
268
+ if (key && value) {
269
+ obj[key] = value;
270
+ }
271
+ }
272
+ const result: string = querystring.stringify(obj);
273
+ return result ? ('?' + result) : '';
274
+ }
275
+
276
+
@@ -1,37 +1,37 @@
1
- // export const apiHost = `${window.location.protocol}//qi.${(window.location.host.match(/(?<=\.).*/) || [''])[0]}`;
2
-
3
- // 预设资源类型
4
- export const resourceTypes: string[] = ['json', 'widget', 'image', 'audio', 'markdown', 'theme', 'reveal_slide', 'license', 'video', 'catalog'];
5
-
6
- // 全局列表加载条目数
7
- export const pageSize: number = 100;
8
-
9
- // Moment 日期时间格式
10
- export const momentDateFormat: string = 'YYYY-MM-DD'
11
- export const momentDateTimeFormat: string = 'YYYY-MM-DD HH:mm';
12
-
13
- // 签约方用户的身份类型定义
14
- export enum EnumContractPartyIdentityType {
15
- resource = 1,
16
- node,
17
- consumer,
18
- }
19
-
20
- // 标的物类型定义
21
- export enum EnumSubjectType {
22
- resource = 1,
23
- exhibit,
24
- user,
25
- }
26
-
27
- // 合约状态定义
28
- export enum EnumContractStatus {
29
- pending,
30
- authorized,
31
- stopped,
32
- }
33
-
34
- // 合约授权状态定义
35
- // export enum ContractAuthStatus {
36
- //
37
- // }
1
+ // export const apiHost = `${window.location.protocol}//qi.${(window.location.host.match(/(?<=\.).*/) || [''])[0]}`;
2
+
3
+ // 预设资源类型
4
+ export const resourceTypes: string[] = ['json', 'widget', 'image', 'audio', 'markdown', 'theme', 'reveal_slide', 'license', 'video', 'catalog'];
5
+
6
+ // 全局列表加载条目数
7
+ export const pageSize: number = 100;
8
+
9
+ // Moment 日期时间格式
10
+ export const momentDateFormat: string = 'YYYY-MM-DD'
11
+ export const momentDateTimeFormat: string = 'YYYY-MM-DD HH:mm';
12
+
13
+ // 签约方用户的身份类型定义
14
+ export enum EnumContractPartyIdentityType {
15
+ resource = 1,
16
+ node,
17
+ consumer,
18
+ }
19
+
20
+ // 标的物类型定义
21
+ export enum EnumSubjectType {
22
+ resource = 1,
23
+ exhibit,
24
+ user,
25
+ }
26
+
27
+ // 合约状态定义
28
+ export enum EnumContractStatus {
29
+ pending,
30
+ authorized,
31
+ stopped,
32
+ }
33
+
34
+ // 合约授权状态定义
35
+ // export enum ContractAuthStatus {
36
+ //
37
+ // }