Skip to content

Commit

Permalink
Merge pull request #1219 from nickgros/SWC-6662c
Browse files Browse the repository at this point in the history
  • Loading branch information
nickgros authored Sep 20, 2024
2 parents 82e8dbf + 632788d commit 8b8e08f
Show file tree
Hide file tree
Showing 89 changed files with 192 additions and 155 deletions.
1 change: 1 addition & 0 deletions .github/workflows/npmpublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
markdown-it-synapse,
markdown-it-synapse-table,
'@sage-bionetworks/markdown-it-container',
'@sage-bionetworks/synapse-client',
'@sage-bionetworks/synapse-types',
]
runs-on: ubuntu-latest
Expand Down
4 changes: 2 additions & 2 deletions apps/SageAccountWeb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
"@mui/system": "^5.15.13",
"@mui/utils": "^5.15.13",
"@react-hookz/web": "^23.1.0",
"@sage-bionetworks/synapse-client": "workspace:*",
"@sage-bionetworks/synapse-types": "workspace:*",
"@tanstack/react-query": "5.22.2",
"katex": "^0.16.10",
"lodash-es": "^4.17.21",
Expand All @@ -23,12 +25,10 @@
"react-easy-crop": "^5.0.7",
"react-router-dom": "^5.3.4",
"sass": "^1.71.1",
"synapse-client": "workspace:*",
"synapse-react-client": "workspace:*",
"universal-cookie": "^4.0.4"
},
"devDependencies": {
"@sage-bionetworks/synapse-types": "workspace:*",
"@testing-library/jest-dom": "^6.4.6",
"@testing-library/react": "^16.0.0",
"@testing-library/user-event": "^14.5.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
useQuerySearchParam,
} from 'synapse-react-client'
import { TwoFactorAuthResetToken } from '@sage-bionetworks/synapse-types'
import { TwoFactorAuthErrorResponse } from 'synapse-client/generated/models/TwoFactorAuthErrorResponse'
import { TwoFactorAuthErrorResponse } from '@sage-bionetworks/synapse-client/generated/models/TwoFactorAuthErrorResponse'
import { hexDecodeAndDeserialize } from '../../URLUtils'
import { BackButton } from '../BackButton'
import { LeftRightPanel } from '../LeftRightPanel'
Expand Down
2 changes: 1 addition & 1 deletion packages/synapse-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ To generate code, we use the [Synapse REST Services](https://rest-docs.synapse.o

## Generating code

To generate code for the models and services, simply run `pnpm nx run synapse-client:build`. This will trigger the OpenAPI Generator CLI and also run any scripts that may be needed to improve code generation.
To generate code for the models and services, simply run `pnpm nx run @sage-bionetworks/synapse-client:build`. This will trigger the OpenAPI Generator CLI and also run any scripts that may be needed to improve code generation.

## Upgrading the OpenAPI definition

Expand Down
2 changes: 1 addition & 1 deletion packages/synapse-client/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "synapse-client",
"name": "@sage-bionetworks/synapse-client",
"version": "0.0.1",
"description": "",
"type": "module",
Expand Down
2 changes: 1 addition & 1 deletion packages/synapse-react-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"@rjsf/validator-ajv8": "5.17.1",
"@sage-bionetworks/markdown-it-container": "workspace:*",
"@sage-bionetworks/react-base-table": "^1.13.4",
"@sage-bionetworks/synapse-client": "workspace:*",
"@sage-bionetworks/synapse-types": "workspace:*",
"@tanstack/query-core": "5.22.2",
"@tanstack/react-query": "5.22.2",
Expand Down Expand Up @@ -112,7 +113,6 @@
"schema-dts": "^1.1.2",
"shortid": "^2.2.16",
"spark-md5": "^3.0.2",
"synapse-client": "workspace:*",
"tinycolor2": "^1.6.0",
"tslib": "^2.6.2",
"ua-parser-js": "^1.0.37",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
useGetAccessRequirementACL,
useUpdateAccessRequirementACL,
} from '../../synapse-queries'
import { SynapseClientError } from 'synapse-client/util/SynapseClientError'
import { SynapseClientError } from '@sage-bionetworks/synapse-client/util/SynapseClientError'
import useUpdateAcl from '../AclEditor/useUpdateAcl'
import { AclEditor } from '../AclEditor/AclEditor'
import { PermissionLevel } from '../../utils/PermissionLevelToAccessType'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import {
import userEvent from '@testing-library/user-event'
import { MOCK_ACCESS_TOKEN } from '../../../../mocks/MockSynapseContext'
import * as UserSearchBoxV2Module from '../../../UserSearchBox/UserSearchBoxV2'
import { SynapseClientError } from 'synapse-client/util/SynapseClientError'
import { SynapseClientError } from '@sage-bionetworks/synapse-client/util/SynapseClientError'
import MarkdownSynapse from '../../../Markdown/MarkdownSynapse'
import * as AccessRequirementListUtils from '../../AccessRequirementListUtils'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {
useSubmitDataAccessRequest,
useUpdateDataAccessRequest,
} from '../../../../synapse-queries'
import { SynapseClientError } from 'synapse-client/util/SynapseClientError'
import { SynapseClientError } from '@sage-bionetworks/synapse-client/util/SynapseClientError'
import TextField from '../../../TextField/TextField'
import DataAccessRequestAccessorsEditor, {
DataAccessRequestAccessorsEditorProps,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
MOCK_RESEARCH_PROJECT,
} from '../../../../mocks/dataaccess/MockResearchProject'
import { MOCK_ACCESS_TOKEN } from '../../../../mocks/MockSynapseContext'
import { SynapseClientError } from 'synapse-client/util/SynapseClientError'
import { SynapseClientError } from '@sage-bionetworks/synapse-client/util/SynapseClientError'
import * as AccessRequirementListUtils from '../../AccessRequirementListUtils'
import MarkdownSynapse from '../../../Markdown/MarkdownSynapse'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import { Box, Typography } from '@mui/material'
import useLogin from '../../utils/hooks/useLogin'
import { TwoFactorAuthErrorResponse } from 'synapse-client/generated/models/TwoFactorAuthErrorResponse'
import { TwoFactorAuthErrorResponse } from '@sage-bionetworks/synapse-client/generated/models/TwoFactorAuthErrorResponse'
import LoginForm from './LoginForm'
import LoginFlowBackButton from './LoginFlowBackButton'
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { displayToast } from '../ToastMessage/ToastMessage'
import { RegenerateBackupCodesWarning } from './RegenerateBackupCodesWarning'
import { RecoveryCodeGrid } from './RecoveryCodeGrid'
import { TwoFactorAuthRecoveryCodes } from '@sage-bionetworks/synapse-types'
import { SynapseClientError } from 'synapse-client/util/SynapseClientError'
import { SynapseClientError } from '@sage-bionetworks/synapse-client/util/SynapseClientError'
import { useMediaPrintOnly } from '../../utils/hooks/useMediaPrintOnly'

export type TwoFactorBackupCodesProps = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import TwoFactorEnrollmentForm, {
TwoFactorEnrollmentFormProps,
} from './TwoFactorEnrollmentForm'
import { TotpSecret } from '@sage-bionetworks/synapse-types'
import { SynapseClientError } from 'synapse-client/util/SynapseClientError'
import { SynapseClientError } from '@sage-bionetworks/synapse-client/util/SynapseClientError'
import { mockUserProfileData } from '../../mocks/user/mock_user_profile'
import { MOCK_CONTEXT_VALUE } from '../../mocks/MockSynapseContext'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { UseQueryResult } from '@tanstack/react-query'
import { Set } from 'immutable'
import React, { useEffect, useState } from 'react'
import { useGetFullTableQueryResults } from '../../synapse-queries'
import { SynapseClientError } from 'synapse-client/util/SynapseClientError'
import { SynapseClientError } from '@sage-bionetworks/synapse-client/util/SynapseClientError'
import { BUNDLE_MASK_QUERY_RESULTS } from '../../utils/SynapseConstants'
import ConfirmationDialog from '../ConfirmationDialog'
import { ErrorBanner } from '../error/ErrorBanner'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
getUseQuerySuccessMock,
} from '../../testutils/ReactQueryMockUtils'
import { PassingRecord, QuizResponse } from '@sage-bionetworks/synapse-types'
import { SynapseClientError } from 'synapse-client/util/SynapseClientError'
import { SynapseClientError } from '@sage-bionetworks/synapse-client/util/SynapseClientError'
import { BackendDestinationEnum, getEndpoint } from '../../utils/functions'
import { rest, server } from '../../mocks/msw/server'
import { useGetCurrentUserBundle } from '../../synapse-queries'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
mockChallengeTeamMember,
} from '../../mocks/challenge/mockChallenge'
import { MOCK_TEAM_ID } from '../../mocks/team/mockTeam'
import { SynapseClientError } from 'synapse-client/util/SynapseClientError'
import { SynapseClientError } from '@sage-bionetworks/synapse-client/util/SynapseClientError'

const mockOnError = jest.fn()
const mockOnJoinClick = jest.fn()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import FileUpload from '../FileUpload'
import IconSvg from '../IconSvg'
import { UploadCallbackResp } from '@sage-bionetworks/synapse-types'
import { FileEntity } from '@sage-bionetworks/synapse-types'
import { SynapseClientError } from 'synapse-client/util/SynapseClientError'
import { SynapseClientError } from '@sage-bionetworks/synapse-client/util/SynapseClientError'
import { EntityItem } from './ChallengeSubmission'
import ConfirmationDialog from '../ConfirmationDialog'
import { useQueryClient } from '@tanstack/react-query'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
MembershipInvitation,
Team,
} from '@sage-bionetworks/synapse-types'
import { SynapseClientError } from 'synapse-client/util/SynapseClientError'
import { SynapseClientError } from '@sage-bionetworks/synapse-client/util/SynapseClientError'
import useCreateAndRegisterChallengeTeam from './useCreateAndRegisterChallengeTeam'

jest.mock('./useCreateAndRegisterChallengeTeam')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
MembershipInvitation,
Team,
} from '@sage-bionetworks/synapse-types'
import { SynapseClientError } from 'synapse-client/util/SynapseClientError'
import { SynapseClientError } from '@sage-bionetworks/synapse-client/util/SynapseClientError'

function render() {
const renderedHook = renderHook(() => useCreateAndRegisterChallengeTeam(), {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
MembershipInvitation,
Team,
} from '@sage-bionetworks/synapse-types'
import { SynapseClientError } from 'synapse-client/util/SynapseClientError'
import { SynapseClientError } from '@sage-bionetworks/synapse-client/util/SynapseClientError'

/**
* Hook that in one call will
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
TwoFactorAuthOtpType,
TwoFactorAuthResetRequest,
} from '@sage-bionetworks/synapse-types'
import { TwoFactorAuthErrorResponse } from 'synapse-client/generated/models/TwoFactorAuthErrorResponse'
import { TwoFactorAuthErrorResponse } from '@sage-bionetworks/synapse-client/generated/models/TwoFactorAuthErrorResponse'
import { useChangePassword, useResetTwoFactorAuth } from '../../synapse-queries'
import { Alert, Typography } from '@mui/material'
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
Entity,
} from '@sage-bionetworks/synapse-types'
import { MOCK_ACCESS_TOKEN } from '../../mocks/MockSynapseContext'
import { SynapseClientError } from 'synapse-client/util/SynapseClientError'
import { SynapseClientError } from '@sage-bionetworks/synapse-client/util/SynapseClientError'
import { mockProjectViewEntity } from '../../mocks/entity/mockProjectView'

const mockTableEntityInstance = mockTableEntityData.entity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
deleteEvaluation,
getEvaluationPermissions,
} from '../../synapse-client/SynapseClient'
import { SynapseClientError } from 'synapse-client/util/SynapseClientError'
import { SynapseClientError } from '@sage-bionetworks/synapse-client/util/SynapseClientError'
import { Evaluation } from '@sage-bionetworks/synapse-types'
import { Button } from '@mui/material'
import { Card, Col, Dropdown, Row } from 'react-bootstrap'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Alert, Button } from '@mui/material'
import { Col, Dropdown, Form, Row } from 'react-bootstrap'
import React, { useEffect, useState } from 'react'
import SynapseClient from '../../synapse-client'
import { SynapseClientError } from 'synapse-client/util/SynapseClientError'
import { SynapseClientError } from '@sage-bionetworks/synapse-client/util/SynapseClientError'
import { ErrorBanner } from '../error/ErrorBanner'
import { Evaluation } from '@sage-bionetworks/synapse-types'
import { CreatedOnByUserDiv } from './CreatedOnByUserDiv'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
deleteEvaluationRound,
updateEvaluationRound,
} from '../../synapse-client/SynapseClient'
import { SynapseClientError } from 'synapse-client/util/SynapseClientError'
import { SynapseClientError } from '@sage-bionetworks/synapse-client/util/SynapseClientError'
import { EvaluationRoundEditorDropdown } from './EvaluationRoundEditorDropdown'
import { ErrorBanner } from '../error/ErrorBanner'
import { useSynapseContext } from '../../utils/context/SynapseContext'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
EvaluationRoundInput,
} from './input_models/models'
import { getEvaluationRoundsList } from '../../synapse-client/SynapseClient'
import { SynapseClientError } from 'synapse-client/util/SynapseClientError'
import { SynapseClientError } from '@sage-bionetworks/synapse-client/util/SynapseClientError'
import shortid from 'shortid'
import { EvaluationRoundListResponse } from '@sage-bionetworks/synapse-types'
import { ErrorBanner } from '../error/ErrorBanner'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from '@sage-bionetworks/synapse-types'
import { SynapseConstants } from '../../utils'
import { getFiles } from '../../synapse-client'
import { SynapseClientError } from 'synapse-client/util/SynapseClientError'
import { SynapseClientError } from '@sage-bionetworks/synapse-client/util/SynapseClientError'
import { ErrorBanner } from '../error/ErrorBanner'
import useGetQueryResultBundle from '../../synapse-queries/entity/useGetQueryResultBundle'
import useShowDesktop from '../../utils/hooks/useShowDesktop'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { act, render, screen, waitFor } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import React from 'react'
import { createWrapper } from '../../testutils/TestingLibraryUtils'
import { MOCK_ACCESS_TOKEN } from '../../mocks/MockSynapseContext'
import { MOCK_CONTEXT_VALUE } from '../../mocks/MockSynapseContext'
import { rest, server } from '../../mocks/msw/server'
import {
CreateOAuthModal,
Expand All @@ -19,7 +19,6 @@ import {
getEndpoint,
} from '../../utils/functions/getEndpoint'
import { WarningDialog } from '../SynapseForm/WarningDialog'
import SynapseClient from '../../synapse-client'
import { noop } from 'lodash-es'

const mockToastFn = jest
Expand All @@ -44,10 +43,14 @@ const defaultProps: CreateOAuthModalProps = {
setIsShowingConfirmModal: jest.fn(),
}

jest.spyOn(SynapseClient, 'createOAuthClient')
jest.spyOn(SynapseClient, 'updateOAuthClient')
const createOAuthClientSpy = jest.mocked(SynapseClient.createOAuthClient)
const updateOAuthClientSpy = jest.mocked(SynapseClient.updateOAuthClient)
const createOAuthClientSpy = jest.spyOn(
MOCK_CONTEXT_VALUE.synapseClient.openIDConnectServicesClient,
'postAuthV1Oauth2Client',
)
const updateOAuthClientSpy = jest.spyOn(
MOCK_CONTEXT_VALUE.synapseClient.openIDConnectServicesClient,
'putAuthV1Oauth2ClientId',
)

function renderComponent(props: CreateOAuthModalProps = defaultProps) {
render(<CreateOAuthModal {...props} />, {
Expand Down Expand Up @@ -156,8 +159,8 @@ describe('Create OAuth Client', () => {

await user.click(saveButton)

expect(createOAuthClientSpy).toHaveBeenLastCalledWith(
{
expect(createOAuthClientSpy).toHaveBeenLastCalledWith({
oAuthClient: {
client_id: undefined,
client_name: mockClient.client_name,
client_uri: mockClient.client_uri,
Expand All @@ -168,8 +171,7 @@ describe('Create OAuth Client', () => {
tos_uri: '',
userinfo_signed_response_alg: OIDCSigningAlgorithm.RS256,
},
MOCK_ACCESS_TOKEN,
)
})

await waitFor(() =>
expect(mockToastFn).toHaveBeenCalledWith(
Expand Down Expand Up @@ -223,8 +225,9 @@ describe('Create OAuth Client', () => {
})
await user.click(saveButton)

expect(updateOAuthClientSpy).toHaveBeenLastCalledWith(
{
expect(updateOAuthClientSpy).toHaveBeenLastCalledWith({
id: mockClient.client_id,
oAuthClient: {
client_id: mockClient.client_id,
client_name: `${mockClient.client_name}rename`,
client_uri: mockClient.client_uri,
Expand All @@ -235,8 +238,7 @@ describe('Create OAuth Client', () => {
tos_uri: mockClient.tos_uri,
userinfo_signed_response_alg: OIDCSigningAlgorithm.RS256,
},
MOCK_ACCESS_TOKEN,
)
})

await waitFor(() =>
expect(mockToastFn).toHaveBeenCalledWith('Successfully saved', 'success'),
Expand Down Expand Up @@ -269,8 +271,9 @@ describe('Create OAuth Client', () => {

await user.click(saveButton)

expect(updateOAuthClientSpy).toHaveBeenLastCalledWith(
{
expect(updateOAuthClientSpy).toHaveBeenLastCalledWith({
id: mockClient.client_id,
oAuthClient: {
client_id: mockClient.client_id,
client_name: mockClient.client_name,
client_uri: mockClient.client_uri,
Expand All @@ -280,8 +283,7 @@ describe('Create OAuth Client', () => {
tos_uri: mockClient.tos_uri,
userinfo_signed_response_alg: undefined,
},
MOCK_ACCESS_TOKEN,
)
})

await waitFor(() =>
expect(mockToastFn).toHaveBeenCalledWith('Successfully saved', 'success'),
Expand Down
Loading

0 comments on commit 8b8e08f

Please sign in to comment.