@arrirpc/codegen-dart 0.71.1 → 0.73.0

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.cjs CHANGED
@@ -404,7 +404,7 @@ function dartClassFromSchema(schema, context) {
404
404
  String get ${validDartIdentifier(context.discriminatorKey)} => "${context.discriminatorValue}";
405
405
  `;
406
406
  }
407
- result.content = `${getCodeComments(schema.metadata)}class ${finalClassName} implements ${context.discriminatorParentId ?? "ArriModel"} {
407
+ result.content = `${getCodeComments(schema.metadata)}class ${finalClassName} implements ${context.discriminatorParentId ? `${context.modelPrefix}${context.discriminatorParentId}` : "ArriModel"} {
408
408
  ${fieldParts.join("\n")}
409
409
  const ${finalClassName}({
410
410
  ${constructorParts.join("\n")}
@@ -579,7 +579,7 @@ ${subContentParts.join("\n\n")}`;
579
579
  function dartEnumFromSchema(schema, context) {
580
580
  const isNullable = outputIsNullable(schema, context);
581
581
  const enumName = getDartClassName(schema, context);
582
- const typeName = isNullable ? `${enumName}?` : enumName;
582
+ const typeName = isNullable ? `${context.modelPrefix}${enumName}?` : `${context.modelPrefix}${enumName}`;
583
583
  const enumValues = schema.enum.map((val) => ({
584
584
  name: codegenUtils.camelCase(val, { normalize: true }),
585
585
  serialValue: val
@@ -639,7 +639,7 @@ ${enumValues.map((val) => ` ${val.name}("${val.serialValue}")`).join(",\n")};
639
639
  }
640
640
 
641
641
  @override
642
- int compareTo(${enumName} other) => name.compareTo(other.name);
642
+ int compareTo(${context.modelPrefix}${enumName} other) => name.compareTo(other.name);
643
643
  }`;
644
644
  context.generatedTypes.push(enumName);
645
645
  return output;
@@ -1129,7 +1129,7 @@ function createDartClient(def, options) {
1129
1129
  const typeParts = [];
1130
1130
  const context = {
1131
1131
  clientName: options.clientName ?? "Client",
1132
- modelPrefix: options.modelPrefix ?? "",
1132
+ modelPrefix: options.typePrefix ?? "",
1133
1133
  generatedTypes: [],
1134
1134
  instancePath: "",
1135
1135
  schemaPath: "",
package/dist/index.d.cts CHANGED
@@ -26,7 +26,10 @@ interface DartProperty {
26
26
  interface DartClientGeneratorOptions {
27
27
  outputFile: string;
28
28
  clientName?: string;
29
- modelPrefix?: string;
29
+ /**
30
+ * Add a prefix to the generated class names
31
+ */
32
+ typePrefix?: string;
30
33
  format?: boolean;
31
34
  }
32
35
  declare const dartClientGenerator: _arrirpc_codegen_utils.GeneratorPlugin<DartClientGeneratorOptions>;
package/dist/index.d.mts CHANGED
@@ -26,7 +26,10 @@ interface DartProperty {
26
26
  interface DartClientGeneratorOptions {
27
27
  outputFile: string;
28
28
  clientName?: string;
29
- modelPrefix?: string;
29
+ /**
30
+ * Add a prefix to the generated class names
31
+ */
32
+ typePrefix?: string;
30
33
  format?: boolean;
31
34
  }
32
35
  declare const dartClientGenerator: _arrirpc_codegen_utils.GeneratorPlugin<DartClientGeneratorOptions>;
package/dist/index.d.ts CHANGED
@@ -26,7 +26,10 @@ interface DartProperty {
26
26
  interface DartClientGeneratorOptions {
27
27
  outputFile: string;
28
28
  clientName?: string;
29
- modelPrefix?: string;
29
+ /**
30
+ * Add a prefix to the generated class names
31
+ */
32
+ typePrefix?: string;
30
33
  format?: boolean;
31
34
  }
32
35
  declare const dartClientGenerator: _arrirpc_codegen_utils.GeneratorPlugin<DartClientGeneratorOptions>;
package/dist/index.mjs CHANGED
@@ -397,7 +397,7 @@ function dartClassFromSchema(schema, context) {
397
397
  String get ${validDartIdentifier(context.discriminatorKey)} => "${context.discriminatorValue}";
398
398
  `;
399
399
  }
400
- result.content = `${getCodeComments(schema.metadata)}class ${finalClassName} implements ${context.discriminatorParentId ?? "ArriModel"} {
400
+ result.content = `${getCodeComments(schema.metadata)}class ${finalClassName} implements ${context.discriminatorParentId ? `${context.modelPrefix}${context.discriminatorParentId}` : "ArriModel"} {
401
401
  ${fieldParts.join("\n")}
402
402
  const ${finalClassName}({
403
403
  ${constructorParts.join("\n")}
@@ -572,7 +572,7 @@ ${subContentParts.join("\n\n")}`;
572
572
  function dartEnumFromSchema(schema, context) {
573
573
  const isNullable = outputIsNullable(schema, context);
574
574
  const enumName = getDartClassName(schema, context);
575
- const typeName = isNullable ? `${enumName}?` : enumName;
575
+ const typeName = isNullable ? `${context.modelPrefix}${enumName}?` : `${context.modelPrefix}${enumName}`;
576
576
  const enumValues = schema.enum.map((val) => ({
577
577
  name: camelCase(val, { normalize: true }),
578
578
  serialValue: val
@@ -632,7 +632,7 @@ ${enumValues.map((val) => ` ${val.name}("${val.serialValue}")`).join(",\n")};
632
632
  }
633
633
 
634
634
  @override
635
- int compareTo(${enumName} other) => name.compareTo(other.name);
635
+ int compareTo(${context.modelPrefix}${enumName} other) => name.compareTo(other.name);
636
636
  }`;
637
637
  context.generatedTypes.push(enumName);
638
638
  return output;
@@ -1122,7 +1122,7 @@ function createDartClient(def, options) {
1122
1122
  const typeParts = [];
1123
1123
  const context = {
1124
1124
  clientName: options.clientName ?? "Client",
1125
- modelPrefix: options.modelPrefix ?? "",
1125
+ modelPrefix: options.typePrefix ?? "",
1126
1126
  generatedTypes: [],
1127
1127
  instancePath: "",
1128
1128
  schemaPath: "",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arrirpc/codegen-dart",
3
- "version": "0.71.1",
3
+ "version": "0.73.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.1",
26
- "@arrirpc/codegen-utils": "0.71.1"
25
+ "pathe": "^2.0.2",
26
+ "@arrirpc/codegen-utils": "0.73.0"
27
27
  }
28
28
  }