@socketsecurity/sdk 3.1.3 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +51 -3
- package/README.md +5 -129
- package/dist/constants.d.ts +4 -1
- package/dist/file-upload.d.ts +7 -8
- package/dist/http-client.d.ts +31 -27
- package/dist/index.d.ts +4 -4
- package/dist/index.js +2964 -22582
- package/dist/promise-queue.d.ts +9 -9
- package/dist/socket-sdk-class.d.ts +556 -172
- package/dist/testing.d.ts +9 -9
- package/dist/testing.js +0 -1
- package/dist/types-strict.d.ts +180 -144
- package/dist/types.d.ts +71 -12
- package/dist/utils.d.ts +61 -0
- package/package.json +14 -5
- package/types/api.d.ts +2690 -234
package/dist/testing.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ export declare function mockSuccessResponse<T>(data: T, status?: number): Socket
|
|
|
33
33
|
* expect(response.success).toBe(false)
|
|
34
34
|
* ```
|
|
35
35
|
*/
|
|
36
|
-
export declare function mockErrorResponse<T>(error: string, status?: number, cause?: string): SocketSdkGenericResult<T>;
|
|
36
|
+
export declare function mockErrorResponse<T>(error: string, status?: number, cause?: string | undefined): SocketSdkGenericResult<T>;
|
|
37
37
|
/**
|
|
38
38
|
* Create a mock Socket API error response body.
|
|
39
39
|
*
|
|
@@ -48,10 +48,10 @@ export declare function mockErrorResponse<T>(error: string, status?: number, cau
|
|
|
48
48
|
* .reply(404, mockApiErrorBody('Repository not found'))
|
|
49
49
|
* ```
|
|
50
50
|
*/
|
|
51
|
-
export declare function mockApiErrorBody(message: string, details?: Record<string, unknown>): {
|
|
51
|
+
export declare function mockApiErrorBody(message: string, details?: Record<string, unknown> | undefined): {
|
|
52
52
|
error: {
|
|
53
53
|
message: string;
|
|
54
|
-
details?: Record<string, unknown
|
|
54
|
+
details?: Record<string, unknown> | undefined;
|
|
55
55
|
};
|
|
56
56
|
};
|
|
57
57
|
/**
|
|
@@ -393,8 +393,8 @@ export declare const fixtures: {
|
|
|
393
393
|
* )
|
|
394
394
|
* ```
|
|
395
395
|
*/
|
|
396
|
-
export declare function mockSdkResult<T extends SocketSdkOperations>(success: true, data: SocketSdkSuccessResult<T>['data'], status?: number): SocketSdkSuccessResult<T>;
|
|
397
|
-
export declare function mockSdkResult<T extends SocketSdkOperations>(success: false, error: string, status?: number, cause?: string): SocketSdkErrorResult<T>;
|
|
396
|
+
export declare function mockSdkResult<T extends SocketSdkOperations>(success: true, data: SocketSdkSuccessResult<T>['data'], status?: number | undefined): SocketSdkSuccessResult<T>;
|
|
397
|
+
export declare function mockSdkResult<T extends SocketSdkOperations>(success: false, error: string, status?: number | undefined, cause?: string | undefined): SocketSdkErrorResult<T>;
|
|
398
398
|
/**
|
|
399
399
|
* Create a mock SDK error with proper structure.
|
|
400
400
|
*
|
|
@@ -410,12 +410,12 @@ export declare function mockSdkResult<T extends SocketSdkOperations>(success: fa
|
|
|
410
410
|
* ```
|
|
411
411
|
*/
|
|
412
412
|
export declare function mockSdkError(type: 'NOT_FOUND' | 'UNAUTHORIZED' | 'FORBIDDEN' | 'SERVER_ERROR' | 'TIMEOUT', options?: {
|
|
413
|
-
cause?: string;
|
|
414
|
-
message?: string;
|
|
415
|
-
status?: number;
|
|
413
|
+
cause?: string | undefined;
|
|
414
|
+
message?: string | undefined;
|
|
415
|
+
status?: number | undefined;
|
|
416
416
|
}): Error & {
|
|
417
417
|
status: number;
|
|
418
|
-
cause?: string;
|
|
418
|
+
cause?: string | undefined;
|
|
419
419
|
};
|
|
420
420
|
/**
|
|
421
421
|
* Type guard to check if SDK result is successful.
|
package/dist/testing.js
CHANGED
package/dist/types-strict.d.ts
CHANGED
|
@@ -1,111 +1,183 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @fileoverview Strict type definitions for Socket SDK v3.
|
|
3
|
+
* AUTO-GENERATED from OpenAPI definitions using AST parsing - DO NOT EDIT MANUALLY.
|
|
3
4
|
* These types provide better TypeScript DX by marking guaranteed fields as required
|
|
4
|
-
* and only keeping truly optional fields as optional.
|
|
5
|
+
* and only keeping truly optional fields as optional.
|
|
6
|
+
*
|
|
7
|
+
* Generated by: scripts/generate-strict-types.mjs
|
|
5
8
|
*/
|
|
6
9
|
/**
|
|
7
|
-
*
|
|
8
|
-
|
|
10
|
+
* Options for create full scan.
|
|
11
|
+
*/
|
|
12
|
+
export type CreateFullScanOptions = {
|
|
13
|
+
branch?: string | undefined;
|
|
14
|
+
commit_hash?: string | undefined;
|
|
15
|
+
commit_message?: string | undefined;
|
|
16
|
+
committers?: string | undefined;
|
|
17
|
+
integration_org_slug?: string | undefined;
|
|
18
|
+
integration_type?: 'api' | 'github' | 'gitlab' | 'bitbucket' | 'azure' | 'web' | undefined;
|
|
19
|
+
make_default_branch?: boolean | undefined;
|
|
20
|
+
pathsRelativeTo?: string | undefined;
|
|
21
|
+
pull_request?: number | undefined;
|
|
22
|
+
repo: string;
|
|
23
|
+
scan_type?: string | undefined;
|
|
24
|
+
set_as_pending_head?: boolean | undefined;
|
|
25
|
+
tmp?: boolean | undefined;
|
|
26
|
+
workspace?: string | undefined;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Strict type for full scan item.
|
|
9
30
|
*/
|
|
10
31
|
export type FullScanItem = {
|
|
11
|
-
|
|
32
|
+
api_url: string | null;
|
|
33
|
+
branch?: string | null | undefined;
|
|
34
|
+
commit_hash?: string | null | undefined;
|
|
35
|
+
commit_message?: string | null | undefined;
|
|
36
|
+
committers?: string[] | undefined;
|
|
12
37
|
created_at: string;
|
|
13
|
-
|
|
38
|
+
html_report_url: string;
|
|
39
|
+
html_url?: string | null | undefined;
|
|
40
|
+
id: string;
|
|
41
|
+
integration_branch_url?: string | null | undefined;
|
|
42
|
+
integration_commit_url?: string | null | undefined;
|
|
43
|
+
integration_pull_request_url?: string | null | undefined;
|
|
44
|
+
integration_repo_url: string;
|
|
45
|
+
integration_type: string | null;
|
|
14
46
|
organization_id: string;
|
|
15
47
|
organization_slug: string;
|
|
48
|
+
pull_request?: number | null | undefined;
|
|
49
|
+
repo: string;
|
|
16
50
|
repository_id: string;
|
|
17
51
|
repository_slug: string;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
integration_type: string;
|
|
22
|
-
integration_repo_url: string;
|
|
23
|
-
branch: string | null;
|
|
24
|
-
commit_message: string | null;
|
|
25
|
-
commit_hash: string | null;
|
|
26
|
-
pull_request: number | null;
|
|
27
|
-
committers: string[];
|
|
28
|
-
html_url: string | null;
|
|
29
|
-
integration_branch_url: string | null;
|
|
30
|
-
integration_commit_url: string | null;
|
|
31
|
-
integration_pull_request_url: string | null;
|
|
32
|
-
scan_state: 'pending' | 'precrawl' | 'resolve' | 'scan' | null;
|
|
33
|
-
unmatchedFiles?: string[];
|
|
52
|
+
scan_state?: 'pending' | 'precrawl' | 'resolve' | 'scan' | null | undefined;
|
|
53
|
+
updated_at: string;
|
|
54
|
+
workspace?: string | undefined;
|
|
34
55
|
};
|
|
35
56
|
/**
|
|
36
|
-
* Strict type for full scan list
|
|
57
|
+
* Strict type for full scan list data.
|
|
37
58
|
*/
|
|
38
59
|
export type FullScanListData = {
|
|
60
|
+
nextPage?: number | null | undefined;
|
|
61
|
+
nextPageCursor?: string | null | undefined;
|
|
39
62
|
results: FullScanItem[];
|
|
40
|
-
nextPageCursor: string | null;
|
|
41
|
-
nextPage: number | null;
|
|
42
63
|
};
|
|
43
64
|
/**
|
|
44
|
-
*
|
|
65
|
+
* Options for get repository.
|
|
45
66
|
*/
|
|
46
|
-
export type
|
|
47
|
-
|
|
48
|
-
data: FullScanListData;
|
|
49
|
-
error?: undefined;
|
|
50
|
-
status: number;
|
|
51
|
-
success: true;
|
|
67
|
+
export type GetRepositoryOptions = {
|
|
68
|
+
workspace?: string | undefined;
|
|
52
69
|
};
|
|
53
70
|
/**
|
|
54
|
-
*
|
|
71
|
+
* Options for list full scans.
|
|
55
72
|
*/
|
|
56
|
-
export type
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
73
|
+
export type ListFullScansOptions = {
|
|
74
|
+
branch?: string | undefined;
|
|
75
|
+
commit_hash?: string | undefined;
|
|
76
|
+
direction?: 'asc' | 'desc' | undefined;
|
|
77
|
+
from?: string | undefined;
|
|
78
|
+
page?: number | undefined;
|
|
79
|
+
per_page?: number | undefined;
|
|
80
|
+
pull_request?: string | undefined;
|
|
81
|
+
repo?: string | undefined;
|
|
82
|
+
sort?: 'name' | 'created_at' | undefined;
|
|
83
|
+
startAfterCursor?: string | undefined;
|
|
84
|
+
use_cursor?: boolean | undefined;
|
|
85
|
+
workspace?: string | undefined;
|
|
62
86
|
};
|
|
63
87
|
/**
|
|
64
|
-
* Options for
|
|
88
|
+
* Options for list repositories.
|
|
65
89
|
*/
|
|
66
|
-
export type
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
use_cursor?: boolean;
|
|
73
|
-
from?: string;
|
|
74
|
-
repo?: string;
|
|
75
|
-
branch?: string;
|
|
76
|
-
pull_request?: string;
|
|
77
|
-
commit_hash?: string;
|
|
90
|
+
export type ListRepositoriesOptions = {
|
|
91
|
+
direction?: string | undefined;
|
|
92
|
+
include_archived?: boolean | undefined;
|
|
93
|
+
page?: number | undefined;
|
|
94
|
+
per_page?: number | undefined;
|
|
95
|
+
sort?: string | undefined;
|
|
78
96
|
};
|
|
79
97
|
/**
|
|
80
|
-
*
|
|
98
|
+
* Strict type for organization item.
|
|
81
99
|
*/
|
|
82
|
-
export type
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
pull_request?: number;
|
|
89
|
-
committers?: string;
|
|
90
|
-
integration_type?: 'api' | 'github' | 'gitlab' | 'bitbucket' | 'azure';
|
|
91
|
-
integration_org_slug?: string;
|
|
92
|
-
make_default_branch?: boolean;
|
|
93
|
-
set_as_pending_head?: boolean;
|
|
94
|
-
tmp?: boolean;
|
|
95
|
-
scan_type?: string;
|
|
100
|
+
export type OrganizationItem = {
|
|
101
|
+
id: string;
|
|
102
|
+
image?: string | null | undefined;
|
|
103
|
+
name?: string | null | undefined;
|
|
104
|
+
plan: string;
|
|
105
|
+
slug: string;
|
|
96
106
|
};
|
|
97
107
|
/**
|
|
98
|
-
*
|
|
108
|
+
* Strict type for repositories list data.
|
|
99
109
|
*/
|
|
100
|
-
export type
|
|
101
|
-
|
|
110
|
+
export type RepositoriesListData = {
|
|
111
|
+
nextPage?: number | null | undefined;
|
|
112
|
+
results: RepositoryItem[];
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* Strict type for repository item.
|
|
116
|
+
*/
|
|
117
|
+
export type RepositoryItem = {
|
|
118
|
+
archived: boolean;
|
|
119
|
+
created_at: string;
|
|
120
|
+
default_branch: string | null;
|
|
121
|
+
description: string | null;
|
|
122
|
+
head_full_scan_id: string | null;
|
|
123
|
+
homepage: string | null;
|
|
124
|
+
id: string;
|
|
125
|
+
integration_meta: {
|
|
126
|
+
/** @enum {string} */
|
|
127
|
+
type?: 'github';
|
|
128
|
+
value?: {
|
|
129
|
+
/**
|
|
130
|
+
* @description The GitHub installation_id of the active associated Socket GitHub App
|
|
131
|
+
* @default
|
|
132
|
+
*/
|
|
133
|
+
installation_id: string;
|
|
134
|
+
/**
|
|
135
|
+
* @description The GitHub login name that the active Socket GitHub App installation is installed to
|
|
136
|
+
* @default
|
|
137
|
+
*/
|
|
138
|
+
installation_login: string;
|
|
139
|
+
/**
|
|
140
|
+
* @description The name of the associated GitHub repo.
|
|
141
|
+
* @default
|
|
142
|
+
*/
|
|
143
|
+
repo_name: string | null;
|
|
144
|
+
/**
|
|
145
|
+
* @description The id of the associated GitHub repo.
|
|
146
|
+
* @default
|
|
147
|
+
*/
|
|
148
|
+
repo_id: string | null;
|
|
149
|
+
};
|
|
150
|
+
} | null;
|
|
151
|
+
name: string;
|
|
152
|
+
slig?: string | undefined;
|
|
153
|
+
slug: string;
|
|
154
|
+
updated_at: string;
|
|
155
|
+
visibility: 'public' | 'private';
|
|
156
|
+
workspace: string;
|
|
157
|
+
};
|
|
158
|
+
/**
|
|
159
|
+
* Strict type for repository label item.
|
|
160
|
+
*/
|
|
161
|
+
export type RepositoryLabelItem = {
|
|
162
|
+
has_license_policy?: boolean | undefined;
|
|
163
|
+
has_security_policy?: boolean | undefined;
|
|
164
|
+
id: string;
|
|
165
|
+
name: string;
|
|
166
|
+
repository_ids?: string[] | undefined;
|
|
167
|
+
};
|
|
168
|
+
/**
|
|
169
|
+
* Strict type for repository labels list data.
|
|
170
|
+
*/
|
|
171
|
+
export type RepositoryLabelsListData = {
|
|
172
|
+
nextPage?: number | null | undefined;
|
|
173
|
+
results: RepositoryLabelItem[];
|
|
102
174
|
};
|
|
103
175
|
/**
|
|
104
176
|
* Error result type for all SDK operations.
|
|
105
177
|
*/
|
|
106
178
|
export type StrictErrorResult = {
|
|
107
179
|
cause?: string | undefined;
|
|
108
|
-
data?: undefined;
|
|
180
|
+
data?: undefined | undefined;
|
|
109
181
|
error: string;
|
|
110
182
|
status: number;
|
|
111
183
|
success: false;
|
|
@@ -114,88 +186,69 @@ export type StrictErrorResult = {
|
|
|
114
186
|
* Generic strict result type combining success and error.
|
|
115
187
|
*/
|
|
116
188
|
export type StrictResult<T> = {
|
|
117
|
-
cause?: undefined;
|
|
189
|
+
cause?: undefined | undefined;
|
|
118
190
|
data: T;
|
|
119
|
-
error?: undefined;
|
|
191
|
+
error?: undefined | undefined;
|
|
120
192
|
status: number;
|
|
121
193
|
success: true;
|
|
122
194
|
} | StrictErrorResult;
|
|
123
195
|
/**
|
|
124
|
-
* Strict type for
|
|
196
|
+
* Strict type for full scan list result.
|
|
125
197
|
*/
|
|
126
|
-
export type
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
plan: string;
|
|
198
|
+
export type FullScanListResult = {
|
|
199
|
+
cause?: undefined | undefined;
|
|
200
|
+
data: FullScanListData;
|
|
201
|
+
error?: undefined | undefined;
|
|
202
|
+
status: number;
|
|
203
|
+
success: true;
|
|
133
204
|
};
|
|
134
205
|
/**
|
|
135
|
-
* Strict type for
|
|
206
|
+
* Strict type for single full scan result.
|
|
136
207
|
*/
|
|
137
|
-
export type
|
|
138
|
-
cause?: undefined;
|
|
139
|
-
data:
|
|
140
|
-
|
|
141
|
-
};
|
|
142
|
-
error?: undefined;
|
|
208
|
+
export type FullScanResult = {
|
|
209
|
+
cause?: undefined | undefined;
|
|
210
|
+
data: FullScanItem;
|
|
211
|
+
error?: undefined | undefined;
|
|
143
212
|
status: number;
|
|
144
213
|
success: true;
|
|
145
214
|
};
|
|
146
215
|
/**
|
|
147
|
-
*
|
|
216
|
+
* Options for streaming a full scan.
|
|
148
217
|
*/
|
|
149
|
-
export type
|
|
150
|
-
|
|
151
|
-
created_at: string;
|
|
152
|
-
updated_at: string;
|
|
153
|
-
name: string;
|
|
154
|
-
organization_id: string;
|
|
155
|
-
organization_slug: string;
|
|
156
|
-
default_branch: string | null;
|
|
157
|
-
homepage: string | null;
|
|
158
|
-
archived: boolean;
|
|
159
|
-
visibility: 'public' | 'private' | 'internal';
|
|
218
|
+
export type StreamFullScanOptions = {
|
|
219
|
+
output?: boolean | string | undefined;
|
|
160
220
|
};
|
|
161
221
|
/**
|
|
162
|
-
* Strict type for
|
|
222
|
+
* Strict type for organizations list result.
|
|
163
223
|
*/
|
|
164
|
-
export type
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
224
|
+
export type OrganizationsResult = {
|
|
225
|
+
cause?: undefined | undefined;
|
|
226
|
+
data: {
|
|
227
|
+
organizations: OrganizationItem[];
|
|
228
|
+
};
|
|
229
|
+
error?: undefined | undefined;
|
|
230
|
+
status: number;
|
|
231
|
+
success: true;
|
|
168
232
|
};
|
|
169
233
|
/**
|
|
170
234
|
* Strict type for repositories list result.
|
|
171
235
|
*/
|
|
172
236
|
export type RepositoriesListResult = {
|
|
173
|
-
cause?: undefined;
|
|
237
|
+
cause?: undefined | undefined;
|
|
174
238
|
data: RepositoriesListData;
|
|
175
|
-
error?: undefined;
|
|
239
|
+
error?: undefined | undefined;
|
|
176
240
|
status: number;
|
|
177
241
|
success: true;
|
|
178
242
|
};
|
|
179
|
-
/**
|
|
180
|
-
* Options for listing repositories.
|
|
181
|
-
*/
|
|
182
|
-
export type ListRepositoriesOptions = {
|
|
183
|
-
sort?: 'name' | 'created_at';
|
|
184
|
-
direction?: 'asc' | 'desc';
|
|
185
|
-
per_page?: number;
|
|
186
|
-
page?: number;
|
|
187
|
-
startAfterCursor?: string;
|
|
188
|
-
use_cursor?: boolean;
|
|
189
|
-
};
|
|
190
243
|
/**
|
|
191
244
|
* Strict type for delete operation result.
|
|
192
245
|
*/
|
|
193
246
|
export type DeleteResult = {
|
|
194
|
-
cause?: undefined;
|
|
247
|
+
cause?: undefined | undefined;
|
|
195
248
|
data: {
|
|
196
249
|
success: boolean;
|
|
197
250
|
};
|
|
198
|
-
error?: undefined;
|
|
251
|
+
error?: undefined | undefined;
|
|
199
252
|
status: number;
|
|
200
253
|
success: true;
|
|
201
254
|
};
|
|
@@ -203,36 +256,19 @@ export type DeleteResult = {
|
|
|
203
256
|
* Strict type for single repository result.
|
|
204
257
|
*/
|
|
205
258
|
export type RepositoryResult = {
|
|
206
|
-
cause?: undefined;
|
|
259
|
+
cause?: undefined | undefined;
|
|
207
260
|
data: RepositoryItem;
|
|
208
|
-
error?: undefined;
|
|
261
|
+
error?: undefined | undefined;
|
|
209
262
|
status: number;
|
|
210
263
|
success: true;
|
|
211
264
|
};
|
|
212
|
-
/**
|
|
213
|
-
* Strict type for repository label item.
|
|
214
|
-
*/
|
|
215
|
-
export type RepositoryLabelItem = {
|
|
216
|
-
id: string;
|
|
217
|
-
name: string;
|
|
218
|
-
repository_ids?: string[];
|
|
219
|
-
has_security_policy?: boolean;
|
|
220
|
-
has_license_policy?: boolean;
|
|
221
|
-
};
|
|
222
|
-
/**
|
|
223
|
-
* Strict type for repository labels list data.
|
|
224
|
-
*/
|
|
225
|
-
export type RepositoryLabelsListData = {
|
|
226
|
-
results: RepositoryLabelItem[];
|
|
227
|
-
nextPage: number | null;
|
|
228
|
-
};
|
|
229
265
|
/**
|
|
230
266
|
* Strict type for repository labels list result.
|
|
231
267
|
*/
|
|
232
268
|
export type RepositoryLabelsListResult = {
|
|
233
|
-
cause?: undefined;
|
|
269
|
+
cause?: undefined | undefined;
|
|
234
270
|
data: RepositoryLabelsListData;
|
|
235
|
-
error?: undefined;
|
|
271
|
+
error?: undefined | undefined;
|
|
236
272
|
status: number;
|
|
237
273
|
success: true;
|
|
238
274
|
};
|
|
@@ -240,9 +276,9 @@ export type RepositoryLabelsListResult = {
|
|
|
240
276
|
* Strict type for single repository label result.
|
|
241
277
|
*/
|
|
242
278
|
export type RepositoryLabelResult = {
|
|
243
|
-
cause?: undefined;
|
|
279
|
+
cause?: undefined | undefined;
|
|
244
280
|
data: RepositoryLabelItem;
|
|
245
|
-
error?: undefined;
|
|
281
|
+
error?: undefined | undefined;
|
|
246
282
|
status: number;
|
|
247
283
|
success: true;
|
|
248
284
|
};
|
|
@@ -250,11 +286,11 @@ export type RepositoryLabelResult = {
|
|
|
250
286
|
* Strict type for delete repository label result.
|
|
251
287
|
*/
|
|
252
288
|
export type DeleteRepositoryLabelResult = {
|
|
253
|
-
cause?: undefined;
|
|
289
|
+
cause?: undefined | undefined;
|
|
254
290
|
data: {
|
|
255
291
|
status: string;
|
|
256
292
|
};
|
|
257
|
-
error?: undefined;
|
|
293
|
+
error?: undefined | undefined;
|
|
258
294
|
status: number;
|
|
259
295
|
success: true;
|
|
260
296
|
};
|
package/dist/types.d.ts
CHANGED
|
@@ -59,6 +59,21 @@ export type ArtifactPatches = {
|
|
|
59
59
|
patches: PatchRecord[];
|
|
60
60
|
};
|
|
61
61
|
export type Agent = HttpsAgent | HttpAgent | ClientHttp2Session;
|
|
62
|
+
export interface RequestInfo {
|
|
63
|
+
method: string;
|
|
64
|
+
url: string;
|
|
65
|
+
headers?: Record<string, string> | undefined;
|
|
66
|
+
timeout?: number | undefined;
|
|
67
|
+
}
|
|
68
|
+
export interface ResponseInfo {
|
|
69
|
+
method: string;
|
|
70
|
+
url: string;
|
|
71
|
+
duration: number;
|
|
72
|
+
status?: number | undefined;
|
|
73
|
+
statusText?: string | undefined;
|
|
74
|
+
headers?: Record<string, string> | undefined;
|
|
75
|
+
error?: Error | undefined;
|
|
76
|
+
}
|
|
62
77
|
export type CompactSocketArtifactAlert = Remap<Omit<SocketArtifactAlert, 'actionSource' | 'category' | 'end' | 'file' | 'start'>>;
|
|
63
78
|
export type CompactSocketArtifact = Remap<Omit<SocketArtifact, 'alerts' | 'alertKeysToReachabilitySummaries' | 'alertKeysToReachabilityTypes' | 'artifact' | 'batchIndex' | 'dead' | 'dependencies' | 'dev' | 'direct' | 'inputPurl' | 'manifestFiles' | 'score' | 'size' | 'topLevelAncestors'> & {
|
|
64
79
|
alerts: CompactSocketArtifactAlert[];
|
|
@@ -91,6 +106,12 @@ export type RequestOptions = ((HttpsRequestOptions & {
|
|
|
91
106
|
})) & {
|
|
92
107
|
timeout?: number | undefined;
|
|
93
108
|
};
|
|
109
|
+
export type RequestOptionsWithHooks = RequestOptions & {
|
|
110
|
+
hooks?: {
|
|
111
|
+
onRequest?: ((info: RequestInfo) => void) | undefined;
|
|
112
|
+
onResponse?: ((info: ResponseInfo) => void) | undefined;
|
|
113
|
+
} | undefined;
|
|
114
|
+
};
|
|
94
115
|
export type SendMethod = 'POST' | 'PUT';
|
|
95
116
|
export type SendOptions = {
|
|
96
117
|
body?: unknown | undefined;
|
|
@@ -107,19 +128,19 @@ export type SocketArtifactAlert = Remap<Omit<components['schemas']['SocketAlert'
|
|
|
107
128
|
}>;
|
|
108
129
|
export type SocketSdkOperations = keyof operations;
|
|
109
130
|
export type SocketSdkSuccessResult<T extends SocketSdkOperations> = {
|
|
110
|
-
cause?: undefined;
|
|
131
|
+
cause?: undefined | undefined;
|
|
111
132
|
data: OpReturnType<operations[T]>;
|
|
112
|
-
error?: undefined;
|
|
133
|
+
error?: undefined | undefined;
|
|
113
134
|
status: number;
|
|
114
135
|
success: true;
|
|
115
136
|
};
|
|
116
137
|
export type SocketSdkErrorResult<T extends SocketSdkOperations> = {
|
|
117
138
|
cause?: string | undefined;
|
|
118
|
-
data?: undefined;
|
|
139
|
+
data?: undefined | undefined;
|
|
119
140
|
error: string;
|
|
120
141
|
status: number;
|
|
121
142
|
success: false;
|
|
122
|
-
_operation?: T;
|
|
143
|
+
_operation?: T | undefined;
|
|
123
144
|
};
|
|
124
145
|
export type SocketSdkResult<T extends SocketSdkOperations> = SocketSdkSuccessResult<T> | SocketSdkErrorResult<T>;
|
|
125
146
|
/**
|
|
@@ -136,14 +157,14 @@ export type SocketSdkData<T extends SocketSdkOperations> = OpReturnType<operatio
|
|
|
136
157
|
*/
|
|
137
158
|
export type SocketSdkArrayElement<T extends SocketSdkOperations, K extends keyof SocketSdkData<T>> = SocketSdkData<T>[K] extends Array<infer U> ? U : never;
|
|
138
159
|
export type SocketSdkGenericResult<T> = {
|
|
139
|
-
cause?: undefined;
|
|
160
|
+
cause?: undefined | undefined;
|
|
140
161
|
data: T;
|
|
141
|
-
error?: undefined;
|
|
162
|
+
error?: undefined | undefined;
|
|
142
163
|
status: number;
|
|
143
164
|
success: true;
|
|
144
165
|
} | {
|
|
145
166
|
cause?: string | undefined;
|
|
146
|
-
data?: undefined;
|
|
167
|
+
data?: undefined | undefined;
|
|
147
168
|
error: string;
|
|
148
169
|
status: number;
|
|
149
170
|
success: false;
|
|
@@ -196,14 +217,36 @@ export interface SocketSdkOptions {
|
|
|
196
217
|
baseUrl?: string | undefined;
|
|
197
218
|
/**
|
|
198
219
|
* Enable TTL caching for API responses (default: false).
|
|
199
|
-
* When enabled, GET requests are cached with
|
|
220
|
+
* When enabled, GET requests are cached with configurable TTLs.
|
|
221
|
+
* Only applies to listOrganizations() and getQuota() methods.
|
|
200
222
|
*/
|
|
201
223
|
cache?: boolean | undefined;
|
|
202
224
|
/**
|
|
203
225
|
* Cache TTL in milliseconds (default: 300_000 = 5 minutes).
|
|
204
226
|
* Only used when cache is enabled.
|
|
227
|
+
* Can be a single number for all endpoints or an object for per-endpoint TTLs.
|
|
228
|
+
*
|
|
229
|
+
* Recommended TTLs by endpoint:
|
|
230
|
+
* - organizations: 30 minutes (rarely changes)
|
|
231
|
+
* - quota: 10 minutes (changes incrementally)
|
|
232
|
+
*
|
|
233
|
+
* @example
|
|
234
|
+
* // Single TTL for all endpoints.
|
|
235
|
+
* cacheTtl: 15 * 60 * 1000 // 15 minutes
|
|
236
|
+
*
|
|
237
|
+
* @example
|
|
238
|
+
* // Per-endpoint TTLs with recommended values.
|
|
239
|
+
* cacheTtl: {
|
|
240
|
+
* default: 5 * 60 * 1000, // 5 minutes default
|
|
241
|
+
* organizations: 30 * 60 * 1000, // 30 minutes (recommended)
|
|
242
|
+
* quota: 10 * 60 * 1000 // 10 minutes (recommended)
|
|
243
|
+
* }
|
|
205
244
|
*/
|
|
206
|
-
cacheTtl?: number |
|
|
245
|
+
cacheTtl?: number | {
|
|
246
|
+
default?: number | undefined;
|
|
247
|
+
organizations?: number | undefined;
|
|
248
|
+
quota?: number | undefined;
|
|
249
|
+
} | undefined;
|
|
207
250
|
/**
|
|
208
251
|
* Callback for file validation events.
|
|
209
252
|
* Called when any file-upload method detects unreadable files:
|
|
@@ -219,6 +262,11 @@ export interface SocketSdkOptions {
|
|
|
219
262
|
* @since v3.0.0
|
|
220
263
|
*/
|
|
221
264
|
onFileValidation?: FileValidationCallback | undefined;
|
|
265
|
+
/** Request/response logging hooks */
|
|
266
|
+
hooks?: {
|
|
267
|
+
onRequest?: ((info: RequestInfo) => void) | undefined;
|
|
268
|
+
onResponse?: ((info: ResponseInfo) => void) | undefined;
|
|
269
|
+
} | undefined;
|
|
222
270
|
/**
|
|
223
271
|
* Number of retry attempts on failure (default: 0, retries disabled).
|
|
224
272
|
* Retries are opt-in following Node.js fs.rm() pattern.
|
|
@@ -240,15 +288,15 @@ export type UploadManifestFilesResponse = {
|
|
|
240
288
|
unmatchedFiles: string[];
|
|
241
289
|
};
|
|
242
290
|
export type UploadManifestFilesReturnType = {
|
|
243
|
-
cause?: undefined;
|
|
291
|
+
cause?: undefined | undefined;
|
|
244
292
|
data: UploadManifestFilesResponse;
|
|
245
|
-
error?: undefined;
|
|
293
|
+
error?: undefined | undefined;
|
|
246
294
|
status: 200;
|
|
247
295
|
success: true;
|
|
248
296
|
};
|
|
249
297
|
export type UploadManifestFilesError = {
|
|
250
298
|
cause?: string | undefined;
|
|
251
|
-
data?: undefined;
|
|
299
|
+
data?: undefined | undefined;
|
|
252
300
|
error: string;
|
|
253
301
|
status: number;
|
|
254
302
|
success: false;
|
|
@@ -274,6 +322,17 @@ export type CreateScanFromFilepathsOptions = {
|
|
|
274
322
|
export type StreamOrgFullScanOptions = {
|
|
275
323
|
output?: boolean | string | undefined;
|
|
276
324
|
};
|
|
325
|
+
export type PostOrgTelemetryPayload = Record<string, unknown>;
|
|
326
|
+
export type PostOrgTelemetryResponse = Record<string, never>;
|
|
327
|
+
/**
|
|
328
|
+
* Configuration for telemetry collection.
|
|
329
|
+
* Controls whether telemetry is enabled and how events are collected.
|
|
330
|
+
*/
|
|
331
|
+
export interface TelemetryConfig {
|
|
332
|
+
telemetry: {
|
|
333
|
+
enabled: boolean;
|
|
334
|
+
};
|
|
335
|
+
}
|
|
277
336
|
export type UploadManifestFilesOptions = {
|
|
278
337
|
pathsRelativeTo?: string | undefined;
|
|
279
338
|
};
|