@arrirpc/codegen-dart 0.74.0 → 0.75.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 CHANGED
@@ -404,11 +404,12 @@ function dartClassFromSchema(schema, context) {
404
404
  String get ${validDartIdentifier(context.discriminatorKey)} => "${context.discriminatorValue}";
405
405
  `;
406
406
  }
407
+ const hasProperties = propNames.length > 0;
407
408
  result.content = `${getCodeComments(schema.metadata)}class ${finalClassName} implements ${context.discriminatorParentId ? `${context.modelPrefix}${context.discriminatorParentId}` : "ArriModel"} {
408
409
  ${fieldParts.join("\n")}
409
- const ${finalClassName}({
410
+ const ${finalClassName}(${hasProperties ? "{" : ""}
410
411
  ${constructorParts.join("\n")}
411
- });
412
+ ${hasProperties ? "}" : ""});
412
413
  ${discriminatorPart}
413
414
  factory ${finalClassName}.empty() {
414
415
  return ${finalClassName}(
@@ -449,9 +450,9 @@ ${toUrlQueryParts.join("\n")}
449
450
  }
450
451
 
451
452
  @override
452
- ${finalClassName} copyWith({
453
+ ${finalClassName} copyWith(${hasProperties ? "{" : ""}
453
454
  ${copyWithParamParts.join("\n")}
454
- }) {
455
+ ${hasProperties ? "}" : ""}) {
455
456
  return ${finalClassName}(
456
457
  ${copyWithReturnParts.join("\n")}
457
458
  );
@@ -581,7 +582,7 @@ function dartEnumFromSchema(schema, context) {
581
582
  const enumName = getDartClassName(schema, context);
582
583
  const typeName = isNullable ? `${context.modelPrefix}${enumName}?` : `${context.modelPrefix}${enumName}`;
583
584
  const enumValues = schema.enum.map((val) => ({
584
- name: codegenUtils.camelCase(val, { normalize: true }),
585
+ name: validDartIdentifier(codegenUtils.camelCase(val, { normalize: true })),
585
586
  serialValue: val
586
587
  }));
587
588
  if (!enumValues.length) {
@@ -1131,8 +1132,6 @@ function createDartClient(def, options) {
1131
1132
  clientName: options.clientName ?? "Client",
1132
1133
  modelPrefix: options.typePrefix ?? "",
1133
1134
  generatedTypes: [],
1134
- instancePath: "",
1135
- schemaPath: "",
1136
1135
  clientVersion: def.info?.version ?? ""
1137
1136
  };
1138
1137
  const services = codegenUtils.unflattenProcedures(def.procedures);
@@ -1161,13 +1160,8 @@ function createDartClient(def, options) {
1161
1160
  }
1162
1161
  if (codegenUtils.isRpcDefinition(subSchema)) {
1163
1162
  const rpc = dartRpcFromSchema(subSchema, {
1164
- clientName: context.clientName,
1165
1163
  modelPrefix: context.modelPrefix,
1166
- generatedTypes: context.generatedTypes,
1167
- instancePath: key,
1168
- schemaPath: `procedures.${key}`,
1169
- clientVersion: context.clientVersion
1170
- });
1164
+ instancePath: key});
1171
1165
  if (rpc) {
1172
1166
  rpcParts.push(rpc);
1173
1167
  }
package/dist/index.mjs CHANGED
@@ -397,11 +397,12 @@ function dartClassFromSchema(schema, context) {
397
397
  String get ${validDartIdentifier(context.discriminatorKey)} => "${context.discriminatorValue}";
398
398
  `;
399
399
  }
400
+ const hasProperties = propNames.length > 0;
400
401
  result.content = `${getCodeComments(schema.metadata)}class ${finalClassName} implements ${context.discriminatorParentId ? `${context.modelPrefix}${context.discriminatorParentId}` : "ArriModel"} {
401
402
  ${fieldParts.join("\n")}
402
- const ${finalClassName}({
403
+ const ${finalClassName}(${hasProperties ? "{" : ""}
403
404
  ${constructorParts.join("\n")}
404
- });
405
+ ${hasProperties ? "}" : ""});
405
406
  ${discriminatorPart}
406
407
  factory ${finalClassName}.empty() {
407
408
  return ${finalClassName}(
@@ -442,9 +443,9 @@ ${toUrlQueryParts.join("\n")}
442
443
  }
443
444
 
444
445
  @override
445
- ${finalClassName} copyWith({
446
+ ${finalClassName} copyWith(${hasProperties ? "{" : ""}
446
447
  ${copyWithParamParts.join("\n")}
447
- }) {
448
+ ${hasProperties ? "}" : ""}) {
448
449
  return ${finalClassName}(
449
450
  ${copyWithReturnParts.join("\n")}
450
451
  );
@@ -574,7 +575,7 @@ function dartEnumFromSchema(schema, context) {
574
575
  const enumName = getDartClassName(schema, context);
575
576
  const typeName = isNullable ? `${context.modelPrefix}${enumName}?` : `${context.modelPrefix}${enumName}`;
576
577
  const enumValues = schema.enum.map((val) => ({
577
- name: camelCase(val, { normalize: true }),
578
+ name: validDartIdentifier(camelCase(val, { normalize: true })),
578
579
  serialValue: val
579
580
  }));
580
581
  if (!enumValues.length) {
@@ -1124,8 +1125,6 @@ function createDartClient(def, options) {
1124
1125
  clientName: options.clientName ?? "Client",
1125
1126
  modelPrefix: options.typePrefix ?? "",
1126
1127
  generatedTypes: [],
1127
- instancePath: "",
1128
- schemaPath: "",
1129
1128
  clientVersion: def.info?.version ?? ""
1130
1129
  };
1131
1130
  const services = unflattenProcedures(def.procedures);
@@ -1154,13 +1153,8 @@ function createDartClient(def, options) {
1154
1153
  }
1155
1154
  if (isRpcDefinition(subSchema)) {
1156
1155
  const rpc = dartRpcFromSchema(subSchema, {
1157
- clientName: context.clientName,
1158
1156
  modelPrefix: context.modelPrefix,
1159
- generatedTypes: context.generatedTypes,
1160
- instancePath: key,
1161
- schemaPath: `procedures.${key}`,
1162
- clientVersion: context.clientVersion
1163
- });
1157
+ instancePath: key});
1164
1158
  if (rpc) {
1165
1159
  rpcParts.push(rpc);
1166
1160
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arrirpc/codegen-dart",
3
- "version": "0.74.0",
3
+ "version": "0.75.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
- "pathe": "^2.0.2",
26
- "@arrirpc/codegen-utils": "0.74.0"
25
+ "pathe": "^2.0.3",
26
+ "@arrirpc/codegen-utils": "0.75.0"
27
27
  }
28
28
  }