Skip to content

fix: fix NSID validation function #97

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 13, 2025
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: 2 additions & 2 deletions packages/client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

## ⚠️ tsky is still in development and is not ready for production use

tsky is still in active development and is not ready for production use. If you want to contribute to the project, please read the [CONTRIBUTING.md](CONTRIBUTING.md) file or join our [Discord Server](https://discord.gg/KPD7XPUZn3).
tsky is still in active development and is not ready for production use. If you want to contribute to the project, please read the [CONTRIBUTING.md](../../CONTRIBUTING.md) file or join our [Discord Server](https://discord.gg/KPD7XPUZn3).

tsky is a lightweight, fast, universal and typed Bluesky API wrapper for Apps & Bots. It's designed to be easy to use, lightweight and straightforward to use. It's built with TypeScript and has full type support.

Expand Down Expand Up @@ -77,7 +77,7 @@ const user_profile = await agent.user.profile();

## Contributing

If you want to contribute to this project, please read the [CONTRIBUTING.md](CONTRIBUTING.md) file.
If you want to contribute to this project, please read the [CONTRIBUTING.md](../../CONTRIBUTING.md) file.

## License

Expand Down
20 changes: 18 additions & 2 deletions packages/lex-cli/src/generator/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,9 +368,25 @@ export const userTypeSchema = t.isOneOf([

export type UserTypeSchema = t.InferType<typeof userTypeSchema>;

/**
* represents a namespace identifier (NSID)
*/
export type Nsid = `${string}.${string}.${string}`;

const NSID_RE =
/^[a-z](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)+\.[a-z]{1,63}$/i;
const nsidType = t.cascade(t.isString(), (value) => NSID_RE.test(value));
/^[a-zA-Z](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+\.[a-zA-Z][a-zA-Z0-9]{0,62}?$/;

// #__NO_SIDE_EFFECTS__
export const isNsid = (input: unknown): input is Nsid => {
return (
typeof input === 'string' &&
input.length >= 5 &&
input.length <= 317 &&
NSID_RE.test(input)
);
};

const nsidType = t.cascade(t.isString(), (value) => isNsid(value));

export const documentSchema = t.cascade(
t.isObject({
Expand Down