Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/lex-cli/src/generator/resolvers/string.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import type { StringSchema } from '../schema.js';
import { IGNORED_FORMATS, TYPE_FORMATS, sortName } from '../../utils/index.js';
import type { StringSchema } from '../schema.js';

export function resolveStringFormat(format: string, nsid: string): string {
if (format === 'did') return TYPE_FORMATS.DID;
if (format === 'cid') return TYPE_FORMATS.CID;
if (format === 'handle') return TYPE_FORMATS.HANDLE;
if (format === 'at-uri') return TYPE_FORMATS.URI;
if (format === 'tid') return TYPE_FORMATS.TID;
if (format === 'record-key') return TYPE_FORMATS.RKEY;
if (IGNORED_FORMATS.has(format)) return 'string';

console.warn(`${nsid}: unknown format ${format}`);
Expand Down
6 changes: 5 additions & 1 deletion packages/lex-cli/src/generator/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,11 @@ export const stringSchema: t.StrictValidator<
maxGraphemes?: number;
minGraphemes?: number;
} => {
if (value.format !== undefined && value.format !== 'uri') {
if (
value.format !== undefined &&
value.format !== 'uri' &&
value.format !== 'record-key'
) {
if (
value.maxLength !== undefined ||
value.minLength !== undefined ||
Expand Down
2 changes: 2 additions & 0 deletions packages/lex-cli/src/utils/formats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ export const TYPE_FORMATS = {
CID: 'At.CID',
HANDLE: 'At.Handle',
URI: 'At.Uri',
TID: 'At.TID',
RKEY: 'At.RKEY',
} as const;

export const IGNORED_FORMATS = new Set([
Expand Down
8 changes: 7 additions & 1 deletion packages/lex-cli/src/utils/prelude.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,13 @@ export declare namespace At {
type Handle = string;

/** URI string */
type Uri = string;
type Uri = string;

/** TID string */
type TID = string;

/** RKEY string */
type RKEY = string;

/** Object containing a CID string */
interface CIDLink {
Expand Down
4 changes: 4 additions & 0 deletions packages/lexicons/scripts/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "../tsconfig.json",
"include": "*.ts"
}
2 changes: 1 addition & 1 deletion packages/lexicons/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
"skipLibCheck": true
},
"include": ["index.ts", "src/**/*"],
"exclude": ["node_modules", "dist", "scripts"]
"exclude": ["node_modules", "dist"]
}