Skip to content

Commit bab043e

Browse files
ajay-kgjtorikian
andauthored
feat(android): add Android emitter (kotlinx.serialization + OkHttp, suspend API) (#206)
Co-authored-by: Garen J. Torikian <gjtorikian@users.noreply.github.com>
1 parent d6246e0 commit bab043e

36 files changed

Lines changed: 7234 additions & 45 deletions

docs/lang-gen/workspace.md

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,24 @@ does not exist, say which one is missing and how to point at it
3434
| Emitter source | `src/{lang}/` | The only place to fix generated-output defects. |
3535
| Emitter tests | `test/{lang}/` | vitest unit tests, including the `non-spec.test.ts` coverage pins. |
3636

37-
Emitters currently in `src/`: `dotnet`, `elixir`, `go`, `ios`, `kotlin`, `node`,
38-
`php`, `python`, `ruby`, `rust`. Confirm with `ls src` rather than trusting this
39-
list — and note that `compat`, `shared`, and `snippets` are also directories under
40-
`src/` but are not emitters. There is no `android` emitter; if someone asks for one
41-
by name, say so instead of generating something.
37+
Emitters currently in `src/`: `android`, `dotnet`, `elixir`, `go`, `ios`, `kotlin`,
38+
`node`, `php`, `python`, `ruby`, `rust`. Confirm with `ls src` rather than trusting
39+
this list — and note that `compat`, `shared`, and `snippets` are also directories
40+
under `src/` but are not emitters.
41+
42+
`android` and `kotlin` are both Kotlin emitters and are **not** interchangeable.
43+
`kotlin` targets the JVM and uses Jackson; `android` uses kotlinx.serialization
44+
(compile-time serializers, no reflection, no R8 keep rules) and emits `suspend`
45+
methods. Pick by target runtime, not by language name.
4246

4347
`{lang}` is the **emitter identifier**, not the language name — `dotnet` emits C#
4448
into `workos-dotnet`, `ios` emits Swift, `node` emits TypeScript.
4549

4650
### When `docs/sdk-architecture/{lang}.md` is missing
4751

48-
The design docs cover a subset of emitters (currently `dotnet`, `elixir`, `go`,
49-
`ios`, `node`, `php`, `python`, `rust`; `kotlin` and `ruby` have none). A missing
52+
The design docs cover a subset of emitters (currently `android`, `dotnet`,
53+
`elixir`, `go`, `ios`, `node`, `php`, `python`, `rust`; `kotlin` and `ruby` have
54+
none). A missing
5055
doc is not a reason to stop, and it is not a licence to guess — derive the same
5156
facts from code and say that you did:
5257

@@ -137,11 +142,14 @@ Notes:
137142
- `scripts/sdk-generate.sh` accepts only `--lang`, `--output`, `--namespace`,
138143
`--services`. It hard-errors on anything else, including `--target`.
139144
- It defaults `--namespace` to `WorkOS` for `php`, `ios`, and `android`, and
140-
`workos` elsewhere. Do not override unless the language design doc says to. Two
141-
quirks in that branch, both in the spec repo and out of scope here: the `android`
142-
case is dead (no such emitter), and `kotlin` is _not_ in the cased list even
143-
though the script's own comment says a Kotlin client class needs the cased form —
144-
so a kotlin run gets `workos`. If kotlin output looks wrong, check that first.
145+
`workos` elsewhere. Do not override unless the language design doc says to.
146+
`android` genuinely needs the cased form: the namespace becomes the client type
147+
prefix, so `workos` yields `WorkosClient` accessors that do not match the
148+
hand-maintained `WorkOSClient` and the SDK will not compile. One quirk remains in
149+
that branch, in the spec repo and out of scope here: `kotlin` is _not_ in the
150+
cased list even though the script's own comment says a Kotlin client class needs
151+
the cased form — so a kotlin run gets `workos`. If kotlin output looks wrong,
152+
check that first.
145153
- The old `npm run sdk:generate:{lang}` scripts and the `--output` staging +
146154
`--target` live split are **gone**. If you need staging separate from the live
147155
repo, skip the wrapper and call the CLI directly:

docs/sdk-architecture/android.md

Lines changed: 944 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)