map.js 913 B

1234567891011121314151617181920212223242526272829
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.parseMapDef = void 0;
  4. const parseDef_js_1 = require("../parseDef.js");
  5. const record_js_1 = require("./record.js");
  6. function parseMapDef(def, refs) {
  7. if (refs.mapStrategy === "record") {
  8. return (0, record_js_1.parseRecordDef)(def, refs);
  9. }
  10. const keys = (0, parseDef_js_1.parseDef)(def.keyType._def, {
  11. ...refs,
  12. currentPath: [...refs.currentPath, "items", "items", "0"],
  13. }) || {};
  14. const values = (0, parseDef_js_1.parseDef)(def.valueType._def, {
  15. ...refs,
  16. currentPath: [...refs.currentPath, "items", "items", "1"],
  17. }) || {};
  18. return {
  19. type: "array",
  20. maxItems: 125,
  21. items: {
  22. type: "array",
  23. items: [keys, values],
  24. minItems: 2,
  25. maxItems: 2,
  26. },
  27. };
  28. }
  29. exports.parseMapDef = parseMapDef;