MCPcopy Create free account
hub / github.com/Effect-TS/effect / decodeSchemaString

Function decodeSchemaString

packages/effect/src/encoding/Csv.ts:773–792  ·  view source on GitHub ↗
(schema: S)

Source from the content-addressed store, hash-verified

771 */
772export const decodeSchemaString =
773 <S extends Schema.Constraint>(schema: S) =>
774 <IE = never, Done = unknown>(options?: DecodeSchemaOptions, parseOptions?: SchemaAST.ParseOptions): Channel.Channel<
775 Arr.NonEmptyReadonlyArray<S["Type"]>,
776 IE | CsvError | Schema.SchemaError,
777 Done,
778 Arr.NonEmptyReadonlyArray<string>,
779 IE,
780 Done,
781 S["DecodingServices"]
782 > => {
783 const codec = toCodec(schema, options?.disableCodecs)
784 checkCells(SchemaAST.toEncoded(codec.ast), undefined)
785 const item = options?.headers === true && options.disableCodecs !== true ? headerCodec(codec) : codec
786 const decode = Schema.decodeUnknownEffect(toArrayCodec(item), parseOptions)
787 return Channel.mapEffect(decodeRecords<IE, Done>(options), (records) =>
788 Effect.mapError(
789 decode(Arr.map(records, (record) => record.value)),
790 (error) => rebaseIssue(error, (index) => records[index].record)
791 ))
792 }
793
794/**
795 * Creates a channel that parses UTF-8 CSV and decodes each record with a schema.

Callers 1

decodeSchemaFunction · 0.70

Calls 7

checkCellsFunction · 0.85
toArrayCodecFunction · 0.85
decodeRecordsFunction · 0.85
rebaseIssueFunction · 0.85
toCodecFunction · 0.70
decodeFunction · 0.70
mapMethod · 0.45

Tested by

no test coverage detected