MCPcopy
hub / github.com/prisma/prisma / parsePrismaConfigInternalShape

Function parsePrismaConfigInternalShape

packages/config/src/PrismaConfig.ts:328–349  ·  view source on GitHub ↗

* Parse a given input object to ensure it conforms to the `PrismaConfigInternal` type Shape. * This function may fail, but it will never throw.

(input: unknown)

Source from the content-addressed store, hash-verified

326 * This function may fail, but it will never throw.
327 */
328function parsePrismaConfigInternalShape(input: unknown): Either.Either<PrismaConfigInternal, Error> {
329 debug('Parsing PrismaConfigInternal: %o', input)
330
331 // Bypass the parsing step when the input is already an object with the correct internal brand.
332 if (typeof input === 'object' && input !== null && input['__brand'] === PRISMA_CONFIG_INTERNAL_BRAND) {
333 debug('Short-circuit: input is already a PrismaConfigInternal object')
334 return Either.right(input as PrismaConfigInternal)
335 }
336
337 return pipe(
338 Shape.decodeUnknownEither(PrismaConfigInternalShape, {})(input, {
339 onExcessProperty: 'error',
340 }),
341 // Brand the output type to make `PrismaConfigInternal` opaque, without exposing the `Effect/Brand` type
342 // to the public API.
343 // This is done to work around the following issues:
344 // - https://github.com/microsoft/rushstack/issues/1308
345 // - https://github.com/microsoft/rushstack/issues/4034
346 // - https://github.com/microsoft/TypeScript/issues/58914
347 Either.map(brandPrismaConfigInternal),
348 )
349}
350
351export function makePrismaConfigInternal(makeArgs: _PrismaConfigInternal): PrismaConfigInternal {
352 return pipe(PrismaConfigInternalShape.make(makeArgs), brandPrismaConfigInternal)

Callers 1

parseDefaultExportFunction · 0.85

Calls 2

debugFunction · 0.85
pipeFunction · 0.50

Tested by

no test coverage detected