@vulog/aima-user 1.2.30 → 1.2.32
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 +483 -0
- package/dist/index.d.cts +327 -0
- package/dist/index.d.mts +222 -200
- package/dist/index.mjs +411 -570
- package/package.json +21 -8
- package/{tsup.config.ts → tsdown.config.ts} +1 -1
- package/dist/index.d.ts +0 -305
- package/dist/index.js +0 -668
- /package/{.eslintrc.js → .eslintrc.cjs} +0 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,483 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let zod = require("zod");
|
|
3
|
+
let _vulog_aima_core = require("@vulog/aima-core");
|
|
4
|
+
//#region src/acceptTAndC.ts
|
|
5
|
+
const schema$7 = zod.z.object({
|
|
6
|
+
userId: zod.z.string().uuid(),
|
|
7
|
+
cityId: zod.z.string().uuid()
|
|
8
|
+
});
|
|
9
|
+
const acceptTAndC = async (client, userId, cityId) => {
|
|
10
|
+
const result = schema$7.safeParse({
|
|
11
|
+
userId,
|
|
12
|
+
cityId
|
|
13
|
+
});
|
|
14
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
15
|
+
await client.post(`boapi/proxy/user/fleets/${client.clientOptions.fleetId}/cities/${cityId}/users/${userId}/agreements`);
|
|
16
|
+
};
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region src/assignBillingGroup.ts
|
|
19
|
+
const schema$6 = zod.z.object({
|
|
20
|
+
entityId: zod.z.string().trim().min(1).uuid(),
|
|
21
|
+
billingGroupId: zod.z.string().trim().min(1).uuid()
|
|
22
|
+
});
|
|
23
|
+
const assignBillingGroup = async (client, entityId, billingGroupId) => {
|
|
24
|
+
const result = schema$6.safeParse({
|
|
25
|
+
entityId,
|
|
26
|
+
billingGroupId
|
|
27
|
+
});
|
|
28
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
29
|
+
await client.post(`/boapi/proxy/user/fleets/${client.clientOptions.fleetId}/billingGroup/${result.data.billingGroupId}/entities/${result.data.entityId}`);
|
|
30
|
+
};
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/unassignBillingGroup.ts
|
|
33
|
+
const schema$5 = zod.z.object({
|
|
34
|
+
entityId: zod.z.string().trim().min(1).uuid(),
|
|
35
|
+
billingGroupId: zod.z.string().trim().min(1).uuid()
|
|
36
|
+
});
|
|
37
|
+
const unassignBillingGroup = async (client, entityId, billingGroupId) => {
|
|
38
|
+
const result = schema$5.safeParse({
|
|
39
|
+
entityId,
|
|
40
|
+
billingGroupId
|
|
41
|
+
});
|
|
42
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
43
|
+
await client.delete(`/boapi/proxy/user/fleets/${client.clientOptions.fleetId}/billingGroup/${billingGroupId}/entities/${entityId}`);
|
|
44
|
+
};
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region src/createBusinessProfile.ts
|
|
47
|
+
const createBusinessProfileSchema = zod.z.object({
|
|
48
|
+
userId: zod.z.string().nonempty().uuid(),
|
|
49
|
+
businessId: zod.z.string().nonempty().uuid(),
|
|
50
|
+
data: zod.z.object({
|
|
51
|
+
emailConsent: zod.z.boolean(),
|
|
52
|
+
email: zod.z.string().email(),
|
|
53
|
+
requestId: zod.z.string().nonempty().uuid(),
|
|
54
|
+
costCenterId: zod.z.string().uuid().nullish()
|
|
55
|
+
})
|
|
56
|
+
});
|
|
57
|
+
const createBusinessProfile = async (client, userId, businessId, data) => {
|
|
58
|
+
const result = createBusinessProfileSchema.safeParse({
|
|
59
|
+
userId,
|
|
60
|
+
businessId,
|
|
61
|
+
data
|
|
62
|
+
});
|
|
63
|
+
if (!result.success) throw new TypeError("Invalid argd", { cause: result.error.issues });
|
|
64
|
+
return client.post(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/business/${businessId}/user/${userId}`, result.data).then(({ data: p }) => p);
|
|
65
|
+
};
|
|
66
|
+
//#endregion
|
|
67
|
+
//#region src/createUser.ts
|
|
68
|
+
const createUserSchema = zod.z.object({
|
|
69
|
+
userName: zod.z.string().min(1),
|
|
70
|
+
password: zod.z.string().min(1),
|
|
71
|
+
locale: zod.z.string().length(5),
|
|
72
|
+
email: zod.z.string().min(1).email(),
|
|
73
|
+
dataPrivacyConsent: zod.z.boolean().optional(),
|
|
74
|
+
profilingConsent: zod.z.boolean().optional(),
|
|
75
|
+
marketingConsent: zod.z.boolean().optional(),
|
|
76
|
+
phoneNumber: zod.z.string().optional()
|
|
77
|
+
});
|
|
78
|
+
const createUserOptionsSchema = zod.z.object({
|
|
79
|
+
tcApproval: zod.z.boolean().default(true),
|
|
80
|
+
skipUserNotification: zod.z.boolean().default(false)
|
|
81
|
+
}).default({
|
|
82
|
+
tcApproval: true,
|
|
83
|
+
skipUserNotification: false
|
|
84
|
+
});
|
|
85
|
+
const createUser = async (client, user, option) => {
|
|
86
|
+
const resultUser = createUserSchema.safeParse(user);
|
|
87
|
+
if (!resultUser.success) throw new TypeError("Invalid user", { cause: resultUser.error.issues });
|
|
88
|
+
const resultOptions = createUserOptionsSchema.safeParse(option);
|
|
89
|
+
if (!resultOptions.success) throw new TypeError("Invalid options", { cause: resultOptions.error.issues });
|
|
90
|
+
const searchParams = new URLSearchParams();
|
|
91
|
+
searchParams.append("tcApproval", resultOptions.data.tcApproval.toString());
|
|
92
|
+
searchParams.append("skipUserNotification", resultOptions.data.skipUserNotification.toString());
|
|
93
|
+
return client.post(`/boapi/proxy/user/fleets/${client.clientOptions.fleetId}/userDefault?${searchParams.toString()}`, resultUser.data).then(({ data }) => data);
|
|
94
|
+
};
|
|
95
|
+
//#endregion
|
|
96
|
+
//#region src/types.ts
|
|
97
|
+
const accountStatus = [
|
|
98
|
+
"INCOMPLETE",
|
|
99
|
+
"PENDING",
|
|
100
|
+
"APPROVED",
|
|
101
|
+
"REJECTED",
|
|
102
|
+
"SUSPENDED",
|
|
103
|
+
"ARCHIVED"
|
|
104
|
+
];
|
|
105
|
+
const personalInformationUserTypes = [
|
|
106
|
+
"IDENTITY",
|
|
107
|
+
"USERNAME",
|
|
108
|
+
"BIRTH",
|
|
109
|
+
"NATIONALITY",
|
|
110
|
+
"NOTES",
|
|
111
|
+
"GENDER",
|
|
112
|
+
"PERSONAL_COMPANY",
|
|
113
|
+
"FISCAL",
|
|
114
|
+
"ADDRESS",
|
|
115
|
+
"MEMBERSHIP"
|
|
116
|
+
];
|
|
117
|
+
const personalInformationUserPaths = [
|
|
118
|
+
"/identity/firstName",
|
|
119
|
+
"/identity/lastName",
|
|
120
|
+
"/identity/middleName",
|
|
121
|
+
"/identity/preferredName",
|
|
122
|
+
"/birth/birthDate",
|
|
123
|
+
"/birth/countryBirth",
|
|
124
|
+
"/birth/provinceBirth",
|
|
125
|
+
"/birth/cityBirth",
|
|
126
|
+
"/nationality",
|
|
127
|
+
"/notes",
|
|
128
|
+
"/gender",
|
|
129
|
+
"/personalCompany/companyName",
|
|
130
|
+
"/personalCompany/companyVat",
|
|
131
|
+
"/personalCompany/companyAddress/streetName",
|
|
132
|
+
"/personalCompany/companyAddress/city",
|
|
133
|
+
"/personalCompany/companyAddress/postalCode",
|
|
134
|
+
"/personalCompany/companyAddress/region",
|
|
135
|
+
"/personalCompany/companyAddress/country",
|
|
136
|
+
"/personalCompany/companyAddress/number",
|
|
137
|
+
"/personalCompany/companyAddress/addressAdditionalInformation",
|
|
138
|
+
"/fiscalInformation/fiscal",
|
|
139
|
+
"/fiscalInformation/personalVatNumber",
|
|
140
|
+
"/fiscalInformation/sdi",
|
|
141
|
+
"/fiscalInformation/pecAddress",
|
|
142
|
+
"/fiscalInformation/marketReference",
|
|
143
|
+
"/address/streetName",
|
|
144
|
+
"/address/city",
|
|
145
|
+
"/address/postalCode",
|
|
146
|
+
"/address/region",
|
|
147
|
+
"/address/country",
|
|
148
|
+
"/address/number",
|
|
149
|
+
"/address/addressAdditionalInformation",
|
|
150
|
+
"/membership"
|
|
151
|
+
];
|
|
152
|
+
const personalInformationUserTypeSchema = zod.z.enum(personalInformationUserTypes);
|
|
153
|
+
const personalInformationProfileTypes = [
|
|
154
|
+
"ID_NUMBER",
|
|
155
|
+
"PHONE_NUMBER",
|
|
156
|
+
"EMAIL",
|
|
157
|
+
"BILLING_ADDRESS"
|
|
158
|
+
];
|
|
159
|
+
const personalInformationProfileTypeSchema = zod.z.enum(personalInformationProfileTypes);
|
|
160
|
+
//#endregion
|
|
161
|
+
//#region src/findUser.ts
|
|
162
|
+
const querySchema = zod.z.object({
|
|
163
|
+
searchType: zod.z.enum([
|
|
164
|
+
"email",
|
|
165
|
+
"username",
|
|
166
|
+
"phoneNumber"
|
|
167
|
+
]),
|
|
168
|
+
searchQuery: zod.z.string().min(1),
|
|
169
|
+
types: zod.z.array(personalInformationUserTypeSchema).min(1)
|
|
170
|
+
});
|
|
171
|
+
const findUser = async (client, searchType, searchQuery, types) => {
|
|
172
|
+
const result = querySchema.safeParse({
|
|
173
|
+
searchType,
|
|
174
|
+
searchQuery,
|
|
175
|
+
types
|
|
176
|
+
});
|
|
177
|
+
if (!result.success) throw new TypeError("Invalid arguments", { cause: result.error.issues });
|
|
178
|
+
return client.post(`/boapi/proxy/user/fleets/${client.clientOptions.fleetId}/users/pi/find?types=${result.data.types.join(",")}`, { [result.data.searchType]: result.data.searchQuery }).then(({ data }) => data);
|
|
179
|
+
};
|
|
180
|
+
//#endregion
|
|
181
|
+
//#region src/getProfilePersonalInfoById.ts
|
|
182
|
+
const argsSchema$3 = zod.z.object({
|
|
183
|
+
userId: zod.z.string().trim().min(1).uuid(),
|
|
184
|
+
profileId: zod.z.string().trim().min(1).uuid(),
|
|
185
|
+
types: zod.z.array(personalInformationProfileTypeSchema).min(1)
|
|
186
|
+
});
|
|
187
|
+
const getProfilePersonalInfoById = async (client, userId, profileId, types) => {
|
|
188
|
+
const result = argsSchema$3.safeParse({
|
|
189
|
+
userId,
|
|
190
|
+
profileId,
|
|
191
|
+
types
|
|
192
|
+
});
|
|
193
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
194
|
+
return client.get(`/boapi/proxy/user/fleets/${client.clientOptions.fleetId}/users/${result.data.userId}/profiles/${result.data.profileId}/pi?types=${result.data.types.join(",")}`).then(({ data }) => data);
|
|
195
|
+
};
|
|
196
|
+
//#endregion
|
|
197
|
+
//#region src/getRegistrationOverview.ts
|
|
198
|
+
const getRegistrationOverview = async (client, userId) => {
|
|
199
|
+
const result = zod.z.string().uuid().safeParse(userId);
|
|
200
|
+
if (!result.success) throw new TypeError("Invalid userId", { cause: result.error.issues });
|
|
201
|
+
return client.get(`boapi/proxy/user/fleets/${client.clientOptions.fleetId}/users/${userId}/services`).then(({ data: { userId: uid, ...data } }) => data);
|
|
202
|
+
};
|
|
203
|
+
//#endregion
|
|
204
|
+
//#region src/getUserById.ts
|
|
205
|
+
const getUserById = async (client, id, addAccountStatus = false) => {
|
|
206
|
+
const result = zod.z.string().trim().min(1).uuid().safeParse(id);
|
|
207
|
+
if (!result.success) throw new TypeError("Invalid id", { cause: result.error.issues });
|
|
208
|
+
const user = await client.get(`/boapi/proxy/user/fleets/${client.clientOptions.fleetId}/users/${id}/status`).then(({ data }) => data);
|
|
209
|
+
if (addAccountStatus) user.accountStatus = await client.get(`/boapi/proxy/user/fleets/${client.clientOptions.fleetId}/users/${id}`).then(({ data: { accountStatus } }) => accountStatus);
|
|
210
|
+
return user;
|
|
211
|
+
};
|
|
212
|
+
//#endregion
|
|
213
|
+
//#region src/getUserPersonalInfoById.ts
|
|
214
|
+
const argsSchema$2 = zod.z.object({
|
|
215
|
+
id: zod.z.string().trim().min(1).uuid(),
|
|
216
|
+
types: zod.z.array(personalInformationUserTypeSchema).min(1)
|
|
217
|
+
});
|
|
218
|
+
const getUserPersonalInfoById = async (client, id, types) => {
|
|
219
|
+
const result = argsSchema$2.safeParse({
|
|
220
|
+
id,
|
|
221
|
+
types
|
|
222
|
+
});
|
|
223
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
224
|
+
return client.get(`/boapi/proxy/user/fleets/${client.clientOptions.fleetId}/users/${result.data.id}/pi?types=${result.data.types.join(",")}`).then(({ data }) => data);
|
|
225
|
+
};
|
|
226
|
+
//#endregion
|
|
227
|
+
//#region src/getUsersPIByIds.ts
|
|
228
|
+
const argsSchema$1 = zod.z.object({
|
|
229
|
+
ids: zod.z.array(zod.z.string().trim().min(1).uuid()).min(1),
|
|
230
|
+
types: zod.z.array(personalInformationUserTypeSchema).min(1)
|
|
231
|
+
});
|
|
232
|
+
const getUsersPIByIds = async (client, ids, types) => {
|
|
233
|
+
const result = argsSchema$1.safeParse({
|
|
234
|
+
ids,
|
|
235
|
+
types
|
|
236
|
+
});
|
|
237
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
238
|
+
return client.post(`/boapi/proxy/user/fleets/${client.clientOptions.fleetId}/users/pi/list?${result.data.types.map((type) => `types=${type}`).join("&")}`, { userIds: result.data.ids }).then(({ data }) => data.content);
|
|
239
|
+
};
|
|
240
|
+
//#endregion
|
|
241
|
+
//#region src/label.ts
|
|
242
|
+
const schema$4 = zod.z.object({ userId: zod.z.string().uuid() });
|
|
243
|
+
const schemaData = zod.z.object({
|
|
244
|
+
userId: zod.z.string().uuid(),
|
|
245
|
+
labelId: zod.z.number().positive()
|
|
246
|
+
});
|
|
247
|
+
const getLabelsForUser = async (client, userId) => {
|
|
248
|
+
const result = schema$4.safeParse({ userId });
|
|
249
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
250
|
+
return client.get(`boapi/proxy/user/fleets/${client.clientOptions.fleetId}/users/${userId}/userLabels`).then(({ data }) => data);
|
|
251
|
+
};
|
|
252
|
+
const addLabelForUser = async (client, userId, labelId) => {
|
|
253
|
+
const result = schemaData.safeParse({
|
|
254
|
+
userId,
|
|
255
|
+
labelId
|
|
256
|
+
});
|
|
257
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
258
|
+
await client.post(`boapi/proxy/user/fleets/${client.clientOptions.fleetId}/users/${userId}/userLabels`, { labelId });
|
|
259
|
+
};
|
|
260
|
+
const removeLabelForUser = async (client, userId, labelId) => {
|
|
261
|
+
const result = schemaData.safeParse({
|
|
262
|
+
userId,
|
|
263
|
+
labelId
|
|
264
|
+
});
|
|
265
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
266
|
+
await client.delete(`boapi/proxy/user/fleets/${client.clientOptions.fleetId}/users/${userId}/userLabels/${labelId}`);
|
|
267
|
+
};
|
|
268
|
+
//#endregion
|
|
269
|
+
//#region src/setServicesStatus.ts
|
|
270
|
+
const schema$3 = zod.z.object({
|
|
271
|
+
disableEmailNotification: zod.z.boolean(),
|
|
272
|
+
operatorProfileId: zod.z.string().uuid(),
|
|
273
|
+
actions: zod.z.array(zod.z.object({
|
|
274
|
+
reasonForChange: zod.z.string(),
|
|
275
|
+
serviceId: zod.z.string().uuid(),
|
|
276
|
+
status: zod.z.enum([
|
|
277
|
+
"APPROVED",
|
|
278
|
+
"INCOMPLETE",
|
|
279
|
+
"PENDING",
|
|
280
|
+
"REJECTED",
|
|
281
|
+
"SUSPENDED",
|
|
282
|
+
"UNREGISTERED"
|
|
283
|
+
])
|
|
284
|
+
})).min(1)
|
|
285
|
+
});
|
|
286
|
+
const setServicesStatus = async (client, profileId, servicesUpdate) => {
|
|
287
|
+
const resultProfileId = zod.z.string().uuid().safeParse(profileId);
|
|
288
|
+
if (!resultProfileId.success) throw new TypeError("Invalid profileId", { cause: resultProfileId.error.issues });
|
|
289
|
+
const resultServices = schema$3.safeParse(servicesUpdate);
|
|
290
|
+
if (!resultServices.success) throw new TypeError("Invalid servicesUpdate", { cause: resultServices.error.issues });
|
|
291
|
+
await client.post(`boapi/proxy/user/fleets/${client.clientOptions.fleetId}/profiles/${profileId}/serviceRegistrations`, servicesUpdate);
|
|
292
|
+
};
|
|
293
|
+
//#endregion
|
|
294
|
+
//#region src/registerUserToService.ts
|
|
295
|
+
const registerUserToService = async (client, entityId, serviceId) => {
|
|
296
|
+
const resultEntityId = zod.z.string().uuid().safeParse(entityId);
|
|
297
|
+
if (!resultEntityId.success) throw new TypeError("Invalid entityId", { cause: resultEntityId.error.issues });
|
|
298
|
+
const resultServiceId = zod.z.string().uuid().safeParse(serviceId);
|
|
299
|
+
if (!resultServiceId.success) throw new TypeError("Invalid serviceId", { cause: resultServiceId.error.issues });
|
|
300
|
+
await client.put(`boapi/proxy/user/fleets/${client.clientOptions.fleetId}/entities/${entityId}/services/${serviceId}`);
|
|
301
|
+
};
|
|
302
|
+
//#endregion
|
|
303
|
+
//#region src/updateProfilePersonalInfo.ts
|
|
304
|
+
const paths = [
|
|
305
|
+
"/phoneNumber",
|
|
306
|
+
"/email",
|
|
307
|
+
"/idNumber"
|
|
308
|
+
];
|
|
309
|
+
const schema$2 = zod.z.object({
|
|
310
|
+
userId: zod.z.string().trim().min(1).uuid(),
|
|
311
|
+
profileId: zod.z.string().trim().min(1).uuid(),
|
|
312
|
+
actions: zod.z.array(zod.z.union([zod.z.object({
|
|
313
|
+
op: zod.z.enum(["add", "replace"]),
|
|
314
|
+
path: zod.z.enum(paths),
|
|
315
|
+
value: zod.z.string().min(1)
|
|
316
|
+
}), zod.z.object({
|
|
317
|
+
op: zod.z.literal("remove"),
|
|
318
|
+
path: zod.z.enum(paths)
|
|
319
|
+
})])).min(1)
|
|
320
|
+
});
|
|
321
|
+
const updateProfilePersonalInfo = async (client, userId, profileId, actions) => {
|
|
322
|
+
const result = schema$2.safeParse({
|
|
323
|
+
userId,
|
|
324
|
+
profileId,
|
|
325
|
+
actions
|
|
326
|
+
});
|
|
327
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
328
|
+
await client.patch(`/boapi/proxy/user/fleets/${client.clientOptions.fleetId}/users/${userId}/profiles/${profileId}/pi`, actions, { headers: { "Content-Type": "application/json-patch+json" } });
|
|
329
|
+
};
|
|
330
|
+
//#endregion
|
|
331
|
+
//#region src/updateUser.ts
|
|
332
|
+
const schema$1 = zod.z.object({
|
|
333
|
+
id: zod.z.string().trim().min(1).uuid(),
|
|
334
|
+
user: zod.z.object({
|
|
335
|
+
locale: zod.z.string(),
|
|
336
|
+
accountStatus: zod.z.enum(accountStatus),
|
|
337
|
+
dataPrivacyConsent: zod.z.boolean(),
|
|
338
|
+
marketingConsent: zod.z.boolean(),
|
|
339
|
+
surveyConsent: zod.z.boolean(),
|
|
340
|
+
shareDataConsent: zod.z.boolean(),
|
|
341
|
+
profilingConsent: zod.z.boolean(),
|
|
342
|
+
membershipNumber: zod.z.string()
|
|
343
|
+
}).partial()
|
|
344
|
+
});
|
|
345
|
+
const updateUser = async (client, id, user) => {
|
|
346
|
+
const result = schema$1.safeParse({
|
|
347
|
+
id,
|
|
348
|
+
user
|
|
349
|
+
});
|
|
350
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
351
|
+
return client.post(`/boapi/proxy/user/fleets/${client.clientOptions.fleetId}/users/${id}`, user).then(({ data }) => data);
|
|
352
|
+
};
|
|
353
|
+
//#endregion
|
|
354
|
+
//#region src/updateUserPersonalInfo.ts
|
|
355
|
+
const schema = zod.z.object({
|
|
356
|
+
userId: zod.z.string().trim().min(1).uuid(),
|
|
357
|
+
actions: zod.z.array(zod.z.union([zod.z.object({
|
|
358
|
+
op: zod.z.enum(["add", "replace"]),
|
|
359
|
+
path: zod.z.enum(personalInformationUserPaths),
|
|
360
|
+
value: zod.z.string().min(1)
|
|
361
|
+
}), zod.z.object({
|
|
362
|
+
op: zod.z.literal("remove"),
|
|
363
|
+
path: zod.z.enum(personalInformationUserPaths)
|
|
364
|
+
})])).min(1)
|
|
365
|
+
});
|
|
366
|
+
const updateUserPersonalInfo = async (client, userId, actions) => {
|
|
367
|
+
const result = schema.safeParse({
|
|
368
|
+
userId,
|
|
369
|
+
actions
|
|
370
|
+
});
|
|
371
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
372
|
+
await client.patch(`/boapi/proxy/user/fleets/${client.clientOptions.fleetId}/users/${userId}/pi`, actions, { headers: { "Content-Type": "application/json-patch+json" } }).then(({ data }) => data);
|
|
373
|
+
};
|
|
374
|
+
//#endregion
|
|
375
|
+
//#region src/getEntity.ts
|
|
376
|
+
const getEntity = async (client, entityId) => {
|
|
377
|
+
const result = zod.z.string().trim().min(1).uuid().safeParse(entityId);
|
|
378
|
+
if (!result.success) throw new TypeError("Invalid entity id", { cause: result.error.issues });
|
|
379
|
+
return await client.get(`/boapi/proxy/user/fleets/${client.clientOptions.fleetId}/entities/${entityId}`).then(({ data }) => data);
|
|
380
|
+
};
|
|
381
|
+
//#endregion
|
|
382
|
+
//#region src/getFleetBillingGroups.ts
|
|
383
|
+
const getFleetBillingGroups = async (client, options) => {
|
|
384
|
+
const resultOptions = (0, _vulog_aima_core.createPaginableOptionsSchema)().default({}).safeParse(options);
|
|
385
|
+
if (!resultOptions.success) throw new TypeError("Invalid options", { cause: resultOptions.error.issues });
|
|
386
|
+
const finalOptions = resultOptions.data;
|
|
387
|
+
const searchParams = new URLSearchParams();
|
|
388
|
+
searchParams.append("page", finalOptions.page.toString());
|
|
389
|
+
searchParams.append("size", finalOptions.pageSize.toString());
|
|
390
|
+
return client.get(`/boapi/proxy/user/fleets/${client.clientOptions.fleetId}/billingGroup?${searchParams.toString()}`).then(({ data, headers }) => {
|
|
391
|
+
return {
|
|
392
|
+
data,
|
|
393
|
+
page: headers.number,
|
|
394
|
+
pageSize: headers.size,
|
|
395
|
+
total: headers.totalelements,
|
|
396
|
+
totalPages: headers.totalpages
|
|
397
|
+
};
|
|
398
|
+
}).catch((error) => {
|
|
399
|
+
throw new Error(`Failed to get fleet billing groups: ${error.message}`);
|
|
400
|
+
});
|
|
401
|
+
};
|
|
402
|
+
//#endregion
|
|
403
|
+
//#region src/getUsersByIds.ts
|
|
404
|
+
const argsSchema = zod.z.object({ ids: zod.z.array(zod.z.string().trim().min(1).uuid()).min(1) });
|
|
405
|
+
const getUsersByIds = async (client, ids) => {
|
|
406
|
+
const result = argsSchema.safeParse({ ids });
|
|
407
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
408
|
+
return client.post(`/boapi/proxy/user/fleets/${client.clientOptions.fleetId}/users/list`, result.data.ids).then(({ data }) => data);
|
|
409
|
+
};
|
|
410
|
+
//#endregion
|
|
411
|
+
//#region src/getUsers.ts
|
|
412
|
+
const statusSchema = zod.z.enum([
|
|
413
|
+
"PENDING",
|
|
414
|
+
"INCOMPLETE",
|
|
415
|
+
"SUSPENDED",
|
|
416
|
+
"REJECTED",
|
|
417
|
+
"APPROVED"
|
|
418
|
+
]);
|
|
419
|
+
const profileTypeSchema = zod.z.enum(["Single", "Business"]);
|
|
420
|
+
const userFiltersSchema = zod.z.object({
|
|
421
|
+
status: statusSchema.optional(),
|
|
422
|
+
profileType: profileTypeSchema.optional(),
|
|
423
|
+
serviceId: zod.z.string().uuid().optional()
|
|
424
|
+
});
|
|
425
|
+
const sortSchema = zod.z.enum([
|
|
426
|
+
"registrationDate",
|
|
427
|
+
"userName",
|
|
428
|
+
"firstName",
|
|
429
|
+
"lastName",
|
|
430
|
+
"updateDate"
|
|
431
|
+
]);
|
|
432
|
+
const getUsers = async (client, options) => {
|
|
433
|
+
const resultOptions = (0, _vulog_aima_core.createPaginableOptionsSchema)(userFiltersSchema.default({}), sortSchema.optional().default("registrationDate")).default({}).safeParse(options);
|
|
434
|
+
if (!resultOptions.success) throw new TypeError("Invalid options", { cause: resultOptions.error.issues });
|
|
435
|
+
const finalOptions = resultOptions.data;
|
|
436
|
+
const searchParams = new URLSearchParams();
|
|
437
|
+
searchParams.append("page", finalOptions.page.toString());
|
|
438
|
+
searchParams.append("size", finalOptions.pageSize.toString());
|
|
439
|
+
searchParams.append("sort", `${finalOptions.sort.toString()},${finalOptions.sortDirection.toString()}`);
|
|
440
|
+
Object.entries(finalOptions.filters).forEach(([key, value]) => {
|
|
441
|
+
if (value === void 0) return;
|
|
442
|
+
searchParams.append(key, value);
|
|
443
|
+
});
|
|
444
|
+
return client.get(`/boapi/proxy/user/fleets/${client.clientOptions.fleetId}/users?${searchParams.toString()}`).then(({ data, headers }) => {
|
|
445
|
+
return {
|
|
446
|
+
data,
|
|
447
|
+
page: headers.number,
|
|
448
|
+
pageSize: headers.size,
|
|
449
|
+
total: headers.totalelements,
|
|
450
|
+
totalPages: headers.totalpages
|
|
451
|
+
};
|
|
452
|
+
});
|
|
453
|
+
};
|
|
454
|
+
//#endregion
|
|
455
|
+
exports.acceptTAndC = acceptTAndC;
|
|
456
|
+
exports.accountStatus = accountStatus;
|
|
457
|
+
exports.addLabelForUser = addLabelForUser;
|
|
458
|
+
exports.assignBillingGroup = assignBillingGroup;
|
|
459
|
+
exports.createBusinessProfile = createBusinessProfile;
|
|
460
|
+
exports.createUser = createUser;
|
|
461
|
+
exports.findUser = findUser;
|
|
462
|
+
exports.getEntity = getEntity;
|
|
463
|
+
exports.getFleetBillingGroups = getFleetBillingGroups;
|
|
464
|
+
exports.getLabelsForUser = getLabelsForUser;
|
|
465
|
+
exports.getProfilePersonalInfoById = getProfilePersonalInfoById;
|
|
466
|
+
exports.getRegistrationOverview = getRegistrationOverview;
|
|
467
|
+
exports.getUserById = getUserById;
|
|
468
|
+
exports.getUserPersonalInfoById = getUserPersonalInfoById;
|
|
469
|
+
exports.getUsers = getUsers;
|
|
470
|
+
exports.getUsersByIds = getUsersByIds;
|
|
471
|
+
exports.getUsersPIByIds = getUsersPIByIds;
|
|
472
|
+
exports.personalInformationProfileTypeSchema = personalInformationProfileTypeSchema;
|
|
473
|
+
exports.personalInformationProfileTypes = personalInformationProfileTypes;
|
|
474
|
+
exports.personalInformationUserPaths = personalInformationUserPaths;
|
|
475
|
+
exports.personalInformationUserTypeSchema = personalInformationUserTypeSchema;
|
|
476
|
+
exports.personalInformationUserTypes = personalInformationUserTypes;
|
|
477
|
+
exports.registerUserToService = registerUserToService;
|
|
478
|
+
exports.removeLabelForUser = removeLabelForUser;
|
|
479
|
+
exports.setServicesStatus = setServicesStatus;
|
|
480
|
+
exports.unassignBillingGroup = unassignBillingGroup;
|
|
481
|
+
exports.updateProfilePersonalInfo = updateProfilePersonalInfo;
|
|
482
|
+
exports.updateUser = updateUser;
|
|
483
|
+
exports.updateUserPersonalInfo = updateUserPersonalInfo;
|