@vulog/aima-ticket 1.2.29 → 1.2.31
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/index.cjs +91 -0
- package/dist/index.d.cts +62 -0
- package/dist/index.d.mts +46 -42
- package/dist/index.mjs +82 -92
- package/package.json +20 -7
- package/{tsup.config.ts → tsdown.config.ts} +1 -1
- package/dist/index.d.ts +0 -58
- package/dist/index.js +0 -127
- /package/{.eslintrc.js → .eslintrc.cjs} +0 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let _vulog_aima_core = require("@vulog/aima-core");
|
|
3
|
+
let zod = require("zod");
|
|
4
|
+
//#region src/types.ts
|
|
5
|
+
const StatusList = zod.z.enum([
|
|
6
|
+
"PENDING",
|
|
7
|
+
"CLOSED",
|
|
8
|
+
"RESOLVED",
|
|
9
|
+
"ONGOING",
|
|
10
|
+
"REJECTED",
|
|
11
|
+
"NEW"
|
|
12
|
+
]);
|
|
13
|
+
zod.z.enum([
|
|
14
|
+
"CRITICAL",
|
|
15
|
+
"HIGH",
|
|
16
|
+
"MEDIUM",
|
|
17
|
+
"LOW"
|
|
18
|
+
]);
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region src/getTickets.ts
|
|
21
|
+
const schema = (0, _vulog_aima_core.createPaginableOptionsSchema)(zod.z.object({
|
|
22
|
+
status: zod.z.array(StatusList).default([]),
|
|
23
|
+
categoryId: zod.z.array(zod.z.number()).default([])
|
|
24
|
+
}).default({})).default({});
|
|
25
|
+
const getTickets = async (client, options) => {
|
|
26
|
+
const result = schema.safeParse(options);
|
|
27
|
+
if (!result.success) throw new TypeError("Invalid options", { cause: result.error.issues });
|
|
28
|
+
const finalOptions = result.data;
|
|
29
|
+
const searchParams = new URLSearchParams();
|
|
30
|
+
searchParams.append("page", finalOptions.page.toString());
|
|
31
|
+
searchParams.append("size", finalOptions.pageSize.toString());
|
|
32
|
+
Object.entries(finalOptions.filters).forEach(([key, value]) => {
|
|
33
|
+
if (value === void 0) return;
|
|
34
|
+
if (Array.isArray(value)) value.forEach((v) => searchParams.append(key, v.toString()));
|
|
35
|
+
else searchParams.append(key, value);
|
|
36
|
+
});
|
|
37
|
+
return client.get(`boapi/proxy/desk/fleets/${client.clientOptions.fleetId}/tickets?${searchParams.toString()}`).then(({ data, headers }) => {
|
|
38
|
+
return {
|
|
39
|
+
data,
|
|
40
|
+
page: headers.number,
|
|
41
|
+
pageSize: headers.size,
|
|
42
|
+
total: headers.totalelements,
|
|
43
|
+
totalPages: headers.totalpages
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
//#endregion
|
|
48
|
+
//#region src/getUserGroupById.ts
|
|
49
|
+
const getUserGroups = async (client, id) => {
|
|
50
|
+
const result = zod.z.string().trim().min(1).uuid().safeParse(id);
|
|
51
|
+
if (!result.success) throw new TypeError("Invalid id", { cause: result.error.issues });
|
|
52
|
+
return client.get(`boapi/proxy/desk/fleets/${client.clientOptions.fleetId}/users/${id}/groups`).then(({ data }) => data).catch((error) => {
|
|
53
|
+
if (error.formattedError?.status === 404) return [];
|
|
54
|
+
throw error;
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
//#endregion
|
|
58
|
+
//#region src/createTicket.ts
|
|
59
|
+
const createTicketParamSchema = zod.z.object({
|
|
60
|
+
subject: zod.z.string().min(1),
|
|
61
|
+
description: zod.z.string().optional(),
|
|
62
|
+
status: zod.z.enum([
|
|
63
|
+
"NEW",
|
|
64
|
+
"PENDING",
|
|
65
|
+
"CLOSED",
|
|
66
|
+
"RESOLVED",
|
|
67
|
+
"ONGOING",
|
|
68
|
+
"REJECTED"
|
|
69
|
+
]).default("NEW"),
|
|
70
|
+
priority: zod.z.enum([
|
|
71
|
+
"LOW",
|
|
72
|
+
"MEDIUM",
|
|
73
|
+
"HIGH",
|
|
74
|
+
"CRITICAL"
|
|
75
|
+
]).default("MEDIUM"),
|
|
76
|
+
categoryId: zod.z.number().min(0),
|
|
77
|
+
vehicleIds: zod.z.array(zod.z.string().uuid()).optional(),
|
|
78
|
+
userIds: zod.z.array(zod.z.string().uuid()).optional(),
|
|
79
|
+
tripId: zod.z.string().optional()
|
|
80
|
+
});
|
|
81
|
+
const createTicket = async (client, data) => {
|
|
82
|
+
const resultData = createTicketParamSchema.safeParse(data);
|
|
83
|
+
if (!resultData.success) throw new TypeError("Invalid data", { cause: resultData.error.issues });
|
|
84
|
+
const ticket = await client.post(`/boapi/proxy/desk/fleets/${client.clientOptions.fleetId}/tickets`, resultData.data);
|
|
85
|
+
if (!ticket) throw new Error("Failed to create ticket");
|
|
86
|
+
return ticket.data;
|
|
87
|
+
};
|
|
88
|
+
//#endregion
|
|
89
|
+
exports.createTicket = createTicket;
|
|
90
|
+
exports.getTickets = getTickets;
|
|
91
|
+
exports.getUserGroups = getUserGroups;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Client } from "@vulog/aima-client";
|
|
2
|
+
import { PaginableOptions, PaginableResponse } from "@vulog/aima-core";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
|
|
5
|
+
//#region src/types.d.ts
|
|
6
|
+
declare const StatusList: z.ZodEnum<["PENDING", "CLOSED", "RESOLVED", "ONGOING", "REJECTED", "NEW"]>;
|
|
7
|
+
declare const PriorityList: z.ZodEnum<["CRITICAL", "HIGH", "MEDIUM", "LOW"]>;
|
|
8
|
+
type UserGroup = {
|
|
9
|
+
id: number;
|
|
10
|
+
name: string;
|
|
11
|
+
};
|
|
12
|
+
type Status = z.infer<typeof StatusList>;
|
|
13
|
+
type Priority = z.infer<typeof PriorityList>;
|
|
14
|
+
type Ticket = {
|
|
15
|
+
id: string;
|
|
16
|
+
userId?: string | null;
|
|
17
|
+
vehicleId?: string | null;
|
|
18
|
+
fleetId: string;
|
|
19
|
+
tripId?: string | null;
|
|
20
|
+
creatorId?: string | null;
|
|
21
|
+
modelId?: number | null;
|
|
22
|
+
assignedTo?: string | null;
|
|
23
|
+
subject: string;
|
|
24
|
+
status: Status;
|
|
25
|
+
priority: Priority;
|
|
26
|
+
creationDate: string;
|
|
27
|
+
updateDate: string;
|
|
28
|
+
workedHours: number;
|
|
29
|
+
customerFault: number;
|
|
30
|
+
categoryId: string;
|
|
31
|
+
eventType?: string | null;
|
|
32
|
+
assignees: string[];
|
|
33
|
+
groupId?: number | null;
|
|
34
|
+
closeDate?: string | null;
|
|
35
|
+
userIds: string[];
|
|
36
|
+
vehicleIds: string[];
|
|
37
|
+
};
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region src/getTickets.d.ts
|
|
40
|
+
type TicketFilters = {
|
|
41
|
+
status?: Status[];
|
|
42
|
+
categoryId?: number[];
|
|
43
|
+
};
|
|
44
|
+
declare const getTickets: (client: Client, options?: PaginableOptions<TicketFilters>) => Promise<PaginableResponse<Ticket>>;
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region src/getUserGroupById.d.ts
|
|
47
|
+
declare const getUserGroups: (client: Client, id: string) => Promise<UserGroup[]>;
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region src/createTicket.d.ts
|
|
50
|
+
type CreateTicketParam = {
|
|
51
|
+
subject: string;
|
|
52
|
+
description: string;
|
|
53
|
+
status: 'NEW' | 'PENDING' | 'CLOSED' | 'RESOLVED' | 'ONGOING' | 'REJECTED';
|
|
54
|
+
priority: 'LOW' | 'MEDIUM' | 'HIGH' | 'CRITICAL';
|
|
55
|
+
categoryId: number;
|
|
56
|
+
vehicleIds?: string[];
|
|
57
|
+
userIds?: string[];
|
|
58
|
+
tripId?: string;
|
|
59
|
+
};
|
|
60
|
+
declare const createTicket: (client: Client, data: CreateTicketParam) => Promise<Ticket>;
|
|
61
|
+
//#endregion
|
|
62
|
+
export { CreateTicketParam, Priority, PriorityList, Status, StatusList, Ticket, TicketFilters, UserGroup, createTicket, getTickets, getUserGroups };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,58 +1,62 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { PaginableOptions, PaginableResponse } from "@vulog/aima-core";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { Client } from "@vulog/aima-client";
|
|
4
4
|
|
|
5
|
+
//#region src/types.d.ts
|
|
5
6
|
declare const StatusList: z.ZodEnum<["PENDING", "CLOSED", "RESOLVED", "ONGOING", "REJECTED", "NEW"]>;
|
|
6
7
|
declare const PriorityList: z.ZodEnum<["CRITICAL", "HIGH", "MEDIUM", "LOW"]>;
|
|
7
8
|
type UserGroup = {
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
id: number;
|
|
10
|
+
name: string;
|
|
10
11
|
};
|
|
11
12
|
type Status = z.infer<typeof StatusList>;
|
|
12
13
|
type Priority = z.infer<typeof PriorityList>;
|
|
13
14
|
type Ticket = {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
15
|
+
id: string;
|
|
16
|
+
userId?: string | null;
|
|
17
|
+
vehicleId?: string | null;
|
|
18
|
+
fleetId: string;
|
|
19
|
+
tripId?: string | null;
|
|
20
|
+
creatorId?: string | null;
|
|
21
|
+
modelId?: number | null;
|
|
22
|
+
assignedTo?: string | null;
|
|
23
|
+
subject: string;
|
|
24
|
+
status: Status;
|
|
25
|
+
priority: Priority;
|
|
26
|
+
creationDate: string;
|
|
27
|
+
updateDate: string;
|
|
28
|
+
workedHours: number;
|
|
29
|
+
customerFault: number;
|
|
30
|
+
categoryId: string;
|
|
31
|
+
eventType?: string | null;
|
|
32
|
+
assignees: string[];
|
|
33
|
+
groupId?: number | null;
|
|
34
|
+
closeDate?: string | null;
|
|
35
|
+
userIds: string[];
|
|
36
|
+
vehicleIds: string[];
|
|
36
37
|
};
|
|
37
|
-
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region src/getTickets.d.ts
|
|
38
40
|
type TicketFilters = {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
status?: Status[];
|
|
42
|
+
categoryId?: number[];
|
|
41
43
|
};
|
|
42
44
|
declare const getTickets: (client: Client, options?: PaginableOptions<TicketFilters>) => Promise<PaginableResponse<Ticket>>;
|
|
43
|
-
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region src/getUserGroupById.d.ts
|
|
44
47
|
declare const getUserGroups: (client: Client, id: string) => Promise<UserGroup[]>;
|
|
45
|
-
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region src/createTicket.d.ts
|
|
46
50
|
type CreateTicketParam = {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
subject: string;
|
|
52
|
+
description: string;
|
|
53
|
+
status: 'NEW' | 'PENDING' | 'CLOSED' | 'RESOLVED' | 'ONGOING' | 'REJECTED';
|
|
54
|
+
priority: 'LOW' | 'MEDIUM' | 'HIGH' | 'CRITICAL';
|
|
55
|
+
categoryId: number;
|
|
56
|
+
vehicleIds?: string[];
|
|
57
|
+
userIds?: string[];
|
|
58
|
+
tripId?: string;
|
|
55
59
|
};
|
|
56
60
|
declare const createTicket: (client: Client, data: CreateTicketParam) => Promise<Ticket>;
|
|
57
|
-
|
|
58
|
-
export {
|
|
61
|
+
//#endregion
|
|
62
|
+
export { CreateTicketParam, Priority, PriorityList, Status, StatusList, Ticket, TicketFilters, UserGroup, createTicket, getTickets, getUserGroups };
|
package/dist/index.mjs
CHANGED
|
@@ -1,98 +1,88 @@
|
|
|
1
|
-
// src/getTickets.ts
|
|
2
1
|
import { createPaginableOptionsSchema } from "@vulog/aima-core";
|
|
3
|
-
import { z as z2 } from "zod";
|
|
4
|
-
|
|
5
|
-
// src/types.ts
|
|
6
2
|
import { z } from "zod";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
3
|
+
//#region src/types.ts
|
|
4
|
+
const StatusList = z.enum([
|
|
5
|
+
"PENDING",
|
|
6
|
+
"CLOSED",
|
|
7
|
+
"RESOLVED",
|
|
8
|
+
"ONGOING",
|
|
9
|
+
"REJECTED",
|
|
10
|
+
"NEW"
|
|
11
|
+
]);
|
|
12
|
+
z.enum([
|
|
13
|
+
"CRITICAL",
|
|
14
|
+
"HIGH",
|
|
15
|
+
"MEDIUM",
|
|
16
|
+
"LOW"
|
|
17
|
+
]);
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region src/getTickets.ts
|
|
20
|
+
const schema = createPaginableOptionsSchema(z.object({
|
|
21
|
+
status: z.array(StatusList).default([]),
|
|
22
|
+
categoryId: z.array(z.number()).default([])
|
|
23
|
+
}).default({})).default({});
|
|
24
|
+
const getTickets = async (client, options) => {
|
|
25
|
+
const result = schema.safeParse(options);
|
|
26
|
+
if (!result.success) throw new TypeError("Invalid options", { cause: result.error.issues });
|
|
27
|
+
const finalOptions = result.data;
|
|
28
|
+
const searchParams = new URLSearchParams();
|
|
29
|
+
searchParams.append("page", finalOptions.page.toString());
|
|
30
|
+
searchParams.append("size", finalOptions.pageSize.toString());
|
|
31
|
+
Object.entries(finalOptions.filters).forEach(([key, value]) => {
|
|
32
|
+
if (value === void 0) return;
|
|
33
|
+
if (Array.isArray(value)) value.forEach((v) => searchParams.append(key, v.toString()));
|
|
34
|
+
else searchParams.append(key, value);
|
|
35
|
+
});
|
|
36
|
+
return client.get(`boapi/proxy/desk/fleets/${client.clientOptions.fleetId}/tickets?${searchParams.toString()}`).then(({ data, headers }) => {
|
|
37
|
+
return {
|
|
38
|
+
data,
|
|
39
|
+
page: headers.number,
|
|
40
|
+
pageSize: headers.size,
|
|
41
|
+
total: headers.totalelements,
|
|
42
|
+
totalPages: headers.totalpages
|
|
43
|
+
};
|
|
44
|
+
});
|
|
47
45
|
};
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
return client.get(`boapi/proxy/desk/fleets/${client.clientOptions.fleetId}/users/${id}/groups`).then(({ data }) => data).catch((error) => {
|
|
59
|
-
if (error.formattedError?.status === 404) {
|
|
60
|
-
return [];
|
|
61
|
-
}
|
|
62
|
-
throw error;
|
|
63
|
-
});
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region src/getUserGroupById.ts
|
|
48
|
+
const getUserGroups = async (client, id) => {
|
|
49
|
+
const result = z.string().trim().min(1).uuid().safeParse(id);
|
|
50
|
+
if (!result.success) throw new TypeError("Invalid id", { cause: result.error.issues });
|
|
51
|
+
return client.get(`boapi/proxy/desk/fleets/${client.clientOptions.fleetId}/users/${id}/groups`).then(({ data }) => data).catch((error) => {
|
|
52
|
+
if (error.formattedError?.status === 404) return [];
|
|
53
|
+
throw error;
|
|
54
|
+
});
|
|
64
55
|
};
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
56
|
+
//#endregion
|
|
57
|
+
//#region src/createTicket.ts
|
|
58
|
+
const createTicketParamSchema = z.object({
|
|
59
|
+
subject: z.string().min(1),
|
|
60
|
+
description: z.string().optional(),
|
|
61
|
+
status: z.enum([
|
|
62
|
+
"NEW",
|
|
63
|
+
"PENDING",
|
|
64
|
+
"CLOSED",
|
|
65
|
+
"RESOLVED",
|
|
66
|
+
"ONGOING",
|
|
67
|
+
"REJECTED"
|
|
68
|
+
]).default("NEW"),
|
|
69
|
+
priority: z.enum([
|
|
70
|
+
"LOW",
|
|
71
|
+
"MEDIUM",
|
|
72
|
+
"HIGH",
|
|
73
|
+
"CRITICAL"
|
|
74
|
+
]).default("MEDIUM"),
|
|
75
|
+
categoryId: z.number().min(0),
|
|
76
|
+
vehicleIds: z.array(z.string().uuid()).optional(),
|
|
77
|
+
userIds: z.array(z.string().uuid()).optional(),
|
|
78
|
+
tripId: z.string().optional()
|
|
77
79
|
});
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
const ticket = await client.post(
|
|
86
|
-
`/boapi/proxy/desk/fleets/${client.clientOptions.fleetId}/tickets`,
|
|
87
|
-
resultData.data
|
|
88
|
-
);
|
|
89
|
-
if (!ticket) {
|
|
90
|
-
throw new Error("Failed to create ticket");
|
|
91
|
-
}
|
|
92
|
-
return ticket.data;
|
|
93
|
-
};
|
|
94
|
-
export {
|
|
95
|
-
createTicket,
|
|
96
|
-
getTickets,
|
|
97
|
-
getUserGroups
|
|
80
|
+
const createTicket = async (client, data) => {
|
|
81
|
+
const resultData = createTicketParamSchema.safeParse(data);
|
|
82
|
+
if (!resultData.success) throw new TypeError("Invalid data", { cause: resultData.error.issues });
|
|
83
|
+
const ticket = await client.post(`/boapi/proxy/desk/fleets/${client.clientOptions.fleetId}/tickets`, resultData.data);
|
|
84
|
+
if (!ticket) throw new Error("Failed to create ticket");
|
|
85
|
+
return ticket.data;
|
|
98
86
|
};
|
|
87
|
+
//#endregion
|
|
88
|
+
export { createTicket, getTickets, getUserGroups };
|
package/package.json
CHANGED
|
@@ -1,12 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vulog/aima-ticket",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "1.2.31",
|
|
5
|
+
"main": "dist/index.cjs",
|
|
5
6
|
"module": "dist/index.mjs",
|
|
6
|
-
"types": "dist/index.d.
|
|
7
|
+
"types": "dist/index.d.cts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": {
|
|
11
|
+
"types": "./dist/index.d.mts",
|
|
12
|
+
"default": "./dist/index.mjs"
|
|
13
|
+
},
|
|
14
|
+
"require": {
|
|
15
|
+
"types": "./dist/index.d.cts",
|
|
16
|
+
"default": "./dist/index.cjs"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
},
|
|
7
20
|
"scripts": {
|
|
8
|
-
"build": "
|
|
9
|
-
"dev": "
|
|
21
|
+
"build": "tsdown",
|
|
22
|
+
"dev": "tsdown --watch",
|
|
10
23
|
"test": "vitest run",
|
|
11
24
|
"test:watch": "vitest",
|
|
12
25
|
"lint": "eslint src/**/* --ext .ts"
|
|
@@ -19,8 +32,8 @@
|
|
|
19
32
|
"author": "Vulog",
|
|
20
33
|
"license": "MIT",
|
|
21
34
|
"dependencies": {
|
|
22
|
-
"@vulog/aima-client": "1.2.
|
|
23
|
-
"@vulog/aima-core": "1.2.
|
|
35
|
+
"@vulog/aima-client": "1.2.31",
|
|
36
|
+
"@vulog/aima-core": "1.2.31"
|
|
24
37
|
},
|
|
25
38
|
"peerDependencies": {
|
|
26
39
|
"zod": "^3.25.76"
|
package/dist/index.d.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { Client } from '@vulog/aima-client';
|
|
2
|
-
import { PaginableOptions, PaginableResponse } from '@vulog/aima-core';
|
|
3
|
-
import { z } from 'zod';
|
|
4
|
-
|
|
5
|
-
declare const StatusList: z.ZodEnum<["PENDING", "CLOSED", "RESOLVED", "ONGOING", "REJECTED", "NEW"]>;
|
|
6
|
-
declare const PriorityList: z.ZodEnum<["CRITICAL", "HIGH", "MEDIUM", "LOW"]>;
|
|
7
|
-
type UserGroup = {
|
|
8
|
-
id: number;
|
|
9
|
-
name: string;
|
|
10
|
-
};
|
|
11
|
-
type Status = z.infer<typeof StatusList>;
|
|
12
|
-
type Priority = z.infer<typeof PriorityList>;
|
|
13
|
-
type Ticket = {
|
|
14
|
-
id: string;
|
|
15
|
-
userId?: string | null;
|
|
16
|
-
vehicleId?: string | null;
|
|
17
|
-
fleetId: string;
|
|
18
|
-
tripId?: string | null;
|
|
19
|
-
creatorId?: string | null;
|
|
20
|
-
modelId?: number | null;
|
|
21
|
-
assignedTo?: string | null;
|
|
22
|
-
subject: string;
|
|
23
|
-
status: Status;
|
|
24
|
-
priority: Priority;
|
|
25
|
-
creationDate: string;
|
|
26
|
-
updateDate: string;
|
|
27
|
-
workedHours: number;
|
|
28
|
-
customerFault: number;
|
|
29
|
-
categoryId: string;
|
|
30
|
-
eventType?: string | null;
|
|
31
|
-
assignees: string[];
|
|
32
|
-
groupId?: number | null;
|
|
33
|
-
closeDate?: string | null;
|
|
34
|
-
userIds: string[];
|
|
35
|
-
vehicleIds: string[];
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
type TicketFilters = {
|
|
39
|
-
status?: Status[];
|
|
40
|
-
categoryId?: number[];
|
|
41
|
-
};
|
|
42
|
-
declare const getTickets: (client: Client, options?: PaginableOptions<TicketFilters>) => Promise<PaginableResponse<Ticket>>;
|
|
43
|
-
|
|
44
|
-
declare const getUserGroups: (client: Client, id: string) => Promise<UserGroup[]>;
|
|
45
|
-
|
|
46
|
-
type CreateTicketParam = {
|
|
47
|
-
subject: string;
|
|
48
|
-
description: string;
|
|
49
|
-
status: 'NEW' | 'PENDING' | 'CLOSED' | 'RESOLVED' | 'ONGOING' | 'REJECTED';
|
|
50
|
-
priority: 'LOW' | 'MEDIUM' | 'HIGH' | 'CRITICAL';
|
|
51
|
-
categoryId: number;
|
|
52
|
-
vehicleIds?: string[];
|
|
53
|
-
userIds?: string[];
|
|
54
|
-
tripId?: string;
|
|
55
|
-
};
|
|
56
|
-
declare const createTicket: (client: Client, data: CreateTicketParam) => Promise<Ticket>;
|
|
57
|
-
|
|
58
|
-
export { type CreateTicketParam, type Priority, PriorityList, type Status, StatusList, type Ticket, type TicketFilters, type UserGroup, createTicket, getTickets, getUserGroups };
|
package/dist/index.js
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/index.ts
|
|
21
|
-
var index_exports = {};
|
|
22
|
-
__export(index_exports, {
|
|
23
|
-
createTicket: () => createTicket,
|
|
24
|
-
getTickets: () => getTickets,
|
|
25
|
-
getUserGroups: () => getUserGroups
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(index_exports);
|
|
28
|
-
|
|
29
|
-
// src/getTickets.ts
|
|
30
|
-
var import_aima_core = require("@vulog/aima-core");
|
|
31
|
-
var import_zod2 = require("zod");
|
|
32
|
-
|
|
33
|
-
// src/types.ts
|
|
34
|
-
var import_zod = require("zod");
|
|
35
|
-
var StatusList = import_zod.z.enum(["PENDING", "CLOSED", "RESOLVED", "ONGOING", "REJECTED", "NEW"]);
|
|
36
|
-
var PriorityList = import_zod.z.enum(["CRITICAL", "HIGH", "MEDIUM", "LOW"]);
|
|
37
|
-
|
|
38
|
-
// src/getTickets.ts
|
|
39
|
-
var schema = (0, import_aima_core.createPaginableOptionsSchema)(
|
|
40
|
-
import_zod2.z.object({
|
|
41
|
-
status: import_zod2.z.array(StatusList).default([]),
|
|
42
|
-
categoryId: import_zod2.z.array(import_zod2.z.number()).default([])
|
|
43
|
-
}).default({})
|
|
44
|
-
).default({});
|
|
45
|
-
var getTickets = async (client, options) => {
|
|
46
|
-
const result = schema.safeParse(options);
|
|
47
|
-
if (!result.success) {
|
|
48
|
-
throw new TypeError("Invalid options", {
|
|
49
|
-
cause: result.error.issues
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
const finalOptions = result.data;
|
|
53
|
-
const searchParams = new URLSearchParams();
|
|
54
|
-
searchParams.append("page", finalOptions.page.toString());
|
|
55
|
-
searchParams.append("size", finalOptions.pageSize.toString());
|
|
56
|
-
Object.entries(finalOptions.filters).forEach(([key, value]) => {
|
|
57
|
-
if (value === void 0) {
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
if (Array.isArray(value)) {
|
|
61
|
-
value.forEach((v) => searchParams.append(key, v.toString()));
|
|
62
|
-
} else {
|
|
63
|
-
searchParams.append(key, value);
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
return client.get(`boapi/proxy/desk/fleets/${client.clientOptions.fleetId}/tickets?${searchParams.toString()}`).then(({ data, headers }) => {
|
|
67
|
-
return {
|
|
68
|
-
data,
|
|
69
|
-
page: headers.number,
|
|
70
|
-
pageSize: headers.size,
|
|
71
|
-
total: headers.totalelements,
|
|
72
|
-
totalPages: headers.totalpages
|
|
73
|
-
};
|
|
74
|
-
});
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
// src/getUserGroupById.ts
|
|
78
|
-
var import_zod3 = require("zod");
|
|
79
|
-
var getUserGroups = async (client, id) => {
|
|
80
|
-
const result = import_zod3.z.string().trim().min(1).uuid().safeParse(id);
|
|
81
|
-
if (!result.success) {
|
|
82
|
-
throw new TypeError("Invalid id", {
|
|
83
|
-
cause: result.error.issues
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
return client.get(`boapi/proxy/desk/fleets/${client.clientOptions.fleetId}/users/${id}/groups`).then(({ data }) => data).catch((error) => {
|
|
87
|
-
if (error.formattedError?.status === 404) {
|
|
88
|
-
return [];
|
|
89
|
-
}
|
|
90
|
-
throw error;
|
|
91
|
-
});
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
// src/createTicket.ts
|
|
95
|
-
var import_zod4 = require("zod");
|
|
96
|
-
var createTicketParamSchema = import_zod4.z.object({
|
|
97
|
-
subject: import_zod4.z.string().min(1),
|
|
98
|
-
description: import_zod4.z.string().optional(),
|
|
99
|
-
status: import_zod4.z.enum(["NEW", "PENDING", "CLOSED", "RESOLVED", "ONGOING", "REJECTED"]).default("NEW"),
|
|
100
|
-
priority: import_zod4.z.enum(["LOW", "MEDIUM", "HIGH", "CRITICAL"]).default("MEDIUM"),
|
|
101
|
-
categoryId: import_zod4.z.number().min(0),
|
|
102
|
-
vehicleIds: import_zod4.z.array(import_zod4.z.string().uuid()).optional(),
|
|
103
|
-
userIds: import_zod4.z.array(import_zod4.z.string().uuid()).optional(),
|
|
104
|
-
tripId: import_zod4.z.string().optional()
|
|
105
|
-
});
|
|
106
|
-
var createTicket = async (client, data) => {
|
|
107
|
-
const resultData = createTicketParamSchema.safeParse(data);
|
|
108
|
-
if (!resultData.success) {
|
|
109
|
-
throw new TypeError("Invalid data", {
|
|
110
|
-
cause: resultData.error.issues
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
const ticket = await client.post(
|
|
114
|
-
`/boapi/proxy/desk/fleets/${client.clientOptions.fleetId}/tickets`,
|
|
115
|
-
resultData.data
|
|
116
|
-
);
|
|
117
|
-
if (!ticket) {
|
|
118
|
-
throw new Error("Failed to create ticket");
|
|
119
|
-
}
|
|
120
|
-
return ticket.data;
|
|
121
|
-
};
|
|
122
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
123
|
-
0 && (module.exports = {
|
|
124
|
-
createTicket,
|
|
125
|
-
getTickets,
|
|
126
|
-
getUserGroups
|
|
127
|
-
});
|
|
File without changes
|