@arrirpc/codegen-dart 0.78.0 → 0.79.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
@@ -11,7 +11,7 @@ const fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
11
11
  const path__default = /*#__PURE__*/_interopDefaultCompat(path);
12
12
 
13
13
  function outputIsNullable(schema, context) {
14
- if (schema.nullable) {
14
+ if (schema.isNullable) {
15
15
  return true;
16
16
  }
17
17
  if (context.isOptional) {
@@ -241,7 +241,7 @@ function dartListFromSchema(schema, context) {
241
241
  if (context.isOptional) {
242
242
  return `${input}!.map((_el_) => ${innerType.toJson("_el_", "", "")}).toList()`;
243
243
  }
244
- if (schema.nullable) {
244
+ if (schema.isNullable) {
245
245
  return `${input}?.map((_el_) => ${innerType.toJson("_el_", "", "")}).toList()`;
246
246
  }
247
247
  return `${input}.map((_el_) => ${innerType.toJson("_el_", "", "")}).toList()`;
@@ -266,19 +266,15 @@ function dartClassFromSchema(schema, context) {
266
266
  defaultValue,
267
267
  fromJson(input) {
268
268
  if (isNullable) {
269
- return `${input} is Map<String, dynamic>
270
- ? ${finalClassName}.fromJson(${input})
271
- : null`;
269
+ return `${input} is Map<String, dynamic> ? ${finalClassName}.fromJson(${input}) : null`;
272
270
  }
273
- return `${input} is Map<String, dynamic>
274
- ? ${finalClassName}.fromJson(${input})
275
- : ${finalClassName}.empty()`;
271
+ return `${input} is Map<String, dynamic> ? ${finalClassName}.fromJson(${input}) : ${finalClassName}.empty()`;
276
272
  },
277
273
  toJson(input) {
278
274
  if (context.isOptional) {
279
275
  return `${input}!.toJson()`;
280
276
  }
281
- if (schema.nullable) {
277
+ if (schema.isNullable) {
282
278
  return `${input}?.toJson()`;
283
279
  }
284
280
  return `${input}.toJson()`;
@@ -520,19 +516,15 @@ function dartSealedClassFromSchema(schema, context) {
520
516
  defaultValue,
521
517
  fromJson(input) {
522
518
  if (isNullable) {
523
- return `${input} is Map<String, dynamic>
524
- ? ${finalClassName}.fromJson(${input})
525
- : null`;
519
+ return `${input} is Map<String, dynamic> ? ${finalClassName}.fromJson(${input}) : null`;
526
520
  }
527
- return `${input} is Map<String, dynamic>
528
- ? ${finalClassName}.fromJson(${input})
529
- : ${finalClassName}.empty()`;
521
+ return `${input} is Map<String, dynamic> ? ${finalClassName}.fromJson(${input}) : ${finalClassName}.empty()`;
530
522
  },
531
523
  toJson(input) {
532
524
  if (context.isOptional) {
533
525
  return `${input}!.toJson()`;
534
526
  }
535
- if (schema.nullable) {
527
+ if (schema.isNullable) {
536
528
  return `${input}?.toJson()`;
537
529
  }
538
530
  return `${input}.toJson()`;
@@ -605,7 +597,7 @@ function dartEnumFromSchema(schema, context) {
605
597
  if (context.isOptional) {
606
598
  return `${input}!.serialValue`;
607
599
  }
608
- if (schema.nullable) {
600
+ if (schema.isNullable) {
609
601
  return `${input}?.serialValue`;
610
602
  }
611
603
  return `${input}.serialValue`;
@@ -614,7 +606,7 @@ function dartEnumFromSchema(schema, context) {
614
606
  if (context.isOptional) {
615
607
  return `if (${input} != null) ${target}.add("${key}=\${${input}!.serialValue}")`;
616
608
  }
617
- if (schema.nullable) {
609
+ if (schema.isNullable) {
618
610
  return `${target}.add("${key}=\${${input}?.serialValue}")`;
619
611
  }
620
612
  return `${target}.add("${key}=\${${input}.serialValue}")`;
@@ -716,7 +708,7 @@ function dartDateTimeFromSchema(schema, context) {
716
708
  if (context.isOptional) {
717
709
  return `${input}!.toUtc().toIso8601String()`;
718
710
  }
719
- if (schema.nullable) {
711
+ if (schema.isNullable) {
720
712
  return `${input}?.toUtc().toIso8601String()`;
721
713
  }
722
714
  return `${input}.toUtc().toIso8601String()`;
@@ -725,7 +717,7 @@ function dartDateTimeFromSchema(schema, context) {
725
717
  if (context.isOptional) {
726
718
  return `if (${input} != null) ${target}.add("${key}=\${${input}!.toUtc().toIso8601String()}")`;
727
719
  }
728
- if (schema.nullable) {
720
+ if (schema.isNullable) {
729
721
  return `${target}.add("${key}=\${${input}?.toUtc().toIso8601String()}")`;
730
722
  }
731
723
  return `${target}.add("${key}=\${${input}.toUtc().toIso8601String()}")`;
@@ -803,7 +795,7 @@ function dartBigIntFromSchema(schema, context) {
803
795
  if (context.isOptional) {
804
796
  return `${input}!.toString()`;
805
797
  }
806
- if (schema.nullable) {
798
+ if (schema.isNullable) {
807
799
  return `${input}?.toString()`;
808
800
  }
809
801
  return `${input}.toString()`;
@@ -1028,7 +1020,7 @@ function dartMapFromSchema(schema, context) {
1028
1020
  if (context.isOptional) {
1029
1021
  return `${input}!.map((_key_, _val_) => MapEntry(_key_, ${innerType.toJson("_val_", "", "")},),)`;
1030
1022
  }
1031
- if (schema.nullable) {
1023
+ if (schema.isNullable) {
1032
1024
  return `${input}?.map((_key_, _val_) => MapEntry(_key_, ${innerType.toJson("_val_", "", "")},),)`;
1033
1025
  }
1034
1026
  return `${input}.map((_key_, _val_) => MapEntry(_key_, ${innerType.toJson("_val_", "", "")},),)`;
@@ -1067,7 +1059,7 @@ function dartRefFromSchema(schema, context) {
1067
1059
  if (context.isOptional) {
1068
1060
  return `${input}!.toJson()`;
1069
1061
  }
1070
- if (schema.nullable) {
1062
+ if (schema.isNullable) {
1071
1063
  return `${input}?.toJson()`;
1072
1064
  }
1073
1065
  return `${input}.toJson()`;
package/dist/index.mjs CHANGED
@@ -4,7 +4,7 @@ import { camelCase, pascalCase, removeDisallowedChars, isServiceDefinition, isRp
4
4
  import path from 'pathe';
5
5
 
6
6
  function outputIsNullable(schema, context) {
7
- if (schema.nullable) {
7
+ if (schema.isNullable) {
8
8
  return true;
9
9
  }
10
10
  if (context.isOptional) {
@@ -234,7 +234,7 @@ function dartListFromSchema(schema, context) {
234
234
  if (context.isOptional) {
235
235
  return `${input}!.map((_el_) => ${innerType.toJson("_el_", "", "")}).toList()`;
236
236
  }
237
- if (schema.nullable) {
237
+ if (schema.isNullable) {
238
238
  return `${input}?.map((_el_) => ${innerType.toJson("_el_", "", "")}).toList()`;
239
239
  }
240
240
  return `${input}.map((_el_) => ${innerType.toJson("_el_", "", "")}).toList()`;
@@ -259,19 +259,15 @@ function dartClassFromSchema(schema, context) {
259
259
  defaultValue,
260
260
  fromJson(input) {
261
261
  if (isNullable) {
262
- return `${input} is Map<String, dynamic>
263
- ? ${finalClassName}.fromJson(${input})
264
- : null`;
262
+ return `${input} is Map<String, dynamic> ? ${finalClassName}.fromJson(${input}) : null`;
265
263
  }
266
- return `${input} is Map<String, dynamic>
267
- ? ${finalClassName}.fromJson(${input})
268
- : ${finalClassName}.empty()`;
264
+ return `${input} is Map<String, dynamic> ? ${finalClassName}.fromJson(${input}) : ${finalClassName}.empty()`;
269
265
  },
270
266
  toJson(input) {
271
267
  if (context.isOptional) {
272
268
  return `${input}!.toJson()`;
273
269
  }
274
- if (schema.nullable) {
270
+ if (schema.isNullable) {
275
271
  return `${input}?.toJson()`;
276
272
  }
277
273
  return `${input}.toJson()`;
@@ -513,19 +509,15 @@ function dartSealedClassFromSchema(schema, context) {
513
509
  defaultValue,
514
510
  fromJson(input) {
515
511
  if (isNullable) {
516
- return `${input} is Map<String, dynamic>
517
- ? ${finalClassName}.fromJson(${input})
518
- : null`;
512
+ return `${input} is Map<String, dynamic> ? ${finalClassName}.fromJson(${input}) : null`;
519
513
  }
520
- return `${input} is Map<String, dynamic>
521
- ? ${finalClassName}.fromJson(${input})
522
- : ${finalClassName}.empty()`;
514
+ return `${input} is Map<String, dynamic> ? ${finalClassName}.fromJson(${input}) : ${finalClassName}.empty()`;
523
515
  },
524
516
  toJson(input) {
525
517
  if (context.isOptional) {
526
518
  return `${input}!.toJson()`;
527
519
  }
528
- if (schema.nullable) {
520
+ if (schema.isNullable) {
529
521
  return `${input}?.toJson()`;
530
522
  }
531
523
  return `${input}.toJson()`;
@@ -598,7 +590,7 @@ function dartEnumFromSchema(schema, context) {
598
590
  if (context.isOptional) {
599
591
  return `${input}!.serialValue`;
600
592
  }
601
- if (schema.nullable) {
593
+ if (schema.isNullable) {
602
594
  return `${input}?.serialValue`;
603
595
  }
604
596
  return `${input}.serialValue`;
@@ -607,7 +599,7 @@ function dartEnumFromSchema(schema, context) {
607
599
  if (context.isOptional) {
608
600
  return `if (${input} != null) ${target}.add("${key}=\${${input}!.serialValue}")`;
609
601
  }
610
- if (schema.nullable) {
602
+ if (schema.isNullable) {
611
603
  return `${target}.add("${key}=\${${input}?.serialValue}")`;
612
604
  }
613
605
  return `${target}.add("${key}=\${${input}.serialValue}")`;
@@ -709,7 +701,7 @@ function dartDateTimeFromSchema(schema, context) {
709
701
  if (context.isOptional) {
710
702
  return `${input}!.toUtc().toIso8601String()`;
711
703
  }
712
- if (schema.nullable) {
704
+ if (schema.isNullable) {
713
705
  return `${input}?.toUtc().toIso8601String()`;
714
706
  }
715
707
  return `${input}.toUtc().toIso8601String()`;
@@ -718,7 +710,7 @@ function dartDateTimeFromSchema(schema, context) {
718
710
  if (context.isOptional) {
719
711
  return `if (${input} != null) ${target}.add("${key}=\${${input}!.toUtc().toIso8601String()}")`;
720
712
  }
721
- if (schema.nullable) {
713
+ if (schema.isNullable) {
722
714
  return `${target}.add("${key}=\${${input}?.toUtc().toIso8601String()}")`;
723
715
  }
724
716
  return `${target}.add("${key}=\${${input}.toUtc().toIso8601String()}")`;
@@ -796,7 +788,7 @@ function dartBigIntFromSchema(schema, context) {
796
788
  if (context.isOptional) {
797
789
  return `${input}!.toString()`;
798
790
  }
799
- if (schema.nullable) {
791
+ if (schema.isNullable) {
800
792
  return `${input}?.toString()`;
801
793
  }
802
794
  return `${input}.toString()`;
@@ -1021,7 +1013,7 @@ function dartMapFromSchema(schema, context) {
1021
1013
  if (context.isOptional) {
1022
1014
  return `${input}!.map((_key_, _val_) => MapEntry(_key_, ${innerType.toJson("_val_", "", "")},),)`;
1023
1015
  }
1024
- if (schema.nullable) {
1016
+ if (schema.isNullable) {
1025
1017
  return `${input}?.map((_key_, _val_) => MapEntry(_key_, ${innerType.toJson("_val_", "", "")},),)`;
1026
1018
  }
1027
1019
  return `${input}.map((_key_, _val_) => MapEntry(_key_, ${innerType.toJson("_val_", "", "")},),)`;
@@ -1060,7 +1052,7 @@ function dartRefFromSchema(schema, context) {
1060
1052
  if (context.isOptional) {
1061
1053
  return `${input}!.toJson()`;
1062
1054
  }
1063
- if (schema.nullable) {
1055
+ if (schema.isNullable) {
1064
1056
  return `${input}?.toJson()`;
1065
1057
  }
1066
1058
  return `${input}.toJson()`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arrirpc/codegen-dart",
3
- "version": "0.78.0",
3
+ "version": "0.79.1",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -23,6 +23,6 @@
23
23
  ],
24
24
  "dependencies": {
25
25
  "pathe": "^2.0.3",
26
- "@arrirpc/codegen-utils": "0.78.0"
26
+ "@arrirpc/codegen-utils": "0.79.1"
27
27
  }
28
28
  }