Skip to content

Commit 30b6643

Browse files
committed
refactor: brand api key ids in bindings
1 parent 25ea5d4 commit 30b6643

3 files changed

Lines changed: 12 additions & 2 deletions

File tree

packages/bindings/src/clob/api-key.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { z } from 'zod';
2+
import { ApiKeySchema } from '../shared';
23

34
export const RawApiKeyCredsSchema = z.object({
4-
apiKey: z.string(),
5+
apiKey: ApiKeySchema,
56
secret: z.string(),
67
passphrase: z.string(),
78
});
@@ -15,7 +16,7 @@ export const ApiKeyCredsSchema = RawApiKeyCredsSchema.transform((creds) => ({
1516
export type ApiKeyCreds = z.infer<typeof ApiKeyCredsSchema>;
1617

1718
export const ApiKeysResponseSchema = z.object({
18-
apiKeys: z.array(z.string()),
19+
apiKeys: z.array(ApiKeySchema),
1920
});
2021

2122
export type ApiKeysResponse = z.infer<typeof ApiKeysResponseSchema>;

packages/bindings/src/shared.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import {
2+
type ApiKey,
23
type CategoryId,
34
type ClobRewardId,
45
type EventId,
56
type ImageOptimizationId,
67
type InternalUserId,
78
type MarketId,
89
type TagId,
10+
toApiKey,
911
toCategoryId,
1012
toClobRewardId,
1113
toEventId,
@@ -17,6 +19,7 @@ import {
1719
import { z } from 'zod';
1820

1921
export const CategoryIdSchema = z.string().transform(toCategoryId);
22+
export const ApiKeySchema = z.string().transform(toApiKey);
2023
export const ClobRewardIdSchema = z.string().transform(toClobRewardId);
2124
export const EventIdSchema = z.string().transform(toEventId);
2225
export const ISODateStringSchema = z
@@ -36,6 +39,7 @@ export type ISODateString = z.output<typeof ISODateStringSchema>;
3639
export type ISOCalendarDateString = z.output<typeof ISOCalendarDateSchema>;
3740

3841
export type {
42+
ApiKey,
3943
CategoryId,
4044
ClobRewardId,
4145
EventId,

packages/types/src/ids.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ function toTaggedInteger<T extends number>(value: number): T {
1313
}
1414

1515
export type BestLineId = Tagged<string, 'BestLineId'>;
16+
export type ApiKey = Tagged<Uuid, 'ApiKey'>;
1617
export type CategoryId = Tagged<string, 'CategoryId'>;
1718
export type ChatId = Tagged<string, 'ChatId'>;
1819
export type ClobRewardId = Tagged<string, 'ClobRewardId'>;
@@ -32,9 +33,12 @@ export type SportId = Tagged<number, 'SportId'>;
3233
export type TagId = Tagged<string, 'TagId'>;
3334
export type TeamId = Tagged<number, 'TeamId'>;
3435
export type TemplateId = Tagged<string, 'TemplateId'>;
36+
export type Uuid = Tagged<string, 'Uuid'>;
3537

3638
export const toBestLineId = (value: string): BestLineId =>
3739
toTaggedString<BestLineId>(value);
40+
export const toApiKey = (value: string): ApiKey =>
41+
toTaggedString<ApiKey>(value);
3842
export const toCategoryId = (value: string): CategoryId =>
3943
toTaggedString<CategoryId>(value);
4044
export const toChatId = (value: string): ChatId =>
@@ -68,3 +72,4 @@ export const toTeamId = (value: number): TeamId =>
6872
toTaggedInteger<TeamId>(value);
6973
export const toTemplateId = (value: string): TemplateId =>
7074
toTaggedString<TemplateId>(value);
75+
export const toUuid = (value: string): Uuid => toTaggedString<Uuid>(value);

0 commit comments

Comments
 (0)