* 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)
| 326 | * This function may fail, but it will never throw. |
| 327 | */ |
| 328 | function 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 | |
| 351 | export function makePrismaConfigInternal(makeArgs: _PrismaConfigInternal): PrismaConfigInternal { |
| 352 | return pipe(PrismaConfigInternalShape.make(makeArgs), brandPrismaConfigInternal) |
no test coverage detected