Skip to content

Commit

Permalink
feat(wip): add xero connector to venice (#55)
Browse files Browse the repository at this point in the history
* feat(wip): dummy xero connector implementation

* remove xero-sdk reference till publish

* feat: add xero connector with open-sdk

* update connector image on dashboard

* update name
  • Loading branch information
jatinsandilya authored Mar 31, 2024
1 parent a9bd65b commit fad365b
Show file tree
Hide file tree
Showing 11 changed files with 112 additions and 17 deletions.
2 changes: 2 additions & 0 deletions apps/app-config/connectors/connectors.def.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {default as connectorTwenty} from '@usevenice/connector-twenty/def'
import {default as connectorVenmo} from '@usevenice/connector-venmo/def'
import {default as connectorWebhook} from '@usevenice/connector-webhook/def'
import {default as connectorWise} from '@usevenice/connector-wise/def'
import {default as connectorXero} from '@usevenice/connector-xero/def'
import {default as connectorYodlee} from '@usevenice/connector-yodlee/def'

export const defConnectors = {
Expand Down Expand Up @@ -66,5 +67,6 @@ export const defConnectors = {
venmo: connectorVenmo,
webhook: connectorWebhook,
wise: connectorWise,
xero: connectorXero,
yodlee: connectorYodlee,
}
8 changes: 8 additions & 0 deletions apps/app-config/connectors/connectors.merged.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ import {default as connectorWebhook_def} from '@usevenice/connector-webhook/def'
import {default as connectorWebhook_server} from '@usevenice/connector-webhook/server'
import {default as connectorWise_def} from '@usevenice/connector-wise/def'
import {default as connectorWise_server} from '@usevenice/connector-wise/server'
import {default as connectorXero_def} from '@usevenice/connector-xero/def'
import {default as connectorXero_server} from '@usevenice/connector-xero/server'
import {default as connectorYodlee_def} from '@usevenice/connector-yodlee/def'
import {default as connectorYodlee_server} from '@usevenice/connector-yodlee/server'

Expand Down Expand Up @@ -222,6 +224,11 @@ const connectorWise = {
...connectorWise_server,
}

const connectorXero = {
...connectorXero_def,
...connectorXero_server,
}

const connectorYodlee = {
...connectorYodlee_def,
...connectorYodlee_server,
Expand Down Expand Up @@ -260,5 +267,6 @@ export const mergedConnectors = {
venmo: connectorVenmo,
webhook: connectorWebhook,
wise: connectorWise,
xero: connectorXero,
yodlee: connectorYodlee,
}
2 changes: 2 additions & 0 deletions apps/app-config/connectors/connectors.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {default as connectorToggl} from '@usevenice/connector-toggl/server'
import {default as connectorTwenty} from '@usevenice/connector-twenty/server'
import {default as connectorWebhook} from '@usevenice/connector-webhook/server'
import {default as connectorWise} from '@usevenice/connector-wise/server'
import {default as connectorXero} from '@usevenice/connector-xero/server'
import {default as connectorYodlee} from '@usevenice/connector-yodlee/server'

export const serverConnectors = {
Expand Down Expand Up @@ -62,5 +63,6 @@ export const serverConnectors = {
twenty: connectorTwenty,
webhook: connectorWebhook,
wise: connectorWise,
xero: connectorXero,
yodlee: connectorYodlee,
}
9 changes: 9 additions & 0 deletions apps/app-config/connectors/meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,15 @@ module.exports = [
server: '@usevenice/connector-wise/server',
},
},
{
name: 'xero',
dirName: 'connector-xero',
varName: 'connectorXero',
imports: {
def: '@usevenice/connector-xero/def',
server: '@usevenice/connector-xero/server',
},
},
{
name: 'yodlee',
dirName: 'connector-yodlee',
Expand Down
3 changes: 2 additions & 1 deletion apps/app-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
],
"scripts": {
"generate:docs": "pnpm tsx watch ./_generateDocs.bin.ts",
"generate:lists": "node --loader tsx ./_generateConnectorLists.ts"
"generate:lists": "npx tsx ./_generateConnectorLists.ts"
},
"dependencies": {
"@clerk/nextjs": "4.29.3",
Expand Down Expand Up @@ -48,6 +48,7 @@
"@usevenice/connector-venmo": "workspace:*",
"@usevenice/connector-webhook": "workspace:*",
"@usevenice/connector-wise": "workspace:*",
"@usevenice/connector-xero": "workspace:*",
"@usevenice/connector-yodlee": "workspace:*",
"@usevenice/engine-backend": "workspace:*",
"@usevenice/engine-frontend": "workspace:*",
Expand Down
2 changes: 2 additions & 0 deletions apps/web/public/_assets/logo-xero.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions connectors/connector-xero/def.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import type {
ConnectorDef,
ConnectorSchemas,
EntityPayloadWithRaw,
} from '@usevenice/cdk'
import {connHelpers} from '@usevenice/cdk'
import {z, zCast} from '@usevenice/util'

export const xeroSchemas = {
name: z.literal('xero'),
resourceSettings: z.object({
access_token: z.string(),
}),
destinationInputEntity: zCast<EntityPayloadWithRaw>(),
} satisfies ConnectorSchemas

export const helpers = connHelpers(xeroSchemas)

export const xeroDef = {
metadata: {
categories: ['accounting'],
logoUrl: '/_assets/logo-xero.svg',
displayName: 'Xero',
stage: 'alpha',
nangoProvider: 'xero',
},
name: 'xero',
schemas: xeroSchemas,
} satisfies ConnectorDef<typeof xeroSchemas>

export default xeroDef
4 changes: 4 additions & 0 deletions connectors/connector-xero/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// codegen:start {preset: barrel, include: "./{*.{ts,tsx},*/index.{ts,tsx}}", exclude: "./**/*.{d,spec,test,fixture,gen,node}.{ts,tsx}"}
export * from './def'
export * from './server'
// codegen:end
14 changes: 14 additions & 0 deletions connectors/connector-xero/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "@usevenice/connector-xero",
"version": "0.0.0",
"private": true,
"sideEffects": [],
"module": "./index.ts",
"dependencies": {
"@opensdks/sdk-xero": "^0.0.2",
"@opensdks/util-zod": "^0.0.15",
"@usevenice/cdk": "workspace:*",
"@usevenice/util": "workspace:*"
},
"devDependencies": {}
}
16 changes: 16 additions & 0 deletions connectors/connector-xero/server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import {initXeroSDK} from '@opensdks/sdk-xero'
import type {ConnectorServer} from '@usevenice/cdk'
import type {xeroSchemas} from './def'

export const xeroServer = {
newInstance: ({settings}) => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const xero = initXeroSDK({
headers: {authorization: `Bearer ${settings.access_token}`},
})
// TODO(@jatin): Add logic here to handle sync.
return xero
},
} satisfies ConnectorServer<typeof xeroSchemas>

export default xeroServer
38 changes: 22 additions & 16 deletions pnpm-lock.yaml

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

0 comments on commit fad365b

Please sign in to comment.