Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
146 commits
Select commit Hold shift + click to select a range
6782ba1
chore: update dependencies and package manager
luxass Dec 28, 2025
f68b4fa
test(fs-bridge): improve error messages in encoded attack tests
luxass Dec 28, 2025
54e93e7
refactor(ui): update components for improved structure and consistency
luxass Dec 28, 2025
eb137c3
feat(web): add file explorer routes and components
luxass Dec 28, 2025
98916a9
feat(api): enhance wildcard route with query parameters
luxass Dec 28, 2025
eef3d84
fix(mock-store): ensure safe access to files in response
luxass Dec 28, 2025
6069b89
feat(web): enhance file explorer with search and filter functionality
luxass Dec 28, 2025
ac51c48
feat(web): enhance file explorer with improved filtering and sorting …
luxass Dec 28, 2025
fad8bef
feat(api): enhance wildcard route with filtering and sorting options
luxass Dec 28, 2025
ac08403
fix(web): update link to character explorer in HomePage
luxass Dec 28, 2025
a436cf9
test(fs-bridge): improve excessive encoding attack messages
luxass Dec 28, 2025
65df754
fix(web): update API base URL variable naming in production and previ…
luxass Dec 28, 2025
1279273
feat(web): refactor API base URL handling and update icons
luxass Dec 28, 2025
140e32c
chore: remove phosphor icons
luxass Dec 29, 2025
bc53a9c
feat(ucd-store-v2): add version comparison functionality
luxass Dec 29, 2025
6308a6c
refactor(web): replace phosphor icons with lucide icons
luxass Dec 29, 2025
c864129
feat(web): add new routes for codepoint inspector and comparison
luxass Dec 29, 2025
c561f6d
feat(web): add new documentation routes for API and pages
luxass Dec 29, 2025
a8d3c05
feat(web): implement server entry and context for API base URL
luxass Dec 29, 2025
86a7641
feat(web): add route for version redirection
luxass Dec 29, 2025
8964db4
feat(web): implement version management features and UI
luxass Dec 29, 2025
bce3093
feat(api): add routes for Unicode blocks, characters, and properties
luxass Dec 29, 2025
7e0d383
feat(web): enhance meta tags for improved SEO and description
luxass Dec 29, 2025
2efcbaa
feat(api): add wildcard route parameters for Unicode data access
luxass Dec 29, 2025
ac34281
feat(web): update sort parameter to use 'lastModified' in search schema
luxass Dec 29, 2025
b44f826
feat(web): update NonRenderableFile component to use fileUrl
luxass Dec 29, 2025
736de6d
chore(select): remove unnecessary whitespace in SelectScrollUpButton
luxass Dec 29, 2025
edc2db8
feat(ucd-store-v2): add comparison modes for version comparison
luxass Dec 29, 2025
b598630
feat(web): implement VersionHeader component for route pages
luxass Dec 29, 2025
da3b695
feat(web): add version display to search results
luxass Dec 29, 2025
f6649ae
feat(cli): add 'compare' subcommand for version differences
luxass Dec 29, 2025
2ebaf28
feat(cli): implement `compare` command for version comparison
luxass Dec 29, 2025
ad101a9
chore(api): add TODO comment for future fix in calculateStatistics
luxass Dec 29, 2025
87df8f8
feat(web): add recharts package version 3.6.0
luxass Dec 29, 2025
20ae935
refactor(fs-bridge): update API_BASE_URL_SCHEMA to use z.url for bett…
luxass Dec 29, 2025
b925495
feat(ucd-store-v2): ensure consistent API path for file fetching
luxass Dec 29, 2025
f6962e4
feat(lockfile): add stripUnicodeHeader and computeContentHash functions
luxass Dec 29, 2025
623d0e7
feat(web): restructure sidebar and version handling
luxass Dec 29, 2025
1b61e69
feat(api): enhance version comparison functionality
luxass Dec 29, 2025
0213393
feat(ucd-store-v2): add detailed file change information to version c…
luxass Dec 29, 2025
ee5898e
feat(web): update comparison statistics and file list display
luxass Dec 29, 2025
1f9f6a7
WIP
luxass Dec 30, 2025
ba7a2d4
chore: remove old ucd-store
luxass Dec 30, 2025
8ef33ad
chore: rename ucd-store-v2 to ucd-store
luxass Dec 30, 2025
6741907
WIP
luxass Dec 30, 2025
6da910f
WIP
luxass Dec 30, 2025
3e295a8
feat(test-utils): add support for error fields validation
luxass Dec 30, 2025
59b72ee
feat(ucd-store): add UCDStoreApiFallbackError for API fetch failures
luxass Dec 30, 2025
45f228d
test(ucd-store): add comprehensive tests for getFile function
luxass Dec 30, 2025
6a7fee9
feat(ucd-store): replace generic error with API fallback error
luxass Dec 30, 2025
2a0d0fe
test(ucd-store): add comprehensive tests for listFiles function
luxass Dec 30, 2025
45b9375
feat(ucd-store): replace generic error with API fallback error in fil…
luxass Dec 30, 2025
c377cfc
feat(ucd-store): add comprehensive tests for getFileTree function
luxass Dec 30, 2025
6e4acc1
feat(shared): add TreeNode interface and file path utilities
luxass Dec 31, 2025
896dc9e
feat(fs-bridge): update @luxass/msw-utils to version 0.6.0
luxass Dec 31, 2025
0b51068
feat(test-utils): enhance file retrieval logic in mock API
luxass Dec 31, 2025
74a5986
feat(shared): enhance findFileByPath function and tests
luxass Dec 31, 2025
3c55776
feat(test-utils): enhance file response handling in mock API
luxass Dec 31, 2025
489a9d9
refactor(ucd-store): reorder imports for clarity and consistency
luxass Dec 31, 2025
e613f3c
refactor(test-utils): simplify stripContent function to remove childr…
luxass Dec 31, 2025
74ddf9b
test(ucd-store): add HTTP & NODE integration tests for file operations
luxass Dec 31, 2025
1cefe85
feat(ucd-store): add isUCDStoreInternalContext function and refactor …
luxass Dec 31, 2025
794e423
chore(ucd-store): update parameter descriptions in analyze and mirror…
luxass Dec 31, 2025
3ba7aa8
feat(cli): add lockfile command and related options
luxass Dec 31, 2025
f60d5c1
feat(cli): add 'info' subcommand for lockfile details
luxass Dec 31, 2025
c483b3e
feat(cli): add formatBytes utility for byte formatting
luxass Dec 31, 2025
916753a
feat(test-utils): add stripUcdPrefix function to handle file paths
luxass Dec 31, 2025
f422a49
feat(cli): enhance output structure in store comparison
luxass Dec 31, 2025
83a87c3
feat(cli): add 'hash' subcommand for computing file hashes
luxass Dec 31, 2025
8938a4e
chore: add TypeScript SDK configuration settings
luxass Dec 31, 2025
f5243d1
feat(cli): enhance lockfile info output with filters
luxass Dec 31, 2025
6f8ebe2
feat(cli): add 'validate' subcommand for lockfile validation
luxass Dec 31, 2025
84f2024
feat(lockfile): add lockfile validation function and schema updates
luxass Dec 31, 2025
8a31ce2
refactor(lockfile): rename `readLockfileOrDefault` to `readlockfileOr…
luxass Dec 31, 2025
86da36b
test(lockfile): add comprehensive validation tests for lockfile
luxass Dec 31, 2025
971c0eb
feat(fs-bridge): add error handling module and update dependencies
luxass Dec 31, 2025
1b761ab
test(lockfile): add unit tests for snapshot read/write operations
luxass Dec 31, 2025
94fdf10
WIP
luxass Dec 31, 2025
457a8e0
test(cli): add mock responses for ucd-config.json in tests
luxass Dec 31, 2025
2996468
test(cli): update log capture methods in lockfile tests
luxass Dec 31, 2025
d4a5469
test(cli): add mock responses for ucd-config.json in tests
luxass Dec 31, 2025
ded2956
refactor(cli): replace log with info for output consistency
luxass Jan 1, 2026
6b28241
refactor(cli): replace `info` method with `log` for output
luxass Jan 1, 2026
982c7e7
WIP
luxass Jan 1, 2026
942be0f
WIP
luxass Jan 1, 2026
65a9a0c
WIP
luxass Jan 1, 2026
67a2909
WIP
luxass Jan 1, 2026
b864db4
chore: upgrade apache autoindex parse
luxass Jan 1, 2026
a803fc5
chore: update apache-autoindex-parse
luxass Jan 1, 2026
10c12cd
fix(api): fallback to /
luxass Jan 1, 2026
2aae8c3
feat(api): add version retrieval and file tree endpoints
luxass Jan 1, 2026
643da49
refactor(shared): update TreeNode to UnicodeTreeNode in file functions
luxass Jan 1, 2026
0f5ae1c
feat(test-utils): add `toMatchSchema` matcher for schema validation
luxass Jan 1, 2026
2699014
refactor(schemas): simplify schema definitions and improve clarity
luxass Jan 1, 2026
63c6318
test(schemas): add comprehensive tests for schemas validation
luxass Jan 1, 2026
d7308e0
refactor(test-utils): simplify file node handling functions
luxass Jan 1, 2026
6c661ea
WIP
luxass Jan 1, 2026
a6a28d9
refactor(hash): simplify header line detection logic
luxass Jan 1, 2026
66de976
chore(lockfile): remove obsolete path tests
luxass Jan 1, 2026
7a8b6c0
refactor(lockfile): improve header line regex validation
luxass Jan 1, 2026
7c3a6c0
chore: update '@unicode-utils/core' to 0.12.0-beta.19
luxass Jan 1, 2026
fd13411
refactor(api): update logger import path in get.ts
luxass Jan 1, 2026
b4c46b6
refactor(schemas): simplify type definitions and imports
luxass Jan 1, 2026
9dcfd8e
refactor(shared): update type definitions for file functions
luxass Jan 1, 2026
a93163d
refactor(store): reorganize imports and enhance listFiles test
luxass Jan 1, 2026
b121531
refactor(api): enhance JSON schema generation with error handling
luxass Jan 2, 2026
9f8d0ba
feat(test-utils): add default content for files
luxass Jan 2, 2026
f5bdb93
refactor(test-utils): simplify file handling and improve mock responses
luxass Jan 2, 2026
2b60b29
chore: lint
luxass Jan 2, 2026
81da6ae
feat(api): update routes to include version parameter
luxass Jan 2, 2026
ea9dede
chore: lint
luxass Jan 2, 2026
027cdfa
feat(shared): add FetchSchemaValidationError for schema validation er…
luxass Jan 2, 2026
dcb0ba8
refactor(client): update base URL and add lastModified to file entries
luxass Jan 2, 2026
d466790
fix(lockfile): correct regex for header line check
luxass Jan 2, 2026
ca712cd
refactor(ucd-store): update version handling and file paths in tests
luxass Jan 2, 2026
5b0622c
refactor(ucd-store): update version handling and API responses in tests
luxass Jan 2, 2026
b3cdbc4
feat(test-utils): add path handling for mock store nodes
luxass Jan 2, 2026
12c1199
chore: lint
luxass Jan 2, 2026
b51c4ee
chore: remove unused fn
luxass Jan 2, 2026
4c3d590
WIP
luxass Jan 2, 2026
f46b90a
chore: update readme for frontend
luxass Jan 2, 2026
3ac48b0
chore: update usage instructions in README
luxass Jan 3, 2026
c73a83f
feat(schemas): add validation for directory node properties
luxass Jan 3, 2026
7758cb3
feat(api): cast result to UnicodeTree in file tree route
luxass Jan 3, 2026
1e3d39f
feat(api): trim whitespace from text-based responses
luxass Jan 3, 2026
a0ce0d2
feat(test-utils): enhance file tree handling and responses
luxass Jan 3, 2026
f486207
feat(test-utils): enhance path handling in addPathsToFileNodes
luxass Jan 3, 2026
a250711
refactor(api): simplify return structure in parseUnicodeDirectory
luxass Jan 3, 2026
9271e9d
feat(schemas): enhance FileEntrySchema validation for paths
luxass Jan 3, 2026
9516402
refactor(schemas): rename UnicodeTreeNode to UnicodeFileTreeNode
luxass Jan 3, 2026
fc55d93
chore: upgrade zod
luxass Jan 4, 2026
2a3baa1
refactor(vitest): enhance createProjects function with options
luxass Jan 4, 2026
71b9a3e
refactor(shared): update example in flattenFilePaths documentation
luxass Jan 4, 2026
93d4e27
feat(test-utils): add new response matchers for API validation
luxass Jan 4, 2026
dbf3f03
test(api): update tests for Unicode version handling
luxass Jan 4, 2026
76d6066
feat(api): add contract tests for msw file-tree handler
luxass Jan 4, 2026
4ac07ad
chore: fix docs
luxass Jan 4, 2026
516ad89
chore: lint
luxass Jan 4, 2026
733f44c
refactor(test-utils): reorganize response matchers and remove unused …
luxass Jan 4, 2026
6a18668
refactor(test-utils): improve response handling and schema validation
luxass Jan 4, 2026
6963334
test(api): enhance error handling and add HEAD request tests
luxass Jan 4, 2026
b8017d2
refactor(api): cleanup the wildcard route
luxass Jan 4, 2026
c739ef2
test(api): enhance file request tests and error handling
luxass Jan 4, 2026
d0a3a43
refactor(test-utils): trim whitespace in default file contents
luxass Jan 4, 2026
545da6e
refactor(test-utils): enhance file response handling and headers
luxass Jan 4, 2026
2767ef5
test(api): improve size header checks in MSW tests
luxass Jan 4, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,7 @@
},
"files.readonlyInclude": {
"**/routeTree.gen.ts": true
}
},
"typescript.tsdk": "node_modules/typescript/lib",
"typescript.experimental.useTsgo": true
}
20 changes: 1 addition & 19 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,10 @@ The repository is organized into three main workspace categories:
### Key Packages

- **@ucdjs/ucd-store**: Store for managing Unicode Character Database files. Supports multiple file system bridges (Node.js, HTTP, in-memory). Core operations include mirror, analyze, and clean.
- **@ucdjs/ucd-store-v2**: Next-generation store with lockfile and snapshot support.
> NOTE: This is a temporary package name while the new store is being implemented. Once stable, it will replace `@ucdjs/ucd-store`.
> Core operations include mirror, analyze, and sync (different from v1).
- **@ucdjs/lockfile**: Lockfile and snapshot management utilities for UCD stores. Provides file hashing, lockfile/snapshot validation, and test utilities.
- **@ucdjs/schema-gen**: Uses AI (OpenAI) to generate TypeScript schemas from Unicode data files
- **@ucdjs/cli**: Command-line interface for UCD operations (binary: `ucd`)
> Currently uses `@ucdjs/ucd-store-v2` and `@ucdjs/lockfile` under the hood.
> Currently uses `@ucdjs/ucd-store` and `@ucdjs/lockfile` under the hood.
- **@ucdjs/client**: OpenAPI-based API client for the UCD API
- **@ucdjs/fs-bridge**: File system abstraction layer that allows different storage backends
- **@ucdjs/schemas**: Zod schemas for Unicode data files (includes lockfile and snapshot schemas)
Expand Down Expand Up @@ -183,21 +180,6 @@ The `@ucdjs/schema-gen` package uses OpenAI to generate TypeScript type definiti
2. Uses AI to infer field types and descriptions
3. Generates TypeScript interfaces using knitwork

### UCD Store Migration
The project is currently migrating from `@ucdjs/ucd-store` to `@ucdjs/ucd-store-v2`. Key differences:

**Old Store (@ucdjs/ucd-store)**:
- Operations: mirror, analyze, clean
- No lockfile/snapshot support

**New Store (@ucdjs/ucd-store-v2)**:
- Operations: mirror, analyze, sync
- Integrated lockfile and snapshot support via `@ucdjs/lockfile`
- Currently used by CLI
- Will replace old store once stable

Both stores coexist during the migration period. When working with the CLI or testing new features, use ucd-store-v2.

### Internal Development Tools

#### Moonbeam (@ucdjs/moonbeam)
Expand Down
12 changes: 3 additions & 9 deletions apps/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,12 @@

A RESTful API for accessing Unicode Character Database (UCD) data.

## 📦 Installation
## � Usage

```sh
git clone https://github.com/ucdjs/api.ucdjs.dev.git
cd api.ucdjs.dev
pnpm install
```

## 🚀 Usage
From the root directory:

```sh
pnpm run dev
pnpm run dev:apps
```

## 📖 API Documentation
Expand Down
2 changes: 1 addition & 1 deletion apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@ucdjs/api",
"type": "module",
"private": true,
"packageManager": "pnpm@10.26.1",
"packageManager": "pnpm@10.26.2",
"scripts": {
"dev": "wrangler dev --port 8787 --inspector-port 9229",
"build": "wrangler deploy --dry-run --outdir=dist --tsconfig=./tsconfig.build.json --env=production",
Expand Down
4 changes: 4 additions & 0 deletions apps/api/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
export const V1_FILES_ROUTER_BASE_PATH = "/api/v1/files";
export const V1_VERSIONS_ROUTER_BASE_PATH = "/api/v1/versions";
export const V1_SCHEMAS_ROUTER_BASE_PATH = "/api/v1/schemas";
export const V1_CHARACTERS_ROUTER_BASE_PATH = "/api/v1/characters";
export const V1_PROPERTIES_ROUTER_BASE_PATH = "/api/v1/properties";
export const V1_BLOCKS_ROUTER_BASE_PATH = "/api/v1/blocks";

export const WELL_KNOWN_ROUTER_BASE_PATH = "/.well-known";

export const HTML_EXTENSIONS = [
Expand Down
109 changes: 99 additions & 10 deletions apps/api/src/lib/files.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Entry } from "apache-autoindex-parse";
import { trimTrailingSlash } from "@luxass/utils";
import { createGlobMatcher } from "@ucdjs-internal/shared";
import { parse } from "apache-autoindex-parse";

/**
Expand All @@ -20,13 +20,102 @@ import { parse } from "apache-autoindex-parse";
* console.log(entries); // [{ type: 'directory', name: 'UNIDATA', path: '/UNIDATA', ... }]
* ```
*/
export async function parseUnicodeDirectory(html: string): Promise<Entry[]> {
const files = parse(html, "F2");

return files.map(({ type, name, path, lastModified }) => ({
type,
name: trimTrailingSlash(name),
path: trimTrailingSlash(path),
lastModified,
}));
export async function parseUnicodeDirectory(html: string, basePath = ""): Promise<Entry[]> {
const files = parse(html, {
format: "F2",
basePath,
});

return files;
}

export interface DirectoryFilterOptions {
/**
* A string to filter file/directory names that start with this query (case-insensitive).
*/
query?: string;

/**
* A glob pattern to filter file/directory names.
*/
pattern?: string;

/**
* Type of entries to include: "all" (default), "files", or "directories".
*/
type?: string;

/**
* Field to sort by: "name" (default) or "lastModified".
*/
sort?: string;

/**
* Sort order: "asc" (default) or "desc".
*/
order?: string;
}

/**
* Applies filtering and sorting to directory entries based on query parameters.
*
* @param {Entry[]} files - Array of directory entries to filter and sort
* @param {DirectoryFilterOptions} options - Filter and sort options
* @returns {Entry[]} Filtered and sorted array of entries
*/
export function applyDirectoryFiltersAndSort(
files: Entry[],
options: DirectoryFilterOptions,
): Entry[] {
let filtered = [...files];

// Apply query filter (prefix search, case-insensitive)
if (options.query) {
// eslint-disable-next-line no-console
console.info(`[v1_files]: applying query filter: ${options.query}`);
const queryLower = options.query.toLowerCase();
filtered = filtered.filter((entry) => entry.name.toLowerCase().startsWith(queryLower));
}

// Apply pattern filter if provided
if (options.pattern) {
// eslint-disable-next-line no-console
console.info(`[v1_files]: applying glob pattern filter: ${options.pattern}`);
const matcher = createGlobMatcher(options.pattern);
filtered = filtered.filter((entry) => matcher(entry.name));
}

// Apply type filter
const type = options.type || "all";
if (type === "files") {
filtered = filtered.filter((entry) => entry.type === "file");
} else if (type === "directories") {
filtered = filtered.filter((entry) => entry.type === "directory");
}

// Apply sorting (directories always first, like Windows File Explorer)
const sort = options.sort || "name";
const order = options.order || "asc";

filtered = filtered.toSorted((a, b) => {
// Directories always come first
if (a.type !== b.type) {
return a.type === "directory" ? -1 : 1;
}

// Within same type, apply the requested sort
let comparison: number;

if (sort === "lastModified") {
// lastModified is always available from parseUnicodeDirectory
comparison = (a.lastModified ?? 0) - (b.lastModified ?? 0);
} else {
// Natural name sorting (numeric aware) so 2.0.0 < 10.0.0
comparison = a.name.localeCompare(b.name, undefined, { numeric: true, sensitivity: "base" });
}

return order === "desc" ? -comparison : comparison;
});

return filtered;
}
3 changes: 3 additions & 0 deletions apps/api/src/openapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ export type OpenAPIObjectConfig = Parameters<OpenAPIHono["getOpenAPI31Document"]
export const OPENAPI_TAGS = {
VERSIONS: "Versions",
FILES: "Files",
CHARACTERS: "Characters",
PROPERTIES: "Properties",
BLOCKS: "Blocks",
WELL_KNOWN: "Well-Known",
} as const satisfies Record<string, string>;

Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/routes/.well-known/ucd-config.json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export function registerUcdConfigRoute(router: OpenAPIHono<HonoEnv>) {
version: "0.1",
endpoints: {
files: V1_FILES_ROUTER_BASE_PATH,
manifest: `${WELL_KNOWN_ROUTER_BASE_PATH}/ucd-store.json`,
manifest: `${WELL_KNOWN_ROUTER_BASE_PATH}/ucd-store/{version}.json`,
versions: V1_VERSIONS_ROUTER_BASE_PATH,
},
versions: versionStrings,
Expand Down
115 changes: 115 additions & 0 deletions apps/api/src/routes/v1_blocks/$block.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
import type { OpenAPIHono } from "@hono/zod-openapi";
import type { HonoEnv } from "../../types";
import { createRoute } from "@hono/zod-openapi";
import { dedent } from "@luxass/utils";
import { UnicodeBlockSchema } from "@ucdjs/schemas";
import { cache } from "hono/cache";
import { MAX_AGE_ONE_DAY_SECONDS } from "../../constants";
import { badRequest, notFound } from "../../lib/errors";
import { createLogger } from "../../lib/logger";
import { VERSION_ROUTE_PARAM } from "../../lib/shared-parameters";
import { generateReferences, OPENAPI_TAGS } from "../../openapi";

const log = createLogger("ucd:api:v1_blocks");

const GET_BLOCK_ROUTE = createRoute({
method: "get",
path: "/{version}/{block}",
tags: [OPENAPI_TAGS.BLOCKS],
middleware: [
cache({
cacheName: "ucdjs:v1_blocks:block",
cacheControl: `max-age=${MAX_AGE_ONE_DAY_SECONDS}`,
}),
],
parameters: [
VERSION_ROUTE_PARAM,
{
name: "block",
in: "path",
schema: { type: "string" },
required: true,
description: "Unicode block name or ID (e.g., Basic_Latin, CJK_Unified_Ideographs)",
},
],

description: dedent`
## Get Unicode Block Details

Retrieve detailed information about a specific Unicode block.

- Supports **block name or ID** (e.g., \`Basic_Latin\`, \`CJK_Unified_Ideographs\`)
- Returns **block information** including codepoint range and character count
- Optionally **includes character list** with minimal or detailed format
- Supports **pagination** via limit parameter
- Supports **caching** for performance optimization
`,
responses: {
200: {
content: {
"application/json": {
schema: UnicodeBlockSchema,
examples: {
default: {
summary: "Basic Latin block",
value: {
name: "Basic Latin",
aliases: ["ASCII"],
range: { start: "U+0000", end: "U+007F" },
count: 128,
description: "ASCII characters and basic Latin",
relatedScripts: ["Latin"],
},
},
withCharacters: {
summary: "Block with characters",
value: {
name: "Basic Latin",
aliases: ["ASCII"],
range: { start: "U+0000", end: "U+007F" },
count: 128,
description: "ASCII characters and basic Latin",
relatedScripts: ["Latin"],
characters: [
{ codepoint: "U+0041", character: "A", name: "LATIN CAPITAL LETTER A" },
{ codepoint: "U+0061", character: "a", name: "LATIN SMALL LETTER A" },
],
},
},
},
},
},
description: "Block details",
},
...(generateReferences([
400,
404,
429,
500,
])),
},
});

export function registerBlockRoute(router: OpenAPIHono<HonoEnv>) {
router.openapi(GET_BLOCK_ROUTE, async (c) => {
const { block, version } = c.req.param();

if (!block || block.length === 0) {
log.warn("Empty block name");
return badRequest(c, {
message: "Block name cannot be empty",
});
}

// TODO: Fetch block data from Unicode database
// Include characters if requested, apply format and limit
log.info("Fetching block data", {
block,
version,
});

return notFound(c, {
message: `Block "${block}" not found. API implementation pending.`,
});
});
}
Loading
Loading