arri 0.0.40 → 0.0.43

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.
@@ -42,7 +42,7 @@ require('h3');
42
42
  require('@sinclair/typebox/errors');
43
43
  require('@sinclair/typebox/value');
44
44
  require('ofetch');
45
- require('../shared/arri.529292e9.cjs');
45
+ require('../shared/arri.f250629b.cjs');
46
46
  require('child_process');
47
47
  require('listhen');
48
48
 
@@ -40,7 +40,7 @@ import 'h3';
40
40
  import '@sinclair/typebox/errors';
41
41
  import '@sinclair/typebox/value';
42
42
  import 'ofetch';
43
- import '../shared/arri.3b1c1533.mjs';
43
+ import '../shared/arri.d767421d.mjs';
44
44
  import 'child_process';
45
45
  import 'listhen';
46
46
 
package/dist/cli.cjs CHANGED
@@ -29,7 +29,7 @@ const utils$l = require('./shared/arri.0752aa2b.cjs');
29
29
  const index = require('./index.cjs');
30
30
  require('node:stream');
31
31
  const ofetch = require('ofetch');
32
- const dart = require('./shared/arri.529292e9.cjs');
32
+ const dart = require('./shared/arri.f250629b.cjs');
33
33
  const listhen = require('listhen');
34
34
  require('@sinclair/typebox');
35
35
  require('h3');
package/dist/cli.mjs CHANGED
@@ -27,7 +27,7 @@ import { c as camelCase, r as removeDisallowedChars, k as kebabCase, d as isAppl
27
27
  import { defaultConfig, DEV_DEFINITION_ENDPOINT } from './index.mjs';
28
28
  import 'node:stream';
29
29
  import { ofetch } from 'ofetch';
30
- import { g as dartClientGenerator } from './shared/arri.3b1c1533.mjs';
30
+ import { g as dartClientGenerator } from './shared/arri.d767421d.mjs';
31
31
  import { listenAndWatch } from 'listhen';
32
32
  import '@sinclair/typebox';
33
33
  import 'h3';
package/dist/codegen.cjs CHANGED
@@ -3,7 +3,7 @@
3
3
  const require$$0 = require('fs');
4
4
  const prettier = require('prettier');
5
5
  const utils = require('./shared/arri.0752aa2b.cjs');
6
- const dart = require('./shared/arri.529292e9.cjs');
6
+ const dart = require('./shared/arri.f250629b.cjs');
7
7
  require('child_process');
8
8
 
9
9
  let generatedModels = [];
package/dist/codegen.mjs CHANGED
@@ -2,8 +2,8 @@ import { writeFileSync } from 'fs';
2
2
  import { format } from 'prettier';
3
3
  import { u as unflattenObject, i as isServiceDef, p as pascalCase, a as isProcedureDef, b as unflattenProcedures, c as camelCase } from './shared/arri.ebf86912.mjs';
4
4
  export { d as isApplicationDef, n as normalizeWhitespace, r as removeDisallowedChars, s as setNestedObjectProperty } from './shared/arri.ebf86912.mjs';
5
- import { d as defineClientGeneratorPlugin, i as isJsonSchemaScalarType, a as isJsonSchemaNullType, b as isJsonSchemaObject, c as isJsonSchemaRecord, e as isJsonSchemaEnum, f as isJsonSchemaArray } from './shared/arri.3b1c1533.mjs';
6
- export { p as classListTransformer, o as classTransformer, h as createDartClient, g as dartClientGenerator, l as dartModelFromJsonSchema, n as dartParsedJsonField, k as dartProcedureFromServiceDefinition, m as dartPropertyTypeFromSchema, j as dartServiceFromServiceDefinition, q as isDartType, r as isDartTypeWithNullables, t as transformers } from './shared/arri.3b1c1533.mjs';
5
+ import { d as defineClientGeneratorPlugin, i as isJsonSchemaScalarType, a as isJsonSchemaNullType, b as isJsonSchemaObject, c as isJsonSchemaRecord, e as isJsonSchemaEnum, f as isJsonSchemaArray } from './shared/arri.d767421d.mjs';
6
+ export { p as classListTransformer, o as classTransformer, h as createDartClient, g as dartClientGenerator, l as dartModelFromJsonSchema, n as dartParsedJsonField, k as dartProcedureFromServiceDefinition, m as dartPropertyTypeFromSchema, j as dartServiceFromServiceDefinition, q as isDartType, r as isDartTypeWithNullables, t as transformers } from './shared/arri.d767421d.mjs';
7
7
  import 'child_process';
8
8
 
9
9
  let generatedModels = [];
@@ -348,6 +348,9 @@ function dartModelFromJsonSchema(modelName, schema, opts) {
348
348
  ${fields.map((field) => {
349
349
  const isNullable = field.type.endsWith("?");
350
350
  const typeName = field.type.replace("?", "");
351
+ if (typeName === "dynamic") {
352
+ return `"${field.jsonKey}": ${field.name}`;
353
+ }
351
354
  if (isDartTypeWithNullables(field.type)) {
352
355
  const transformer = transformers[typeName];
353
356
  return transformer.toJsonBody(
@@ -375,7 +378,9 @@ function dartModelFromJsonSchema(modelName, schema, opts) {
375
378
  };
376
379
  }
377
380
  ${modelDisplayName} copyWith({
378
- ${fields.map((field) => `${field.type.replace("?", "")}? ${field.name},`).join("\n ")}
381
+ ${fields.map(
382
+ (field) => `${field.type.replace("?", "")}${field.type !== "dynamic" ? "?" : ""} ${field.name},`
383
+ ).join("\n ")}
379
384
  }) {
380
385
  return ${modelDisplayName}(
381
386
  ${fields.map((field) => `${field.name}: ${field.name} ?? this.${field.name},`).join("\n ")}
@@ -388,7 +393,7 @@ ${subModelParts.join("\n")}`;
388
393
  function dartPropertyTypeFromSchema(objectName, propertyName, schema, opts) {
389
394
  const prop = schema.properties?.[propertyName];
390
395
  const isOptional = !schema.required?.includes(propertyName);
391
- let finalType = "";
396
+ let finalType = "dynamic";
392
397
  const subTypes = [];
393
398
  if (isJsonSchemaEnum(prop)) {
394
399
  const enumName = pascalCase(`${objectName}_${propertyName}`);
@@ -515,6 +520,9 @@ function dartPropertyTypeFromSchema(objectName, propertyName, schema, opts) {
515
520
  return [finalType, subTypes.length ? subTypes : void 0];
516
521
  }
517
522
  function dartParsedJsonField(fieldName, jsonKey, dartType) {
523
+ if (dartType === "dynamic") {
524
+ return `${fieldName}: json["${jsonKey}"]`;
525
+ }
518
526
  if (isDartTypeWithNullables(dartType)) {
519
527
  switch (dartType) {
520
528
  case "String":
@@ -716,7 +724,7 @@ const classListTransformer = (typename) => {
716
724
  return {
717
725
  fromJsonBody: (key, jsonKey, fallback) => {
718
726
  return `${key}: json["${jsonKey}"] is List ?
719
- (json["${jsonKey}"] as List<Map<String, dynamic>>)
727
+ (json["${jsonKey}"] as List<dynamic>)
720
728
  .map((val) => ${typename}.fromJson(val)).toList() : ${fallback}`;
721
729
  },
722
730
  toJsonBody: (key, jsonKey, isNullable) => `"${jsonKey}": ${key}${isNullable ? "?" : ""}.map((val) => val.toJson()).toList()`
@@ -350,6 +350,9 @@ function dartModelFromJsonSchema(modelName, schema, opts) {
350
350
  ${fields.map((field) => {
351
351
  const isNullable = field.type.endsWith("?");
352
352
  const typeName = field.type.replace("?", "");
353
+ if (typeName === "dynamic") {
354
+ return `"${field.jsonKey}": ${field.name}`;
355
+ }
353
356
  if (isDartTypeWithNullables(field.type)) {
354
357
  const transformer = transformers[typeName];
355
358
  return transformer.toJsonBody(
@@ -377,7 +380,9 @@ function dartModelFromJsonSchema(modelName, schema, opts) {
377
380
  };
378
381
  }
379
382
  ${modelDisplayName} copyWith({
380
- ${fields.map((field) => `${field.type.replace("?", "")}? ${field.name},`).join("\n ")}
383
+ ${fields.map(
384
+ (field) => `${field.type.replace("?", "")}${field.type !== "dynamic" ? "?" : ""} ${field.name},`
385
+ ).join("\n ")}
381
386
  }) {
382
387
  return ${modelDisplayName}(
383
388
  ${fields.map((field) => `${field.name}: ${field.name} ?? this.${field.name},`).join("\n ")}
@@ -390,7 +395,7 @@ ${subModelParts.join("\n")}`;
390
395
  function dartPropertyTypeFromSchema(objectName, propertyName, schema, opts) {
391
396
  const prop = schema.properties?.[propertyName];
392
397
  const isOptional = !schema.required?.includes(propertyName);
393
- let finalType = "";
398
+ let finalType = "dynamic";
394
399
  const subTypes = [];
395
400
  if (isJsonSchemaEnum(prop)) {
396
401
  const enumName = utils.pascalCase(`${objectName}_${propertyName}`);
@@ -517,6 +522,9 @@ function dartPropertyTypeFromSchema(objectName, propertyName, schema, opts) {
517
522
  return [finalType, subTypes.length ? subTypes : void 0];
518
523
  }
519
524
  function dartParsedJsonField(fieldName, jsonKey, dartType) {
525
+ if (dartType === "dynamic") {
526
+ return `${fieldName}: json["${jsonKey}"]`;
527
+ }
520
528
  if (isDartTypeWithNullables(dartType)) {
521
529
  switch (dartType) {
522
530
  case "String":
@@ -718,7 +726,7 @@ const classListTransformer = (typename) => {
718
726
  return {
719
727
  fromJsonBody: (key, jsonKey, fallback) => {
720
728
  return `${key}: json["${jsonKey}"] is List ?
721
- (json["${jsonKey}"] as List<Map<String, dynamic>>)
729
+ (json["${jsonKey}"] as List<dynamic>)
722
730
  .map((val) => ${typename}.fromJson(val)).toList() : ${fallback}`;
723
731
  },
724
732
  toJsonBody: (key, jsonKey, isNullable) => `"${jsonKey}": ${key}${isNullable ? "?" : ""}.map((val) => val.toJson()).toList()`
package/package.json CHANGED
@@ -25,7 +25,7 @@
25
25
  "chokidar": "^3.5.3",
26
26
  "listhen": "^1.5.0"
27
27
  },
28
- "version": "0.0.40",
28
+ "version": "0.0.43",
29
29
  "repository": {
30
30
  "url": "https://github.com/modiimedia/arri"
31
31
  }