UNPKG

the-moby-effect

Version:
29 lines 1.43 kB
import * as Effect from "effect/Effect"; import * as Schema from "effect/Schema"; import * as SchemaGetter from "effect/SchemaGetter"; import * as SchemaIssue from "effect/SchemaIssue"; /** * Docker parses the values of a filters query parameter as map[string][]string * (or the legacy map[string]map[string]bool), so scalar filter values must * encode as single-element arrays - a bare string, number, or boolean value is * rejected by the daemon with a 400. * * @internal */ export const StringFilter = /*#__PURE__*/Schema.Tuple([Schema.String]).pipe(/*#__PURE__*/Schema.decodeTo(Schema.String, { decode: /*#__PURE__*/SchemaGetter.transform(([value]) => value), encode: /*#__PURE__*/SchemaGetter.transform(value => [value]) })); /** @internal */ export const NumberFilter = /*#__PURE__*/Schema.Tuple([Schema.NumberFromString]).pipe(/*#__PURE__*/Schema.decodeTo(Schema.Number, { decode: /*#__PURE__*/SchemaGetter.transform(([value]) => value), encode: /*#__PURE__*/SchemaGetter.transform(value => [value]) })); /** @internal */ export const BooleanFilter = filterName => Schema.Tuple([Schema.String]).pipe(Schema.decodeTo(Schema.Boolean, { decode: SchemaGetter.transformOrFail(_fromA => Effect.fail(new SchemaIssue.InvalidValue({ message: `Decoding '${filterName}' filter is not supported` }))), encode: SchemaGetter.transform(bool => [bool ? "true" : "false"]) })); //# sourceMappingURL=filters.js.map