Skip to content

Commit

Permalink
Use limitToSeamHttpRequestOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
razor-x committed Nov 16, 2023
1 parent 7027df9 commit c143d78
Show file tree
Hide file tree
Showing 27 changed files with 230 additions and 150 deletions.
5 changes: 4 additions & 1 deletion generate-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,10 @@ import {
type SeamHttpOptionsWithPersonalAccessToken,
type SeamHttpRequestOptions,
} from 'lib/seam/connect/options.js'
import { parseOptions } from 'lib/seam/connect/parse-options.js'
import {
limitToSeamHttpRequestOptions,
parseOptions
} from 'lib/seam/connect/parse-options.js'
import {
resolveActionAttempt,
} from 'lib/seam/connect/resolve-action-attempt.js'
Expand Down
8 changes: 1 addition & 7 deletions src/lib/seam/connect/options.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { Client, ClientOptions } from './client.js'
import { isSeamHttpRequestOption } from './parse-options.js'
import type { ResolveActionAttemptOptions } from './resolve-action-attempt.js'

export type SeamHttpMultiWorkspaceOptions =
Expand All @@ -22,13 +23,6 @@ export interface SeamHttpRequestOptions {
waitForActionAttempt?: boolean | ResolveActionAttemptOptions
}

const isSeamHttpRequestOption = (key: string): boolean => {
const keys: Record<keyof SeamHttpRequestOptions, true> = {
waitForActionAttempt: true,
}
return Object.keys(keys).includes(key)
}

export interface SeamHttpFromPublishableKeyOptions
extends SeamHttpCommonOptions {}

Expand Down
21 changes: 21 additions & 0 deletions src/lib/seam/connect/parse-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,24 @@ const getEndpointFromEnv = (): string | null | undefined => {
globalThis.process?.env?.SEAM_API_URL
)
}

export const limitToSeamHttpRequestOptions = (
options: Required<SeamHttpRequestOptions>,
): Required<SeamHttpRequestOptions> => {
return Object.keys(options)
.filter(isSeamHttpRequestOption)
.reduce(
(obj, key) => ({
...obj,
[key]: options[key as keyof SeamHttpRequestOptions],
}),
{},
) as Required<SeamHttpRequestOptions>
}

export const isSeamHttpRequestOption = (key: string): boolean => {
const keys: Record<keyof SeamHttpRequestOptions, true> = {
waitForActionAttempt: true,
}
return Object.keys(keys).includes(key)
}
15 changes: 9 additions & 6 deletions src/lib/seam/connect/routes/access-codes-unmanaged.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 9 additions & 6 deletions src/lib/seam/connect/routes/access-codes.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 9 additions & 6 deletions src/lib/seam/connect/routes/acs-access-groups.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 9 additions & 6 deletions src/lib/seam/connect/routes/acs-credentials.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 9 additions & 6 deletions src/lib/seam/connect/routes/acs-systems.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 9 additions & 6 deletions src/lib/seam/connect/routes/acs-users.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 9 additions & 6 deletions src/lib/seam/connect/routes/acs.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 9 additions & 6 deletions src/lib/seam/connect/routes/action-attempts.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 9 additions & 6 deletions src/lib/seam/connect/routes/client-sessions.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit c143d78

Please sign in to comment.