@socketsecurity/sdk 3.2.0 → 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 +22 -0
- package/README.md +1 -1
- package/dist/constants.d.ts +1 -1
- package/dist/http-client.d.ts +21 -21
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1339 -1098
- package/dist/promise-queue.d.ts +9 -9
- package/dist/socket-sdk-class.d.ts +528 -380
- package/dist/testing.d.ts +9 -9
- package/dist/types-strict.d.ts +180 -144
- package/dist/types.d.ts +14 -14
- package/dist/utils.d.ts +42 -42
- package/package.json +6 -4
- package/types/api.d.ts +1042 -409
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/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
|
@@ -108,8 +108,8 @@ export type RequestOptions = ((HttpsRequestOptions & {
|
|
|
108
108
|
};
|
|
109
109
|
export type RequestOptionsWithHooks = RequestOptions & {
|
|
110
110
|
hooks?: {
|
|
111
|
-
onRequest?: (info: RequestInfo) => void;
|
|
112
|
-
onResponse?: (info: ResponseInfo) => void;
|
|
111
|
+
onRequest?: ((info: RequestInfo) => void) | undefined;
|
|
112
|
+
onResponse?: ((info: ResponseInfo) => void) | undefined;
|
|
113
113
|
} | undefined;
|
|
114
114
|
};
|
|
115
115
|
export type SendMethod = 'POST' | 'PUT';
|
|
@@ -128,19 +128,19 @@ export type SocketArtifactAlert = Remap<Omit<components['schemas']['SocketAlert'
|
|
|
128
128
|
}>;
|
|
129
129
|
export type SocketSdkOperations = keyof operations;
|
|
130
130
|
export type SocketSdkSuccessResult<T extends SocketSdkOperations> = {
|
|
131
|
-
cause?: undefined;
|
|
131
|
+
cause?: undefined | undefined;
|
|
132
132
|
data: OpReturnType<operations[T]>;
|
|
133
|
-
error?: undefined;
|
|
133
|
+
error?: undefined | undefined;
|
|
134
134
|
status: number;
|
|
135
135
|
success: true;
|
|
136
136
|
};
|
|
137
137
|
export type SocketSdkErrorResult<T extends SocketSdkOperations> = {
|
|
138
138
|
cause?: string | undefined;
|
|
139
|
-
data?: undefined;
|
|
139
|
+
data?: undefined | undefined;
|
|
140
140
|
error: string;
|
|
141
141
|
status: number;
|
|
142
142
|
success: false;
|
|
143
|
-
_operation?: T;
|
|
143
|
+
_operation?: T | undefined;
|
|
144
144
|
};
|
|
145
145
|
export type SocketSdkResult<T extends SocketSdkOperations> = SocketSdkSuccessResult<T> | SocketSdkErrorResult<T>;
|
|
146
146
|
/**
|
|
@@ -157,14 +157,14 @@ export type SocketSdkData<T extends SocketSdkOperations> = OpReturnType<operatio
|
|
|
157
157
|
*/
|
|
158
158
|
export type SocketSdkArrayElement<T extends SocketSdkOperations, K extends keyof SocketSdkData<T>> = SocketSdkData<T>[K] extends Array<infer U> ? U : never;
|
|
159
159
|
export type SocketSdkGenericResult<T> = {
|
|
160
|
-
cause?: undefined;
|
|
160
|
+
cause?: undefined | undefined;
|
|
161
161
|
data: T;
|
|
162
|
-
error?: undefined;
|
|
162
|
+
error?: undefined | undefined;
|
|
163
163
|
status: number;
|
|
164
164
|
success: true;
|
|
165
165
|
} | {
|
|
166
166
|
cause?: string | undefined;
|
|
167
|
-
data?: undefined;
|
|
167
|
+
data?: undefined | undefined;
|
|
168
168
|
error: string;
|
|
169
169
|
status: number;
|
|
170
170
|
success: false;
|
|
@@ -264,8 +264,8 @@ export interface SocketSdkOptions {
|
|
|
264
264
|
onFileValidation?: FileValidationCallback | undefined;
|
|
265
265
|
/** Request/response logging hooks */
|
|
266
266
|
hooks?: {
|
|
267
|
-
onRequest?: (info: RequestInfo) => void;
|
|
268
|
-
onResponse?: (info: ResponseInfo) => void;
|
|
267
|
+
onRequest?: ((info: RequestInfo) => void) | undefined;
|
|
268
|
+
onResponse?: ((info: ResponseInfo) => void) | undefined;
|
|
269
269
|
} | undefined;
|
|
270
270
|
/**
|
|
271
271
|
* Number of retry attempts on failure (default: 0, retries disabled).
|
|
@@ -288,15 +288,15 @@ export type UploadManifestFilesResponse = {
|
|
|
288
288
|
unmatchedFiles: string[];
|
|
289
289
|
};
|
|
290
290
|
export type UploadManifestFilesReturnType = {
|
|
291
|
-
cause?: undefined;
|
|
291
|
+
cause?: undefined | undefined;
|
|
292
292
|
data: UploadManifestFilesResponse;
|
|
293
|
-
error?: undefined;
|
|
293
|
+
error?: undefined | undefined;
|
|
294
294
|
status: 200;
|
|
295
295
|
success: true;
|
|
296
296
|
};
|
|
297
297
|
export type UploadManifestFilesError = {
|
|
298
298
|
cause?: string | undefined;
|
|
299
|
-
data?: undefined;
|
|
299
|
+
data?: undefined | undefined;
|
|
300
300
|
error: string;
|
|
301
301
|
status: number;
|
|
302
302
|
success: false;
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,31 +1,5 @@
|
|
|
1
1
|
import type { QueryParams } from './types';
|
|
2
2
|
export { createUserAgentFromPkgJson } from './user-agent';
|
|
3
|
-
/**
|
|
4
|
-
* Normalize base URL by ensuring it ends with a trailing slash.
|
|
5
|
-
* Required for proper URL joining with relative paths.
|
|
6
|
-
* Memoized for performance since base URLs are typically reused.
|
|
7
|
-
*/
|
|
8
|
-
export declare const normalizeBaseUrl: (baseUrl: string) => string;
|
|
9
|
-
/**
|
|
10
|
-
* Create a promise with externally accessible resolve/reject functions.
|
|
11
|
-
* Polyfill for Promise.withResolvers() on older Node.js versions.
|
|
12
|
-
*/
|
|
13
|
-
export declare function promiseWithResolvers<T>(): ReturnType<typeof Promise.withResolvers<T>>;
|
|
14
|
-
/**
|
|
15
|
-
* Convert query parameters to URLSearchParams with API-compatible key normalization.
|
|
16
|
-
* Transforms camelCase keys to snake_case and filters out empty values.
|
|
17
|
-
*/
|
|
18
|
-
export declare function queryToSearchParams(init?: URLSearchParams | string | QueryParams | Iterable<[string, unknown]> | ReadonlyArray<[string, unknown]> | null | undefined): URLSearchParams;
|
|
19
|
-
/**
|
|
20
|
-
* Convert relative file paths to absolute paths.
|
|
21
|
-
* Resolves paths relative to specified base directory or current working directory.
|
|
22
|
-
*/
|
|
23
|
-
export declare function resolveAbsPaths(filepaths: string[], pathsRelativeTo?: string | undefined): string[];
|
|
24
|
-
/**
|
|
25
|
-
* Resolve base path to an absolute directory path.
|
|
26
|
-
* Converts relative paths to absolute using current working directory as reference.
|
|
27
|
-
*/
|
|
28
|
-
export declare function resolveBasePath(pathsRelativeTo?: string): string;
|
|
29
3
|
/**
|
|
30
4
|
* Calculate Jaccard similarity coefficient between two strings based on word sets.
|
|
31
5
|
* Returns a value between 0 (no overlap) and 1 (identical word sets).
|
|
@@ -44,22 +18,6 @@ export declare function resolveBasePath(pathsRelativeTo?: string): string;
|
|
|
44
18
|
* ```
|
|
45
19
|
*/
|
|
46
20
|
export declare function calculateWordSetSimilarity(str1: string, str2: string): number;
|
|
47
|
-
/**
|
|
48
|
-
* Determine if a "reason" string should be omitted due to high similarity with error message.
|
|
49
|
-
* Uses Jaccard similarity to detect redundant phrasing.
|
|
50
|
-
*
|
|
51
|
-
* @param errorMessage - Main error message
|
|
52
|
-
* @param reason - Detailed reason/cause string
|
|
53
|
-
* @param threshold - Similarity threshold (0-1), defaults to 0.6
|
|
54
|
-
* @returns true if reason should be omitted (too similar)
|
|
55
|
-
*
|
|
56
|
-
* @example
|
|
57
|
-
* ```typescript
|
|
58
|
-
* shouldOmitReason('Invalid token', 'The token is invalid') // true (high overlap)
|
|
59
|
-
* shouldOmitReason('Request failed', 'Rate limit exceeded') // false (low overlap)
|
|
60
|
-
* ```
|
|
61
|
-
*/
|
|
62
|
-
export declare function shouldOmitReason(errorMessage: string, reason: string | undefined, threshold?: number): boolean;
|
|
63
21
|
/**
|
|
64
22
|
* Filter error cause based on similarity to error message.
|
|
65
23
|
* Returns undefined if the cause should be omitted due to redundancy.
|
|
@@ -87,3 +45,45 @@ export declare function shouldOmitReason(errorMessage: string, reason: string |
|
|
|
87
45
|
* ```
|
|
88
46
|
*/
|
|
89
47
|
export declare function filterRedundantCause(errorMessage: string, errorCause: string | undefined, threshold?: number): string | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* Normalize base URL by ensuring it ends with a trailing slash.
|
|
50
|
+
* Required for proper URL joining with relative paths.
|
|
51
|
+
* Memoized for performance since base URLs are typically reused.
|
|
52
|
+
*/
|
|
53
|
+
export declare const normalizeBaseUrl: (baseUrl: string) => string;
|
|
54
|
+
/**
|
|
55
|
+
* Create a promise with externally accessible resolve/reject functions.
|
|
56
|
+
* Polyfill for Promise.withResolvers() on older Node.js versions.
|
|
57
|
+
*/
|
|
58
|
+
export declare function promiseWithResolvers<T>(): ReturnType<typeof Promise.withResolvers<T>>;
|
|
59
|
+
/**
|
|
60
|
+
* Convert query parameters to URLSearchParams with API-compatible key normalization.
|
|
61
|
+
* Transforms camelCase keys to snake_case and filters out empty values.
|
|
62
|
+
*/
|
|
63
|
+
export declare function queryToSearchParams(init?: URLSearchParams | string | QueryParams | Iterable<[string, unknown]> | ReadonlyArray<[string, unknown]> | null | undefined): URLSearchParams;
|
|
64
|
+
/**
|
|
65
|
+
* Convert relative file paths to absolute paths.
|
|
66
|
+
* Resolves paths relative to specified base directory or current working directory.
|
|
67
|
+
*/
|
|
68
|
+
export declare function resolveAbsPaths(filepaths: string[], pathsRelativeTo?: string | undefined): string[];
|
|
69
|
+
/**
|
|
70
|
+
* Resolve base path to an absolute directory path.
|
|
71
|
+
* Converts relative paths to absolute using current working directory as reference.
|
|
72
|
+
*/
|
|
73
|
+
export declare function resolveBasePath(pathsRelativeTo?: string): string;
|
|
74
|
+
/**
|
|
75
|
+
* Determine if a "reason" string should be omitted due to high similarity with error message.
|
|
76
|
+
* Uses Jaccard similarity to detect redundant phrasing.
|
|
77
|
+
*
|
|
78
|
+
* @param errorMessage - Main error message
|
|
79
|
+
* @param reason - Detailed reason/cause string
|
|
80
|
+
* @param threshold - Similarity threshold (0-1), defaults to 0.6
|
|
81
|
+
* @returns true if reason should be omitted (too similar)
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```typescript
|
|
85
|
+
* shouldOmitReason('Invalid token', 'The token is invalid') // true (high overlap)
|
|
86
|
+
* shouldOmitReason('Request failed', 'Rate limit exceeded') // false (low overlap)
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
export declare function shouldOmitReason(errorMessage: string, reason: string | undefined, threshold?: number): boolean;
|