@kizunajs/swift 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,21 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_generator = require("./generator-v_aUFbbV.cjs");
3
+ //#region src/client-target.ts
4
+ /**
5
+ * A Swift client target for `kizuna.config.ts`.
6
+ *
7
+ * @example
8
+ * swiftClient({ output: './Sources/APIClient/APIClient.swift', namespace: 'API' });
9
+ */
10
+ const swiftClient = (options) => ({
11
+ kind: "swift",
12
+ output: options.output,
13
+ generate: (contract) => require_generator.generateSwiftClient(contract, {
14
+ namespaceName: options.namespace ?? "API",
15
+ camelCaseProperties: options.camelCaseProperties,
16
+ unknownEnumCase: options.unknownEnumCase
17
+ })
18
+ });
19
+ //#endregion
20
+ exports.generateSwiftClient = require_generator.generateSwiftClient;
21
+ exports.swiftClient = swiftClient;
@@ -0,0 +1,69 @@
1
+ import { ApiDefinition, ClientTarget } from "kizunajs";
2
+
3
+ //#region src/generator.d.ts
4
+ interface SwiftConfig {
5
+ namespaceName: string;
6
+ /**
7
+ * Convert wire field names to camelCase properties, mapping the wire name
8
+ * back via `CodingKeys`. When off, names are kept verbatim so the generated
9
+ * types mirror the wire shape.
10
+ *
11
+ * @default false
12
+ */
13
+ camelCaseProperties?: boolean;
14
+ /**
15
+ * Emit each `z.enum` as a `RawRepresentable` enum with a `case unknown(String)`
16
+ * fallback, so unrecognised wire values decode instead of throwing. The raw
17
+ * string round-trips on encode and in query params. Discriminated unions are
18
+ * unaffected and still throw on an unknown discriminator.
19
+ *
20
+ * @default false
21
+ */
22
+ unknownEnumCase?: boolean;
23
+ }
24
+ /**
25
+ * Generate a Swift API client from a kizuna config.
26
+ *
27
+ * - `namespaceName`: the actor class. Defaults to `APIClient`.
28
+ */
29
+ declare const generateSwiftClient: (api: ApiDefinition, options: SwiftConfig) => string;
30
+ //#endregion
31
+ //#region src/client-target.d.ts
32
+ /**
33
+ * Where a generated Swift client is written, and what it is called there.
34
+ */
35
+ interface SwiftClientOptions {
36
+ /**
37
+ * Path the generated file is written to.
38
+ */
39
+ output: string;
40
+ /**
41
+ * Name of the generated namespace enum.
42
+ *
43
+ * @default 'API'
44
+ */
45
+ namespace?: string;
46
+ /**
47
+ * Convert wire field names to camelCase properties, mapping the wire name
48
+ * back via `CodingKeys`.
49
+ *
50
+ * @default false
51
+ */
52
+ camelCaseProperties?: boolean;
53
+ /**
54
+ * Give every enum an `unknown` case, so a value the client has not been
55
+ * generated for decodes instead of throwing.
56
+ *
57
+ * @default false
58
+ */
59
+ unknownEnumCase?: boolean;
60
+ }
61
+ /**
62
+ * A Swift client target for `kizuna.config.ts`.
63
+ *
64
+ * @example
65
+ * swiftClient({ output: './Sources/APIClient/APIClient.swift', namespace: 'API' });
66
+ */
67
+ declare const swiftClient: (options: SwiftClientOptions) => ClientTarget;
68
+ //#endregion
69
+ export { type SwiftClientOptions, type SwiftConfig, generateSwiftClient, swiftClient };
@@ -0,0 +1,69 @@
1
+ import { ApiDefinition, ClientTarget } from "kizunajs";
2
+
3
+ //#region src/generator.d.ts
4
+ interface SwiftConfig {
5
+ namespaceName: string;
6
+ /**
7
+ * Convert wire field names to camelCase properties, mapping the wire name
8
+ * back via `CodingKeys`. When off, names are kept verbatim so the generated
9
+ * types mirror the wire shape.
10
+ *
11
+ * @default false
12
+ */
13
+ camelCaseProperties?: boolean;
14
+ /**
15
+ * Emit each `z.enum` as a `RawRepresentable` enum with a `case unknown(String)`
16
+ * fallback, so unrecognised wire values decode instead of throwing. The raw
17
+ * string round-trips on encode and in query params. Discriminated unions are
18
+ * unaffected and still throw on an unknown discriminator.
19
+ *
20
+ * @default false
21
+ */
22
+ unknownEnumCase?: boolean;
23
+ }
24
+ /**
25
+ * Generate a Swift API client from a kizuna config.
26
+ *
27
+ * - `namespaceName`: the actor class. Defaults to `APIClient`.
28
+ */
29
+ declare const generateSwiftClient: (api: ApiDefinition, options: SwiftConfig) => string;
30
+ //#endregion
31
+ //#region src/client-target.d.ts
32
+ /**
33
+ * Where a generated Swift client is written, and what it is called there.
34
+ */
35
+ interface SwiftClientOptions {
36
+ /**
37
+ * Path the generated file is written to.
38
+ */
39
+ output: string;
40
+ /**
41
+ * Name of the generated namespace enum.
42
+ *
43
+ * @default 'API'
44
+ */
45
+ namespace?: string;
46
+ /**
47
+ * Convert wire field names to camelCase properties, mapping the wire name
48
+ * back via `CodingKeys`.
49
+ *
50
+ * @default false
51
+ */
52
+ camelCaseProperties?: boolean;
53
+ /**
54
+ * Give every enum an `unknown` case, so a value the client has not been
55
+ * generated for decodes instead of throwing.
56
+ *
57
+ * @default false
58
+ */
59
+ unknownEnumCase?: boolean;
60
+ }
61
+ /**
62
+ * A Swift client target for `kizuna.config.ts`.
63
+ *
64
+ * @example
65
+ * swiftClient({ output: './Sources/APIClient/APIClient.swift', namespace: 'API' });
66
+ */
67
+ declare const swiftClient: (options: SwiftClientOptions) => ClientTarget;
68
+ //#endregion
69
+ export { type SwiftClientOptions, type SwiftConfig, generateSwiftClient, swiftClient };
package/dist/index.mjs ADDED
@@ -0,0 +1,19 @@
1
+ import { t as generateSwiftClient } from "./generator-D2AtmA6u.mjs";
2
+ //#region src/client-target.ts
3
+ /**
4
+ * A Swift client target for `kizuna.config.ts`.
5
+ *
6
+ * @example
7
+ * swiftClient({ output: './Sources/APIClient/APIClient.swift', namespace: 'API' });
8
+ */
9
+ const swiftClient = (options) => ({
10
+ kind: "swift",
11
+ output: options.output,
12
+ generate: (contract) => generateSwiftClient(contract, {
13
+ namespaceName: options.namespace ?? "API",
14
+ camelCaseProperties: options.camelCaseProperties,
15
+ unknownEnumCase: options.unknownEnumCase
16
+ })
17
+ });
18
+ //#endregion
19
+ export { generateSwiftClient, swiftClient };
package/package.json ADDED
@@ -0,0 +1,79 @@
1
+ {
2
+ "name": "@kizunajs/swift",
3
+ "version": "2.0.0-beta.0",
4
+ "description": "Swift 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
+ "swift",
15
+ "ios",
16
+ "codegen",
17
+ "client-generation"
18
+ ],
19
+ "license": "MIT",
20
+ "homepage": "https://kizunajs.com/docs/clients/swift",
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+https://github.com/kizunajs/kizuna.git",
24
+ "directory": "packages/swift"
25
+ },
26
+ "bugs": "https://github.com/kizunajs/kizuna/issues",
27
+ "type": "module",
28
+ "sideEffects": false,
29
+ "engines": {
30
+ "node": ">=24"
31
+ },
32
+ "main": "./dist/index.cjs",
33
+ "module": "./dist/index.mjs",
34
+ "types": "./dist/index.d.mts",
35
+ "exports": {
36
+ ".": {
37
+ "import": {
38
+ "types": "./dist/index.d.mts",
39
+ "default": "./dist/index.mjs"
40
+ },
41
+ "require": {
42
+ "types": "./dist/index.d.cts",
43
+ "default": "./dist/index.cjs"
44
+ }
45
+ }
46
+ },
47
+ "bin": {
48
+ "kizuna-swift": "./dist/cli.mjs"
49
+ },
50
+ "kizuna": {
51
+ "entries": {
52
+ ".": "server"
53
+ }
54
+ },
55
+ "files": [
56
+ "dist"
57
+ ],
58
+ "publishConfig": {
59
+ "access": "public"
60
+ },
61
+ "dependencies": {
62
+ "@kizunajs/cli": "2.0.0-beta.0"
63
+ },
64
+ "peerDependencies": {
65
+ "zod": "^4.0.0",
66
+ "kizunajs": "2.0.0-beta.0"
67
+ },
68
+ "devDependencies": {
69
+ "@types/node": "^24",
70
+ "tsdown": "^0.21.0",
71
+ "typescript": "^6.0.3",
72
+ "zod": "^4.0.0",
73
+ "kizunajs": "2.0.0-beta.0"
74
+ },
75
+ "scripts": {
76
+ "build": "tsdown src/index.ts src/cli.ts --format esm,cjs --dts --clean --external kizunajs --external @kizunajs/cli --external zod",
77
+ "typecheck": "tsc --noEmit"
78
+ }
79
+ }