Skip to content

Commit

Permalink
fix(ssm): type for path parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
vicary committed Aug 3, 2022
1 parent 0993757 commit bd4badd
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions packages/ssm/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,17 @@ interface Options<S = SSM>
extends MiddyOptions<S, SSM.Types.ClientConfiguration> {}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
type Basename<T> = T extends `${infer _P}/${infer _S}` ? Basename<_S> : T
// eslint-disable-next-line @typescript-eslint/no-unused-vars
type ExtractPaths<T> = T extends `${infer _P}/${infer _S}` ? T : never
// eslint-disable-next-line @typescript-eslint/no-unused-vars
type ExtractSingles<T> = T extends `${infer _P}/${infer _S}` ? never : T
type ExtractSingles<T> = T extends `/${infer _}` ? never : T

export type Context<TOptions extends Options | undefined> = TOptions extends {
setToContext: true
}
? LambdaContext &
Record<Basename<ExtractPaths<keyof TOptions['fetchData']>>, JsonValue> &
Record<ExtractSingles<keyof TOptions['fetchData']>, JsonValue>
Record<ExtractSingles<keyof TOptions['fetchData']>, JsonValue> &
// eslint-disable-next-line @typescript-eslint/no-unused-vars
(keyof TOptions['fetchData'] extends `${infer _P}/${infer _S}`
? Record<string, JsonValue>
: unknown)
: LambdaContext

declare function ssm<TOptions extends Options> (
Expand Down

0 comments on commit bd4badd

Please sign in to comment.