Skip to content
Merged
Show file tree
Hide file tree
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
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,28 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).

## [3.3.0](https://github.com/SocketDev/socket-sdk-js/releases/tag/v3.3.0) - 2026-01-25

### Added

- New SDK convenience methods for OpenAPI v3.3.0 endpoints:
- `batchOrgPackageFetch(orgSlug, components, options)` - Organization-scoped PURL batch lookup with security policy label support
- `exportOpenVEX(orgSlug, id, options)` - Export vulnerability exploitability data as OpenVEX v0.2.0 documents (includes patch data and reachability analysis)
- `getOrgAlertFullScans(orgSlug, options)` - List full scans associated with specific alerts
- `rescanFullScan(orgSlug, fullScanId, options)` - Rescan existing full scans with shallow (policy reapplication) or deep (dependency resolution rerun) modes
- Repository endpoints now support optional `workspace` parameter for workspace-scoped operations:
- `createRepository(orgSlug, params, { workspace })`
- `deleteRepository(orgSlug, repoSlug, { workspace })`
- `getRepository(orgSlug, repoSlug, { workspace })`
- `updateRepository(orgSlug, repoSlug, params, { workspace })`

### Changed

- Updated `@socketsecurity/lib` to v5.5.3
- TypeScript: Auto-generated strict types from OpenAPI schema for improved type safety
- TypeScript: All optional properties now explicitly include `| undefined` for better null checking
- Synced OpenAPI type definitions with latest API specification

## [3.2.0](https://github.com/SocketDev/socket-sdk-js/releases/tag/v3.2.0) - 2025-12-08

### Added
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@socketsecurity/sdk",
"version": "3.2.0",
"version": "3.3.0",
"packageManager": "pnpm@10.28.1",
"license": "MIT",
"description": "SDK for the Socket API client",
Expand Down
142 changes: 71 additions & 71 deletions src/http-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,77 @@ export async function getResponseJson(
}
}

/**
* Create DELETE request with automatic retry logic.
* Retries on network errors and 5xx responses.
*
* @param retries - Number of retry attempts (default: 0, retries disabled)
* @param retryDelay - Initial delay in ms (default: 100)
*/
/* c8 ignore start - Retry wrapper depends on withRetry which is already ignored */
export async function createDeleteRequestWithRetry(
baseUrl: string,
urlPath: string,
options?: RequestOptionsWithHooks | undefined,
retries = 0,
retryDelay = 100,
): Promise<IncomingMessage> {
return await withRetry(
() => createDeleteRequest(baseUrl, urlPath, options),
retries,
retryDelay,
)
}
/* c8 ignore stop */

/**
* Create GET request with automatic retry logic.
* Retries on network errors and 5xx responses.
*
* @param retries - Number of retry attempts (default: 0, retries disabled)
* @param retryDelay - Initial delay in ms (default: 100)
*/
/* c8 ignore start - Retry wrapper depends on withRetry which is already ignored */
export async function createGetRequestWithRetry(
baseUrl: string,
urlPath: string,
options?: RequestOptionsWithHooks | undefined,
retries = 0,
retryDelay = 100,
): Promise<IncomingMessage> {
return await withRetry(
() => createGetRequest(baseUrl, urlPath, options),
retries,
retryDelay,
)
}
/* c8 ignore stop */

/**
* Create request with JSON payload and automatic retry logic.
* Retries on network errors and 5xx responses.
*
* @param retries - Number of retry attempts (default: 0, retries disabled)
* @param retryDelay - Initial delay in ms (default: 100)
*/
/* c8 ignore start - Retry wrapper depends on withRetry which is already ignored */
export async function createRequestWithJsonAndRetry(
method: SendMethod,
baseUrl: string,
urlPath: string,
json: unknown,
options?: RequestOptionsWithHooks | undefined,
retries = 0,
retryDelay = 100,
): Promise<IncomingMessage> {
return await withRetry(
() => createRequestWithJson(method, baseUrl, urlPath, json, options),
retries,
retryDelay,
)
}
/* c8 ignore stop */

/**
* Check if HTTP response has a successful status code (2xx range).
* Returns true for status codes between 200-299, false otherwise.
Expand Down Expand Up @@ -647,74 +718,3 @@ export async function withRetry<T>(
throw lastError || new Error('Request failed after retries')
}
/* c8 ignore stop */

/**
* Create GET request with automatic retry logic.
* Retries on network errors and 5xx responses.
*
* @param retries - Number of retry attempts (default: 0, retries disabled)
* @param retryDelay - Initial delay in ms (default: 100)
*/
/* c8 ignore start - Retry wrapper depends on withRetry which is already ignored */
export async function createGetRequestWithRetry(
baseUrl: string,
urlPath: string,
options?: RequestOptionsWithHooks | undefined,
retries = 0,
retryDelay = 100,
): Promise<IncomingMessage> {
return await withRetry(
() => createGetRequest(baseUrl, urlPath, options),
retries,
retryDelay,
)
}
/* c8 ignore stop */

/**
* Create DELETE request with automatic retry logic.
* Retries on network errors and 5xx responses.
*
* @param retries - Number of retry attempts (default: 0, retries disabled)
* @param retryDelay - Initial delay in ms (default: 100)
*/
/* c8 ignore start - Retry wrapper depends on withRetry which is already ignored */
export async function createDeleteRequestWithRetry(
baseUrl: string,
urlPath: string,
options?: RequestOptionsWithHooks | undefined,
retries = 0,
retryDelay = 100,
): Promise<IncomingMessage> {
return await withRetry(
() => createDeleteRequest(baseUrl, urlPath, options),
retries,
retryDelay,
)
}
/* c8 ignore stop */

/**
* Create request with JSON payload and automatic retry logic.
* Retries on network errors and 5xx responses.
*
* @param retries - Number of retry attempts (default: 0, retries disabled)
* @param retryDelay - Initial delay in ms (default: 100)
*/
/* c8 ignore start - Retry wrapper depends on withRetry which is already ignored */
export async function createRequestWithJsonAndRetry(
method: SendMethod,
baseUrl: string,
urlPath: string,
json: unknown,
options?: RequestOptionsWithHooks | undefined,
retries = 0,
retryDelay = 100,
): Promise<IncomingMessage> {
return await withRetry(
() => createRequestWithJson(method, baseUrl, urlPath, json, options),
retries,
retryDelay,
)
}
/* c8 ignore stop */
66 changes: 33 additions & 33 deletions src/promise-queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,6 @@ export class PromiseQueue {
}
}

/**
* Add a task to the queue
* @param fn - Async function to execute
* @returns Promise that resolves with the function's result
*/
async add<T>(fn: () => Promise<T>): Promise<T> {
return await new Promise<T>((resolve, reject) => {
const task: QueuedTask<T> = { fn, resolve, reject }

if (this.maxQueueLength && this.queue.length >= this.maxQueueLength) {
// Drop oldest task to prevent memory buildup
this.queue.shift()
}

this.queue.push(task as QueuedTask<unknown>)
this.runNext()
})
}

private runNext(): void {
if (this.running >= this.maxConcurrency || !this.queue.length) {
return
Expand All @@ -72,6 +53,39 @@ export class PromiseQueue {
})
}

/**
* Get the number of tasks currently running
*/
get activeCount(): number {
return this.running
}

/**
* Add a task to the queue
* @param fn - Async function to execute
* @returns Promise that resolves with the function's result
*/
async add<T>(fn: () => Promise<T>): Promise<T> {
return await new Promise<T>((resolve, reject) => {
const task: QueuedTask<T> = { fn, resolve, reject }

if (this.maxQueueLength && this.queue.length >= this.maxQueueLength) {
// Drop oldest task to prevent memory buildup
this.queue.shift()
}

this.queue.push(task as QueuedTask<unknown>)
this.runNext()
})
}

/**
* Clear all pending tasks from the queue (does not affect running tasks)
*/
clear(): void {
this.queue = []
}

/**
* Wait for all queued and running tasks to complete
*/
Expand All @@ -88,24 +102,10 @@ export class PromiseQueue {
})
}

/**
* Get the number of tasks currently running
*/
get activeCount(): number {
return this.running
}

/**
* Get the number of tasks waiting in the queue
*/
get pendingCount(): number {
return this.queue.length
}

/**
* Clear all pending tasks from the queue (does not affect running tasks)
*/
clear(): void {
this.queue = []
}
}
Loading