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 | typescript | 931 | supaglue-labs | albertyfwu | @@ -44,6 +45,25 @@ export default function init(app: Router) {
});
}
+ let strategyType = 'full then incremental';
+ if (version === 'v2') {
+ const { destination } = await prisma.integration.findFirstOrThrow({ | why not just query
```
prisma.connection.findFirstOrThrow({
select: {
integration: {
select: {
destination: true
}
}
}
});
```
|
supaglue | github_2023 | typescript | 928 | supaglue-labs | albertyfwu | @@ -125,6 +129,54 @@ export async function runSync({ syncId, connectionId, category }: RunSyncArgs):
);
}
+async function doFullOnlySync({ | you need to implement this in `run_managed_sync` not `run_sync` |
supaglue | github_2023 | typescript | 927 | supaglue-labs | asdfryan | @@ -12,13 +13,97 @@ import syncHistory from './sync_history';
import syncInfo from './sync_info';
import webhook from './webhook';
+const { prisma } = getDependencyContainer();
+
export default function init(app: Router): void {
// application routes should not require application header
const v1ApplicationR... | We need to condition this on whether or not version is v2 and the destination is s3 (`full only`) |
supaglue | github_2023 | typescript | 927 | supaglue-labs | asdfryan | @@ -61,6 +61,14 @@ export default function init(app: Router) {
id: existingSync.id,
},
data: {
+ // TODO: we need to kill the old syncs first before we set this,
+ // since it could be overridden by the old running syncs
+ strategy: {
+ type: 'full then... | same here |
supaglue | github_2023 | others | 886 | supaglue-labs | asdfryan | @@ -26,13 +26,14 @@ model Application {
}
model Destination {
- id String @id @default(uuid())
+ id String @id @default(uuid())
type String
- applicationId String @unique @map("application_id")
- application Application @relation(fields: [applicationId], refe... | should we drop this? or are we keeping it for now. |
supaglue | github_2023 | others | 213 | supaglue-labs | tomkit | @@ -55,6 +64,82 @@ Continue on to the docs to go through our [quickstart](https://docs.supaglue.com
We are currently in Public Alpha. Watch "releases" of this repo to be notified of significant updates (as minor semver releases).
+## Self hosting | Maybe move this to DEVELOPMENT.md |
supaglue | github_2023 | typescript | 674 | supaglue-labs | albertyfwu | @@ -63,6 +63,7 @@ export abstract class CommonModelBaseService {
columns,
cast: {
boolean: (value: boolean) => value.toString(),
+ string: (value: string) => value.replaceAll('\n', '\\n'), | does this work for \r\n too?
just curious why csv library wouldn't handle these. maybe there's an option to deal with it? |
supaglue | github_2023 | typescript | 733 | supaglue-labs | asdfryan | @@ -198,6 +205,18 @@ export default function PostgresDestinationDetailsPanel({ isLoading }: PostgresD
/>
</Stack>
+ <Stack className="gap-2">
+ <Typography variant="subtitle1">SSL</Typography>
+ <Select | Should this be a checkbox instead? |
supaglue | github_2023 | typescript | 733 | supaglue-labs | tomkit | @@ -58,6 +65,23 @@ export default function PostgresDestinationDetailsPanel({ isLoading }: PostgresD
if (!user) {
setUser(destination.config.user);
}
+ if (!password) {
+ setPassword(destination.config.password);
+ }
+ if (!ca) {
+ setCa(destination.config.ca);
+ }
+ if (!cert) ... | In another PR I removed these `if()` guards now that the 2nd argument for `useEffect()` (its `dependencies`) are working now. Having the `if()` guards would mean some values are set, but not others based on the value being truthy/falsy |
supaglue | github_2023 | others | 733 | supaglue-labs | tomkit | @@ -18,10 +18,41 @@ properties:
password:
type: string
example: password
+ sslmode:
+ type: string
+ enum:
+ - disable
+ - require
+ example: require
+ sslaccept:
+ type: string
+ enum:
+ - strict
+ - accept_invalid_certs
+ example: strict
+ ca:
+ type: string
+ ... | We might want to add a lightweight of differentiating between different types of connection configurations, e.g. not all will require certificates |
supaglue | github_2023 | others | 871 | supaglue-labs | asdfryan | @@ -26,11 +26,11 @@ items:
type: string
nullable: true
example: CA
- street1:
+ street_1: | I think this change is not backwards compatible -- in order to migrate we should probably keep both around / talk with our customers etc. |
supaglue | github_2023 | others | 864 | supaglue-labs | asdfryan | @@ -19,11 +19,24 @@ model Application {
orgId String @map("org_id")
Customer Customer[]
Integration Integration[]
+ Destination Destination[] | Why is this an array if there is a unique constraint? |
supaglue | github_2023 | typescript | 855 | supaglue-labs | albertyfwu | @@ -26,7 +26,11 @@ export abstract class AbstractCrmRemoteClient extends AbstractRemoteClient imple
return 'crm';
}
- abstract listObjects(commonModelType: CRMCommonModelType, updatedAfter?: Date): Promise<Readable>;
+ abstract listObjects(
+ commonModelType: CRMCommonModelType,
+ updatedAfter?: Date,... | maybe we should just name this `heartbeat` and break the abstraction barrier, so the method is expected to just heartbeat as often as it can when it's making forward progress |
supaglue | github_2023 | typescript | 843 | supaglue-labs | albertyfwu | @@ -248,14 +271,141 @@ class PipedriveClient extends AbstractCrmRemoteClient {
commonModelType: T,
params: CRMCommonModelTypeMap<T>['createParams']
): Promise<CRMCommonModelTypeMap<T>['object']> {
- throw new Error('Not implemented');
+ switch (commonModelType) {
+ case 'contact':
+ retur... | why do you need to assert the type here? we don't need to do this for hubspot or salesforce |
supaglue | github_2023 | typescript | 843 | supaglue-labs | albertyfwu | @@ -139,17 +144,126 @@ export const fromPipedrivePhonesToPhoneNumbers = (phoneNumbers: { label: string;
.map((phoneNumber) => ({ phoneNumber: phoneNumber.value, phoneNumberType: phoneNumber.label } as PhoneNumber));
};
-export const fromPipedriveOrganizationToAddress = (organization: PipedriveRecord): Address =... | if one of these is null, there will be an extra space. is that OK? |
supaglue | github_2023 | typescript | 837 | supaglue-labs | tomkit | @@ -102,19 +103,35 @@ const { connectionService, integrationService, webhookService, applicationServic
}
};
- const subscribe = (eventType: string) => {
- const streamErrorHandler = (err: any) => {
+ const subscribe = async (eventType: string) => { | What's diff between local and cloud for this? |
supaglue | github_2023 | others | 825 | supaglue-labs | asdfryan | @@ -21,6 +21,8 @@ post:
properties:
website:
$ref: ../components/schemas/filters.yaml#/filter
+ remote_id: | Should probably document that this is an AND and not an OR |
supaglue | github_2023 | typescript | 820 | supaglue-labs | albertyfwu | @@ -180,6 +179,18 @@ class OutreachClient extends AbstractEngagementRemoteClient {
]);
}
+ private async listSequenceStates(updatedAfter?: Date): Promise<Readable> {
+ const normalPageFetcher = await this.#getListRecordsFetcher(`${this.#baseURL}/api/v2/sequenceStates`, updatedAfter); | `#getListRecordsFetcher` doesn't need to return a Promise |
supaglue | github_2023 | typescript | 817 | supaglue-labs | albertyfwu | @@ -0,0 +1,92 @@
+import { EngagementSequenceState } from '@supaglue/db';
+import { GetInternalParams } from '@supaglue/types';
+import { RemoteSequenceState, SequenceState } from '@supaglue/types/engagement';
+import { v5 as uuidv5 } from 'uuid';
+
+export const toSnakecasedKeysSequenceState = (sequenceState: Sequence... | should we refactor these `uuidv5(...)` things into functions? this feels like it could be error-prone if we need to use this in multiple places |
supaglue | github_2023 | typescript | 817 | supaglue-labs | albertyfwu | @@ -0,0 +1,92 @@
+import { EngagementSequenceState } from '@supaglue/db';
+import { GetInternalParams } from '@supaglue/types';
+import { RemoteSequenceState, SequenceState } from '@supaglue/types/engagement';
+import { v5 as uuidv5 } from 'uuid';
+
+export const toSnakecasedKeysSequenceState = (sequenceState: Sequence... | nit: `??` instead of `||` |
supaglue | github_2023 | typescript | 816 | supaglue-labs | albertyfwu | @@ -0,0 +1,21 @@
+import {
+ CreateSequenceStatePathParams,
+ CreateSequenceStateRequest,
+ CreateSequenceStateResponse,
+} from '@supaglue/schemas/engagement';
+import { Request, Response, Router } from 'express';
+
+export default function init(app: Router): void {
+ const router = Router();
+
+ router.post(
+ ... | nit: `implemented` |
supaglue | github_2023 | others | 809 | supaglue-labs | tomkit | @@ -1,32 +1,53 @@
-post:
- operationId: createSequence
- summary: Create sequence
+get:
+ operationId: getSequences
+ summary: List sequences
tags:
- Sequences
security:
- ApiKeyAuth: []
- parameters: []
- requestBody:
- required: true
- content:
- application/json:
- schema:
- ... | nit: can use yaml here instead of json |
supaglue | github_2023 | typescript | 798 | supaglue-labs | tomkit | @@ -1,7 +1,9 @@
+export * from './application_service';
export * from './common_models';
export * from './connection_service';
export * from './customer_service';
export * from './integration_service';
export * from './remote_service';
export * from './sg_user_service';
export * from './sync_history_service';
+e... | Should we also move the existing webhooks into this? Is it meant to encapsulate both? If not, can we name it to reflect it or add a comment |
supaglue | github_2023 | others | 798 | supaglue-labs | tomkit | @@ -316,3 +317,15 @@ model SyncHistory {
@@map("sync_history")
}
+
+model ReplayId { | Should this be a top-level model? Or be encapsulated in a webhook model? |
supaglue | github_2023 | others | 806 | supaglue-labs | tomkit | @@ -6,6 +6,7 @@ x-common-env:
SUPAGLUE_LOG_LEVEL: debug
SUPAGLUE_DISABLE_ERROR_REPORTING: 1
NEXT_PUBLIC_SUPAGLUE_DISABLE_ERROR_REPORTING: 1
+ SUPAGLUE_DISABLE_ANALYTICS: 1 | are these still presence of flags? |
supaglue | github_2023 | typescript | 799 | supaglue-labs | tomkit | @@ -1,29 +1,114 @@
import { ConnectionUnsafe, Integration } from '@supaglue/types';
import { EngagementCommonModelType, EngagementCommonModelTypeMap } from '@supaglue/types/engagement';
+import axios from 'axios';
import { Readable } from 'stream';
+import { paginator } from '../../utils/paginator';
import { Abstra... | is `300000` an Outreach specific setting? |
supaglue | github_2023 | typescript | 795 | supaglue-labs | tomkit | @@ -20,36 +18,30 @@ type DependencyContainer = {
prisma: PrismaClient;
temporalClient: Client;
connectionService: ConnectionService;
- contactService: ContactService;
remoteService: RemoteService;
- accountService: AccountService;
- leadService: LeadService;
- userService: UserService;
- eventService: ... | nit: if we prefix all of these with `Crm` it will be more explicit for readability before we have engagement services for all of these objects |
supaglue | github_2023 | typescript | 795 | supaglue-labs | tomkit | @@ -15,10 +15,15 @@ if (schema) {
}
export const COMMON_MODEL_DB_TABLES = {
- contacts: `${schemaPrefix}crm_contacts`,
- accounts: `${schemaPrefix}crm_accounts`,
- leads: `${schemaPrefix}crm_leads`,
- opportunities: `${schemaPrefix}crm_opportunities`,
- users: `${schemaPrefix}crm_users`,
- events: `${schemaPr... | nit: This is namespacing using the table name -- if we move them into schemas we won't have to do string concatenation |
supaglue | github_2023 | typescript | 792 | supaglue-labs | asdfryan | @@ -43,7 +43,7 @@ WHERE last_modified_at IS NULL;
},
});
const unsafeSalesforceConnections = await Promise.all(
- salesforceConnectionModels.map(fromConnectionModelToConnectionUnsafe)
+ salesforceConnectionModels.map(fromConnectionModelToConnectionUnsafe<'salesforce'>) | We should just delete this endpoint IMO. This was for a migration. |
supaglue | github_2023 | typescript | 792 | supaglue-labs | asdfryan | @@ -0,0 +1,137 @@
+import { createPromiseClient, PromiseClient } from '@bufbuild/connect';
+// @ts-expect-error this is an ESM module, but we are only using the types
+import type { PartialMessage } from '@bufbuild/protobuf';
+import { logger } from '@supaglue/core/lib/logger';
+import { LRUCache } from 'lru-cache';
+i... | remove? |
supaglue | github_2023 | typescript | 792 | supaglue-labs | asdfryan | @@ -0,0 +1,137 @@
+import { createPromiseClient, PromiseClient } from '@bufbuild/connect';
+// @ts-expect-error this is an ESM module, but we are only using the types
+import type { PartialMessage } from '@bufbuild/protobuf';
+import { logger } from '@supaglue/core/lib/logger';
+import { LRUCache } from 'lru-cache';
+i... | remove? |
supaglue | github_2023 | typescript | 792 | supaglue-labs | asdfryan | @@ -0,0 +1,137 @@
+import { createPromiseClient, PromiseClient } from '@bufbuild/connect';
+// @ts-expect-error this is an ESM module, but we are only using the types
+import type { PartialMessage } from '@bufbuild/protobuf';
+import { logger } from '@supaglue/core/lib/logger';
+import { LRUCache } from 'lru-cache';
+i... | remove here and elsewhere |
supaglue | github_2023 | typescript | 792 | supaglue-labs | asdfryan | @@ -0,0 +1,125 @@
+import { getCoreDependencyContainer } from '@supaglue/core';
+import { logger } from '@supaglue/core/lib/logger';
+import { CDCChangeType, CDCWebhookPayload } from '@supaglue/types/cdc';
+import * as jsforce from 'jsforce';
+import { createClient } from './client';
+import { ReplayPreset } from './ge... | Do we need to periodically refresh this token? |
supaglue | github_2023 | typescript | 792 | supaglue-labs | asdfryan | @@ -0,0 +1,121 @@
+import { getCoreDependencyContainer } from '@supaglue/core';
+import { logger } from '@supaglue/core/lib/logger';
+import { CDCChangeType, CDCWebhookPayload } from '@supaglue/types/cdc';
+import * as jsforce from 'jsforce';
+import { createClient } from './client';
+import { ReplayPreset } from './ge... | I noticed we're refreshing the token here without persisting it in the db (i.e. via emitting the `token_refreshed` event, like we do in the salesforce client.
Does refreshing the token invalidate the existing access token? (e.g. for our syncs etc) |
supaglue | github_2023 | typescript | 785 | supaglue-labs | asdfryan | @@ -63,6 +65,12 @@ export async function runSync({ syncId, connectionId }: RunSyncArgs): Promise<vo
// Read sync from DB
const { sync } = await getSync({ syncId });
+ if (SyncStateFSM.isResetFlagSet(sync)) {
+ // NOTE: keep the resetted sync state in memory only and let the subsequent sync implementations t... | IMO we should only do this once the whole workflow is completed. |
supaglue | github_2023 | others | 785 | supaglue-labs | asdfryan | @@ -309,6 +309,7 @@ model CrmEvent {
model Sync {
id String @id @default(uuid())
state Json
+ resync Boolean @default(false) | Rename to forceSync or forceFullRefresh or something that matches the endpoint |
supaglue | github_2023 | typescript | 785 | supaglue-labs | asdfryan | @@ -78,3 +79,10 @@ export type ReverseThenForwardSyncState =
| ReverseThenForwardSyncStateForwardPhase;
export type SyncState = FullThenIncrementalSyncState | ReverseThenForwardSyncState;
+
+// The triplet of customer-provided identifiers to uniquely identify a sync. @todo: this triple can also be used elsewhere ... | Nit: typo |
supaglue | github_2023 | typescript | 785 | supaglue-labs | asdfryan | @@ -3,6 +3,7 @@ import { CommonModel } from './common';
type BaseSync = {
id: string;
connectionId: string;
+ resync: boolean; // flag: whether to treat the sync as phase "created" | rename |
supaglue | github_2023 | typescript | 785 | supaglue-labs | asdfryan | @@ -323,3 +333,16 @@ const getErrorMessageStack = (err: Error): { message: string; stack: string } =>
}
return { message: err.message ?? 'Unknown error', stack: err.stack ?? 'No stack' };
};
+
+class SyncStateFSM {
+ static isResetFlagSet(sync: Sync): boolean {
+ return sync.resync;
+ }
+
+ static setIniti... | Why do we need to do this? |
supaglue | github_2023 | typescript | 785 | supaglue-labs | asdfryan | @@ -323,3 +335,18 @@ const getErrorMessageStack = (err: Error): { message: string; stack: string } =>
}
return { message: err.message ?? 'Unknown error', stack: err.stack ?? 'No stack' };
};
+
+class SyncStateFSM { | This can be deleted now I think |
supaglue | github_2023 | typescript | 766 | supaglue-labs | lucasmarshall | @@ -46,6 +47,8 @@ export default function IntegrationDetailsPanel({ providerName, category, isLoad
);
useEffect(() => {
+ setFriendlyIntegrationId(integration?.id ? integration.id : '--'); | ```suggestion
setFriendlyIntegrationId(integration?.id ?? '--');
``` |
supaglue | github_2023 | typescript | 767 | supaglue-labs | asdfryan | @@ -67,18 +70,42 @@ export default function Home() {
setMobileOpen(!mobileOpen);
};
+ const handleEmebedLinkClick = async (params: GridRenderCellParams) => {
+ addNotification({ message: 'Copied to clipboard', severity: 'success' });
+
+ // NOTE: assumes one connection per customer
+ // TODO: data-d... | Why can't we just use the frontend url (from env var) here? |
supaglue | github_2023 | typescript | 767 | supaglue-labs | asdfryan | @@ -67,18 +70,42 @@ export default function Home() {
setMobileOpen(!mobileOpen);
};
+ const handleEmebedLinkClick = async (params: GridRenderCellParams) => {
+ addNotification({ message: 'Copied to clipboard', severity: 'success' });
+
+ // NOTE: assumes one connection per customer
+ // TODO: data-d... | This needs to come from env |
supaglue | github_2023 | typescript | 770 | supaglue-labs | tomkit | @@ -225,6 +230,17 @@ export const fromHubspotOwnerToRemoteUser = ({
remoteWasDeleted: !!archived,
remoteDeletedAt: null,
detectedOrRemoteDeletedAt: archived ? new Date() : null,
+ rawData: {
+ id, | nit: can you add a comment about where this list of fields came from? |
supaglue | github_2023 | others | 758 | supaglue-labs | lucasmarshall | @@ -75,7 +75,9 @@ model Connection {
credentials Bytes // encrypted, {type, access_token, refresh_token, expires_at, raw}
customer Customer @relation(fields: [customerId], references: [id], onDelete: Cascade)
customerId String @map("customer_id")
+ // Deprecated | ```suggestion
/// Deprecated
```
https://www.prisma.io/docs/concepts/components/prisma-schema#comments
|
supaglue | github_2023 | typescript | 727 | supaglue-labs | asdfryan | @@ -1,45 +1,41 @@
-import * as Sentry from '@sentry/node';
-import pino, { Level } from 'pino';
-import build from 'pino-abstract-transport';
+import pino, { Level, Logger } from 'pino';
+import { addContext, wrapLogger } from 'pino-context';
import pretty from 'pino-pretty';
+import { createWriteStream } from 'pino-s... | discussed offline -- I'm not sure this will do what we want, but testing sgtm |
supaglue | github_2023 | typescript | 727 | supaglue-labs | tomkit | @@ -15,18 +14,13 @@ import syncHistory from './sync_history';
import syncInfo from './sync_info';
import webhook from './webhook';
-const { connectionAndSyncService, prisma } = getDependencyContainer();
+const { prisma } = getDependencyContainer();
export default function init(app: Router): void {
// applicat... | How do you execute it now, ssh onto the machine and run the script? |
supaglue | github_2023 | typescript | 747 | supaglue-labs | lucasmarshall | @@ -304,7 +306,28 @@ class HubSpotClient extends AbstractCrmRemoteClient {
return await this.getAccount(company.id);
}
+ async #getPipelineStageMapping(): Promise<
+ Record<string, { label: string; stageIdsToLabels: Record<string, string> }>
+ > {
+ return await retryWhenRateLimited(async () => {
+ ... | Maybe we should cache this for a while? It won't change often, right? |
supaglue | github_2023 | typescript | 751 | supaglue-labs | tomkit | @@ -163,78 +164,46 @@ class HubSpotClient extends AbstractCrmRemoteClient {
}
public async listAccounts(updatedAfter?: Date): Promise<Readable> {
- // TODO(585): Incremental uses the Search endpoint which doesn't allow for more than 10000 results. We need to introduce another layer of pagination.
- let im... | The next PR has this function returning:
`return this.#listAccountsFull.bind(this, /* archived */ false);` |
supaglue | github_2023 | typescript | 732 | supaglue-labs | tomkit | @@ -216,7 +217,15 @@ export default function PostgresDestinationDetailsPanel({ isLoading }: PostgresD
setIsSaving(true);
const newDestination = await createOrUpdateDestination();
addNotification({ message: 'Successfully updated postgres destination', severity: 'success... | `id !== newDestination.id` |
supaglue | github_2023 | typescript | 723 | supaglue-labs | tomkit | @@ -52,9 +52,9 @@ export async function createOrUpdateWebhook(applicationId: string, data: Webhook
return r;
}
-export async function deleteWebhook(applicationId: string): Promise<void> {
+export async function deleteWebhook(applicationId: string) {
await fetch(`/api/internal/webhook/delete`, {
- method: 'P... | I originally considered 'DELETE', but since we're not deleting the actual resource, but operating on the "application" resource, I made it a POST (it currently behaves more like RPC) |
supaglue | github_2023 | others | 700 | supaglue-labs | tomkit | @@ -24,6 +24,9 @@
],
"outputs": ["build/**"]
},
+ "mgmt-ui#build": { | what does `#build` denote? |
supaglue | github_2023 | typescript | 708 | supaglue-labs | tomkit | @@ -604,3 +595,25 @@ export const authConfig: ConnectorAuthConfig = {
authorizeHost: 'https://login.salesforce.com',
authorizePath: '/services/oauth2/authorize',
};
+
+function capitalizeString(str: string): string {
+ if (!str) {
+ return str;
+ }
+ return str.charAt(0).toUpperCase() + str.slice(1);
+}
+
... | nit: could offload to underscore's intersection |
supaglue | github_2023 | typescript | 684 | supaglue-labs | lucasmarshall | @@ -11,18 +11,25 @@ import { useEffect, useState } from 'react';
import Spinner from '../Spinner';
import { integrationCardsInfo } from './IntegrationTabPanelContainer';
+const ONE_HOUR_SECONDS = 60 * 60;
+
export type IntegrationDetailsPanelProps = {
category: IntegrationCategory;
providerName: CRMProviderN... | This should be higher than 60 seconds. Most syncs take a couple of minutes at least. If we have it this low, we'll have a constantly growing queue.
5 minutes should be our min, IMO. |
supaglue | github_2023 | typescript | 694 | supaglue-labs | albertyfwu | @@ -42,6 +44,34 @@ export class LeadService extends CommonModelBaseService {
return fromLeadModel(model, expandedAssociations);
}
+ public async search(
+ connectionId: string,
+ paginationParams: PaginationInternalParams,
+ filters: LeadFilters
+ ): Promise<PaginatedResult<Lead>> {
+ const { pa... | nit: `models.map(fromLeadModel)` |
supaglue | github_2023 | typescript | 690 | supaglue-labs | albertyfwu | @@ -141,7 +140,7 @@ export const fromHubSpotContactToContact = ({
: [];
return {
- remoteId: id,
+ id: id, | nit: replace all `id: id` across all files with just `id` |
supaglue | github_2023 | others | 682 | supaglue-labs | asdfryan | @@ -26,11 +26,11 @@ items:
type: string
nullable: true
example: CA
- street1: | A couple weeks ago I changed it to this because if you convert this to camelcase and then back to snakecase, it remains street1 (doesn't work for street_1). |
supaglue | github_2023 | typescript | 682 | supaglue-labs | asdfryan | @@ -0,0 +1,333 @@
+import { ConnectionSafeAny, CRMCommonModelType, PostgresDestination } from '@supaglue/types';
+import { stringify } from 'csv-stringify';
+import { Pool, PoolClient } from 'pg';
+import { from as copyFrom } from 'pg-copy-streams';
+import { Readable, Transform } from 'stream';
+import { pipeline } fr... | it's available now |
supaglue | github_2023 | typescript | 682 | supaglue-labs | asdfryan | @@ -0,0 +1,333 @@
+import { ConnectionSafeAny, CRMCommonModelType, PostgresDestination } from '@supaglue/types';
+import { stringify } from 'csv-stringify';
+import { Pool, PoolClient } from 'pg';
+import { from as copyFrom } from 'pg-copy-streams';
+import { Readable, Transform } from 'stream';
+import { pipeline } fr... | Is it ever possible for 2 syncs to be running simultaneously for the same common model? |
supaglue | github_2023 | typescript | 682 | supaglue-labs | asdfryan | @@ -0,0 +1,333 @@
+import { ConnectionSafeAny, CRMCommonModelType, PostgresDestination } from '@supaglue/types';
+import { stringify } from 'csv-stringify';
+import { Pool, PoolClient } from 'pg';
+import { from as copyFrom } from 'pg-copy-streams';
+import { Readable, Transform } from 'stream';
+import { pipeline } fr... | I wonder if we can just get rid of all the `remote_` prefixes |
supaglue | github_2023 | typescript | 682 | supaglue-labs | asdfryan | @@ -39,6 +30,7 @@ export function createImportRecords(
}: ImportRecordsArgs): Promise<ImportRecordsResult> {
const connection = await connectionService.getSafeById(connectionId);
const client = await remoteService.getCrmRemoteClient(connectionId);
+ const writer = await destinationService.getWriterByApp... | What happens if you create a connection without any destinations? |
supaglue | github_2023 | typescript | 681 | supaglue-labs | albertyfwu | @@ -42,6 +43,9 @@ export default function PostgresDestinationDetailsPanel({ isLoading }: PostgresD
if (!database) {
setDatabase(destination.config.database);
}
+ if (!schema) {
+ setDatabase(destination.config.schema); | this should be `setSchema` |
supaglue | github_2023 | typescript | 681 | supaglue-labs | albertyfwu | @@ -133,6 +139,19 @@ export default function PostgresDestinationDetailsPanel({ isLoading }: PostgresD
/>
</Stack>
+ <Stack className="gap-2">
+ <Typography variant="subtitle1">Schema</Typography>
+ <TextField
+ value={database} | this needs to be schema too. i'll address in my PR |
supaglue | github_2023 | typescript | 671 | supaglue-labs | albertyfwu | @@ -8,46 +8,47 @@ type BaseDestinationUpdateParams = BaseDestination;
export type S3Destination = BaseDestination & {
type: 's3';
- // TODO: encryption
- config: {
- region: string; // us-west-2
- bucket: string;
- accessKeyId: string;
- secretAccessKey: string;
- };
+ // TODO(670): encryption
+ ... | where does the customer specify the schema we should write to? or should we use schema to encode `crm`, `hris`, etc.? |
supaglue | github_2023 | typescript | 673 | supaglue-labs | albertyfwu | @@ -74,7 +74,7 @@ export async function runSync({ syncId, connectionId }: RunSyncArgs): Promise<vo
break;
}
} catch (err: any) {
- const errorMessage = getErrorMessage(err);
+ const { message: errorMessage, stack: errorStack } = getErrorMessageStack(err);
await Promise.all(
CRM_COMMON... | why aren't we just literally passing the error in? i think we are doing too much conversion/mapping here |
supaglue | github_2023 | typescript | 656 | supaglue-labs | tomkit | @@ -39,8 +40,30 @@ SET last_modified_at = GREATEST(
WHERE last_modified_at IS NULL;
`);
}
+ });
- res.status(200).send();
+ v1ApplicationRouter.post('/_backfill_connection_remote_id', async (req, res) => {
+ const salesforceConnectionModels = await prisma.connection.findMany({
+ where: {
+ ... | nit: `forEach` |
supaglue | github_2023 | typescript | 663 | supaglue-labs | asdfryan | @@ -0,0 +1,65 @@
+/* eslint-disable @typescript-eslint/no-floating-promises */ | where is the floating promise? |
supaglue | github_2023 | typescript | 663 | supaglue-labs | asdfryan | @@ -0,0 +1,13 @@
+import PostgresIcon from '@/assets/destination_icons/postgres.png';
+import S3Icon from '@/assets/destination_icons/s3.png';
+import Image from 'next/image';
+import { ReactNode } from 'react';
+
+export default function destinationTypeToIcon(type: string, size = 25): ReactNode { | Can we refactor this and `providerToIcon` to be the same? it looks the same |
supaglue | github_2023 | typescript | 663 | supaglue-labs | asdfryan | @@ -0,0 +1,24 @@
+import { getOrgId } from '@/utils/org';
+import type { NextApiRequest, NextApiResponse } from 'next';
+import { API_HOST, SG_INTERNAL_TOKEN } from '../..';
+
+export default async function handler(req: NextApiRequest, res: NextApiResponse) {
+ const result = await fetch(`${API_HOST}/internal/v1/desti... | Can we take the opportunity to DRY this (at least the headers) |
supaglue | github_2023 | typescript | 663 | supaglue-labs | asdfryan | @@ -0,0 +1,170 @@
+/* eslint-disable @typescript-eslint/no-floating-promises */ | Where is the floating promise? |
supaglue | github_2023 | typescript | 666 | supaglue-labs | asdfryan | @@ -1,43 +1,22 @@
-import type {
- Address,
- BaseCrmModel,
- BaseCrmModelNonRemoteParams,
- BaseCrmModelRemoteOnlyParams,
- CustomFields,
- LifecycleStage,
- PhoneNumber,
- User,
-} from '..';
+import type { Address, BaseCrmModel, CustomFields, LifecycleStage, PhoneNumber } from '..';
import { Filter } from '... | Are we getting rid of the associations? |
supaglue | github_2023 | others | 653 | supaglue-labs | tomkit | @@ -15,8 +15,8 @@ jobs:
- name: Install Dependencies
run: yarn install
- name: Pull Vercel Environment Information
- run: yarn workspace mgmt-ui vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }} | What was the issue here, were there some artifacts from another github action or something? |
supaglue | github_2023 | typescript | 654 | supaglue-labs | albertyfwu | @@ -15,26 +14,12 @@ if (process.env.SUPAGLUE_PRETTY_LOGS) {
}
if (sentryEnabled) {
- const sentryStream = build(async (source) => {
- for await (const obj of source) {
- if (!obj) {
- return;
- }
-
- const { err, msg, level } = obj;
-
- // warning is 40, error is 50, fatal is 60
- ... | was the problem that we were returning here instead of `continue`? |
supaglue | github_2023 | typescript | 654 | supaglue-labs | albertyfwu | @@ -836,7 +836,7 @@ const retryWhenRateLimited = async <Args extends any[], Return>(
try {
return await operation(...parameters);
} catch (e: any) {
- logger.error(e, 'Error encountered');
+ logger.error(e, `Error encountered: ${e.message}`); | won't the error message be included by pino? why do we need to interpolate it here? |
supaglue | github_2023 | typescript | 654 | supaglue-labs | tomkit | @@ -1,16 +1,47 @@
+import { logger } from '@supaglue/core/lib';
+import { distinctId } from '@supaglue/core/lib/distinct_identifier';
+import { getSystemProperties, posthogClient } from '@supaglue/core/lib/posthog';
import { SyncHistoryService } from '@supaglue/core/services';
import { SyncHistoryStatus } from '@supa... | nit: can we log the message in a fixed way and log the dynamic/contextual part as part of the metadata argument to make it easier to search? |
supaglue | github_2023 | others | 633 | supaglue-labs | lucasmarshall | @@ -1,3 +1,63 @@
# Salesforce Connected App
-*Docs to be added...*
+import BrowserWindow from '@site/src/components/BrowserWindow';
+import Tabs from '@theme/Tabs';
+import TabItem from '@theme/TabItem';
+
+To connect to your customers' Salesforce instances, you'll need to update the redirect URL to point to Supaglu... | Should clarify that this is the customer's customer's Salesforce account we are talking about here. Given that, it may not belong in this section, since this is about our customer configuring their app in their developer account. |
supaglue | github_2023 | typescript | 622 | supaglue-labs | albertyfwu | @@ -253,7 +263,16 @@ class SalesforceClient extends AbstractCrmRemoteClient {
// CSV download for bulk 2.0 with large loads and also more future control of rate limits,
// etc.
if (response.status === 401) {
- await this.#refreshAccessToken();
+ try {
+ await this.#refreshAcc... | is the error name exactly this, or should this be `startsWith`? Can you give an example and leave a note to point to where this error gets generated in the jsforce library? Also, can we leave a comment/GH issue to possibly move off of jsforce here? |
supaglue | github_2023 | typescript | 622 | supaglue-labs | albertyfwu | @@ -2,12 +2,15 @@ import type { CRMProviderName } from './crm';
export type ConnectionStatus = 'available' | 'added' | 'authorized' | 'callable';
+// TODO: Bifurcate salesforce vs hubspot
export type ConnectionCredentialsDecrypted = {
type: string;
accessToken: string;
refreshToken: string;
expiresAt:... | create GH issue to bifurcate types |
supaglue | github_2023 | typescript | 600 | supaglue-labs | albertyfwu | @@ -25,7 +25,7 @@ const { populateAssociations } = proxyActivities<ReturnType<typeof createActivit
const { getSync, updateSyncState, logSyncStart, logSyncFinish, maybeSendSyncFinishWebhook } = proxyActivities<
ReturnType<typeof createActivities>
>({
- startToCloseTimeout: '30 second',
+ startToCloseTimeout: '5 m... | can you only bump the webhook to 5 minutes and leave the others alone |
supaglue | github_2023 | others | 583 | supaglue-labs | tomkit | @@ -21,9 +27,3 @@ Supported object types:
- Contact
- Lead
- Opportunity | We also support User now |
supaglue | github_2023 | others | 583 | supaglue-labs | tomkit | @@ -20,9 +26,3 @@ Supported object types:
- Company
- Contact
- Deal | We also support User now |
supaglue | github_2023 | typescript | 589 | supaglue-labs | lucasmarshall | @@ -15,8 +15,8 @@ export default function init(app: Router): void {
const v1Router = Router();
v1Router.use(apiKeyHeaderMiddleware);
- v1Router.post('/_manually_clean_up_orphaned_temporal_syncs', async (req, res) => {
- const result = await connectionAndSyncService.manuallyCleanUpOrphanedTemporalSyncs();
+ ... | Can we rename to `_manually_fix_syncs`? temporal is an implementation detail |
supaglue | github_2023 | typescript | 589 | supaglue-labs | tomkit | @@ -249,12 +260,97 @@ export class ConnectionAndSyncService {
}
}
+ // Upsert schedules in case
+ const connectionIds = syncs.map((sync) => sync.connectionId);
+ const connections = await this.#connectionService.getSafeByIds(connectionIds);
+
+ // Get the integrations
+ const integrationIds... | nit: I think the default we use in the mgmt-ui is 1 hour |
supaglue | github_2023 | others | 588 | supaglue-labs | asdfryan | @@ -43,6 +43,8 @@ paths:
$ref: paths/sync_history.yaml
'/sync-info':
$ref: paths/sync_info.yaml
+ '/sync/_manually_clean_up_orphaned_temporal_syncs': | This will generate openapi docs for this. Do we really want to expose this in our public API documentation? |
supaglue | github_2023 | others | 563 | supaglue-labs | albertyfwu | @@ -42,6 +42,8 @@ COPY --from=installer --chown=nodejs:nodejs /app/apps/api/dist .
COPY --from=installer --chown=nodejs:nodejs /app/node_modules ./node_modules
COPY --from=installer --chown=nodejs:nodejs /app/apps/api/package.json .
COPY --from=installer --chown=nodejs:nodejs /app/packages/core/dist ./node_modules/@... | thanks for catching these |
supaglue | github_2023 | typescript | 567 | supaglue-labs | albertyfwu | @@ -231,41 +241,42 @@ class SalesforceClient extends AbstractCrmRemoteClient {
this.emit('token_refreshed', token.access_token, null);
}
- async #fetch(path: string, init: RequestInit): Promise<ReturnType<typeof fetch>> {
- const helper = async () => {
- return await fetch(`${this.#instanceUrl}${path... | @asdfryan should t his be 429? |
supaglue | github_2023 | typescript | 569 | supaglue-labs | tomkit | @@ -96,24 +97,37 @@ export abstract class CommonModelBaseService {
logger.info({ connectionId, customerId, table }, 'Importing common model objects into temp table [COMPLETED]');
// Copy from temp table
- logger.info({ connectionId, customerId, table }, 'Copying from temp table to main table [IN PR... | Can we accumulate this from the stream above? |
supaglue | github_2023 | typescript | 562 | supaglue-labs | asdfryan | @@ -12,45 +14,54 @@ export function createPopulateAssociations(
leadService: LeadService,
eventService: EventService
) {
- return async function populateAssociations({ connectionId }: PopulateAssociationsArgs) {
+ return async function populateAssociations({
+ connectionId,
+ originalMaxLastModifiedAtMsM... | Shouldn't this be `originalMaxLastModifiedAtMsMap['account']` instead? |
supaglue | github_2023 | others | 562 | supaglue-labs | asdfryan | @@ -144,6 +145,7 @@ model CrmContact {
events CrmEvent[]
@@unique([connectionId, remoteId])
+ @@index([connectionId, lastModifiedAt(sort: Asc)]) // for incremental syncs hitting our API // TODO: consider adding index on `remoteWasDeleted` | We may want to add indices on the association fields |
supaglue | github_2023 | typescript | 562 | supaglue-labs | asdfryan | @@ -286,19 +303,25 @@ export class EventService extends CommonModelBaseService {
FROM ${contactsTable} u
WHERE
c.connection_id = '${connectionId}'
+ AND c.last_modified_at > '${startingLastModifiedAt.toISOString()}' | I haven't thought about this, but `startingLastModifiedAt` is for events right? Should this instead be for contacts instead? |
supaglue | github_2023 | others | 556 | supaglue-labs | tomkit | @@ -21,6 +21,10 @@ syncWorker:
nodeSelector: {}
tolerations: []
affinity: {}
+ db:
+ parameters:
+ connectionLimit: 0 # prisma defaults to num_cpu * 2 + 1
+ poolTimeout: 10 # primsa default is 10 secs | did you mean to reverse these two values? |
supaglue | github_2023 | typescript | 544 | supaglue-labs | albertyfwu | @@ -63,17 +63,25 @@ export class ApplicationService {
return applications.map(fromApplicationModel);
}
- public async create(createParams: ApplicationCreateParams): Promise<Application> {
- const createdApplication = await this.#prisma.application.create({
- data: {
+ public async upsert(createParam... | feels like createIfNotExist is better, since we already have an `update` endpoint, but don't feel strongly |
supaglue | github_2023 | typescript | 527 | supaglue-labs | asdfryan | @@ -38,6 +41,21 @@ export default function ApplicationMenu() {
await router.push(`/applications/${newApplication.id}`);
};
+ const onUpdateApplicationName = async (id: string, name: string) => {
+ handleClose();
+ const newApplication = await updateApplicationName(id, name);
+ await mutate(applicati... | Do you also need to update the active application? |
supaglue | github_2023 | typescript | 528 | supaglue-labs | albertyfwu | @@ -97,6 +97,15 @@ export function createImportRecords(
);
break;
}
+ case 'event': {
+ const readable = await client.listEvents(updatedAfter); | shouldn't this be await eventService.upsertRemoteEvents? |
supaglue | github_2023 | typescript | 528 | supaglue-labs | albertyfwu | @@ -0,0 +1,94 @@
+import { Event, RemoteEvent } from '@supaglue/types';
+import { v4 as uuidv4 } from 'uuid';
+import { fromAccountModel, fromContactModel, fromLeadModel, fromOpportunityModel, fromUserModel } from '.';
+import { CrmEventExpanded } from '../types';
+
+export const fromEventModel = (
+ {
+ id,
+ r... | is this intentional? missing `lead`? |
supaglue | github_2023 | typescript | 528 | supaglue-labs | albertyfwu | @@ -33,6 +39,52 @@ export const fromSalesforceUserToRemoteUser = (record: Record<string, any>): Rem
};
};
+export const fromSalesforceEventToRemoteEvent = (record: Record<string, any>): RemoteEvent => {
+ // In SFDC, WhoId can refer to either a contact or a lead
+ const remoteContactId = (record.WhoId as string... | can `whoId` be null? |
supaglue | github_2023 | typescript | 528 | supaglue-labs | albertyfwu | @@ -0,0 +1,262 @@
+import { COMMON_MODEL_DB_TABLES, schemaPrefix } from '@supaglue/db';
+import { Event, ListInternalParams, PaginatedResult } from '@supaglue/types';
+import { Readable } from 'stream';
+import { NotFoundError, UnauthorizedError } from '../../errors';
+import { getExpandedAssociations } from '../../lib... | we really need to do some de-duping/abstraction of code later |
supaglue | github_2023 | typescript | 521 | supaglue-labs | asdfryan | @@ -0,0 +1,22 @@
+import { NotFoundError } from '@supaglue/core/errors';
+import { fromApplicationModel } from '@supaglue/core/mappers/application';
+import type { PrismaClient } from '@supaglue/db';
+import { Application } from '@supaglue/types';
+
+export class ApplicationService {
+ #prisma: PrismaClient;
+
+ cons... | hmm why not use the one in core? |
supaglue | github_2023 | typescript | 515 | supaglue-labs | albertyfwu | @@ -46,8 +49,14 @@ export const getServerSideProps: GetServerSideProps = async ({ req, res }) => {
};
export default function Home() {
- const { customers = [], isLoading } = useCustomers();
+ const { customers = [], isLoading, mutate } = useCustomers();
const [mobileOpen, setMobileOpen] = useState(false);
+ ... | shouldn't we create customer before revalidate? |
supaglue | github_2023 | typescript | 515 | supaglue-labs | lucasmarshall | @@ -3,11 +3,12 @@ import { CustomerExpandedSafe } from '@supaglue/core/types/customer';
import { useSWRWithApplication } from './useSWRWithApplication';
export function useCustomers() {
- const { data, isLoading, error } = useSWRWithApplication<CustomerExpandedSafe[]>('/api/internal/customers');
+ const { data, i... | ```suggestion
const { data, ...rest } = useSWRWithApplication<CustomerExpandedSafe[]>('/api/internal/customers');
``` |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.