Skip to content

Commit b03ff55

Browse files
committed
refactor: user controller alias + deprecation notice
1 parent 3a2d9ce commit b03ff55

File tree

3 files changed

+32
-7
lines changed

3 files changed

+32
-7
lines changed

src/backend.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import memori from './backend/memori';
2-
import user from './backend/user';
32
import userPwl from './backend/userPwl';
43
import integration from './backend/integration';
54
import asset from './backend/asset';
@@ -17,7 +16,7 @@ import trustedApplication from './backend/trustedApplication';
1716
const backendAPI = (apiUrl: string) => ({
1817
asset: asset(apiUrl),
1918
memori: memori(apiUrl),
20-
user: user(apiUrl),
19+
user: userPwl(apiUrl),
2120
userPwl: userPwl(apiUrl),
2221
integration: integration(apiUrl),
2322
invitation: invitation(apiUrl),
@@ -32,7 +31,6 @@ const backendAPI = (apiUrl: string) => ({
3231
trustedApplication: trustedApplication(apiUrl),
3332
...asset(apiUrl),
3433
...memori(apiUrl),
35-
...user(apiUrl),
3634
...userPwl(apiUrl),
3735
...integration(apiUrl),
3836
...invitation(apiUrl),

src/backend/user.test.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,19 @@ import memori from '../index';
22

33
const client = memori('https://backend.memori.ai');
44

5-
describe('backend/users api', () => {
5+
describe('backend/users api (pwl)', () => {
66
it('works on users apis', async () => {
77
expect(
8-
await client.backend.user.getUser(
8+
await client.backend.userPwl.pwlGetUser(
9+
'768b9654-e781-4c3c-81fa-ae1529d1bfbe',
10+
'be2e4a44-890b-483b-a26a-f6e122f36e2b'
11+
)
12+
).not.toBeNull();
13+
});
14+
15+
it('works on users alias apis', async () => {
16+
expect(
17+
await client.backend.user.pwlGetUser(
918
'768b9654-e781-4c3c-81fa-ae1529d1bfbe',
1019
'be2e4a44-890b-483b-a26a-f6e122f36e2b'
1120
)
@@ -14,7 +23,7 @@ describe('backend/users api', () => {
1423

1524
it('works on users apis with shorthand version', async () => {
1625
expect(
17-
await client.backend.getUser(
26+
await client.backend.pwlGetUser(
1827
'768b9654-e781-4c3c-81fa-ae1529d1bfbe',
1928
'be2e4a44-890b-483b-a26a-f6e122f36e2b'
2029
)

src/backend/user.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { apiFetcher } from '../apiFetcher';
44
export default (apiUrl: string) => ({
55
/**
66
* Registers a new user.
7+
* @deprecated Use PwlUser APIs
78
* @param user - The user object
89
* @returns The created user object
910
*/
@@ -16,6 +17,7 @@ export default (apiUrl: string) => ({
1617

1718
/**
1819
* Confirms the registration of a User and performs a Login.
20+
* @deprecated Use PwlUser APIs
1921
* @param user - The user object
2022
* @returns The created user object
2123
*/
@@ -28,6 +30,7 @@ export default (apiUrl: string) => ({
2830

2931
/**
3032
* Tries a login with the specified credentials and returns a login token if successful.
33+
* @deprecated Use PwlUser APIs
3134
* @param user - The user object
3235
* @returns The logged in user object
3336
*/
@@ -42,6 +45,7 @@ export default (apiUrl: string) => ({
4245

4346
/**
4447
* Logs out the user.
48+
* @deprecated Use PwlUser APIs
4549
* @param authToken - The login token
4650
*/
4751
userLogout: (authToken: string) =>
@@ -52,6 +56,7 @@ export default (apiUrl: string) => ({
5256

5357
/**
5458
* Gets the details of the currently logged in User object.
59+
* @deprecated Use PwlUser APIs
5560
* @param authToken - The login token
5661
* @returns The user object
5762
*/
@@ -66,6 +71,7 @@ export default (apiUrl: string) => ({
6671

6772
/**
6873
* Gets the details of a User object.
74+
* @deprecated Use PwlUser APIs
6975
* @param authToken - The login token
7076
* @param userID - The user ID
7177
* @returns The user object
@@ -81,6 +87,7 @@ export default (apiUrl: string) => ({
8187

8288
/**
8389
* Gets a list of all the existing User objects.
90+
* @deprecated Use PwlUser APIs
8491
* @param authToken - The login token
8592
* @returns A list of User objects
8693
*/
@@ -95,6 +102,7 @@ export default (apiUrl: string) => ({
95102

96103
/**
97104
* Gets a list of all the existing User objects paginated.
105+
* @deprecated Use PwlUser APIs
98106
* @param authToken - The login token
99107
* @param from - The 0-based index of the first User object to list
100108
* @param howMany - The number of User objects to list
@@ -114,6 +122,7 @@ export default (apiUrl: string) => ({
114122

115123
/**
116124
* Deletes the currently logged in User.
125+
* @deprecated Use PwlUser APIs
117126
* @param {string} authToken - The login token
118127
* @param {string} userID: The User ID
119128
*/
@@ -125,6 +134,7 @@ export default (apiUrl: string) => ({
125134

126135
/**
127136
* Updates the details of a User object.
137+
* @deprecated Use PwlUser APIs
128138
* @param authToken - The login token
129139
* @param userID - The user ID
130140
* @returns The user object
@@ -145,6 +155,7 @@ export default (apiUrl: string) => ({
145155
* If found, the User receives a verification code via e-mail.
146156
* The code must be sent via the ResetConfirm API, passing the same User object
147157
* sent to this API with the addition of the verification code and the new password.
158+
* @deprecated Use PwlUser APIs
148159
* @param {User} user - The user object
149160
*/
150161
resetPassword: (user: User) =>
@@ -156,6 +167,7 @@ export default (apiUrl: string) => ({
156167

157168
/**
158169
* Confirms the password reset of a User and performs a Login
170+
* @deprecated Use PwlUser APIs
159171
* @param {User} user - The user object
160172
*/
161173
resetConfirm: (user: User) =>
@@ -173,6 +185,7 @@ export default (apiUrl: string) => ({
173185

174186
/**
175187
* Recovers a User's name and sends it to their configured e-mail.
188+
* @deprecated Use PwlUser APIs
176189
* @param {User} user - The user object
177190
*/
178191
recoverUsername: (user: User) =>
@@ -184,6 +197,7 @@ export default (apiUrl: string) => ({
184197

185198
/**
186199
* Re-sends the verification code to confirm a pending User registration.
200+
* @deprecated Use PwlUser APIs
187201
* @param {User} user - The user object
188202
*/
189203
resendVerificationCode: (user: Partial<User>) =>
@@ -195,6 +209,7 @@ export default (apiUrl: string) => ({
195209

196210
/**
197211
* Registers a new user.
212+
* @deprecated Use PwlUser APIs
198213
* @param {User} user - The user object
199214
*/
200215
createUser: (authToken: string, user: Partial<User>) =>
@@ -206,10 +221,13 @@ export default (apiUrl: string) => ({
206221

207222
/**
208223
* Refreshes a temporary session token for a user just logged or created.
224+
* @deprecated Use PwlUser APIs
209225
* @param refreshTemporarySessionSpecs - The refresh temporary session specifications
210226
* @returns The refreshed session details
211227
*/
212-
refreshTemporarySession: (refreshTemporarySessionSpecs: RefreshTemporarySessionRequest) =>
228+
refreshTemporarySession: (
229+
refreshTemporarySessionSpecs: RefreshTemporarySessionRequest
230+
) =>
213231
apiFetcher('/RefreshTemporarySession', {
214232
apiUrl,
215233
body: refreshTemporarySessionSpecs,

0 commit comments

Comments
 (0)