Skip to content

Commit cb03952

Browse files
authored
fix(lexicons): support tid and record-key format in object property (#70)
1 parent a291257 commit cb03952

File tree

6 files changed

+22
-4
lines changed

6 files changed

+22
-4
lines changed

packages/lex-cli/src/generator/resolvers/string.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
import type { StringSchema } from '../schema.js';
21
import { IGNORED_FORMATS, TYPE_FORMATS, sortName } from '../../utils/index.js';
2+
import type { StringSchema } from '../schema.js';
33

44
export function resolveStringFormat(format: string, nsid: string): string {
55
if (format === 'did') return TYPE_FORMATS.DID;
66
if (format === 'cid') return TYPE_FORMATS.CID;
77
if (format === 'handle') return TYPE_FORMATS.HANDLE;
88
if (format === 'at-uri') return TYPE_FORMATS.URI;
9+
if (format === 'tid') return TYPE_FORMATS.TID;
10+
if (format === 'record-key') return TYPE_FORMATS.RKEY;
911
if (IGNORED_FORMATS.has(format)) return 'string';
1012

1113
console.warn(`${nsid}: unknown format ${format}`);

packages/lex-cli/src/generator/schema.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,11 @@ export const stringSchema: t.StrictValidator<
9494
maxGraphemes?: number;
9595
minGraphemes?: number;
9696
} => {
97-
if (value.format !== undefined && value.format !== 'uri') {
97+
if (
98+
value.format !== undefined &&
99+
value.format !== 'uri' &&
100+
value.format !== 'record-key'
101+
) {
98102
if (
99103
value.maxLength !== undefined ||
100104
value.minLength !== undefined ||

packages/lex-cli/src/utils/formats.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ export const TYPE_FORMATS = {
33
CID: 'At.CID',
44
HANDLE: 'At.Handle',
55
URI: 'At.Uri',
6+
TID: 'At.TID',
7+
RKEY: 'At.RKEY',
68
} as const;
79

810
export const IGNORED_FORMATS = new Set([

packages/lex-cli/src/utils/prelude.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,13 @@ export declare namespace At {
3333
type Handle = string;
3434
3535
/** URI string */
36-
type Uri = string;
36+
type Uri = string;
37+
38+
/** TID string */
39+
type TID = string;
40+
41+
/** RKEY string */
42+
type RKEY = string;
3743
3844
/** Object containing a CID string */
3945
interface CIDLink {
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"extends": "../tsconfig.json",
3+
"include": "*.ts"
4+
}

packages/lexicons/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@
1313
"skipLibCheck": true
1414
},
1515
"include": ["index.ts", "src/**/*"],
16-
"exclude": ["node_modules", "dist", "scripts"]
16+
"exclude": ["node_modules", "dist"]
1717
}

0 commit comments

Comments
 (0)