feat: move TypeScript client codegen into the SDK module#9
Draft
TomChv wants to merge 1 commit into
Draft
Conversation
Add plumbing to handle client generation directly inside the typescript-sdk module. Move the client codegen binary as a helper of this codegen. Signed-off-by: Vasek - Tom C <tom@dagger.io>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Moves TypeScript client generation out of
dagger/dagger's engine runtime and into this SDK module, so the module can generate a typed client for a bound module without the engine driving codegen or opening a nested engine session. The SDK receives the schema + module metadata as plain data and runs codegen in an ordinary container.Pairs with the engine-side proposal in
dagger/dagger(hack/designs/client-codegen-workflow.md), which makes client generation a normal@generaterollup generator owned by the SDK. Full design rationale lives indesign/client-gen.md.What's in it
helpers/codegen— the TypeScript client generator, ported fromdagger/dagger'scmd/codegenas a standalone Go module:dagger.io/daggerdependency (deps:strcase,memfs,golang.org/x/mod). Engine-free: reads a pre-computed introspection schema + ameta.json(module name, engine version, dependencies) and emitsclient.gen.tsplus per-dependency<dep>.gen.tsfiles.--module-source-idGraphQL query (which needed a nested engine) with themeta.jsonfile input.DIR_SOURCEfail-closed: onlyGIT_SOURCE/LOCAL_SOURCEdeps can be served by a generated client; anything else errors rather than silently producing an unservable client.helpers/config-updator— new client config writers for the scoped-package model:client-package-json:type: module, SDK-owned@dagger.io/daggerpinned to the engine version,typescriptpin, and a scopedname(@dagger.io/<sanitized>-client) when unnamed.client-tsconfig/client-deno-config(deno writes thenpm:@dagger.io/dagger@<v>import).typescript-sdk.dang— the dang wiring:codegenBuilder/configUpdatorBuildercontainers (compile the Go helpers, same pattern asmoduleConfigBuilder).generateClient(ws, module, path)— the workspace analogue ofmod(ws, path).generate(ws).generateAllClient(ws) @generate— regenerates every client registered in workspace config (currentModule.asSDK.clients).generateAll→generateAllModulefor symmetry withgenerateAllClient.e2e —
generateClientCheckandgenerateAllClientCheck(client analogues ofgenerateCheck/generateAllCheck), plus a registered client fixture indagger.toml.Design decisions
@dagger.io/dagger; no bundled library is vendored here.source+refPin) is embedded into the generatedserveModuleDependencies; local deps take the workspace-only guarded serve.Testing
dagger --x-release=v1.0.0-beta.5 check— 13/13 green, including the two new client checks. The Go helpers are also independently covered (go test ./...in each).Known limitations / follow-ups
ModuleSource.clientSchemaIntrospectionJSONorCurrentModuleAsSDKClient.moduleSource. Until they ship, the module resolves via the polyfill and uses the module-facingintrospectionSchemaJSON. Swap both in once the engine primitives land — the client is otherwise generated from a schema that hides some core types and omits self-bindings.config-updatorbut isn't wired intoclientDirectoryyet.generate/app) has no dependencies, soserveModuleDependenciesisn't yet exercised end-to-end — a dependency-bearing client fixture is a good next addition.