@vulog/aima-user 1.2.19 → 1.2.21
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/README.md +38 -27
- package/dist/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +139 -119
- package/dist/index.mjs +138 -119
- package/package.json +4 -4
- package/src/index.ts +1 -0
- package/src/unassignBillingGroup.ts +19 -0
package/README.md
CHANGED
|
@@ -14,10 +14,10 @@ npm install @vulog/aima-client @vulog/aima-core @vulog/aima-user
|
|
|
14
14
|
|
|
15
15
|
```javascript
|
|
16
16
|
import { getClient } from '@vulog/aima-client';
|
|
17
|
-
import {
|
|
18
|
-
createUser,
|
|
19
|
-
findUser,
|
|
20
|
-
getUserById,
|
|
17
|
+
import {
|
|
18
|
+
createUser,
|
|
19
|
+
findUser,
|
|
20
|
+
getUserById,
|
|
21
21
|
updateUser,
|
|
22
22
|
createBusinessProfile,
|
|
23
23
|
getFleetBillingGroups
|
|
@@ -186,6 +186,17 @@ const result = await assignBillingGroup(client, {
|
|
|
186
186
|
});
|
|
187
187
|
```
|
|
188
188
|
|
|
189
|
+
#### unassignBillingGroup
|
|
190
|
+
|
|
191
|
+
Unassign a user to a billing group.
|
|
192
|
+
|
|
193
|
+
```javascript
|
|
194
|
+
const result = await unassignBillingGroup(client, {
|
|
195
|
+
entityId: 'user-uuid-here',
|
|
196
|
+
billingGroupId: 'billing-group-id-here'
|
|
197
|
+
});
|
|
198
|
+
```
|
|
199
|
+
|
|
189
200
|
### Terms and Conditions
|
|
190
201
|
|
|
191
202
|
#### acceptTAndC
|
|
@@ -219,7 +230,7 @@ const result = await setServicesStatus(client, {
|
|
|
219
230
|
|
|
220
231
|
#### registerUserToService
|
|
221
232
|
|
|
222
|
-
Register a user entity to a specific service it's optional if the service is public (users are subscribed by default to public services). but mandatory to be able to book on a private service.
|
|
233
|
+
Register a user entity to a specific service it's optional if the service is public (users are subscribed by default to public services). but mandatory to be able to book on a private service.
|
|
223
234
|
|
|
224
235
|
```javascript
|
|
225
236
|
await registerUserToService(client, 'entity-uuid-here', 'service-uuid-here');
|
|
@@ -299,10 +310,10 @@ All functions include validation using Zod schemas and will throw appropriate er
|
|
|
299
310
|
|
|
300
311
|
```javascript
|
|
301
312
|
import { getClient } from '@vulog/aima-client';
|
|
302
|
-
import {
|
|
303
|
-
createUser,
|
|
304
|
-
findUser,
|
|
305
|
-
getUserById,
|
|
313
|
+
import {
|
|
314
|
+
createUser,
|
|
315
|
+
findUser,
|
|
316
|
+
getUserById,
|
|
306
317
|
updateUser,
|
|
307
318
|
createBusinessProfile,
|
|
308
319
|
getFleetBillingGroups
|
|
@@ -329,26 +340,26 @@ async function userManagementWorkflow() {
|
|
|
329
340
|
marketingConsent: true,
|
|
330
341
|
phoneNumber: '+1234567890'
|
|
331
342
|
});
|
|
332
|
-
|
|
343
|
+
|
|
333
344
|
console.log('User created:', newUser);
|
|
334
|
-
|
|
345
|
+
|
|
335
346
|
// Find user by email
|
|
336
347
|
const foundUsers = await findUser(client, {
|
|
337
348
|
email: 'jane.doe@example.com'
|
|
338
349
|
});
|
|
339
350
|
console.log('Found users:', foundUsers);
|
|
340
|
-
|
|
351
|
+
|
|
341
352
|
// Get user by ID
|
|
342
353
|
const user = await getUserById(client, newUser.id);
|
|
343
354
|
console.log('User details:', user);
|
|
344
|
-
|
|
355
|
+
|
|
345
356
|
// Update user
|
|
346
357
|
const updatedUser = await updateUser(client, newUser.id, {
|
|
347
358
|
phoneNumber: '+0987654321',
|
|
348
359
|
locale: 'fr_FR'
|
|
349
360
|
});
|
|
350
361
|
console.log('User updated:', updatedUser);
|
|
351
|
-
|
|
362
|
+
|
|
352
363
|
// Create business profile
|
|
353
364
|
const businessProfile = await createBusinessProfile(client, {
|
|
354
365
|
entityId: newUser.id,
|
|
@@ -362,11 +373,11 @@ async function userManagementWorkflow() {
|
|
|
362
373
|
}
|
|
363
374
|
});
|
|
364
375
|
console.log('Business profile created:', businessProfile);
|
|
365
|
-
|
|
376
|
+
|
|
366
377
|
// Get billing groups
|
|
367
378
|
const billingGroups = await getFleetBillingGroups(client);
|
|
368
379
|
console.log('Billing groups:', billingGroups);
|
|
369
|
-
|
|
380
|
+
|
|
370
381
|
return { newUser, updatedUser, businessProfile, billingGroups };
|
|
371
382
|
} catch (error) {
|
|
372
383
|
console.error('User management error:', error);
|
|
@@ -382,19 +393,19 @@ async function searchUsers(client, searchTerm) {
|
|
|
382
393
|
try {
|
|
383
394
|
// Search by email
|
|
384
395
|
const emailResults = await findUser(client, { email: searchTerm });
|
|
385
|
-
|
|
396
|
+
|
|
386
397
|
// Search by username
|
|
387
398
|
const usernameResults = await findUser(client, { userName: searchTerm });
|
|
388
|
-
|
|
399
|
+
|
|
389
400
|
// Search by phone number
|
|
390
401
|
const phoneResults = await findUser(client, { phoneNumber: searchTerm });
|
|
391
|
-
|
|
402
|
+
|
|
392
403
|
// Combine and deduplicate results
|
|
393
404
|
const allResults = [...emailResults, ...usernameResults, ...phoneResults];
|
|
394
|
-
const uniqueResults = allResults.filter((user, index, self) =>
|
|
405
|
+
const uniqueResults = allResults.filter((user, index, self) =>
|
|
395
406
|
index === self.findIndex(u => u.id === user.id)
|
|
396
407
|
);
|
|
397
|
-
|
|
408
|
+
|
|
398
409
|
console.log(`Found ${uniqueResults.length} unique users for "${searchTerm}"`);
|
|
399
410
|
return uniqueResults;
|
|
400
411
|
} catch (error) {
|
|
@@ -412,13 +423,13 @@ async function analyzeUsers(client) {
|
|
|
412
423
|
// This would require a function to get all users
|
|
413
424
|
// For now, we'll demonstrate with individual user lookups
|
|
414
425
|
const sampleUserIds = ['user1', 'user2', 'user3']; // Replace with actual IDs
|
|
415
|
-
|
|
426
|
+
|
|
416
427
|
const users = await Promise.all(
|
|
417
428
|
sampleUserIds.map(id => getUserById(client, id).catch(() => null))
|
|
418
429
|
);
|
|
419
|
-
|
|
430
|
+
|
|
420
431
|
const validUsers = users.filter(user => user !== null);
|
|
421
|
-
|
|
432
|
+
|
|
422
433
|
const analysis = {
|
|
423
434
|
totalUsers: validUsers.length,
|
|
424
435
|
activeUsers: validUsers.filter(u => u.status === 'ACTIVE').length,
|
|
@@ -434,7 +445,7 @@ async function analyzeUsers(client) {
|
|
|
434
445
|
return acc;
|
|
435
446
|
}, {})
|
|
436
447
|
};
|
|
437
|
-
|
|
448
|
+
|
|
438
449
|
console.log('User Analysis:');
|
|
439
450
|
console.log(`Total Users: ${analysis.totalUsers}`);
|
|
440
451
|
console.log(`Active: ${analysis.activeUsers}`);
|
|
@@ -442,11 +453,11 @@ async function analyzeUsers(client) {
|
|
|
442
453
|
console.log(`Suspended: ${analysis.suspendedUsers}`);
|
|
443
454
|
console.log('Consent Stats:', analysis.consentStats);
|
|
444
455
|
console.log('Locale Distribution:', analysis.localeDistribution);
|
|
445
|
-
|
|
456
|
+
|
|
446
457
|
return analysis;
|
|
447
458
|
} catch (error) {
|
|
448
459
|
console.error('User analysis error:', error);
|
|
449
460
|
throw error;
|
|
450
461
|
}
|
|
451
462
|
}
|
|
452
|
-
```
|
|
463
|
+
```
|
package/dist/index.d.mts
CHANGED
|
@@ -7,6 +7,8 @@ declare const acceptTAndC: (client: Client, userId: string, cityId: string) => P
|
|
|
7
7
|
|
|
8
8
|
declare const assignBillingGroup: (client: Client, entityId: string, billingGroupId: string) => Promise<void>;
|
|
9
9
|
|
|
10
|
+
declare const unassignBillingGroup: (client: Client, entityId: string, billingGroupId: string) => Promise<void>;
|
|
11
|
+
|
|
10
12
|
type Address = {
|
|
11
13
|
streetName?: string;
|
|
12
14
|
city?: string;
|
|
@@ -300,4 +302,4 @@ type UserSort = z.infer<typeof sortSchema>;
|
|
|
300
302
|
type UserFilters = z.infer<typeof userFiltersSchema>;
|
|
301
303
|
declare const getUsers: (client: Client, options?: PaginableOptions<UserFilters, UserSort>) => Promise<PaginableResponse<UserStatus>>;
|
|
302
304
|
|
|
303
|
-
export { type AccountStatus, type Address, type BillingGroup, type CreateBusinessProfile, type CreateUser, type CreateUserOptions, type Entity, type FiscalInformation, type IndividualBusiness, type Label, type PersonalCompany, type PersonalInformationBirth, type PersonalInformationIdentity, type PersonalInformationProfile, type PersonalInformationProfileType, type PersonalInformationUser, type PersonalInformationUserType, type Profile, type ProfilePaths, type ProfileServiceRegistration, type ProfileStatus, type ProfileType, type ResponseFind, type SearchType, type ServiceRegistrationWithReason, type ServiceStatus, type ServicesRegistrationList, type ServicesUpdate, type User, type UserAgreement, type UserFilters, type UserFull, type UserPaths, type UserProfile, type UserServiceRegistration, type UserSort, type UserStatus, type UserUpdateBody, 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, updateProfilePersonalInfo, updateUser, updateUserPersonalInfo };
|
|
305
|
+
export { type AccountStatus, type Address, type BillingGroup, type CreateBusinessProfile, type CreateUser, type CreateUserOptions, type Entity, type FiscalInformation, type IndividualBusiness, type Label, type PersonalCompany, type PersonalInformationBirth, type PersonalInformationIdentity, type PersonalInformationProfile, type PersonalInformationProfileType, type PersonalInformationUser, type PersonalInformationUserType, type Profile, type ProfilePaths, type ProfileServiceRegistration, type ProfileStatus, type ProfileType, type ResponseFind, type SearchType, type ServiceRegistrationWithReason, type ServiceStatus, type ServicesRegistrationList, type ServicesUpdate, type User, type UserAgreement, type UserFilters, type UserFull, type UserPaths, type UserProfile, type UserServiceRegistration, type UserSort, type UserStatus, type UserUpdateBody, 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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,8 @@ declare const acceptTAndC: (client: Client, userId: string, cityId: string) => P
|
|
|
7
7
|
|
|
8
8
|
declare const assignBillingGroup: (client: Client, entityId: string, billingGroupId: string) => Promise<void>;
|
|
9
9
|
|
|
10
|
+
declare const unassignBillingGroup: (client: Client, entityId: string, billingGroupId: string) => Promise<void>;
|
|
11
|
+
|
|
10
12
|
type Address = {
|
|
11
13
|
streetName?: string;
|
|
12
14
|
city?: string;
|
|
@@ -300,4 +302,4 @@ type UserSort = z.infer<typeof sortSchema>;
|
|
|
300
302
|
type UserFilters = z.infer<typeof userFiltersSchema>;
|
|
301
303
|
declare const getUsers: (client: Client, options?: PaginableOptions<UserFilters, UserSort>) => Promise<PaginableResponse<UserStatus>>;
|
|
302
304
|
|
|
303
|
-
export { type AccountStatus, type Address, type BillingGroup, type CreateBusinessProfile, type CreateUser, type CreateUserOptions, type Entity, type FiscalInformation, type IndividualBusiness, type Label, type PersonalCompany, type PersonalInformationBirth, type PersonalInformationIdentity, type PersonalInformationProfile, type PersonalInformationProfileType, type PersonalInformationUser, type PersonalInformationUserType, type Profile, type ProfilePaths, type ProfileServiceRegistration, type ProfileStatus, type ProfileType, type ResponseFind, type SearchType, type ServiceRegistrationWithReason, type ServiceStatus, type ServicesRegistrationList, type ServicesUpdate, type User, type UserAgreement, type UserFilters, type UserFull, type UserPaths, type UserProfile, type UserServiceRegistration, type UserSort, type UserStatus, type UserUpdateBody, 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, updateProfilePersonalInfo, updateUser, updateUserPersonalInfo };
|
|
305
|
+
export { type AccountStatus, type Address, type BillingGroup, type CreateBusinessProfile, type CreateUser, type CreateUserOptions, type Entity, type FiscalInformation, type IndividualBusiness, type Label, type PersonalCompany, type PersonalInformationBirth, type PersonalInformationIdentity, type PersonalInformationProfile, type PersonalInformationProfileType, type PersonalInformationUser, type PersonalInformationUserType, type Profile, type ProfilePaths, type ProfileServiceRegistration, type ProfileStatus, type ProfileType, type ResponseFind, type SearchType, type ServiceRegistrationWithReason, type ServiceStatus, type ServicesRegistrationList, type ServicesUpdate, type User, type UserAgreement, type UserFilters, type UserFull, type UserPaths, type UserProfile, type UserServiceRegistration, type UserSort, type UserStatus, type UserUpdateBody, 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 };
|
package/dist/index.js
CHANGED
|
@@ -45,6 +45,7 @@ __export(index_exports, {
|
|
|
45
45
|
registerUserToService: () => registerUserToService,
|
|
46
46
|
removeLabelForUser: () => removeLabelForUser,
|
|
47
47
|
setServicesStatus: () => setServicesStatus,
|
|
48
|
+
unassignBillingGroup: () => unassignBillingGroup,
|
|
48
49
|
updateProfilePersonalInfo: () => updateProfilePersonalInfo,
|
|
49
50
|
updateUser: () => updateUser,
|
|
50
51
|
updateUserPersonalInfo: () => updateUserPersonalInfo
|
|
@@ -87,16 +88,34 @@ var assignBillingGroup = async (client, entityId, billingGroupId) => {
|
|
|
87
88
|
);
|
|
88
89
|
};
|
|
89
90
|
|
|
90
|
-
// src/
|
|
91
|
+
// src/unassignBillingGroup.ts
|
|
91
92
|
var import_zod3 = require("zod");
|
|
92
|
-
var
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
93
|
+
var schema3 = import_zod3.z.object({
|
|
94
|
+
entityId: import_zod3.z.string().trim().min(1).uuid(),
|
|
95
|
+
billingGroupId: import_zod3.z.string().trim().min(1).uuid()
|
|
96
|
+
});
|
|
97
|
+
var unassignBillingGroup = async (client, entityId, billingGroupId) => {
|
|
98
|
+
const result = schema3.safeParse({ entityId, billingGroupId });
|
|
99
|
+
if (!result.success) {
|
|
100
|
+
throw new TypeError("Invalid args", {
|
|
101
|
+
cause: result.error.issues
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
await client.delete(
|
|
105
|
+
`/boapi/proxy/user/fleets/${client.clientOptions.fleetId}/billingGroup/${billingGroupId}/entities/${entityId}`
|
|
106
|
+
);
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
// src/createBusinessProfile.ts
|
|
110
|
+
var import_zod4 = require("zod");
|
|
111
|
+
var createBusinessProfileSchema = import_zod4.z.object({
|
|
112
|
+
userId: import_zod4.z.string().nonempty().uuid(),
|
|
113
|
+
businessId: import_zod4.z.string().nonempty().uuid(),
|
|
114
|
+
data: import_zod4.z.object({
|
|
115
|
+
emailConsent: import_zod4.z.boolean(),
|
|
116
|
+
email: import_zod4.z.string().email(),
|
|
117
|
+
requestId: import_zod4.z.string().nonempty().uuid(),
|
|
118
|
+
costCenterId: import_zod4.z.string().uuid().nullish()
|
|
100
119
|
})
|
|
101
120
|
});
|
|
102
121
|
var createBusinessProfile = async (client, userId, businessId, data) => {
|
|
@@ -117,20 +136,20 @@ var createBusinessProfile = async (client, userId, businessId, data) => {
|
|
|
117
136
|
};
|
|
118
137
|
|
|
119
138
|
// src/createUser.ts
|
|
120
|
-
var
|
|
121
|
-
var createUserSchema =
|
|
122
|
-
userName:
|
|
123
|
-
password:
|
|
124
|
-
locale:
|
|
125
|
-
email:
|
|
126
|
-
dataPrivacyConsent:
|
|
127
|
-
profilingConsent:
|
|
128
|
-
marketingConsent:
|
|
129
|
-
phoneNumber:
|
|
139
|
+
var import_zod5 = require("zod");
|
|
140
|
+
var createUserSchema = import_zod5.z.object({
|
|
141
|
+
userName: import_zod5.z.string().min(1),
|
|
142
|
+
password: import_zod5.z.string().min(1),
|
|
143
|
+
locale: import_zod5.z.string().length(5),
|
|
144
|
+
email: import_zod5.z.string().min(1).email(),
|
|
145
|
+
dataPrivacyConsent: import_zod5.z.boolean().optional(),
|
|
146
|
+
profilingConsent: import_zod5.z.boolean().optional(),
|
|
147
|
+
marketingConsent: import_zod5.z.boolean().optional(),
|
|
148
|
+
phoneNumber: import_zod5.z.string().optional()
|
|
130
149
|
});
|
|
131
|
-
var createUserOptionsSchema =
|
|
132
|
-
tcApproval:
|
|
133
|
-
skipUserNotification:
|
|
150
|
+
var createUserOptionsSchema = import_zod5.z.object({
|
|
151
|
+
tcApproval: import_zod5.z.boolean().default(true),
|
|
152
|
+
skipUserNotification: import_zod5.z.boolean().default(false)
|
|
134
153
|
}).default({
|
|
135
154
|
tcApproval: true,
|
|
136
155
|
skipUserNotification: false
|
|
@@ -158,10 +177,10 @@ var createUser = async (client, user, option) => {
|
|
|
158
177
|
};
|
|
159
178
|
|
|
160
179
|
// src/findUser.ts
|
|
161
|
-
var
|
|
180
|
+
var import_zod7 = require("zod");
|
|
162
181
|
|
|
163
182
|
// src/types.ts
|
|
164
|
-
var
|
|
183
|
+
var import_zod6 = require("zod");
|
|
165
184
|
var accountStatus = ["INCOMPLETE", "PENDING", "APPROVED", "REJECTED", "SUSPENDED", "ARCHIVED"];
|
|
166
185
|
var personalInformationUserTypes = [
|
|
167
186
|
"IDENTITY",
|
|
@@ -210,16 +229,16 @@ var personalInformationUserPaths = [
|
|
|
210
229
|
"/address/addressAdditionalInformation",
|
|
211
230
|
"/membership"
|
|
212
231
|
];
|
|
213
|
-
var personalInformationUserTypeSchema =
|
|
232
|
+
var personalInformationUserTypeSchema = import_zod6.z.enum(personalInformationUserTypes);
|
|
214
233
|
var personalInformationProfileTypes = ["ID_NUMBER", "PHONE_NUMBER", "EMAIL", "BILLING_ADDRESS"];
|
|
215
|
-
var personalInformationProfileTypeSchema =
|
|
234
|
+
var personalInformationProfileTypeSchema = import_zod6.z.enum(personalInformationProfileTypes);
|
|
216
235
|
|
|
217
236
|
// src/findUser.ts
|
|
218
237
|
var searchTypes = ["email", "username", "phoneNumber"];
|
|
219
|
-
var querySchema =
|
|
220
|
-
searchType:
|
|
221
|
-
searchQuery:
|
|
222
|
-
types:
|
|
238
|
+
var querySchema = import_zod7.z.object({
|
|
239
|
+
searchType: import_zod7.z.enum(searchTypes),
|
|
240
|
+
searchQuery: import_zod7.z.string().min(1),
|
|
241
|
+
types: import_zod7.z.array(personalInformationUserTypeSchema).min(1)
|
|
223
242
|
});
|
|
224
243
|
var findUser = async (client, searchType, searchQuery, types) => {
|
|
225
244
|
const result = querySchema.safeParse({
|
|
@@ -241,11 +260,11 @@ var findUser = async (client, searchType, searchQuery, types) => {
|
|
|
241
260
|
};
|
|
242
261
|
|
|
243
262
|
// src/getProfilePersonalInfoById.ts
|
|
244
|
-
var
|
|
245
|
-
var argsSchema =
|
|
246
|
-
userId:
|
|
247
|
-
profileId:
|
|
248
|
-
types:
|
|
263
|
+
var import_zod8 = require("zod");
|
|
264
|
+
var argsSchema = import_zod8.z.object({
|
|
265
|
+
userId: import_zod8.z.string().trim().min(1).uuid(),
|
|
266
|
+
profileId: import_zod8.z.string().trim().min(1).uuid(),
|
|
267
|
+
types: import_zod8.z.array(personalInformationProfileTypeSchema).min(1)
|
|
249
268
|
});
|
|
250
269
|
var getProfilePersonalInfoById = async (client, userId, profileId, types) => {
|
|
251
270
|
const result = argsSchema.safeParse({ userId, profileId, types });
|
|
@@ -260,9 +279,9 @@ var getProfilePersonalInfoById = async (client, userId, profileId, types) => {
|
|
|
260
279
|
};
|
|
261
280
|
|
|
262
281
|
// src/getRegistrationOverview.ts
|
|
263
|
-
var
|
|
282
|
+
var import_zod9 = require("zod");
|
|
264
283
|
var getRegistrationOverview = async (client, userId) => {
|
|
265
|
-
const result =
|
|
284
|
+
const result = import_zod9.z.string().uuid().safeParse(userId);
|
|
266
285
|
if (!result.success) {
|
|
267
286
|
throw new TypeError("Invalid userId", {
|
|
268
287
|
cause: result.error.issues
|
|
@@ -272,9 +291,9 @@ var getRegistrationOverview = async (client, userId) => {
|
|
|
272
291
|
};
|
|
273
292
|
|
|
274
293
|
// src/getUserById.ts
|
|
275
|
-
var
|
|
294
|
+
var import_zod10 = require("zod");
|
|
276
295
|
var getUserById = async (client, id, addAccountStatus = false) => {
|
|
277
|
-
const result =
|
|
296
|
+
const result = import_zod10.z.string().trim().min(1).uuid().safeParse(id);
|
|
278
297
|
if (!result.success) {
|
|
279
298
|
throw new TypeError("Invalid id", {
|
|
280
299
|
cause: result.error.issues
|
|
@@ -288,10 +307,10 @@ var getUserById = async (client, id, addAccountStatus = false) => {
|
|
|
288
307
|
};
|
|
289
308
|
|
|
290
309
|
// src/getUserPersonalInfoById.ts
|
|
291
|
-
var
|
|
292
|
-
var argsSchema2 =
|
|
293
|
-
id:
|
|
294
|
-
types:
|
|
310
|
+
var import_zod11 = require("zod");
|
|
311
|
+
var argsSchema2 = import_zod11.z.object({
|
|
312
|
+
id: import_zod11.z.string().trim().min(1).uuid(),
|
|
313
|
+
types: import_zod11.z.array(personalInformationUserTypeSchema).min(1)
|
|
295
314
|
});
|
|
296
315
|
var getUserPersonalInfoById = async (client, id, types) => {
|
|
297
316
|
const result = argsSchema2.safeParse({ id, types });
|
|
@@ -306,10 +325,10 @@ var getUserPersonalInfoById = async (client, id, types) => {
|
|
|
306
325
|
};
|
|
307
326
|
|
|
308
327
|
// src/getUsersPIByIds.ts
|
|
309
|
-
var
|
|
310
|
-
var argsSchema3 =
|
|
311
|
-
ids:
|
|
312
|
-
types:
|
|
328
|
+
var import_zod12 = require("zod");
|
|
329
|
+
var argsSchema3 = import_zod12.z.object({
|
|
330
|
+
ids: import_zod12.z.array(import_zod12.z.string().trim().min(1).uuid()).min(1),
|
|
331
|
+
types: import_zod12.z.array(personalInformationUserTypeSchema).min(1)
|
|
313
332
|
});
|
|
314
333
|
var getUsersPIByIds = async (client, ids, types) => {
|
|
315
334
|
const result = argsSchema3.safeParse({ ids, types });
|
|
@@ -327,16 +346,16 @@ var getUsersPIByIds = async (client, ids, types) => {
|
|
|
327
346
|
};
|
|
328
347
|
|
|
329
348
|
// src/label.ts
|
|
330
|
-
var
|
|
331
|
-
var
|
|
332
|
-
userId:
|
|
349
|
+
var import_zod13 = require("zod");
|
|
350
|
+
var schema4 = import_zod13.z.object({
|
|
351
|
+
userId: import_zod13.z.string().uuid()
|
|
333
352
|
});
|
|
334
|
-
var schemaData =
|
|
335
|
-
userId:
|
|
336
|
-
labelId:
|
|
353
|
+
var schemaData = import_zod13.z.object({
|
|
354
|
+
userId: import_zod13.z.string().uuid(),
|
|
355
|
+
labelId: import_zod13.z.number().positive()
|
|
337
356
|
});
|
|
338
357
|
var getLabelsForUser = async (client, userId) => {
|
|
339
|
-
const result =
|
|
358
|
+
const result = schema4.safeParse({ userId });
|
|
340
359
|
if (!result.success) {
|
|
341
360
|
throw new TypeError("Invalid args", {
|
|
342
361
|
cause: result.error.issues
|
|
@@ -368,27 +387,27 @@ var removeLabelForUser = async (client, userId, labelId) => {
|
|
|
368
387
|
};
|
|
369
388
|
|
|
370
389
|
// src/setServicesStatus.ts
|
|
371
|
-
var
|
|
390
|
+
var import_zod14 = require("zod");
|
|
372
391
|
var registrationStatus = ["APPROVED", "INCOMPLETE", "PENDING", "REJECTED", "SUSPENDED", "UNREGISTERED"];
|
|
373
|
-
var
|
|
374
|
-
disableEmailNotification:
|
|
375
|
-
operatorProfileId:
|
|
376
|
-
actions:
|
|
377
|
-
|
|
378
|
-
reasonForChange:
|
|
379
|
-
serviceId:
|
|
380
|
-
status:
|
|
392
|
+
var schema5 = import_zod14.z.object({
|
|
393
|
+
disableEmailNotification: import_zod14.z.boolean(),
|
|
394
|
+
operatorProfileId: import_zod14.z.string().uuid(),
|
|
395
|
+
actions: import_zod14.z.array(
|
|
396
|
+
import_zod14.z.object({
|
|
397
|
+
reasonForChange: import_zod14.z.string(),
|
|
398
|
+
serviceId: import_zod14.z.string().uuid(),
|
|
399
|
+
status: import_zod14.z.enum(registrationStatus)
|
|
381
400
|
})
|
|
382
401
|
).min(1)
|
|
383
402
|
});
|
|
384
403
|
var setServicesStatus = async (client, profileId, servicesUpdate) => {
|
|
385
|
-
const resultProfileId =
|
|
404
|
+
const resultProfileId = import_zod14.z.string().uuid().safeParse(profileId);
|
|
386
405
|
if (!resultProfileId.success) {
|
|
387
406
|
throw new TypeError("Invalid profileId", {
|
|
388
407
|
cause: resultProfileId.error.issues
|
|
389
408
|
});
|
|
390
409
|
}
|
|
391
|
-
const resultServices =
|
|
410
|
+
const resultServices = schema5.safeParse(servicesUpdate);
|
|
392
411
|
if (!resultServices.success) {
|
|
393
412
|
throw new TypeError("Invalid servicesUpdate", {
|
|
394
413
|
cause: resultServices.error.issues
|
|
@@ -401,15 +420,15 @@ var setServicesStatus = async (client, profileId, servicesUpdate) => {
|
|
|
401
420
|
};
|
|
402
421
|
|
|
403
422
|
// src/registerUserToService.ts
|
|
404
|
-
var
|
|
423
|
+
var import_zod15 = require("zod");
|
|
405
424
|
var registerUserToService = async (client, entityId, serviceId) => {
|
|
406
|
-
const resultEntityId =
|
|
425
|
+
const resultEntityId = import_zod15.z.string().uuid().safeParse(entityId);
|
|
407
426
|
if (!resultEntityId.success) {
|
|
408
427
|
throw new TypeError("Invalid entityId", {
|
|
409
428
|
cause: resultEntityId.error.issues
|
|
410
429
|
});
|
|
411
430
|
}
|
|
412
|
-
const resultServiceId =
|
|
431
|
+
const resultServiceId = import_zod15.z.string().uuid().safeParse(serviceId);
|
|
413
432
|
if (!resultServiceId.success) {
|
|
414
433
|
throw new TypeError("Invalid serviceId", {
|
|
415
434
|
cause: resultServiceId.error.issues
|
|
@@ -421,27 +440,27 @@ var registerUserToService = async (client, entityId, serviceId) => {
|
|
|
421
440
|
};
|
|
422
441
|
|
|
423
442
|
// src/updateProfilePersonalInfo.ts
|
|
424
|
-
var
|
|
443
|
+
var import_zod16 = require("zod");
|
|
425
444
|
var paths = ["/phoneNumber", "/email", "/idNumber"];
|
|
426
|
-
var
|
|
427
|
-
userId:
|
|
428
|
-
profileId:
|
|
429
|
-
actions:
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
op:
|
|
433
|
-
path:
|
|
434
|
-
value:
|
|
445
|
+
var schema6 = import_zod16.z.object({
|
|
446
|
+
userId: import_zod16.z.string().trim().min(1).uuid(),
|
|
447
|
+
profileId: import_zod16.z.string().trim().min(1).uuid(),
|
|
448
|
+
actions: import_zod16.z.array(
|
|
449
|
+
import_zod16.z.union([
|
|
450
|
+
import_zod16.z.object({
|
|
451
|
+
op: import_zod16.z.enum(["add", "replace"]),
|
|
452
|
+
path: import_zod16.z.enum(paths),
|
|
453
|
+
value: import_zod16.z.string().min(1)
|
|
435
454
|
}),
|
|
436
|
-
|
|
437
|
-
op:
|
|
438
|
-
path:
|
|
455
|
+
import_zod16.z.object({
|
|
456
|
+
op: import_zod16.z.literal("remove"),
|
|
457
|
+
path: import_zod16.z.enum(paths)
|
|
439
458
|
})
|
|
440
459
|
])
|
|
441
460
|
).min(1)
|
|
442
461
|
});
|
|
443
462
|
var updateProfilePersonalInfo = async (client, userId, profileId, actions) => {
|
|
444
|
-
const result =
|
|
463
|
+
const result = schema6.safeParse({ userId, profileId, actions });
|
|
445
464
|
if (!result.success) {
|
|
446
465
|
throw new TypeError("Invalid args", {
|
|
447
466
|
cause: result.error.issues
|
|
@@ -459,22 +478,22 @@ var updateProfilePersonalInfo = async (client, userId, profileId, actions) => {
|
|
|
459
478
|
};
|
|
460
479
|
|
|
461
480
|
// src/updateUser.ts
|
|
462
|
-
var
|
|
463
|
-
var
|
|
464
|
-
id:
|
|
465
|
-
user:
|
|
466
|
-
locale:
|
|
467
|
-
accountStatus:
|
|
468
|
-
dataPrivacyConsent:
|
|
469
|
-
marketingConsent:
|
|
470
|
-
surveyConsent:
|
|
471
|
-
shareDataConsent:
|
|
472
|
-
profilingConsent:
|
|
473
|
-
membershipNumber:
|
|
481
|
+
var import_zod17 = require("zod");
|
|
482
|
+
var schema7 = import_zod17.z.object({
|
|
483
|
+
id: import_zod17.z.string().trim().min(1).uuid(),
|
|
484
|
+
user: import_zod17.z.object({
|
|
485
|
+
locale: import_zod17.z.string(),
|
|
486
|
+
accountStatus: import_zod17.z.enum(accountStatus),
|
|
487
|
+
dataPrivacyConsent: import_zod17.z.boolean(),
|
|
488
|
+
marketingConsent: import_zod17.z.boolean(),
|
|
489
|
+
surveyConsent: import_zod17.z.boolean(),
|
|
490
|
+
shareDataConsent: import_zod17.z.boolean(),
|
|
491
|
+
profilingConsent: import_zod17.z.boolean(),
|
|
492
|
+
membershipNumber: import_zod17.z.string()
|
|
474
493
|
}).partial()
|
|
475
494
|
});
|
|
476
495
|
var updateUser = async (client, id, user) => {
|
|
477
|
-
const result =
|
|
496
|
+
const result = schema7.safeParse({ id, user });
|
|
478
497
|
if (!result.success) {
|
|
479
498
|
throw new TypeError("Invalid args", {
|
|
480
499
|
cause: result.error.issues
|
|
@@ -484,25 +503,25 @@ var updateUser = async (client, id, user) => {
|
|
|
484
503
|
};
|
|
485
504
|
|
|
486
505
|
// src/updateUserPersonalInfo.ts
|
|
487
|
-
var
|
|
488
|
-
var
|
|
489
|
-
userId:
|
|
490
|
-
actions:
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
op:
|
|
494
|
-
path:
|
|
495
|
-
value:
|
|
506
|
+
var import_zod18 = require("zod");
|
|
507
|
+
var schema8 = import_zod18.z.object({
|
|
508
|
+
userId: import_zod18.z.string().trim().min(1).uuid(),
|
|
509
|
+
actions: import_zod18.z.array(
|
|
510
|
+
import_zod18.z.union([
|
|
511
|
+
import_zod18.z.object({
|
|
512
|
+
op: import_zod18.z.enum(["add", "replace"]),
|
|
513
|
+
path: import_zod18.z.enum(personalInformationUserPaths),
|
|
514
|
+
value: import_zod18.z.string().min(1)
|
|
496
515
|
}),
|
|
497
|
-
|
|
498
|
-
op:
|
|
499
|
-
path:
|
|
516
|
+
import_zod18.z.object({
|
|
517
|
+
op: import_zod18.z.literal("remove"),
|
|
518
|
+
path: import_zod18.z.enum(personalInformationUserPaths)
|
|
500
519
|
})
|
|
501
520
|
])
|
|
502
521
|
).min(1)
|
|
503
522
|
});
|
|
504
523
|
var updateUserPersonalInfo = async (client, userId, actions) => {
|
|
505
|
-
const result =
|
|
524
|
+
const result = schema8.safeParse({ userId, actions });
|
|
506
525
|
if (!result.success) {
|
|
507
526
|
throw new TypeError("Invalid args", {
|
|
508
527
|
cause: result.error.issues
|
|
@@ -516,9 +535,9 @@ var updateUserPersonalInfo = async (client, userId, actions) => {
|
|
|
516
535
|
};
|
|
517
536
|
|
|
518
537
|
// src/getEntity.ts
|
|
519
|
-
var
|
|
538
|
+
var import_zod19 = require("zod");
|
|
520
539
|
var getEntity = async (client, entityId) => {
|
|
521
|
-
const result =
|
|
540
|
+
const result = import_zod19.z.string().trim().min(1).uuid().safeParse(entityId);
|
|
522
541
|
if (!result.success) {
|
|
523
542
|
throw new TypeError("Invalid entity id", {
|
|
524
543
|
cause: result.error.issues
|
|
@@ -558,9 +577,9 @@ var getFleetBillingGroups = async (client, options) => {
|
|
|
558
577
|
};
|
|
559
578
|
|
|
560
579
|
// src/getUsersByIds.ts
|
|
561
|
-
var
|
|
562
|
-
var argsSchema4 =
|
|
563
|
-
ids:
|
|
580
|
+
var import_zod20 = require("zod");
|
|
581
|
+
var argsSchema4 = import_zod20.z.object({
|
|
582
|
+
ids: import_zod20.z.array(import_zod20.z.string().trim().min(1).uuid()).min(1)
|
|
564
583
|
});
|
|
565
584
|
var getUsersByIds = async (client, ids) => {
|
|
566
585
|
const result = argsSchema4.safeParse({ ids });
|
|
@@ -574,15 +593,15 @@ var getUsersByIds = async (client, ids) => {
|
|
|
574
593
|
|
|
575
594
|
// src/getUsers.ts
|
|
576
595
|
var import_aima_core2 = require("@vulog/aima-core");
|
|
577
|
-
var
|
|
578
|
-
var statusSchema =
|
|
579
|
-
var profileTypeSchema =
|
|
580
|
-
var userFiltersSchema =
|
|
596
|
+
var import_zod21 = require("zod");
|
|
597
|
+
var statusSchema = import_zod21.z.enum(["PENDING", "INCOMPLETE", "SUSPENDED", "REJECTED", "APPROVED"]);
|
|
598
|
+
var profileTypeSchema = import_zod21.z.enum(["Single", "Business"]);
|
|
599
|
+
var userFiltersSchema = import_zod21.z.object({
|
|
581
600
|
status: statusSchema.optional(),
|
|
582
601
|
profileType: profileTypeSchema.optional(),
|
|
583
|
-
serviceId:
|
|
602
|
+
serviceId: import_zod21.z.string().uuid().optional()
|
|
584
603
|
});
|
|
585
|
-
var sortSchema =
|
|
604
|
+
var sortSchema = import_zod21.z.enum(["registrationDate", "userName", "firstName", "lastName", "updateDate"]);
|
|
586
605
|
var getUsers = async (client, options) => {
|
|
587
606
|
const paginableOptionsSchema = (0, import_aima_core2.createPaginableOptionsSchema)(
|
|
588
607
|
userFiltersSchema.default({}),
|
|
@@ -642,6 +661,7 @@ var getUsers = async (client, options) => {
|
|
|
642
661
|
registerUserToService,
|
|
643
662
|
removeLabelForUser,
|
|
644
663
|
setServicesStatus,
|
|
664
|
+
unassignBillingGroup,
|
|
645
665
|
updateProfilePersonalInfo,
|
|
646
666
|
updateUser,
|
|
647
667
|
updateUserPersonalInfo
|
package/dist/index.mjs
CHANGED
|
@@ -34,16 +34,34 @@ var assignBillingGroup = async (client, entityId, billingGroupId) => {
|
|
|
34
34
|
);
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
-
// src/
|
|
37
|
+
// src/unassignBillingGroup.ts
|
|
38
38
|
import { z as z3 } from "zod";
|
|
39
|
-
var
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
39
|
+
var schema3 = z3.object({
|
|
40
|
+
entityId: z3.string().trim().min(1).uuid(),
|
|
41
|
+
billingGroupId: z3.string().trim().min(1).uuid()
|
|
42
|
+
});
|
|
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
|
+
);
|
|
53
|
+
};
|
|
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()
|
|
47
65
|
})
|
|
48
66
|
});
|
|
49
67
|
var createBusinessProfile = async (client, userId, businessId, data) => {
|
|
@@ -64,20 +82,20 @@ var createBusinessProfile = async (client, userId, businessId, data) => {
|
|
|
64
82
|
};
|
|
65
83
|
|
|
66
84
|
// src/createUser.ts
|
|
67
|
-
import { z as
|
|
68
|
-
var createUserSchema =
|
|
69
|
-
userName:
|
|
70
|
-
password:
|
|
71
|
-
locale:
|
|
72
|
-
email:
|
|
73
|
-
dataPrivacyConsent:
|
|
74
|
-
profilingConsent:
|
|
75
|
-
marketingConsent:
|
|
76
|
-
phoneNumber:
|
|
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()
|
|
77
95
|
});
|
|
78
|
-
var createUserOptionsSchema =
|
|
79
|
-
tcApproval:
|
|
80
|
-
skipUserNotification:
|
|
96
|
+
var createUserOptionsSchema = z5.object({
|
|
97
|
+
tcApproval: z5.boolean().default(true),
|
|
98
|
+
skipUserNotification: z5.boolean().default(false)
|
|
81
99
|
}).default({
|
|
82
100
|
tcApproval: true,
|
|
83
101
|
skipUserNotification: false
|
|
@@ -105,10 +123,10 @@ var createUser = async (client, user, option) => {
|
|
|
105
123
|
};
|
|
106
124
|
|
|
107
125
|
// src/findUser.ts
|
|
108
|
-
import { z as
|
|
126
|
+
import { z as z7 } from "zod";
|
|
109
127
|
|
|
110
128
|
// src/types.ts
|
|
111
|
-
import { z as
|
|
129
|
+
import { z as z6 } from "zod";
|
|
112
130
|
var accountStatus = ["INCOMPLETE", "PENDING", "APPROVED", "REJECTED", "SUSPENDED", "ARCHIVED"];
|
|
113
131
|
var personalInformationUserTypes = [
|
|
114
132
|
"IDENTITY",
|
|
@@ -157,16 +175,16 @@ var personalInformationUserPaths = [
|
|
|
157
175
|
"/address/addressAdditionalInformation",
|
|
158
176
|
"/membership"
|
|
159
177
|
];
|
|
160
|
-
var personalInformationUserTypeSchema =
|
|
178
|
+
var personalInformationUserTypeSchema = z6.enum(personalInformationUserTypes);
|
|
161
179
|
var personalInformationProfileTypes = ["ID_NUMBER", "PHONE_NUMBER", "EMAIL", "BILLING_ADDRESS"];
|
|
162
|
-
var personalInformationProfileTypeSchema =
|
|
180
|
+
var personalInformationProfileTypeSchema = z6.enum(personalInformationProfileTypes);
|
|
163
181
|
|
|
164
182
|
// src/findUser.ts
|
|
165
183
|
var searchTypes = ["email", "username", "phoneNumber"];
|
|
166
|
-
var querySchema =
|
|
167
|
-
searchType:
|
|
168
|
-
searchQuery:
|
|
169
|
-
types:
|
|
184
|
+
var querySchema = z7.object({
|
|
185
|
+
searchType: z7.enum(searchTypes),
|
|
186
|
+
searchQuery: z7.string().min(1),
|
|
187
|
+
types: z7.array(personalInformationUserTypeSchema).min(1)
|
|
170
188
|
});
|
|
171
189
|
var findUser = async (client, searchType, searchQuery, types) => {
|
|
172
190
|
const result = querySchema.safeParse({
|
|
@@ -188,11 +206,11 @@ var findUser = async (client, searchType, searchQuery, types) => {
|
|
|
188
206
|
};
|
|
189
207
|
|
|
190
208
|
// src/getProfilePersonalInfoById.ts
|
|
191
|
-
import { z as
|
|
192
|
-
var argsSchema =
|
|
193
|
-
userId:
|
|
194
|
-
profileId:
|
|
195
|
-
types:
|
|
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)
|
|
196
214
|
});
|
|
197
215
|
var getProfilePersonalInfoById = async (client, userId, profileId, types) => {
|
|
198
216
|
const result = argsSchema.safeParse({ userId, profileId, types });
|
|
@@ -207,9 +225,9 @@ var getProfilePersonalInfoById = async (client, userId, profileId, types) => {
|
|
|
207
225
|
};
|
|
208
226
|
|
|
209
227
|
// src/getRegistrationOverview.ts
|
|
210
|
-
import { z as
|
|
228
|
+
import { z as z9 } from "zod";
|
|
211
229
|
var getRegistrationOverview = async (client, userId) => {
|
|
212
|
-
const result =
|
|
230
|
+
const result = z9.string().uuid().safeParse(userId);
|
|
213
231
|
if (!result.success) {
|
|
214
232
|
throw new TypeError("Invalid userId", {
|
|
215
233
|
cause: result.error.issues
|
|
@@ -219,9 +237,9 @@ var getRegistrationOverview = async (client, userId) => {
|
|
|
219
237
|
};
|
|
220
238
|
|
|
221
239
|
// src/getUserById.ts
|
|
222
|
-
import { z as
|
|
240
|
+
import { z as z10 } from "zod";
|
|
223
241
|
var getUserById = async (client, id, addAccountStatus = false) => {
|
|
224
|
-
const result =
|
|
242
|
+
const result = z10.string().trim().min(1).uuid().safeParse(id);
|
|
225
243
|
if (!result.success) {
|
|
226
244
|
throw new TypeError("Invalid id", {
|
|
227
245
|
cause: result.error.issues
|
|
@@ -235,10 +253,10 @@ var getUserById = async (client, id, addAccountStatus = false) => {
|
|
|
235
253
|
};
|
|
236
254
|
|
|
237
255
|
// src/getUserPersonalInfoById.ts
|
|
238
|
-
import { z as
|
|
239
|
-
var argsSchema2 =
|
|
240
|
-
id:
|
|
241
|
-
types:
|
|
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)
|
|
242
260
|
});
|
|
243
261
|
var getUserPersonalInfoById = async (client, id, types) => {
|
|
244
262
|
const result = argsSchema2.safeParse({ id, types });
|
|
@@ -253,10 +271,10 @@ var getUserPersonalInfoById = async (client, id, types) => {
|
|
|
253
271
|
};
|
|
254
272
|
|
|
255
273
|
// src/getUsersPIByIds.ts
|
|
256
|
-
import { z as
|
|
257
|
-
var argsSchema3 =
|
|
258
|
-
ids:
|
|
259
|
-
types:
|
|
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)
|
|
260
278
|
});
|
|
261
279
|
var getUsersPIByIds = async (client, ids, types) => {
|
|
262
280
|
const result = argsSchema3.safeParse({ ids, types });
|
|
@@ -274,16 +292,16 @@ var getUsersPIByIds = async (client, ids, types) => {
|
|
|
274
292
|
};
|
|
275
293
|
|
|
276
294
|
// src/label.ts
|
|
277
|
-
import { z as
|
|
278
|
-
var
|
|
279
|
-
userId:
|
|
295
|
+
import { z as z13 } from "zod";
|
|
296
|
+
var schema4 = z13.object({
|
|
297
|
+
userId: z13.string().uuid()
|
|
280
298
|
});
|
|
281
|
-
var schemaData =
|
|
282
|
-
userId:
|
|
283
|
-
labelId:
|
|
299
|
+
var schemaData = z13.object({
|
|
300
|
+
userId: z13.string().uuid(),
|
|
301
|
+
labelId: z13.number().positive()
|
|
284
302
|
});
|
|
285
303
|
var getLabelsForUser = async (client, userId) => {
|
|
286
|
-
const result =
|
|
304
|
+
const result = schema4.safeParse({ userId });
|
|
287
305
|
if (!result.success) {
|
|
288
306
|
throw new TypeError("Invalid args", {
|
|
289
307
|
cause: result.error.issues
|
|
@@ -315,27 +333,27 @@ var removeLabelForUser = async (client, userId, labelId) => {
|
|
|
315
333
|
};
|
|
316
334
|
|
|
317
335
|
// src/setServicesStatus.ts
|
|
318
|
-
import { z as
|
|
336
|
+
import { z as z14 } from "zod";
|
|
319
337
|
var registrationStatus = ["APPROVED", "INCOMPLETE", "PENDING", "REJECTED", "SUSPENDED", "UNREGISTERED"];
|
|
320
|
-
var
|
|
321
|
-
disableEmailNotification:
|
|
322
|
-
operatorProfileId:
|
|
323
|
-
actions:
|
|
324
|
-
|
|
325
|
-
reasonForChange:
|
|
326
|
-
serviceId:
|
|
327
|
-
status:
|
|
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)
|
|
328
346
|
})
|
|
329
347
|
).min(1)
|
|
330
348
|
});
|
|
331
349
|
var setServicesStatus = async (client, profileId, servicesUpdate) => {
|
|
332
|
-
const resultProfileId =
|
|
350
|
+
const resultProfileId = z14.string().uuid().safeParse(profileId);
|
|
333
351
|
if (!resultProfileId.success) {
|
|
334
352
|
throw new TypeError("Invalid profileId", {
|
|
335
353
|
cause: resultProfileId.error.issues
|
|
336
354
|
});
|
|
337
355
|
}
|
|
338
|
-
const resultServices =
|
|
356
|
+
const resultServices = schema5.safeParse(servicesUpdate);
|
|
339
357
|
if (!resultServices.success) {
|
|
340
358
|
throw new TypeError("Invalid servicesUpdate", {
|
|
341
359
|
cause: resultServices.error.issues
|
|
@@ -348,15 +366,15 @@ var setServicesStatus = async (client, profileId, servicesUpdate) => {
|
|
|
348
366
|
};
|
|
349
367
|
|
|
350
368
|
// src/registerUserToService.ts
|
|
351
|
-
import { z as
|
|
369
|
+
import { z as z15 } from "zod";
|
|
352
370
|
var registerUserToService = async (client, entityId, serviceId) => {
|
|
353
|
-
const resultEntityId =
|
|
371
|
+
const resultEntityId = z15.string().uuid().safeParse(entityId);
|
|
354
372
|
if (!resultEntityId.success) {
|
|
355
373
|
throw new TypeError("Invalid entityId", {
|
|
356
374
|
cause: resultEntityId.error.issues
|
|
357
375
|
});
|
|
358
376
|
}
|
|
359
|
-
const resultServiceId =
|
|
377
|
+
const resultServiceId = z15.string().uuid().safeParse(serviceId);
|
|
360
378
|
if (!resultServiceId.success) {
|
|
361
379
|
throw new TypeError("Invalid serviceId", {
|
|
362
380
|
cause: resultServiceId.error.issues
|
|
@@ -368,27 +386,27 @@ var registerUserToService = async (client, entityId, serviceId) => {
|
|
|
368
386
|
};
|
|
369
387
|
|
|
370
388
|
// src/updateProfilePersonalInfo.ts
|
|
371
|
-
import { z as
|
|
389
|
+
import { z as z16 } from "zod";
|
|
372
390
|
var paths = ["/phoneNumber", "/email", "/idNumber"];
|
|
373
|
-
var
|
|
374
|
-
userId:
|
|
375
|
-
profileId:
|
|
376
|
-
actions:
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
op:
|
|
380
|
-
path:
|
|
381
|
-
value:
|
|
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)
|
|
382
400
|
}),
|
|
383
|
-
|
|
384
|
-
op:
|
|
385
|
-
path:
|
|
401
|
+
z16.object({
|
|
402
|
+
op: z16.literal("remove"),
|
|
403
|
+
path: z16.enum(paths)
|
|
386
404
|
})
|
|
387
405
|
])
|
|
388
406
|
).min(1)
|
|
389
407
|
});
|
|
390
408
|
var updateProfilePersonalInfo = async (client, userId, profileId, actions) => {
|
|
391
|
-
const result =
|
|
409
|
+
const result = schema6.safeParse({ userId, profileId, actions });
|
|
392
410
|
if (!result.success) {
|
|
393
411
|
throw new TypeError("Invalid args", {
|
|
394
412
|
cause: result.error.issues
|
|
@@ -406,22 +424,22 @@ var updateProfilePersonalInfo = async (client, userId, profileId, actions) => {
|
|
|
406
424
|
};
|
|
407
425
|
|
|
408
426
|
// src/updateUser.ts
|
|
409
|
-
import { z as
|
|
410
|
-
var
|
|
411
|
-
id:
|
|
412
|
-
user:
|
|
413
|
-
locale:
|
|
414
|
-
accountStatus:
|
|
415
|
-
dataPrivacyConsent:
|
|
416
|
-
marketingConsent:
|
|
417
|
-
surveyConsent:
|
|
418
|
-
shareDataConsent:
|
|
419
|
-
profilingConsent:
|
|
420
|
-
membershipNumber:
|
|
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()
|
|
421
439
|
}).partial()
|
|
422
440
|
});
|
|
423
441
|
var updateUser = async (client, id, user) => {
|
|
424
|
-
const result =
|
|
442
|
+
const result = schema7.safeParse({ id, user });
|
|
425
443
|
if (!result.success) {
|
|
426
444
|
throw new TypeError("Invalid args", {
|
|
427
445
|
cause: result.error.issues
|
|
@@ -431,25 +449,25 @@ var updateUser = async (client, id, user) => {
|
|
|
431
449
|
};
|
|
432
450
|
|
|
433
451
|
// src/updateUserPersonalInfo.ts
|
|
434
|
-
import { z as
|
|
435
|
-
var
|
|
436
|
-
userId:
|
|
437
|
-
actions:
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
op:
|
|
441
|
-
path:
|
|
442
|
-
value:
|
|
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)
|
|
443
461
|
}),
|
|
444
|
-
|
|
445
|
-
op:
|
|
446
|
-
path:
|
|
462
|
+
z18.object({
|
|
463
|
+
op: z18.literal("remove"),
|
|
464
|
+
path: z18.enum(personalInformationUserPaths)
|
|
447
465
|
})
|
|
448
466
|
])
|
|
449
467
|
).min(1)
|
|
450
468
|
});
|
|
451
469
|
var updateUserPersonalInfo = async (client, userId, actions) => {
|
|
452
|
-
const result =
|
|
470
|
+
const result = schema8.safeParse({ userId, actions });
|
|
453
471
|
if (!result.success) {
|
|
454
472
|
throw new TypeError("Invalid args", {
|
|
455
473
|
cause: result.error.issues
|
|
@@ -463,9 +481,9 @@ var updateUserPersonalInfo = async (client, userId, actions) => {
|
|
|
463
481
|
};
|
|
464
482
|
|
|
465
483
|
// src/getEntity.ts
|
|
466
|
-
import { z as
|
|
484
|
+
import { z as z19 } from "zod";
|
|
467
485
|
var getEntity = async (client, entityId) => {
|
|
468
|
-
const result =
|
|
486
|
+
const result = z19.string().trim().min(1).uuid().safeParse(entityId);
|
|
469
487
|
if (!result.success) {
|
|
470
488
|
throw new TypeError("Invalid entity id", {
|
|
471
489
|
cause: result.error.issues
|
|
@@ -505,9 +523,9 @@ var getFleetBillingGroups = async (client, options) => {
|
|
|
505
523
|
};
|
|
506
524
|
|
|
507
525
|
// src/getUsersByIds.ts
|
|
508
|
-
import { z as
|
|
509
|
-
var argsSchema4 =
|
|
510
|
-
ids:
|
|
526
|
+
import { z as z20 } from "zod";
|
|
527
|
+
var argsSchema4 = z20.object({
|
|
528
|
+
ids: z20.array(z20.string().trim().min(1).uuid()).min(1)
|
|
511
529
|
});
|
|
512
530
|
var getUsersByIds = async (client, ids) => {
|
|
513
531
|
const result = argsSchema4.safeParse({ ids });
|
|
@@ -521,15 +539,15 @@ var getUsersByIds = async (client, ids) => {
|
|
|
521
539
|
|
|
522
540
|
// src/getUsers.ts
|
|
523
541
|
import { createPaginableOptionsSchema as createPaginableOptionsSchema2 } from "@vulog/aima-core";
|
|
524
|
-
import { z as
|
|
525
|
-
var statusSchema =
|
|
526
|
-
var profileTypeSchema =
|
|
527
|
-
var userFiltersSchema =
|
|
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({
|
|
528
546
|
status: statusSchema.optional(),
|
|
529
547
|
profileType: profileTypeSchema.optional(),
|
|
530
|
-
serviceId:
|
|
548
|
+
serviceId: z21.string().uuid().optional()
|
|
531
549
|
});
|
|
532
|
-
var sortSchema =
|
|
550
|
+
var sortSchema = z21.enum(["registrationDate", "userName", "firstName", "lastName", "updateDate"]);
|
|
533
551
|
var getUsers = async (client, options) => {
|
|
534
552
|
const paginableOptionsSchema = createPaginableOptionsSchema2(
|
|
535
553
|
userFiltersSchema.default({}),
|
|
@@ -588,6 +606,7 @@ export {
|
|
|
588
606
|
registerUserToService,
|
|
589
607
|
removeLabelForUser,
|
|
590
608
|
setServicesStatus,
|
|
609
|
+
unassignBillingGroup,
|
|
591
610
|
updateProfilePersonalInfo,
|
|
592
611
|
updateUser,
|
|
593
612
|
updateUserPersonalInfo
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vulog/aima-user",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.21",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/index.mjs",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
"author": "Vulog",
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@vulog/aima-client": "1.2.
|
|
23
|
-
"@vulog/aima-config": "1.2.
|
|
24
|
-
"@vulog/aima-core": "1.2.
|
|
22
|
+
"@vulog/aima-client": "1.2.21",
|
|
23
|
+
"@vulog/aima-config": "1.2.21",
|
|
24
|
+
"@vulog/aima-core": "1.2.21"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"zod": "^3.25.76"
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Client } from '@vulog/aima-client';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
const schema = z.object({
|
|
5
|
+
entityId: z.string().trim().min(1).uuid(),
|
|
6
|
+
billingGroupId: z.string().trim().min(1).uuid(),
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export const unassignBillingGroup = async (client: Client, entityId: string, billingGroupId: string): Promise<void> => {
|
|
10
|
+
const result = schema.safeParse({ entityId, billingGroupId });
|
|
11
|
+
if (!result.success) {
|
|
12
|
+
throw new TypeError('Invalid args', {
|
|
13
|
+
cause: result.error.issues,
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
await client.delete(
|
|
17
|
+
`/boapi/proxy/user/fleets/${client.clientOptions.fleetId}/billingGroup/${billingGroupId}/entities/${entityId}`
|
|
18
|
+
);
|
|
19
|
+
};
|