@arrirpc/codegen-rust 0.76.4 → 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
@@ -22,10 +22,11 @@ export default defineConfig({
22
22
 
23
23
  | Name | Descriptions |
24
24
  | --------------------- | -------------------------------------------------------------------------- |
25
- | clientName | The named of the generated client struct (Defaults to "Client") |
26
25
  | outputFile (required) | Path to the file that will be created by the generator |
26
+ | clientName | The named of the generated client struct (Defaults to "Client") |
27
27
  | typePrefix | Add a prefix to the generated struct names |
28
28
  | format | Whether to run `rustfmt` on the generated file or not (Defaults to "true") |
29
+ | rootService | The root service of the generated client |
29
30
 
30
31
  ### 2) Install the Rust client library
31
32
 
package/dist/index.cjs CHANGED
@@ -161,7 +161,8 @@ function rustArrayFromSchema(schema, context) {
161
161
  clientVersion: context.clientVersion,
162
162
  clientName: context.clientName,
163
163
  typeNamePrefix: context.typeNamePrefix,
164
- generatedTypes: context.generatedTypes
164
+ generatedTypes: context.generatedTypes,
165
+ rootService: context.rootService
165
166
  });
166
167
  const isOptionType = outputIsOptionType(schema, context);
167
168
  const typeName = isOptionType ? `Option<Vec<${innerType.finalTypeName}>>` : `Vec<${innerType.finalTypeName}>`;
@@ -306,7 +307,8 @@ function rustTaggedUnionFromSchema(schema, context) {
306
307
  schemaPath: `${context.schemaPath}/mapping/${key}`,
307
308
  generatedTypes: context.generatedTypes,
308
309
  discriminatorKey,
309
- discriminatorValue
310
+ discriminatorValue,
311
+ rootService: context.rootService
310
312
  });
311
313
  if (keyType.content) subTypeContent.push(keyType.content);
312
314
  const keyName = validRustIdentifier(key);
@@ -353,7 +355,8 @@ function rustTaggedUnionFromSchema(schema, context) {
353
355
  schemaPath: `${context.schemaPath}/mapping/${key}`,
354
356
  generatedTypes: context.generatedTypes,
355
357
  discriminatorKey,
356
- discriminatorValue
358
+ discriminatorValue,
359
+ rootService: context.rootService
357
360
  });
358
361
  if (keyType.content) subTypeContent.push(keyType.content);
359
362
  const keyName = validRustIdentifier(key);
@@ -656,7 +659,8 @@ function rustObjectFromSchema(schema, context) {
656
659
  typeNamePrefix: context.typeNamePrefix,
657
660
  instancePath: `/${structName}/${key}`,
658
661
  schemaPath: `${context.schemaPath}/properties/${key}`,
659
- generatedTypes: context.generatedTypes
662
+ generatedTypes: context.generatedTypes,
663
+ rootService: context.rootService
660
664
  });
661
665
  if (innerType.content) {
662
666
  subContent.push(innerType.content);
@@ -714,7 +718,8 @@ function rustObjectFromSchema(schema, context) {
714
718
  instancePath: `/${structName}/${key}`,
715
719
  schemaPath: `${context.schemaPath}/optionalProperties/${key}`,
716
720
  generatedTypes: context.generatedTypes,
717
- isOptional: true
721
+ isOptional: true,
722
+ rootService: context.rootService
718
723
  });
719
724
  if (innerType.content) {
720
725
  subContent.push(innerType.content);
@@ -1657,7 +1662,8 @@ function rustServiceFromSchema(schema, context) {
1657
1662
  typeNamePrefix: context.typeNamePrefix,
1658
1663
  instancePath: `${context.instancePath}.${key}`,
1659
1664
  schemaPath: `${context.schemaPath}.${key}`,
1660
- generatedTypes: context.generatedTypes
1665
+ generatedTypes: context.generatedTypes,
1666
+ rootService: context.rootService
1661
1667
  });
1662
1668
  if (subService.content) {
1663
1669
  subServices.push({
@@ -1674,7 +1680,8 @@ function rustServiceFromSchema(schema, context) {
1674
1680
  typeNamePrefix: context.typeNamePrefix,
1675
1681
  instancePath: `${context.instancePath}.${key}`,
1676
1682
  schemaPath: `${context.schemaPath}.${key}`,
1677
- generatedTypes: context.generatedTypes
1683
+ generatedTypes: context.generatedTypes,
1684
+ rootService: context.rootService
1678
1685
  });
1679
1686
  if (rpc) {
1680
1687
  rpcParts.push(rpc);
@@ -1724,7 +1731,8 @@ function rustRecordFromSchema(schema, context) {
1724
1731
  typeNamePrefix: context.typeNamePrefix,
1725
1732
  instancePath: `${context.instancePath}/value`,
1726
1733
  schemaPath: `${context.schemaPath}/values`,
1727
- generatedTypes: context.generatedTypes
1734
+ generatedTypes: context.generatedTypes,
1735
+ rootService: context.rootService
1728
1736
  });
1729
1737
  const isOptionType = outputIsOptionType(schema, context);
1730
1738
  const typeName = isOptionType ? `Option<BTreeMap<String, ${innerType.finalTypeName}>>` : `BTreeMap<String, ${innerType.finalTypeName}>`;
@@ -1869,7 +1877,8 @@ const rustClientGenerator = codegenUtils.defineGeneratorPlugin(
1869
1877
  typeNamePrefix: options.typePrefix ?? "",
1870
1878
  instancePath: "",
1871
1879
  schemaPath: "",
1872
- generatedTypes: []
1880
+ generatedTypes: [],
1881
+ rootService: options.rootService
1873
1882
  };
1874
1883
  const client = createRustClient(def, {
1875
1884
  ...context
@@ -1891,7 +1900,7 @@ const rustClientGenerator = codegenUtils.defineGeneratorPlugin(
1891
1900
  }
1892
1901
  );
1893
1902
  function createRustClient(def, context) {
1894
- const services = codegenUtils.unflattenProcedures(def.procedures);
1903
+ const services = codegenUtils.unflattenProcedures(def.procedures, context.rootService);
1895
1904
  const rpcParts = [];
1896
1905
  const subServices = [];
1897
1906
  const subServiceContent = [];
@@ -1904,7 +1913,8 @@ function createRustClient(def, context) {
1904
1913
  typeNamePrefix: context.typeNamePrefix,
1905
1914
  instancePath: key,
1906
1915
  schemaPath: key,
1907
- generatedTypes: context.generatedTypes
1916
+ generatedTypes: context.generatedTypes,
1917
+ rootService: context.rootService
1908
1918
  });
1909
1919
  if (service.content) {
1910
1920
  subServices.push({
@@ -1921,7 +1931,8 @@ function createRustClient(def, context) {
1921
1931
  clientName: context.clientName,
1922
1932
  typeNamePrefix: context.typeNamePrefix,
1923
1933
  instancePath: key,
1924
- generatedTypes: context.generatedTypes
1934
+ generatedTypes: context.generatedTypes,
1935
+ rootService: context.rootService
1925
1936
  });
1926
1937
  if (rpc) {
1927
1938
  rpcParts.push(rpc);
package/dist/index.d.cts CHANGED
@@ -11,6 +11,7 @@ interface GeneratorContext {
11
11
  discriminatorKey?: string;
12
12
  discriminatorValue?: string;
13
13
  isOptional?: boolean;
14
+ rootService: string | undefined;
14
15
  }
15
16
  interface RustProperty {
16
17
  typeId: string;
@@ -31,9 +32,11 @@ interface RustClientGeneratorOptions {
31
32
  outputFile: string;
32
33
  format?: boolean;
33
34
  typePrefix?: string;
35
+ rootService?: string;
34
36
  }
35
37
  declare const rustClientGenerator: _arrirpc_codegen_utils.GeneratorPlugin<RustClientGeneratorOptions>;
36
38
  declare function createRustClient(def: AppDefinition, context: Omit<GeneratorContext, 'clientVersion'>): string;
37
39
  declare function rustTypeFromSchema(schema: Schema, context: GeneratorContext): RustProperty;
38
40
 
39
- export { type RustClientGeneratorOptions, createRustClient, rustClientGenerator, rustTypeFromSchema };
41
+ export { createRustClient, rustClientGenerator, rustTypeFromSchema };
42
+ export type { RustClientGeneratorOptions };
package/dist/index.d.mts CHANGED
@@ -11,6 +11,7 @@ interface GeneratorContext {
11
11
  discriminatorKey?: string;
12
12
  discriminatorValue?: string;
13
13
  isOptional?: boolean;
14
+ rootService: string | undefined;
14
15
  }
15
16
  interface RustProperty {
16
17
  typeId: string;
@@ -31,9 +32,11 @@ interface RustClientGeneratorOptions {
31
32
  outputFile: string;
32
33
  format?: boolean;
33
34
  typePrefix?: string;
35
+ rootService?: string;
34
36
  }
35
37
  declare const rustClientGenerator: _arrirpc_codegen_utils.GeneratorPlugin<RustClientGeneratorOptions>;
36
38
  declare function createRustClient(def: AppDefinition, context: Omit<GeneratorContext, 'clientVersion'>): string;
37
39
  declare function rustTypeFromSchema(schema: Schema, context: GeneratorContext): RustProperty;
38
40
 
39
- export { type RustClientGeneratorOptions, createRustClient, rustClientGenerator, rustTypeFromSchema };
41
+ export { createRustClient, rustClientGenerator, rustTypeFromSchema };
42
+ export type { RustClientGeneratorOptions };
package/dist/index.d.ts CHANGED
@@ -11,6 +11,7 @@ interface GeneratorContext {
11
11
  discriminatorKey?: string;
12
12
  discriminatorValue?: string;
13
13
  isOptional?: boolean;
14
+ rootService: string | undefined;
14
15
  }
15
16
  interface RustProperty {
16
17
  typeId: string;
@@ -31,9 +32,11 @@ interface RustClientGeneratorOptions {
31
32
  outputFile: string;
32
33
  format?: boolean;
33
34
  typePrefix?: string;
35
+ rootService?: string;
34
36
  }
35
37
  declare const rustClientGenerator: _arrirpc_codegen_utils.GeneratorPlugin<RustClientGeneratorOptions>;
36
38
  declare function createRustClient(def: AppDefinition, context: Omit<GeneratorContext, 'clientVersion'>): string;
37
39
  declare function rustTypeFromSchema(schema: Schema, context: GeneratorContext): RustProperty;
38
40
 
39
- export { type RustClientGeneratorOptions, createRustClient, rustClientGenerator, rustTypeFromSchema };
41
+ export { createRustClient, rustClientGenerator, rustTypeFromSchema };
42
+ export type { RustClientGeneratorOptions };
package/dist/index.mjs CHANGED
@@ -153,7 +153,8 @@ function rustArrayFromSchema(schema, context) {
153
153
  clientVersion: context.clientVersion,
154
154
  clientName: context.clientName,
155
155
  typeNamePrefix: context.typeNamePrefix,
156
- generatedTypes: context.generatedTypes
156
+ generatedTypes: context.generatedTypes,
157
+ rootService: context.rootService
157
158
  });
158
159
  const isOptionType = outputIsOptionType(schema, context);
159
160
  const typeName = isOptionType ? `Option<Vec<${innerType.finalTypeName}>>` : `Vec<${innerType.finalTypeName}>`;
@@ -298,7 +299,8 @@ function rustTaggedUnionFromSchema(schema, context) {
298
299
  schemaPath: `${context.schemaPath}/mapping/${key}`,
299
300
  generatedTypes: context.generatedTypes,
300
301
  discriminatorKey,
301
- discriminatorValue
302
+ discriminatorValue,
303
+ rootService: context.rootService
302
304
  });
303
305
  if (keyType.content) subTypeContent.push(keyType.content);
304
306
  const keyName = validRustIdentifier(key);
@@ -345,7 +347,8 @@ function rustTaggedUnionFromSchema(schema, context) {
345
347
  schemaPath: `${context.schemaPath}/mapping/${key}`,
346
348
  generatedTypes: context.generatedTypes,
347
349
  discriminatorKey,
348
- discriminatorValue
350
+ discriminatorValue,
351
+ rootService: context.rootService
349
352
  });
350
353
  if (keyType.content) subTypeContent.push(keyType.content);
351
354
  const keyName = validRustIdentifier(key);
@@ -648,7 +651,8 @@ function rustObjectFromSchema(schema, context) {
648
651
  typeNamePrefix: context.typeNamePrefix,
649
652
  instancePath: `/${structName}/${key}`,
650
653
  schemaPath: `${context.schemaPath}/properties/${key}`,
651
- generatedTypes: context.generatedTypes
654
+ generatedTypes: context.generatedTypes,
655
+ rootService: context.rootService
652
656
  });
653
657
  if (innerType.content) {
654
658
  subContent.push(innerType.content);
@@ -706,7 +710,8 @@ function rustObjectFromSchema(schema, context) {
706
710
  instancePath: `/${structName}/${key}`,
707
711
  schemaPath: `${context.schemaPath}/optionalProperties/${key}`,
708
712
  generatedTypes: context.generatedTypes,
709
- isOptional: true
713
+ isOptional: true,
714
+ rootService: context.rootService
710
715
  });
711
716
  if (innerType.content) {
712
717
  subContent.push(innerType.content);
@@ -1649,7 +1654,8 @@ function rustServiceFromSchema(schema, context) {
1649
1654
  typeNamePrefix: context.typeNamePrefix,
1650
1655
  instancePath: `${context.instancePath}.${key}`,
1651
1656
  schemaPath: `${context.schemaPath}.${key}`,
1652
- generatedTypes: context.generatedTypes
1657
+ generatedTypes: context.generatedTypes,
1658
+ rootService: context.rootService
1653
1659
  });
1654
1660
  if (subService.content) {
1655
1661
  subServices.push({
@@ -1666,7 +1672,8 @@ function rustServiceFromSchema(schema, context) {
1666
1672
  typeNamePrefix: context.typeNamePrefix,
1667
1673
  instancePath: `${context.instancePath}.${key}`,
1668
1674
  schemaPath: `${context.schemaPath}.${key}`,
1669
- generatedTypes: context.generatedTypes
1675
+ generatedTypes: context.generatedTypes,
1676
+ rootService: context.rootService
1670
1677
  });
1671
1678
  if (rpc) {
1672
1679
  rpcParts.push(rpc);
@@ -1716,7 +1723,8 @@ function rustRecordFromSchema(schema, context) {
1716
1723
  typeNamePrefix: context.typeNamePrefix,
1717
1724
  instancePath: `${context.instancePath}/value`,
1718
1725
  schemaPath: `${context.schemaPath}/values`,
1719
- generatedTypes: context.generatedTypes
1726
+ generatedTypes: context.generatedTypes,
1727
+ rootService: context.rootService
1720
1728
  });
1721
1729
  const isOptionType = outputIsOptionType(schema, context);
1722
1730
  const typeName = isOptionType ? `Option<BTreeMap<String, ${innerType.finalTypeName}>>` : `BTreeMap<String, ${innerType.finalTypeName}>`;
@@ -1861,7 +1869,8 @@ const rustClientGenerator = defineGeneratorPlugin(
1861
1869
  typeNamePrefix: options.typePrefix ?? "",
1862
1870
  instancePath: "",
1863
1871
  schemaPath: "",
1864
- generatedTypes: []
1872
+ generatedTypes: [],
1873
+ rootService: options.rootService
1865
1874
  };
1866
1875
  const client = createRustClient(def, {
1867
1876
  ...context
@@ -1883,7 +1892,7 @@ const rustClientGenerator = defineGeneratorPlugin(
1883
1892
  }
1884
1893
  );
1885
1894
  function createRustClient(def, context) {
1886
- const services = unflattenProcedures(def.procedures);
1895
+ const services = unflattenProcedures(def.procedures, context.rootService);
1887
1896
  const rpcParts = [];
1888
1897
  const subServices = [];
1889
1898
  const subServiceContent = [];
@@ -1896,7 +1905,8 @@ function createRustClient(def, context) {
1896
1905
  typeNamePrefix: context.typeNamePrefix,
1897
1906
  instancePath: key,
1898
1907
  schemaPath: key,
1899
- generatedTypes: context.generatedTypes
1908
+ generatedTypes: context.generatedTypes,
1909
+ rootService: context.rootService
1900
1910
  });
1901
1911
  if (service.content) {
1902
1912
  subServices.push({
@@ -1913,7 +1923,8 @@ function createRustClient(def, context) {
1913
1923
  clientName: context.clientName,
1914
1924
  typeNamePrefix: context.typeNamePrefix,
1915
1925
  instancePath: key,
1916
- generatedTypes: context.generatedTypes
1926
+ generatedTypes: context.generatedTypes,
1927
+ rootService: context.rootService
1917
1928
  });
1918
1929
  if (rpc) {
1919
1930
  rpcParts.push(rpc);
package/package.json CHANGED
@@ -22,7 +22,7 @@
22
22
  ],
23
23
  "dependencies": {
24
24
  "pathe": "^2.0.3",
25
- "@arrirpc/codegen-utils": "0.76.4"
25
+ "@arrirpc/codegen-utils": "0.77.0"
26
26
  },
27
- "version": "0.76.4"
27
+ "version": "0.77.0"
28
28
  }