@bugbug-io/sdk 13.39.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/README.md +576 -0
- package/dist/constants/sdk-error-codes.d.ts +35 -0
- package/dist/constants/sdk-error-codes.d.ts.map +1 -0
- package/dist/index.d.ts +87 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3844 -0
- package/dist/modules/auth/auth.d.ts +11 -0
- package/dist/modules/auth/auth.d.ts.map +1 -0
- package/dist/modules/auth/auth.types.d.ts +34 -0
- package/dist/modules/auth/auth.types.d.ts.map +1 -0
- package/dist/modules/auth/auth.utils.d.ts +4 -0
- package/dist/modules/auth/auth.utils.d.ts.map +1 -0
- package/dist/modules/components/components.d.ts +43 -0
- package/dist/modules/components/components.d.ts.map +1 -0
- package/dist/modules/config/config.d.ts +48 -0
- package/dist/modules/config/config.d.ts.map +1 -0
- package/dist/modules/groups/groups.d.ts +62 -0
- package/dist/modules/groups/groups.d.ts.map +1 -0
- package/dist/modules/profiles/profiles.d.ts +71 -0
- package/dist/modules/profiles/profiles.d.ts.map +1 -0
- package/dist/modules/project/project.d.ts +58 -0
- package/dist/modules/project/project.d.ts.map +1 -0
- package/dist/modules/projectArtifacts/projectArtifacts.d.ts +8 -0
- package/dist/modules/projectArtifacts/projectArtifacts.d.ts.map +1 -0
- package/dist/modules/projectArtifacts/projectArtifacts.types.d.ts +14 -0
- package/dist/modules/projectArtifacts/projectArtifacts.types.d.ts.map +1 -0
- package/dist/modules/projects/projects.d.ts +36 -0
- package/dist/modules/projects/projects.d.ts.map +1 -0
- package/dist/modules/projects/projects.types.d.ts +6 -0
- package/dist/modules/projects/projects.types.d.ts.map +1 -0
- package/dist/modules/stepRuns/stepRuns.d.ts +22 -0
- package/dist/modules/stepRuns/stepRuns.d.ts.map +1 -0
- package/dist/modules/steps/steps.d.ts +47 -0
- package/dist/modules/steps/steps.d.ts.map +1 -0
- package/dist/modules/steps/steps.utils.d.ts +11 -0
- package/dist/modules/steps/steps.utils.d.ts.map +1 -0
- package/dist/modules/suites/suites.d.ts +153 -0
- package/dist/modules/suites/suites.d.ts.map +1 -0
- package/dist/modules/suites/suites.types.d.ts +31 -0
- package/dist/modules/suites/suites.types.d.ts.map +1 -0
- package/dist/modules/tests/tests.d.ts +253 -0
- package/dist/modules/tests/tests.d.ts.map +1 -0
- package/dist/modules/tests/tests.types.d.ts +34 -0
- package/dist/modules/tests/tests.types.d.ts.map +1 -0
- package/dist/modules/tests/tests.utils.d.ts +11 -0
- package/dist/modules/tests/tests.utils.d.ts.map +1 -0
- package/dist/modules/variables/variables.d.ts +14 -0
- package/dist/modules/variables/variables.d.ts.map +1 -0
- package/dist/modules/variables/variables.types.d.ts +7 -0
- package/dist/modules/variables/variables.types.d.ts.map +1 -0
- package/dist/modules/visualRegression/visualRegression.constants.d.ts +7 -0
- package/dist/modules/visualRegression/visualRegression.constants.d.ts.map +1 -0
- package/dist/modules/visualRegression/visualRegression.d.ts +69 -0
- package/dist/modules/visualRegression/visualRegression.d.ts.map +1 -0
- package/dist/modules/visualRegression/visualRegression.types.d.ts +12 -0
- package/dist/modules/visualRegression/visualRegression.types.d.ts.map +1 -0
- package/dist/sdk.d.ts +126 -0
- package/dist/sdk.d.ts.map +1 -0
- package/dist/services/apiClient/apiClient.d.ts +167 -0
- package/dist/services/apiClient/apiClient.d.ts.map +1 -0
- package/dist/services/apiClient/apiClient.types.d.ts +19 -0
- package/dist/services/apiClient/apiClient.types.d.ts.map +1 -0
- package/dist/services/apiClient/apiClient.utils.d.ts +32 -0
- package/dist/services/apiClient/apiClient.utils.d.ts.map +1 -0
- package/dist/services/rateLimiter/rateLimiter.constants.d.ts +5 -0
- package/dist/services/rateLimiter/rateLimiter.constants.d.ts.map +1 -0
- package/dist/services/rateLimiter/rateLimiter.d.ts +49 -0
- package/dist/services/rateLimiter/rateLimiter.d.ts.map +1 -0
- package/dist/services/rateLimiter/rateLimiter.types.d.ts +34 -0
- package/dist/services/rateLimiter/rateLimiter.types.d.ts.map +1 -0
- package/dist/testUtils/fakeFactory.d.ts +15 -0
- package/dist/testUtils/fakeFactory.d.ts.map +1 -0
- package/dist/testUtils/setup.d.ts +2 -0
- package/dist/testUtils/setup.d.ts.map +1 -0
- package/dist/types/config.d.ts +121 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/errors.d.ts +162 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/sdk.d.ts +28 -0
- package/dist/types/sdk.d.ts.map +1 -0
- package/dist/utils/pagination.d.ts +10 -0
- package/dist/utils/pagination.d.ts.map +1 -0
- package/dist/utils/polling.d.ts +20 -0
- package/dist/utils/polling.d.ts.map +1 -0
- package/package.json +83 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"visualRegression.types.d.ts","sourceRoot":"","sources":["../../../src/modules/visualRegression/visualRegression.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,8BAA8B,GAAG,mBAAmB,GAAG,wBAAwB,CAAC;AAE5F,MAAM,WAAW,6BAA6B;IAC5C,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,uBAAuB,CAAC,EAAE,MAAM,CAAC;CAClC;AAED,MAAM,WAAW,+BAA+B;IAC9C,OAAO,EAAE,6BAA6B,EAAE,CAAC;CAC1C"}
|
package/dist/sdk.d.ts
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import type { BugBugConfig, RequestOptions } from './types/config';
|
|
2
|
+
import type { ConnectivityStatus } from './types/sdk';
|
|
3
|
+
import { AuthModule } from './modules/auth/auth';
|
|
4
|
+
import { ComponentsModule } from './modules/components/components';
|
|
5
|
+
import { ConfigModule } from './modules/config/config';
|
|
6
|
+
import { GroupsModule } from './modules/groups/groups';
|
|
7
|
+
import { ProfilesModule } from './modules/profiles/profiles';
|
|
8
|
+
import { ProjectModule } from './modules/project/project';
|
|
9
|
+
import { ProjectArtifactsModule } from './modules/projectArtifacts/projectArtifacts';
|
|
10
|
+
import { ProjectsModule } from './modules/projects/projects';
|
|
11
|
+
import { StepRunsModule } from './modules/stepRuns/stepRuns';
|
|
12
|
+
import { StepsModule } from './modules/steps/steps';
|
|
13
|
+
import { SuitesModule } from './modules/suites/suites';
|
|
14
|
+
import { TestsModule } from './modules/tests/tests';
|
|
15
|
+
import { VariablesModule } from './modules/variables/variables';
|
|
16
|
+
import { VisualRegressionModule } from './modules/visualRegression/visualRegression';
|
|
17
|
+
/**
|
|
18
|
+
* Main BugBug SDK class providing modular access to BugBug API functionality.
|
|
19
|
+
*
|
|
20
|
+
* Organizes functionality into dedicated modules:
|
|
21
|
+
* - `tests` - Test management and execution
|
|
22
|
+
* - `suites` - Suite management and execution
|
|
23
|
+
* - `profiles` - Profile management
|
|
24
|
+
* - `config` - System configuration and connectivity
|
|
25
|
+
* - `groups` - Groups/components management
|
|
26
|
+
* - `components` - Reusable test components listing
|
|
27
|
+
* - `steps` - Individual test steps management
|
|
28
|
+
* - `project` - Project settings, ZIP export, and ZIP import
|
|
29
|
+
* - `projectArtifacts` - Project artifact uploads for upload-file steps
|
|
30
|
+
* - `visualRegression` - Visual regression reference screenshots
|
|
31
|
+
* - `auth` - OAuth authorization and token identity helpers
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* import { createBugBug } from '@bugbug-io/sdk';
|
|
36
|
+
*
|
|
37
|
+
* const sdk = createBugBug({
|
|
38
|
+
* apiToken: 'your-api-token',
|
|
39
|
+
* verbose: true
|
|
40
|
+
* });
|
|
41
|
+
*
|
|
42
|
+
* // Run a test and watch progress
|
|
43
|
+
* const result = await sdk.tests.startRun('my-test', {
|
|
44
|
+
* watchProgress: true,
|
|
45
|
+
* onProgress: (run) => console.log(`Status: ${run.status}`)
|
|
46
|
+
* });
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export declare class BugBugSDK {
|
|
50
|
+
#private;
|
|
51
|
+
readonly tests: TestsModule;
|
|
52
|
+
readonly suites: SuitesModule;
|
|
53
|
+
readonly profiles: ProfilesModule;
|
|
54
|
+
readonly config: ConfigModule;
|
|
55
|
+
readonly groups: GroupsModule;
|
|
56
|
+
readonly components: ComponentsModule;
|
|
57
|
+
readonly steps: StepsModule;
|
|
58
|
+
readonly stepRuns: StepRunsModule;
|
|
59
|
+
readonly project: ProjectModule;
|
|
60
|
+
readonly projectArtifacts: ProjectArtifactsModule;
|
|
61
|
+
readonly projects: ProjectsModule;
|
|
62
|
+
readonly variables: VariablesModule;
|
|
63
|
+
readonly visualRegression: VisualRegressionModule;
|
|
64
|
+
readonly auth: AuthModule;
|
|
65
|
+
/**
|
|
66
|
+
* @param config - SDK configuration (API token, base URL, rate limits, etc.)
|
|
67
|
+
*/
|
|
68
|
+
constructor(config: BugBugConfig);
|
|
69
|
+
/**
|
|
70
|
+
* Get the current SDK configuration.
|
|
71
|
+
*
|
|
72
|
+
* @returns Readonly configuration object with all resolved defaults
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```typescript
|
|
76
|
+
* const config = sdk.getConfig();
|
|
77
|
+
* console.log(`API URL: ${config.apiUrl}`);
|
|
78
|
+
* console.log(`Verbose: ${config.verbose}`);
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
getConfig: () => Readonly<Required<BugBugConfig>>;
|
|
82
|
+
/**
|
|
83
|
+
* Update SDK configuration at runtime.
|
|
84
|
+
*
|
|
85
|
+
* @param updates - Partial configuration updates to apply
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```typescript
|
|
89
|
+
* sdk.updateConfig({
|
|
90
|
+
* verbose: true,
|
|
91
|
+
* timeout: 60000
|
|
92
|
+
* });
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
updateConfig: (updates: Partial<BugBugConfig>) => void;
|
|
96
|
+
/**
|
|
97
|
+
* Set the active project for subsequent project-scoped requests.
|
|
98
|
+
* Shorthand for `updateConfig({ projectId })`.
|
|
99
|
+
*
|
|
100
|
+
* @param projectId - The project id to scope requests to.
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* ```typescript
|
|
104
|
+
* sdk.setProject('00000000-0000-0000-0000-000000000001');
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
setProject: (projectId: string) => void;
|
|
108
|
+
/**
|
|
109
|
+
* Test API connectivity and authentication.
|
|
110
|
+
*
|
|
111
|
+
* @param options - Request options including timeout and signal
|
|
112
|
+
* @returns Connectivity test result with timing and status
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```typescript
|
|
116
|
+
* const result = await sdk.testConnection();
|
|
117
|
+
* if (result.connected) {
|
|
118
|
+
* console.log(`Connected in ${result.responseTime}ms`);
|
|
119
|
+
* } else {
|
|
120
|
+
* console.error(`Connection failed: ${result.error}`);
|
|
121
|
+
* }
|
|
122
|
+
* ```
|
|
123
|
+
*/
|
|
124
|
+
testConnection: (options?: RequestOptions) => Promise<ConnectivityStatus>;
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=sdk.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../src/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,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E7E;;;;;;;;;;;;OAYG;IACH,YAAY,GAAI,SAAS,OAAO,CAAC,YAAY,CAAC,KAAG,IAAI,CAEnD;IAEF;;;;;;;;;;OAUG;IACH,UAAU,GAAI,WAAW,MAAM,KAAG,IAAI,CAEpC;IAEF;;;;;;;;;;;;;;;OAeG;IACH,cAAc,GAAU,UAAS,cAAmB,KAAG,OAAO,CAAC,kBAAkB,CAAC,CAC1C;CACzC"}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import type { BugBugConfig, RequestOptions } from '../../types/config';
|
|
2
|
+
/**
|
|
3
|
+
* Core HTTP client for the BugBug API.
|
|
4
|
+
*
|
|
5
|
+
* Owns the auth/base-URL configuration, request-time rate limiting,
|
|
6
|
+
* timeout/abort handling, and the OpenAPI→SDK error mapping. Domain modules
|
|
7
|
+
* (tests/suites/…) call into these methods; integrators rarely instantiate
|
|
8
|
+
* this directly — use `createBugBug()` from the package root instead.
|
|
9
|
+
*
|
|
10
|
+
* Every public HTTP method may throw one of the SDK error classes from
|
|
11
|
+
* `types/errors.ts`:
|
|
12
|
+
* - `AuthenticationError` (401), `AuthorizationError` (403)
|
|
13
|
+
* - `NotFoundError` (404), `ValidationError` (400/422 with DRF field map)
|
|
14
|
+
* - `RateLimitError` (429), `InternalServerError` (500),
|
|
15
|
+
* `ServiceUnavailableError` (502/503/504), `HttpError` (other 4xx/5xx)
|
|
16
|
+
* - `NetworkError`, `TimeoutError`, `CancellationError`, `UnexpectedResponseError`
|
|
17
|
+
*/
|
|
18
|
+
export declare class BugBugApiClient {
|
|
19
|
+
#private;
|
|
20
|
+
constructor(config: BugBugConfig);
|
|
21
|
+
/**
|
|
22
|
+
* Issue a GET request through the openapi-fetch JSON path.
|
|
23
|
+
*
|
|
24
|
+
* @param path - API path template (e.g. `/tests/{id}/`).
|
|
25
|
+
* @param options.queryParams - Mapped to URL search params; `undefined`/`null` values are dropped.
|
|
26
|
+
* @param options.pathParams - Used to substitute `{name}` placeholders in `path`.
|
|
27
|
+
* @returns Parsed JSON response body typed as `T`.
|
|
28
|
+
*/
|
|
29
|
+
get: <T = unknown>(path: string, options?: RequestOptions & {
|
|
30
|
+
queryParams?: Record<string, unknown>;
|
|
31
|
+
pathParams?: Record<string, string>;
|
|
32
|
+
}) => Promise<T>;
|
|
33
|
+
/**
|
|
34
|
+
* Issue a POST request. The body is JSON-serialized by openapi-fetch.
|
|
35
|
+
*
|
|
36
|
+
* @param path - API path template.
|
|
37
|
+
* @param options.body - Request body (JSON-serialized).
|
|
38
|
+
* @param options.queryParams - URL search params.
|
|
39
|
+
* @param options.pathParams - Path-segment values.
|
|
40
|
+
*/
|
|
41
|
+
post: <T = unknown>(path: string, options?: RequestOptions & {
|
|
42
|
+
body?: unknown;
|
|
43
|
+
queryParams?: Record<string, unknown>;
|
|
44
|
+
pathParams?: Record<string, string>;
|
|
45
|
+
}) => Promise<T>;
|
|
46
|
+
getAppRoot: <T = unknown>(path: string, options?: RequestOptions & {
|
|
47
|
+
acceptRedirect?: boolean;
|
|
48
|
+
authenticated?: boolean;
|
|
49
|
+
redirect?: RequestRedirect;
|
|
50
|
+
queryParams?: Record<string, unknown>;
|
|
51
|
+
pathParams?: Record<string, string>;
|
|
52
|
+
}) => Promise<T>;
|
|
53
|
+
postAppRoot: <T = unknown>(path: string, options?: RequestOptions & {
|
|
54
|
+
authenticated?: boolean;
|
|
55
|
+
body?: unknown;
|
|
56
|
+
queryParams?: Record<string, unknown>;
|
|
57
|
+
pathParams?: Record<string, string>;
|
|
58
|
+
}) => Promise<T>;
|
|
59
|
+
/**
|
|
60
|
+
* Issue a JSON POST request for endpoints that intentionally return no
|
|
61
|
+
* response body even on 2xx success.
|
|
62
|
+
*/
|
|
63
|
+
postNoContent: (path: string, options?: RequestOptions & {
|
|
64
|
+
body?: unknown;
|
|
65
|
+
queryParams?: Record<string, unknown>;
|
|
66
|
+
pathParams?: Record<string, string>;
|
|
67
|
+
}) => Promise<void>;
|
|
68
|
+
/** Issue a PUT request (full-replace semantics). See {@link post} for parameters. */
|
|
69
|
+
put: <T = unknown>(path: string, options?: RequestOptions & {
|
|
70
|
+
body?: unknown;
|
|
71
|
+
queryParams?: Record<string, unknown>;
|
|
72
|
+
pathParams?: Record<string, string>;
|
|
73
|
+
}) => Promise<T>;
|
|
74
|
+
/** Issue a PATCH request (partial-update semantics). See {@link post} for parameters. */
|
|
75
|
+
patch: <T = unknown>(path: string, options?: RequestOptions & {
|
|
76
|
+
body?: unknown;
|
|
77
|
+
queryParams?: Record<string, unknown>;
|
|
78
|
+
pathParams?: Record<string, string>;
|
|
79
|
+
}) => Promise<T>;
|
|
80
|
+
/**
|
|
81
|
+
* Issue a DELETE request. An optional `body` is accepted for DRF endpoints
|
|
82
|
+
* that require one, though `openapi-fetch` only sends it when the OpenAPI
|
|
83
|
+
* spec declares it.
|
|
84
|
+
*/
|
|
85
|
+
delete: <T = unknown>(path: string, options?: RequestOptions & {
|
|
86
|
+
body?: unknown;
|
|
87
|
+
queryParams?: Record<string, unknown>;
|
|
88
|
+
pathParams?: Record<string, string>;
|
|
89
|
+
}) => Promise<T>;
|
|
90
|
+
/**
|
|
91
|
+
* GET an endpoint that returns plain text (e.g. JUnit XML, logs).
|
|
92
|
+
*
|
|
93
|
+
* Bypasses the openapi-fetch JSON parser. Errors still flow through the
|
|
94
|
+
* shared status→error mapping.
|
|
95
|
+
*
|
|
96
|
+
* @returns The response body as a string.
|
|
97
|
+
*/
|
|
98
|
+
getText: (path: string, options?: RequestOptions & {
|
|
99
|
+
queryParams?: Record<string, unknown>;
|
|
100
|
+
pathParams?: Record<string, string>;
|
|
101
|
+
}) => Promise<string>;
|
|
102
|
+
/**
|
|
103
|
+
* GET an endpoint returning binary bytes (ZIP / octet-stream).
|
|
104
|
+
*
|
|
105
|
+
* @returns The response body as `Uint8Array`.
|
|
106
|
+
*/
|
|
107
|
+
getBinary: (path: string, options?: RequestOptions & {
|
|
108
|
+
queryParams?: Record<string, unknown>;
|
|
109
|
+
pathParams?: Record<string, string>;
|
|
110
|
+
}) => Promise<Uint8Array>;
|
|
111
|
+
/**
|
|
112
|
+
* POST raw bytes or text with an explicit `Content-Type`.
|
|
113
|
+
*
|
|
114
|
+
* Used for binary (ZIP) and YAML uploads that don't fit the openapi-fetch
|
|
115
|
+
* JSON path. The response is parsed as JSON when possible, otherwise the
|
|
116
|
+
* raw text is returned.
|
|
117
|
+
*
|
|
118
|
+
* @param path - API path template.
|
|
119
|
+
* @param body - Raw bytes or string to send as the request body.
|
|
120
|
+
* @param options.contentType - MIME type sent in the `Content-Type` header.
|
|
121
|
+
* @returns Parsed JSON body or raw text.
|
|
122
|
+
*/
|
|
123
|
+
postRaw: <T = unknown>(path: string, body: Uint8Array | string, options: RequestOptions & {
|
|
124
|
+
contentType: string;
|
|
125
|
+
queryParams?: Record<string, unknown>;
|
|
126
|
+
pathParams?: Record<string, string>;
|
|
127
|
+
}) => Promise<T>;
|
|
128
|
+
/**
|
|
129
|
+
* POST a `multipart/form-data` body. The browser/fetch sets the
|
|
130
|
+
* `Content-Type` boundary automatically.
|
|
131
|
+
*
|
|
132
|
+
* @param path - API path template.
|
|
133
|
+
* @param form - The `FormData` instance to send.
|
|
134
|
+
* @returns Parsed JSON body or raw text.
|
|
135
|
+
*/
|
|
136
|
+
postForm: <T = unknown>(path: string, form: FormData, options?: RequestOptions & {
|
|
137
|
+
queryParams?: Record<string, unknown>;
|
|
138
|
+
pathParams?: Record<string, string>;
|
|
139
|
+
useAppRoot?: boolean;
|
|
140
|
+
}) => Promise<T>;
|
|
141
|
+
/**
|
|
142
|
+
* Return a frozen snapshot of the resolved configuration (defaults applied).
|
|
143
|
+
*/
|
|
144
|
+
getConfig: () => Readonly<Required<BugBugConfig>>;
|
|
145
|
+
/**
|
|
146
|
+
* Patch configuration at runtime. Re-builds the openapi-fetch client when
|
|
147
|
+
* `apiToken` or `apiUrl` changes, and rebuilds the rate limiter when
|
|
148
|
+
* `rateLimit` changes — other fields take effect on the next request.
|
|
149
|
+
*
|
|
150
|
+
* @param updates - Partial configuration overrides to merge in.
|
|
151
|
+
*/
|
|
152
|
+
updateConfig: (updates: Partial<BugBugConfig>) => void;
|
|
153
|
+
/**
|
|
154
|
+
* Snapshot of the in-process rate-limiter state.
|
|
155
|
+
*
|
|
156
|
+
* @returns `{ requestsInWindow, remainingRequests, maxRequests, windowMs, resetTime, canMakeRequest }`.
|
|
157
|
+
*/
|
|
158
|
+
getRateLimitStatus: () => {
|
|
159
|
+
requestsInWindow: number;
|
|
160
|
+
maxRequests: number;
|
|
161
|
+
remainingRequests: number;
|
|
162
|
+
windowMs: number;
|
|
163
|
+
resetTime: number | null;
|
|
164
|
+
canMakeRequest: boolean;
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
//# sourceMappingURL=apiClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apiClient.d.ts","sourceRoot":"","sources":["../../../src/services/apiClient/apiClient.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAuCvE;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,eAAe;;gBAKd,MAAM,EAAE,YAAY;IA6ThC;;;;;;;OAOG;IACH,GAAG,GAAU,CAAC,GAAG,OAAO,EACtB,MAAM,MAAM,EACZ,UAAS,cAAc,GAAG;QACxB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACtC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KAChC,KACL,OAAO,CAAC,CAAC,CAAC,CAUX;IAEF;;;;;;;OAOG;IACH,IAAI,GAAU,CAAC,GAAG,OAAO,EACvB,MAAM,MAAM,EACZ,UAAS,cAAc,GAAG;QACxB,IAAI,CAAC,EAAE,OAAO,CAAC;QACf,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACtC,UAAU,CAAC,E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IACH,OAAO,GAAU,CAAC,GAAG,OAAO,EAC1B,MAAM,MAAM,EACZ,MAAM,UAAU,GAAG,MAAM,EACzB,SAAS,cAAc,GAAG;QACxB,WAAW,EAAE,MAAM,CAAC;QACpB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACtC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KACrC,KACA,OAAO,CAAC,CAAC,CAAC,CAQX;IAEF;;;;;;;OAOG;IACH,QAAQ,GAAU,CAAC,GAAG,OAAO,EAC3B,MAAM,MAAM,EACZ,MAAM,QAAQ,EACd,UAAS,cAAc,GAAG;QACxB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACtC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACpC,UAAU,CAAC,EAAE,OAAO,CAAC;KACjB,KACL,OAAO,CAAC,CAAC,CAAC,CAGT;IAgKJ;;OAEG;IACH,SAAS,QAAO,QAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAA0B;IAE1E;;;;;;OAMG;IACH,YAAY,GAAI,SAAS,OAAO,CAAC,YAAY,CAAC,KAAG,IAAI,CAanD;IAEF;;;;OAIG;IACH,kBAAkB;;;;;;;MAAuC;CAmE1D"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { paths } from '@bugbug-io/api-schema';
|
|
2
|
+
import type createClient from 'openapi-fetch';
|
|
3
|
+
/**
|
|
4
|
+
* OpenAPI client type
|
|
5
|
+
*/
|
|
6
|
+
export type ApiClient = ReturnType<typeof createClient<paths>>;
|
|
7
|
+
/**
|
|
8
|
+
* OpenAPI request options type
|
|
9
|
+
*/
|
|
10
|
+
export type OpenApiRequestOptions = {
|
|
11
|
+
signal?: AbortSignal;
|
|
12
|
+
headers?: Record<string, string>;
|
|
13
|
+
params?: {
|
|
14
|
+
path?: Record<string, string>;
|
|
15
|
+
query?: Record<string, unknown>;
|
|
16
|
+
};
|
|
17
|
+
body?: unknown;
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=apiClient.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apiClient.types.d.ts","sourceRoot":"","sources":["../../../src/services/apiClient/apiClient.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,YAAY,MAAM,eAAe,CAAC;AAE9C;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;AAE/D;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,MAAM,CAAC,EAAE;QACP,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC9B,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACjC,CAAC;IACF,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Best-effort human message from a parsed error body. Returns an empty string
|
|
3
|
+
* when nothing useful can be extracted so per-status fallbacks in
|
|
4
|
+
* `handleOpenApiError` (e.g. "Resource not found") take precedence.
|
|
5
|
+
*/
|
|
6
|
+
export declare function formatApiErrorMessage(error: unknown): string;
|
|
7
|
+
export declare function formatNetworkErrorMessage(error: TypeError): string;
|
|
8
|
+
export declare function formatUnexpectedResponseMessage(error: Error, method: string, url: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* Coerce an error body to an object so it can be walked for field errors.
|
|
11
|
+
* Strings produced by the raw text/binary paths may be JSON; try to parse.
|
|
12
|
+
*/
|
|
13
|
+
export declare function parseErrorBody(error: unknown): unknown;
|
|
14
|
+
/**
|
|
15
|
+
* Extract a DRF-style field-error map from an error body.
|
|
16
|
+
*
|
|
17
|
+
* DRF returns shapes like:
|
|
18
|
+
* { field_name: ["This field is required."] }
|
|
19
|
+
* { non_field_errors: ["..."] }
|
|
20
|
+
* { nested: { sub_field: ["..."] } }
|
|
21
|
+
*
|
|
22
|
+
* This walks the structure (skipping the well-known `detail`/`message`/`error`
|
|
23
|
+
* keys handled by `formatApiErrorValue`) and produces flat dot-paths mapping
|
|
24
|
+
* to string arrays so MCP clients can react per-field.
|
|
25
|
+
*/
|
|
26
|
+
export declare function extractFieldErrors(body: unknown): Record<string, string[]> | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Parse a response body as JSON, falling back to the raw text when it is not
|
|
29
|
+
* valid JSON. An empty body resolves to `undefined`.
|
|
30
|
+
*/
|
|
31
|
+
export declare function parseJsonOrText<T>(text: string): T;
|
|
32
|
+
//# sourceMappingURL=apiClient.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apiClient.utils.d.ts","sourceRoot":"","sources":["../../../src/services/apiClient/apiClient.utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAG5D;AAaD,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,CAMlE;AAED,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAEjG;AAwBD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAStD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,GAAG,SAAS,CAgCtF;AA+BD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,CAOlD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rateLimiter.constants.d.ts","sourceRoot":"","sources":["../../../src/services/rateLimiter/rateLimiter.constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,uBAAuB,IAAI,CAAC;AACzC,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAC3C,eAAO,MAAM,wBAAwB,OAAO,CAAC;AAC7C,eAAO,MAAM,wBAAwB,QAAS,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { RateLimitConfig } from './rateLimiter.types';
|
|
2
|
+
/**
|
|
3
|
+
* Token-bucket-ish rate limiter with exponential backoff.
|
|
4
|
+
*
|
|
5
|
+
* Used internally by `BugBugApiClient`. Integrators rarely instantiate this
|
|
6
|
+
* directly; instead pass {@link RateLimitConfig} via `BugBugConfig.rateLimit`.
|
|
7
|
+
*/
|
|
8
|
+
export declare class RateLimiter {
|
|
9
|
+
#private;
|
|
10
|
+
constructor(config: RateLimitConfig);
|
|
11
|
+
/**
|
|
12
|
+
* Execute a function with rate limiting and exponential backoff.
|
|
13
|
+
*
|
|
14
|
+
* The retry loop fires when:
|
|
15
|
+
* 1. The **client-side** gate trips (`canMakeRequest()` returns false) — `fn`
|
|
16
|
+
* was never called.
|
|
17
|
+
* 2. The function throws `RateLimitError` (typically a server 429) AND
|
|
18
|
+
* `retryServer429` is enabled. Retrying server 429s on non-idempotent
|
|
19
|
+
* requests (POST startRun, POST startRun) can produce duplicate
|
|
20
|
+
* resources — set `retryServer429: false` to disable.
|
|
21
|
+
*
|
|
22
|
+
* @param fn - The function to execute under rate limiting.
|
|
23
|
+
* @returns The function's resolved value.
|
|
24
|
+
* @throws {RateLimitError} When retries are exhausted or `retryServer429` is
|
|
25
|
+
* disabled and the server returned 429.
|
|
26
|
+
*/
|
|
27
|
+
execute<T>(fn: () => Promise<T>): Promise<T>;
|
|
28
|
+
/**
|
|
29
|
+
* Snapshot of the current rate-limiter state.
|
|
30
|
+
*
|
|
31
|
+
* @returns `requestsInWindow`, `remainingRequests`, `canMakeRequest`,
|
|
32
|
+
* `resetTime` (epoch ms when the oldest tracked request leaves the
|
|
33
|
+
* window — `null` when no requests are tracked).
|
|
34
|
+
*/
|
|
35
|
+
getStatus(): {
|
|
36
|
+
requestsInWindow: number;
|
|
37
|
+
maxRequests: number;
|
|
38
|
+
remainingRequests: number;
|
|
39
|
+
windowMs: number;
|
|
40
|
+
resetTime: number | null;
|
|
41
|
+
canMakeRequest: boolean;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Discard all tracked request timestamps. Useful in tests or after a clock
|
|
45
|
+
* jump. Not normally called in production.
|
|
46
|
+
*/
|
|
47
|
+
reset(): void;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=rateLimiter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rateLimiter.d.ts","sourceRoot":"","sources":["../../../src/services/rateLimiter/rateLimiter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAW3D;;;;;GAKG;AACH,qBAAa,WAAW;;gBAIV,MAAM,EAAE,eAAe;IA+BnC;;;;;;;;;;;;;;;OAeG;IACG,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IA8HlD;;;;;;OAMG;IACH,SAAS;;;;;;;;IAcT;;;OAGG;IACH,KAAK,IAAI,IAAI;CAGd"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export interface RateLimitConfig {
|
|
2
|
+
/** Maximum number of requests allowed inside one rolling window. */
|
|
3
|
+
maxRequests: number;
|
|
4
|
+
/** Rolling window size in milliseconds. */
|
|
5
|
+
windowMs: number;
|
|
6
|
+
/**
|
|
7
|
+
* Suggested wait time (ms) when the client-side gate trips. Used as the
|
|
8
|
+
* `retryAfter` on synthetic `RateLimitError` instances. Default: `1000`.
|
|
9
|
+
*/
|
|
10
|
+
retryAfter?: number;
|
|
11
|
+
/**
|
|
12
|
+
* Whether to automatically retry server-side 429 responses with exponential
|
|
13
|
+
* backoff.
|
|
14
|
+
* Defaults to `true`.
|
|
15
|
+
*
|
|
16
|
+
* **WARNING:** When `true`, a 429 returned mid-POST is retried transparently.
|
|
17
|
+
* For non-idempotent calls - `tests.startRun`, `suites.startRun`,
|
|
18
|
+
* `tests.create`, etc. - this can produce **duplicate resources** if the
|
|
19
|
+
* server already accepted the first request before returning 429. Set to
|
|
20
|
+
* `false` for production integrations that mutate data; the caller can then
|
|
21
|
+
* implement an idempotent retry strategy.
|
|
22
|
+
*/
|
|
23
|
+
retryServer429?: boolean;
|
|
24
|
+
/** Exponential backoff parameters applied when retrying rate-limited requests. */
|
|
25
|
+
exponentialBackoff: {
|
|
26
|
+
/** Starting delay in milliseconds. */
|
|
27
|
+
baseDelay: number;
|
|
28
|
+
/** Maximum delay in milliseconds. */
|
|
29
|
+
maxDelay: number;
|
|
30
|
+
/** Maximum retry attempts before giving up. */
|
|
31
|
+
maxRetries: number;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=rateLimiter.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rateLimiter.types.d.ts","sourceRoot":"","sources":["../../../src/services/rateLimiter/rateLimiter.types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,oEAAoE;IACpE,WAAW,EAAE,MAAM,CAAC;IAEpB,2CAA2C;IAC3C,QAAQ,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;;;;;;;;;OAWG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB,kFAAkF;IAClF,kBAAkB,EAAE;QAClB,sCAAsC;QACtC,SAAS,EAAE,MAAM,CAAC;QAClB,qCAAqC;QACrC,QAAQ,EAAE,MAAM,CAAC;QACjB,+CAA+C;QAC/C,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;CACH"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { BugBugConfig } from '../types/config';
|
|
2
|
+
import type { CreatedVariable, Profile, Project, Variable } from '@bugbug-io/api-schema';
|
|
3
|
+
type Override<T> = Partial<T>;
|
|
4
|
+
export declare const createFakeSdk: (overrides?: Partial<BugBugConfig>) => import("../sdk").BugBugSDK;
|
|
5
|
+
export declare const createFakeCursorPage: <T>(results: T[], nextToken?: string | null, count?: number) => {
|
|
6
|
+
count: number | undefined;
|
|
7
|
+
nextToken: string | null;
|
|
8
|
+
results: T[];
|
|
9
|
+
};
|
|
10
|
+
export declare const createFakeProfile: (overrides?: Override<Profile>) => Profile;
|
|
11
|
+
export declare const createFakeProject: (overrides?: Override<Project>) => Project;
|
|
12
|
+
export declare const createFakeVariable: (overrides?: Override<Variable>) => Variable;
|
|
13
|
+
export declare const createFakeCreatedVariable: (overrides?: Override<CreatedVariable>) => CreatedVariable;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=fakeFactory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fakeFactory.d.ts","sourceRoot":"","sources":["../../src/testUtils/fakeFactory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAIzF,KAAK,QAAQ,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC;AAE9B,eAAO,MAAM,aAAa,GAAI,YAAW,OAAO,CAAC,YAAY,CAAM,+BAChB,CAAC;AAEpD,eAAO,MAAM,oBAAoB,GAAI,CAAC,EACpC,SAAS,CAAC,EAAE,EACZ,YAAW,MAAM,GAAG,IAAW,EAC/B,QAAQ,MAAM;;;;CAKd,CAAC;AAEH,eAAO,MAAM,iBAAiB,GAAI,YAAW,QAAQ,CAAC,OAAO,CAAM,KAAG,OAKpE,CAAC;AAEH,eAAO,MAAM,iBAAiB,GAAI,YAAW,QAAQ,CAAC,OAAO,CAAM,KAAG,OAOpE,CAAC;AAEH,eAAO,MAAM,kBAAkB,GAAI,YAAW,QAAQ,CAAC,QAAQ,CAAM,KAAG,QAMtE,CAAC;AAEH,eAAO,MAAM,yBAAyB,GACpC,YAAW,QAAQ,CAAC,eAAe,CAAM,KACxC,eAID,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/testUtils/setup.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public configuration types for the BugBug SDK.
|
|
3
|
+
*/
|
|
4
|
+
import type { RateLimitConfig } from '../services/rateLimiter/rateLimiter.types';
|
|
5
|
+
import type { TriggeredBy } from '@bugbug-io/api-schema';
|
|
6
|
+
export interface BugBugConfig {
|
|
7
|
+
/**
|
|
8
|
+
* API token used for all requests. When omitted, the SDK resolves it
|
|
9
|
+
* from `bugbug.yaml`, `.env`, or `BUGBUG_API_TOKEN` (in that order). Throws
|
|
10
|
+
* a `ConfigurationError` at construction time if no token can be found.
|
|
11
|
+
*/
|
|
12
|
+
apiToken?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Origin marker recorded on runs started via this SDK instance. Defaults to
|
|
15
|
+
* `'api'`. Set once at SDK construction; individual `tests.startRun`/`suites.startRun`
|
|
16
|
+
* calls do not override this.
|
|
17
|
+
*
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
triggeredBy?: TriggeredBy;
|
|
21
|
+
/**
|
|
22
|
+
* Full API base URL — the SDK does **not** auto-append `/api/v2`. Defaults
|
|
23
|
+
* to `https://app.bugbug.io/api/v2` when omitted. Use the exported
|
|
24
|
+
* `normalizeApiBaseUrl` helper if you only have a host-only value (e.g.
|
|
25
|
+
* from `BUGBUG_API_URL`).
|
|
26
|
+
*
|
|
27
|
+
* @internal
|
|
28
|
+
*/
|
|
29
|
+
apiUrl?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Active project id for organization/user tokens, threaded into project-scoped
|
|
32
|
+
* requests. When omitted, the SDK resolves it from `BUGBUG_PROJECT_ID`,
|
|
33
|
+
* `bugbug.yaml`, or the persisted current project. Project tokens ignore this —
|
|
34
|
+
* their project is implied by the token. Use {@link BugBugSDK.setProject} to
|
|
35
|
+
* change it at runtime.
|
|
36
|
+
*/
|
|
37
|
+
projectId?: string;
|
|
38
|
+
/** Enable detailed request/response debug logging. Default: `false`. */
|
|
39
|
+
verbose?: boolean;
|
|
40
|
+
/** Lower bound on emitted log severity. Default: `'info'`. */
|
|
41
|
+
logLevel?: 'debug' | 'info' | 'warn' | 'error';
|
|
42
|
+
/** Per-request timeout in milliseconds. Default: `30_000` (30s). */
|
|
43
|
+
timeout?: number;
|
|
44
|
+
/** Client-side rate limiting and retry-on-429 behavior. See {@link RateLimitConfig}. */
|
|
45
|
+
rateLimit?: RateLimitConfig;
|
|
46
|
+
/**
|
|
47
|
+
* Extra HTTP headers added to every request.
|
|
48
|
+
* Caller-supplied `Authorization` is still ignored: the SDK's token
|
|
49
|
+
* always wins.
|
|
50
|
+
*/
|
|
51
|
+
requestHeaders?: Record<string, string>;
|
|
52
|
+
/** Hook invoked just before a request is dispatched. */
|
|
53
|
+
onBeforeRequest?: RequestHook;
|
|
54
|
+
/** Hook invoked after a successful (non-error) response. */
|
|
55
|
+
onAfterRequest?: RequestHook;
|
|
56
|
+
/** Hook invoked after a request errored. Receives the parsed `Response` and the underlying `Error`. */
|
|
57
|
+
onRequestError?: RequestErrorHook;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Callback receiving the request data envelope. Used by `onBeforeRequest`
|
|
61
|
+
* and `onAfterRequest`. Receives a snapshot of the resolved request (method,
|
|
62
|
+
* path, body, params, signal, timeout, headers).
|
|
63
|
+
*/
|
|
64
|
+
export type RequestHook = (requestData: RequestData) => void;
|
|
65
|
+
/**
|
|
66
|
+
* Callback receiving the request envelope, the underlying `Response`, and
|
|
67
|
+
* the originating `Error`. Used by `onRequestError`.
|
|
68
|
+
*/
|
|
69
|
+
export type RequestErrorHook = (requestData: RequestData, response: Response, error: Error) => void;
|
|
70
|
+
/**
|
|
71
|
+
* Common options shared by polling/wait helpers like
|
|
72
|
+
* `tests.watchRunProgress` and `suites.watchRunProgress`.
|
|
73
|
+
*
|
|
74
|
+
* @typeParam T - The polled resource type (e.g. `TestRunState`, `SuiteRunState`).
|
|
75
|
+
*/
|
|
76
|
+
export interface WaitOptions<T = unknown> {
|
|
77
|
+
/** Poll interval in milliseconds. Default: `2_000`. */
|
|
78
|
+
pollInterval?: number;
|
|
79
|
+
/**
|
|
80
|
+
* Total wait timeout in milliseconds. When omitted, each wait helper
|
|
81
|
+
* applies its own resource-appropriate default (5 minutes for tests,
|
|
82
|
+
* 10 minutes for suites).
|
|
83
|
+
*/
|
|
84
|
+
timeout?: number;
|
|
85
|
+
/** Callback invoked on every successful poll with the latest snapshot. */
|
|
86
|
+
onProgress?: (data: T) => void | Promise<void>;
|
|
87
|
+
}
|
|
88
|
+
export type RequestData = {
|
|
89
|
+
method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
|
|
90
|
+
path: string;
|
|
91
|
+
body?: unknown;
|
|
92
|
+
params?: {
|
|
93
|
+
path?: Record<string, string>;
|
|
94
|
+
query?: Record<string, unknown>;
|
|
95
|
+
};
|
|
96
|
+
signal?: RequestOptions['signal'];
|
|
97
|
+
timeout?: RequestOptions['timeout'];
|
|
98
|
+
headers?: RequestOptions['headers'];
|
|
99
|
+
};
|
|
100
|
+
export interface RequestOptions {
|
|
101
|
+
/** Abort signal for client-side cancellation. Throws `CancellationError`. */
|
|
102
|
+
signal?: AbortSignal;
|
|
103
|
+
/**
|
|
104
|
+
* Per-request timeout in milliseconds. Overrides `BugBugConfig.timeout` for
|
|
105
|
+
* this call only.
|
|
106
|
+
*/
|
|
107
|
+
timeout?: number;
|
|
108
|
+
/**
|
|
109
|
+
* Per-request HTTP headers. These are merged *first* so the SDK's auth and
|
|
110
|
+
* `User-Agent` headers always win — supplying `Authorization` here will
|
|
111
|
+
* have no effect.
|
|
112
|
+
*/
|
|
113
|
+
headers?: Record<string, string>;
|
|
114
|
+
/**
|
|
115
|
+
* Whether the SDK should add the configured `projectId` to this request.
|
|
116
|
+
*
|
|
117
|
+
* @internal
|
|
118
|
+
*/
|
|
119
|
+
projectScoped?: boolean;
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEzD,MAAM,WAAW,YAAY;IAC3B;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;IAE1B;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,wEAAwE;IACxE,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;IAE/C,oEAAoE;IACpE,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,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