vms-nest-api-document 17.0.0 → 18.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,354 @@
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/gps_lock_relay_log_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 = 1e14, 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 getAllEnums = (enumType) => {
88
+ return Object.values(enumType);
89
+ };
90
+ var enumArrayOptional = (fieldName, enumType, defaultValue = getAllEnums(enumType), min = 0, max = 100, unique = false) => {
91
+ const schema = z.array(z.nativeEnum(enumType), {
92
+ invalid_type_error: `${fieldName} must be an array containing only the following values: ${Object.values(
93
+ enumType
94
+ ).join(", ")}.`
95
+ }).min(min, `${fieldName} must contain at least ${min} items.`).max(max, `${fieldName} must contain at most ${max} items.`);
96
+ if (unique) {
97
+ schema.refine(
98
+ (arr) => new Set(arr).size === arr.length,
99
+ `${fieldName} must contain unique values.`
100
+ );
101
+ }
102
+ return schema.optional().default(() => defaultValue);
103
+ };
104
+ var dynamicJsonSchema = (fieldName, defaultValue = {}) => z.record(z.any()).optional().default(() => defaultValue);
105
+ var single_select_optional = (fieldName) => {
106
+ r_log(fieldName);
107
+ const schema = z.string().trim().transform(handleNullOrUndefined);
108
+ return schema;
109
+ };
110
+ var multi_select_mandatory = (fieldName, min = 1, max = 100, defaultValue = []) => {
111
+ const schema = z.array(
112
+ z.string({
113
+ invalid_type_error: `${fieldName} must be an array of strings.`
114
+ })
115
+ ).min(
116
+ min,
117
+ `Please select at least ${min} ${fieldName}${min > 1 ? "s" : ""}.`
118
+ ).max(
119
+ max,
120
+ `Please select at most ${max} ${fieldName}${max > 1 ? "s" : ""}.`
121
+ );
122
+ return schema.optional().default(defaultValue);
123
+ };
124
+ var multi_select_optional = (fieldName, max = 1e3, defaultValue = []) => {
125
+ const schema = z.array(
126
+ z.string({
127
+ invalid_type_error: `${fieldName} must be an array of strings.`
128
+ })
129
+ ).max(
130
+ max,
131
+ `Please select at most ${max} ${fieldName}${max > 1 ? "s" : ""}.`
132
+ );
133
+ return schema.optional().default(defaultValue);
134
+ };
135
+
136
+ // src/zod_utils/zod_base_schema.ts
137
+ import { z as z2 } from "zod";
138
+
139
+ // src/core/Enums.ts
140
+ var PAGING = /* @__PURE__ */ ((PAGING2) => {
141
+ PAGING2["Yes"] = "Yes";
142
+ PAGING2["No"] = "No";
143
+ return PAGING2;
144
+ })(PAGING || {});
145
+ var LoadParents = /* @__PURE__ */ ((LoadParents2) => {
146
+ LoadParents2["Yes"] = "Yes";
147
+ LoadParents2["No"] = "No";
148
+ LoadParents2["Custom"] = "Custom";
149
+ return LoadParents2;
150
+ })(LoadParents || {});
151
+ var LoadChild = /* @__PURE__ */ ((LoadChild2) => {
152
+ LoadChild2["No"] = "No";
153
+ LoadChild2["Yes"] = "Yes";
154
+ LoadChild2["Count"] = "Count";
155
+ LoadChild2["Custom"] = "Custom";
156
+ LoadChild2["Direct"] = "Direct";
157
+ return LoadChild2;
158
+ })(LoadChild || {});
159
+ var LoadChildCount = /* @__PURE__ */ ((LoadChildCount2) => {
160
+ LoadChildCount2["No"] = "No";
161
+ LoadChildCount2["Yes"] = "Yes";
162
+ LoadChildCount2["Custom"] = "Custom";
163
+ return LoadChildCount2;
164
+ })(LoadChildCount || {});
165
+ var OrderBy = /* @__PURE__ */ ((OrderBy2) => {
166
+ OrderBy2["asc"] = "asc";
167
+ OrderBy2["desc"] = "desc";
168
+ return OrderBy2;
169
+ })(OrderBy || {});
170
+ var LoginFrom = /* @__PURE__ */ ((LoginFrom2) => {
171
+ LoginFrom2["Web"] = "Web";
172
+ LoginFrom2["Android"] = "Android";
173
+ LoginFrom2["IPhone"] = "IPhone";
174
+ LoginFrom2["AndroidPWA"] = "AndroidPWA";
175
+ LoginFrom2["iOSPWA"] = "iOSPWA";
176
+ return LoginFrom2;
177
+ })(LoginFrom || {});
178
+ var Status = /* @__PURE__ */ ((Status2) => {
179
+ Status2["Active"] = "Active";
180
+ Status2["Inactive"] = "Inactive";
181
+ return Status2;
182
+ })(Status || {});
183
+ var FileType = /* @__PURE__ */ ((FileType2) => {
184
+ FileType2["NoFile"] = "NoFile";
185
+ FileType2["Image"] = "Image";
186
+ FileType2["Video"] = "Video";
187
+ FileType2["PDF"] = "PDF";
188
+ FileType2["Excel"] = "Excel";
189
+ return FileType2;
190
+ })(FileType || {});
191
+ var YesNo = /* @__PURE__ */ ((YesNo2) => {
192
+ YesNo2["Yes"] = "Yes";
193
+ YesNo2["No"] = "No";
194
+ return YesNo2;
195
+ })(YesNo || {});
196
+ var RequestType = /* @__PURE__ */ ((RequestType2) => {
197
+ RequestType2["Lock"] = "Lock";
198
+ RequestType2["Unlock"] = "Unlock";
199
+ return RequestType2;
200
+ })(RequestType || {});
201
+
202
+ // src/zod_utils/zod_base_schema.ts
203
+ var OrderBySchema = z2.array(
204
+ z2.object({
205
+ name: stringMandatory("Order Field Name", 0, 255),
206
+ field: stringMandatory("Order Field Name", 0, 255),
207
+ direction: enumMandatory("Order Direction", OrderBy, "asc" /* asc */)
208
+ })
209
+ );
210
+ var BaseFileSchema = z2.object({
211
+ usage_type: stringMandatory("Usage Type", 3, 100),
212
+ file_type: enumMandatory("File Type", FileType, "Image" /* Image */),
213
+ file_url: stringOptional("File URL", 0, 300),
214
+ file_key: stringOptional("File Key", 0, 300),
215
+ file_name: stringOptional("File Name", 0, 300),
216
+ file_description: stringOptional("File Description", 0, 2e3),
217
+ file_size: numberOptional("File Size"),
218
+ file_metadata: dynamicJsonSchema("File Metadata", {}),
219
+ status: enumMandatory("Status", Status, "Active" /* Active */)
220
+ });
221
+ var BaseQuerySchema = z2.object({
222
+ search: stringOptional("Search", 0, 255, ""),
223
+ status: enumArrayOptional("Status", Status, getAllEnums(Status), 0, 10, true),
224
+ paging: enumOptional("Paging", PAGING, "Yes" /* Yes */),
225
+ page_count: numberOptional("Page Count", 0, 1e3, 100),
226
+ page_index: numberOptional("Page Index", 0, 1e3, 0),
227
+ load_parents: enumOptional("Load Parents", LoadParents, "No" /* No */),
228
+ load_parents_list: stringArrayOptional("Load Parents List"),
229
+ load_child: enumOptional("Load Child", LoadChild, "No" /* No */),
230
+ load_child_list: stringArrayOptional("Load Child List"),
231
+ load_child_count: enumOptional(
232
+ "Load Child",
233
+ LoadChildCount,
234
+ "No" /* No */
235
+ ),
236
+ load_child_count_list: stringArrayOptional("Load Child List"),
237
+ include_details: dynamicJsonSchema("Include Details", {}),
238
+ where_relations: dynamicJsonSchema("Where Relations", {}),
239
+ order_by: OrderBySchema.optional().default([]),
240
+ include_master_data: enumOptional("Include Master Data", YesNo, "No" /* No */),
241
+ date_format_id: single_select_optional("MasterMainDateFormat"),
242
+ time_zone_id: single_select_optional("MasterMainTimeZone")
243
+ });
244
+ var FilePresignedUrlSchema = z2.object({
245
+ file_name: stringMandatory("File Name", 1, 255),
246
+ file_type: enumMandatory("File Type", FileType, "Image" /* Image */)
247
+ });
248
+ var MongoBaseQuerySchema = z2.object({
249
+ search: stringOptional("Search", 0, 255, ""),
250
+ paging: enumOptional("Paging", PAGING, "Yes" /* Yes */),
251
+ page_count: numberOptional("Page Count", 0, 1e3, 100),
252
+ page_index: numberOptional("Page Index", 0, 1e3, 0),
253
+ login_from: enumMandatory("Login From", LoginFrom, "Web" /* Web */),
254
+ date_format_id: single_select_optional("MasterMainDateFormat"),
255
+ // ✅ Single-selection -> MasterMainDateFormat
256
+ time_zone_id: single_select_optional("MasterMainTimeZone")
257
+ // ✅ Single-selection -> MasterMainTimeZone
258
+ });
259
+
260
+ // src/services/gps/features/gps_lock_relay_log_service.ts
261
+ var URL = "gps/features/gps_lock_relay_log";
262
+ var ENDPOINTS = {
263
+ // GPSLockRelayLog APIs
264
+ find: `${URL}/search`,
265
+ create: URL,
266
+ update: (id) => `${URL}/${id}`,
267
+ delete: (id) => `${URL}/${id}`
268
+ };
269
+ var GPSLockRelayLogSchema = z3.object({
270
+ // Relations - Parent
271
+ organisation_id: stringMandatory("Organisation"),
272
+ user_id: stringOptional("User"),
273
+ vehicle_id: stringMandatory("Master Vehicle"),
274
+ driver_id: stringOptional("Master Driver"),
275
+ // Main Field Details
276
+ request_type: enumMandatory(
277
+ "Request Type",
278
+ RequestType,
279
+ "Unlock" /* Unlock */
280
+ ),
281
+ command: stringOptional("Command", 0, 150),
282
+ is_success: enumMandatory("Is Success", YesNo, "No" /* No */),
283
+ response: stringOptional("Response", 0, 1e3),
284
+ // Metadata
285
+ status: enumMandatory("Status", Status, "Active" /* Active */)
286
+ });
287
+ var GPSLockRelayLogQuerySchema = BaseQuerySchema.extend({
288
+ // Self Table
289
+ gps_lock_relay_log_ids: multi_select_optional("GPSLockRelayLog"),
290
+ // Multi-Selection -> GPSLockRelayLog
291
+ // Relations - Parent
292
+ organisation_ids: multi_select_mandatory("UserOrganisation"),
293
+ // Multi-Selection -> UserOrganisation
294
+ user_ids: multi_select_optional("User"),
295
+ // Multi-Selection -> User
296
+ vehicle_ids: multi_select_mandatory("MasterVehicle"),
297
+ // Multi-Selection -> MasterVehicle
298
+ driver_ids: multi_select_optional("MasterDriver"),
299
+ // Multi-Selection -> MasterDriver
300
+ // Main Field Details
301
+ request_type: enumArrayOptional(
302
+ "Request Type",
303
+ RequestType,
304
+ getAllEnums(RequestType)
305
+ ),
306
+ is_success: enumArrayOptional("Is Success", YesNo, getAllEnums(YesNo))
307
+ });
308
+ var toGPSLockRelayLogPayload = (row) => ({
309
+ organisation_id: row.organisation_id || "",
310
+ user_id: row.user_id || "",
311
+ vehicle_id: row.vehicle_id || "",
312
+ driver_id: row.driver_id || "",
313
+ request_type: row.request_type || "Unlock" /* Unlock */,
314
+ command: row.command || "",
315
+ is_success: row.is_success || "No" /* No */,
316
+ response: row.response || "",
317
+ status: row.status || "Active" /* Active */
318
+ });
319
+ var newGPSLockRelayLogPayload = () => ({
320
+ organisation_id: "",
321
+ user_id: "",
322
+ vehicle_id: "",
323
+ driver_id: "",
324
+ request_type: "Unlock" /* Unlock */,
325
+ command: "",
326
+ is_success: "No" /* No */,
327
+ response: "",
328
+ status: "Active" /* Active */
329
+ });
330
+ var findGPSLockRelayLogs = async (data) => {
331
+ return apiPost(
332
+ ENDPOINTS.find,
333
+ data
334
+ );
335
+ };
336
+ var createGPSLockRelayLog = async (data) => {
337
+ return apiPost(ENDPOINTS.create, data);
338
+ };
339
+ var updateGPSLockRelayLog = async (id, data) => {
340
+ return apiPatch(ENDPOINTS.update(id), data);
341
+ };
342
+ var deleteGPSLockRelayLog = async (id) => {
343
+ return apiDelete(ENDPOINTS.delete(id));
344
+ };
345
+ export {
346
+ GPSLockRelayLogQuerySchema,
347
+ GPSLockRelayLogSchema,
348
+ createGPSLockRelayLog,
349
+ deleteGPSLockRelayLog,
350
+ findGPSLockRelayLogs,
351
+ newGPSLockRelayLogPayload,
352
+ toGPSLockRelayLogPayload,
353
+ updateGPSLockRelayLog
354
+ };
@@ -31,7 +31,6 @@ declare const ContactUsDetailSchema: z.ZodObject<{
31
31
  telegram_chat_url: z.ZodDefault<z.ZodEffects<z.ZodString, string, string>>;
32
32
  status: z.ZodType<Status, z.ZodTypeDef, Status>;
33
33
  }, "strip", z.ZodTypeAny, {
34
- status: Status;
35
34
  mobile_number: string;
36
35
  email: string;
37
36
  facebook_link: string;
@@ -42,6 +41,7 @@ declare const ContactUsDetailSchema: z.ZodObject<{
42
41
  pinterest_link: string;
43
42
  whats_app_chat_url: string;
44
43
  telegram_chat_url: string;
44
+ status: Status;
45
45
  }, {
46
46
  status: Status;
47
47
  mobile_number?: string | undefined;
@@ -17,10 +17,10 @@ declare const FaqSchema: z.ZodObject<{
17
17
  faq_content: z.ZodDefault<z.ZodEffects<z.ZodString, string, string>>;
18
18
  status: z.ZodType<Status, z.ZodTypeDef, Status>;
19
19
  }, "strip", z.ZodTypeAny, {
20
+ status: Status;
20
21
  faq_section: string;
21
22
  faq_header: string;
22
23
  faq_content: string;
23
- status: Status;
24
24
  }, {
25
25
  status: Status;
26
26
  faq_section?: string | undefined;
@@ -25,10 +25,10 @@ declare const RequestDemoSchema: z.ZodObject<{
25
25
  admin_view: z.ZodType<YesNo, z.ZodTypeDef, YesNo>;
26
26
  status: z.ZodType<Status, z.ZodTypeDef, Status>;
27
27
  }, "strip", z.ZodTypeAny, {
28
+ email: string;
28
29
  status: Status;
29
30
  message: string;
30
31
  name: string;
31
- email: string;
32
32
  mobile: string;
33
33
  admin_message: string;
34
34
  city: string;
@@ -37,8 +37,8 @@ declare const RequestDemoSchema: z.ZodObject<{
37
37
  status: Status;
38
38
  name: string;
39
39
  admin_view: YesNo;
40
- message?: string | undefined;
41
40
  email?: string | undefined;
41
+ message?: string | undefined;
42
42
  mobile?: string | undefined;
43
43
  admin_message?: string | undefined;
44
44
  city?: string | undefined;
@@ -134,15 +134,15 @@ declare const RequestDemoCreateSchema: z.ZodObject<{
134
134
  message: z.ZodDefault<z.ZodEffects<z.ZodString, string, string>>;
135
135
  city: z.ZodDefault<z.ZodEffects<z.ZodString, string, string>>;
136
136
  }, "strip", z.ZodTypeAny, {
137
+ email: string;
137
138
  message: string;
138
139
  name: string;
139
- email: string;
140
140
  mobile: string;
141
141
  city: string;
142
142
  }, {
143
143
  name: string;
144
- message?: string | undefined;
145
144
  email?: string | undefined;
145
+ message?: string | undefined;
146
146
  mobile?: string | undefined;
147
147
  city?: string | undefined;
148
148
  }>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vms-nest-api-document",
3
- "version": "17.0.0",
3
+ "version": "18.0.0",
4
4
  "description": "Reusable API SDK built with NestJS, Prisma, Axios, and Zod for VMS frontends.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",