Skip to content

Commit fcebd9c

Browse files
committed
refactor: update SDK method names to v3 conventions
Update all SDK method calls to use v3 naming conventions that follow REST patterns (list*, get*, create*, update*, delete*). Changes: - getOrgFullScanList → listFullScans - createOrgFullScan → createFullScan - getOrgFullScanBuffered → getFullScan - deleteOrgFullScan → deleteFullScan - streamOrgFullScan → streamFullScan - getOrgRepoList → listRepositories - getOrgRepo → getRepository - createOrgRepo → createRepository - updateOrgRepo → updateRepository - deleteOrgRepo → deleteRepository - getOrganizations → listOrganizations
1 parent b25b68b commit fcebd9c

11 files changed

+50
-46
lines changed

packages/cli/src/commands/scan/fetch-create-org-full-scan.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export async function fetchCreateOrgFullScan(
5555
const sockSdk = sockSdkCResult.data
5656

5757
return await handleApiCall(
58-
sockSdk.createOrgFullScan(orgSlug, packagePaths, {
58+
sockSdk.createFullScan(orgSlug, packagePaths, {
5959
pathsRelativeTo: cwd,
6060
queryParams: {
6161
...(branchName ? { branch: branchName } : {}),

packages/cli/src/commands/scan/fetch-create-org-full-scan.test.mts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe('fetchCreateOrgFullScan', () => {
2222
)
2323

2424
const { mockHandleApi, mockSdk } = await setupSdkMockSuccess(
25-
'createOrgFullScan',
25+
'createFullScan',
2626
{
2727
scanId: 'scan-123',
2828
status: 'pending',
@@ -105,7 +105,7 @@ describe('fetchCreateOrgFullScan', () => {
105105
'./fetch-create-org-full-scan.mts'
106106
)
107107

108-
await setupSdkMockError('createOrgFullScan', 'Failed to create scan', 500)
108+
await setupSdkMockError('createFullScan', 'Failed to create scan', 500)
109109

110110
const config = {
111111
branchName: 'main',
@@ -132,7 +132,7 @@ describe('fetchCreateOrgFullScan', () => {
132132
)
133133

134134
const { mockSdk, mockSetupSdk } = await setupSdkMockSuccess(
135-
'createOrgFullScan',
135+
'createFullScan',
136136
{},
137137
)
138138

@@ -189,7 +189,7 @@ describe('fetchCreateOrgFullScan', () => {
189189
'./fetch-create-org-full-scan.mts'
190190
)
191191

192-
const { mockSdk } = await setupSdkMockSuccess('createOrgFullScan', {})
192+
const { mockSdk } = await setupSdkMockSuccess('createFullScan', {})
193193

194194
const config = {
195195
branchName: '',
@@ -222,7 +222,7 @@ describe('fetchCreateOrgFullScan', () => {
222222
'./fetch-create-org-full-scan.mts'
223223
)
224224

225-
const { mockSdk } = await setupSdkMockSuccess('createOrgFullScan', {})
225+
const { mockSdk } = await setupSdkMockSuccess('createFullScan', {})
226226

227227
const config = {
228228
branchName: 'main',
@@ -256,7 +256,7 @@ describe('fetchCreateOrgFullScan', () => {
256256
'./fetch-create-org-full-scan.mts'
257257
)
258258

259-
const { mockSdk } = await setupSdkMockSuccess('createOrgFullScan', {})
259+
const { mockSdk } = await setupSdkMockSuccess('createFullScan', {})
260260

261261
const config = {
262262
branchName: 'main',
@@ -279,7 +279,7 @@ describe('fetchCreateOrgFullScan', () => {
279279
'./fetch-create-org-full-scan.mts'
280280
)
281281

282-
const { mockSdk } = await setupSdkMockSuccess('createOrgFullScan', {})
282+
const { mockSdk } = await setupSdkMockSuccess('createFullScan', {})
283283

284284
const testCases = [
285285
['org-with-dashes', 'repo-with-dashes'],

packages/cli/src/commands/scan/fetch-delete-org-full-scan.mts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export async function fetchDeleteOrgFullScan(
1313
orgSlug: string,
1414
scanId: string,
1515
options?: FetchDeleteOrgFullScanOptions | undefined,
16-
): Promise<CResult<SocketSdkSuccessResult<'deleteOrgFullScan'>['data']>> {
16+
): Promise<CResult<SocketSdkSuccessResult<'deleteFullScan'>['data']>> {
1717
const { sdkOpts } = {
1818
__proto__: null,
1919
...options,
@@ -25,7 +25,7 @@ export async function fetchDeleteOrgFullScan(
2525
}
2626
const sockSdk = sockSdkCResult.data
2727

28-
return await handleApiCall(sockSdk.deleteOrgFullScan(orgSlug, scanId), {
28+
return await handleApiCall(sockSdk.deleteFullScan(orgSlug, scanId), {
2929
description: 'to delete a scan',
3030
})
3131
}

packages/cli/src/commands/scan/fetch-delete-org-full-scan.test.mts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ vi.mock('../../utils/socket/sdk.mts', () => ({
1919
describe('fetchDeleteOrgFullScan', () => {
2020
it('deletes scan successfully', async () => {
2121
const { mockHandleApi, mockSdk } = await setupSdkMockSuccess(
22-
'deleteOrgFullScan',
22+
'deleteFullScan',
2323
{
2424
deleted: true,
2525
scanId: 'scan-123',
@@ -54,7 +54,7 @@ describe('fetchDeleteOrgFullScan', () => {
5454
})
5555

5656
it('handles API call failure', async () => {
57-
await setupSdkMockError('deleteOrgFullScan', 'Scan not found', 404)
57+
await setupSdkMockError('deleteFullScan', 'Scan not found', 404)
5858

5959
const result = await fetchDeleteOrgFullScan('org', 'nonexistent-scan')
6060

@@ -63,7 +63,7 @@ describe('fetchDeleteOrgFullScan', () => {
6363
})
6464

6565
it('passes custom SDK options', async () => {
66-
const { mockSetupSdk } = await setupSdkMockSuccess('deleteOrgFullScan', {})
66+
const { mockSetupSdk } = await setupSdkMockSuccess('deleteFullScan', {})
6767

6868
const sdkOpts = {
6969
apiToken: 'custom-token',
@@ -76,7 +76,7 @@ describe('fetchDeleteOrgFullScan', () => {
7676
})
7777

7878
it('handles different org slugs and scan IDs', async () => {
79-
const { mockSdk } = await setupSdkMockSuccess('deleteOrgFullScan', {})
79+
const { mockSdk } = await setupSdkMockSuccess('deleteFullScan', {})
8080

8181
const testCases = [
8282
['org-with-dashes', 'scan-123'],
@@ -92,7 +92,7 @@ describe('fetchDeleteOrgFullScan', () => {
9292
})
9393

9494
it('uses null prototype for options', async () => {
95-
const { mockSdk } = await setupSdkMockSuccess('deleteOrgFullScan', {})
95+
const { mockSdk } = await setupSdkMockSuccess('deleteFullScan', {})
9696

9797
// This tests that the function properly uses __proto__: null.
9898
await fetchDeleteOrgFullScan('org', 'scan')

packages/cli/src/commands/scan/fetch-list-scans.mts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export type FetchOrgFullScanListOptions = {
2323
export async function fetchOrgFullScanList(
2424
config: FetchOrgFullScanListConfig,
2525
options?: FetchOrgFullScanListOptions | undefined,
26-
): Promise<CResult<SocketSdkSuccessResult<'getOrgFullScanList'>['data']>> {
26+
): Promise<CResult<SocketSdkSuccessResult<'listFullScans'>['data']>> {
2727
const { sdkOpts } = {
2828
__proto__: null,
2929
...options,
@@ -41,7 +41,7 @@ export async function fetchOrgFullScanList(
4141
} as FetchOrgFullScanListConfig
4242

4343
return await handleApiCall(
44-
sockSdk.getOrgFullScanList(orgSlug, {
44+
sockSdk.listFullScans(orgSlug, {
4545
...(branch ? { branch } : {}),
4646
...(repo ? { repo } : {}),
4747
sort,

packages/cli/src/commands/scan/fetch-list-scans.test.mts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ describe('fetchOrgFullScanList', () => {
1616
const { fetchOrgFullScanList } = await import('./fetch-list-scans.mts')
1717

1818
const { mockHandleApi, mockSdk } = await setupSdkMockSuccess(
19-
'getOrgFullScanList',
19+
'listFullScans',
2020
{
2121
scans: [
2222
{ id: 'scan-123', status: 'completed' },
@@ -87,7 +87,7 @@ describe('fetchOrgFullScanList', () => {
8787
'../../../test/helpers/sdk-test-helpers.mts'
8888
)
8989

90-
await setupSdkMockError('getOrgFullScanList', 'API error', 500)
90+
await setupSdkMockError('listFullScans', 'API error', 500)
9191

9292
const config = {
9393
branch: 'main',
@@ -110,7 +110,7 @@ describe('fetchOrgFullScanList', () => {
110110
const { fetchOrgFullScanList } = await import('./fetch-list-scans.mts')
111111

112112
const { mockSdk, mockSetupSdk } = await setupSdkMockSuccess(
113-
'getOrgFullScanList',
113+
'listFullScans',
114114
{},
115115
)
116116

@@ -149,7 +149,7 @@ describe('fetchOrgFullScanList', () => {
149149
it('handles empty optional config values', async () => {
150150
const { fetchOrgFullScanList } = await import('./fetch-list-scans.mts')
151151

152-
const { mockSdk } = await setupSdkMockSuccess('getOrgFullScanList', {})
152+
const { mockSdk } = await setupSdkMockSuccess('listFullScans', {})
153153

154154
const config = {
155155
branch: '',
@@ -176,7 +176,7 @@ describe('fetchOrgFullScanList', () => {
176176
it('handles different pagination parameters', async () => {
177177
const { fetchOrgFullScanList } = await import('./fetch-list-scans.mts')
178178

179-
const { mockSdk } = await setupSdkMockSuccess('getOrgFullScanList', {})
179+
const { mockSdk } = await setupSdkMockSuccess('listFullScans', {})
180180

181181
const testCases = [
182182
{ page: 1, perPage: 10 },
@@ -215,7 +215,7 @@ describe('fetchOrgFullScanList', () => {
215215
it('handles different sort and direction combinations', async () => {
216216
const { fetchOrgFullScanList } = await import('./fetch-list-scans.mts')
217217

218-
const { mockSdk } = await setupSdkMockSuccess('getOrgFullScanList', {})
218+
const { mockSdk } = await setupSdkMockSuccess('listFullScans', {})
219219

220220
const testCases = [
221221
{ sort: 'created_at', direction: 'asc' },
@@ -254,7 +254,7 @@ describe('fetchOrgFullScanList', () => {
254254
it('uses null prototype for config and options', async () => {
255255
const { fetchOrgFullScanList } = await import('./fetch-list-scans.mts')
256256

257-
const { mockSdk } = await setupSdkMockSuccess('getOrgFullScanList', {})
257+
const { mockSdk } = await setupSdkMockSuccess('listFullScans', {})
258258

259259
const config = {
260260
branch: 'main',

packages/cli/src/commands/scan/handle-create-new-scan.mts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,7 @@ export async function handleCreateNewScan({
123123
cwd,
124124
})
125125

126-
spinner.successAndStop(
127-
`Found ${packagePaths.length} ${pluralize('file', { count: packagePaths.length })} to include in scan.`,
128-
)
126+
spinner.successAndStop('Finished searching for local files.')
129127

130128
const wasValidInput = checkCommandInput(outputKind, {
131129
nook: true,
@@ -139,10 +137,6 @@ export async function handleCreateNewScan({
139137
return
140138
}
141139

142-
logger.success(
143-
`Found ${packagePaths.length} local ${pluralize('file', { count: packagePaths.length })}`,
144-
)
145-
146140
debugDir({ packagePaths })
147141

148142
if (readOnly) {
@@ -196,6 +190,11 @@ export async function handleCreateNewScan({
196190
tier1ReachabilityScanId = reachResult.data?.tier1ReachabilityScanId
197191
}
198192

193+
// Display final file count after all modifications.
194+
logger.success(
195+
`Found ${scanPaths.length} ${pluralize('file', { count: scanPaths.length })} to include in scan`,
196+
)
197+
199198
const fullScanCResult = await fetchCreateOrgFullScan(
200199
scanPaths,
201200
orgSlug,

packages/cli/src/commands/scan/output-delete-scan.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import type { CResult, OutputKind } from '../../types.mts'
77
import type { SocketSdkSuccessResult } from '@socketsecurity/sdk'
88

99
export async function outputDeleteScan(
10-
result: CResult<SocketSdkSuccessResult<'deleteOrgFullScan'>['data']>,
10+
result: CResult<SocketSdkSuccessResult<'deleteFullScan'>['data']>,
1111
outputKind: OutputKind,
1212
): Promise<void> {
1313
if (!result.ok) {

packages/cli/src/commands/scan/output-list-scans.mts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ import type { CResult, OutputKind } from '../../types.mts'
1010
import type { SocketSdkSuccessResult } from '@socketsecurity/sdk'
1111

1212
type ScanListItem =
13-
SocketSdkSuccessResult<'getOrgFullScanList'>['data']['results'][number]
13+
SocketSdkSuccessResult<'listFullScans'>['data']['results'][number]
1414

1515
export async function outputListScans(
16-
result: CResult<SocketSdkSuccessResult<'getOrgFullScanList'>['data']>,
16+
result: CResult<SocketSdkSuccessResult<'listFullScans'>['data']>,
1717
outputKind: OutputKind,
1818
): Promise<void> {
1919
if (!result.ok) {

packages/cli/src/commands/scan/stream-scan.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export async function streamScan(
2929

3030
// Note: This will write to stdout or target file. It is not a noop.
3131
return await handleApiCall(
32-
sockSdk.streamOrgFullScan(orgSlug, scanId, {
32+
sockSdk.streamFullScan(orgSlug, scanId, {
3333
output: file === '-' ? undefined : file,
3434
}),
3535
{ description: 'a scan' },

0 commit comments

Comments
 (0)