{"id":23732456,"url":"https://github.com/nikoksr/typeid-zig","last_synced_at":"2025-06-18T07:42:57.294Z","repository":{"id":269585316,"uuid":"907863360","full_name":"nikoksr/typeid-zig","owner":"nikoksr","description":"Type-safe, K-sortable, globally unique identifier inspired by Stripe IDs implemented in Zig.","archived":false,"fork":false,"pushed_at":"2025-04-09T15:56:10.000Z","size":51,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-24T00:11:36.637Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Zig","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nikoksr.png","metadata":{"files":{"readme":"README.md","changelog":null,"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,"zenodo":null}},"created_at":"2024-12-24T15:25:11.000Z","updated_at":"2025-04-09T15:56:12.000Z","dependencies_parsed_at":null,"dependency_job_id":"7b46cd88-1c6a-4e23-931d-5bd9819f0f78","html_url":"https://github.com/nikoksr/typeid-zig","commit_stats":null,"previous_names":["nikoksr/typeid-zig"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/nikoksr/typeid-zig","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikoksr%2Ftypeid-zig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikoksr%2Ftypeid-zig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikoksr%2Ftypeid-zig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikoksr%2Ftypeid-zig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nikoksr","download_url":"https://codeload.github.com/nikoksr/typeid-zig/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikoksr%2Ftypeid-zig/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260513683,"owners_count":23020568,"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":[],"created_at":"2024-12-31T04:18:10.477Z","updated_at":"2025-06-18T07:42:52.271Z","avatar_url":"https://github.com/nikoksr.png","language":"Zig","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n\u0026nbsp;\n\u003ch1\u003etypeid-zig\u003c/h1\u003e\n\u003cp\u003e\u003ci\u003eType-safe, K-sortable, globally unique identifier inspired by Stripe IDs implemented in Zig.\u003c/i\u003e\u003c/p\u003e\n\n\u0026nbsp;\n\n[![Zig](https://img.shields.io/badge/Zig-0.13.0-orange.svg)](https://ziglang.org/)\n![CI](https://github.com/nikoksr/typeid-zig/actions/workflows/ci.yml/badge.svg)\n\n\u003c/div\u003e\n\n\u0026nbsp;\n\n## About\n\nImplementation of Type-IDs in Zig. Implemented as described by the official specification:\n\n- [Type-ID specification](https://github.com/jetify-com/typeid/tree/main/spec)\n\nThis implementation is part of the [official list of community provided TypeID implementations](https://github.com/jetify-com/typeid?tab=readme-ov-file#community-provided-implementations).\n\n## What are Type-IDs?\n\nAs per the official specification:\n\nTypeIDs are a modern, type-safe extension of UUIDv7. Inspired by a similar use of prefixes\nin Stripe's APIs.\n\nTypeIDs are canonically encoded as lowercase strings consisting of three parts:\n\n1. A type prefix (at most 63 characters in all lowercase snake_case ASCII [a-z_]).\n2. An underscore '\\_' separator\n3. A 128-bit UUIDv7 encoded as a 26-character string using a modified base32 encoding.\n\nHere's an example of a TypeID of type `user`:\n\n```\nuser_2x4y6z8a0b1c2d3e4f5g6h7j8k\n  │    │\n  │    └── 26-character base32-encoded UUIDv7\n  │\n  └── Type prefix (snake_case [a-z_])\n        Max length: 63 characters\n```\n\nA [formal specification](https://github.com/jetify-com/typeid/tree/main/spec) defines the encoding in more detail.\n\n## Installation\n\n1. Add as a dependency in your `build.zig.zon`:\n\n```bash\nzig fetch --save git+https://github.com/nikoksr/typeid-zig#main\n```\n\n2. In your `build.zig`, add the `typeid` module as a dependency:\n\n```zig\nconst typeid = b.dependency(\"typeid\", .{\n    .target = target,\n    .optimize = optimize,\n});\n\nexe.root_module.addImport(\"typeid\", typeid.module(\"typeid\"));\n```\n\n## Usage\n\n```zig\nconst typeid = @import(\"typeid\");\nconst TypeID = typeid.TypeID;\nconst StringBuf = typeid.StringBuf;\n\n// Create a new TypeID with prefix\nconst tid = try TypeID.init(\"user\");\n\n// Get string representation.\n// StringBuf is simply a convenience buffer that's big enough to hold a TypeID of any size.\n//     =\u003e pub const StringBuf = [90]u8;\nvar str_buf: StringBuf = undefined;\nconst str = tid.toString(\u0026str_buf); // \"user_01h455vb4pex5vsknk084sn02q\"\n\n// Parse existing TypeID string\nconst parsed = try TypeID.fromString(\"post_01h455vb4pex5vsknk084sn02q\");\n```\n\n## Tests\n\n```bash\nzig build test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnikoksr%2Ftypeid-zig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnikoksr%2Ftypeid-zig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnikoksr%2Ftypeid-zig/lists"}