arri 0.0.9 → 0.0.10

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.
@@ -29,7 +29,7 @@ require('node:module');
29
29
  require('node:assert');
30
30
  require('node:v8');
31
31
  require('node:util');
32
- require('../shared/arri.835c5c3c.cjs');
32
+ require('../shared/arri.24f662c0.cjs');
33
33
  require('fs/promises');
34
34
  require('child_process');
35
35
  require('node:http');
@@ -27,7 +27,7 @@ import 'node:module';
27
27
  import 'node:assert';
28
28
  import 'node:v8';
29
29
  import 'node:util';
30
- import '../shared/arri.0e69fc28.mjs';
30
+ import '../shared/arri.5b1d01a1.mjs';
31
31
  import 'fs/promises';
32
32
  import 'child_process';
33
33
  import 'node:http';
@@ -31,7 +31,7 @@ require('node:module');
31
31
  require('node:assert');
32
32
  require('node:v8');
33
33
  require('node:util');
34
- require('../shared/arri.835c5c3c.cjs');
34
+ require('../shared/arri.24f662c0.cjs');
35
35
  require('fs/promises');
36
36
  require('child_process');
37
37
  require('node:http');
@@ -29,7 +29,7 @@ import 'node:module';
29
29
  import 'node:assert';
30
30
  import 'node:v8';
31
31
  import 'node:util';
32
- import '../shared/arri.0e69fc28.mjs';
32
+ import '../shared/arri.5b1d01a1.mjs';
33
33
  import 'fs/promises';
34
34
  import 'child_process';
35
35
  import 'node:http';
@@ -35,7 +35,7 @@ require('v8');
35
35
  require('node:module');
36
36
  require('node:assert');
37
37
  require('node:v8');
38
- require('../shared/arri.835c5c3c.cjs');
38
+ require('../shared/arri.24f662c0.cjs');
39
39
  require('fs/promises');
40
40
  require('child_process');
41
41
  require('node:http');
@@ -33,7 +33,7 @@ import 'v8';
33
33
  import 'node:module';
34
34
  import 'node:assert';
35
35
  import 'node:v8';
36
- import '../shared/arri.0e69fc28.mjs';
36
+ import '../shared/arri.5b1d01a1.mjs';
37
37
  import 'fs/promises';
38
38
  import 'child_process';
39
39
  import 'node:http';
package/dist/cli.cjs CHANGED
@@ -29,7 +29,7 @@ const node_module = require('node:module');
29
29
  const assert = require('node:assert');
30
30
  const v8$1 = require('node:v8');
31
31
  const node_util = require('node:util');
32
- const dart = require('./shared/arri.835c5c3c.cjs');
32
+ const dart = require('./shared/arri.24f662c0.cjs');
33
33
  const node_http = require('node:http');
34
34
  const https = require('node:https');
35
35
  const node_net = require('node:net');
package/dist/cli.mjs CHANGED
@@ -27,7 +27,7 @@ import { builtinModules } from 'node:module';
27
27
  import assert from 'node:assert';
28
28
  import v8$1 from 'node:v8';
29
29
  import { format as format$1, inspect, promisify as promisify$5 } from 'node:util';
30
- import { f as format2, a as dartClientGenerator } from './shared/arri.0e69fc28.mjs';
30
+ import { f as format2, a as dartClientGenerator } from './shared/arri.5b1d01a1.mjs';
31
31
  import { createServer as createServer$2 } from 'node:http';
32
32
  import { createServer as createServer$1 } from 'node:https';
33
33
  import { createServer } from 'node:net';
package/dist/codegen.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const index = require('./shared/arri.8e602d87.cjs');
4
- const dart = require('./shared/arri.835c5c3c.cjs');
4
+ const dart = require('./shared/arri.24f662c0.cjs');
5
5
  const fs = require('fs');
6
6
  require('module');
7
7
  require('url');
@@ -29,7 +29,7 @@ declare function dartServiceFromServiceDefinition(name: string, def: ServiceDefi
29
29
  declare function dartProcedureFromServiceDefinition(clientName: string, key: string, def: ProcedureDefinition): string;
30
30
  declare function dartModelFromJsonSchema(name: string, schema: JsonSchemaObject): string;
31
31
  declare function dartPropertyTypeFromSchema(objectName: string, propertyName: string, schema: JsonSchemaObject): [DartType | string, string[] | undefined];
32
- declare function dartParsedJsonField(fieldName: string, dartType: string): string;
32
+ declare function dartParsedJsonField(fieldName: string, jsonKey: string, dartType: string): string;
33
33
  declare const dartTypeMap: {
34
34
  readonly integer: "int";
35
35
  readonly bigint: "int";
@@ -46,8 +46,8 @@ declare const dartTypeMap: {
46
46
  };
47
47
  interface DartMappedType {
48
48
  classBody?: string;
49
- fromJsonBody: (jsonKey: string, fallback: string) => string;
50
- toJsonBody: (key: string, isNullable?: boolean) => string;
49
+ fromJsonBody: (key: string, jsonKey: string, fallback: string) => string;
50
+ toJsonBody: (key: string, jsonKey: string, isNullable?: boolean) => string;
51
51
  }
52
52
  declare const transformers: Record<DartType, DartMappedType>;
53
53
  declare const classTransformer: (typename: string, nullable: boolean) => DartMappedType;
@@ -29,7 +29,7 @@ declare function dartServiceFromServiceDefinition(name: string, def: ServiceDefi
29
29
  declare function dartProcedureFromServiceDefinition(clientName: string, key: string, def: ProcedureDefinition): string;
30
30
  declare function dartModelFromJsonSchema(name: string, schema: JsonSchemaObject): string;
31
31
  declare function dartPropertyTypeFromSchema(objectName: string, propertyName: string, schema: JsonSchemaObject): [DartType | string, string[] | undefined];
32
- declare function dartParsedJsonField(fieldName: string, dartType: string): string;
32
+ declare function dartParsedJsonField(fieldName: string, jsonKey: string, dartType: string): string;
33
33
  declare const dartTypeMap: {
34
34
  readonly integer: "int";
35
35
  readonly bigint: "int";
@@ -46,8 +46,8 @@ declare const dartTypeMap: {
46
46
  };
47
47
  interface DartMappedType {
48
48
  classBody?: string;
49
- fromJsonBody: (jsonKey: string, fallback: string) => string;
50
- toJsonBody: (key: string, isNullable?: boolean) => string;
49
+ fromJsonBody: (key: string, jsonKey: string, fallback: string) => string;
50
+ toJsonBody: (key: string, jsonKey: string, isNullable?: boolean) => string;
51
51
  }
52
52
  declare const transformers: Record<DartType, DartMappedType>;
53
53
  declare const classTransformer: (typename: string, nullable: boolean) => DartMappedType;
package/dist/codegen.d.ts CHANGED
@@ -29,7 +29,7 @@ declare function dartServiceFromServiceDefinition(name: string, def: ServiceDefi
29
29
  declare function dartProcedureFromServiceDefinition(clientName: string, key: string, def: ProcedureDefinition): string;
30
30
  declare function dartModelFromJsonSchema(name: string, schema: JsonSchemaObject): string;
31
31
  declare function dartPropertyTypeFromSchema(objectName: string, propertyName: string, schema: JsonSchemaObject): [DartType | string, string[] | undefined];
32
- declare function dartParsedJsonField(fieldName: string, dartType: string): string;
32
+ declare function dartParsedJsonField(fieldName: string, jsonKey: string, dartType: string): string;
33
33
  declare const dartTypeMap: {
34
34
  readonly integer: "int";
35
35
  readonly bigint: "int";
@@ -46,8 +46,8 @@ declare const dartTypeMap: {
46
46
  };
47
47
  interface DartMappedType {
48
48
  classBody?: string;
49
- fromJsonBody: (jsonKey: string, fallback: string) => string;
50
- toJsonBody: (key: string, isNullable?: boolean) => string;
49
+ fromJsonBody: (key: string, jsonKey: string, fallback: string) => string;
50
+ toJsonBody: (key: string, jsonKey: string, isNullable?: boolean) => string;
51
51
  }
52
52
  declare const transformers: Record<DartType, DartMappedType>;
53
53
  declare const classTransformer: (typename: string, nullable: boolean) => DartMappedType;
package/dist/codegen.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { u as unflattenObject, i as isServiceDefinition, p as pascalCase, a as isProcedureDefinition, b as isJsonSchemaScalarType, c as isJsonSchemaNullType, d as isJsonSchemaObject, e as isJsonSchemaEnum, f as isJsonSchemaArray } from './shared/arri.1f1b9dfc.mjs';
2
- import { d as defineClientGeneratorPlugin, f as format2 } from './shared/arri.0e69fc28.mjs';
3
- export { k as classListTransformer, j as classTransformer, c as createDartClient, a as dartClientGenerator, g as dartModelFromJsonSchema, i as dartParsedJsonField, e as dartProcedureFromServiceDefinition, h as dartPropertyTypeFromSchema, b as dartServiceFromServiceDefinition, l as isDartType, m as isDartTypeWithNullables, t as transformers } from './shared/arri.0e69fc28.mjs';
2
+ import { d as defineClientGeneratorPlugin, f as format2 } from './shared/arri.5b1d01a1.mjs';
3
+ export { k as classListTransformer, j as classTransformer, c as createDartClient, a as dartClientGenerator, g as dartModelFromJsonSchema, i as dartParsedJsonField, e as dartProcedureFromServiceDefinition, h as dartPropertyTypeFromSchema, b as dartServiceFromServiceDefinition, l as isDartType, m as isDartTypeWithNullables, t as transformers } from './shared/arri.5b1d01a1.mjs';
4
4
  import { writeFileSync } from 'fs';
5
5
  import 'module';
6
6
  import 'url';
@@ -25,8 +25,8 @@ const assert4__default = /*#__PURE__*/_interopDefaultCompat(assert4);
25
25
  const fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
26
26
  const v8__default = /*#__PURE__*/_interopDefaultCompat(v8);
27
27
 
28
- const require$2 = require$$2.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('shared/arri.835c5c3c.cjs', document.baseURI).href)));
29
- const __filename$2 = require$$7.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('shared/arri.835c5c3c.cjs', document.baseURI).href)));
28
+ const require$2 = require$$2.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('shared/arri.24f662c0.cjs', document.baseURI).href)));
29
+ const __filename$2 = require$$7.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('shared/arri.24f662c0.cjs', document.baseURI).href)));
30
30
  const __dirname$1 = require$$0.dirname(__filename$2);
31
31
 
32
32
  var __create$1 = Object.create;
@@ -7791,8 +7791,8 @@ const doc = {
7791
7791
  utils: utils
7792
7792
  };
7793
7793
 
7794
- const require$1 = require$$2.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('shared/arri.835c5c3c.cjs', document.baseURI).href)));
7795
- const __filename$1 = require$$7.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('shared/arri.835c5c3c.cjs', document.baseURI).href)));
7794
+ const require$1 = require$$2.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('shared/arri.24f662c0.cjs', document.baseURI).href)));
7795
+ const __filename$1 = require$$7.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('shared/arri.24f662c0.cjs', document.baseURI).href)));
7796
7796
  require$$0.dirname(__filename$1);
7797
7797
 
7798
7798
  var __create = Object.create;
@@ -29145,7 +29145,7 @@ class ${prefix} {
29145
29145
  return arriRequest(
29146
29146
  "$_baseUrl\${endpoint.path}",
29147
29147
  method: endpoint.method,
29148
- headers: headers ?? this._headers,
29148
+ headers: headers ?? _headers,
29149
29149
  body: body,
29150
29150
  query: query,
29151
29151
  encoding: encoding,
@@ -29294,7 +29294,7 @@ function dartModelFromJsonSchema(name, schema) {
29294
29294
  subModelParts.push(sub);
29295
29295
  }
29296
29296
  }
29297
- fields.push({ type: dartType, name: key });
29297
+ fields.push({ type: dartType, name: index.camelCase(key), jsonKey: key });
29298
29298
  if (!isDartType(dartType) && "type" in val && val.type === "object") {
29299
29299
  subModelParts.push(
29300
29300
  dartModelFromJsonSchema(dartType.replace("?", ""), val)
@@ -29310,7 +29310,13 @@ function dartModelFromJsonSchema(name, schema) {
29310
29310
  });
29311
29311
  factory ${name}.fromJson(Map<String, dynamic> json) {
29312
29312
  return ${name}(
29313
- ${fields.map((field) => `${dartParsedJsonField(field.name, field.type)},`).join("\n ")}
29313
+ ${fields.map(
29314
+ (field) => `${dartParsedJsonField(
29315
+ field.name,
29316
+ field.jsonKey,
29317
+ field.type
29318
+ )},`
29319
+ ).join("\n ")}
29314
29320
  );
29315
29321
  }
29316
29322
  Map<String, dynamic> toJson() {
@@ -29320,16 +29326,22 @@ function dartModelFromJsonSchema(name, schema) {
29320
29326
  const typeName = field.type.replace("?", "");
29321
29327
  if (isDartTypeWithNullables(field.type)) {
29322
29328
  const transformer = transformers[typeName];
29323
- return transformer.toJsonBody(field.name, isNullable);
29329
+ return transformer.toJsonBody(
29330
+ field.name,
29331
+ field.jsonKey,
29332
+ isNullable
29333
+ );
29324
29334
  }
29325
29335
  if (field.type.includes("List<")) {
29326
29336
  return classListTransformer(typeName).toJsonBody(
29327
29337
  field.name,
29338
+ field.jsonKey,
29328
29339
  isNullable
29329
29340
  );
29330
29341
  }
29331
29342
  return classTransformer(typeName, isNullable).toJsonBody(
29332
29343
  field.name,
29344
+ field.jsonKey,
29333
29345
  isNullable
29334
29346
  );
29335
29347
  }).join(",\n ")},
@@ -29468,28 +29480,49 @@ function dartPropertyTypeFromSchema(objectName, propertyName, schema) {
29468
29480
  }
29469
29481
  return [finalType, subTypes.length ? subTypes : void 0];
29470
29482
  }
29471
- function dartParsedJsonField(fieldName, dartType) {
29483
+ function dartParsedJsonField(fieldName, jsonKey, dartType) {
29472
29484
  if (isDartTypeWithNullables(dartType)) {
29473
29485
  switch (dartType) {
29474
29486
  case "String":
29475
- return transformers.String.fromJsonBody(fieldName, '""');
29487
+ return transformers.String.fromJsonBody(
29488
+ fieldName,
29489
+ jsonKey,
29490
+ '""'
29491
+ );
29476
29492
  case "String?":
29477
- return transformers.String.fromJsonBody(fieldName, "null");
29493
+ return transformers.String.fromJsonBody(
29494
+ fieldName,
29495
+ jsonKey,
29496
+ "null"
29497
+ );
29478
29498
  case "bool":
29479
- return transformers.bool.fromJsonBody(fieldName, "false");
29499
+ return transformers.bool.fromJsonBody(
29500
+ fieldName,
29501
+ jsonKey,
29502
+ "false"
29503
+ );
29480
29504
  case "double":
29481
- return transformers.double.fromJsonBody(fieldName, "0.0");
29505
+ return transformers.double.fromJsonBody(
29506
+ fieldName,
29507
+ jsonKey,
29508
+ "0.0"
29509
+ );
29482
29510
  case "int":
29483
- return transformers.int.fromJsonBody(fieldName, "0");
29511
+ return transformers.int.fromJsonBody(fieldName, jsonKey, "0");
29484
29512
  case "null":
29485
- return transformers.null.fromJsonBody(fieldName, "");
29513
+ return transformers.null.fromJsonBody(fieldName, jsonKey, "");
29486
29514
  case "DateTime":
29487
29515
  return transformers.DateTime.fromJsonBody(
29488
29516
  fieldName,
29517
+ jsonKey,
29489
29518
  "DateTime(0)"
29490
29519
  );
29491
29520
  case "DateTime?":
29492
- return transformers.DateTime.fromJsonBody(fieldName, "null");
29521
+ return transformers.DateTime.fromJsonBody(
29522
+ fieldName,
29523
+ jsonKey,
29524
+ "null"
29525
+ );
29493
29526
  case "List<String>":
29494
29527
  case "List<bool>":
29495
29528
  case "List<double>":
@@ -29497,26 +29530,29 @@ function dartParsedJsonField(fieldName, dartType) {
29497
29530
  case "List<null>":
29498
29531
  return defaultListFromJsonBody(
29499
29532
  fieldName,
29533
+ jsonKey,
29500
29534
  dartType.replace("List<", "").replace(">", ""),
29501
29535
  "[]"
29502
29536
  );
29503
29537
  default:
29504
- return `${fieldName}: json["${fieldName}"] is ${dartType.replace(
29538
+ return `${fieldName}: json["${jsonKey}"] is ${dartType.replace(
29505
29539
  "?",
29506
29540
  ""
29507
- )} ? json["${fieldName}"] : null`;
29541
+ )} ? json["${jsonKey}"] : null`;
29508
29542
  }
29509
29543
  }
29510
29544
  if (dartType.includes("List<")) {
29511
29545
  const innerType = dartType.replace("List<", "").replace(">", "").replace("?", "");
29512
29546
  return classListTransformer(innerType).fromJsonBody(
29513
29547
  fieldName,
29548
+ jsonKey,
29514
29549
  dartType.endsWith("?") ? "null" : "[]"
29515
29550
  );
29516
29551
  }
29517
29552
  const classType = dartType.split("?").join("").trim();
29518
29553
  return classTransformer(classType, dartType.endsWith("?")).fromJsonBody(
29519
29554
  fieldName,
29555
+ jsonKey,
29520
29556
  classType
29521
29557
  );
29522
29558
  }
@@ -29541,89 +29577,91 @@ const transformers = {
29541
29577
  toJsonBody: defaultToJsonBody
29542
29578
  },
29543
29579
  int: {
29544
- fromJsonBody: (key, fallback) => defaultFromJsonBody(key, "int", fallback),
29580
+ fromJsonBody: (key, jsonKey, fallback) => defaultFromJsonBody(key, jsonKey, "int", fallback),
29545
29581
  toJsonBody: defaultToJsonBody
29546
29582
  },
29547
29583
  double: {
29548
- fromJsonBody: (key, fallback) => defaultFromJsonBody(key, "double", fallback),
29584
+ fromJsonBody: (key, jsonKey, fallback) => defaultFromJsonBody(key, jsonKey, "double", fallback),
29549
29585
  toJsonBody: defaultToJsonBody
29550
29586
  },
29551
29587
  String: {
29552
- fromJsonBody: (key, fallback) => defaultFromJsonBody(key, "String", fallback),
29588
+ fromJsonBody: (key, jsonKey, fallback) => defaultFromJsonBody(key, jsonKey, "String", fallback),
29553
29589
  toJsonBody: defaultToJsonBody
29554
29590
  },
29555
29591
  bool: {
29556
- fromJsonBody: (key, fallback) => defaultFromJsonBody(key, "bool", fallback),
29592
+ fromJsonBody: (key, jsonKey, fallback) => defaultFromJsonBody(key, jsonKey, "bool", fallback),
29557
29593
  toJsonBody: defaultToJsonBody
29558
29594
  },
29559
29595
  DateTime: {
29560
- fromJsonBody: (key, fallback) => `${key}: json["${key}"] is String ? DateTime.parse(json["${key}"]) : ${fallback}`,
29561
- toJsonBody: (key, isNullable) => `"${key}": ${key}${isNullable ? "?" : ""}.toIso8601String()`
29596
+ fromJsonBody: (key, jsonKey, fallback) => `${key}: json["${jsonKey}"] is String ? DateTime.parse(json["${jsonKey}"]) : ${fallback}`,
29597
+ toJsonBody: (key, jsonKey, isNullable) => `"${jsonKey}": ${key}${isNullable ? "?" : ""}.toIso8601String()`
29562
29598
  },
29563
29599
  "List<null>": {
29564
- fromJsonBody: (key, fallback) => defaultListFromJsonBody(key, "null", fallback),
29600
+ fromJsonBody: (key, jsonKey, fallback) => defaultListFromJsonBody(key, jsonKey, "null", fallback),
29565
29601
  toJsonBody: defaultToJsonBody
29566
29602
  },
29567
29603
  "List<int>": {
29568
- fromJsonBody: (key, fallback) => defaultListFromJsonBody(key, "int", fallback),
29604
+ fromJsonBody: (key, jsonKey, fallback) => defaultListFromJsonBody(key, jsonKey, "int", fallback),
29569
29605
  toJsonBody: defaultToJsonBody
29570
29606
  },
29571
29607
  "List<double>": {
29572
- fromJsonBody: (key, fallback) => defaultListFromJsonBody(key, "double", fallback),
29608
+ fromJsonBody: (key, jsonKey, fallback) => defaultListFromJsonBody(key, jsonKey, "double", fallback),
29573
29609
  toJsonBody: defaultToJsonBody
29574
29610
  },
29575
29611
  "List<String>": {
29576
- fromJsonBody: (key, fallback) => defaultListFromJsonBody(key, "String", fallback),
29612
+ fromJsonBody: (key, jsonKey, fallback) => defaultListFromJsonBody(key, jsonKey, "String", fallback),
29577
29613
  toJsonBody: defaultToJsonBody
29578
29614
  },
29579
29615
  "List<bool>": {
29580
- fromJsonBody: (key, fallback) => defaultListFromJsonBody(key, "bool", fallback),
29616
+ fromJsonBody: (key, jsonKey, fallback) => defaultListFromJsonBody(key, jsonKey, "bool", fallback),
29581
29617
  toJsonBody: defaultToJsonBody
29582
29618
  },
29583
29619
  "List<DateTime>": {
29584
- fromJsonBody: (key, fallback) => `${key}: json["${key}"] is List<String> ?
29585
- (json["${key}"] as List<String>)
29620
+ fromJsonBody: (key, jsonKey, fallback) => `${key}: json["${jsonKey}"] is List<String> ?
29621
+ (json["${jsonKey}"] as List<String>)
29586
29622
  .map((item) => DateTime.parse(item)).toList() : ${fallback}`,
29587
- toJsonBody: (key, isNullable) => `"${key}": ${key}${isNullable ? "?" : ""}.map((val) => val.toIso8601String()).toList()`
29623
+ toJsonBody: (key, jsonKey, isNullable) => `"${jsonKey}": ${key}${isNullable ? "?" : ""}.map((val) => val.toIso8601String()).toList()`
29588
29624
  },
29589
29625
  Uint8List: {
29590
- fromJsonBody: (key, fallback) => `${key}: json["${key}"] is List ? Uint8List.fromList(json["${key}"]) : ${fallback}`,
29591
- toJsonBody: (key, isNullable) => `"${key}": ${key}${isNullable ? "?" : ""}.toList()`
29626
+ fromJsonBody: (key, jsonKey, fallback) => `${key}: json["${jsonKey}"] is List ? Uint8List.fromList(json["${jsonKey}"]) : ${fallback}`,
29627
+ toJsonBody: (key, jsonKey, isNullable) => `"${jsonKey}": ${key}${isNullable ? "?" : ""}.toList()`
29592
29628
  },
29593
29629
  "List<Uint8List>": {
29594
- fromJsonBody: (key, fallback) => `${key}: json["${key}"] is List && (json["${key}"] as List).isNotEmpty && (json["${key}"] as List).first is List ? json["${key}"] : ${fallback}`,
29595
- toJsonBody: (key, isNullable) => `"${key}": ${key}${isNullable ? "?" : ""}.map((val) => val.toList()).toList()`
29630
+ fromJsonBody: (key, jsonKey, fallback) => `${key}: json["${jsonKey}"] is List && (json["${jsonKey}"] as List).isNotEmpty && (json["${jsonKey}"] as List).first is List ? json["${jsonKey}"] : ${fallback}`,
29631
+ toJsonBody: (key, jsonKey, isNullable) => `"${jsonKey}": ${key}${isNullable ? "?" : ""}.map((val) => val.toList()).toList()`
29596
29632
  }
29597
29633
  };
29598
- function defaultFromJsonBody(key, typename, fallback) {
29599
- return `${key}: json["${key}"] is ${typename} ? json["${key}"] : ${fallback}`;
29634
+ function defaultFromJsonBody(key, jsonKey, typename, fallback) {
29635
+ return `${key}: json["${jsonKey}"] is ${typename} ? json["${jsonKey}"] : ${fallback}`;
29600
29636
  }
29601
- function defaultListFromJsonBody(key, typename, fallback) {
29602
- return `${key}: json["${key}"] is List<${typename}> ? json["${key}"] : ${fallback}`;
29637
+ function defaultListFromJsonBody(key, jsonKey, typename, fallback) {
29638
+ return `${key}: json["${jsonKey}"] is List<${typename}> ? json["${jsonKey}"] : ${fallback}`;
29603
29639
  }
29604
- function defaultToJsonBody(key) {
29605
- return `"${key}": ${key}`;
29640
+ function defaultToJsonBody(key, jsonKey) {
29641
+ return `"${jsonKey}": ${key}`;
29606
29642
  }
29607
29643
  const classTransformer = (typename, nullable) => {
29608
29644
  return {
29609
- fromJsonBody: (key, fallback) => {
29645
+ fromJsonBody: (key, jsonKey, fallback) => {
29610
29646
  if (nullable) {
29611
- return `${key}: json["${key}"] is Map<String, dynamic> ?
29612
- ${typename}.fromJson(json["${key}"]) : null`;
29647
+ return `${key}: json["${jsonKey}"] is Map<String, dynamic> ?
29648
+ ${typename}.fromJson(json["${jsonKey}"]) : null`;
29613
29649
  }
29614
- return `${key}: ${typename}.fromJson(json["${key}"])`;
29650
+ return `${key}: ${typename}.fromJson(json["${jsonKey}"])`;
29615
29651
  },
29616
- toJsonBody: (key, isNullable) => `"${key}": ${key}${isNullable ? "?" : ""}.toJson()`
29652
+ toJsonBody: (key, jsonKey, isNullable) => {
29653
+ return `"${jsonKey}": ${key}${isNullable ? "?" : ""}.toJson()`;
29654
+ }
29617
29655
  };
29618
29656
  };
29619
29657
  const classListTransformer = (typename) => {
29620
29658
  return {
29621
- fromJsonBody: (key, fallback) => {
29622
- return `${key}: json["${key}"] is List<Map<String, dynamic>> ?
29623
- (json["${key}"] as List<Map<String, dynamic>>)
29659
+ fromJsonBody: (key, jsonKey, fallback) => {
29660
+ return `${key}: json["${jsonKey}"] is List<Map<String, dynamic>> ?
29661
+ (json["${jsonKey}"] as List<Map<String, dynamic>>)
29624
29662
  .map((val) => ${typename}.fromJson(val)).toList() : ${fallback}`;
29625
29663
  },
29626
- toJsonBody: (key, isNullable) => `"${key}": ${key}${isNullable ? "?" : ""}.map((val) => val.toJson()).toList()`
29664
+ toJsonBody: (key, jsonKey, isNullable) => `"${jsonKey}": ${key}${isNullable ? "?" : ""}.map((val) => val.toJson()).toList()`
29627
29665
  };
29628
29666
  };
29629
29667
  function isDartType(input) {
@@ -29132,7 +29132,7 @@ class ${prefix} {
29132
29132
  return arriRequest(
29133
29133
  "$_baseUrl\${endpoint.path}",
29134
29134
  method: endpoint.method,
29135
- headers: headers ?? this._headers,
29135
+ headers: headers ?? _headers,
29136
29136
  body: body,
29137
29137
  query: query,
29138
29138
  encoding: encoding,
@@ -29281,7 +29281,7 @@ function dartModelFromJsonSchema(name, schema) {
29281
29281
  subModelParts.push(sub);
29282
29282
  }
29283
29283
  }
29284
- fields.push({ type: dartType, name: key });
29284
+ fields.push({ type: dartType, name: camelCase(key), jsonKey: key });
29285
29285
  if (!isDartType(dartType) && "type" in val && val.type === "object") {
29286
29286
  subModelParts.push(
29287
29287
  dartModelFromJsonSchema(dartType.replace("?", ""), val)
@@ -29297,7 +29297,13 @@ function dartModelFromJsonSchema(name, schema) {
29297
29297
  });
29298
29298
  factory ${name}.fromJson(Map<String, dynamic> json) {
29299
29299
  return ${name}(
29300
- ${fields.map((field) => `${dartParsedJsonField(field.name, field.type)},`).join("\n ")}
29300
+ ${fields.map(
29301
+ (field) => `${dartParsedJsonField(
29302
+ field.name,
29303
+ field.jsonKey,
29304
+ field.type
29305
+ )},`
29306
+ ).join("\n ")}
29301
29307
  );
29302
29308
  }
29303
29309
  Map<String, dynamic> toJson() {
@@ -29307,16 +29313,22 @@ function dartModelFromJsonSchema(name, schema) {
29307
29313
  const typeName = field.type.replace("?", "");
29308
29314
  if (isDartTypeWithNullables(field.type)) {
29309
29315
  const transformer = transformers[typeName];
29310
- return transformer.toJsonBody(field.name, isNullable);
29316
+ return transformer.toJsonBody(
29317
+ field.name,
29318
+ field.jsonKey,
29319
+ isNullable
29320
+ );
29311
29321
  }
29312
29322
  if (field.type.includes("List<")) {
29313
29323
  return classListTransformer(typeName).toJsonBody(
29314
29324
  field.name,
29325
+ field.jsonKey,
29315
29326
  isNullable
29316
29327
  );
29317
29328
  }
29318
29329
  return classTransformer(typeName, isNullable).toJsonBody(
29319
29330
  field.name,
29331
+ field.jsonKey,
29320
29332
  isNullable
29321
29333
  );
29322
29334
  }).join(",\n ")},
@@ -29455,28 +29467,49 @@ function dartPropertyTypeFromSchema(objectName, propertyName, schema) {
29455
29467
  }
29456
29468
  return [finalType, subTypes.length ? subTypes : void 0];
29457
29469
  }
29458
- function dartParsedJsonField(fieldName, dartType) {
29470
+ function dartParsedJsonField(fieldName, jsonKey, dartType) {
29459
29471
  if (isDartTypeWithNullables(dartType)) {
29460
29472
  switch (dartType) {
29461
29473
  case "String":
29462
- return transformers.String.fromJsonBody(fieldName, '""');
29474
+ return transformers.String.fromJsonBody(
29475
+ fieldName,
29476
+ jsonKey,
29477
+ '""'
29478
+ );
29463
29479
  case "String?":
29464
- return transformers.String.fromJsonBody(fieldName, "null");
29480
+ return transformers.String.fromJsonBody(
29481
+ fieldName,
29482
+ jsonKey,
29483
+ "null"
29484
+ );
29465
29485
  case "bool":
29466
- return transformers.bool.fromJsonBody(fieldName, "false");
29486
+ return transformers.bool.fromJsonBody(
29487
+ fieldName,
29488
+ jsonKey,
29489
+ "false"
29490
+ );
29467
29491
  case "double":
29468
- return transformers.double.fromJsonBody(fieldName, "0.0");
29492
+ return transformers.double.fromJsonBody(
29493
+ fieldName,
29494
+ jsonKey,
29495
+ "0.0"
29496
+ );
29469
29497
  case "int":
29470
- return transformers.int.fromJsonBody(fieldName, "0");
29498
+ return transformers.int.fromJsonBody(fieldName, jsonKey, "0");
29471
29499
  case "null":
29472
- return transformers.null.fromJsonBody(fieldName, "");
29500
+ return transformers.null.fromJsonBody(fieldName, jsonKey, "");
29473
29501
  case "DateTime":
29474
29502
  return transformers.DateTime.fromJsonBody(
29475
29503
  fieldName,
29504
+ jsonKey,
29476
29505
  "DateTime(0)"
29477
29506
  );
29478
29507
  case "DateTime?":
29479
- return transformers.DateTime.fromJsonBody(fieldName, "null");
29508
+ return transformers.DateTime.fromJsonBody(
29509
+ fieldName,
29510
+ jsonKey,
29511
+ "null"
29512
+ );
29480
29513
  case "List<String>":
29481
29514
  case "List<bool>":
29482
29515
  case "List<double>":
@@ -29484,26 +29517,29 @@ function dartParsedJsonField(fieldName, dartType) {
29484
29517
  case "List<null>":
29485
29518
  return defaultListFromJsonBody(
29486
29519
  fieldName,
29520
+ jsonKey,
29487
29521
  dartType.replace("List<", "").replace(">", ""),
29488
29522
  "[]"
29489
29523
  );
29490
29524
  default:
29491
- return `${fieldName}: json["${fieldName}"] is ${dartType.replace(
29525
+ return `${fieldName}: json["${jsonKey}"] is ${dartType.replace(
29492
29526
  "?",
29493
29527
  ""
29494
- )} ? json["${fieldName}"] : null`;
29528
+ )} ? json["${jsonKey}"] : null`;
29495
29529
  }
29496
29530
  }
29497
29531
  if (dartType.includes("List<")) {
29498
29532
  const innerType = dartType.replace("List<", "").replace(">", "").replace("?", "");
29499
29533
  return classListTransformer(innerType).fromJsonBody(
29500
29534
  fieldName,
29535
+ jsonKey,
29501
29536
  dartType.endsWith("?") ? "null" : "[]"
29502
29537
  );
29503
29538
  }
29504
29539
  const classType = dartType.split("?").join("").trim();
29505
29540
  return classTransformer(classType, dartType.endsWith("?")).fromJsonBody(
29506
29541
  fieldName,
29542
+ jsonKey,
29507
29543
  classType
29508
29544
  );
29509
29545
  }
@@ -29528,89 +29564,91 @@ const transformers = {
29528
29564
  toJsonBody: defaultToJsonBody
29529
29565
  },
29530
29566
  int: {
29531
- fromJsonBody: (key, fallback) => defaultFromJsonBody(key, "int", fallback),
29567
+ fromJsonBody: (key, jsonKey, fallback) => defaultFromJsonBody(key, jsonKey, "int", fallback),
29532
29568
  toJsonBody: defaultToJsonBody
29533
29569
  },
29534
29570
  double: {
29535
- fromJsonBody: (key, fallback) => defaultFromJsonBody(key, "double", fallback),
29571
+ fromJsonBody: (key, jsonKey, fallback) => defaultFromJsonBody(key, jsonKey, "double", fallback),
29536
29572
  toJsonBody: defaultToJsonBody
29537
29573
  },
29538
29574
  String: {
29539
- fromJsonBody: (key, fallback) => defaultFromJsonBody(key, "String", fallback),
29575
+ fromJsonBody: (key, jsonKey, fallback) => defaultFromJsonBody(key, jsonKey, "String", fallback),
29540
29576
  toJsonBody: defaultToJsonBody
29541
29577
  },
29542
29578
  bool: {
29543
- fromJsonBody: (key, fallback) => defaultFromJsonBody(key, "bool", fallback),
29579
+ fromJsonBody: (key, jsonKey, fallback) => defaultFromJsonBody(key, jsonKey, "bool", fallback),
29544
29580
  toJsonBody: defaultToJsonBody
29545
29581
  },
29546
29582
  DateTime: {
29547
- fromJsonBody: (key, fallback) => `${key}: json["${key}"] is String ? DateTime.parse(json["${key}"]) : ${fallback}`,
29548
- toJsonBody: (key, isNullable) => `"${key}": ${key}${isNullable ? "?" : ""}.toIso8601String()`
29583
+ fromJsonBody: (key, jsonKey, fallback) => `${key}: json["${jsonKey}"] is String ? DateTime.parse(json["${jsonKey}"]) : ${fallback}`,
29584
+ toJsonBody: (key, jsonKey, isNullable) => `"${jsonKey}": ${key}${isNullable ? "?" : ""}.toIso8601String()`
29549
29585
  },
29550
29586
  "List<null>": {
29551
- fromJsonBody: (key, fallback) => defaultListFromJsonBody(key, "null", fallback),
29587
+ fromJsonBody: (key, jsonKey, fallback) => defaultListFromJsonBody(key, jsonKey, "null", fallback),
29552
29588
  toJsonBody: defaultToJsonBody
29553
29589
  },
29554
29590
  "List<int>": {
29555
- fromJsonBody: (key, fallback) => defaultListFromJsonBody(key, "int", fallback),
29591
+ fromJsonBody: (key, jsonKey, fallback) => defaultListFromJsonBody(key, jsonKey, "int", fallback),
29556
29592
  toJsonBody: defaultToJsonBody
29557
29593
  },
29558
29594
  "List<double>": {
29559
- fromJsonBody: (key, fallback) => defaultListFromJsonBody(key, "double", fallback),
29595
+ fromJsonBody: (key, jsonKey, fallback) => defaultListFromJsonBody(key, jsonKey, "double", fallback),
29560
29596
  toJsonBody: defaultToJsonBody
29561
29597
  },
29562
29598
  "List<String>": {
29563
- fromJsonBody: (key, fallback) => defaultListFromJsonBody(key, "String", fallback),
29599
+ fromJsonBody: (key, jsonKey, fallback) => defaultListFromJsonBody(key, jsonKey, "String", fallback),
29564
29600
  toJsonBody: defaultToJsonBody
29565
29601
  },
29566
29602
  "List<bool>": {
29567
- fromJsonBody: (key, fallback) => defaultListFromJsonBody(key, "bool", fallback),
29603
+ fromJsonBody: (key, jsonKey, fallback) => defaultListFromJsonBody(key, jsonKey, "bool", fallback),
29568
29604
  toJsonBody: defaultToJsonBody
29569
29605
  },
29570
29606
  "List<DateTime>": {
29571
- fromJsonBody: (key, fallback) => `${key}: json["${key}"] is List<String> ?
29572
- (json["${key}"] as List<String>)
29607
+ fromJsonBody: (key, jsonKey, fallback) => `${key}: json["${jsonKey}"] is List<String> ?
29608
+ (json["${jsonKey}"] as List<String>)
29573
29609
  .map((item) => DateTime.parse(item)).toList() : ${fallback}`,
29574
- toJsonBody: (key, isNullable) => `"${key}": ${key}${isNullable ? "?" : ""}.map((val) => val.toIso8601String()).toList()`
29610
+ toJsonBody: (key, jsonKey, isNullable) => `"${jsonKey}": ${key}${isNullable ? "?" : ""}.map((val) => val.toIso8601String()).toList()`
29575
29611
  },
29576
29612
  Uint8List: {
29577
- fromJsonBody: (key, fallback) => `${key}: json["${key}"] is List ? Uint8List.fromList(json["${key}"]) : ${fallback}`,
29578
- toJsonBody: (key, isNullable) => `"${key}": ${key}${isNullable ? "?" : ""}.toList()`
29613
+ fromJsonBody: (key, jsonKey, fallback) => `${key}: json["${jsonKey}"] is List ? Uint8List.fromList(json["${jsonKey}"]) : ${fallback}`,
29614
+ toJsonBody: (key, jsonKey, isNullable) => `"${jsonKey}": ${key}${isNullable ? "?" : ""}.toList()`
29579
29615
  },
29580
29616
  "List<Uint8List>": {
29581
- fromJsonBody: (key, fallback) => `${key}: json["${key}"] is List && (json["${key}"] as List).isNotEmpty && (json["${key}"] as List).first is List ? json["${key}"] : ${fallback}`,
29582
- toJsonBody: (key, isNullable) => `"${key}": ${key}${isNullable ? "?" : ""}.map((val) => val.toList()).toList()`
29617
+ fromJsonBody: (key, jsonKey, fallback) => `${key}: json["${jsonKey}"] is List && (json["${jsonKey}"] as List).isNotEmpty && (json["${jsonKey}"] as List).first is List ? json["${jsonKey}"] : ${fallback}`,
29618
+ toJsonBody: (key, jsonKey, isNullable) => `"${jsonKey}": ${key}${isNullable ? "?" : ""}.map((val) => val.toList()).toList()`
29583
29619
  }
29584
29620
  };
29585
- function defaultFromJsonBody(key, typename, fallback) {
29586
- return `${key}: json["${key}"] is ${typename} ? json["${key}"] : ${fallback}`;
29621
+ function defaultFromJsonBody(key, jsonKey, typename, fallback) {
29622
+ return `${key}: json["${jsonKey}"] is ${typename} ? json["${jsonKey}"] : ${fallback}`;
29587
29623
  }
29588
- function defaultListFromJsonBody(key, typename, fallback) {
29589
- return `${key}: json["${key}"] is List<${typename}> ? json["${key}"] : ${fallback}`;
29624
+ function defaultListFromJsonBody(key, jsonKey, typename, fallback) {
29625
+ return `${key}: json["${jsonKey}"] is List<${typename}> ? json["${jsonKey}"] : ${fallback}`;
29590
29626
  }
29591
- function defaultToJsonBody(key) {
29592
- return `"${key}": ${key}`;
29627
+ function defaultToJsonBody(key, jsonKey) {
29628
+ return `"${jsonKey}": ${key}`;
29593
29629
  }
29594
29630
  const classTransformer = (typename, nullable) => {
29595
29631
  return {
29596
- fromJsonBody: (key, fallback) => {
29632
+ fromJsonBody: (key, jsonKey, fallback) => {
29597
29633
  if (nullable) {
29598
- return `${key}: json["${key}"] is Map<String, dynamic> ?
29599
- ${typename}.fromJson(json["${key}"]) : null`;
29634
+ return `${key}: json["${jsonKey}"] is Map<String, dynamic> ?
29635
+ ${typename}.fromJson(json["${jsonKey}"]) : null`;
29600
29636
  }
29601
- return `${key}: ${typename}.fromJson(json["${key}"])`;
29637
+ return `${key}: ${typename}.fromJson(json["${jsonKey}"])`;
29602
29638
  },
29603
- toJsonBody: (key, isNullable) => `"${key}": ${key}${isNullable ? "?" : ""}.toJson()`
29639
+ toJsonBody: (key, jsonKey, isNullable) => {
29640
+ return `"${jsonKey}": ${key}${isNullable ? "?" : ""}.toJson()`;
29641
+ }
29604
29642
  };
29605
29643
  };
29606
29644
  const classListTransformer = (typename) => {
29607
29645
  return {
29608
- fromJsonBody: (key, fallback) => {
29609
- return `${key}: json["${key}"] is List<Map<String, dynamic>> ?
29610
- (json["${key}"] as List<Map<String, dynamic>>)
29646
+ fromJsonBody: (key, jsonKey, fallback) => {
29647
+ return `${key}: json["${jsonKey}"] is List<Map<String, dynamic>> ?
29648
+ (json["${jsonKey}"] as List<Map<String, dynamic>>)
29611
29649
  .map((val) => ${typename}.fromJson(val)).toList() : ${fallback}`;
29612
29650
  },
29613
- toJsonBody: (key, isNullable) => `"${key}": ${key}${isNullable ? "?" : ""}.map((val) => val.toJson()).toList()`
29651
+ toJsonBody: (key, jsonKey, isNullable) => `"${jsonKey}": ${key}${isNullable ? "?" : ""}.map((val) => val.toJson()).toList()`
29614
29652
  };
29615
29653
  };
29616
29654
  function isDartType(input) {
package/package.json CHANGED
@@ -22,7 +22,7 @@
22
22
  "chokidar": "^3.5.3",
23
23
  "listhen": "^1.4.3"
24
24
  },
25
- "version": "0.0.9",
25
+ "version": "0.0.10",
26
26
  "repository": {
27
27
  "url": "https://github.com/modiimedia/arri"
28
28
  }