Skip to content

Commit

Permalink
adding missing kit changes
Browse files Browse the repository at this point in the history
  • Loading branch information
pellicceama committed Oct 31, 2024
1 parent d1d3f16 commit 0a8899f
Show file tree
Hide file tree
Showing 8 changed files with 1,441 additions and 86 deletions.
2 changes: 2 additions & 0 deletions kits/cdk/connector.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import type {
import type {EndUserId, Id} from './id.types'
import {makeId} from './id.types'
import type {ZStandard} from './models'
import {VerticalKey} from './verticals'

/**
* Equivalent to to airbyte's low code connector spec,
Expand Down Expand Up @@ -226,6 +227,7 @@ export interface ConnectorServer<
name: string
logo_url?: string | null
updated_at: string
verticals?: VerticalKey[]
raw_data: T['_intOpType']['data']
}>
}>
Expand Down
2 changes: 1 addition & 1 deletion kits/cdk/entity-links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export function cachingTransformLink(

/**
* Used to workaround beancount limitation https://groups.google.com/g/beancount/c/PmkPVgLNKgg
* Not ideal that we have to use Openint link to workaround
* Not ideal that we have to use Venice link to workaround
* beancount quirk. Maybe this should actually be a beancount plugin in python?
* @see https://share.cleanshot.com/8AVFxc
* We have two options instead
Expand Down
1 change: 1 addition & 0 deletions kits/cdk/internal/NangoClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const zNangoOauthConnectParams = z
})
.passthrough()

// Where is this used relative to nango frontend?
export function buildNangoConnectUrl({
provider_config_key,
...params
Expand Down
18 changes: 18 additions & 0 deletions kits/cdk/internal/oauthConnector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,35 @@ export function oauthConnect({
connectorName,
connectorConfigId,
resourceId,
authOptions,
}: {
nangoFrontend: NangoFrontend
connectorName: string
connectorConfigId: Id['ccfg']
/** Should address the re-connect scenario, but let's see... */
resourceId?: Id['reso']
authOptions?: {
authorization_params?: Record<string, string | undefined>
}
}): Promise<OauthBaseTypes['connectOutput']> {
// console.log('oauthConnect', {
// connectorName,
// connectorConfigId,
// resourceId,
// authOptions,
// })
return nangoFrontend
.auth(
connectorConfigId,
resourceId ?? makeId('reso', connectorName, makeUlid()),
{
params: {},
...authOptions,
// authOptions would tend to contain the authorization_params needed to make the initial connection
// authorization_params: {
// scope: 'https://www.googleapis.com/auth/drive.readonly',
// },
},
)
.then((r) => oauthBaseSchema.connectOutput.parse(r))
.catch((err) => {
Expand Down
5 changes: 3 additions & 2 deletions kits/cdk/internal/remote-procedure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ export async function getRemoteContext(ctx: ProtectedContext) {
const nango = initNangoSDK({
headers: {authorization: `Bearer ${ctx.env.NANGO_SECRET_KEY}`},
})

// @ts-expect-error oauth is conditionally present
const oauthCredentialsExpiryTime = new Date(resource.settings?.oauth?.credentials?.raw?.expires_at ?? new Date(new Date().getTime() + 1000));
const forceRefreshCredentials = oauthCredentialsExpiryTime < new Date();

const settings = {
...resource.settings,
...(resource.connectorConfig.connector.metadata?.nangoProvider && {
Expand All @@ -48,6 +48,7 @@ export async function getRemoteContext(ctx: ProtectedContext) {
params: {
path: {connectionId},
query: {
refresh_token: true,
provider_config_key: providerConfigKey,
force_refresh: forceRefreshCredentials, // Conditionally call based on expiry
},
Expand Down
1 change: 1 addition & 0 deletions kits/cdk/verticals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const _VERTICAL_BY_KEY = {
one-way with no impact on original data.`,
objects: ['job', 'offer', 'candidate', 'opening'],
},
email: {},
} satisfies Record<string, VerticalInfo>

// MARK: -
Expand Down
Loading

0 comments on commit 0a8899f

Please sign in to comment.