@socketsecurity/sdk 3.2.0 → 3.3.1

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/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.
@@ -1,111 +1,228 @@
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. This improves IntelliSense autocomplete.
5
+ * and only keeping truly optional fields as optional.
6
+ *
7
+ * Generated by: scripts/generate-strict-types.mjs
5
8
  */
6
9
  /**
7
- * Strict type for full scan metadata item.
8
- * Represents a single full scan with guaranteed fields marked as required.
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
- id: string;
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
- updated_at: string;
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
- repo: string;
19
- html_report_url: string;
20
- api_url: string;
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
+ scan_type?: string | null | undefined;
54
+ updated_at: string;
55
+ workspace?: string | undefined;
34
56
  };
35
57
  /**
36
- * Strict type for full scan list response.
58
+ * Strict type for full scan list data.
37
59
  */
38
60
  export type FullScanListData = {
61
+ nextPage?: number | null | undefined;
62
+ nextPageCursor?: string | null | undefined;
39
63
  results: FullScanItem[];
40
- nextPageCursor: string | null;
41
- nextPage: number | null;
42
64
  };
43
65
  /**
44
- * Strict type for full scan list result.
66
+ * Options for get repository.
45
67
  */
46
- export type FullScanListResult = {
47
- cause?: undefined;
48
- data: FullScanListData;
49
- error?: undefined;
50
- status: number;
51
- success: true;
68
+ export type GetRepositoryOptions = {
69
+ workspace?: string | undefined;
52
70
  };
53
71
  /**
54
- * Strict type for single full scan result.
72
+ * Options for list full scans.
55
73
  */
56
- export type FullScanResult = {
57
- cause?: undefined;
58
- data: FullScanItem;
59
- error?: undefined;
60
- status: number;
61
- success: true;
74
+ export type ListFullScansOptions = {
75
+ branch?: string | undefined;
76
+ commit_hash?: string | undefined;
77
+ direction?: 'asc' | 'desc' | undefined;
78
+ from?: string | undefined;
79
+ page?: number | undefined;
80
+ per_page?: number | undefined;
81
+ pull_request?: string | undefined;
82
+ repo?: string | undefined;
83
+ scan_type?: string | undefined;
84
+ sort?: 'name' | 'created_at' | undefined;
85
+ startAfterCursor?: string | undefined;
86
+ use_cursor?: boolean | undefined;
87
+ workspace?: string | undefined;
62
88
  };
63
89
  /**
64
- * Options for listing full scans.
90
+ * Options for list repositories.
65
91
  */
66
- export type ListFullScansOptions = {
67
- sort?: 'name' | 'created_at';
68
- direction?: 'asc' | 'desc';
69
- per_page?: number;
70
- page?: number;
71
- startAfterCursor?: string;
72
- use_cursor?: boolean;
73
- from?: string;
74
- repo?: string;
75
- branch?: string;
76
- pull_request?: string;
77
- commit_hash?: string;
92
+ export type ListRepositoriesOptions = {
93
+ direction?: string | undefined;
94
+ include_archived?: boolean | undefined;
95
+ page?: number | undefined;
96
+ per_page?: number | undefined;
97
+ sort?: string | undefined;
78
98
  };
79
99
  /**
80
- * Options for creating a full scan.
100
+ * Strict type for organization item.
81
101
  */
82
- export type CreateFullScanOptions = {
83
- pathsRelativeTo?: string;
84
- repo: string;
85
- branch?: string;
86
- commit_message?: string;
87
- commit_hash?: string;
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;
102
+ export type OrganizationItem = {
103
+ id: string;
104
+ image?: string | null | undefined;
105
+ name?: string | null | undefined;
106
+ plan: string;
107
+ slug: string;
96
108
  };
97
109
  /**
98
- * Options for streaming a full scan.
110
+ * Strict type for repositories list data.
99
111
  */
100
- export type StreamFullScanOptions = {
101
- output?: boolean | string;
112
+ export type RepositoriesListData = {
113
+ nextPage?: number | null | undefined;
114
+ results: RepositoryListItem[];
115
+ };
116
+ /**
117
+ * Strict type for repository list item.
118
+ */
119
+ export type RepositoryListItem = {
120
+ archived: boolean;
121
+ created_at: string;
122
+ default_branch: string | null;
123
+ description: string | null;
124
+ head_full_scan_id: string | null;
125
+ homepage: string | null;
126
+ id: string;
127
+ integration_meta?: {
128
+ /** @enum {string} */
129
+ type?: 'github';
130
+ value?: {
131
+ /**
132
+ * @description The GitHub installation_id of the active associated Socket GitHub App
133
+ * @default
134
+ */
135
+ installation_id: string;
136
+ /**
137
+ * @description The GitHub login name that the active Socket GitHub App installation is installed to
138
+ * @default
139
+ */
140
+ installation_login: string;
141
+ /**
142
+ * @description The name of the associated GitHub repo.
143
+ * @default
144
+ */
145
+ repo_name: string | null;
146
+ /**
147
+ * @description The id of the associated GitHub repo.
148
+ * @default
149
+ */
150
+ repo_id: string | null;
151
+ };
152
+ } | null | undefined;
153
+ name: string;
154
+ slug: string;
155
+ updated_at: string;
156
+ visibility: 'public' | 'private';
157
+ workspace: string;
158
+ };
159
+ /**
160
+ * Strict type for repository item.
161
+ */
162
+ export type RepositoryItem = {
163
+ archived: boolean;
164
+ created_at: string;
165
+ default_branch: string | null;
166
+ description: string | null;
167
+ head_full_scan_id: string | null;
168
+ homepage: string | null;
169
+ id: string;
170
+ integration_meta: {
171
+ /** @enum {string} */
172
+ type?: 'github';
173
+ value?: {
174
+ /**
175
+ * @description The GitHub installation_id of the active associated Socket GitHub App
176
+ * @default
177
+ */
178
+ installation_id: string;
179
+ /**
180
+ * @description The GitHub login name that the active Socket GitHub App installation is installed to
181
+ * @default
182
+ */
183
+ installation_login: string;
184
+ /**
185
+ * @description The name of the associated GitHub repo.
186
+ * @default
187
+ */
188
+ repo_name: string | null;
189
+ /**
190
+ * @description The id of the associated GitHub repo.
191
+ * @default
192
+ */
193
+ repo_id: string | null;
194
+ };
195
+ } | null;
196
+ name: string;
197
+ slig: string;
198
+ slug: string;
199
+ updated_at: string;
200
+ visibility: 'public' | 'private';
201
+ workspace: string;
202
+ };
203
+ /**
204
+ * Strict type for repository label item.
205
+ */
206
+ export type RepositoryLabelItem = {
207
+ has_license_policy?: boolean | undefined;
208
+ has_security_policy?: boolean | undefined;
209
+ id: string;
210
+ name: string;
211
+ repository_ids?: string[] | undefined;
212
+ };
213
+ /**
214
+ * Strict type for repository labels list data.
215
+ */
216
+ export type RepositoryLabelsListData = {
217
+ nextPage?: number | null | undefined;
218
+ results: RepositoryLabelItem[];
102
219
  };
103
220
  /**
104
221
  * Error result type for all SDK operations.
105
222
  */
106
223
  export type StrictErrorResult = {
107
224
  cause?: string | undefined;
108
- data?: undefined;
225
+ data?: undefined | undefined;
109
226
  error: string;
110
227
  status: number;
111
228
  success: false;
@@ -114,88 +231,69 @@ export type StrictErrorResult = {
114
231
  * Generic strict result type combining success and error.
115
232
  */
116
233
  export type StrictResult<T> = {
117
- cause?: undefined;
234
+ cause?: undefined | undefined;
118
235
  data: T;
119
- error?: undefined;
236
+ error?: undefined | undefined;
120
237
  status: number;
121
238
  success: true;
122
239
  } | StrictErrorResult;
123
240
  /**
124
- * Strict type for organization item.
241
+ * Strict type for full scan list result.
125
242
  */
126
- export type OrganizationItem = {
127
- id: string;
128
- name: string;
129
- slug: string;
130
- created_at: string;
131
- updated_at: string;
132
- plan: string;
243
+ export type FullScanListResult = {
244
+ cause?: undefined | undefined;
245
+ data: FullScanListData;
246
+ error?: undefined | undefined;
247
+ status: number;
248
+ success: true;
133
249
  };
134
250
  /**
135
- * Strict type for organizations list result.
251
+ * Strict type for single full scan result.
136
252
  */
137
- export type OrganizationsResult = {
138
- cause?: undefined;
139
- data: {
140
- organizations: OrganizationItem[];
141
- };
142
- error?: undefined;
253
+ export type FullScanResult = {
254
+ cause?: undefined | undefined;
255
+ data: FullScanItem;
256
+ error?: undefined | undefined;
143
257
  status: number;
144
258
  success: true;
145
259
  };
146
260
  /**
147
- * Strict type for repository item.
261
+ * Options for streaming a full scan.
148
262
  */
149
- export type RepositoryItem = {
150
- id: string;
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';
263
+ export type StreamFullScanOptions = {
264
+ output?: boolean | string | undefined;
160
265
  };
161
266
  /**
162
- * Strict type for repositories list data.
267
+ * Strict type for organizations list result.
163
268
  */
164
- export type RepositoriesListData = {
165
- results: RepositoryItem[];
166
- nextPageCursor: string | null;
167
- nextPage: number | null;
269
+ export type OrganizationsResult = {
270
+ cause?: undefined | undefined;
271
+ data: {
272
+ organizations: OrganizationItem[];
273
+ };
274
+ error?: undefined | undefined;
275
+ status: number;
276
+ success: true;
168
277
  };
169
278
  /**
170
279
  * Strict type for repositories list result.
171
280
  */
172
281
  export type RepositoriesListResult = {
173
- cause?: undefined;
282
+ cause?: undefined | undefined;
174
283
  data: RepositoriesListData;
175
- error?: undefined;
284
+ error?: undefined | undefined;
176
285
  status: number;
177
286
  success: true;
178
287
  };
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
288
  /**
191
289
  * Strict type for delete operation result.
192
290
  */
193
291
  export type DeleteResult = {
194
- cause?: undefined;
292
+ cause?: undefined | undefined;
195
293
  data: {
196
294
  success: boolean;
197
295
  };
198
- error?: undefined;
296
+ error?: undefined | undefined;
199
297
  status: number;
200
298
  success: true;
201
299
  };
@@ -203,36 +301,19 @@ export type DeleteResult = {
203
301
  * Strict type for single repository result.
204
302
  */
205
303
  export type RepositoryResult = {
206
- cause?: undefined;
304
+ cause?: undefined | undefined;
207
305
  data: RepositoryItem;
208
- error?: undefined;
306
+ error?: undefined | undefined;
209
307
  status: number;
210
308
  success: true;
211
309
  };
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
310
  /**
230
311
  * Strict type for repository labels list result.
231
312
  */
232
313
  export type RepositoryLabelsListResult = {
233
- cause?: undefined;
314
+ cause?: undefined | undefined;
234
315
  data: RepositoryLabelsListData;
235
- error?: undefined;
316
+ error?: undefined | undefined;
236
317
  status: number;
237
318
  success: true;
238
319
  };
@@ -240,9 +321,9 @@ export type RepositoryLabelsListResult = {
240
321
  * Strict type for single repository label result.
241
322
  */
242
323
  export type RepositoryLabelResult = {
243
- cause?: undefined;
324
+ cause?: undefined | undefined;
244
325
  data: RepositoryLabelItem;
245
- error?: undefined;
326
+ error?: undefined | undefined;
246
327
  status: number;
247
328
  success: true;
248
329
  };
@@ -250,11 +331,11 @@ export type RepositoryLabelResult = {
250
331
  * Strict type for delete repository label result.
251
332
  */
252
333
  export type DeleteRepositoryLabelResult = {
253
- cause?: undefined;
334
+ cause?: undefined | undefined;
254
335
  data: {
255
336
  status: string;
256
337
  };
257
- error?: undefined;
338
+ error?: undefined | undefined;
258
339
  status: number;
259
340
  success: true;
260
341
  };
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,20 @@ 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
+ url?: string | undefined;
144
+ _operation?: T | undefined;
144
145
  };
145
146
  export type SocketSdkResult<T extends SocketSdkOperations> = SocketSdkSuccessResult<T> | SocketSdkErrorResult<T>;
146
147
  /**
@@ -157,17 +158,18 @@ export type SocketSdkData<T extends SocketSdkOperations> = OpReturnType<operatio
157
158
  */
158
159
  export type SocketSdkArrayElement<T extends SocketSdkOperations, K extends keyof SocketSdkData<T>> = SocketSdkData<T>[K] extends Array<infer U> ? U : never;
159
160
  export type SocketSdkGenericResult<T> = {
160
- cause?: undefined;
161
+ cause?: undefined | undefined;
161
162
  data: T;
162
- error?: undefined;
163
+ error?: undefined | undefined;
163
164
  status: number;
164
165
  success: true;
165
166
  } | {
166
167
  cause?: string | undefined;
167
- data?: undefined;
168
+ data?: undefined | undefined;
168
169
  error: string;
169
170
  status: number;
170
171
  success: false;
172
+ url?: string | undefined;
171
173
  };
172
174
  /**
173
175
  * Result from file validation callback.
@@ -264,18 +266,17 @@ export interface SocketSdkOptions {
264
266
  onFileValidation?: FileValidationCallback | undefined;
265
267
  /** Request/response logging hooks */
266
268
  hooks?: {
267
- onRequest?: (info: RequestInfo) => void;
268
- onResponse?: (info: ResponseInfo) => void;
269
+ onRequest?: ((info: RequestInfo) => void) | undefined;
270
+ onResponse?: ((info: ResponseInfo) => void) | undefined;
269
271
  } | undefined;
270
272
  /**
271
- * Number of retry attempts on failure (default: 0, retries disabled).
272
- * Retries are opt-in following Node.js fs.rm() pattern.
273
- * Recommended: 3 for production, 0 for testing.
273
+ * Number of retry attempts on failure (default: 3).
274
+ * Uses exponential backoff between retries.
274
275
  */
275
276
  retries?: number | undefined;
276
277
  /**
277
- * Initial delay in milliseconds between retries (default: 100).
278
- * Uses exponential backoff: 100ms, 200ms, 400ms, etc.
278
+ * Initial delay in milliseconds between retries (default: 1000).
279
+ * Uses exponential backoff: 1000ms, 2000ms, 4000ms, etc.
279
280
  */
280
281
  retryDelay?: number | undefined;
281
282
  /** Request timeout in milliseconds */
@@ -288,15 +289,15 @@ export type UploadManifestFilesResponse = {
288
289
  unmatchedFiles: string[];
289
290
  };
290
291
  export type UploadManifestFilesReturnType = {
291
- cause?: undefined;
292
+ cause?: undefined | undefined;
292
293
  data: UploadManifestFilesResponse;
293
- error?: undefined;
294
+ error?: undefined | undefined;
294
295
  status: 200;
295
296
  success: true;
296
297
  };
297
298
  export type UploadManifestFilesError = {
298
299
  cause?: string | undefined;
299
- data?: undefined;
300
+ data?: undefined | undefined;
300
301
  error: string;
301
302
  status: number;
302
303
  success: false;