@vulog/aima-user 1.2.34 → 1.2.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -198,7 +198,7 @@ const getProfilePersonalInfoById = async (client, userId, profileId, types) => {
198
198
  const getRegistrationOverview = async (client, userId) => {
199
199
  const result = zod.z.string().uuid().safeParse(userId);
200
200
  if (!result.success) throw new TypeError("Invalid userId", { cause: result.error.issues });
201
- return client.get(`boapi/proxy/user/fleets/${client.clientOptions.fleetId}/users/${userId}/services`).then(({ data: { userId: uid, ...data } }) => data);
201
+ return client.get(`boapi/proxy/user/fleets/${client.clientOptions.fleetId}/users/${userId}/services`).then(({ data: { userId: _, ...data } }) => data);
202
202
  };
203
203
  //#endregion
204
204
  //#region src/getUserById.ts
@@ -210,6 +210,13 @@ const getUserById = async (client, id, addAccountStatus = false) => {
210
210
  return user;
211
211
  };
212
212
  //#endregion
213
+ //#region src/getUserByEmail.ts
214
+ const getUserByEmail = async (client, email) => {
215
+ const result = zod.z.string().trim().min(1).email().safeParse(email);
216
+ if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
217
+ return client.get(`/boapi/proxy/user/fleets/${client.clientOptions.fleetId}/usernames/${encodeURIComponent(result.data)}`).then(({ data }) => data);
218
+ };
219
+ //#endregion
213
220
  //#region src/getUserPersonalInfoById.ts
214
221
  const argsSchema$2 = zod.z.object({
215
222
  id: zod.z.string().trim().min(1).uuid(),
@@ -464,6 +471,7 @@ exports.getFleetBillingGroups = getFleetBillingGroups;
464
471
  exports.getLabelsForUser = getLabelsForUser;
465
472
  exports.getProfilePersonalInfoById = getProfilePersonalInfoById;
466
473
  exports.getRegistrationOverview = getRegistrationOverview;
474
+ exports.getUserByEmail = getUserByEmail;
467
475
  exports.getUserById = getUserById;
468
476
  exports.getUserPersonalInfoById = getUserPersonalInfoById;
469
477
  exports.getUsers = getUsers;
package/dist/index.d.cts CHANGED
@@ -233,6 +233,9 @@ declare const getRegistrationOverview: (client: Client, userId: string) => Promi
233
233
  //#region src/getUserById.d.ts
234
234
  declare const getUserById: (client: Client, id: string, addAccountStatus?: boolean) => Promise<User>;
235
235
  //#endregion
236
+ //#region src/getUserByEmail.d.ts
237
+ declare const getUserByEmail: (client: Client, email: string) => Promise<User>;
238
+ //#endregion
236
239
  //#region src/getUserPersonalInfoById.d.ts
237
240
  declare const getUserPersonalInfoById: (client: Client, id: string, types: PersonalInformationUserType[]) => Promise<PersonalInformationUser>;
238
241
  //#endregion
@@ -324,4 +327,4 @@ type UserSort = z.infer<typeof sortSchema>;
324
327
  type UserFilters = z.infer<typeof userFiltersSchema>;
325
328
  declare const getUsers: (client: Client, options?: PaginableOptions<UserFilters, UserSort>) => Promise<PaginableResponse<UserStatus>>;
326
329
  //#endregion
327
- export { AccountStatus, Address, BillingGroup, CreateBusinessProfile, CreateUser, CreateUserOptions, Entity, FiscalInformation, IndividualBusiness, Label, PersonalCompany, PersonalInformationBirth, PersonalInformationIdentity, PersonalInformationProfile, PersonalInformationProfileType, PersonalInformationUser, PersonalInformationUserType, Profile, ProfilePaths, ProfileServiceRegistration, ProfileStatus, ProfileType, ResponseFind, SearchType, ServiceRegistrationWithReason, ServiceStatus, ServicesRegistrationList, ServicesUpdate, User, UserAgreement, UserFilters, UserFull, UserPaths, UserProfile, UserServiceRegistration, UserSort, UserStatus, 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 };
330
+ export { AccountStatus, Address, BillingGroup, CreateBusinessProfile, CreateUser, CreateUserOptions, Entity, FiscalInformation, IndividualBusiness, Label, PersonalCompany, PersonalInformationBirth, PersonalInformationIdentity, PersonalInformationProfile, PersonalInformationProfileType, PersonalInformationUser, PersonalInformationUserType, Profile, ProfilePaths, ProfileServiceRegistration, ProfileStatus, ProfileType, ResponseFind, SearchType, ServiceRegistrationWithReason, ServiceStatus, ServicesRegistrationList, ServicesUpdate, User, UserAgreement, UserFilters, UserFull, UserPaths, UserProfile, UserServiceRegistration, UserSort, UserStatus, UserUpdateBody, acceptTAndC, accountStatus, addLabelForUser, assignBillingGroup, createBusinessProfile, createUser, findUser, getEntity, getFleetBillingGroups, getLabelsForUser, getProfilePersonalInfoById, getRegistrationOverview, getUserByEmail, getUserById, getUserPersonalInfoById, getUsers, getUsersByIds, getUsersPIByIds, personalInformationProfileTypeSchema, personalInformationProfileTypes, personalInformationUserPaths, personalInformationUserTypeSchema, personalInformationUserTypes, registerUserToService, removeLabelForUser, setServicesStatus, unassignBillingGroup, updateProfilePersonalInfo, updateUser, updateUserPersonalInfo };
package/dist/index.d.mts CHANGED
@@ -233,6 +233,9 @@ declare const getRegistrationOverview: (client: Client, userId: string) => Promi
233
233
  //#region src/getUserById.d.ts
234
234
  declare const getUserById: (client: Client, id: string, addAccountStatus?: boolean) => Promise<User>;
235
235
  //#endregion
236
+ //#region src/getUserByEmail.d.ts
237
+ declare const getUserByEmail: (client: Client, email: string) => Promise<User>;
238
+ //#endregion
236
239
  //#region src/getUserPersonalInfoById.d.ts
237
240
  declare const getUserPersonalInfoById: (client: Client, id: string, types: PersonalInformationUserType[]) => Promise<PersonalInformationUser>;
238
241
  //#endregion
@@ -324,4 +327,4 @@ type UserSort = z.infer<typeof sortSchema>;
324
327
  type UserFilters = z.infer<typeof userFiltersSchema>;
325
328
  declare const getUsers: (client: Client, options?: PaginableOptions<UserFilters, UserSort>) => Promise<PaginableResponse<UserStatus>>;
326
329
  //#endregion
327
- export { AccountStatus, Address, BillingGroup, CreateBusinessProfile, CreateUser, CreateUserOptions, Entity, FiscalInformation, IndividualBusiness, Label, PersonalCompany, PersonalInformationBirth, PersonalInformationIdentity, PersonalInformationProfile, PersonalInformationProfileType, PersonalInformationUser, PersonalInformationUserType, Profile, ProfilePaths, ProfileServiceRegistration, ProfileStatus, ProfileType, ResponseFind, SearchType, ServiceRegistrationWithReason, ServiceStatus, ServicesRegistrationList, ServicesUpdate, User, UserAgreement, UserFilters, UserFull, UserPaths, UserProfile, UserServiceRegistration, UserSort, UserStatus, 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 };
330
+ export { AccountStatus, Address, BillingGroup, CreateBusinessProfile, CreateUser, CreateUserOptions, Entity, FiscalInformation, IndividualBusiness, Label, PersonalCompany, PersonalInformationBirth, PersonalInformationIdentity, PersonalInformationProfile, PersonalInformationProfileType, PersonalInformationUser, PersonalInformationUserType, Profile, ProfilePaths, ProfileServiceRegistration, ProfileStatus, ProfileType, ResponseFind, SearchType, ServiceRegistrationWithReason, ServiceStatus, ServicesRegistrationList, ServicesUpdate, User, UserAgreement, UserFilters, UserFull, UserPaths, UserProfile, UserServiceRegistration, UserSort, UserStatus, UserUpdateBody, acceptTAndC, accountStatus, addLabelForUser, assignBillingGroup, createBusinessProfile, createUser, findUser, getEntity, getFleetBillingGroups, getLabelsForUser, getProfilePersonalInfoById, getRegistrationOverview, getUserByEmail, getUserById, getUserPersonalInfoById, getUsers, getUsersByIds, getUsersPIByIds, personalInformationProfileTypeSchema, personalInformationProfileTypes, personalInformationUserPaths, personalInformationUserTypeSchema, personalInformationUserTypes, registerUserToService, removeLabelForUser, setServicesStatus, unassignBillingGroup, updateProfilePersonalInfo, updateUser, updateUserPersonalInfo };
package/dist/index.mjs CHANGED
@@ -197,7 +197,7 @@ const getProfilePersonalInfoById = async (client, userId, profileId, types) => {
197
197
  const getRegistrationOverview = async (client, userId) => {
198
198
  const result = z.string().uuid().safeParse(userId);
199
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);
200
+ return client.get(`boapi/proxy/user/fleets/${client.clientOptions.fleetId}/users/${userId}/services`).then(({ data: { userId: _, ...data } }) => data);
201
201
  };
202
202
  //#endregion
203
203
  //#region src/getUserById.ts
@@ -209,6 +209,13 @@ const getUserById = async (client, id, addAccountStatus = false) => {
209
209
  return user;
210
210
  };
211
211
  //#endregion
212
+ //#region src/getUserByEmail.ts
213
+ const getUserByEmail = async (client, email) => {
214
+ const result = z.string().trim().min(1).email().safeParse(email);
215
+ if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
216
+ return client.get(`/boapi/proxy/user/fleets/${client.clientOptions.fleetId}/usernames/${encodeURIComponent(result.data)}`).then(({ data }) => data);
217
+ };
218
+ //#endregion
212
219
  //#region src/getUserPersonalInfoById.ts
213
220
  const argsSchema$2 = z.object({
214
221
  id: z.string().trim().min(1).uuid(),
@@ -451,4 +458,4 @@ const getUsers = async (client, options) => {
451
458
  });
452
459
  };
453
460
  //#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 };
461
+ export { acceptTAndC, accountStatus, addLabelForUser, assignBillingGroup, createBusinessProfile, createUser, findUser, getEntity, getFleetBillingGroups, getLabelsForUser, getProfilePersonalInfoById, getRegistrationOverview, getUserByEmail, getUserById, getUserPersonalInfoById, getUsers, getUsersByIds, getUsersPIByIds, personalInformationProfileTypeSchema, personalInformationProfileTypes, personalInformationUserPaths, personalInformationUserTypeSchema, personalInformationUserTypes, registerUserToService, removeLabelForUser, setServicesStatus, unassignBillingGroup, updateProfilePersonalInfo, updateUser, updateUserPersonalInfo };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vulog/aima-user",
3
3
  "type": "module",
4
- "version": "1.2.34",
4
+ "version": "1.2.36",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",
7
7
  "types": "dist/index.d.cts",
@@ -22,7 +22,7 @@
22
22
  "dev": "tsdown --watch",
23
23
  "test": "vitest run",
24
24
  "test:watch": "vitest",
25
- "lint": "eslint src/**/* --ext .ts"
25
+ "lint": "eslint src/"
26
26
  },
27
27
  "keywords": [
28
28
  "AIMA",
@@ -32,9 +32,9 @@
32
32
  "author": "Vulog",
33
33
  "license": "MIT",
34
34
  "dependencies": {
35
- "@vulog/aima-client": "1.2.34",
36
- "@vulog/aima-config": "1.2.34",
37
- "@vulog/aima-core": "1.2.34"
35
+ "@vulog/aima-client": "1.2.36",
36
+ "@vulog/aima-config": "1.2.36",
37
+ "@vulog/aima-core": "1.2.36"
38
38
  },
39
39
  "peerDependencies": {
40
40
  "zod": "^3.25.76"
@@ -15,5 +15,5 @@ export const getRegistrationOverview = async (client: Client, userId: string): P
15
15
  .get<
16
16
  UserServiceRegistration & { userId: string }
17
17
  >(`boapi/proxy/user/fleets/${client.clientOptions.fleetId}/users/${userId}/services`)
18
- .then(({ data: { userId: uid, ...data } }) => data);
18
+ .then(({ data: { userId: _, ...data } }) => data);
19
19
  };
@@ -0,0 +1,61 @@
1
+ import { describe, test, expect, vi, beforeEach } from 'vitest';
2
+ import { Client } from '@vulog/aima-client';
3
+ import { getUserByEmail } from './getUserByEmail';
4
+
5
+ describe('getUserByEmail', () => {
6
+ const FLEET_ID = 'FLEET_ID';
7
+ const getMock = vi.fn();
8
+ const client = {
9
+ get: getMock,
10
+ clientOptions: {
11
+ fleetId: FLEET_ID,
12
+ },
13
+ } as unknown as Client;
14
+
15
+ beforeEach(() => {
16
+ getMock.mockReset();
17
+ });
18
+
19
+ test('throws Invalid args when email is invalid', async () => {
20
+ await expect(getUserByEmail(client, 'not-an-email')).rejects.toThrow(TypeError);
21
+ await expect(getUserByEmail(client, 'not-an-email')).rejects.toMatchObject({
22
+ message: 'Invalid args',
23
+ });
24
+ expect(getMock).not.toHaveBeenCalled();
25
+ });
26
+
27
+ test('throws Invalid args when email is empty', async () => {
28
+ await expect(getUserByEmail(client, '')).rejects.toThrow(TypeError);
29
+ expect(getMock).not.toHaveBeenCalled();
30
+ });
31
+
32
+ test('calls GET with correct URL (email encoded) and returns user', async () => {
33
+ const email = 'user+tag@example.com';
34
+ const userData = {
35
+ id: '20fb98a3-b60d-491a-9359-62e55f51fcb9',
36
+ fleetId: FLEET_ID,
37
+ registrationDate: '2024-01-15T10:00:00Z',
38
+ locale: 'en_GB',
39
+ agreements: [],
40
+ profiles: [],
41
+ dataPrivacyConsent: true,
42
+ marketingConsent: false,
43
+ surveyConsent: false,
44
+ shareDataConsent: false,
45
+ surveyConsentUpdateDate: '',
46
+ shareDataConsentUpdateDate: '',
47
+ profilingConsent: false,
48
+ profilingConsentUpdateDate: '',
49
+ };
50
+ getMock.mockResolvedValueOnce({ data: userData });
51
+
52
+ const result = await getUserByEmail(client, email);
53
+
54
+ expect(getMock).toHaveBeenCalledTimes(1);
55
+ expect(getMock).toHaveBeenCalledWith(
56
+ `/boapi/proxy/user/fleets/${FLEET_ID}/usernames/${encodeURIComponent(email)}`
57
+ );
58
+ expect(result).toEqual(userData);
59
+ expect(result.id).toBe(userData.id);
60
+ });
61
+ });
@@ -0,0 +1,19 @@
1
+ import { Client } from '@vulog/aima-client';
2
+ import { z } from 'zod';
3
+
4
+ import { User } from './types';
5
+
6
+ export const getUserByEmail = async (client: Client, email: string): Promise<User> => {
7
+ const result = z.string().trim().min(1).email().safeParse(email);
8
+ if (!result.success) {
9
+ throw new TypeError('Invalid args', {
10
+ cause: result.error.issues,
11
+ });
12
+ }
13
+
14
+ return client
15
+ .get<User>(
16
+ `/boapi/proxy/user/fleets/${client.clientOptions.fleetId}/usernames/${encodeURIComponent(result.data)}`
17
+ )
18
+ .then(({ data }) => data);
19
+ };
package/src/index.ts CHANGED
@@ -7,6 +7,7 @@ export * from './findUser';
7
7
  export * from './getProfilePersonalInfoById';
8
8
  export * from './getRegistrationOverview';
9
9
  export * from './getUserById';
10
+ export * from './getUserByEmail';
10
11
  export * from './getUserPersonalInfoById';
11
12
  export * from './getUsersPIByIds';
12
13
  export * from './label';
package/.eslintrc.cjs DELETED
@@ -1,112 +0,0 @@
1
- module.exports = {
2
- parser: '@typescript-eslint/parser',
3
- parserOptions: {
4
- // Indicates the location of the TypeScript configuration file
5
- project: 'tsconfig.json',
6
- // Sets the root directory for the TypeScript configuration
7
- tsconfigRootDir: __dirname,
8
- // Specifies the version of ECMAScript syntax to be used
9
- ecmaVersion: 'latest',
10
- // Indicates the type of source code (script or module)
11
- sourceType: 'module',
12
- },
13
- plugins: ['@typescript-eslint', 'prettier', 'import'],
14
- extends: [
15
- 'airbnb-base',
16
- 'airbnb-typescript/base',
17
- 'plugin:@typescript-eslint/recommended',
18
- 'prettier',
19
- 'plugin:prettier/recommended',
20
- ],
21
- root: true,
22
- env: {
23
- es6: true,
24
- node: true,
25
- },
26
- ignorePatterns: [
27
- '/dist/**/*', // Ignore built files.
28
- '.eslintrc.js',
29
- '**/*.test.ts',
30
- ],
31
- rules: {
32
- // Configures the Prettier integration with ESLint
33
- 'prettier/prettier': ['error', { endOfLine: 'auto' }],
34
- // Disables the rule requiring an 'I' prefix for interfaces
35
- '@typescript-eslint/interface-name-prefix': 'off',
36
- // Configures the naming conventions for various code constructs
37
- '@typescript-eslint/naming-convention': [
38
- // ... various naming convention configurations ...
39
- 'error',
40
- // Allows any naming format for destructured variables
41
- {
42
- selector: 'variable',
43
- modifiers: ['destructured'],
44
- format: null,
45
- },
46
- // Requires strict camelCase for function names
47
- {
48
- selector: 'function',
49
- format: ['strictCamelCase'],
50
- },
51
- // Requires boolean variables to have one of the specified prefixes
52
- {
53
- selector: 'variable',
54
- format: null,
55
- types: ['boolean'],
56
- prefix: ['is', 'should', 'has', 'can', 'did', 'will'],
57
- },
58
- // Requires enum names to have a strict PascalCase format
59
- {
60
- selector: 'enum',
61
- format: ['StrictPascalCase'],
62
- },
63
- ],
64
- 'import/extensions': 'off',
65
- // Disables the rule requiring explicit return types for functions
66
- '@typescript-eslint/explicit-function-return-type': 'off',
67
- // Disables the rule requiring explicit boundary types for modules
68
- '@typescript-eslint/explicit-module-boundary-types': 'off',
69
- // Disables the rule prohibiting the use of 'any' type
70
- '@typescript-eslint/no-explicit-any': 'off',
71
- // Disables the rule detecting unused variables
72
- 'no-unused-vars': 0,
73
- // Disables the rule disallowing named exports used as a default export
74
- 'import/no-named-as-default': 0,
75
- // Configures the order and formatting of import statements
76
- 'import/order': [
77
- // ... import order configuration ...
78
- 'error',
79
- {
80
- // Configure the alphabetization settings
81
- alphabetize: {
82
- // Enforce ascending alphabetical order
83
- order: 'asc',
84
- // Do not ignore the case while sorting
85
- caseInsensitive: false,
86
- },
87
- // Enforce newlines between different groups and inside groups of imports
88
- 'newlines-between': 'always-and-inside-groups',
89
- // Warn when there is an import statement that is not part of any group
90
- warnOnUnassignedImports: true,
91
- },
92
- ],
93
- // Configures the rule detecting extraneous dependencies
94
- 'import/no-extraneous-dependencies': [
95
- // ... extraneous dependencies configuration ...
96
- 'error',
97
- {
98
- // Specify the file patterns where devDependencies imports are allowed
99
- devDependencies: [
100
- // Allow devDependencies imports in test and spec files
101
- '**/*.test.{ts,js}',
102
- '**/*.spec.{ts,js}',
103
- // Allow devDependencies imports in the 'test' folder
104
- './test/**.{ts,js}',
105
- // Allow devDependencies imports in the 'scripts' folder
106
- './scripts/**/*.{ts,js}',
107
- ],
108
- },
109
- ],
110
- 'import/prefer-default-export': 'off',
111
- },
112
- };