Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 28 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,10 @@ class SocketSdk {
}
}

async getOrgFullScan (
async streamOrgFullScan (
orgSlug: string,
fullScanId: string,
file?: string
file?: string | false // When `false`, just .get rather than .stream
): Promise<SocketSdkResultType<'getOrgFullScan'>> {
const orgSlugParam = encodeURIComponent(orgSlug)
const fullScanIdParam = encodeURIComponent(fullScanId)
Expand All @@ -223,7 +223,7 @@ class SocketSdk {
this.#getClient().stream(`orgs/${orgSlugParam}/full-scans/${fullScanIdParam}`),
createWriteStream(file)
)
} else {
} else if (file !== false) {
readStream = this.#getClient().stream(`orgs/${orgSlugParam}/full-scans/${fullScanIdParam}`).pipe(process.stdout)
}
return this.#handleApiSuccess<'getOrgFullScan'>(readStream)
Expand All @@ -232,6 +232,31 @@ class SocketSdk {
}
}

/** @deprecated in favor of streamOrgFullScan */
async getOrgFullScan (
orgSlug: string,
fullScanId: string,
file?: string
) { return this.streamOrgFullScan(orgSlug, fullScanId, file) }

/**
* Name is "buffered" because getOrgFullScan was a previous api that streamed
* the contents and I don't want to risk version collisions.
*/
async getOrgFullScanBuffered (
orgSlug: string,
fullScanId: string
): Promise<SocketSdkResultType<'getOrgFullScan'>> {
const orgSlugParam = encodeURIComponent(orgSlug)
const fullScanIdParam = encodeURIComponent(fullScanId)
try {
const data = this.#getClient().get(`orgs/${orgSlugParam}/full-scans/${fullScanIdParam}`).json()
return this.#handleApiSuccess<'getOrgFullScan'>(data)
} catch (err) {
return this.#handleApiError<'getOrgFullScan'>(err)
}
}

async getOrgFullScanMetadata (
orgSlug: string,
fullScanId: string
Expand Down
Loading