Skip to content

Commit

Permalink
Fix style
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleAMathews committed Dec 19, 2024
1 parent 325bb25 commit 54eec3e
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions packages/typescript-client/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,19 @@ export interface PostgresParams {
replica?: Replica
}

type ParamValue = string | string[] | (() => string | string[] | Promise<string | string[]>)
type ParamValue =
| string
| string[]
| (() => string | string[] | Promise<string | string[]>)

/**
* External params type - what users provide.
* Excludes reserved parameters to prevent dynamic variations that could cause stream shape changes.
*/
export type ExternalParamsRecord = {
[K in string as K extends ReservedParamKeys ? never : K]: ParamValue | undefined
[K in string as K extends ReservedParamKeys ? never : K]:
| ParamValue
| undefined
} & Partial<PostgresParams>

type ReservedParamKeys =
Expand Down Expand Up @@ -373,7 +378,9 @@ export class ShapeStream<T extends Row<unknown> = Row>
// Resolve headers and params in parallel
const [requestHeaders, params] = await Promise.all([
resolveHeaders(this.options.headers),
this.options.params ? toInternalParams(this.options.params) : undefined,
this.options.params
? toInternalParams(this.options.params)
: undefined,
])

// Validate params after resolution
Expand Down Expand Up @@ -629,6 +636,6 @@ function validateOptions<T>(options: Partial<ShapeStreamOptions<T>>): void {
}

validateParams(options.params)

return
}

0 comments on commit 54eec3e

Please sign in to comment.