@kizunajs/swift 2.0.0-beta.2 → 2.0.0-beta.20

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.d.cts CHANGED
@@ -1,4 +1,7 @@
1
- import { ApiDefinition, ClientTarget } from "kizunajs";
1
+ import { GeneratedFileOptions } from "kizunajs/generator";
2
+ import * as _$kizunajs from "kizunajs";
3
+ import { ApiDefinition } from "kizunajs";
4
+ import { z } from "zod";
2
5
 
3
6
  //#region src/generator.d.ts
4
7
  interface SwiftConfig {
@@ -29,41 +32,28 @@ interface SwiftConfig {
29
32
  declare const generateSwiftClient: (api: ApiDefinition, options: SwiftConfig) => string;
30
33
  //#endregion
31
34
  //#region src/client-target.d.ts
35
+ declare const SwiftClientOptionsSchema: z.ZodObject<{
36
+ namespace: z.ZodDefault<z.ZodString>;
37
+ camelCaseProperties: z.ZodOptional<z.ZodBoolean>;
38
+ unknownEnumCase: z.ZodOptional<z.ZodBoolean>;
39
+ }, z.core.$strip>;
32
40
  /**
33
41
  * Where a generated Swift client is written, and what it is called there.
34
42
  */
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
- }
43
+ type SwiftClientOptions = z.input<typeof SwiftClientOptionsSchema> & GeneratedFileOptions;
61
44
  /**
62
- * A Swift client target for `kizuna.config.ts`.
45
+ * A Swift client for `kizuna.config.ts`.
63
46
  *
64
47
  * @example
65
- * swiftClient({ output: './Sources/APIClient/APIClient.swift', namespace: 'API' });
48
+ * swiftClient({
49
+ * output: './Sources/APIClient/APIClient.swift',
50
+ * namespace: 'API',
51
+ * });
66
52
  */
67
- declare const swiftClient: (options: SwiftClientOptions) => ClientTarget;
53
+ declare const swiftClient: (options: {
54
+ namespace?: string | undefined;
55
+ camelCaseProperties?: boolean | undefined;
56
+ unknownEnumCase?: boolean | undefined;
57
+ } & GeneratedFileOptions) => _$kizunajs.GeneratedFile;
68
58
  //#endregion
69
59
  export { type SwiftClientOptions, type SwiftConfig, generateSwiftClient, swiftClient };
package/dist/index.d.mts CHANGED
@@ -1,4 +1,7 @@
1
- import { ApiDefinition, ClientTarget } from "kizunajs";
1
+ import { GeneratedFileOptions } from "kizunajs/generator";
2
+ import { z } from "zod";
3
+ import * as _$kizunajs from "kizunajs";
4
+ import { ApiDefinition } from "kizunajs";
2
5
 
3
6
  //#region src/generator.d.ts
4
7
  interface SwiftConfig {
@@ -29,41 +32,28 @@ interface SwiftConfig {
29
32
  declare const generateSwiftClient: (api: ApiDefinition, options: SwiftConfig) => string;
30
33
  //#endregion
31
34
  //#region src/client-target.d.ts
35
+ declare const SwiftClientOptionsSchema: z.ZodObject<{
36
+ namespace: z.ZodDefault<z.ZodString>;
37
+ camelCaseProperties: z.ZodOptional<z.ZodBoolean>;
38
+ unknownEnumCase: z.ZodOptional<z.ZodBoolean>;
39
+ }, z.core.$strip>;
32
40
  /**
33
41
  * Where a generated Swift client is written, and what it is called there.
34
42
  */
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
- }
43
+ type SwiftClientOptions = z.input<typeof SwiftClientOptionsSchema> & GeneratedFileOptions;
61
44
  /**
62
- * A Swift client target for `kizuna.config.ts`.
45
+ * A Swift client for `kizuna.config.ts`.
63
46
  *
64
47
  * @example
65
- * swiftClient({ output: './Sources/APIClient/APIClient.swift', namespace: 'API' });
48
+ * swiftClient({
49
+ * output: './Sources/APIClient/APIClient.swift',
50
+ * namespace: 'API',
51
+ * });
66
52
  */
67
- declare const swiftClient: (options: SwiftClientOptions) => ClientTarget;
53
+ declare const swiftClient: (options: {
54
+ namespace?: string | undefined;
55
+ camelCaseProperties?: boolean | undefined;
56
+ unknownEnumCase?: boolean | undefined;
57
+ } & GeneratedFileOptions) => _$kizunajs.GeneratedFile;
68
58
  //#endregion
69
59
  export { type SwiftClientOptions, type SwiftConfig, generateSwiftClient, swiftClient };
package/dist/index.mjs CHANGED
@@ -1,16 +1,41 @@
1
- import { t as generateSwiftClient } from "./generator-D2AtmA6u.mjs";
2
- //#region src/client-target.ts
1
+ import { n as swiftClientWalk, t as generateSwiftClient } from "./generator-2GeebFHv.mjs";
2
+ import { defineClient } from "kizunajs/generator";
3
+ import { z } from "zod";
3
4
  /**
4
- * A Swift client target for `kizuna.config.ts`.
5
+ * A Swift client for `kizuna.config.ts`.
5
6
  *
6
7
  * @example
7
- * swiftClient({ output: './Sources/APIClient/APIClient.swift', namespace: 'API' });
8
+ * swiftClient({
9
+ * output: './Sources/APIClient/APIClient.swift',
10
+ * namespace: 'API',
11
+ * });
8
12
  */
9
- const swiftClient = (options) => ({
10
- kind: "swift",
11
- output: options.output,
12
- generate: (contract) => generateSwiftClient(contract, {
13
- namespaceName: options.namespace ?? "API",
13
+ const swiftClient = defineClient({
14
+ target: "swift",
15
+ options: z.object({
16
+ /**
17
+ * Name of the generated namespace enum.
18
+ *
19
+ * @default 'API'
20
+ */
21
+ namespace: z.string().default("API"),
22
+ /**
23
+ * Convert wire field names to camelCase properties, mapping the wire name
24
+ * back via `CodingKeys`.
25
+ *
26
+ * @default false
27
+ */
28
+ camelCaseProperties: z.boolean().optional(),
29
+ /**
30
+ * Give every enum an `unknown` case, so a value the client has not been
31
+ * generated for decodes instead of throwing.
32
+ *
33
+ * @default false
34
+ */
35
+ unknownEnumCase: z.boolean().optional()
36
+ }),
37
+ generate: ({ options, api }) => swiftClientWalk(api, {
38
+ namespaceName: options.namespace,
14
39
  camelCaseProperties: options.camelCaseProperties,
15
40
  unknownEnumCase: options.unknownEnumCase
16
41
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kizunajs/swift",
3
- "version": "2.0.0-beta.2",
3
+ "version": "2.0.0-beta.20",
4
4
  "description": "Swift client generation for Kizuna.js APIs",
5
5
  "keywords": [
6
6
  "kizunajs",
@@ -59,18 +59,18 @@
59
59
  "access": "public"
60
60
  },
61
61
  "dependencies": {
62
- "@kizunajs/cli": "2.0.0-beta.2"
62
+ "@kizunajs/cli": "2.0.0-beta.20"
63
63
  },
64
64
  "peerDependencies": {
65
- "zod": "^4.0.0",
66
- "kizunajs": "2.0.0-beta.2"
65
+ "kizunajs": "2.0.0-beta.20",
66
+ "zod": "^4.0.0"
67
67
  },
68
68
  "devDependencies": {
69
+ "kizunajs": "2.0.0-beta.20",
69
70
  "@types/node": "^24",
70
71
  "tsdown": "^0.21.0",
71
72
  "typescript": "^6.0.3",
72
- "zod": "^4.0.0",
73
- "kizunajs": "2.0.0-beta.2"
73
+ "zod": "^4.0.0"
74
74
  },
75
75
  "scripts": {
76
76
  "build": "tsdown src/index.ts src/cli.ts --format esm,cjs --dts --clean --external kizunajs --external @kizunajs/cli --external zod",