@supalive/codegen 1.4.0 → 1.5.0

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-O2U-Keyx.js";
2
+ import { n as generateToDisk, r as readEntryConfig } from "./src-CsHYrzoq.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-O2U-Keyx.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-CsHYrzoq.js";
2
2
  export { SchemaEnumRegistry, emit, extractClient, generate, generateToDisk, loadSchemaEnums, readEntryConfig, resolveConfig };
@@ -808,6 +808,7 @@ function uniqueName(symName, registry, _type) {
808
808
  return pascal(symName);
809
809
  }
810
810
  function singular(hint) {
811
+ if (hint.endsWith("Result") && hint.length > 6) return hint.slice(0, -6) + "Item";
811
812
  if (hint.endsWith("ies")) return hint.slice(0, -3) + "y";
812
813
  if (hint.endsWith("s") && !hint.endsWith("ss")) return hint.slice(0, -1);
813
814
  return hint + "Item";
@@ -823,7 +824,8 @@ function cleanStem(modelName) {
823
824
  for (const suffix of [
824
825
  "ResultItem",
825
826
  "Result",
826
- "Args"
827
+ "Args",
828
+ "Item"
827
829
  ]) if (s.length > suffix.length && s.endsWith(suffix)) {
828
830
  s = s.slice(0, -suffix.length);
829
831
  break;
@@ -1044,6 +1046,7 @@ function emitModel(m) {
1044
1046
  return `(identical(other.${f.name}, ${f.name}) || ${cmp})`;
1045
1047
  }).join(" &&\n ");
1046
1048
  const hashParts = m.fields.map((f) => isDeep(f) ? `deepHashCode(${f.name})` : f.name).join(", ");
1049
+ const toStringFields = m.fields.map((f) => `${f.name}: $${f.name}`).join(", ");
1047
1050
  const hashBody = m.fields.length === 0 ? "runtimeType.hashCode" : m.fields.length <= 19 ? `Object.hash(runtimeType, ${hashParts})` : `Object.hashAll([runtimeType, ${hashParts}])`;
1048
1051
  return `${docComment(m.doc, "")}class ${m.name} implements SupaliveModel {
1049
1052
  const ${m.name}(${m.fields.length ? "{\n" + ctorParams + ",\n }" : ""});
@@ -1070,6 +1073,11 @@ ${toJson}
1070
1073
 
1071
1074
  @override
1072
1075
  int get hashCode => ${hashBody};
1076
+
1077
+ @override
1078
+ String toString() {
1079
+ return '${m.name}{${toStringFields}}';
1080
+ }
1073
1081
  }
1074
1082
  `;
1075
1083
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supalive/codegen",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
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",