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