Just some Directus stuff.
So, this is my take on the code generation for Directus, releasing it to catch some early bugs that might happen.
Right now it's pretty simple and it's just going to output some types and utility functions that are compatible with the current Directus SDK, but it was designed to support custom outputs (because I use Directus in several different languages). Right now I won't expand (or document) on the templating side, because I still need to get to the final data model and make it stable to export to the template engine.
npx indirectus sdk generate --url http://localhost:8055 --token <some-static-token-with-admin-privileges>
A local .directus
folder will be created containing schema cache + the generated client output.
The .directus/generated/client.ts
exports:
Schema
type with all your schema mappings (use it while creating the client with the SDK's createDirectus<Schema>
method.)client.request(fn)
to make data fetching cleaner.Easiest way to develop, build and test is:
pnpm install
pnpm dev
pnpm indirectus
, for example pnpm indirectus sdk generate
.env
file on the workspace root containing your server settingsDIRECTUS_URL=http://....
DIRECTUS_TOKEN=.....