Inspect TypeScript client generation¶
Evolving. Aksara renders a fetch-based CRUD client from ViewSets. Generated list parameters remain specific to each ViewSet and are compatible with the internal query serializer under TypeScript strict mode. Treat the output as generated material to review for your application.
Generate from explicit ViewSets¶
After creating the first-project ticket desk,
save this file beside main.py. It uses the public Python generator and the
same application ViewSet; it does not connect to PostgreSQL.
from pathlib import Path
from aksara.sdk import generate_typescript_sdk
from app.views import TicketViewSet
Path("api.ts").write_text(generate_typescript_sdk([TicketViewSet]))
The output includes TicketCreate, TicketUpdate, TicketRead, query parameter
interfaces and an AksaraClient. Generated methods cover list, get, create,
update and delete. Custom actions and durable-operation endpoints are not
included automatically. Regenerate after changing the model or ViewSet schema.
Verify before using the output¶
With TypeScript 5.9.3 available in a development environment:
The canonical Ticket Desk output passes this strict check. Generation succeeding is still not sufficient validation: compile the generated file and exercise it against your application's REST API, especially when you use custom serializers or mounted route prefixes.
CLI discovery¶
The equivalent generator command is:
Options are --language typescript (the only supported language), --output
(default api.ts), --views-module and --stdout. The application module must
be importable in the CLI process. In an isolated wheel environment, an
uninstalled app.views directory was not discovered by the console command;
it reported No ViewSets discovered. The explicit Python script above avoids
that discovery ambiguity without changing framework configuration.
Client behavior to review¶
Generated clients accept baseUrl, headers and a custom fetch implementation.
They do not implement login or token refresh. Supply credentials according to
your application's authentication boundary; generated TypeScript types do not
replace server permissions, policy or tenant checks.
The current client uses JSON bodies and PATCH for updates. On a non-success
HTTP response it throws an Error containing the status and status text; it
does not preserve structured backend error bodies automatically. The TypeScript
interfaces are static declarations, not runtime response validation. Review
pagination, nullable values, mounted route prefixes and custom serializers for
your actual ViewSets before adopting generated output.