Skip to content

Commit b8f8053

Browse files
committed
Update call signatures
1 parent ffd8197 commit b8f8053

File tree

7 files changed

+41
-38
lines changed

7 files changed

+41
-38
lines changed

src/commands/package/fetch-purls-shallow-score.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ export async function fetchPurlsShallowScore(
3232

3333
const result = await handleApiCall(
3434
sockSdk.batchPackageFetch(
35+
{ components: purls.map(purl => ({ purl })) },
3536
{
3637
alerts: 'true',
3738
},
38-
{ components: purls.map(purl => ({ purl })) },
3939
),
4040
{ desc: 'looking up package' },
4141
)

src/commands/repository/fetch-list-all-repos.mts

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,25 @@ import { handleApiCall } from '../../utils/api.mts'
44
import { setupSdk } from '../../utils/sdk.mts'
55

66
import type { CResult } from '../../types.mts'
7+
import type { SetupSdkOptions } from '../../utils/sdk.mts'
78
import type { SocketSdkSuccessResult } from '@socketsecurity/sdk'
89

9-
export async function fetchListAllRepos({
10-
direction,
11-
orgSlug,
12-
sort,
13-
}: {
14-
direction: string
15-
orgSlug: string
16-
sort: string
17-
}): Promise<CResult<SocketSdkSuccessResult<'getOrgRepoList'>['data']>> {
18-
const sockSdkCResult = await setupSdk()
10+
export type FetchListAllReposOptions = {
11+
direction?: string | undefined
12+
sdkOptions?: SetupSdkOptions | undefined
13+
sort?: string | undefined
14+
}
15+
16+
export async function fetchListAllRepos(
17+
orgSlug: string,
18+
options?: FetchListAllReposOptions | undefined,
19+
): Promise<CResult<SocketSdkSuccessResult<'getOrgRepoList'>['data']>> {
20+
const { direction, sdkOptions, sort } = {
21+
__proto__: null,
22+
...options,
23+
} as FetchListAllReposOptions
24+
25+
const sockSdkCResult = await setupSdk(sdkOptions)
1926
if (!sockSdkCResult.ok) {
2027
return sockSdkCResult
2128
}

src/commands/repository/handle-list-repos.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export async function handleListRepos({
2222
sort: string
2323
}): Promise<void> {
2424
if (all) {
25-
const data = await fetchListAllRepos({ direction, orgSlug, sort })
25+
const data = await fetchListAllRepos(orgSlug, { direction, sort })
2626

2727
await outputListRepos(data, outputKind, 0, 0, sort, Infinity, direction)
2828
} else {

src/commands/scan/cmd-scan-view.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ async function run(
150150
}
151151

152152
if (json && stream) {
153-
await streamScan(orgSlug, scanId, file)
153+
await streamScan(orgSlug, scanId, { file })
154154
} else {
155155
await handleScanView(orgSlug, scanId, file, outputKind)
156156
}

src/commands/scan/create-scan-from-github.mts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,8 @@ export async function createScanFromGithub({
4040
.filter(Boolean)
4141
if (all || targetRepos.length === 0) {
4242
// Fetch from Socket API
43-
const result = await fetchListAllRepos({
43+
const result = await fetchListAllRepos(orgSlug, {
4444
direction: 'asc',
45-
orgSlug,
4645
sort: 'name',
4746
})
4847
if (!result.ok) {

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

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -52,22 +52,17 @@ export async function fetchCreateOrgFullScan(
5252
const sockSdk = sockSdkCResult.data
5353

5454
return await handleApiCall(
55-
sockSdk.createOrgFullScan(
56-
orgSlug,
57-
{
58-
...(branchName ? { branch: branchName } : {}),
59-
...(commitHash ? { commit_hash: commitHash } : {}),
60-
...(commitMessage ? { commit_message: commitMessage } : {}),
61-
...(committers ? { committers } : {}),
62-
make_default_branch: String(defaultBranch),
63-
...(pullRequest ? { pull_request: String(pullRequest) } : {}),
64-
repo: repoName,
65-
set_as_pending_head: String(pendingHead),
66-
tmp: String(tmp),
67-
},
68-
packagePaths,
69-
cwd,
70-
),
55+
sockSdk.createOrgFullScan(orgSlug, packagePaths, cwd, {
56+
...(branchName ? { branch: branchName } : {}),
57+
...(commitHash ? { commit_hash: commitHash } : {}),
58+
...(commitMessage ? { commit_message: commitMessage } : {}),
59+
...(committers ? { committers } : {}),
60+
make_default_branch: String(defaultBranch),
61+
...(pullRequest ? { pull_request: String(pullRequest) } : {}),
62+
repo: repoName,
63+
set_as_pending_head: String(pendingHead),
64+
tmp: String(tmp),
65+
}),
7166
{ desc: 'to create a scan' },
7267
)
7368
}

src/utils/alerts-map.mts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,17 @@ export async function getAlertsMapFromPurls(
9898

9999
for await (const batchResult of sockSdk.batchPackageStream(
100100
{
101-
alerts: 'true',
102-
compact: 'true',
103-
...(opts.include.actions
104-
? { actions: opts.include.actions.join(',') }
105-
: {}),
106-
...(opts.include.unfixable ? {} : { fixable: 'true' }),
101+
components: uniqPurls.map(purl => ({ purl })),
107102
},
108103
{
109-
components: uniqPurls.map(purl => ({ purl })),
104+
queryParams: {
105+
alerts: 'true',
106+
compact: 'true',
107+
...(opts.include.actions
108+
? { actions: opts.include.actions.join(',') }
109+
: {}),
110+
...(opts.include.unfixable ? {} : { fixable: 'true' }),
111+
},
110112
},
111113
)) {
112114
if (batchResult.success) {

0 commit comments

Comments
 (0)