diff --git a/packages/client/README.md b/packages/client/README.md index 5b34532..5fc6735 100644 --- a/packages/client/README.md +++ b/packages/client/README.md @@ -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. @@ -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 diff --git a/packages/lex-cli/src/generator/schema.ts b/packages/lex-cli/src/generator/schema.ts index 0f10988..abc7231 100644 --- a/packages/lex-cli/src/generator/schema.ts +++ b/packages/lex-cli/src/generator/schema.ts @@ -368,9 +368,25 @@ export const userTypeSchema = t.isOneOf([ export type UserTypeSchema = t.InferType; +/** + * 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({