@arrirpc/codegen-swift 0.76.3 → 0.77.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/README.md CHANGED
@@ -6,13 +6,13 @@
6
6
 
7
7
  ```ts
8
8
  // arri.config.ts
9
- import { defineConfig, generators } from "arri";
9
+ import { defineConfig, generators } from 'arri';
10
10
 
11
11
  export default defineConfig({
12
12
  generators: [
13
13
  generators.swiftClient({
14
- clientName: "MyClient",
15
- outputFile: "./client/Sources/MyClient.g.swift",
14
+ clientName: 'MyClient',
15
+ outputFile: './client/Sources/MyClient.g.swift',
16
16
  }),
17
17
  ],
18
18
  });
@@ -22,9 +22,10 @@ export default defineConfig({
22
22
 
23
23
  | Name | Description |
24
24
  | --------------------- | ------------------------------------------------------ |
25
- | clientName (required) | The name of the generated client |
26
25
  | outputFile (required) | Path to the file that will be created by the generator |
26
+ | clientName | The name of the generated client |
27
27
  | typePrefix | Add a prefix to all of the generated types |
28
+ | rootService | The root service of the generated client |
28
29
 
29
30
  ### 2) Install the Swift client library
30
31
 
package/dist/index.cjs CHANGED
@@ -1397,14 +1397,14 @@ const swiftClientGenerator = codegenUtils.defineGeneratorPlugin(
1397
1397
  function createSwiftClient(def, options) {
1398
1398
  const context = {
1399
1399
  clientVersion: def.info?.version ?? "",
1400
- clientName: options.clientName,
1400
+ clientName: options.clientName ?? "Client",
1401
1401
  typePrefix: options.typePrefix ?? "",
1402
1402
  instancePath: "",
1403
1403
  schemaPath: "",
1404
1404
  generatedTypes: [],
1405
1405
  containsRequiredRef: {}
1406
1406
  };
1407
- const services = codegenUtils.unflattenProcedures(def.procedures);
1407
+ const services = codegenUtils.unflattenProcedures(def.procedures, options.rootService);
1408
1408
  const mainService = swiftServiceFromSchema(services, context);
1409
1409
  const typeContent = [];
1410
1410
  for (const key of Object.keys(def.definitions)) {
package/dist/index.d.cts CHANGED
@@ -31,12 +31,36 @@ interface SwiftProperty {
31
31
  }
32
32
 
33
33
  interface SwiftClientGeneratorOptions {
34
- clientName: string;
34
+ /**
35
+ * Defaults to "Client"
36
+ */
37
+ clientName?: string;
35
38
  outputFile: string;
39
+ /**
40
+ * Add a prefix to the generated structs
41
+ */
36
42
  typePrefix?: string;
43
+ /**
44
+ * Set the root service of the generated client
45
+ *
46
+ *
47
+ * __Example:__
48
+ *
49
+ * Given the following procedures:
50
+ * - users.getUser
51
+ * - users.updateUser
52
+ * - posts.getPost
53
+ * - posts.updatePosts
54
+ *
55
+ * Setting the rootService to `posts` means the generated client will only have the following procedures:
56
+ * - getPost
57
+ * - updatePosts
58
+ */
59
+ rootService?: string;
37
60
  }
38
61
  declare const swiftClientGenerator: _arrirpc_codegen_utils.GeneratorPlugin<SwiftClientGeneratorOptions>;
39
62
  declare function createSwiftClient(def: AppDefinition, options: SwiftClientGeneratorOptions): string;
40
63
  declare function swiftTypeFromSchema(schema: Schema, context: GeneratorContext): SwiftProperty;
41
64
 
42
- export { type SwiftClientGeneratorOptions, createSwiftClient, swiftClientGenerator, swiftTypeFromSchema };
65
+ export { createSwiftClient, swiftClientGenerator, swiftTypeFromSchema };
66
+ export type { SwiftClientGeneratorOptions };
package/dist/index.d.mts CHANGED
@@ -31,12 +31,36 @@ interface SwiftProperty {
31
31
  }
32
32
 
33
33
  interface SwiftClientGeneratorOptions {
34
- clientName: string;
34
+ /**
35
+ * Defaults to "Client"
36
+ */
37
+ clientName?: string;
35
38
  outputFile: string;
39
+ /**
40
+ * Add a prefix to the generated structs
41
+ */
36
42
  typePrefix?: string;
43
+ /**
44
+ * Set the root service of the generated client
45
+ *
46
+ *
47
+ * __Example:__
48
+ *
49
+ * Given the following procedures:
50
+ * - users.getUser
51
+ * - users.updateUser
52
+ * - posts.getPost
53
+ * - posts.updatePosts
54
+ *
55
+ * Setting the rootService to `posts` means the generated client will only have the following procedures:
56
+ * - getPost
57
+ * - updatePosts
58
+ */
59
+ rootService?: string;
37
60
  }
38
61
  declare const swiftClientGenerator: _arrirpc_codegen_utils.GeneratorPlugin<SwiftClientGeneratorOptions>;
39
62
  declare function createSwiftClient(def: AppDefinition, options: SwiftClientGeneratorOptions): string;
40
63
  declare function swiftTypeFromSchema(schema: Schema, context: GeneratorContext): SwiftProperty;
41
64
 
42
- export { type SwiftClientGeneratorOptions, createSwiftClient, swiftClientGenerator, swiftTypeFromSchema };
65
+ export { createSwiftClient, swiftClientGenerator, swiftTypeFromSchema };
66
+ export type { SwiftClientGeneratorOptions };
package/dist/index.d.ts CHANGED
@@ -31,12 +31,36 @@ interface SwiftProperty {
31
31
  }
32
32
 
33
33
  interface SwiftClientGeneratorOptions {
34
- clientName: string;
34
+ /**
35
+ * Defaults to "Client"
36
+ */
37
+ clientName?: string;
35
38
  outputFile: string;
39
+ /**
40
+ * Add a prefix to the generated structs
41
+ */
36
42
  typePrefix?: string;
43
+ /**
44
+ * Set the root service of the generated client
45
+ *
46
+ *
47
+ * __Example:__
48
+ *
49
+ * Given the following procedures:
50
+ * - users.getUser
51
+ * - users.updateUser
52
+ * - posts.getPost
53
+ * - posts.updatePosts
54
+ *
55
+ * Setting the rootService to `posts` means the generated client will only have the following procedures:
56
+ * - getPost
57
+ * - updatePosts
58
+ */
59
+ rootService?: string;
37
60
  }
38
61
  declare const swiftClientGenerator: _arrirpc_codegen_utils.GeneratorPlugin<SwiftClientGeneratorOptions>;
39
62
  declare function createSwiftClient(def: AppDefinition, options: SwiftClientGeneratorOptions): string;
40
63
  declare function swiftTypeFromSchema(schema: Schema, context: GeneratorContext): SwiftProperty;
41
64
 
42
- export { type SwiftClientGeneratorOptions, createSwiftClient, swiftClientGenerator, swiftTypeFromSchema };
65
+ export { createSwiftClient, swiftClientGenerator, swiftTypeFromSchema };
66
+ export type { SwiftClientGeneratorOptions };
package/dist/index.mjs CHANGED
@@ -1391,14 +1391,14 @@ const swiftClientGenerator = defineGeneratorPlugin(
1391
1391
  function createSwiftClient(def, options) {
1392
1392
  const context = {
1393
1393
  clientVersion: def.info?.version ?? "",
1394
- clientName: options.clientName,
1394
+ clientName: options.clientName ?? "Client",
1395
1395
  typePrefix: options.typePrefix ?? "",
1396
1396
  instancePath: "",
1397
1397
  schemaPath: "",
1398
1398
  generatedTypes: [],
1399
1399
  containsRequiredRef: {}
1400
1400
  };
1401
- const services = unflattenProcedures(def.procedures);
1401
+ const services = unflattenProcedures(def.procedures, options.rootService);
1402
1402
  const mainService = swiftServiceFromSchema(services, context);
1403
1403
  const typeContent = [];
1404
1404
  for (const key of Object.keys(def.definitions)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arrirpc/codegen-swift",
3
- "version": "0.76.3",
3
+ "version": "0.77.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -22,7 +22,7 @@
22
22
  "dist"
23
23
  ],
24
24
  "dependencies": {
25
- "@arrirpc/codegen-utils": "0.76.3"
25
+ "@arrirpc/codegen-utils": "0.77.0"
26
26
  },
27
27
  "devDependencies": {}
28
28
  }