{"id":23252626,"url":"https://github.com/biyuehu/tsukiko","last_synced_at":"2025-08-20T10:33:28.859Z","repository":{"id":210249201,"uuid":"725946462","full_name":"BIYUEHU/tsukiko","owner":"BIYUEHU","description":"Types Check And Parse In The Runtime Base On TypeScript","archived":false,"fork":false,"pushed_at":"2024-07-24T12:15:29.000Z","size":248,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-11-19T04:00:18.740Z","etag":null,"topics":["dto","dto-generator","dto-pattern","tools","type-checker","types","typescript","utils","zod"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BIYUEHU.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-12-01T07:49:43.000Z","updated_at":"2024-09-16T16:18:35.000Z","dependencies_parsed_at":"2023-12-01T16:27:38.407Z","dependency_job_id":"6b8fdb01-736d-44f5-b2e0-88acb106718b","html_url":"https://github.com/BIYUEHU/tsukiko","commit_stats":null,"previous_names":["biyuehu/tsukiko"],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BIYUEHU%2Ftsukiko","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BIYUEHU%2Ftsukiko/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BIYUEHU%2Ftsukiko/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BIYUEHU%2Ftsukiko/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BIYUEHU","download_url":"https://codeload.github.com/BIYUEHU/tsukiko/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230406934,"owners_count":18220882,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dto","dto-generator","dto-pattern","tools","type-checker","types","typescript","utils","zod"],"created_at":"2024-12-19T10:17:25.781Z","updated_at":"2024-12-19T10:17:26.449Z","avatar_url":"https://github.com/BIYUEHU.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!-- markdown-lint-disable --\u003e\n\u003cdiv align=\"center\"\u003e\n\n# Tsukiko\n\n![npm](https://img.shields.io/npm/v/tsukiko) ![GitHub License](https://img.shields.io/github/license/biyuehu/tsukiko?color=blue) ![GitHub last commit (by committer)](https://img.shields.io/github/last-commit/biyuehu/tsukiko)\n\n**⚡ Dynamic Types Cheker At Runtime Which Develop Base On TypeScript ⚡**\n\n[Tsukiko Docs](docs/README.md)\n\n\u003c/div\u003e\n\n## 📃 Install\n\n- NPM\n\n```bash\nnpm install tsukiko\n```\n\n- YAYN\n\n```bash\nyarn add tsukiko\n```\n\n- PNPM\n\n```bash\npnpm install tsukiko\n```\n\n## 🎯 Internationalization\n\n- English\n- 日本語 (Japanese)\n- 繁體中文 (Traditional Chinese)\n- 简体中文（Simplified Chinese）\n\n## 🚀 Parser\n\n- `NumberParser`\n- `StringParser`\n- `BooleanParser`\n- `NullParser`\n- `UndefinedParser`\n- `AnyParser`\n- `UnknownParser`\n- `NeverParser`\n- `ArrayParser`\n- `TupleParser`\n- `ObjectParser`\n- `EnumParser`\n- `LiteralParser`\n- `IntersectionParser`\n- `UnionParser`\n- `CustomParser`\n- `FunctionParser`\n- `ClassParser`\n\n## 🛠️ Tools\n\n- ParserInfer\n- tsuFactory\n- TsuError\n\n## 📝 Json-Schema\n\nAll parsers' methods which are supported list:\n\n- `NumberParser`\n  - `int()`\n  - `multiple()`\n  - `natural()`\n  - `positive()`\n  - `negative()`\n  - `percent()`\n  - `port()`\n- `StringParser`\n  - `regexp()`\n  - `email()`\n  - `domain()`\n  - `url()`\n  - `max()`\n  - `min()`\n  - `range()`\n- `BooleanParser`\n  - Fully support\n- `NullParser`\n  - Fully support\n- `ArrayParser`\n  - Fully support\n- `TupleParser`\n  - Fully support\n- `ObjectParser`\n  - `strict()`\n  - `index()`\n  - `max()`\n  - `min()`\n  - `range()`\n- `EnumParser`\n  - Only support literal values (string, number, boolean constants)\n- `LiteralParser`\n  - Fully support\n- `IntersectionParser`\n  - Fully support\n- `UnionParser`\n  - Fully support\n\nThe parsers and methods which no listed are all not supported.\n\n## 🌰 Example\n\n```typescript\n// example/example1.ts\nimport Tsu, { tsuFactory } from \"tsukiko\";\n\nconst schema = Tsu.Tuple([Tsu.Number()]);\nexport type Schema = Tsu.infer\u003ctypeof schema\u003e;\n\nconst schema2 = Tsu.Array(Tsu.String());\nexport type Schema2 = Tsu.infer\u003ctypeof schema2\u003e;\n\nconst schema3 = Tsu.Object({\n  value: Tsu.Number(),\n  name: schema2,\n  host: Tsu.String().regexp(/http(s)?:\\/\\/(.*)/),\n  port: Tsu.Number().range(1, 65565).int(),\n  allowList: Tsu.Array(Tsu.String()),\n  listType: Tsu.Union([Tsu.Literal(\"include\"), Tsu.Literal(\"exclude\")]),\n});\n\nexport type Schema3 = Tsu.infer\u003ctypeof schema3\u003e;\n\nconst schema4 = Tsu.Intersection([Tsu.Number(), Tsu.Literal(1)]);\nexport type Schema4 = Tsu.infer\u003ctypeof schema4\u003e;\n\nconst schema5 = Tsu.Intersection([\n  Tsu.Literal(\"hello world\"),\n  Tsu.Union([schema, Tsu.Union([Tsu.Number().optional(), schema2])]),\n]);\nexport type Schema5 = Tsu.infer\u003ctypeof schema5\u003e;\n\nconst schema6 = Tsu.Object({}).index(\n  Tsu.String().regexp(/[0-9]+\\.[0-9]+\\.[0-9]+/),\n  Tsu.String().regexp(/kotori-plugin-(.*)/)\n);\n\nexport type Schema6 = Tsu.infer\u003ctypeof schema6\u003e;\nexport const example6: Schema6 = {\n  \"kotori-plugin-adapter-qq\": \"1.5.0\",\n  \"kotori-plugin-adapter-wechat\": \"0.2.0\",\n  \"kotori-plugin-database-sqlite\": \"2.1.0\",\n  \"kotori-plugin-database-mysql\": \"3.1.0\",\n  \"kotori-plugin-help\": \"1.2.0\",\n  \"kotori-plugin-wiki\": \"1.0.0\",\n};\n\nconst newTsu = tsuFactory(\"ja_JP\");\n\nexport const localeTypeSchema = newTsu.Union([\n  newTsu.Union([newTsu.Literal(\"en_US\"), newTsu.Literal(\"ja_JP\")]),\n  newTsu.Union([newTsu.Literal(\"zh_CN\"), newTsu.Literal(\"zh_TW\")]),\n]);\n\nconst globalConfigBaseSchema = newTsu.Object({\n  lang: localeTypeSchema.default(\"ja_JP\"),\n  \"command-prefix\": newTsu.String().default(\"/\"),\n});\n\nconst adapterConfigBaseSchema = newTsu.Intersection([\n  newTsu.Object({\n    extends: newTsu.String(),\n    master: newTsu.Union([newTsu.Number(), newTsu.String()]),\n  }),\n  globalConfigBaseSchema,\n]);\n\nexport const globalConfigSchema = newTsu.Object({\n  global: globalConfigBaseSchema,\n  adapter: newTsu.Object({}).index(adapterConfigBaseSchema).default({}),\n  plugin: newTsu.Object({}).index(newTsu.Unknown()).default({}),\n});\n\nexport type GlobalConfig = Tsu.infer\u003ctypeof globalConfigSchema\u003e;\n\nconsole.log(\n  globalConfigSchema.parse({\n    global: { lang: \"zh_CN\" },\n    adapter: { aa: { master: \"1\", lang: \"ja_JP\" } },\n  })\n);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbiyuehu%2Ftsukiko","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbiyuehu%2Ftsukiko","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbiyuehu%2Ftsukiko/lists"}