@kizunajs/kotlin 2.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs ADDED
@@ -0,0 +1,22 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_generator = require("./generator-s2pn7vqP.cjs");
3
+ //#region src/client-target.ts
4
+ /**
5
+ * A Kotlin client target for `kizuna.config.ts`.
6
+ *
7
+ * @example
8
+ * kotlinClient({ output: './api/APIClient.kt', package: 'com.example.api' });
9
+ */
10
+ const kotlinClient = (options) => ({
11
+ kind: "kotlin",
12
+ output: options.output,
13
+ generate: (contract) => require_generator.generateKotlinClient(contract, {
14
+ namespaceName: options.namespace ?? "API",
15
+ packageName: options.package,
16
+ camelCaseProperties: options.camelCaseProperties,
17
+ unknownEnumCase: options.unknownEnumCase
18
+ })
19
+ });
20
+ //#endregion
21
+ exports.generateKotlinClient = require_generator.generateKotlinClient;
22
+ exports.kotlinClient = kotlinClient;
@@ -0,0 +1,82 @@
1
+ import { ApiDefinition, ClientTarget } from "kizunajs";
2
+
3
+ //#region src/generator.d.ts
4
+ interface KotlinConfig {
5
+ namespaceName: string;
6
+ /**
7
+ * Package declaration for the generated file (e.g. `com.example.api`).
8
+ *
9
+ * Omit to emit the file with no package (the default/root package).
10
+ */
11
+ packageName?: string;
12
+ /**
13
+ * Convert wire field names to camelCase properties, mapping the wire name
14
+ * back via `@SerialName`. When off, names are kept verbatim so the generated
15
+ * types mirror the wire shape.
16
+ *
17
+ * @default false
18
+ */
19
+ camelCaseProperties?: boolean;
20
+ /**
21
+ * Emit each `z.enum` as a `sealed interface` with an `Unknown(wireValue)`
22
+ * member, so unrecognised wire values decode instead of throwing. The raw
23
+ * string round-trips on encode and in query params. Discriminated unions are
24
+ * unaffected and still throw on an unknown discriminator.
25
+ *
26
+ * @default false
27
+ */
28
+ unknownEnumCase?: boolean;
29
+ }
30
+ /**
31
+ * Generate a Kotlin API client from a Kizuna api.
32
+ *
33
+ * @param api - What `defineConfig` assembled.
34
+ * @param config - Override the generated names:
35
+ * - `namespaceName`: the object wrapping shared types.
36
+ * - `packageName`: optional package declaration for the generated file.
37
+ */
38
+ declare const generateKotlinClient: (api: ApiDefinition, config: KotlinConfig) => string;
39
+ //#endregion
40
+ //#region src/client-target.d.ts
41
+ /**
42
+ * Where a generated Kotlin client is written, and what it is called there.
43
+ */
44
+ interface KotlinClientOptions {
45
+ /**
46
+ * Path the generated file is written to.
47
+ */
48
+ output: string;
49
+ /**
50
+ * Name of the generated namespace object.
51
+ *
52
+ * @default 'API'
53
+ */
54
+ namespace?: string;
55
+ /**
56
+ * Package declaration for the generated file, e.g. `com.example.api`.
57
+ */
58
+ package?: string;
59
+ /**
60
+ * Convert wire field names to camelCase properties, mapping the wire name
61
+ * back via `@SerialName`.
62
+ *
63
+ * @default false
64
+ */
65
+ camelCaseProperties?: boolean;
66
+ /**
67
+ * Give every enum an `unknown` case, so a value the client has not been
68
+ * generated for decodes instead of throwing.
69
+ *
70
+ * @default false
71
+ */
72
+ unknownEnumCase?: boolean;
73
+ }
74
+ /**
75
+ * A Kotlin client target for `kizuna.config.ts`.
76
+ *
77
+ * @example
78
+ * kotlinClient({ output: './api/APIClient.kt', package: 'com.example.api' });
79
+ */
80
+ declare const kotlinClient: (options: KotlinClientOptions) => ClientTarget;
81
+ //#endregion
82
+ export { type KotlinClientOptions, type KotlinConfig, generateKotlinClient, kotlinClient };
@@ -0,0 +1,82 @@
1
+ import { ApiDefinition, ClientTarget } from "kizunajs";
2
+
3
+ //#region src/generator.d.ts
4
+ interface KotlinConfig {
5
+ namespaceName: string;
6
+ /**
7
+ * Package declaration for the generated file (e.g. `com.example.api`).
8
+ *
9
+ * Omit to emit the file with no package (the default/root package).
10
+ */
11
+ packageName?: string;
12
+ /**
13
+ * Convert wire field names to camelCase properties, mapping the wire name
14
+ * back via `@SerialName`. When off, names are kept verbatim so the generated
15
+ * types mirror the wire shape.
16
+ *
17
+ * @default false
18
+ */
19
+ camelCaseProperties?: boolean;
20
+ /**
21
+ * Emit each `z.enum` as a `sealed interface` with an `Unknown(wireValue)`
22
+ * member, so unrecognised wire values decode instead of throwing. The raw
23
+ * string round-trips on encode and in query params. Discriminated unions are
24
+ * unaffected and still throw on an unknown discriminator.
25
+ *
26
+ * @default false
27
+ */
28
+ unknownEnumCase?: boolean;
29
+ }
30
+ /**
31
+ * Generate a Kotlin API client from a Kizuna api.
32
+ *
33
+ * @param api - What `defineConfig` assembled.
34
+ * @param config - Override the generated names:
35
+ * - `namespaceName`: the object wrapping shared types.
36
+ * - `packageName`: optional package declaration for the generated file.
37
+ */
38
+ declare const generateKotlinClient: (api: ApiDefinition, config: KotlinConfig) => string;
39
+ //#endregion
40
+ //#region src/client-target.d.ts
41
+ /**
42
+ * Where a generated Kotlin client is written, and what it is called there.
43
+ */
44
+ interface KotlinClientOptions {
45
+ /**
46
+ * Path the generated file is written to.
47
+ */
48
+ output: string;
49
+ /**
50
+ * Name of the generated namespace object.
51
+ *
52
+ * @default 'API'
53
+ */
54
+ namespace?: string;
55
+ /**
56
+ * Package declaration for the generated file, e.g. `com.example.api`.
57
+ */
58
+ package?: string;
59
+ /**
60
+ * Convert wire field names to camelCase properties, mapping the wire name
61
+ * back via `@SerialName`.
62
+ *
63
+ * @default false
64
+ */
65
+ camelCaseProperties?: boolean;
66
+ /**
67
+ * Give every enum an `unknown` case, so a value the client has not been
68
+ * generated for decodes instead of throwing.
69
+ *
70
+ * @default false
71
+ */
72
+ unknownEnumCase?: boolean;
73
+ }
74
+ /**
75
+ * A Kotlin client target for `kizuna.config.ts`.
76
+ *
77
+ * @example
78
+ * kotlinClient({ output: './api/APIClient.kt', package: 'com.example.api' });
79
+ */
80
+ declare const kotlinClient: (options: KotlinClientOptions) => ClientTarget;
81
+ //#endregion
82
+ export { type KotlinClientOptions, type KotlinConfig, generateKotlinClient, kotlinClient };
package/dist/index.mjs ADDED
@@ -0,0 +1,20 @@
1
+ import { t as generateKotlinClient } from "./generator-BvNpSarY.mjs";
2
+ //#region src/client-target.ts
3
+ /**
4
+ * A Kotlin client target for `kizuna.config.ts`.
5
+ *
6
+ * @example
7
+ * kotlinClient({ output: './api/APIClient.kt', package: 'com.example.api' });
8
+ */
9
+ const kotlinClient = (options) => ({
10
+ kind: "kotlin",
11
+ output: options.output,
12
+ generate: (contract) => generateKotlinClient(contract, {
13
+ namespaceName: options.namespace ?? "API",
14
+ packageName: options.package,
15
+ camelCaseProperties: options.camelCaseProperties,
16
+ unknownEnumCase: options.unknownEnumCase
17
+ })
18
+ });
19
+ //#endregion
20
+ export { generateKotlinClient, kotlinClient };
package/package.json ADDED
@@ -0,0 +1,80 @@
1
+ {
2
+ "name": "@kizunajs/kotlin",
3
+ "version": "2.0.0-beta.0",
4
+ "description": "Kotlin client generation for Kizuna.js APIs",
5
+ "keywords": [
6
+ "kizunajs",
7
+ "typescript",
8
+ "zod",
9
+ "openapi",
10
+ "spec-driven",
11
+ "type-safe",
12
+ "rest",
13
+ "api",
14
+ "kotlin",
15
+ "android",
16
+ "jvm",
17
+ "codegen",
18
+ "client-generation"
19
+ ],
20
+ "license": "MIT",
21
+ "homepage": "https://kizunajs.com/docs/clients/kotlin",
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "git+https://github.com/kizunajs/kizuna.git",
25
+ "directory": "packages/kotlin"
26
+ },
27
+ "bugs": "https://github.com/kizunajs/kizuna/issues",
28
+ "type": "module",
29
+ "sideEffects": false,
30
+ "engines": {
31
+ "node": ">=24"
32
+ },
33
+ "main": "./dist/index.cjs",
34
+ "module": "./dist/index.mjs",
35
+ "types": "./dist/index.d.mts",
36
+ "exports": {
37
+ ".": {
38
+ "import": {
39
+ "types": "./dist/index.d.mts",
40
+ "default": "./dist/index.mjs"
41
+ },
42
+ "require": {
43
+ "types": "./dist/index.d.cts",
44
+ "default": "./dist/index.cjs"
45
+ }
46
+ }
47
+ },
48
+ "bin": {
49
+ "kizuna-kotlin": "./dist/cli.mjs"
50
+ },
51
+ "kizuna": {
52
+ "entries": {
53
+ ".": "server"
54
+ }
55
+ },
56
+ "files": [
57
+ "dist"
58
+ ],
59
+ "publishConfig": {
60
+ "access": "public"
61
+ },
62
+ "dependencies": {
63
+ "@kizunajs/cli": "2.0.0-beta.0"
64
+ },
65
+ "peerDependencies": {
66
+ "zod": "^4.0.0",
67
+ "kizunajs": "2.0.0-beta.0"
68
+ },
69
+ "devDependencies": {
70
+ "@types/node": "^22.9.0",
71
+ "tsdown": "^0.21.0",
72
+ "typescript": "^6.0.3",
73
+ "zod": "^4.0.0",
74
+ "kizunajs": "2.0.0-beta.0"
75
+ },
76
+ "scripts": {
77
+ "build": "tsdown src/index.ts src/cli.ts --format esm,cjs --dts --clean --external kizunajs --external @kizunajs/cli --external zod",
78
+ "typecheck": "tsc --noEmit"
79
+ }
80
+ }