@mx-space/api-client 1.8.0 → 1.8.1
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/controllers/activity.ts +3 -2
- package/dist/index.cjs +5 -3
- package/dist/index.d.cts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.global.js +5 -3
- package/dist/index.js +5 -3
- package/interfaces/client.ts +5 -0
- package/package.json +2 -2
package/controllers/activity.ts
CHANGED
|
@@ -60,7 +60,7 @@ export class ActivityController<ResponseWrapper> implements IController {
|
|
|
60
60
|
position,
|
|
61
61
|
roomName,
|
|
62
62
|
sid,
|
|
63
|
-
|
|
63
|
+
ts,
|
|
64
64
|
displayName,
|
|
65
65
|
}: {
|
|
66
66
|
roomName: string
|
|
@@ -69,12 +69,13 @@ export class ActivityController<ResponseWrapper> implements IController {
|
|
|
69
69
|
sid: string
|
|
70
70
|
|
|
71
71
|
displayName?: string
|
|
72
|
+
ts?: number
|
|
72
73
|
}) {
|
|
73
74
|
return this.proxy.presence.update.post({
|
|
74
75
|
data: {
|
|
75
76
|
identity,
|
|
76
77
|
position,
|
|
77
|
-
ts: Date.now(),
|
|
78
|
+
ts: ts || Date.now(),
|
|
78
79
|
roomName,
|
|
79
80
|
sid,
|
|
80
81
|
|
package/dist/index.cjs
CHANGED
|
@@ -227,13 +227,14 @@ var ActivityController = class {
|
|
|
227
227
|
position,
|
|
228
228
|
roomName,
|
|
229
229
|
sid,
|
|
230
|
+
ts,
|
|
230
231
|
displayName
|
|
231
232
|
}) {
|
|
232
233
|
return this.proxy.presence.update.post({
|
|
233
234
|
data: {
|
|
234
235
|
identity,
|
|
235
236
|
position,
|
|
236
|
-
ts: Date.now(),
|
|
237
|
+
ts: ts || Date.now(),
|
|
237
238
|
roomName,
|
|
238
239
|
sid,
|
|
239
240
|
displayName
|
|
@@ -940,7 +941,8 @@ var HTTPClient = class {
|
|
|
940
941
|
this.options = options;
|
|
941
942
|
this._endpoint = _endpoint.replace(/\/*$/, "").replace("localhost", "127.0.0.1");
|
|
942
943
|
this._proxy = this.buildRoute(this)();
|
|
943
|
-
options.transformResponse
|
|
944
|
+
options.transformResponse || (options.transformResponse = (data) => camelcaseKeys(data));
|
|
945
|
+
options.getDataFromResponse || (options.getDataFromResponse = (res) => res.data);
|
|
944
946
|
this.initGetClient();
|
|
945
947
|
attachRequestMethod(this);
|
|
946
948
|
}
|
|
@@ -1047,7 +1049,7 @@ var HTTPClient = class {
|
|
|
1047
1049
|
}
|
|
1048
1050
|
throw that.options.customThrowResponseError ? that.options.customThrowResponseError(e) : new RequestError(message, code, url, e);
|
|
1049
1051
|
}
|
|
1050
|
-
const data = res
|
|
1052
|
+
const data = that.options.getDataFromResponse(res);
|
|
1051
1053
|
if (!data) {
|
|
1052
1054
|
return null;
|
|
1053
1055
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -16,6 +16,11 @@ interface IClientOptions {
|
|
|
16
16
|
};
|
|
17
17
|
customThrowResponseError: <T extends Error = Error>(err: any) => T;
|
|
18
18
|
transformResponse: <T = any>(data: any) => T;
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
* @default (res) => res.data
|
|
22
|
+
*/
|
|
23
|
+
getDataFromResponse: <T = any>(response: unknown) => T;
|
|
19
24
|
}
|
|
20
25
|
type ClientOptions = Partial<IClientOptions>;
|
|
21
26
|
|
|
@@ -274,12 +279,13 @@ declare class ActivityController<ResponseWrapper> implements IController {
|
|
|
274
279
|
*
|
|
275
280
|
* @support core >= 5.0.0
|
|
276
281
|
*/
|
|
277
|
-
updatePresence({ identity, position, roomName, sid, displayName, }: {
|
|
282
|
+
updatePresence({ identity, position, roomName, sid, ts, displayName, }: {
|
|
278
283
|
roomName: string;
|
|
279
284
|
position: number;
|
|
280
285
|
identity: string;
|
|
281
286
|
sid: string;
|
|
282
287
|
displayName?: string;
|
|
288
|
+
ts?: number;
|
|
283
289
|
}): RequestProxyResult<unknown, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
284
290
|
[key: string]: any;
|
|
285
291
|
data: unknown;
|
package/dist/index.d.ts
CHANGED
|
@@ -16,6 +16,11 @@ interface IClientOptions {
|
|
|
16
16
|
};
|
|
17
17
|
customThrowResponseError: <T extends Error = Error>(err: any) => T;
|
|
18
18
|
transformResponse: <T = any>(data: any) => T;
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
* @default (res) => res.data
|
|
22
|
+
*/
|
|
23
|
+
getDataFromResponse: <T = any>(response: unknown) => T;
|
|
19
24
|
}
|
|
20
25
|
type ClientOptions = Partial<IClientOptions>;
|
|
21
26
|
|
|
@@ -274,12 +279,13 @@ declare class ActivityController<ResponseWrapper> implements IController {
|
|
|
274
279
|
*
|
|
275
280
|
* @support core >= 5.0.0
|
|
276
281
|
*/
|
|
277
|
-
updatePresence({ identity, position, roomName, sid, displayName, }: {
|
|
282
|
+
updatePresence({ identity, position, roomName, sid, ts, displayName, }: {
|
|
278
283
|
roomName: string;
|
|
279
284
|
position: number;
|
|
280
285
|
identity: string;
|
|
281
286
|
sid: string;
|
|
282
287
|
displayName?: string;
|
|
288
|
+
ts?: number;
|
|
283
289
|
}): RequestProxyResult<unknown, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
284
290
|
[key: string]: any;
|
|
285
291
|
data: unknown;
|
package/dist/index.global.js
CHANGED
|
@@ -163,13 +163,14 @@
|
|
|
163
163
|
position,
|
|
164
164
|
roomName,
|
|
165
165
|
sid,
|
|
166
|
+
ts,
|
|
166
167
|
displayName
|
|
167
168
|
}) {
|
|
168
169
|
return this.proxy.presence.update.post({
|
|
169
170
|
data: {
|
|
170
171
|
identity,
|
|
171
172
|
position,
|
|
172
|
-
ts: Date.now(),
|
|
173
|
+
ts: ts || Date.now(),
|
|
173
174
|
roomName,
|
|
174
175
|
sid,
|
|
175
176
|
displayName
|
|
@@ -876,7 +877,8 @@
|
|
|
876
877
|
this.options = options;
|
|
877
878
|
this._endpoint = _endpoint.replace(/\/*$/, "").replace("localhost", "127.0.0.1");
|
|
878
879
|
this._proxy = this.buildRoute(this)();
|
|
879
|
-
options.transformResponse
|
|
880
|
+
options.transformResponse || (options.transformResponse = (data) => camelcaseKeys(data));
|
|
881
|
+
options.getDataFromResponse || (options.getDataFromResponse = (res) => res.data);
|
|
880
882
|
this.initGetClient();
|
|
881
883
|
attachRequestMethod(this);
|
|
882
884
|
}
|
|
@@ -983,7 +985,7 @@
|
|
|
983
985
|
}
|
|
984
986
|
throw that.options.customThrowResponseError ? that.options.customThrowResponseError(e) : new RequestError(message, code, url, e);
|
|
985
987
|
}
|
|
986
|
-
const data = res
|
|
988
|
+
const data = that.options.getDataFromResponse(res);
|
|
987
989
|
if (!data) {
|
|
988
990
|
return null;
|
|
989
991
|
}
|
package/dist/index.js
CHANGED
|
@@ -161,13 +161,14 @@ var ActivityController = class {
|
|
|
161
161
|
position,
|
|
162
162
|
roomName,
|
|
163
163
|
sid,
|
|
164
|
+
ts,
|
|
164
165
|
displayName
|
|
165
166
|
}) {
|
|
166
167
|
return this.proxy.presence.update.post({
|
|
167
168
|
data: {
|
|
168
169
|
identity,
|
|
169
170
|
position,
|
|
170
|
-
ts: Date.now(),
|
|
171
|
+
ts: ts || Date.now(),
|
|
171
172
|
roomName,
|
|
172
173
|
sid,
|
|
173
174
|
displayName
|
|
@@ -874,7 +875,8 @@ var HTTPClient = class {
|
|
|
874
875
|
this.options = options;
|
|
875
876
|
this._endpoint = _endpoint.replace(/\/*$/, "").replace("localhost", "127.0.0.1");
|
|
876
877
|
this._proxy = this.buildRoute(this)();
|
|
877
|
-
options.transformResponse
|
|
878
|
+
options.transformResponse || (options.transformResponse = (data) => camelcaseKeys(data));
|
|
879
|
+
options.getDataFromResponse || (options.getDataFromResponse = (res) => res.data);
|
|
878
880
|
this.initGetClient();
|
|
879
881
|
attachRequestMethod(this);
|
|
880
882
|
}
|
|
@@ -981,7 +983,7 @@ var HTTPClient = class {
|
|
|
981
983
|
}
|
|
982
984
|
throw that.options.customThrowResponseError ? that.options.customThrowResponseError(e) : new RequestError(message, code, url, e);
|
|
983
985
|
}
|
|
984
|
-
const data = res
|
|
986
|
+
const data = that.options.getDataFromResponse(res);
|
|
985
987
|
if (!data) {
|
|
986
988
|
return null;
|
|
987
989
|
}
|
package/interfaces/client.ts
CHANGED
|
@@ -11,5 +11,10 @@ interface IClientOptions {
|
|
|
11
11
|
}
|
|
12
12
|
customThrowResponseError: <T extends Error = Error>(err: any) => T
|
|
13
13
|
transformResponse: <T = any>(data: any) => T
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
* @default (res) => res.data
|
|
17
|
+
*/
|
|
18
|
+
getDataFromResponse: <T = any>(response: unknown) => T
|
|
14
19
|
}
|
|
15
20
|
export type ClientOptions = Partial<IClientOptions>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mx-space/api-client",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A api client for mx-space server@next",
|
|
6
6
|
"author": "Innei",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"axios": "^1.6.7",
|
|
52
52
|
"camelcase-keys": "^9.1.3",
|
|
53
53
|
"cors": "2.8.5",
|
|
54
|
-
"express": "4.19.
|
|
54
|
+
"express": "4.19.2",
|
|
55
55
|
"form-data": "4.0.0",
|
|
56
56
|
"lodash": "4.17.21",
|
|
57
57
|
"tsup": "8.0.2",
|