Skip to content

Commit

Permalink
refactor(core): rename account prefix to my-account
Browse files Browse the repository at this point in the history
  • Loading branch information
wangsijie committed Nov 19, 2024
1 parent 9a3f78d commit 7bc8d2a
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 244 deletions.
2 changes: 1 addition & 1 deletion packages/core/src/routes/account/constants.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const accountApiPrefix = '/account';
export const accountApiPrefix = '/my-account';
16 changes: 8 additions & 8 deletions packages/core/src/routes/account/index.openapi.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"tags": [
{
"name": "Account",
"name": "My account",
"description": "Account routes provide functionality for managing user profile for the end user to interact directly with access tokens."
}
],
"paths": {
"/api/account": {
"/api/my-account": {
"get": {
"operationId": "GetProfile",
"summary": "Get profile",
Expand Down Expand Up @@ -53,7 +53,7 @@
}
}
},
"/api/account/profile": {
"/api/my-account/profile": {
"patch": {
"operationId": "UpdateOtherProfile",
"summary": "Update other profile",
Expand Down Expand Up @@ -111,7 +111,7 @@
}
}
},
"/api/account/password": {
"/api/my-account/password": {
"post": {
"operationId": "UpdatePassword",
"summary": "Update password",
Expand Down Expand Up @@ -139,7 +139,7 @@
}
}
},
"/api/account/primary-email": {
"/api/my-account/primary-email": {
"post": {
"operationId": "UpdatePrimaryEmail",
"summary": "Update primary email",
Expand Down Expand Up @@ -183,7 +183,7 @@
}
}
},
"/api/account/primary-phone": {
"/api/my-account/primary-phone": {
"post": {
"operationId": "UpdatePrimaryPhone",
"summary": "Update primary phone",
Expand Down Expand Up @@ -227,7 +227,7 @@
}
}
},
"/api/account/identities": {
"/api/my-account/identities": {
"post": {
"operationId": "AddUserIdentities",
"summary": "Add a user identity",
Expand All @@ -252,7 +252,7 @@
}
}
},
"/api/account/identities/{target}": {
"/api/my-account/identities/{target}": {
"delete": {
"operationId": "DeleteIdentity",
"summary": "Delete a user identity",
Expand Down
7 changes: 6 additions & 1 deletion packages/core/src/routes/swagger/utils/documents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@ const managementApiIdentifiableEntityNames = Object.freeze([

/** Additional tags that cannot be inferred from the path. */
const additionalTags = Object.freeze(
condArray<string>('Organization applications', 'Custom UI assets', 'Organization users')
condArray<string>(
'Organization applications',
'Custom UI assets',
'Organization users',
'My account'
)
);

export const buildManagementApiBaseDocument = (
Expand Down
7 changes: 5 additions & 2 deletions packages/core/src/routes/swagger/utils/operation-id.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import pluralize from 'pluralize';

import { EnvSet } from '#src/env-set/index.js';

import { accountApiPrefix } from '../../account/constants.js';
import { verificationApiPrefix } from '../../verification/index.js';

import { shouldThrow } from './general.js';

const chunk = <T>(array: T[], chunkSize: number): T[][] =>
Expand Down Expand Up @@ -124,8 +127,8 @@ const exceptionPrefixes = Object.freeze([
'/interaction',
'/experience',
'/sign-in-exp/default/check-password',
'/account',
'/verifications',
accountApiPrefix,
verificationApiPrefix,
]);

const isPathParameter = (segment?: string) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const updatePassword = async (
verificationRecordId: string,
password: string
) =>
api.post('api/account/password', {
api.post('api/my-account/password', {
json: { password },
headers: { [verificationRecordIdHeader]: verificationRecordId },
});
Expand All @@ -19,13 +19,13 @@ export const updatePrimaryEmail = async (
verificationRecordId: string,
newIdentifierVerificationRecordId: string
) =>
api.post('api/account/primary-email', {
api.post('api/my-account/primary-email', {
json: { email, newIdentifierVerificationRecordId },
headers: { [verificationRecordIdHeader]: verificationRecordId },
});

export const deletePrimaryEmail = async (api: KyInstance, verificationRecordId: string) =>
api.delete('api/account/primary-email', {
api.delete('api/my-account/primary-email', {
headers: { [verificationRecordIdHeader]: verificationRecordId },
});

Expand All @@ -35,13 +35,13 @@ export const updatePrimaryPhone = async (
verificationRecordId: string,
newIdentifierVerificationRecordId: string
) =>
api.post('api/account/primary-phone', {
api.post('api/my-account/primary-phone', {
json: { phone, newIdentifierVerificationRecordId },
headers: { [verificationRecordIdHeader]: verificationRecordId },
});

export const deletePrimaryPhone = async (api: KyInstance, verificationRecordId: string) =>
api.delete('api/account/primary-phone', {
api.delete('api/my-account/primary-phone', {
headers: { [verificationRecordIdHeader]: verificationRecordId },
});

Expand All @@ -50,7 +50,7 @@ export const updateIdentities = async (
verificationRecordId: string,
newIdentifierVerificationRecordId: string
) =>
api.post('api/account/identities', {
api.post('api/my-account/identities', {
json: { newIdentifierVerificationRecordId },
headers: { [verificationRecordIdHeader]: verificationRecordId },
});
Expand All @@ -60,15 +60,17 @@ export const deleteIdentity = async (
target: string,
verificationRecordId: string
) =>
api.delete(`api/account/identities/${target}`, {
api.delete(`api/my-account/identities/${target}`, {
headers: { [verificationRecordIdHeader]: verificationRecordId },
});

export const updateUser = async (api: KyInstance, body: Record<string, unknown>) =>
api.patch('api/account', { json: body }).json<Partial<UserProfileResponse>>();
api.patch('api/my-account', { json: body }).json<Partial<UserProfileResponse>>();

export const updateOtherProfile = async (api: KyInstance, body: Record<string, unknown>) =>
api.patch('api/account/profile', { json: body }).json<Partial<UserProfileResponse['profile']>>();
api
.patch('api/my-account/profile', { json: body })
.json<Partial<UserProfileResponse['profile']>>();

export const getUserInfo = async (api: KyInstance) =>
api.get('api/account').json<Partial<UserProfileResponse>>();
api.get('api/my-account').json<Partial<UserProfileResponse>>();
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
updatePrimaryEmail,
updatePrimaryPhone,
updateUser,
} from '#src/api/profile.js';
} from '#src/api/my-account.js';
import { createVerificationRecordByPassword } from '#src/api/verification-record.js';
import { expectRejects } from '#src/helpers/index.js';
import {
Expand Down Expand Up @@ -40,7 +40,7 @@ describe('account center fields disabled', () => {
});
});

it('should return only name in GET /account', async () => {
it('should return only name in GET /my-account', async () => {
const { user, username, password } = await createDefaultTenantUserWithPassword();
const api = await signInAndGetUserApi(username, password, {
scopes: [UserScope.Email],
Expand Down
Loading

0 comments on commit 7bc8d2a

Please sign in to comment.