Skip to content

Commit bdbb0d9

Browse files
authored
refactor(clerk-js): Standardize API keys naming convention (#7223)
1 parent 866008c commit bdbb0d9

File tree

24 files changed

+64
-56
lines changed

24 files changed

+64
-56
lines changed

.changeset/brown-bags-fold.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@clerk/clerk-js": minor
3+
"@clerk/clerk-react": minor
4+
"@clerk/shared": minor
5+
---
6+
7+
Standardized API keys naming convention

packages/clerk-js/sandbox/app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ void (async () => {
325325
Clerk.mountPricingTable(app, componentControls.pricingTable.getProps() ?? {});
326326
},
327327
'/api-keys': () => {
328-
Clerk.mountApiKeys(app, componentControls.apiKeys.getProps() ?? {});
328+
Clerk.mountAPIKeys(app, componentControls.apiKeys.getProps() ?? {});
329329
},
330330
'/oauth-consent': () => {
331331
const searchParams = new URLSearchParams(window.location.search);

packages/clerk-js/src/core/clerk.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,11 +1226,11 @@ export class Clerk implements ClerkInterface {
12261226
/**
12271227
* @experimental This API is in early access and may change in future releases.
12281228
*
1229-
* Mount a api keys component at the target element.
1229+
* Mount a API keys component at the target element.
12301230
* @param targetNode Target to mount the APIKeys component.
12311231
* @param props Configuration parameters.
12321232
*/
1233-
public mountApiKeys = (node: HTMLDivElement, props?: APIKeysProps) => {
1233+
public mountAPIKeys = (node: HTMLDivElement, props?: APIKeysProps) => {
12341234
this.assertComponentsReady(this.#componentControls);
12351235

12361236
logger.warnOnce('Clerk: <APIKeys /> component is in early access and not yet recommended for production use.');
@@ -1277,12 +1277,12 @@ export class Clerk implements ClerkInterface {
12771277
/**
12781278
* @experimental This API is in early access and may change in future releases.
12791279
*
1280-
* Unmount a api keys component from the target element.
1280+
* Unmount a API keys component from the target element.
12811281
* If there is no component mounted at the target node, results in a noop.
12821282
*
1283-
* @param targetNode Target node to unmount the ApiKeys component from.
1283+
* @param targetNode Target node to unmount the APIKeys component from.
12841284
*/
1285-
public unmountApiKeys = (node: HTMLDivElement) => {
1285+
public unmountAPIKeys = (node: HTMLDivElement) => {
12861286
this.assertComponentsReady(this.#componentControls);
12871287
void this.#componentControls.ensureMounted().then(controls => controls.unmountComponent({ node }));
12881288
};

packages/clerk-js/src/ui/components/ApiKeys/ApiKeys.tsx renamed to packages/clerk-js/src/ui/components/APIKeys/APIKeys.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ export const APIKeysPage = ({ subject, perPage, revokeModalRoot }: APIKeysPagePr
101101
} = useSWRMutation('api-keys-create', (_key, { arg }: { arg: CreateAPIKeyParams }) => clerk.apiKeys.create(arg));
102102
const { t } = useLocalizations();
103103
const [isRevokeModalOpen, setIsRevokeModalOpen] = useState(false);
104-
const [selectedApiKeyId, setSelectedApiKeyId] = useState('');
105-
const [selectedApiKeyName, setSelectedApiKeyName] = useState('');
104+
const [selectedAPIKeyID, setSelectedAPIKeyID] = useState('');
105+
const [selectedAPIKeyName, setSelectedAPIKeyName] = useState('');
106106
const [isCopyModalOpen, setIsCopyModalOpen] = useState(false);
107107

108108
const handleCreateAPIKey = async (params: OnCreateParams) => {
@@ -123,9 +123,9 @@ export const APIKeysPage = ({ subject, perPage, revokeModalRoot }: APIKeysPagePr
123123
}
124124
};
125125

126-
const handleRevoke = (apiKeyId: string, apiKeyName: string) => {
127-
setSelectedApiKeyId(apiKeyId);
128-
setSelectedApiKeyName(apiKeyName);
126+
const handleRevoke = (apiKeyID: string, apiKeyName: string) => {
127+
setSelectedAPIKeyID(apiKeyID);
128+
setSelectedAPIKeyName(apiKeyName);
129129
setIsRevokeModalOpen(true);
130130
};
131131

@@ -220,12 +220,12 @@ export const APIKeysPage = ({ subject, perPage, revokeModalRoot }: APIKeysPagePr
220220
isOpen={isRevokeModalOpen}
221221
onOpen={() => setIsRevokeModalOpen(true)}
222222
onClose={() => {
223-
setSelectedApiKeyId('');
224-
setSelectedApiKeyName('');
223+
setSelectedAPIKeyID('');
224+
setSelectedAPIKeyName('');
225225
setIsRevokeModalOpen(false);
226226
}}
227-
apiKeyId={selectedApiKeyId}
228-
apiKeyName={selectedApiKeyName}
227+
apiKeyID={selectedAPIKeyID}
228+
apiKeyName={selectedAPIKeyName}
229229
onRevokeSuccess={invalidateAll}
230230
modalRoot={revokeModalRoot}
231231
/>

packages/clerk-js/src/ui/components/ApiKeys/RevokeAPIKeyConfirmationModal.tsx renamed to packages/clerk-js/src/ui/components/APIKeys/RevokeAPIKeyConfirmationModal.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ type RevokeAPIKeyConfirmationModalProps = {
1414
isOpen: boolean;
1515
onOpen: () => void;
1616
onClose: () => void;
17-
apiKeyId?: string;
17+
apiKeyID?: string;
1818
apiKeyName: string;
1919
onRevokeSuccess?: () => void;
2020
modalRoot?: React.MutableRefObject<HTMLElement | null>;
@@ -24,7 +24,7 @@ export const RevokeAPIKeyConfirmationModal = ({
2424
isOpen,
2525
onOpen,
2626
onClose,
27-
apiKeyId,
27+
apiKeyID,
2828
apiKeyName,
2929
onRevokeSuccess,
3030
modalRoot,
@@ -48,11 +48,11 @@ export const RevokeAPIKeyConfirmationModal = ({
4848

4949
const handleSubmit = async (e: React.FormEvent) => {
5050
e.preventDefault();
51-
if (!apiKeyId || !canSubmit) {
51+
if (!apiKeyID || !canSubmit) {
5252
return;
5353
}
5454

55-
await clerk.apiKeys.revoke({ apiKeyID: apiKeyId });
55+
await clerk.apiKeys.revoke({ apiKeyID: apiKeyID });
5656
onRevokeSuccess?.();
5757
handleClose();
5858
};

packages/clerk-js/src/ui/components/ApiKeys/__tests__/ApiKeys.spec.tsx renamed to packages/clerk-js/src/ui/components/APIKeys/__tests__/APIKeys.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { describe, expect, it, vi } from 'vitest';
33
import { bindCreateFixtures } from '@/test/create-fixtures';
44
import { render, waitFor } from '@/test/utils';
55

6-
import { APIKeys } from '../ApiKeys';
6+
import { APIKeys } from '../APIKeys';
77

88
const { createFixtures } = bindCreateFixtures('APIKeys');
99

0 commit comments

Comments
 (0)