UNPKG

the-moby-effect

Version:
102 lines (100 loc) 4.24 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PortWithMaybeProtocol = exports.PortSet = exports.PortMap = exports.PortBrand = exports.PortBinding = exports.Port = void 0; var Brand = _interopRequireWildcard(require("effect/Brand")); var Function = _interopRequireWildcard(require("effect/Function")); var Schema = _interopRequireWildcard(require("effect/Schema")); function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); } function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } /** * Operating system port schema. * * @since 1.0.0 */ /** * @since 1.0.0 * @category Branded constructors */ const PortBrand = exports.PortBrand = /*#__PURE__*/Brand.nominal(); /** * An operating system port number. * * @since 1.0.0 * @category Schemas * @example * import * as Schema from "effect/Schema"; * import { Port } from "the-moby-effect/schemas/index.js"; * * const decodePort = Schema.decodeSync(Port); * assert.strictEqual(decodePort(8080), 8080); * * assert.throws(() => decodePort(65536)); * assert.doesNotThrow(() => decodePort(8080)); */ const Port = exports.Port = /*#__PURE__*/Function.pipe(Schema.Int, /*#__PURE__*/Schema.between(0, 2 ** 16 - 1), /*#__PURE__*/Schema.fromBrand(PortBrand), /*#__PURE__*/Schema.annotations({ identifier: "Port", title: "An OS port number", description: "An operating system's port number between 0 and 65535 (inclusive)" })); /** * An operating system port number with an optional protocol. * * @since 1.0.0 * @category Schemas */ const PortWithMaybeProtocol = exports.PortWithMaybeProtocol = /*#__PURE__*/Schema.Union(Schema.TemplateLiteral(Schema.Number), Schema.TemplateLiteral(Schema.Number, "/", Schema.Literal("tcp")), Schema.TemplateLiteral(Schema.Number, "/", Schema.Literal("udp"))).annotations({ identifier: "PortWithMaybeProtocol", title: "An OS port number with an optional protocol", description: "An operating system's port number with an optional protocol" }); /** * A set of operating system ports. * * @since 1.0.0 * @category Schemas * @see https://github.com/docker/go-connections/blob/5df8d2b30ca886f2d94740ce3c54abd58a5bb2c9/nat/nat.go#L23 */ const PortSet = exports.PortSet = /*#__PURE__*/Schema.Record({ key: PortWithMaybeProtocol, // FIXME: What is this type? value: Schema.Object }).annotations({ identifier: "PortSet", title: "A set of OS ports", description: "A set of operating system ports" }); /** * A port binding between the exposed port (container) and the host. * * @since 1.0.0 * @category Schemas * @see https://github.com/docker/go-connections/blob/5df8d2b30ca886f2d94740ce3c54abd58a5bb2c9/nat/nat.go#L11-L17 */ const PortBinding = exports.PortBinding = /*#__PURE__*/Schema.Struct({ HostPort: Schema.String, HostIp: Schema.optionalWith(Schema.String, { nullable: true }) }).annotations({ identifier: "PortBinding", title: "nat.PortBinding", description: "A port binding between the exposed port (container) and the host" }); /** * Port mapping between the exposed port (container) and the host. * * @since 1.0.0 * @category Schemas * @see https://github.com/docker/go-connections/blob/5df8d2b30ca886f2d94740ce3c54abd58a5bb2c9/nat/nat.go#L20 */ const PortMap = exports.PortMap = /*#__PURE__*/Schema.Record({ key: PortWithMaybeProtocol, value: Schema.Array(PortBinding) }).annotations({ identifier: "PortMap", title: "nat.PortMap", description: "Port mapping between the exposed port (container) and the host" }); //# sourceMappingURL=port.js.map