Skip to content

Commit 3b77152

Browse files
author
Kenneth
committed
feature: update for dun-protocol
1 parent 969187c commit 3b77152

34 files changed

+209
-186
lines changed

dun-js-v1.2.2.tgz

-33.3 KB
Binary file not shown.

dun-js-v1.2.3.tgz

-68.2 KB
Binary file not shown.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "dun-js",
33
"description": "The Javascript package for DUN",
4-
"version": "1.2.3",
4+
"version": "1.2.10",
55
"author": "1byte devteam",
66
"license": "ISC",
77
"bugs": {

src/api/calendar.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import { axiosInstanceDun } from "@/config/axios/axiosClient";
2-
import { DateType, ICalendar, IdType, IGetListCalendarParams } from "@/models";
1+
import { axiosInstanceDun } from '../config/axios/axiosClient';
2+
import { DateType, ICalendar, IdType, IGetListCalendarParams } from '../models';
3+
import { formatStringByObj } from '../utils/string';
34

45
const REST = 'calendars';
56

6-
const resetPath = `${REST}/reset`;
7+
const resetPath = `${REST}/reset/{deviceId}`;
78
const lastClientTimePath = `${REST}/last-client-time`;
89

910
export const getListCalendarAPI = async (params?: IGetListCalendarParams): Promise<ICalendar[]> => {
@@ -17,18 +18,18 @@ export const getListCalendarAPI = async (params?: IGetListCalendarParams): Promi
1718
};
1819

1920
export const resetCalendarAPI = async (deviceId: IdType): Promise<boolean> => {
20-
const response = await axiosInstanceDun.post(resetPath, {
21-
deviceId,
22-
});
21+
const response = await axiosInstanceDun.post(
22+
formatStringByObj(resetPath, {
23+
deviceId,
24+
}),
25+
);
2326

2427
const isSuccess = response.data;
2528

2629
return isSuccess;
2730
};
2831

29-
export const getLastSyncTimeCalendarAPI = async (
30-
deviceId: IdType
31-
): Promise<DateType | null> => {
32+
export const getLastSyncTimeCalendarAPI = async (deviceId: IdType): Promise<DateType | null> => {
3233
const params = {
3334
deviceId,
3435
};

src/api/call.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
import { axiosInstanceDun } from "@/config/axios/axiosClient";
2-
import { DateType, ICall, IdType, IGetListCallParams } from "@/models";
3-
import { IListResponse } from "@/models/interfaces/common";
1+
import { axiosInstanceDun } from '../config/axios/axiosClient';
2+
import { DateType, ICall, IdType, IGetListCallParams } from '../models';
3+
import { IListResponse } from '../models/interfaces/common';
4+
import { formatStringByObj } from '../utils/string';
45

56
const REST = 'calls';
67

7-
const resetPath = `${REST}/reset`;
8+
const resetPath = `${REST}/reset/{deviceId}`;
89
const lastClientTimePath = `${REST}/last-client-time`;
910

10-
export const getListCallAPI = async (
11-
params?: IGetListCallParams
12-
): Promise<IListResponse<ICall>> => {
11+
export const getListCallAPI = async (params?: IGetListCallParams): Promise<IListResponse<ICall>> => {
1312
const url = `${REST}`;
1413

1514
const response = await axiosInstanceDun.get(url, {
@@ -25,9 +24,11 @@ export const getListCallAPI = async (
2524
};
2625

2726
export const resetCallAPI = async (deviceId: IdType): Promise<boolean> => {
28-
const response = await axiosInstanceDun.post(resetPath, {
29-
deviceId,
30-
});
27+
const response = await axiosInstanceDun.post(
28+
formatStringByObj(resetPath, {
29+
deviceId,
30+
}),
31+
);
3132

3233
const isSuccess = response.data;
3334

src/api/clipboard.ts

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
import { axiosInstanceDun } from "@/config/axios/axiosClient";
2-
import { DateType, IClipboard, IdType, IGetListClipboardParams } from "@/models";
3-
import { IListResponse } from "@/models/interfaces/common";
1+
import { axiosInstanceDun } from '../config/axios/axiosClient';
2+
import { DateType, IClipboard, IdType, IGetListClipboardParams } from '../models';
3+
import { IListResponse } from '../models/interfaces/common';
4+
import { formatStringByObj } from '../utils/string';
45

56
const REST = 'clipboards';
67

7-
const resetPath = `${REST}/reset`;
8+
const resetPath = `${REST}/reset/{deviceId}`;
89
const lastClientTimePath = `${REST}/last-client-time`;
910

10-
export const getListClipboardAPI = async (
11-
params?: IGetListClipboardParams
12-
): Promise<IListResponse<IClipboard>> => {
11+
export const getListClipboardAPI = async (params?: IGetListClipboardParams): Promise<IListResponse<IClipboard>> => {
1312
const clipboard = `${REST}`;
1413

1514
const response = await axiosInstanceDun.get(clipboard, {
@@ -25,9 +24,11 @@ export const getListClipboardAPI = async (
2524
};
2625

2726
export const resetClipboardAPI = async (deviceId: IdType): Promise<boolean> => {
28-
const response = await axiosInstanceDun.post(resetPath, {
29-
deviceId,
30-
});
27+
const response = await axiosInstanceDun.post(
28+
formatStringByObj(resetPath, {
29+
deviceId,
30+
}),
31+
);
3132

3233
const isSuccess = response.data;
3334

@@ -44,9 +45,7 @@ export const deleteClipboardAPI = async (id: IdType): Promise<boolean> => {
4445
return isSuccess;
4546
};
4647

47-
export const getLastSyncTimeClipboardAPI = async (
48-
deviceId: IdType
49-
): Promise<DateType | null> => {
48+
export const getLastSyncTimeClipboardAPI = async (deviceId: IdType): Promise<DateType | null> => {
5049
const params = {
5150
deviceId,
5251
};

src/api/contact.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
import { axiosInstanceDun } from "@/config/axios/axiosClient";
2-
import { DateType, IContact, IdType, IGetListContactParams } from "@/models";
3-
import { IListResponse } from "@/models/interfaces/common";
1+
import { axiosInstanceDun } from '../config/axios/axiosClient';
2+
import { DateType, IContact, IdType, IGetListContactParams } from '../models';
3+
import { IListResponse } from '../models/interfaces/common';
4+
import { formatStringByObj } from '../utils/string';
45

56
const REST = 'contacts';
67

7-
const resetPath = `${REST}/reset`;
8+
const resetPath = `${REST}/reset/{deviceId}`;
89
const lastClientTimePath = `${REST}/last-client-time`;
910

10-
export const getListContactAPI = async (
11-
params?: IGetListContactParams
12-
): Promise<IListResponse<IContact>> => {
11+
export const getListContactAPI = async (params?: IGetListContactParams): Promise<IListResponse<IContact>> => {
1312
const url = `${REST}`;
1413

1514
const response = await axiosInstanceDun.get(url, {
@@ -25,9 +24,11 @@ export const getListContactAPI = async (
2524
};
2625

2726
export const resetContactAPI = async (deviceId: IdType): Promise<boolean> => {
28-
const response = await axiosInstanceDun.post(resetPath, {
29-
deviceId,
30-
});
27+
const response = await axiosInstanceDun.post(
28+
formatStringByObj(resetPath, {
29+
deviceId,
30+
}),
31+
);
3132

3233
const isSuccess = response.data;
3334

src/api/deviceDataSync.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { axiosInstanceDun } from '@/config/axios/axiosClient';
2-
import { IDeviceDataSync, IGetOrCreateDeviceDataSync } from '@/models';
1+
import { axiosInstanceDun } from '../config/axios/axiosClient';
2+
import { IDeviceDataSync, IGetOrCreateDeviceDataSync } from '../models';
3+
34

45
const REST = 'devices/data-sync';
56

src/api/deviceSettingSync.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
import { axiosInstanceDun } from "@/config/axios/axiosClient";
2-
import { ICreateOrUpdateDeviceSettingSync, IDeviceSettingSync, IGetOrCreateDeviceSettingSync } from "@/models";
1+
import { axiosInstanceDun } from '../config/axios/axiosClient';
2+
import { ICreateOrUpdateDeviceSettingSync, IDeviceSettingSync, IGetOrCreateDeviceSettingSync } from '../models';
33

44
const REST = 'devices/setting-sync';
55

66
const getOrCreatePath = `${REST}/get-or-create`;
77
const createOrUpdatePath = `${REST}/create-or-update`;
88

9-
export const getDeviceSettingSync = async (
10-
params?: IGetOrCreateDeviceSettingSync
11-
): Promise<IDeviceSettingSync> => {
9+
export const getDeviceSettingSync = async (params?: IGetOrCreateDeviceSettingSync): Promise<IDeviceSettingSync> => {
1210
const response = await axiosInstanceDun.get(getOrCreatePath, {
1311
params,
1412
});
@@ -17,7 +15,7 @@ export const getDeviceSettingSync = async (
1715
};
1816

1917
export const createOrUpdateDeviceSettingSync = async (
20-
params?: ICreateOrUpdateDeviceSettingSync
18+
params?: ICreateOrUpdateDeviceSettingSync,
2119
): Promise<ICreateOrUpdateDeviceSettingSync> => {
2220
const response = await axiosInstanceDun.post(createOrUpdatePath, params);
2321

src/api/devices.ts

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,37 @@
1-
import { axiosInstanceDun } from '@/config/axios/axiosClient';
1+
import { axiosInstanceDun } from '../config/axios/axiosClient';
22
import {
3-
IAggregateDevice,
4-
IDeleteDeviceParams,
5-
IEditDeviceParams,
6-
IEditDevicePayload,
7-
IGetListAggregateDevicesParams,
8-
} from '@/models';
3+
IAggregateDevice,
4+
IDeleteDeviceParams,
5+
IEditDeviceParams,
6+
IEditDevicePayload,
7+
IGetListAggregateDevicesParams,
8+
} from '../models';
99

1010
const REST = 'devices';
1111
const GET_ALL_AGGREGATE_DEVICES_PATH = `${REST}/owner`;
1212

1313
export const getAllAggregateDevicesAPI = async (
14-
params: IGetListAggregateDevicesParams,
14+
params: IGetListAggregateDevicesParams,
1515
): Promise<IAggregateDevice[]> => {
16-
const response = await axiosInstanceDun.get(GET_ALL_AGGREGATE_DEVICES_PATH, {
17-
params,
18-
});
16+
const response = await axiosInstanceDun.get(GET_ALL_AGGREGATE_DEVICES_PATH, {
17+
params,
18+
});
1919

20-
return response.data;
20+
return response.data;
2121
};
2222

2323
export const deleteDeviceAPI = async (params: IDeleteDeviceParams) => {
24-
const { id } = params;
25-
const url = `${REST}/${id}`;
24+
const { id } = params;
25+
const url = `${REST}/${id}`;
2626

27-
return await axiosInstanceDun.delete(url);
27+
return await axiosInstanceDun.delete(url);
2828
};
2929

30-
export const updateDeviceAPI = async (
31-
params: IEditDeviceParams,
32-
payload: IEditDevicePayload,
33-
) => {
34-
const { id } = params;
35-
const url = `${REST}/${id}`;
30+
export const updateDeviceAPI = async (params: IEditDeviceParams, payload: IEditDevicePayload) => {
31+
const { id } = params;
32+
const url = `${REST}/${id}`;
3633

37-
const response = await axiosInstanceDun.patch(url, payload);
34+
const response = await axiosInstanceDun.patch(url, payload);
3835

39-
return response.data;
36+
return response.data;
4037
};

0 commit comments

Comments
 (0)