@supalive/codegen 1.5.0 → 1.5.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/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { n as generateToDisk, r as readEntryConfig } from "./src-CsHYrzoq.js";
2
+ import { n as generateToDisk, r as readEntryConfig } from "./src-DM44BrYS.js";
3
3
  import path from "node:path";
4
4
  //#region src/cli.ts
5
5
  function parseArgs(argv) {
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import { a as emit, c as loadSchemaEnums, i as resolveConfig, n as generateToDisk, o as extractClient, r as readEntryConfig, s as SchemaEnumRegistry, t as generate } from "./src-CsHYrzoq.js";
1
+ import { a as emit, c as loadSchemaEnums, i as resolveConfig, n as generateToDisk, o as extractClient, r as readEntryConfig, s as SchemaEnumRegistry, t as generate } from "./src-DM44BrYS.js";
2
2
  export { SchemaEnumRegistry, emit, extractClient, generate, generateToDisk, loadSchemaEnums, readEntryConfig, resolveConfig };
@@ -714,18 +714,18 @@ var Extractor = class {
714
714
  const propType = prop.getTypeAtLocation(this.locationNode);
715
715
  const declaredOptional = (prop.getFlags() & ts.SymbolFlags.Optional) !== 0;
716
716
  const { core, hasNull, hasUndefined } = splitNullish(propType);
717
- const dt = core.length === 0 ? { kind: "dynamic" } : core.length === 1 ? this.walkSingle(core[0], name + pascal(jsonKey)) : this.walkUnion(core, {
718
- hint: name + pascal(jsonKey),
719
- stem: cleanStem(name),
720
- field: jsonKey
721
- });
722
717
  const acc = fieldMap.get(jsonKey) ?? {
723
718
  types: [],
724
719
  present: 0,
725
720
  nullable: false,
726
721
  optional: false
727
722
  };
728
- acc.types.push(dt);
723
+ if (core.length === 1) acc.types.push(this.walkSingle(core[0], name + pascal(jsonKey)));
724
+ else if (core.length > 1) acc.types.push(this.walkUnion(core, {
725
+ hint: name + pascal(jsonKey),
726
+ stem: cleanStem(name),
727
+ field: jsonKey
728
+ }));
729
729
  acc.present++;
730
730
  if (hasNull) acc.nullable = true;
731
731
  if (declaredOptional || hasUndefined) acc.optional = true;
@@ -733,7 +733,7 @@ var Extractor = class {
733
733
  }
734
734
  const fields = [];
735
735
  for (const [jsonKey, acc] of fieldMap) {
736
- const consistent = acc.types.every((t) => JSON.stringify(t) === JSON.stringify(acc.types[0]));
736
+ const consistent = acc.types.length > 0 && acc.types.every((t) => JSON.stringify(t) === JSON.stringify(acc.types[0]));
737
737
  fields.push({
738
738
  name: camel(jsonKey),
739
739
  jsonKey,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supalive/codegen",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
4
4
  "description": "Generate type-safe client code (Dart, and more) from a Supalive TypeScript router.",
5
5
  "author": "Rebaz Raouf",
6
6
  "license": "MIT",