vms-nest-prisma-api-document 8.0.1 → 9.0.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.
@@ -0,0 +1,173 @@
1
+ import { YesNo, ReportType, ReportPreference, Status, PAGING, LoadParents, LoadChild, LoadChildCount, OrderBy } from '../../../../core/Enums.js';
2
+ import { FBR, SBR } from '../../../../core/BaseResponse.js';
3
+ import { z } from 'zod';
4
+ import { U as UserOrganisation, M as MasterVehicle } from '../../../../user_organisation_service-D2pCLN2b.js';
5
+ import '../../../../zod_utils/zod_base_schema.js';
6
+ import '../../../master/main/master_main_sim_provider_service.js';
7
+
8
+ interface UserReportsPreferences extends Record<string, unknown> {
9
+ report_preference_id: string;
10
+ report_name: string;
11
+ report_status: YesNo;
12
+ report_type: ReportType;
13
+ email_ids: string;
14
+ cc_email_ids?: string;
15
+ report_list: ReportPreference[];
16
+ is_all_vehicles: YesNo;
17
+ status: Status;
18
+ added_date_time: string;
19
+ modified_date_time: string;
20
+ organisation_id: string;
21
+ UserOrganisation?: UserOrganisation;
22
+ UserReportsPreferencesVehicleLink: UserReportsPreferencesVehicleLink[];
23
+ _count?: {
24
+ UserReportsPreferencesVehicleLink: number;
25
+ };
26
+ }
27
+ interface UserReportsPreferencesVehicleLink extends Record<string, unknown> {
28
+ report_vehicle_id: string;
29
+ status: Status;
30
+ added_date_time: string;
31
+ modified_date_time: string;
32
+ vehicle_id: string;
33
+ MasterVehicle?: MasterVehicle;
34
+ vehicle_number?: string;
35
+ vehicle_type?: string;
36
+ report_preference_id: string;
37
+ UserReportsPreferences?: UserReportsPreferences;
38
+ }
39
+ declare const UserReportPreferencesSchema: z.ZodObject<{
40
+ organisation_id: z.ZodEffects<z.ZodString, string, string>;
41
+ report_name: z.ZodEffects<z.ZodString, string, string>;
42
+ report_status: z.ZodType<YesNo, z.ZodTypeDef, YesNo>;
43
+ report_type: z.ZodType<ReportType, z.ZodTypeDef, ReportType>;
44
+ email_ids: z.ZodEffects<z.ZodString, string, string>;
45
+ cc_email_ids: z.ZodDefault<z.ZodEffects<z.ZodString, string, string>>;
46
+ is_all_vehicles: z.ZodType<YesNo, z.ZodTypeDef, YesNo>;
47
+ report_list: z.ZodDefault<z.ZodArray<z.ZodNativeEnum<typeof ReportPreference>, "many">>;
48
+ status: z.ZodType<Status, z.ZodTypeDef, Status>;
49
+ vehicle_ids: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
50
+ }, "strip", z.ZodTypeAny, {
51
+ email_ids: string;
52
+ cc_email_ids: string;
53
+ is_all_vehicles: YesNo;
54
+ status: Status;
55
+ organisation_id: string;
56
+ vehicle_ids: string[];
57
+ report_name: string;
58
+ report_status: YesNo;
59
+ report_type: ReportType;
60
+ report_list: ReportPreference[];
61
+ }, {
62
+ email_ids: string;
63
+ is_all_vehicles: YesNo;
64
+ status: Status;
65
+ organisation_id: string;
66
+ report_name: string;
67
+ report_status: YesNo;
68
+ report_type: ReportType;
69
+ cc_email_ids?: string | undefined;
70
+ vehicle_ids?: string[] | undefined;
71
+ report_list?: ReportPreference[] | undefined;
72
+ }>;
73
+ type UserReportPreferencesDTO = z.infer<typeof UserReportPreferencesSchema>;
74
+ declare const UserReportPreferencesQuerySchema: z.ZodObject<{
75
+ search: z.ZodDefault<z.ZodEffects<z.ZodString, string, string>>;
76
+ status: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodNativeEnum<typeof Status>, "many">>>;
77
+ paging: z.ZodDefault<z.ZodOptional<z.ZodNativeEnum<typeof PAGING>>>;
78
+ page_count: z.ZodEffects<z.ZodDefault<z.ZodOptional<z.ZodNumber>>, number, unknown>;
79
+ page_index: z.ZodEffects<z.ZodDefault<z.ZodOptional<z.ZodNumber>>, number, unknown>;
80
+ load_parents: z.ZodDefault<z.ZodOptional<z.ZodNativeEnum<typeof LoadParents>>>;
81
+ load_parents_list: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
82
+ load_child: z.ZodDefault<z.ZodOptional<z.ZodNativeEnum<typeof LoadChild>>>;
83
+ load_child_list: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
84
+ load_child_count: z.ZodDefault<z.ZodOptional<z.ZodNativeEnum<typeof LoadChildCount>>>;
85
+ load_child_count_list: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
86
+ include_details: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>>;
87
+ where_relations: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>>;
88
+ order_by: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodObject<{
89
+ name: z.ZodEffects<z.ZodString, string, string>;
90
+ field: z.ZodEffects<z.ZodString, string, string>;
91
+ direction: z.ZodType<OrderBy, z.ZodTypeDef, OrderBy>;
92
+ }, "strip", z.ZodTypeAny, {
93
+ name: string;
94
+ field: string;
95
+ direction: OrderBy;
96
+ }, {
97
+ name: string;
98
+ field: string;
99
+ direction: OrderBy;
100
+ }>, "many">>>;
101
+ include_master_data: z.ZodDefault<z.ZodOptional<z.ZodNativeEnum<typeof YesNo>>>;
102
+ date_format_id: z.ZodEffects<z.ZodString, string, string>;
103
+ time_zone_id: z.ZodEffects<z.ZodString, string, string>;
104
+ } & {
105
+ organisation_ids: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
106
+ report_preference_ids: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
107
+ report_status: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodNativeEnum<typeof YesNo>, "many">>>;
108
+ report_type: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodNativeEnum<typeof ReportType>, "many">>>;
109
+ is_all_vehicles: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodNativeEnum<typeof YesNo>, "many">>>;
110
+ }, "strip", z.ZodTypeAny, {
111
+ is_all_vehicles: YesNo[];
112
+ status: Status[];
113
+ search: string;
114
+ paging: PAGING;
115
+ page_count: number;
116
+ page_index: number;
117
+ load_parents: LoadParents;
118
+ load_parents_list: string[];
119
+ load_child: LoadChild;
120
+ load_child_list: string[];
121
+ load_child_count: LoadChildCount;
122
+ load_child_count_list: string[];
123
+ include_details: Record<string, any>;
124
+ where_relations: Record<string, any>;
125
+ order_by: {
126
+ name: string;
127
+ field: string;
128
+ direction: OrderBy;
129
+ }[];
130
+ include_master_data: YesNo;
131
+ date_format_id: string;
132
+ time_zone_id: string;
133
+ organisation_ids: string[];
134
+ report_status: YesNo[];
135
+ report_type: ReportType[];
136
+ report_preference_ids: string[];
137
+ }, {
138
+ date_format_id: string;
139
+ time_zone_id: string;
140
+ is_all_vehicles?: YesNo[] | undefined;
141
+ status?: Status[] | undefined;
142
+ search?: string | undefined;
143
+ paging?: PAGING | undefined;
144
+ page_count?: unknown;
145
+ page_index?: unknown;
146
+ load_parents?: LoadParents | undefined;
147
+ load_parents_list?: string[] | undefined;
148
+ load_child?: LoadChild | undefined;
149
+ load_child_list?: string[] | undefined;
150
+ load_child_count?: LoadChildCount | undefined;
151
+ load_child_count_list?: string[] | undefined;
152
+ include_details?: Record<string, any> | undefined;
153
+ where_relations?: Record<string, any> | undefined;
154
+ order_by?: {
155
+ name: string;
156
+ field: string;
157
+ direction: OrderBy;
158
+ }[] | undefined;
159
+ include_master_data?: YesNo | undefined;
160
+ organisation_ids?: string[] | undefined;
161
+ report_status?: YesNo[] | undefined;
162
+ report_type?: ReportType[] | undefined;
163
+ report_preference_ids?: string[] | undefined;
164
+ }>;
165
+ type UserReportPreferencesQueryDTO = z.infer<typeof UserReportPreferencesQuerySchema>;
166
+ declare const toUserReportsPreferencesPayload: (data: UserReportsPreferences) => UserReportPreferencesDTO;
167
+ declare const newUserReportsPreferencesPayload: () => UserReportPreferencesDTO;
168
+ declare const findUserReportsPreferences: (data: UserReportPreferencesQueryDTO) => Promise<FBR<UserReportsPreferences[]>>;
169
+ declare const createUserReportsPreferences: (data: UserReportPreferencesDTO) => Promise<SBR>;
170
+ declare const updateUserReportsPreferences: (id: string, data: UserReportPreferencesDTO) => Promise<SBR>;
171
+ declare const deleteUserReportsPreferences: (id: string) => Promise<SBR>;
172
+
173
+ export { type UserReportPreferencesDTO, type UserReportPreferencesQueryDTO, UserReportPreferencesQuerySchema, UserReportPreferencesSchema, type UserReportsPreferences, type UserReportsPreferencesVehicleLink, createUserReportsPreferences, deleteUserReportsPreferences, findUserReportsPreferences, newUserReportsPreferencesPayload, toUserReportsPreferencesPayload, updateUserReportsPreferences };
@@ -0,0 +1,346 @@
1
+ // src/core/sdk-config.ts
2
+ var KEY = "__vms_axios_instance__";
3
+ var getAxiosInstance = () => {
4
+ const instance = globalThis[KEY];
5
+ if (!instance) {
6
+ throw new Error("\u274C Axios instance not configured. Call setAxiosInstance() first.");
7
+ }
8
+ return instance;
9
+ };
10
+
11
+ // src/core/apiCall.ts
12
+ var apiPost = async (url, data) => {
13
+ const response = await getAxiosInstance().post(url, data);
14
+ return response.data;
15
+ };
16
+ var apiPatch = async (url, data) => {
17
+ const response = await getAxiosInstance().patch(url, data);
18
+ return response.data;
19
+ };
20
+ var apiDelete = async (url) => {
21
+ const response = await getAxiosInstance().delete(url);
22
+ return response.data;
23
+ };
24
+
25
+ // src/services/gps/features/preferences/user_report_preferences.service.ts
26
+ import { z as z3 } from "zod";
27
+
28
+ // src/zod_utils/zod_utils.ts
29
+ import { z } from "zod";
30
+
31
+ // src/core/BaseResponse.ts
32
+ var r_log = (data = {}) => {
33
+ return data;
34
+ };
35
+
36
+ // src/zod_utils/zod_utils.ts
37
+ var handleNullOrUndefined = (value) => typeof value === "string" ? value : "";
38
+ var stringMandatory = (fieldName, min = 1, max = 100) => {
39
+ const schema = z.string().trim().min(min, `${fieldName} must be at least ${min} characters.`).max(max, `${fieldName} must be at most ${max} characters.`).nonempty(`${fieldName} is required.`).transform(handleNullOrUndefined);
40
+ return schema;
41
+ };
42
+ var stringOptional = (fieldName, min = 0, max = 255, defaultValue = "") => {
43
+ const schema = z.string().trim().min(min, `${fieldName} must be at least ${min} characters.`).max(max, `${fieldName} must be at most ${max} characters.`).transform(handleNullOrUndefined).default(defaultValue);
44
+ return schema;
45
+ };
46
+ var stringArrayOptional = (fieldName, min = 0, max = 100, defaultValue = [], unique = false) => {
47
+ const schema = z.array(z.string().trim(), {
48
+ invalid_type_error: `${fieldName} must be an array of strings.`
49
+ }).min(min, `${fieldName} must contain at least ${min} items.`).max(max, `${fieldName} must contain at most ${max} items.`);
50
+ if (unique) {
51
+ schema.refine(
52
+ (arr) => new Set(arr).size === arr.length,
53
+ `${fieldName} must contain unique values.`
54
+ );
55
+ }
56
+ return schema.optional().default(defaultValue);
57
+ };
58
+ var numberOptional = (fieldName, min = 0, max = 1e9, defaultValue = 0) => {
59
+ return z.preprocess(
60
+ (val) => typeof val === "string" && val.trim() !== "" ? Number(val) : val,
61
+ z.number({ invalid_type_error: `${fieldName} must be a number.` }).min(min, `${fieldName} must be at least ${min}.`).max(max, `${fieldName} must be at most ${max}.`).optional().default(defaultValue)
62
+ );
63
+ };
64
+ var enumMandatory = (fieldName, enumType, defaultValue) => {
65
+ return z.union([
66
+ z.nativeEnum(enumType, {
67
+ invalid_type_error: `${fieldName} should be one of the following values: ${Object.values(
68
+ enumType
69
+ ).join(", ")}.`
70
+ }),
71
+ z.string().refine((val) => Object.values(enumType).includes(val), {
72
+ message: `${fieldName} should be one of the following values: ${Object.values(
73
+ enumType
74
+ ).join(", ")}.`
75
+ })
76
+ ]).default(defaultValue).refine((val) => val !== "", {
77
+ message: `Please select ${fieldName}.`
78
+ });
79
+ };
80
+ var enumOptional = (fieldName, enumType, defaultValue) => {
81
+ return z.nativeEnum(enumType, {
82
+ invalid_type_error: `${fieldName} must be an array containing only the following values: ${Object.values(
83
+ enumType
84
+ ).join(", ")}.`
85
+ }).optional().default(() => defaultValue);
86
+ };
87
+ var handleNullOrUndefinedEnumArray = (value, defaultValue) => Array.isArray(value) ? value : defaultValue;
88
+ var getAllEnums = (enumType) => {
89
+ return Object.values(enumType);
90
+ };
91
+ var enumArrayMandatory = (fieldName, enumType, defaultValue = getAllEnums(enumType), min = 1, max = 100, unique = false) => {
92
+ const schema = z.array(z.nativeEnum(enumType), {
93
+ invalid_type_error: `${fieldName} must be an array containing only the following values: ${Object.values(
94
+ enumType
95
+ ).join(", ")}.`
96
+ }).min(min, `${fieldName} must contain at least ${min} items.`).max(max, `${fieldName} must contain at most ${max} items.`);
97
+ if (unique) {
98
+ schema.refine(
99
+ (arr) => new Set(arr).size === arr.length,
100
+ `${fieldName} must contain unique values.`
101
+ );
102
+ }
103
+ schema.transform((val) => handleNullOrUndefinedEnumArray(val, []));
104
+ return schema.default(() => defaultValue);
105
+ };
106
+ var enumArrayOptional = (fieldName, enumType, defaultValue = getAllEnums(enumType), min = 0, max = 100, unique = false) => {
107
+ const schema = z.array(z.nativeEnum(enumType), {
108
+ invalid_type_error: `${fieldName} must be an array containing only the following values: ${Object.values(
109
+ enumType
110
+ ).join(", ")}.`
111
+ }).min(min, `${fieldName} must contain at least ${min} items.`).max(max, `${fieldName} must contain at most ${max} items.`);
112
+ if (unique) {
113
+ schema.refine(
114
+ (arr) => new Set(arr).size === arr.length,
115
+ `${fieldName} must contain unique values.`
116
+ );
117
+ }
118
+ return schema.optional().default(() => defaultValue);
119
+ };
120
+ var dynamicJsonSchema = (fieldName, defaultValue = {}) => z.record(z.any()).optional().default(() => defaultValue);
121
+ var single_select_mandatory = (fieldName) => {
122
+ const schema = z.string().trim().nonempty(`Please select ${fieldName}.`).transform(handleNullOrUndefined);
123
+ return schema;
124
+ };
125
+ var single_select_optional = (fieldName) => {
126
+ r_log(fieldName);
127
+ const schema = z.string().trim().transform(handleNullOrUndefined);
128
+ return schema;
129
+ };
130
+ var multi_select_optional = (fieldName, max = 1e3, defaultValue = []) => {
131
+ const schema = z.array(
132
+ z.string({
133
+ invalid_type_error: `${fieldName} must be an array of strings.`
134
+ })
135
+ ).max(
136
+ max,
137
+ `Please select at most ${max} ${fieldName}${max > 1 ? "s" : ""}.`
138
+ );
139
+ return schema.optional().default(defaultValue);
140
+ };
141
+
142
+ // src/zod_utils/zod_base_schema.ts
143
+ import { z as z2 } from "zod";
144
+
145
+ // src/core/Enums.ts
146
+ var PAGING = /* @__PURE__ */ ((PAGING2) => {
147
+ PAGING2["Yes"] = "Yes";
148
+ PAGING2["No"] = "No";
149
+ return PAGING2;
150
+ })(PAGING || {});
151
+ var LoadParents = /* @__PURE__ */ ((LoadParents2) => {
152
+ LoadParents2["Yes"] = "Yes";
153
+ LoadParents2["No"] = "No";
154
+ LoadParents2["Custom"] = "Custom";
155
+ return LoadParents2;
156
+ })(LoadParents || {});
157
+ var LoadChild = /* @__PURE__ */ ((LoadChild2) => {
158
+ LoadChild2["No"] = "No";
159
+ LoadChild2["Yes"] = "Yes";
160
+ LoadChild2["Count"] = "Count";
161
+ LoadChild2["Custom"] = "Custom";
162
+ LoadChild2["Direct"] = "Direct";
163
+ return LoadChild2;
164
+ })(LoadChild || {});
165
+ var LoadChildCount = /* @__PURE__ */ ((LoadChildCount2) => {
166
+ LoadChildCount2["No"] = "No";
167
+ LoadChildCount2["Yes"] = "Yes";
168
+ LoadChildCount2["Custom"] = "Custom";
169
+ return LoadChildCount2;
170
+ })(LoadChildCount || {});
171
+ var OrderBy = /* @__PURE__ */ ((OrderBy2) => {
172
+ OrderBy2["asc"] = "asc";
173
+ OrderBy2["desc"] = "desc";
174
+ return OrderBy2;
175
+ })(OrderBy || {});
176
+ var LoginFrom = /* @__PURE__ */ ((LoginFrom2) => {
177
+ LoginFrom2["Web"] = "Web";
178
+ LoginFrom2["Android"] = "Android";
179
+ LoginFrom2["IPhone"] = "IPhone";
180
+ return LoginFrom2;
181
+ })(LoginFrom || {});
182
+ var Status = /* @__PURE__ */ ((Status2) => {
183
+ Status2["Active"] = "Active";
184
+ Status2["Inactive"] = "Inactive";
185
+ return Status2;
186
+ })(Status || {});
187
+ var FileType = /* @__PURE__ */ ((FileType2) => {
188
+ FileType2["NoFile"] = "NoFile";
189
+ FileType2["Image"] = "Image";
190
+ FileType2["Video"] = "Video";
191
+ FileType2["PDF"] = "PDF";
192
+ return FileType2;
193
+ })(FileType || {});
194
+ var YesNo = /* @__PURE__ */ ((YesNo2) => {
195
+ YesNo2["Yes"] = "Yes";
196
+ YesNo2["No"] = "No";
197
+ return YesNo2;
198
+ })(YesNo || {});
199
+ var ReportPreference = /* @__PURE__ */ ((ReportPreference2) => {
200
+ ReportPreference2["FleetFuelRefillReport"] = "FleetFuelRefillReport";
201
+ ReportPreference2["FleetFuelRemovalReport"] = "FleetFuelRemovalReport";
202
+ ReportPreference2["FleetFuelConsumptionReport"] = "FleetFuelConsumptionReport";
203
+ return ReportPreference2;
204
+ })(ReportPreference || {});
205
+ var ReportType = /* @__PURE__ */ ((ReportType2) => {
206
+ ReportType2["Daily"] = "Daily";
207
+ ReportType2["Weekly"] = "Weekly";
208
+ ReportType2["Monthly"] = "Monthly";
209
+ return ReportType2;
210
+ })(ReportType || {});
211
+
212
+ // src/zod_utils/zod_base_schema.ts
213
+ var OrderBySchema = z2.array(
214
+ z2.object({
215
+ name: stringMandatory("Order Field Name", 0, 255),
216
+ field: stringMandatory("Order Field Name", 0, 255),
217
+ direction: enumMandatory("Order Direction", OrderBy, "asc" /* asc */)
218
+ })
219
+ );
220
+ var BaseQuerySchema = z2.object({
221
+ search: stringOptional("Search", 0, 255, ""),
222
+ status: enumArrayOptional("Status", Status, getAllEnums(Status), 0, 10, true),
223
+ paging: enumOptional("Paging", PAGING, "Yes" /* Yes */),
224
+ page_count: numberOptional("Page Count", 0, 1e3, 100),
225
+ page_index: numberOptional("Page Index", 0, 1e3, 0),
226
+ load_parents: enumOptional("Load Parents", LoadParents, "No" /* No */),
227
+ load_parents_list: stringArrayOptional("Load Parents List"),
228
+ load_child: enumOptional("Load Child", LoadChild, "No" /* No */),
229
+ load_child_list: stringArrayOptional("Load Child List"),
230
+ load_child_count: enumOptional(
231
+ "Load Child",
232
+ LoadChildCount,
233
+ "No" /* No */
234
+ ),
235
+ load_child_count_list: stringArrayOptional("Load Child List"),
236
+ include_details: dynamicJsonSchema("Include Details", {}),
237
+ where_relations: dynamicJsonSchema("Where Relations", {}),
238
+ order_by: OrderBySchema.optional().default([]),
239
+ include_master_data: enumOptional("Include Master Data", YesNo, "No" /* No */),
240
+ date_format_id: single_select_optional("MasterMainDateFormat"),
241
+ time_zone_id: single_select_optional("MasterMainTimeZone")
242
+ });
243
+ var FilePresignedUrlSchema = z2.object({
244
+ file_name: stringMandatory("File Name", 1, 255),
245
+ file_type: enumMandatory("File Type", FileType, "Image" /* Image */)
246
+ });
247
+ var MongoBaseQuerySchema = z2.object({
248
+ search: stringOptional("Search", 0, 255, ""),
249
+ paging: enumOptional("Paging", PAGING, "Yes" /* Yes */),
250
+ page_count: numberOptional("Page Count", 0, 1e3, 100),
251
+ page_index: numberOptional("Page Index", 0, 1e3, 0),
252
+ login_from: enumMandatory("Login From", LoginFrom, "Web" /* Web */),
253
+ date_format_id: single_select_optional("MasterMainDateFormat"),
254
+ // ✅ Single-selection -> MasterMainDateFormat
255
+ time_zone_id: single_select_optional("MasterMainTimeZone")
256
+ // ✅ Single-selection -> MasterMainTimeZone
257
+ });
258
+
259
+ // src/services/gps/features/preferences/user_report_preferences.service.ts
260
+ var URL = "gps/features/user_report_preferences";
261
+ var ENDPOINTS = {
262
+ find: `${URL}/search`,
263
+ create: URL,
264
+ update: (id) => `${URL}/${id}`,
265
+ delete: (id) => `${URL}/${id}`
266
+ };
267
+ var UserReportPreferencesSchema = z3.object({
268
+ organisation_id: single_select_mandatory("UserOrganisation"),
269
+ report_name: stringMandatory("Report Name", 3, 100),
270
+ report_status: enumMandatory("Report Status", YesNo, "No" /* No */),
271
+ report_type: enumMandatory("Report Type", ReportType, "Daily" /* Daily */),
272
+ email_ids: stringMandatory("Email IDs", 3, 300),
273
+ cc_email_ids: stringOptional("CC email IDs", 0, 300),
274
+ is_all_vehicles: enumMandatory("Is All Vehicles", YesNo, "No" /* No */),
275
+ report_list: enumArrayMandatory(
276
+ "Report List",
277
+ ReportPreference,
278
+ getAllEnums(ReportPreference)
279
+ ),
280
+ status: enumMandatory("Status", Status, "Active" /* Active */),
281
+ vehicle_ids: multi_select_optional("MasterVehicle")
282
+ // Multi selection -> MasterVehicle
283
+ });
284
+ var UserReportPreferencesQuerySchema = BaseQuerySchema.extend({
285
+ organisation_ids: multi_select_optional("UserOrganisation"),
286
+ // ✅ Multi-Selection -> UserOrganisation
287
+ report_preference_ids: multi_select_optional("UserReportPreferences"),
288
+ // ✅ Multi-Selection -> UserNotificationPreferences
289
+ report_status: enumArrayOptional("Report Status", YesNo, getAllEnums(YesNo)),
290
+ report_type: enumArrayOptional(
291
+ "Report Type",
292
+ ReportType,
293
+ getAllEnums(ReportType)
294
+ ),
295
+ is_all_vehicles: enumArrayOptional(
296
+ "Is All Vehicles",
297
+ YesNo,
298
+ getAllEnums(YesNo)
299
+ )
300
+ });
301
+ var toUserReportsPreferencesPayload = (data) => ({
302
+ organisation_id: data.organisation_id,
303
+ report_name: data.report_name,
304
+ report_status: data.report_status,
305
+ report_type: data.report_type,
306
+ email_ids: data.email_ids,
307
+ cc_email_ids: data.report_name,
308
+ is_all_vehicles: data.is_all_vehicles,
309
+ report_list: data.report_list,
310
+ vehicle_ids: data.UserReportsPreferencesVehicleLink?.map((v) => v.vehicle_id) ?? [],
311
+ status: "Active" /* Active */
312
+ });
313
+ var newUserReportsPreferencesPayload = () => ({
314
+ organisation_id: "",
315
+ report_name: "",
316
+ report_status: "Yes" /* Yes */,
317
+ report_type: "Daily" /* Daily */,
318
+ email_ids: "",
319
+ cc_email_ids: "",
320
+ is_all_vehicles: "Yes" /* Yes */,
321
+ report_list: [],
322
+ vehicle_ids: [],
323
+ status: "Active" /* Active */
324
+ });
325
+ var findUserReportsPreferences = async (data) => {
326
+ return apiPost(ENDPOINTS.find, data);
327
+ };
328
+ var createUserReportsPreferences = async (data) => {
329
+ return apiPost(ENDPOINTS.create, data);
330
+ };
331
+ var updateUserReportsPreferences = async (id, data) => {
332
+ return apiPatch(ENDPOINTS.update(id), data);
333
+ };
334
+ var deleteUserReportsPreferences = async (id) => {
335
+ return apiDelete(ENDPOINTS.delete(id));
336
+ };
337
+ export {
338
+ UserReportPreferencesQuerySchema,
339
+ UserReportPreferencesSchema,
340
+ createUserReportsPreferences,
341
+ deleteUserReportsPreferences,
342
+ findUserReportsPreferences,
343
+ newUserReportsPreferencesPayload,
344
+ toUserReportsPreferencesPayload,
345
+ updateUserReportsPreferences
346
+ };