repo_name
stringlengths
1
62
dataset
stringclasses
1 value
lang
stringclasses
11 values
pr_id
int64
1
20.1k
owner
stringlengths
2
34
reviewer
stringlengths
2
39
diff_hunk
stringlengths
15
262k
code_review_comment
stringlengths
1
99.6k
supaglue
github_2023
others
252
supaglue-labs
george-xing
@@ -0,0 +1,110 @@ +--- +sidebar_position: 3 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import BrowserWindow from '@site/src/components/BrowserWindow'; + +# Getting Started + +Use this guide to get up and running with Supaglue with your application. + +Here's a quick overview of the ...
Authenticate instead of OAuth
supaglue
github_2023
others
252
supaglue-labs
george-xing
@@ -0,0 +1,110 @@ +--- +sidebar_position: 3 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import BrowserWindow from '@site/src/components/BrowserWindow'; + +# Getting Started + +Use this guide to get up and running with Supaglue with your application. + +Here's a quick overview of the ...
update images to not include sidebar
supaglue
github_2023
typescript
288
supaglue-labs
asdfryan
@@ -35,9 +35,9 @@ export default function Home() { onDrawerToggle={handleDrawerToggle} /> <Box component="main" sx={{ flex: 1, py: 6, px: 4, bgcolor: '#eaeff1' }}> - <Typography variant="h6">Overview</Typography> - <Typography variant="subtitle2">List of connectors that ha...
Just delete this if you don't want it IMO
supaglue
github_2023
javascript
288
supaglue-labs
asdfryan
@@ -1,6 +1,15 @@ /** @type {import('next').NextConfig} */ const nextConfig = { reactStrictMode: true, + async redirects() {
I checked out the branch and I don't think this is working for me.
supaglue
github_2023
typescript
284
supaglue-labs
tomkit
@@ -220,12 +220,15 @@ const getFullName = (firstName?: string, lastName?: string): string | null => { }; export const toHubspotAccountCreateParams = (params: RemoteAccountCreateParams): Record<string, string> => { + const phoneParams = toHubspotPhoneCreateParams(params.phoneNumbers); return { name: params....
worth noting that hubspot doesn't accept null
supaglue
github_2023
typescript
275
supaglue-labs
asdfryan
@@ -1,16 +1,19 @@ import { internalMiddleware } from '@/middleware/internal'; import { Router } from 'express'; -import api_key from './api_key'; +import apiKey from './api_key'; +import v1Auth from './auth'; import customer from './customer'; import integration from './integration'; import webhook from './webhook...
This should also be guarded by the internal middleware
supaglue
github_2023
typescript
275
supaglue-labs
asdfryan
@@ -71,7 +70,7 @@ export default function AccountMenu() { transformOrigin={{ horizontal: 'right', vertical: 'top' }} anchorOrigin={{ horizontal: 'right', vertical: 'bottom' }} > - <MenuItem onClick={handleClose}> + {/* <MenuItem onClick={handleClose}>
Why not just delete?
supaglue
github_2023
typescript
275
supaglue-labs
asdfryan
@@ -1,13 +1,12 @@ import { API_HOST, APPLICATION_ID } from '@/client'; -import { camelcaseKeys } from '@/utils/camelcase'; import useSWR from 'swr'; import { fetcher } from '.'; export function useCustomers() { const { data, error, isLoading } = useSWR(`${API_HOST}/mgmt/v1/applications/${APPLICATION_ID}/custom...
This should be using internal
supaglue
github_2023
others
275
supaglue-labs
asdfryan
@@ -18,6 +32,7 @@ model Application { updatedAt DateTime @updatedAt @map("updated_at") Customer Customer[] Integration Integration[] + SgUser SgUser[]
This doesn't feel right -- the way this relation is defined, a single Application can have multiple SgUsers?
supaglue
github_2023
others
275
supaglue-labs
asdfryan
@@ -15,6 +15,7 @@ "@mui/material": "^5.11.12", "@mui/x-data-grid": "^6.0.0", "@mui/x-date-pickers": "^6.0.0", + "@next-auth/prisma-adapter": "^1.0.5",
Do we need this?
supaglue
github_2023
others
275
supaglue-labs
lucasmarshall
@@ -0,0 +1,3 @@ +SUPAGLUE_JWT_SECRET=a-secret-to-change +NEXT_PUBLIC_SUPAGLUE_INTERNAL_TOKEN=
We can't have this in the FE or we'll have to build a docker image per customer with their shared secret baked in.
supaglue
github_2023
typescript
275
supaglue-labs
lucasmarshall
@@ -0,0 +1,46 @@ +import { API_HOST, APPLICATION_ID } from '@/client'; +import NextAuth from 'next-auth'; +import CredentialsProvider from 'next-auth/providers/credentials'; + +const sgInternalToken = process.env.SUPAGLUE_INTERNAL_TOKEN!;
This isn't being set in the next app
supaglue
github_2023
typescript
273
supaglue-labs
tomkit
@@ -0,0 +1,17 @@ +import { UnauthorizedError } from '@supaglue/core/errors'; +import { NextFunction, Request, Response } from 'express'; +import { getDependencyContainer } from '../dependency_container'; + +const { applicationService } = getDependencyContainer(); + +export async function internalMiddleware(req: Request...
can we call it something other than the public one, e.g. `x-sg-api-key` or something
supaglue
github_2023
typescript
273
supaglue-labs
tomkit
@@ -0,0 +1,10 @@ +import { Router } from 'express'; +import v1 from './v1'; + +export default function init(app: Router): void { + const internalRouter = Router(); + + v1(internalRouter); + + app.use('/mgmt', internalRouter);
`internal_mgmt` or something like that?
supaglue
github_2023
others
270
supaglue-labs
albertyfwu
@@ -0,0 +1,3 @@ +type: object +additionalProperties: true +description: Custom properties to be inserted that is not covered by the common model. Object keys must match exactly to the corresponding provider API.
nit: that _are_ not
supaglue
github_2023
typescript
264
supaglue-labs
albertyfwu
@@ -87,6 +92,37 @@ export default function init(app: Router): void { } ); + applicationRouter.post('/:application_id/_generate_api_key', async (req: Request, res: Response) => {
can we use the actual req and res types?
supaglue
github_2023
typescript
264
supaglue-labs
albertyfwu
@@ -8,7 +8,8 @@ export type Application = BaseApplication & { }; export type ApplicationConfig = { - webhook: WebhookConfig | null; + webhook?: WebhookConfig | null;
what is the reasoning for both `undefined` and `null`? same question for `apiKey`
supaglue
github_2023
typescript
264
supaglue-labs
asdfryan
@@ -87,9 +99,53 @@ export default function init(app: Router): void { } ); + applicationRouter.post( + '/:application_id/_generate_api_key', + async ( + req: Request<CreateApplicationApiKeyPathParams, CreateApplicationApiKeyResponse, CreateApplicationApiKeyRequest>, + res: Response<CreateAppli...
We should move encryption stuff into a common lib (shared with our credentials encryption)
supaglue
github_2023
others
264
supaglue-labs
asdfryan
@@ -0,0 +1,5 @@ +type: object
We should add the required api key header too
supaglue
github_2023
others
264
supaglue-labs
lucasmarshall
@@ -33,6 +33,7 @@ services: - SUPAGLUE_DISABLE_ERROR_REPORTING - SUPAGLUE_POSTHOG_API_KEY - SUPAGLUE_API_ENCRYPTION_SECRET + - SUPAGLUE_API_KEY_SALT
Anything required we should use the syntax: ```suggestion - SUPAGLUE_API_KEY_SALT=${SUPAGLUE_API_KEY_SALT-?SUPAGLUE_API_KEY_SALT is a required environment variable} ```
supaglue
github_2023
others
264
supaglue-labs
asdfryan
@@ -1,7 +1,6 @@ -SUPAGLUE_API_KEY_SALT=please-change-me - SUPAGLUE_SYNC_PERIOD_MS=900000 SUPAGLUE_API_ENCRYPTION_SECRET=CHANGETHIS +SUPAGLUE_QUICKSTART_API_KEY="8o2kGDTHwTY6zcQV8gx7ep8vV7F2JNdeu95OR75MY7dlQJhzOiM4Ha/dKwXOTfDzDxVo+a6tZBrVxYfzJFIrgw=="
I think the quotes are unnecessary
supaglue
github_2023
others
269
supaglue-labs
albertyfwu
@@ -1,4 +1,5 @@ SUPAGLUE_SYNC_PERIOD_MS=900000 +SUPAGLUE_API_ENCRYPTION_SECRET=CHANGETHIS
merge with @tomkit 's encryption stuff?
supaglue
github_2023
typescript
269
supaglue-labs
albertyfwu
@@ -1,22 +1,41 @@ import type { Connection as ConnectionModel } from '@supaglue/db'; -import { Connection, ConnectionCredentials, ConnectionStatus, CRMConnection } from '../types'; +import { decrypt } from '../lib/crypt'; +import { ConnectionSafe, ConnectionStatus, ConnectionUnsafe, CRMConnectionUnsafe } from '../type...
can you remove casting to ensure that we're actually adhering to safe/unsafe types?
supaglue
github_2023
typescript
269
supaglue-labs
albertyfwu
@@ -1,22 +1,41 @@ import type { Connection as ConnectionModel } from '@supaglue/db'; -import { Connection, ConnectionCredentials, ConnectionStatus, CRMConnection } from '../types'; +import { decrypt } from '../lib/crypt'; +import { ConnectionSafe, ConnectionStatus, ConnectionUnsafe, CRMConnectionUnsafe } from '../type...
remove casting
supaglue
github_2023
others
269
supaglue-labs
tomkit
@@ -62,7 +62,7 @@ model Connection { // Salesforce, Hubspot, etc. providerName String @map("provider_name") status String // available | added | authorized | callable - credentials Json // {type, access_token, refresh_token, expires_at, raw} + credentials Bytes // encrypted, {type,...
for future `type` and `expires_at` might be relevant to pull out so we can do eager token refreshing
supaglue
github_2023
typescript
262
supaglue-labs
albertyfwu
@@ -139,4 +150,21 @@ export class AccountService extends CommonModelBaseService { fromRemoteAccountToDbAccountParams ); } + + public async updateDanglingOwners(connectionId: string): Promise<void> { + const accountsTable = COMMON_MODEL_DB_TABLES['accounts']; + const usersTable = COMMON_MODEL_DB_TA...
nit: `a` instead of `c`?
supaglue
github_2023
typescript
261
supaglue-labs
asdfryan
@@ -1,6 +1,16 @@ import { PrismaClient } from '@prisma/client'; -const prisma = new PrismaClient(); +const prisma = new PrismaClient({ + // log: ['query'],
Remove
supaglue
github_2023
typescript
261
supaglue-labs
asdfryan
@@ -1,6 +1,16 @@ import { PrismaClient } from '@prisma/client'; -const prisma = new PrismaClient(); +const prisma = new PrismaClient({ + // log: ['query'], +}); export * from '@prisma/client'; export default prisma; + +// TODO: Shouldn't be hard-coding the DB schema here. +export const COMMON_MODEL_DB_TABLES = ...
There's a user table now
supaglue
github_2023
typescript
257
supaglue-labs
albertyfwu
@@ -0,0 +1,44 @@ +import { getDependencyContainer } from '@/dependency_container'; +import { camelcaseKeys } from '@/lib/camelcase'; +import { snakecaseKeys } from '@/lib/snakecase'; +import { Request, Response, Router } from 'express'; + +const { userService } = getDependencyContainer(); + +export default function ini...
can we use the actual types to have type-checking?
supaglue
github_2023
typescript
257
supaglue-labs
albertyfwu
@@ -1,5 +1,5 @@ import type { CrmAccount, CrmContact, CrmLead } from '@supaglue/db'; -import type { Account, Address, Contact, EmailAddress, PhoneNumber } from '.'; +import type { Account, Address, Contact, EmailAddress, PhoneNumber } from '../index';
just `..` is enough
supaglue
github_2023
others
255
supaglue-labs
asdfryan
@@ -23,15 +23,17 @@ model Application { } model Customer { - id String @id @default(uuid()) - applicationId String @map("application_id") - application Application @relation(fields: [applicationId], references: [id], onDelete: Cascade) - connections Connection[] - name Stri...
Why 320?
supaglue
github_2023
others
256
supaglue-labs
albertyfwu
@@ -187,6 +187,20 @@ model CrmOpportunity { @@map("crm_opportunities") } +model CrmUser { + id String @id @default(uuid()) + remoteId String @map("remote_id") + customerId String @map("customer_id") + connectionId String @map("connection_id") + remoteWasDeleted Boolean @de...
nit: can we drop `@db.VarChar(255)` and let prisma pick TEXT? it looks like TEXT is fine to use for strings in general in modern postgres
supaglue
github_2023
typescript
240
supaglue-labs
asdfryan
@@ -0,0 +1,49 @@ +import { snakecaseKeys } from './utils/snakecase'; + +export const API_HOST = 'http://localhost:8080'; + +// TODO: get this on the server-side from the session +export const APPLICATION_ID = 'a4398523-03a2-42dd-9681-c91e3e2efaf4'; + +// TODO: use Supaglue TS client +export async function updateRemoteI...
data can be typed
supaglue
github_2023
typescript
240
supaglue-labs
asdfryan
@@ -0,0 +1,49 @@ +import { snakecaseKeys } from './utils/snakecase'; + +export const API_HOST = 'http://localhost:8080'; + +// TODO: get this on the server-side from the session +export const APPLICATION_ID = 'a4398523-03a2-42dd-9681-c91e3e2efaf4'; + +// TODO: use Supaglue TS client
Most of this file can be DRYed
supaglue
github_2023
typescript
240
supaglue-labs
asdfryan
@@ -72,29 +83,62 @@ export default function IntegrationDetailTabPanel(props: IntegrationDetailTabPan }} /> </Stack> - <Stack direction="row" className="gap-2"> - <Button variant="outlined">Cancel</Button>{' '} - <Button - variant="contained" - onClick={() ...
Remove `{' '}`
supaglue
github_2023
typescript
240
supaglue-labs
asdfryan
@@ -72,29 +83,62 @@ export default function IntegrationDetailTabPanel(props: IntegrationDetailTabPan }} /> </Stack> - <Stack direction="row" className="gap-2"> - <Button variant="outlined">Cancel</Button>{' '} - <Button - variant="contained" - onClick={() ...
Why is this line necessary? Does it get overridden by the next line?
supaglue
github_2023
typescript
240
supaglue-labs
asdfryan
@@ -72,29 +83,62 @@ export default function IntegrationDetailTabPanel(props: IntegrationDetailTabPan }} /> </Stack> - <Stack direction="row" className="gap-2"> - <Button variant="outlined">Cancel</Button>{' '} - <Button - variant="contained" - onClick={() ...
Is 1x/hour what we want?
supaglue
github_2023
typescript
240
supaglue-labs
asdfryan
@@ -29,9 +33,16 @@ export default function IntegrationDetailTabPanel(props: IntegrationDetailTabPan return ( <Stack direction="column" className="gap-4"> <Stack direction="row" className="items-center justify-between w-full"> - <Stack direction="row"> - {providerToIcon(integrationCardInfo...
ICON_SIZE?
supaglue
github_2023
typescript
240
supaglue-labs
asdfryan
@@ -17,8 +19,10 @@ export default function IntegrationDetailTabPanel(props: IntegrationDetailTabPan const [clientId, setClientId] = useState(''); const [clientSecret, setClientSecret] = useState(''); const [oauthScopes, setOauthScopes] = useState(''); + const router = useRouter(); - const { trigger } = use...
Looks like integration is already passed in as a prop -- why do we need to do this?
supaglue
github_2023
others
238
supaglue-labs
albertyfwu
@@ -21,9 +21,9 @@ https://`{DOMAIN}`/oauth/connect?customerId=`{CUSTOMER_ID}`&providerName=`{PROVI | `{PROVIDER_NAME}` | The name of the third-party provider (e.g. `salesforce`, `hubspot`, etc.) | Yes | | `{RETURN_URL}` | The URL to return to once the OAuth connection is complete, note: this ca...
can we avoid absolute links? in the last product we have issues with docs from one version linking to docs in another version
supaglue
github_2023
typescript
234
supaglue-labs
tomkit
@@ -20,3 +20,45 @@ export type DeleteCustomerPathParams = paths[`/customers/{customer_id}`]['parame export type DeleteCustomerRequest = never; export type DeleteCustomerResponse = operations['deleteCustomer']['responses'][keyof operations['deleteCustomer']['responses']]['content']['application/json']; + +export ty...
are these under `/customers/:customer_id` ?
supaglue
github_2023
others
233
supaglue-labs
tomkit
@@ -0,0 +1,34 @@ +openapi: 3.0.3 +info: + version: 0.3.3 + title: Supaglue Customer API + contact: + name: Supaglue + email: docs@supaglue.com + url: 'https://supaglue.com' + description: | + # Introduction + + Welcome to the Supaglue Management API documentation. You can use this API to manage custo...
do we have an `/api/` path? I was able to hit it with just `/mgmt/v1/`
supaglue
github_2023
typescript
227
supaglue-labs
albertyfwu
@@ -1,10 +1,18 @@ -import type { Customer, Customer as CustomerModel } from '@supaglue/db'; +import type { Customer } from '@supaglue/db'; +import { CustomerExpanded } from '../types/customer'; +import { fromConnectionModel } from './connection'; -export const fromCustomerModel = ({ id, applicationId, createdAt, upda...
Can we avoid type assertions?
supaglue
github_2023
typescript
227
supaglue-labs
asdfryan
@@ -1,10 +1,18 @@ -import type { Customer, Customer as CustomerModel } from '@supaglue/db'; +import type { Customer } from '@supaglue/db'; +import { CustomerExpanded } from '../types/customer'; +import { fromConnectionModel } from './connection'; -export const fromCustomerModel = ({ id, applicationId, createdAt, upda...
This method signature doesn't make sense to me. Based on the name it looks like you are converting from prisma model to the entity model, but `CustomerExpanded` is not the prisma model.
supaglue
github_2023
typescript
227
supaglue-labs
asdfryan
@@ -1,10 +1,18 @@ -import type { Customer, Customer as CustomerModel } from '@supaglue/db'; +import type { Customer } from '@supaglue/db'; +import { CustomerExpanded } from '../types/customer'; +import { fromConnectionModel } from './connection'; -export const fromCustomerModel = ({ id, applicationId, createdAt, upda...
What are `expandedAssociations` in this context? Associations only really make sense in the common model (i.e. contacts->accounts etc)
supaglue
github_2023
typescript
221
supaglue-labs
tomkit
@@ -58,23 +66,40 @@ export class ConnectionWriterService { public async create(params: ConnectionCreateParams): Promise<Connection> { const integration = await this.#integrationService.getByProviderName(params.providerName); - // TODO: Is this the correct status? - const status: ConnectionStatus = 'adde...
Should we just do fire-and-forget now for these notification webhooks? We can look into queueing and making them lossless down the road (maybe take a look at svix at that point too)?
supaglue
github_2023
typescript
221
supaglue-labs
albertyfwu
@@ -0,0 +1,54 @@ +import type { PrismaClient } from '@supaglue/db'; +import { NotFoundError } from '../errors'; +import { fromApplicationModel } from '../mappers'; +import { Application, ApplicationCreateParams, ApplicationUpdateParams } from '../types'; + +export class ApplicationService { + #prisma: PrismaClient; + ...
nit: can just do `return applications.map(fromApplicationModel)`
supaglue
github_2023
typescript
221
supaglue-labs
albertyfwu
@@ -0,0 +1,54 @@ +import type { PrismaClient } from '@supaglue/db'; +import { NotFoundError } from '../errors'; +import { fromApplicationModel } from '../mappers'; +import { Application, ApplicationCreateParams, ApplicationUpdateParams } from '../types'; + +export class ApplicationService { + #prisma: PrismaClient; + ...
is it necessary to return the object on delete?
supaglue
github_2023
typescript
231
supaglue-labs
tomkit
@@ -296,32 +297,64 @@ class SalesforceClient extends CrmRemoteClientEventEmitter implements CrmRemoteC }); } - async #getBulk2QueryJobResults(soql: string): Promise<Record<string, string>[]> { + async #getBulk2QueryJobResults(soql: string): Promise<Readable> { const { id } = await this.#submitBulk2Quer...
🚀
supaglue
github_2023
typescript
231
supaglue-labs
asdfryan
@@ -187,15 +204,31 @@ class HubSpotClient extends CrmRemoteClientEventEmitter implements CrmRemoteClie return fromHubSpotCompanyToRemoteAccount(company); } - public async listOpportunities(): Promise<RemoteOpportunity[]> { - let after = undefined; - const remoteOpportunities = []; - do { - cons...
seems like there is a way to DRY this, but can be done later.
supaglue
github_2023
typescript
228
supaglue-labs
tomkit
@@ -0,0 +1,77 @@ +import { PrismaClient } from '@supaglue/db'; +import { stringify } from 'csv-stringify'; +import { Pool } from 'pg'; +import { from as copyFrom } from 'pg-copy-streams'; +import { RemoteService } from '../remote_service'; + +export abstract class CommonModelBaseService { + // TODO: Use just pg for co...
what did the perf of this upsert end up being vs upsert when not selecting from a (temp) table?
supaglue
github_2023
typescript
228
supaglue-labs
tomkit
@@ -0,0 +1,77 @@ +import { PrismaClient } from '@supaglue/db'; +import { stringify } from 'csv-stringify'; +import { Pool } from 'pg'; +import { from as copyFrom } from 'pg-copy-streams'; +import { RemoteService } from '../remote_service'; + +export abstract class CommonModelBaseService { + // TODO: Use just pg for co...
typo? `Columns`
supaglue
github_2023
typescript
219
supaglue-labs
tomkit
@@ -1,18 +1,40 @@ import { createActivities } from '@supaglue/sync-workflows'; import { SYNC_TASK_QUEUE } from '@supaglue/sync-workflows/constants'; -import { NativeConnection, Runtime, Worker } from '@temporalio/worker'; +import { LogLevel, LogMetadata, NativeConnection, Runtime, Worker } from '@temporalio/worker'; ...
@lucasmarshall when i logged last in api, i thought our interface was [level](meta, message) or [level](message) ?
supaglue
github_2023
others
209
supaglue-labs
lucasmarshall
@@ -4,3 +4,4 @@ /.pnp.* binary linguist-generated /packages/schemas/gen/**/* linguist-generated openapi/**/openapi.bundle.json linguist-generated +/packages/sdk/**/* linguist-generated
Can we omit the README? Also can we add a `packages/sdk/package.json` with a "generate" script that runs the command in the README?
supaglue
github_2023
typescript
210
supaglue-labs
lucasmarshall
@@ -1,14 +1,14 @@ import { connectionHeaderMiddleware } from '@/middleware/connection'; import { Router } from 'express'; import crm from './crm'; -import customer from './customer'; +import mgmt from './mgmt'; import oauth from './oauth'; export default function initRoutes(app: Router): void { oauth(app); + ...
Doesn't this router need to be mounted on app?
supaglue
github_2023
others
208
supaglue-labs
tomkit
@@ -0,0 +1,117 @@ +--- +sidebar_position: 6 +--- + +import ThemedImage from '@theme/ThemedImage'; + +# Embedded Links + +An Embedded Link is a UI component that allows your application users to set up an integration. + +export const IntegrationCard = ({ icon, provider, description, to }) => ( + <div className="mb-4 p-...
Can we call out the example is using Tailwindcss? Optionally show a version using stylesheets or just call out Tailwindcss above
supaglue
github_2023
typescript
199
supaglue-labs
lucasmarshall
@@ -22,6 +26,15 @@ import { toHubspotOpportunityUpdateParams, } from './mappers'; +const HUBSPOT_RECORD_LIMIT = 100; + +const ASYNC_RETRY_OPTIONS = { + forever: true,
Do we really want to retry forever?
supaglue
github_2023
typescript
199
supaglue-labs
lucasmarshall
@@ -124,14 +137,34 @@ class HubSpotClient extends CrmRemoteClientEventEmitter implements CrmRemoteClie } } - public async listAccounts(limit?: number): Promise<RemoteAccount[]> { - await this.maybeRefreshAccessToken(); - const companies = await this.#client.crm.companies.getAll( - limit, - /*...
We should use the logger here, not `console.error`
supaglue
github_2023
typescript
199
supaglue-labs
lucasmarshall
@@ -154,16 +187,36 @@ class HubSpotClient extends CrmRemoteClientEventEmitter implements CrmRemoteClie return fromHubSpotCompanyToRemoteAccount(company); } - public async listOpportunities(limit?: number): Promise<RemoteOpportunity[]> { - await this.maybeRefreshAccessToken(); - const deals = await this...
Same as above.
supaglue
github_2023
typescript
199
supaglue-labs
lucasmarshall
@@ -196,16 +249,36 @@ class HubSpotClient extends CrmRemoteClientEventEmitter implements CrmRemoteClie return fromHubSpotDealToRemoteOpportunity(deal); } - public async listContacts(limit?: number): Promise<RemoteContact[]> { - await this.maybeRefreshAccessToken(); - const contacts = await this.#client...
Same as above
supaglue
github_2023
typescript
199
supaglue-labs
tomkit
@@ -202,5 +216,13 @@ export class OpportunityService { }); }) ); + return opportunitiesWithDanglingAccounts[opportunitiesWithDanglingAccounts.length - 1].id; + } + + public async updateDanglingAccounts(connectionId: string) { + let cursor = undefined; + do { + cursor = await this.up...
does `POSTGRES_UPDATE_PARALLELISM` actually refer to concurrency? it looks like in `updateDanglingAccountImpl` it's mapped to `limit` ?
supaglue
github_2023
typescript
204
supaglue-labs
albertyfwu
@@ -28,5 +30,8 @@ export default function init(app: Router): void { return res.status(200).send(connection); }); + syncInfo(connectionRouter);
Given that we pass in the customer id in the headers, isn't it enough to look up the sync info? Why do we want to make the sync info and sync history endpoints nested under `/connections`?
supaglue
github_2023
typescript
204
supaglue-labs
tomkit
@@ -6,7 +6,7 @@ const { connectionService, integrationService } = getDependencyContainer(); export async function connectionMiddleware(req: any, res: Response, next: NextFunction) { req.sg = { - connectionId: req.params.connectionId, + connectionId: req.params.connectionId ?? req.params.connection_id,
how come we need to support both?
supaglue
github_2023
typescript
204
supaglue-labs
tomkit
@@ -0,0 +1,36 @@ +import { getDependencyContainer } from '@/dependency_container'; +import { snakecaseKeys } from '@/lib/snakecase'; +import { + GetSyncHistoryPathParams, + GetSyncHistoryQueryParams, + GetSyncHistoryRequest, + GetSyncHistoryResponse, +} from '@supaglue/schemas/customer'; +import { Request, Response...
how did you get req.params to work? if the param is not in the immediate router URI?
supaglue
github_2023
typescript
204
supaglue-labs
tomkit
@@ -6,7 +6,7 @@ const { connectionService, integrationService } = getDependencyContainer(); export async function connectionMiddleware(req: any, res: Response, next: NextFunction) { req.sg = { - connectionId: req.params.connectionId,
does the customer middleware also need to be updated?
supaglue
github_2023
typescript
204
supaglue-labs
tomkit
@@ -0,0 +1,36 @@ +import { getDependencyContainer } from '@/dependency_container'; +import { snakecaseKeys } from '@/lib/snakecase'; +import { + GetSyncHistoryPathParams, + GetSyncHistoryQueryParams, + GetSyncHistoryRequest, + GetSyncHistoryResponse, +} from '@supaglue/schemas/crm'; +import { Request, Response, Rou...
nit: at some point we probably should place all of our hydrated objects under a namespaced key, e.g. `sg`
supaglue
github_2023
typescript
204
supaglue-labs
tomkit
@@ -35,5 +35,5 @@ export default function init(app: Router): void { connection(integrationRouter); - app.use('/integrations/:integrationId', integrationMiddleware, integrationRouter);
does the integration middleware also need to be updated?
supaglue
github_2023
typescript
197
supaglue-labs
albertyfwu
@@ -16,6 +18,24 @@ export type RunSyncsArgs = { }; export async function runSyncs({ connectionId, sessionId }: RunSyncsArgs): Promise<void> { - await Promise.all(CRM_COMMON_MODELS.map((commonModel) => doSync({ connectionId, commonModel, sessionId }))); + const historyIds = await Promise.all( + CRM_COMMON_MODEL...
This is probably beyond the scope of this PR, but we should probably leave a note somewhere that we need to address the "sync" abstraction so that we can properly account for the fact that associations are not done yet by the time that `logSyncFinish` is recorded.
supaglue
github_2023
typescript
197
supaglue-labs
albertyfwu
@@ -0,0 +1,23 @@ +import { SyncHistoryService } from '@supaglue/core/services'; +import { SyncHistoryStatus } from '@supaglue/core/types/sync_history'; + +export function createLogSyncFinish({ syncHistoryService }: { syncHistoryService: SyncHistoryService }) { + return async function logSyncFinish({ + historyId, + ...
Could we move this business logic inside `SyncHistoryService` instead instead of exposing a generic `update` method? It doesn't seem like there will be any external trigger of these methods; they're all internal uses.
supaglue
github_2023
others
197
supaglue-labs
albertyfwu
@@ -169,11 +169,11 @@ model CrmOpportunity { } model SyncHistory { - id String @id @default(uuid()) + id Int @id @default(autoincrement()) // contact, lead, account, opportunity, etc. model String // success | error
update comment? I believe `IN_PROGRESS` is a valid status
supaglue
github_2023
typescript
197
supaglue-labs
albertyfwu
@@ -0,0 +1,15 @@ +import { Connection } from './connection'; + +export type SyncHistoryStatus = 'SUCCESS' | 'FAILURE' | 'IN_PROGRESS'; + +export type SyncHistory = { + id: number; + model: string; + status: SyncHistoryStatus; + errorMessage: string | null; + startTimestamp: Date; + endTimestamp: Date | null; + c...
maybe we can address in another PR, but doesn't this include the credentials too? Is that necessary for a consumer of `SyncHistory`?
supaglue
github_2023
typescript
197
supaglue-labs
albertyfwu
@@ -0,0 +1,86 @@ +import type { PrismaClient } from '@supaglue/db'; +import { getPaginationParams, getPaginationResult } from '../lib/pagination'; +import { fromSyncHistoryModel } from '../mappers'; +import type { PaginatedResult, PaginationParams, SyncHistory, SyncHistoryCreateParams } from '../types'; + +export class...
is the todo to make it generic later?
supaglue
github_2023
typescript
197
supaglue-labs
albertyfwu
@@ -0,0 +1,23 @@ +import type { Connection, SyncHistory as SyncHistoryModel } from '@supaglue/db'; +import { SyncHistory, SyncHistoryStatus } from '../types'; +import { fromConnectionModel } from './connection'; + +export const fromSyncHistoryModel = ({ + id, + model, + status, + errorMessage, + startTimestamp, + ...
does this still return the `credentials`? Additionally, why does the caller of `syncHistoryModel` need the connection object?
supaglue
github_2023
typescript
196
supaglue-labs
lucasmarshall
@@ -1,4 +1,6 @@ +import { CsvError, Info, parse } from 'csv-parse'; import * as jsforce from 'jsforce'; +import fetch, { type Response } from 'node-fetch';
Where is this being added as a dependency? I don't see it in the `package.json` above. Also, we could just use the [built-in node version](https://nodejs.org/dist/latest-v18.x/docs/api/globals.html#fetch) of fetch since we are on node 18
supaglue
github_2023
typescript
196
supaglue-labs
lucasmarshall
@@ -150,13 +195,112 @@ class SalesforceClient extends CrmRemoteClientEventEmitter implements CrmRemoteC }); } + async #submitBulk2QueryJob(soql: string): Promise<SalesforceBulk2QueryJob> { + const response = await fetch(`${this.#instanceUrl}/services/data/v57.0/jobs/query`, { + method: 'POST', + ...
Same as above
supaglue
github_2023
typescript
196
supaglue-labs
lucasmarshall
@@ -150,13 +195,112 @@ class SalesforceClient extends CrmRemoteClientEventEmitter implements CrmRemoteC }); } + async #submitBulk2QueryJob(soql: string): Promise<SalesforceBulk2QueryJob> { + const response = await fetch(`${this.#instanceUrl}/services/data/v57.0/jobs/query`, { + method: 'POST', + ...
Same as above
supaglue
github_2023
typescript
196
supaglue-labs
lucasmarshall
@@ -150,13 +195,112 @@ class SalesforceClient extends CrmRemoteClientEventEmitter implements CrmRemoteC }); } + async #submitBulk2QueryJob(soql: string): Promise<SalesforceBulk2QueryJob> { + const response = await fetch(`${this.#instanceUrl}/services/data/v57.0/jobs/query`, {
Do we want the version to be config-driven here?
supaglue
github_2023
typescript
200
supaglue-labs
lucasmarshall
@@ -0,0 +1,39 @@ +import { getDependencyContainer } from '@/dependency_container'; +import { customerMiddleware } from '@/middleware/customer'; +import { Request, Response, Router } from 'express'; +import integration from './integration'; + +const { customerService } = getDependencyContainer(); + +export default funct...
Let's type these?
supaglue
github_2023
typescript
200
supaglue-labs
lucasmarshall
@@ -0,0 +1,32 @@ +import { getDependencyContainer } from '@/dependency_container'; +import { connectionMiddleware } from '@/middleware/connection'; +import { Request, Response, Router } from 'express'; + +const { connectionService } = getDependencyContainer(); + +export default function init(app: Router): void { + app...
Same as above, need types
supaglue
github_2023
typescript
200
supaglue-labs
lucasmarshall
@@ -0,0 +1,39 @@ +import { getDependencyContainer } from '@/dependency_container'; +import { integrationMiddleware } from '@/middleware/integration'; +import { Request, Response, Router } from 'express'; +import connection from './connection'; + +const { integrationService } = getDependencyContainer(); + +export defaul...
Same as above, need types
supaglue
github_2023
typescript
200
supaglue-labs
khennes
@@ -0,0 +1,13 @@ +export type Customer = { + id: string; + createdAt: Date; + updatedAt: Date; + + // TODO: add fields +}; +export type BaseCustomer = Customer & { + // TODO: add fields +}; +export type BaseCustomerCreateParams = Omit<Omit<Omit<BaseCustomer, 'id'>, 'createdAt'>, 'updatedAt'>;
```suggestion export type BaseCustomerCreateParams = Omit<BaseCustomer, 'id' | 'createdAt' | 'updatedAt'>; ```
supaglue
github_2023
javascript
190
supaglue-labs
lucasmarshall
@@ -182,39 +182,39 @@ const config = { }, { label: 'Microsoft Dynamics 365 Sales', - href: '/connectors/more', + href: '/connectors/ms_dynamics_365_sales',
Can we generate this from the files in the directly instead of configuring manually?
supaglue
github_2023
typescript
190
supaglue-labs
lucasmarshall
@@ -21,7 +22,22 @@ const { DEV_PIPEDRIVE_CLIENT_SECRET, DEV_PIPEDRIVE_SCOPES, DEV_PIPEDRIVE_APP_ID, - SUPAGLUE_SYNC_PERIOD_MS, + DEV_ZENDESK_SELL_CLIENT_ID,
You need to update the list above.
supaglue
github_2023
typescript
190
supaglue-labs
albertyfwu
@@ -0,0 +1,104 @@ +import { + AccountCreateParams, + CRMConnection, + Integration, + RemoteAccount, + RemoteAccountUpdateParams, + RemoteContact, + RemoteContactCreateParams, + RemoteContactUpdateParams, + RemoteLead, + RemoteLeadCreateParams, + RemoteLeadUpdateParams, + RemoteOpportunity, + RemoteOpportun...
don't need these methods
supaglue
github_2023
others
191
supaglue-labs
albertyfwu
@@ -166,3 +167,18 @@ model CrmOpportunity { @@unique([connectionId, remoteId]) @@map("crm_opportunities") } + +model SyncHistory { + id String @id @default(uuid()) + // contact, lead, account, opportunity, etc. + object String
we should standardize on `object` or `model`. i think we're using both in the code...
supaglue
github_2023
others
191
supaglue-labs
albertyfwu
@@ -166,3 +167,18 @@ model CrmOpportunity { @@unique([connectionId, remoteId]) @@map("crm_opportunities") } + +model SyncHistory { + id String @id @default(uuid()) + // contact, lead, account, opportunity, etc. + object String + // success | error + result String + startTime...
why do we want default here?
supaglue
github_2023
others
191
supaglue-labs
albertyfwu
@@ -33,19 +33,20 @@ model Integration { } model Connection { - id String @id @default(uuid()) - integration Integration @relation(fields: [integrationId], references: [id], onDelete: Cascade) - integrationId String @map("integration_id") + id String @id @default(uuid()) ...
lowercase? also, do we need to call it `syncHistoryList`? For connections, we're calling it `connections: Connection[]`
supaglue
github_2023
typescript
186
supaglue-labs
albertyfwu
@@ -0,0 +1,3 @@ +export type SyncConfig = { + period_ms: number;
should we make this camelcase?
supaglue
github_2023
typescript
186
supaglue-labs
albertyfwu
@@ -40,16 +38,14 @@ export class SyncService { } // TODO: Create CommonModel type - public async createSyncsSchedule(connectionId: string): Promise<void> { + public async createSyncsSchedule(connectionId: string, sync_period_ms: number): Promise<void> {
camelCase?
supaglue
github_2023
others
187
supaglue-labs
tomkit
@@ -60,17 +60,15 @@ services: - temporalitedata:/data init: - image: node:18 + image: supaglue/init
do we need an init in override.yml?
supaglue
github_2023
typescript
176
supaglue-labs
albertyfwu
@@ -16,6 +16,6 @@ export type RunSyncsArgs = { }; export async function runSyncs({ connectionId, sessionId }: RunSyncsArgs): Promise<void> { - await Promise.all(CRM_COMMON_MODELS.map((commonModel) => doSync({ connectionId, commonModel, sessionId }))); + CRM_COMMON_MODELS.map(async (commonModel) => await doSync({ ...
this is not being awaited
supaglue
github_2023
others
182
supaglue-labs
tomkit
@@ -6,17 +6,6 @@ "outputs": ["dist/**"] }, "docs#build": { - "inputs": [ - "../../openapi/**/openapi.bundle.json", - "blog/**/*", - "docs/**/*", - "docusaurus.config.js", - "sidebars.js", - "package.json", - "tsconfig.json", - "src/**/*", - ...
Thanks!
supaglue
github_2023
others
168
supaglue-labs
lucasmarshall
@@ -4,7 +4,6 @@ services: environment: - NODE_ENV=development
Probably don't want to check these changes in
supaglue
github_2023
typescript
168
supaglue-labs
lucasmarshall
@@ -45,6 +45,8 @@ app.use( }) ); +app.use(posthogMiddleware);
Doesn't this log success always, even for errors?
supaglue
github_2023
others
164
supaglue-labs
lucasmarshall
@@ -12,36 +12,42 @@ services: POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-supaglue} api: - image: supaglue/api + image: node:18 ports: - '8080:8080' depends_on: - postgres environment: - - NODE_ENV=production
Keep this
supaglue
github_2023
others
164
supaglue-labs
lucasmarshall
@@ -12,36 +12,42 @@ services: POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-supaglue} api: - image: supaglue/api + image: node:18 ports: - '8080:8080' depends_on: - postgres environment: - - NODE_ENV=production - SUPAGLUE_SYNC_PERIOD_MS - SUPAGLUE_DATABASE_URL...
Remove this
supaglue
github_2023
others
164
supaglue-labs
lucasmarshall
@@ -12,36 +12,42 @@ services: POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-supaglue} api: - image: supaglue/api + image: node:18 ports: - '8080:8080' depends_on: - postgres environment: - - NODE_ENV=production - SUPAGLUE_SYNC_PERIOD_MS - SUPAGLUE_DATABASE_URL...
Remove this
supaglue
github_2023
others
164
supaglue-labs
lucasmarshall
@@ -12,36 +12,42 @@ services: POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-supaglue} api: - image: supaglue/api + image: node:18 ports: - '8080:8080' depends_on: - postgres environment: - - NODE_ENV=production - SUPAGLUE_SYNC_PERIOD_MS - SUPAGLUE_DATABASE_URL...
Keep this.
supaglue
github_2023
others
163
supaglue-labs
lucasmarshall
@@ -6,7 +6,7 @@ sidebar_position: 2 ### Third-party provider information -Supaglue interfaces with the Salesforce async Bulk 2 API using the jsForce client. +Supaglue interfaces with the Salesforce async Bulk 2 API using the JSforce client.
```suggestion Supaglue interfaces with the Salesforce async Bulk 2.0 API using the JSforce client. ```
supaglue
github_2023
others
155
supaglue-labs
lucasmarshall
@@ -21,40 +19,51 @@ # Supaglue -Supaglue is a developer platform for integrating your application with your customer's Salesforce instance. It lets you authenticate with Salesforce, define integrations with code to sync SFDC sObjects, and expose customer-facing UI components in your application. Supaglue takes car...
```suggestion Continue on to the docs to go through our [quickstart](https://docs.supaglue.com/quickstart?ref=github-readme). ```