@arrirpc/codegen-rust 0.74.1 → 0.75.1

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 CHANGED
@@ -114,6 +114,12 @@ function getTypeName(schema, context) {
114
114
  function formatDescriptionComment(description, leading = "") {
115
115
  return description.split("\n").map((line) => `${leading}/// ${line}`).join("\n");
116
116
  }
117
+ function maybeStr(show, char) {
118
+ if (show) {
119
+ return char;
120
+ }
121
+ return "";
122
+ }
117
123
 
118
124
  function rustAnyFromSchema(schema, context) {
119
125
  return {
@@ -771,15 +777,16 @@ function rustObjectFromSchema(schema, context) {
771
777
  leading += `#[deprecated]
772
778
  `;
773
779
  }
780
+ const hasProperties = fieldDeclarationParts.length > 0;
774
781
  result.content = `${leading}#[derive(Clone, Debug, PartialEq)]
775
782
  pub struct ${prefixedStructName} {
776
- ${fieldDeclarationParts.join(",\n")},
783
+ ${fieldDeclarationParts.join(",\n")}${maybeStr(hasProperties, ",")}
777
784
  }
778
785
 
779
786
  impl ArriModel for ${prefixedStructName} {
780
787
  fn new() -> Self {
781
788
  Self {
782
- ${defaultParts.join(",\n")},
789
+ ${defaultParts.join(",\n")}${maybeStr(hasProperties, ",")}
783
790
  }
784
791
  }
785
792
  fn from_json(input: serde_json::Value) -> Self {
@@ -1574,8 +1581,8 @@ function rustHttpRpcFromSchema(schema, context) {
1574
1581
  if (schema.isDeprecated) {
1575
1582
  leading += "#[deprecated]\n";
1576
1583
  }
1577
- const params = schema.params ? context.typeNamePrefix + validRustName(schema.params) : undefined;
1578
- const response = schema.response ? context.typeNamePrefix + validRustName(schema.response) : undefined;
1584
+ const params = schema.params ? context.typeNamePrefix + validRustName(schema.params) : void 0;
1585
+ const response = schema.response ? context.typeNamePrefix + validRustName(schema.response) : void 0;
1579
1586
  if (schema.isEventStream) {
1580
1587
  return `${leading}pub async fn ${functionName}<OnEvent>(
1581
1588
  &self,
package/dist/index.mjs CHANGED
@@ -106,6 +106,12 @@ function getTypeName(schema, context) {
106
106
  function formatDescriptionComment(description, leading = "") {
107
107
  return description.split("\n").map((line) => `${leading}/// ${line}`).join("\n");
108
108
  }
109
+ function maybeStr(show, char) {
110
+ if (show) {
111
+ return char;
112
+ }
113
+ return "";
114
+ }
109
115
 
110
116
  function rustAnyFromSchema(schema, context) {
111
117
  return {
@@ -763,15 +769,16 @@ function rustObjectFromSchema(schema, context) {
763
769
  leading += `#[deprecated]
764
770
  `;
765
771
  }
772
+ const hasProperties = fieldDeclarationParts.length > 0;
766
773
  result.content = `${leading}#[derive(Clone, Debug, PartialEq)]
767
774
  pub struct ${prefixedStructName} {
768
- ${fieldDeclarationParts.join(",\n")},
775
+ ${fieldDeclarationParts.join(",\n")}${maybeStr(hasProperties, ",")}
769
776
  }
770
777
 
771
778
  impl ArriModel for ${prefixedStructName} {
772
779
  fn new() -> Self {
773
780
  Self {
774
- ${defaultParts.join(",\n")},
781
+ ${defaultParts.join(",\n")}${maybeStr(hasProperties, ",")}
775
782
  }
776
783
  }
777
784
  fn from_json(input: serde_json::Value) -> Self {
@@ -1566,8 +1573,8 @@ function rustHttpRpcFromSchema(schema, context) {
1566
1573
  if (schema.isDeprecated) {
1567
1574
  leading += "#[deprecated]\n";
1568
1575
  }
1569
- const params = schema.params ? context.typeNamePrefix + validRustName(schema.params) : undefined;
1570
- const response = schema.response ? context.typeNamePrefix + validRustName(schema.response) : undefined;
1576
+ const params = schema.params ? context.typeNamePrefix + validRustName(schema.params) : void 0;
1577
+ const response = schema.response ? context.typeNamePrefix + validRustName(schema.response) : void 0;
1571
1578
  if (schema.isEventStream) {
1572
1579
  return `${leading}pub async fn ${functionName}<OnEvent>(
1573
1580
  &self,
package/package.json CHANGED
@@ -21,8 +21,8 @@
21
21
  "dist"
22
22
  ],
23
23
  "dependencies": {
24
- "pathe": "^2.0.2",
25
- "@arrirpc/codegen-utils": "0.74.1"
24
+ "pathe": "^2.0.3",
25
+ "@arrirpc/codegen-utils": "0.75.1"
26
26
  },
27
- "version": "0.74.1"
27
+ "version": "0.75.1"
28
28
  }