Skip to content

Type Alias: UniqueExposedPorts

ts
type UniqueExposedPorts = ExposeBase[] & tags.TagBase<{
  kind: "uniqueExposedPorts";
  message: "Exposed ports must be unique, number ports must not fall within any defined port range, and port ranges must not overlap or be adjacent.";
  target: "array";
  validate: "\n      (() => {\n       if (!Array.isArray($input)) return true;\n        const numbers = new Set();\n        const ranges = [];\n        for (const el of $input) {\n          // Skip dynamic placeholders and spread markers for uniqueness check\n          if (typeof el === \"string\" && /^%%(ops|global).[^%]+%%$/.test(el)) continue;\n          if (el && typeof el === \"object\" && !Array.isArray(el) && el.__spread__) continue;\n\n          const port = typeof el === \"object\" ? el.port : el;\n          if (typeof port === \"number\") {\n            if (numbers.has(port)) return false;\n            numbers.add(port);\n          } else if (typeof port === \"string\") {\n            // Enforce range format for concrete range strings\n            const match = /^([0-9]+)-([0-9]+)$/.exec(port);\n            if (!match) return false;\n            const start = Number(match[1]), end = Number(match[2]);\n            for (const [rStart, rEnd] of ranges) {\n              if (start <= rEnd && end >= rStart) return false;\n            }\n            ranges.push([start, end]);\n          }\n        }\n        for (const port of numbers) {\n          for (const [start, end] of ranges) {\n            if (port >= start && port <= end) return false;\n          }\n        }\n        return true;\n      })()\n    ";
  value: "uniqueExposedPorts";
}>;

Job definition types for creating Nosana jobs