Skip to content

Commit

Permalink
New File Picker API and adding auth parameter tests (#50)
Browse files Browse the repository at this point in the history
* filepicker APIs

* new sdk version

* fixing auth types

* new file endpoints

* bumping version
  • Loading branch information
pellicceama authored Jan 27, 2025
1 parent 8fe8326 commit e98ac85
Show file tree
Hide file tree
Showing 7 changed files with 677 additions and 38 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -463,9 +463,9 @@ On the other hand OpenSDKs is most valuable when you are working with multiple 3
Or use this single command

```
cp -r ../repo/kits/sdk/openapi.json sdks/sdk-openint/openint.oas.json && \
SDK=sdk-openint && \
turbo run build --filter 'cli' && \
turbo run download --filter $SDK && \
turbo run generate --filter $SDK && \
turbo run build --filter $SDK
```
Expand Down
9 changes: 4 additions & 5 deletions packages/fetch-links/links/authLink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,25 @@ import {openIntProxyLink, OpenIntProxyLinkOptions} from './openIntProxyLink.js'
import {mergeHeaders, modifyRequest} from '../modifyRequestResponse.js'
import type {Link} from '../link.js'

export type ClientAuthOptions =
export type ClientAuthOptions = Partial<NonDiscriminatedUnion<
| {openInt: OpenIntProxyLinkOptions}
/** to be passed as Authorization header as a bearer token, Should handle automatic refreshing */
| {oauth: {accessToken: string; refreshToken?: string; expiresAt?: number}}
| {basic: {username: string; password: string}}
/** non oauth / directly specifying bearer token */
| {bearer: string}
| {bearer: string}>>

type Indexify<T> = T & Record<string, undefined>
type AllUnionKeys<T> = keyof UnionToIntersection<{[K in keyof T]: undefined}>
type NonDiscriminatedUnion<T> = {
[K in AllUnionKeys<T> & string]: Indexify<T>[K]
}

export function authLink(_auth: ClientAuthOptions, baseUrl: string): Link {
if (!_auth) {
export function authLink(auth: ClientAuthOptions, baseUrl: string): Link {
if (!auth) {
// No Op
return (req, next) => next(req)
}
const auth = _auth as NonDiscriminatedUnion<ClientAuthOptions>

if (auth.openInt) {
return openIntProxyLink(auth.openInt, baseUrl)
Expand Down
122 changes: 108 additions & 14 deletions sdks/sdk-openint/openint.oas.json

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

Loading

0 comments on commit e98ac85

Please sign in to comment.