@emeryld/rrroutes-contract 2.7.11 → 2.7.13

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.mjs CHANGED
@@ -591,6 +591,24 @@ function serializeLeavesContract(leaves, options = {}) {
591
591
  }
592
592
 
593
593
  // src/export/flattenSchema.ts
594
+ function formatLiteralType(literal) {
595
+ if (typeof literal === "string") return literal;
596
+ if (typeof literal === "number" || typeof literal === "boolean" || typeof literal === "bigint") {
597
+ return String(literal);
598
+ }
599
+ if (literal === null) return "null";
600
+ if (Array.isArray(literal)) {
601
+ return literal.map((item) => formatLiteralType(item)).join("|");
602
+ }
603
+ if (typeof literal === "object") {
604
+ try {
605
+ return JSON.stringify(literal);
606
+ } catch {
607
+ return "object";
608
+ }
609
+ }
610
+ return "unknown";
611
+ }
594
612
  function normalizeType(schema) {
595
613
  switch (schema.kind) {
596
614
  case "string":
@@ -607,11 +625,7 @@ function normalizeType(schema) {
607
625
  return "unknown";
608
626
  }
609
627
  case "literal": {
610
- const lit = schema.literal;
611
- if (typeof lit === "string") return "string";
612
- if (typeof lit === "number") return "number";
613
- if (typeof lit === "boolean") return "boolean";
614
- return "unknown";
628
+ return formatLiteralType(schema.literal);
615
629
  }
616
630
  default:
617
631
  return "unknown";
@@ -625,7 +639,8 @@ function setNode(out, path4, schema, inherited) {
625
639
  out[path4] = {
626
640
  type: normalizeType(schema),
627
641
  nullable: inherited.nullable || Boolean(schema.nullable),
628
- optional: inherited.optional || Boolean(schema.optional)
642
+ optional: inherited.optional || Boolean(schema.optional),
643
+ literal: schema.kind === "literal" ? schema.literal : void 0
629
644
  };
630
645
  }
631
646
  function flattenInto(out, schema, path4, inherited) {
@@ -1395,7 +1410,7 @@ function buildMeta(sourceExtraction) {
1395
1410
  "literal?",
1396
1411
  "enumValues?"
1397
1412
  ],
1398
- flatSchemaEntry: ["type", "nullable", "optional"]
1413
+ flatSchemaEntry: ["type", "nullable", "optional", "literal?"]
1399
1414
  },
1400
1415
  flattening: {
1401
1416
  notation: "dot+[]",