From a5f25b0d67d7a97870980bab4940faf5b3fd7cdb Mon Sep 17 00:00:00 2001 From: Alexandre Monjol Date: Tue, 2 Jul 2024 11:51:10 +0200 Subject: [PATCH] feat: use new TBA connection for Netuite --- ditto/base.json | 4 +++ package.json | 2 +- .../integrations/AddNetsuiteDialog.tsx | 27 +++++++++++++++++-- src/generated/graphql.tsx | 24 +++++++++++------ yarn.lock | 8 +++--- 5 files changed, 50 insertions(+), 15 deletions(-) diff --git a/ditto/base.json b/ditto/base.json index e01d5735d..94e2e54bf 100644 --- a/ditto/base.json +++ b/ditto/base.json @@ -371,6 +371,10 @@ "text_661ff6e56ef7e1b7c542b311": "payments", "text_661ff6e56ef7e1b7c542b31e": "sales orders", "text_661ff6e56ef7e1b7c542b326": "Connect to NetSuite", + "text_6683cd0bab4ac0007e913af7": "NetSuite Token Id", + "text_6683cd1bb93b060070e9a596": "Type your NetSuite Token Id", + "text_6683cd29cfb79500e588ee47": "NetSuite Token Secret", + "text_6683cd3f33ac8f005b67345c": "Type your NetSuite Token Secret", "text_661ff6e56ef7e1b7c542b1e6": "NetSuite • Accounting", "text_661ff6e56ef7e1b7c542b200": "Items", "text_661ff6e56ef7e1b7c542b20a": "Map items", diff --git a/package.json b/package.json index e742147e3..a5c3479df 100644 --- a/package.json +++ b/package.json @@ -100,7 +100,7 @@ "@mui/styled-engine": "5.14.18", "@mui/styled-engine-sc": "5.14.12", "@mui/x-date-pickers": "6.20.0", - "@nangohq/frontend": "^0.39.18", + "@nangohq/frontend": "0.40.8", "@sentry/react": "7.108.0", "@sentry/tracing": "7.108.0", "apollo-link-timeout": "4.0.0", diff --git a/src/components/settings/integrations/AddNetsuiteDialog.tsx b/src/components/settings/integrations/AddNetsuiteDialog.tsx index a619ba08b..06ee0fe8a 100644 --- a/src/components/settings/integrations/AddNetsuiteDialog.tsx +++ b/src/components/settings/integrations/AddNetsuiteDialog.tsx @@ -38,6 +38,8 @@ gql` syncInvoices syncPayments syncSalesOrders + tokenId + tokenSecret } mutation createNetsuiteIntegration($input: CreateNetsuiteIntegrationInput!) { @@ -113,6 +115,8 @@ export const AddNetsuiteDialog = forwardRef((_, ref) => { accountId: netsuiteProvider?.accountId || '', clientId: netsuiteProvider?.clientId || '', clientSecret: netsuiteProvider?.clientSecret || '', + tokenId: netsuiteProvider?.tokenId || '', + tokenSecret: netsuiteProvider?.tokenSecret || '', scriptEndpointUrl: netsuiteProvider?.scriptEndpointUrl || '', syncCreditNotes: !!netsuiteProvider?.syncCreditNotes, syncInvoices: !!netsuiteProvider?.syncInvoices, @@ -125,6 +129,8 @@ export const AddNetsuiteDialog = forwardRef((_, ref) => { accountId: string().required(''), clientId: string().required(''), clientSecret: string().required(''), + tokenId: string().required(''), + tokenSecret: string().required(''), scriptEndpointUrl: string().url('').required(''), syncCreditNotes: boolean(), syncInvoices: boolean(), @@ -163,13 +169,16 @@ export const AddNetsuiteDialog = forwardRef((_, ref) => { return handleError(res.errors) } } else { - const connectionId = `netsuite-${componentId.replaceAll(':', '')}-${Date.now()}` + const connectionId = `netsuite-tba-${componentId.replaceAll(':', '')}-${Date.now()}` + const nango = new Nango({ publicKey: nangoPublicKey }) try { - const nangoAuthResult = await nango.auth('netsuite', connectionId, { + const nangoAuthResult = await nango.auth('netsuite-tba', connectionId, { params: { accountId: values.accountId }, credentials: { + token_id: values.tokenId, + token_secret: values.tokenSecret, oauth_client_id_override: values.clientId, oauth_client_secret_override: values.clientSecret, }, @@ -305,6 +314,20 @@ export const AddNetsuiteDialog = forwardRef((_, ref) => { placeholder={translate('text_661ff6e56ef7e1b7c542b251')} formikProps={formikProps} /> + + diff --git a/src/generated/graphql.tsx b/src/generated/graphql.tsx index dcbc8d1b7..826dd2f6e 100644 --- a/src/generated/graphql.tsx +++ b/src/generated/graphql.tsx @@ -1160,6 +1160,8 @@ export type CreateNetsuiteIntegrationInput = { syncInvoices?: InputMaybe; syncPayments?: InputMaybe; syncSalesOrders?: InputMaybe; + tokenId: Scalars['String']['input']; + tokenSecret: Scalars['String']['input']; }; /** Autogenerated input type of CreateOktaIntegration */ @@ -3353,6 +3355,8 @@ export type NetsuiteIntegration = { syncInvoices?: Maybe; syncPayments?: Maybe; syncSalesOrders?: Maybe; + tokenId?: Maybe; + tokenSecret?: Maybe; }; /** Accept Invite with Okta Oauth input arguments */ @@ -4833,6 +4837,8 @@ export type UpdateNetsuiteIntegrationInput = { syncInvoices?: InputMaybe; syncPayments?: InputMaybe; syncSalesOrders?: InputMaybe; + tokenId?: InputMaybe; + tokenSecret?: InputMaybe; }; /** Autogenerated input type of UpdateOktaIntegration */ @@ -6030,21 +6036,21 @@ export type UpdateOrgaForLagoTaxManagementMutationVariables = Exact<{ export type UpdateOrgaForLagoTaxManagementMutation = { __typename?: 'Mutation', updateOrganization?: { __typename?: 'CurrentOrganization', id: string } | null }; -export type NetsuiteForCreateDialogDialogFragment = { __typename?: 'NetsuiteIntegration', id: string, accountId?: string | null, clientId?: string | null, clientSecret?: string | null, code: string, name: string, scriptEndpointUrl: string, syncCreditNotes?: boolean | null, syncInvoices?: boolean | null, syncPayments?: boolean | null, syncSalesOrders?: boolean | null }; +export type NetsuiteForCreateDialogDialogFragment = { __typename?: 'NetsuiteIntegration', id: string, accountId?: string | null, clientId?: string | null, clientSecret?: string | null, code: string, name: string, scriptEndpointUrl: string, syncCreditNotes?: boolean | null, syncInvoices?: boolean | null, syncPayments?: boolean | null, syncSalesOrders?: boolean | null, tokenId?: string | null, tokenSecret?: string | null }; export type CreateNetsuiteIntegrationMutationVariables = Exact<{ input: CreateNetsuiteIntegrationInput; }>; -export type CreateNetsuiteIntegrationMutation = { __typename?: 'Mutation', createNetsuiteIntegration?: { __typename?: 'NetsuiteIntegration', id: string, accountId?: string | null, clientId?: string | null, clientSecret?: string | null, code: string, name: string, scriptEndpointUrl: string, syncCreditNotes?: boolean | null, syncInvoices?: boolean | null, syncPayments?: boolean | null, syncSalesOrders?: boolean | null } | null }; +export type CreateNetsuiteIntegrationMutation = { __typename?: 'Mutation', createNetsuiteIntegration?: { __typename?: 'NetsuiteIntegration', id: string, accountId?: string | null, clientId?: string | null, clientSecret?: string | null, code: string, name: string, scriptEndpointUrl: string, syncCreditNotes?: boolean | null, syncInvoices?: boolean | null, syncPayments?: boolean | null, syncSalesOrders?: boolean | null, tokenId?: string | null, tokenSecret?: string | null } | null }; export type UpdateNetsuiteIntegrationMutationVariables = Exact<{ input: UpdateNetsuiteIntegrationInput; }>; -export type UpdateNetsuiteIntegrationMutation = { __typename?: 'Mutation', updateNetsuiteIntegration?: { __typename?: 'NetsuiteIntegration', id: string, accountId?: string | null, clientId?: string | null, clientSecret?: string | null, code: string, name: string, scriptEndpointUrl: string, syncCreditNotes?: boolean | null, syncInvoices?: boolean | null, syncPayments?: boolean | null, syncSalesOrders?: boolean | null } | null }; +export type UpdateNetsuiteIntegrationMutation = { __typename?: 'Mutation', updateNetsuiteIntegration?: { __typename?: 'NetsuiteIntegration', id: string, accountId?: string | null, clientId?: string | null, clientSecret?: string | null, code: string, name: string, scriptEndpointUrl: string, syncCreditNotes?: boolean | null, syncInvoices?: boolean | null, syncPayments?: boolean | null, syncSalesOrders?: boolean | null, tokenId?: string | null, tokenSecret?: string | null } | null }; export type AddStripeProviderDialogFragment = { __typename?: 'StripeProvider', id: string, name: string, code: string, secretKey?: string | null }; @@ -6335,7 +6341,7 @@ export type GetNetsuiteIntegrationsSettingsQueryVariables = Exact<{ }>; -export type GetNetsuiteIntegrationsSettingsQuery = { __typename?: 'Query', integration?: { __typename?: 'AnrokIntegration' } | { __typename?: 'NetsuiteIntegration', id: string, accountId?: string | null, clientId?: string | null, clientSecret?: string | null, code: string, hasMappingsConfigured?: boolean | null, name: string, scriptEndpointUrl: string, syncCreditNotes?: boolean | null, syncInvoices?: boolean | null, syncPayments?: boolean | null, syncSalesOrders?: boolean | null } | { __typename?: 'OktaIntegration' } | { __typename?: 'XeroIntegration' } | null, integrations?: { __typename?: 'IntegrationCollection', collection: Array<{ __typename?: 'AnrokIntegration' } | { __typename?: 'NetsuiteIntegration', id: string } | { __typename?: 'OktaIntegration' } | { __typename?: 'XeroIntegration' }> } | null }; +export type GetNetsuiteIntegrationsSettingsQuery = { __typename?: 'Query', integration?: { __typename?: 'AnrokIntegration' } | { __typename?: 'NetsuiteIntegration', id: string, accountId?: string | null, clientId?: string | null, clientSecret?: string | null, code: string, hasMappingsConfigured?: boolean | null, name: string, scriptEndpointUrl: string, syncCreditNotes?: boolean | null, syncInvoices?: boolean | null, syncPayments?: boolean | null, syncSalesOrders?: boolean | null, tokenId?: string | null, tokenSecret?: string | null } | { __typename?: 'OktaIntegration' } | { __typename?: 'XeroIntegration' } | null, integrations?: { __typename?: 'IntegrationCollection', collection: Array<{ __typename?: 'AnrokIntegration' } | { __typename?: 'NetsuiteIntegration', id: string } | { __typename?: 'OktaIntegration' } | { __typename?: 'XeroIntegration' }> } | null }; export type XeroIntegrationItemsFragment = { __typename?: 'XeroIntegration', id: string }; @@ -7349,7 +7355,7 @@ export type GetMembersQueryVariables = Exact<{ export type GetMembersQuery = { __typename?: 'Query', memberships: { __typename?: 'MembershipCollection', metadata: { __typename?: 'Metadata', currentPage: number, totalPages: number, totalCount: number, adminCount: number }, collection: Array<{ __typename?: 'Membership', id: string, role: MembershipRole, user: { __typename?: 'User', id: string, email?: string | null }, permissions: { __typename?: 'Permissions', addonsCreate: boolean, addonsDelete: boolean, addonsUpdate: boolean, addonsView: boolean, analyticsView: boolean, billableMetricsCreate: boolean, billableMetricsDelete: boolean, billableMetricsUpdate: boolean, billableMetricsView: boolean, couponsAttach: boolean, couponsCreate: boolean, couponsDelete: boolean, couponsDetach: boolean, couponsUpdate: boolean, couponsView: boolean, creditNotesCreate: boolean, creditNotesView: boolean, creditNotesVoid: boolean, customerSettingsUpdateGracePeriod: boolean, customerSettingsUpdateLang: boolean, customerSettingsUpdatePaymentTerms: boolean, customerSettingsUpdateTaxRates: boolean, customerSettingsView: boolean, customersCreate: boolean, customersDelete: boolean, customersUpdate: boolean, customersView: boolean, developersKeysManage: boolean, developersManage: boolean, draftInvoicesUpdate: boolean, invoicesCreate: boolean, invoicesSend: boolean, invoicesUpdate: boolean, invoicesView: boolean, invoicesVoid: boolean, organizationEmailsUpdate: boolean, organizationEmailsView: boolean, organizationIntegrationsCreate: boolean, organizationIntegrationsDelete: boolean, organizationIntegrationsUpdate: boolean, organizationIntegrationsView: boolean, organizationInvoicesUpdate: boolean, organizationInvoicesView: boolean, organizationMembersCreate: boolean, organizationMembersDelete: boolean, organizationMembersUpdate: boolean, organizationMembersView: boolean, organizationTaxesUpdate: boolean, organizationTaxesView: boolean, organizationUpdate: boolean, organizationView: boolean, plansCreate: boolean, plansDelete: boolean, plansUpdate: boolean, plansView: boolean, subscriptionsCreate: boolean, subscriptionsUpdate: boolean, subscriptionsView: boolean, walletsCreate: boolean, walletsTerminate: boolean, walletsTopUp: boolean, walletsUpdate: boolean } }> } }; -export type NetsuiteIntegrationDetailsFragment = { __typename?: 'NetsuiteIntegration', id: string, name: string, accountId?: string | null, clientId?: string | null, clientSecret?: string | null, code: string, scriptEndpointUrl: string, syncCreditNotes?: boolean | null, syncInvoices?: boolean | null, syncPayments?: boolean | null, syncSalesOrders?: boolean | null }; +export type NetsuiteIntegrationDetailsFragment = { __typename?: 'NetsuiteIntegration', id: string, name: string, accountId?: string | null, clientId?: string | null, clientSecret?: string | null, code: string, scriptEndpointUrl: string, syncCreditNotes?: boolean | null, syncInvoices?: boolean | null, syncPayments?: boolean | null, syncSalesOrders?: boolean | null, tokenId?: string | null, tokenSecret?: string | null }; export type GetNetsuiteIntegrationsDetailsQueryVariables = Exact<{ id: Scalars['ID']['input']; @@ -7358,9 +7364,9 @@ export type GetNetsuiteIntegrationsDetailsQueryVariables = Exact<{ }>; -export type GetNetsuiteIntegrationsDetailsQuery = { __typename?: 'Query', integration?: { __typename?: 'AnrokIntegration' } | { __typename?: 'NetsuiteIntegration', id: string, name: string, accountId?: string | null, clientId?: string | null, clientSecret?: string | null, code: string, scriptEndpointUrl: string, syncCreditNotes?: boolean | null, syncInvoices?: boolean | null, syncPayments?: boolean | null, syncSalesOrders?: boolean | null } | { __typename?: 'OktaIntegration' } | { __typename?: 'XeroIntegration' } | null, integrations?: { __typename?: 'IntegrationCollection', collection: Array<{ __typename?: 'AnrokIntegration' } | { __typename?: 'NetsuiteIntegration', id: string } | { __typename?: 'OktaIntegration' } | { __typename?: 'XeroIntegration' }> } | null }; +export type GetNetsuiteIntegrationsDetailsQuery = { __typename?: 'Query', integration?: { __typename?: 'AnrokIntegration' } | { __typename?: 'NetsuiteIntegration', id: string, name: string, accountId?: string | null, clientId?: string | null, clientSecret?: string | null, code: string, scriptEndpointUrl: string, syncCreditNotes?: boolean | null, syncInvoices?: boolean | null, syncPayments?: boolean | null, syncSalesOrders?: boolean | null, tokenId?: string | null, tokenSecret?: string | null } | { __typename?: 'OktaIntegration' } | { __typename?: 'XeroIntegration' } | null, integrations?: { __typename?: 'IntegrationCollection', collection: Array<{ __typename?: 'AnrokIntegration' } | { __typename?: 'NetsuiteIntegration', id: string } | { __typename?: 'OktaIntegration' } | { __typename?: 'XeroIntegration' }> } | null }; -export type NetsuiteIntegrationsFragment = { __typename?: 'NetsuiteIntegration', id: string, name: string, code: string, accountId?: string | null, clientId?: string | null, clientSecret?: string | null, scriptEndpointUrl: string, syncCreditNotes?: boolean | null, syncInvoices?: boolean | null, syncPayments?: boolean | null, syncSalesOrders?: boolean | null }; +export type NetsuiteIntegrationsFragment = { __typename?: 'NetsuiteIntegration', id: string, name: string, code: string, accountId?: string | null, clientId?: string | null, clientSecret?: string | null, scriptEndpointUrl: string, syncCreditNotes?: boolean | null, syncInvoices?: boolean | null, syncPayments?: boolean | null, syncSalesOrders?: boolean | null, tokenId?: string | null, tokenSecret?: string | null }; export type GetNetsuiteIntegrationsListQueryVariables = Exact<{ limit?: InputMaybe; @@ -7368,7 +7374,7 @@ export type GetNetsuiteIntegrationsListQueryVariables = Exact<{ }>; -export type GetNetsuiteIntegrationsListQuery = { __typename?: 'Query', integrations?: { __typename?: 'IntegrationCollection', collection: Array<{ __typename?: 'AnrokIntegration' } | { __typename?: 'NetsuiteIntegration', id: string, name: string, code: string, accountId?: string | null, clientId?: string | null, clientSecret?: string | null, scriptEndpointUrl: string, syncCreditNotes?: boolean | null, syncInvoices?: boolean | null, syncPayments?: boolean | null, syncSalesOrders?: boolean | null } | { __typename?: 'OktaIntegration' } | { __typename?: 'XeroIntegration' }> } | null }; +export type GetNetsuiteIntegrationsListQuery = { __typename?: 'Query', integrations?: { __typename?: 'IntegrationCollection', collection: Array<{ __typename?: 'AnrokIntegration' } | { __typename?: 'NetsuiteIntegration', id: string, name: string, code: string, accountId?: string | null, clientId?: string | null, clientSecret?: string | null, scriptEndpointUrl: string, syncCreditNotes?: boolean | null, syncInvoices?: boolean | null, syncPayments?: boolean | null, syncSalesOrders?: boolean | null, tokenId?: string | null, tokenSecret?: string | null } | { __typename?: 'OktaIntegration' } | { __typename?: 'XeroIntegration' }> } | null }; export type OrganizationInformationsFragment = { __typename?: 'CurrentOrganization', id: string, logoUrl?: string | null, name: string, legalName?: string | null, legalNumber?: string | null, taxIdentificationNumber?: string | null, email?: string | null, addressLine1?: string | null, addressLine2?: string | null, zipcode?: string | null, city?: string | null, state?: string | null, country?: CountryCode | null, timezone?: TimezoneEnum | null }; @@ -9914,6 +9920,8 @@ export const NetsuiteForCreateDialogDialogFragmentDoc = gql` syncInvoices syncPayments syncSalesOrders + tokenId + tokenSecret } `; export const NetsuiteIntegrationItemsFragmentDoc = gql` diff --git a/yarn.lock b/yarn.lock index e3abbf88a..7ed918612 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2267,10 +2267,10 @@ prop-types "^15.8.1" react-transition-group "^4.4.5" -"@nangohq/frontend@^0.39.18": - version "0.39.18" - resolved "https://registry.yarnpkg.com/@nangohq/frontend/-/frontend-0.39.18.tgz#2800c97ab6434a9ca4719b27b918388114192b95" - integrity sha512-pqpLUkzC6zCwc9hNtXTE2IgSP+biuR7U2ySPtK+k67E4kuJQdY4ifqRhw/IlpyHvstZ9MJPVsq8namZNkNE85g== +"@nangohq/frontend@0.40.8": + version "0.40.8" + resolved "https://registry.yarnpkg.com/@nangohq/frontend/-/frontend-0.40.8.tgz#c7e2fc9b902466839ed7765cc8e39756c7287ff2" + integrity sha512-dNRgSDVa/RWNMrAIjC6adZmB4BPc9gntk3VdHDDSeHXV0EPTxKOugIutzSMyYYSIeqT8DWr5c4IAnZaoxd2MnQ== "@nodelib/fs.scandir@2.1.5": version "2.1.5"