@trigger.dev/sdk 4.7.3 → 4.7.4
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/commonjs/v3/concurrencyLimits.d.ts +37 -7
- package/dist/commonjs/v3/concurrencyLimits.js +38 -70
- package/dist/commonjs/v3/concurrencyLimits.js.map +1 -1
- package/dist/commonjs/v3/index.d.ts +1 -1
- package/dist/commonjs/v3/index.js.map +1 -1
- package/dist/commonjs/v3/runs.d.ts +22 -1
- package/dist/commonjs/v3/runs.js +6 -3
- package/dist/commonjs/v3/runs.js.map +1 -1
- package/dist/commonjs/version.js +1 -1
- package/dist/esm/v3/concurrencyLimits.d.ts +37 -7
- package/dist/esm/v3/concurrencyLimits.js +38 -70
- package/dist/esm/v3/concurrencyLimits.js.map +1 -1
- package/dist/esm/v3/index.d.ts +1 -1
- package/dist/esm/v3/index.js.map +1 -1
- package/dist/esm/v3/runs.d.ts +22 -1
- package/dist/esm/v3/runs.js +6 -3
- package/dist/esm/v3/runs.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/docs/ai-chat/patterns/sub-agents.mdx +33 -0
- package/docs/apikeys.mdx +3 -3
- package/docs/billing-limits.mdx +1 -1
- package/docs/cli-env-commands.mdx +5 -4
- package/docs/cli-init-commands.mdx +27 -1
- package/docs/cli-login-commands.mdx +20 -0
- package/docs/cli-projects-commands.mdx +13 -1
- package/docs/cli-runs-commands.mdx +3 -2
- package/docs/cli-update-commands.mdx +9 -3
- package/docs/cli-whoami-commands.mdx +12 -0
- package/docs/concurrency.mdx +32 -0
- package/docs/config/extensions/audioWaveform.mdx +4 -1
- package/docs/config/extensions/overview.mdx +2 -0
- package/docs/config/extensions/prismaExtension.mdx +2 -3
- package/docs/config/extensions/puppeteer.mdx +3 -5
- package/docs/config/extensions/pythonExtension.mdx +9 -1
- package/docs/config/extensions/syncEnvVars.mdx +6 -0
- package/docs/deploy-environment-variables.mdx +1 -1
- package/docs/deployment/atomic-deployment.mdx +2 -0
- package/docs/deployment/dev-branches.mdx +5 -5
- package/docs/deployment/overview.mdx +8 -7
- package/docs/deployment/preview-branches.mdx +6 -3
- package/docs/errors-retrying.mdx +4 -4
- package/docs/how-it-works.mdx +5 -5
- package/docs/introduction.mdx +6 -0
- package/docs/limits.mdx +26 -8
- package/docs/logging.mdx +1 -1
- package/docs/machines.mdx +1 -1
- package/docs/mcp-introduction.mdx +8 -7
- package/docs/mcp-tools.mdx +15 -1
- package/docs/migrating-from-v3.mdx +1 -1
- package/docs/observability/dashboards.mdx +2 -0
- package/docs/observability/query.mdx +6 -2
- package/docs/private-networking/aws-console-setup.mdx +1 -1
- package/docs/private-networking/overview.mdx +1 -1
- package/docs/quick-start.mdx +3 -40
- package/docs/realtime/auth.mdx +1 -1
- package/docs/realtime/backend/input-streams.mdx +159 -0
- package/docs/realtime/backend/streams.mdx +25 -10
- package/docs/realtime/how-it-works.mdx +1 -1
- package/docs/realtime/react-hooks/overview.mdx +1 -1
- package/docs/realtime/react-hooks/streams.mdx +2 -2
- package/docs/realtime/react-hooks/subscribe.mdx +19 -3
- package/docs/realtime/react-hooks/triggering.mdx +2 -2
- package/docs/realtime/react-hooks/use-wait-token.mdx +1 -1
- package/docs/realtime/run-object.mdx +47 -24
- package/docs/replaying.mdx +26 -1
- package/docs/reports.mdx +4 -2
- package/docs/run-tests.mdx +2 -2
- package/docs/run-usage.mdx +3 -3
- package/docs/runs/heartbeats.mdx +2 -2
- package/docs/runs/list-best-practices.mdx +234 -0
- package/docs/runs/metadata.mdx +7 -10
- package/docs/runs.mdx +18 -8
- package/docs/self-hosting/env/supervisor.mdx +2 -0
- package/docs/self-hosting/env/webapp.mdx +5 -0
- package/docs/self-hosting/overview.mdx +26 -0
- package/docs/tags.mdx +6 -0
- package/docs/tasks/scheduled.mdx +11 -5
- package/docs/triggering.mdx +8 -0
- package/docs/troubleshooting-alerts.mdx +102 -3
- package/docs/troubleshooting.mdx +1 -1
- package/docs/upgrading-packages.mdx +3 -3
- package/docs/vercel-integration.mdx +13 -3
- package/docs/versioning.mdx +1 -1
- package/docs/wait-for-token.mdx +3 -3
- package/package.json +2 -2
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import type { ApiPromise, ApiRequestOptions, ConcurrencyLimitItem, ListConcurrencyLimitOptions, OffsetLimitPagePromise, OverrideConcurrencyLimitRequestBody } from "@trigger.dev/core/v3";
|
|
1
|
+
import type { ApiPromise, ApiRequestOptions, ConcurrencyLimitItem, ConcurrencyLimitKeyItem, ListConcurrencyLimitOptions, OffsetLimitPagePromise, OverrideConcurrencyLimitBoundsBody, OverrideConcurrencyLimitKeyBody, OverrideConcurrencyLimitRequestBody } from "@trigger.dev/core/v3";
|
|
2
|
+
/** Options that address one concurrencyKey of a limit. */
|
|
3
|
+
export type ConcurrencyLimitKeyOptions = {
|
|
4
|
+
/** The concurrencyKey whose view, or whose override, the call is about. */
|
|
5
|
+
concurrencyKey: string;
|
|
6
|
+
};
|
|
2
7
|
/**
|
|
3
8
|
* Lists the environment's named concurrency limits (anonymous inline limits appear
|
|
4
9
|
* under their derived `task/<taskId>` names).
|
|
@@ -10,17 +15,23 @@ import type { ApiPromise, ApiRequestOptions, ConcurrencyLimitItem, ListConcurren
|
|
|
10
15
|
*/
|
|
11
16
|
export declare function list(options?: ListConcurrencyLimitOptions, requestOptions?: ApiRequestOptions): OffsetLimitPagePromise<typeof ConcurrencyLimitItem>;
|
|
12
17
|
/**
|
|
13
|
-
* Retrieves a concurrency limit by name
|
|
18
|
+
* Retrieves a concurrency limit by name, or, with `{ concurrencyKey }`, the limit's
|
|
19
|
+
* view for one key: its per-key bound (including any override and when it expires)
|
|
20
|
+
* and the runs executing for that key.
|
|
14
21
|
*
|
|
15
22
|
* @example
|
|
16
23
|
*
|
|
17
24
|
* ```ts
|
|
18
25
|
* const limit = await concurrencyLimits.retrieve("openai");
|
|
19
26
|
* console.log(limit.running, limit.queued, limit.total.current);
|
|
27
|
+
*
|
|
28
|
+
* const session = await concurrencyLimits.retrieve("subagents", { concurrencyKey: sessionId });
|
|
29
|
+
* console.log(session.perKey.override, session.perKey.expiresAt);
|
|
20
30
|
* ```
|
|
21
31
|
* @param name - The limit's name, as declared with `concurrencyLimit()`
|
|
22
|
-
* @returns The concurrency limit
|
|
32
|
+
* @returns The concurrency limit, or its view for the given key
|
|
23
33
|
*/
|
|
34
|
+
export declare function retrieve(name: string, options: ConcurrencyLimitKeyOptions, requestOptions?: ApiRequestOptions): ApiPromise<ConcurrencyLimitKeyItem>;
|
|
24
35
|
export declare function retrieve(name: string, requestOptions?: ApiRequestOptions): ApiPromise<ConcurrencyLimitItem>;
|
|
25
36
|
/**
|
|
26
37
|
* Overrides a concurrency limit's bounds. Only the given fields change; the
|
|
@@ -28,22 +39,41 @@ export declare function retrieve(name: string, requestOptions?: ApiRequestOption
|
|
|
28
39
|
* holding a limit, prefer `pause` (it keeps the configured bounds); overriding
|
|
29
40
|
* `total` to `0` also blocks every run holding the limit.
|
|
30
41
|
*
|
|
42
|
+
* With `concurrencyKey`, the override is a temporary per-key cap for that one key:
|
|
43
|
+
* it replaces the limit's `perKey` for the key, applies to every task holding the
|
|
44
|
+
* limit, and expires after `ttl` (default 7 days, at most 30 days). The limit itself
|
|
45
|
+
* is untouched, and other keys keep the declared `perKey`.
|
|
46
|
+
*
|
|
31
47
|
* @example
|
|
32
48
|
*
|
|
33
49
|
* ```ts
|
|
34
50
|
* await concurrencyLimits.override("openai", { total: 50 });
|
|
51
|
+
*
|
|
52
|
+
* // this session may run 3 sub-agents at once, for the next 7 days
|
|
53
|
+
* await concurrencyLimits.override("subagents", { concurrencyKey: sessionId, perKey: 3 });
|
|
35
54
|
* ```
|
|
36
55
|
* @param name - The limit's name
|
|
37
|
-
* @param override - The bounds to change (`perKey` and/or `total`)
|
|
38
|
-
* @returns The updated concurrency limit
|
|
56
|
+
* @param override - The bounds to change (`perKey` and/or `total`), or `concurrencyKey` with the key's `perKey` cap (and optional `ttl`)
|
|
57
|
+
* @returns The updated concurrency limit, or the key's view when `concurrencyKey` was given
|
|
39
58
|
*/
|
|
40
|
-
export declare function override(name: string, override:
|
|
59
|
+
export declare function override(name: string, override: OverrideConcurrencyLimitKeyBody, requestOptions?: ApiRequestOptions): ApiPromise<ConcurrencyLimitKeyItem>;
|
|
60
|
+
export declare function override(name: string, override: OverrideConcurrencyLimitBoundsBody, requestOptions?: ApiRequestOptions): ApiPromise<ConcurrencyLimitItem>;
|
|
61
|
+
export declare function override(name: string, override: OverrideConcurrencyLimitRequestBody, requestOptions?: ApiRequestOptions): ApiPromise<ConcurrencyLimitItem | ConcurrencyLimitKeyItem>;
|
|
41
62
|
/**
|
|
42
63
|
* Resets a concurrency limit back to its declared values, clearing any override.
|
|
64
|
+
* With `{ concurrencyKey }`, clears that key's override instead and leaves the
|
|
65
|
+
* limit itself alone.
|
|
43
66
|
*
|
|
67
|
+
* @example
|
|
68
|
+
*
|
|
69
|
+
* ```ts
|
|
70
|
+
* await concurrencyLimits.reset("openai");
|
|
71
|
+
* await concurrencyLimits.reset("subagents", { concurrencyKey: sessionId });
|
|
72
|
+
* ```
|
|
44
73
|
* @param name - The limit's name
|
|
45
|
-
* @returns The updated concurrency limit
|
|
74
|
+
* @returns The updated concurrency limit, or the key's view when `concurrencyKey` was given
|
|
46
75
|
*/
|
|
76
|
+
export declare function reset(name: string, options: ConcurrencyLimitKeyOptions, requestOptions?: ApiRequestOptions): ApiPromise<ConcurrencyLimitKeyItem>;
|
|
47
77
|
export declare function reset(name: string, requestOptions?: ApiRequestOptions): ApiPromise<ConcurrencyLimitItem>;
|
|
48
78
|
/**
|
|
49
79
|
* Pauses a concurrency limit. Nothing holding the limit is admitted until it is
|
|
@@ -8,6 +8,26 @@ exports.pause = pause;
|
|
|
8
8
|
exports.resume = resume;
|
|
9
9
|
const v3_1 = require("@trigger.dev/core/v3");
|
|
10
10
|
const tracer_js_1 = require("./tracer.js");
|
|
11
|
+
/**
|
|
12
|
+
* `retrieve` and `reset` take an optional key-options object before the request
|
|
13
|
+
* options. The two are told apart by the `concurrencyKey` property, so existing
|
|
14
|
+
* callers that pass request options in the second position keep working.
|
|
15
|
+
*/
|
|
16
|
+
function splitKeyOptions(first, second) {
|
|
17
|
+
if (first && typeof first === "object" && "concurrencyKey" in first) {
|
|
18
|
+
return { keyOptions: first, requestOptions: second };
|
|
19
|
+
}
|
|
20
|
+
return { keyOptions: undefined, requestOptions: first };
|
|
21
|
+
}
|
|
22
|
+
function limitAttributes(name, extra = {}) {
|
|
23
|
+
return {
|
|
24
|
+
...(0, v3_1.flattenAttributes)({ name, ...extra }),
|
|
25
|
+
...(0, v3_1.accessoryAttributes)({
|
|
26
|
+
items: [{ text: name, variant: "normal" }],
|
|
27
|
+
style: "codepath",
|
|
28
|
+
}),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
11
31
|
/**
|
|
12
32
|
* Lists the environment's named concurrency limits (anonymous inline limits appear
|
|
13
33
|
* under their derived `task/<taskId>` names).
|
|
@@ -26,85 +46,45 @@ function list(options, requestOptions) {
|
|
|
26
46
|
}, requestOptions);
|
|
27
47
|
return apiClient.listConcurrencyLimits(options, $requestOptions);
|
|
28
48
|
}
|
|
29
|
-
|
|
30
|
-
* Retrieves a concurrency limit by name.
|
|
31
|
-
*
|
|
32
|
-
* @example
|
|
33
|
-
*
|
|
34
|
-
* ```ts
|
|
35
|
-
* const limit = await concurrencyLimits.retrieve("openai");
|
|
36
|
-
* console.log(limit.running, limit.queued, limit.total.current);
|
|
37
|
-
* ```
|
|
38
|
-
* @param name - The limit's name, as declared with `concurrencyLimit()`
|
|
39
|
-
* @returns The concurrency limit
|
|
40
|
-
*/
|
|
41
|
-
function retrieve(name, requestOptions) {
|
|
49
|
+
function retrieve(name, optionsOrRequestOptions, maybeRequestOptions) {
|
|
42
50
|
const apiClient = v3_1.apiClientManager.clientOrThrow();
|
|
51
|
+
const { keyOptions, requestOptions } = splitKeyOptions(optionsOrRequestOptions, maybeRequestOptions);
|
|
43
52
|
const $requestOptions = (0, v3_1.mergeRequestOptions)({
|
|
44
53
|
tracer: tracer_js_1.tracer,
|
|
45
54
|
name: "concurrencyLimits.retrieve()",
|
|
46
55
|
icon: "queue",
|
|
47
|
-
attributes: {
|
|
48
|
-
...(0, v3_1.flattenAttributes)({ name }),
|
|
49
|
-
...(0, v3_1.accessoryAttributes)({
|
|
50
|
-
items: [{ text: name, variant: "normal" }],
|
|
51
|
-
style: "codepath",
|
|
52
|
-
}),
|
|
53
|
-
},
|
|
56
|
+
attributes: limitAttributes(name, keyOptions ? { concurrencyKey: keyOptions.concurrencyKey } : {}),
|
|
54
57
|
}, requestOptions);
|
|
58
|
+
if (keyOptions) {
|
|
59
|
+
return apiClient.retrieveConcurrencyLimitKey(name, keyOptions.concurrencyKey, $requestOptions);
|
|
60
|
+
}
|
|
55
61
|
return apiClient.retrieveConcurrencyLimit(name, $requestOptions);
|
|
56
62
|
}
|
|
57
|
-
/**
|
|
58
|
-
* Overrides a concurrency limit's bounds. Only the given fields change; the
|
|
59
|
-
* declared values are kept as the base and restored by `reset`. To stop runs
|
|
60
|
-
* holding a limit, prefer `pause` (it keeps the configured bounds); overriding
|
|
61
|
-
* `total` to `0` also blocks every run holding the limit.
|
|
62
|
-
*
|
|
63
|
-
* @example
|
|
64
|
-
*
|
|
65
|
-
* ```ts
|
|
66
|
-
* await concurrencyLimits.override("openai", { total: 50 });
|
|
67
|
-
* ```
|
|
68
|
-
* @param name - The limit's name
|
|
69
|
-
* @param override - The bounds to change (`perKey` and/or `total`)
|
|
70
|
-
* @returns The updated concurrency limit
|
|
71
|
-
*/
|
|
72
63
|
function override(name, override, requestOptions) {
|
|
73
64
|
const apiClient = v3_1.apiClientManager.clientOrThrow();
|
|
74
65
|
const $requestOptions = (0, v3_1.mergeRequestOptions)({
|
|
75
66
|
tracer: tracer_js_1.tracer,
|
|
76
67
|
name: "concurrencyLimits.override()",
|
|
77
68
|
icon: "queue",
|
|
78
|
-
attributes: {
|
|
79
|
-
...(0, v3_1.flattenAttributes)({ name, override }),
|
|
80
|
-
...(0, v3_1.accessoryAttributes)({
|
|
81
|
-
items: [{ text: name, variant: "normal" }],
|
|
82
|
-
style: "codepath",
|
|
83
|
-
}),
|
|
84
|
-
},
|
|
69
|
+
attributes: limitAttributes(name, { override }),
|
|
85
70
|
}, requestOptions);
|
|
71
|
+
if (override.concurrencyKey !== undefined) {
|
|
72
|
+
return apiClient.overrideConcurrencyLimitKey(name, override, $requestOptions);
|
|
73
|
+
}
|
|
86
74
|
return apiClient.overrideConcurrencyLimit(name, override, $requestOptions);
|
|
87
75
|
}
|
|
88
|
-
|
|
89
|
-
* Resets a concurrency limit back to its declared values, clearing any override.
|
|
90
|
-
*
|
|
91
|
-
* @param name - The limit's name
|
|
92
|
-
* @returns The updated concurrency limit
|
|
93
|
-
*/
|
|
94
|
-
function reset(name, requestOptions) {
|
|
76
|
+
function reset(name, optionsOrRequestOptions, maybeRequestOptions) {
|
|
95
77
|
const apiClient = v3_1.apiClientManager.clientOrThrow();
|
|
78
|
+
const { keyOptions, requestOptions } = splitKeyOptions(optionsOrRequestOptions, maybeRequestOptions);
|
|
96
79
|
const $requestOptions = (0, v3_1.mergeRequestOptions)({
|
|
97
80
|
tracer: tracer_js_1.tracer,
|
|
98
81
|
name: "concurrencyLimits.reset()",
|
|
99
82
|
icon: "queue",
|
|
100
|
-
attributes: {
|
|
101
|
-
...(0, v3_1.flattenAttributes)({ name }),
|
|
102
|
-
...(0, v3_1.accessoryAttributes)({
|
|
103
|
-
items: [{ text: name, variant: "normal" }],
|
|
104
|
-
style: "codepath",
|
|
105
|
-
}),
|
|
106
|
-
},
|
|
83
|
+
attributes: limitAttributes(name, keyOptions ? { concurrencyKey: keyOptions.concurrencyKey } : {}),
|
|
107
84
|
}, requestOptions);
|
|
85
|
+
if (keyOptions) {
|
|
86
|
+
return apiClient.resetConcurrencyLimitKey(name, { concurrencyKey: keyOptions.concurrencyKey }, $requestOptions);
|
|
87
|
+
}
|
|
108
88
|
return apiClient.resetConcurrencyLimit(name, $requestOptions);
|
|
109
89
|
}
|
|
110
90
|
/**
|
|
@@ -125,13 +105,7 @@ function pause(name, requestOptions) {
|
|
|
125
105
|
tracer: tracer_js_1.tracer,
|
|
126
106
|
name: "concurrencyLimits.pause()",
|
|
127
107
|
icon: "queue",
|
|
128
|
-
attributes:
|
|
129
|
-
...(0, v3_1.flattenAttributes)({ name }),
|
|
130
|
-
...(0, v3_1.accessoryAttributes)({
|
|
131
|
-
items: [{ text: name, variant: "normal" }],
|
|
132
|
-
style: "codepath",
|
|
133
|
-
}),
|
|
134
|
-
},
|
|
108
|
+
attributes: limitAttributes(name),
|
|
135
109
|
}, requestOptions);
|
|
136
110
|
return apiClient.pauseConcurrencyLimit(name, "pause", $requestOptions);
|
|
137
111
|
}
|
|
@@ -153,13 +127,7 @@ function resume(name, requestOptions) {
|
|
|
153
127
|
tracer: tracer_js_1.tracer,
|
|
154
128
|
name: "concurrencyLimits.resume()",
|
|
155
129
|
icon: "queue",
|
|
156
|
-
attributes:
|
|
157
|
-
...(0, v3_1.flattenAttributes)({ name }),
|
|
158
|
-
...(0, v3_1.accessoryAttributes)({
|
|
159
|
-
items: [{ text: name, variant: "normal" }],
|
|
160
|
-
style: "codepath",
|
|
161
|
-
}),
|
|
162
|
-
},
|
|
130
|
+
attributes: limitAttributes(name),
|
|
163
131
|
}, requestOptions);
|
|
164
132
|
return apiClient.pauseConcurrencyLimit(name, "resume", $requestOptions);
|
|
165
133
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"concurrencyLimits.js","sourceRoot":"","sources":["../../../src/v3/concurrencyLimits.ts"],"names":[],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"concurrencyLimits.js","sourceRoot":"","sources":["../../../src/v3/concurrencyLimits.ts"],"names":[],"mappings":";;;;;;;;AAWA,6CAK8B;AAC9B,2CAAqC;AAQrC;;;;GAIG;AACH,SAAS,eAAe,CACtB,KAAwC,EACxC,MAAqC;IAErC,IAAI,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
|
|
|
24
24
|
import type { ApiClientConfiguration, TaskRunContext } from "@trigger.dev/core/v3";
|
|
25
25
|
export type { ApiClientConfiguration, TaskRunContext };
|
|
26
26
|
export { ApiError, AuthenticationError, BadRequestError, ConflictError, InternalServerError, NotFoundError, PermissionDeniedError, RateLimitError, UnprocessableEntityError, AbortTaskRunError, OutOfMemoryError, CompleteTaskWithOutput, ChatChunkTooLargeError, isChatChunkTooLargeError, logger, type LogLevel, } from "@trigger.dev/core/v3";
|
|
27
|
-
export { runs, type RunShape, type AnyRunShape, type TaskRunShape, type RealtimeRun, type AnyRealtimeRun, type RetrieveRunResult, type AnyRetrieveRunResult, type BulkAction, } from "./runs.js";
|
|
27
|
+
export { runs, type RunShape, type AnyRunShape, type TaskRunShape, type RealtimeRun, type AnyRealtimeRun, type RetrieveRunResult, type AnyRetrieveRunResult, type BulkAction, type ReplayRunOptions, } from "./runs.js";
|
|
28
28
|
export * as schedules from "./schedules/index.js";
|
|
29
29
|
export { deployments, type RetrieveCurrentDeploymentResponseBody, type ApiDeploymentListResponseItem, } from "./deployments.js";
|
|
30
30
|
export * as envvars from "./envvars.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/v3/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,8CAA4B;AAC5B,uCAAsD;AAA7C,iGAAA,KAAK,OAAA;AACd,yCAAyE;AAAhE,kGAAA,KAAK,OAAA;AAAE,6GAAA,gBAAgB,OAAA;AAAE,8GAAA,iBAAiB,OAAA;AACnD,6CAA2B;AAC3B,6CAA2B;AAC3B,4CAA0B;AAC1B,iDAA+B;AAC/B,6CAA2B;AAC3B,uDAAqC;AACrC,4CAA0B;AAC1B,gDAA8B;AAC9B,+CAA6B;AAC7B,gDAA8B;AAC9B,8CAA4B;AAC5B,4CAA0B;AAC1B,+CAA6B;AAC7B,kDAAgC;AAChC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OAAA;AACd,8GAAA,wBAAwB,OAAA;AACxB,uGAAA,iBAAiB,OAAA;AACjB,sGAAA,gBAAgB,OAAA;AAChB,4GAAA,sBAAsB,OAAA;AACtB,4GAAA,sBAAsB,OAAA;AACtB,8GAAA,wBAAwB,OAAA;AACxB,4FAAA,MAAM,OAAA;AAIR,qCAWmB;AAVjB,+FAAA,IAAI,OAAA;AAWN,QAAY,SAAS,iDAA6B;AAClD,mDAI0B;AAHxB,6GAAA,WAAW,OAAA;AAIb,QAAY,OAAO,yCAAqB;AACxC,QAAY,MAAM,wCAAoB;AACtC,QAAY,iBAAiB,mDAA+B;AAG5D,qCAA4C;AAAnC,oGAAA,SAAS,OAAA;AAAE,+FAAA,IAAI,OAAA;AACxB,uDAA6E;AAApE,iHAAA,aAAa,OAAA;AACtB,QAAY,OAAO,yCAAqB;AACxC,QAAY,MAAM,wCAAoB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AnyRetrieveRunResult, AnyRunShape, ApiRequestOptions, CreateBulkCancelActionOptions, CreateBulkReplayActionOptions, InferRunTypes, ListBulkActionsQueryParams, ListProjectRunsQueryParams, ListRunsQueryParams, RescheduleRunRequestBody, RetrieveRunResult, RunShape, RealtimeRun, AnyRealtimeRun, RunSubscription, TaskRunShape, AnyBatchedRunHandle, AsyncIterableStream, ApiPromise, RealtimeRunSkipColumns, AbortBulkActionResponseBody, BulkActionObject, CanceledRunResponse, CreateBulkActionResponseBody, CursorPagePromise, ListRunResponseItem, ReplayRunResponse, RetrieveRunResponse } from "@trigger.dev/core/v3";
|
|
1
|
+
import type { AnyRetrieveRunResult, AnyRunShape, ApiRequestOptions, CreateBulkCancelActionOptions, CreateBulkReplayActionOptions, InferRunTypes, ListBulkActionsQueryParams, ListProjectRunsQueryParams, ListRunsQueryParams, RescheduleRunRequestBody, RetrieveRunResult, RunShape, RealtimeRun, AnyRealtimeRun, RunSubscription, TaskRunShape, AnyBatchedRunHandle, AsyncIterableStream, ApiPromise, RealtimeRunSkipColumns, AbortBulkActionResponseBody, BulkActionObject, CanceledRunResponse, CreateBulkActionResponseBody, CursorPagePromise, IdempotencyKey, ListRunResponseItem, ReplayRunResponse, RetrieveRunResponse, TriggerOptions } from "@trigger.dev/core/v3";
|
|
2
2
|
import type { AnyRunHandle, AnyTask } from "./shared.js";
|
|
3
3
|
export type { AnyRetrieveRunResult, AnyRunShape, RetrieveRunResult, RunShape, TaskRunShape, RealtimeRun, AnyRealtimeRun, };
|
|
4
4
|
export declare const runs: {
|
|
@@ -26,6 +26,27 @@ declare function listRuns(projectRef: string, params?: ListProjectRunsQueryParam
|
|
|
26
26
|
declare function listRuns(params?: ListRunsQueryParams, requestOptions?: ApiRequestOptions): CursorPagePromise<typeof ListRunResponseItem>;
|
|
27
27
|
type RunId<TRunId> = TRunId extends AnyRunHandle | AnyBatchedRunHandle ? TRunId : TRunId extends AnyTask ? string : TRunId extends string ? TRunId : never;
|
|
28
28
|
declare function retrieveRun<TRunId extends AnyRunHandle | AnyBatchedRunHandle | AnyTask | string>(runId: RunId<TRunId>, requestOptions?: ApiRequestOptions): ApiPromise<RetrieveRunResult<TRunId>>;
|
|
29
|
+
export type ReplayRunOptions = Pick<TriggerOptions, "metadata" | "tags" | "queue" | "concurrencyKey" | "machine" | "version" | "region" | "delay" | "ttl" | "idempotencyKeyTTL" | "maxAttempts" | "maxDuration" | "priority"> & {
|
|
30
|
+
/**
|
|
31
|
+
* The payload for the new run. Omit it to reuse the original run's payload.
|
|
32
|
+
*/
|
|
33
|
+
payload?: unknown;
|
|
34
|
+
/**
|
|
35
|
+
* An idempotency key for the new run. A plain string is used as-is: unlike `trigger()`, it is
|
|
36
|
+
* not scoped to the current run. Use `idempotencyKeys.create()` for a scoped key.
|
|
37
|
+
*/
|
|
38
|
+
idempotencyKey?: IdempotencyKey | string;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Replays a run: creates a new run of the same task from the original run's payload and options.
|
|
42
|
+
* Pass `options` to override any of them for the new run.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* const { id } = await runs.replay("run_1234", { payload: { userId: "123" }, delay: "1h" });
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
declare function replayRun(runId: string, options?: ReplayRunOptions, requestOptions?: ApiRequestOptions): ApiPromise<ReplayRunResponse>;
|
|
29
50
|
declare function replayRun(runId: string, requestOptions?: ApiRequestOptions): ApiPromise<ReplayRunResponse>;
|
|
30
51
|
declare function cancelRun(runId: string, requestOptions?: ApiRequestOptions): ApiPromise<CanceledRunResponse>;
|
|
31
52
|
declare function bulkCancelRuns(options: CreateBulkCancelActionOptions, requestOptions?: ApiRequestOptions): ApiPromise<CreateBulkActionResponseBody>;
|
package/dist/commonjs/v3/runs.js
CHANGED
|
@@ -129,8 +129,11 @@ async function resolvePayloadAndOutputUrls(run) {
|
|
|
129
129
|
}
|
|
130
130
|
return resolvedRun;
|
|
131
131
|
}
|
|
132
|
-
function replayRun(runId, requestOptions) {
|
|
132
|
+
function replayRun(runId, optionsOrRequestOptions, requestOptions) {
|
|
133
133
|
const apiClient = v3_1.apiClientManager.clientOrThrow();
|
|
134
|
+
const options = (0, v3_1.isRequestOptions)(optionsOrRequestOptions)
|
|
135
|
+
? undefined
|
|
136
|
+
: optionsOrRequestOptions;
|
|
134
137
|
const $requestOptions = (0, v3_1.mergeRequestOptions)({
|
|
135
138
|
tracer: tracer_js_1.tracer,
|
|
136
139
|
name: "runs.replay()",
|
|
@@ -147,8 +150,8 @@ function replayRun(runId, requestOptions) {
|
|
|
147
150
|
style: "codepath",
|
|
148
151
|
}),
|
|
149
152
|
},
|
|
150
|
-
}, requestOptions);
|
|
151
|
-
return apiClient.replayRun(runId, $requestOptions);
|
|
153
|
+
}, (0, v3_1.isRequestOptions)(optionsOrRequestOptions) ? optionsOrRequestOptions : requestOptions);
|
|
154
|
+
return apiClient.replayRun(runId, options, $requestOptions);
|
|
152
155
|
}
|
|
153
156
|
function cancelRun(runId, requestOptions) {
|
|
154
157
|
const apiClient = v3_1.apiClientManager.clientOrThrow();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runs.js","sourceRoot":"","sources":["../../../src/v3/runs.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"runs.js","sourceRoot":"","sources":["../../../src/v3/runs.ts"],"names":[],"mappings":";;;AAgCA,6CAM8B;AAC9B,gFAAuF;AAEvF,2CAAqC;AAYxB,QAAA,IAAI,GAAG;IAClB,MAAM,EAAE,SAAS;IACjB,MAAM,EAAE,SAAS;IACjB,QAAQ,EAAE,WAAW;IACrB,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE,aAAa;IACzB,IAAI,EAAE;QACJ,MAAM,EAAE,cAAc;QACtB,MAAM,EAAE,cAAc;QACtB,QAAQ,EAAE,kBAAkB;QAC5B,KAAK,EAAE,eAAe;QACtB,IAAI,EAAE,eAAe;QACrB,IAAI,EAAE,cAAc;KACrB;IACD,IAAI;IACJ,cAAc;IACd,sBAAsB;IACtB,gBAAgB,EAAE,sBAAsB;IACxC,WAAW;CACZ,CAAC;AAaF,SAAS,QAAQ,CACf,kBAAiD,EACjD,eAAsF,EACtF,cAAkC;IAElC,MAAM,SAAS,GAAG,qBAAgB,CAAC,aAAa,EAAE,CAAC;IAEnD,MAAM,eAAe,GAAG,sBAAsB,CAC5C,kBAAkB,EAClB,eAAe,EACf,cAAc,CACf,CAAC;IAEF,IAAI,OAAO,kBAAkB,KAAK,QAAQ,EAAE,CAAC;QAC3C,IAAI,IAAA,qBAAgB,EAAC,eAAe,CAAC,EAAE,CAAC;YACtC,OAAO,SAAS,CAAC,eAAe,CAAC,kBAAkB,EAAE,EAAE,EAAE,eAAe,CAAC,CAAC;QAC5E,CAAC;aAAM,CAAC;YACN,OAAO,SAAS,CAAC,eAAe,CAAC,kBAAkB,EAAE,eAAe,EAAE,eAAe,CAAC,CAAC;QACzF,CAAC;IACH,CAAC;IAED,OAAO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EAAE,CAAC;IAEnD,OAAO,SAAS,CAAC,cAAc,CAAC,MAAM,EAAE;QACtC,eAAe,EACb,OAAO,OAAO,EAAE,gBAAgB,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,IAAI;QAClF,WAAW,EAAE,OAAO,EAAE,WAAW;QACjC,MAAM,EAAE,OAAO,EAAE,MAAM;KACxB,CAAC,CAAC;AACL,CAAC;AA4BD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,SAAS,sBAAsB,CAC7B,GAAsB,EACtB,OAAsC,EACtC,OAAkC;IAElC,MAAM,SAAS,GAAG,qBAAgB,CAAC,aAAa,EAAE,CAAC;IAEnD,OAAO,SAAS,CAAC,sBAAsB,CAAwB,GAAG,EAAE,OAAO,EAAE;QAC3E,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC/C,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,SAAS,sBAAsB,CAC7B,OAAe;IAEf,MAAM,SAAS,GAAG,qBAAgB,CAAC,aAAa,EAAE,CAAC;IAEnD,OAAO,SAAS,CAAC,gBAAgB,CAAwB,OAAO,CAAC,CAAC;AACpE,CAAC;AAED;;GAEG;AACH,KAAK,UAAU,WAAW,CAAI,KAAa,EAAE,SAAiB;IAC5D,MAAM,SAAS,GAAG,qBAAgB,CAAC,aAAa,EAAE,CAAC;IAEnD,OAAO,MAAM,SAAS,CAAC,WAAW,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;AACvD,CAAC"}
|
package/dist/commonjs/version.js
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import type { ApiPromise, ApiRequestOptions, ConcurrencyLimitItem, ListConcurrencyLimitOptions, OffsetLimitPagePromise, OverrideConcurrencyLimitRequestBody } from "@trigger.dev/core/v3";
|
|
1
|
+
import type { ApiPromise, ApiRequestOptions, ConcurrencyLimitItem, ConcurrencyLimitKeyItem, ListConcurrencyLimitOptions, OffsetLimitPagePromise, OverrideConcurrencyLimitBoundsBody, OverrideConcurrencyLimitKeyBody, OverrideConcurrencyLimitRequestBody } from "@trigger.dev/core/v3";
|
|
2
|
+
/** Options that address one concurrencyKey of a limit. */
|
|
3
|
+
export type ConcurrencyLimitKeyOptions = {
|
|
4
|
+
/** The concurrencyKey whose view, or whose override, the call is about. */
|
|
5
|
+
concurrencyKey: string;
|
|
6
|
+
};
|
|
2
7
|
/**
|
|
3
8
|
* Lists the environment's named concurrency limits (anonymous inline limits appear
|
|
4
9
|
* under their derived `task/<taskId>` names).
|
|
@@ -10,17 +15,23 @@ import type { ApiPromise, ApiRequestOptions, ConcurrencyLimitItem, ListConcurren
|
|
|
10
15
|
*/
|
|
11
16
|
export declare function list(options?: ListConcurrencyLimitOptions, requestOptions?: ApiRequestOptions): OffsetLimitPagePromise<typeof ConcurrencyLimitItem>;
|
|
12
17
|
/**
|
|
13
|
-
* Retrieves a concurrency limit by name
|
|
18
|
+
* Retrieves a concurrency limit by name, or, with `{ concurrencyKey }`, the limit's
|
|
19
|
+
* view for one key: its per-key bound (including any override and when it expires)
|
|
20
|
+
* and the runs executing for that key.
|
|
14
21
|
*
|
|
15
22
|
* @example
|
|
16
23
|
*
|
|
17
24
|
* ```ts
|
|
18
25
|
* const limit = await concurrencyLimits.retrieve("openai");
|
|
19
26
|
* console.log(limit.running, limit.queued, limit.total.current);
|
|
27
|
+
*
|
|
28
|
+
* const session = await concurrencyLimits.retrieve("subagents", { concurrencyKey: sessionId });
|
|
29
|
+
* console.log(session.perKey.override, session.perKey.expiresAt);
|
|
20
30
|
* ```
|
|
21
31
|
* @param name - The limit's name, as declared with `concurrencyLimit()`
|
|
22
|
-
* @returns The concurrency limit
|
|
32
|
+
* @returns The concurrency limit, or its view for the given key
|
|
23
33
|
*/
|
|
34
|
+
export declare function retrieve(name: string, options: ConcurrencyLimitKeyOptions, requestOptions?: ApiRequestOptions): ApiPromise<ConcurrencyLimitKeyItem>;
|
|
24
35
|
export declare function retrieve(name: string, requestOptions?: ApiRequestOptions): ApiPromise<ConcurrencyLimitItem>;
|
|
25
36
|
/**
|
|
26
37
|
* Overrides a concurrency limit's bounds. Only the given fields change; the
|
|
@@ -28,22 +39,41 @@ export declare function retrieve(name: string, requestOptions?: ApiRequestOption
|
|
|
28
39
|
* holding a limit, prefer `pause` (it keeps the configured bounds); overriding
|
|
29
40
|
* `total` to `0` also blocks every run holding the limit.
|
|
30
41
|
*
|
|
42
|
+
* With `concurrencyKey`, the override is a temporary per-key cap for that one key:
|
|
43
|
+
* it replaces the limit's `perKey` for the key, applies to every task holding the
|
|
44
|
+
* limit, and expires after `ttl` (default 7 days, at most 30 days). The limit itself
|
|
45
|
+
* is untouched, and other keys keep the declared `perKey`.
|
|
46
|
+
*
|
|
31
47
|
* @example
|
|
32
48
|
*
|
|
33
49
|
* ```ts
|
|
34
50
|
* await concurrencyLimits.override("openai", { total: 50 });
|
|
51
|
+
*
|
|
52
|
+
* // this session may run 3 sub-agents at once, for the next 7 days
|
|
53
|
+
* await concurrencyLimits.override("subagents", { concurrencyKey: sessionId, perKey: 3 });
|
|
35
54
|
* ```
|
|
36
55
|
* @param name - The limit's name
|
|
37
|
-
* @param override - The bounds to change (`perKey` and/or `total`)
|
|
38
|
-
* @returns The updated concurrency limit
|
|
56
|
+
* @param override - The bounds to change (`perKey` and/or `total`), or `concurrencyKey` with the key's `perKey` cap (and optional `ttl`)
|
|
57
|
+
* @returns The updated concurrency limit, or the key's view when `concurrencyKey` was given
|
|
39
58
|
*/
|
|
40
|
-
export declare function override(name: string, override:
|
|
59
|
+
export declare function override(name: string, override: OverrideConcurrencyLimitKeyBody, requestOptions?: ApiRequestOptions): ApiPromise<ConcurrencyLimitKeyItem>;
|
|
60
|
+
export declare function override(name: string, override: OverrideConcurrencyLimitBoundsBody, requestOptions?: ApiRequestOptions): ApiPromise<ConcurrencyLimitItem>;
|
|
61
|
+
export declare function override(name: string, override: OverrideConcurrencyLimitRequestBody, requestOptions?: ApiRequestOptions): ApiPromise<ConcurrencyLimitItem | ConcurrencyLimitKeyItem>;
|
|
41
62
|
/**
|
|
42
63
|
* Resets a concurrency limit back to its declared values, clearing any override.
|
|
64
|
+
* With `{ concurrencyKey }`, clears that key's override instead and leaves the
|
|
65
|
+
* limit itself alone.
|
|
43
66
|
*
|
|
67
|
+
* @example
|
|
68
|
+
*
|
|
69
|
+
* ```ts
|
|
70
|
+
* await concurrencyLimits.reset("openai");
|
|
71
|
+
* await concurrencyLimits.reset("subagents", { concurrencyKey: sessionId });
|
|
72
|
+
* ```
|
|
44
73
|
* @param name - The limit's name
|
|
45
|
-
* @returns The updated concurrency limit
|
|
74
|
+
* @returns The updated concurrency limit, or the key's view when `concurrencyKey` was given
|
|
46
75
|
*/
|
|
76
|
+
export declare function reset(name: string, options: ConcurrencyLimitKeyOptions, requestOptions?: ApiRequestOptions): ApiPromise<ConcurrencyLimitKeyItem>;
|
|
47
77
|
export declare function reset(name: string, requestOptions?: ApiRequestOptions): ApiPromise<ConcurrencyLimitItem>;
|
|
48
78
|
/**
|
|
49
79
|
* Pauses a concurrency limit. Nothing holding the limit is admitted until it is
|
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
import { accessoryAttributes, apiClientManager, flattenAttributes, mergeRequestOptions, } from "@trigger.dev/core/v3";
|
|
2
2
|
import { tracer } from "./tracer.js";
|
|
3
|
+
/**
|
|
4
|
+
* `retrieve` and `reset` take an optional key-options object before the request
|
|
5
|
+
* options. The two are told apart by the `concurrencyKey` property, so existing
|
|
6
|
+
* callers that pass request options in the second position keep working.
|
|
7
|
+
*/
|
|
8
|
+
function splitKeyOptions(first, second) {
|
|
9
|
+
if (first && typeof first === "object" && "concurrencyKey" in first) {
|
|
10
|
+
return { keyOptions: first, requestOptions: second };
|
|
11
|
+
}
|
|
12
|
+
return { keyOptions: undefined, requestOptions: first };
|
|
13
|
+
}
|
|
14
|
+
function limitAttributes(name, extra = {}) {
|
|
15
|
+
return {
|
|
16
|
+
...flattenAttributes({ name, ...extra }),
|
|
17
|
+
...accessoryAttributes({
|
|
18
|
+
items: [{ text: name, variant: "normal" }],
|
|
19
|
+
style: "codepath",
|
|
20
|
+
}),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
3
23
|
/**
|
|
4
24
|
* Lists the environment's named concurrency limits (anonymous inline limits appear
|
|
5
25
|
* under their derived `task/<taskId>` names).
|
|
@@ -18,85 +38,45 @@ export function list(options, requestOptions) {
|
|
|
18
38
|
}, requestOptions);
|
|
19
39
|
return apiClient.listConcurrencyLimits(options, $requestOptions);
|
|
20
40
|
}
|
|
21
|
-
|
|
22
|
-
* Retrieves a concurrency limit by name.
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
*
|
|
26
|
-
* ```ts
|
|
27
|
-
* const limit = await concurrencyLimits.retrieve("openai");
|
|
28
|
-
* console.log(limit.running, limit.queued, limit.total.current);
|
|
29
|
-
* ```
|
|
30
|
-
* @param name - The limit's name, as declared with `concurrencyLimit()`
|
|
31
|
-
* @returns The concurrency limit
|
|
32
|
-
*/
|
|
33
|
-
export function retrieve(name, requestOptions) {
|
|
41
|
+
export function retrieve(name, optionsOrRequestOptions, maybeRequestOptions) {
|
|
34
42
|
const apiClient = apiClientManager.clientOrThrow();
|
|
43
|
+
const { keyOptions, requestOptions } = splitKeyOptions(optionsOrRequestOptions, maybeRequestOptions);
|
|
35
44
|
const $requestOptions = mergeRequestOptions({
|
|
36
45
|
tracer,
|
|
37
46
|
name: "concurrencyLimits.retrieve()",
|
|
38
47
|
icon: "queue",
|
|
39
|
-
attributes: {
|
|
40
|
-
...flattenAttributes({ name }),
|
|
41
|
-
...accessoryAttributes({
|
|
42
|
-
items: [{ text: name, variant: "normal" }],
|
|
43
|
-
style: "codepath",
|
|
44
|
-
}),
|
|
45
|
-
},
|
|
48
|
+
attributes: limitAttributes(name, keyOptions ? { concurrencyKey: keyOptions.concurrencyKey } : {}),
|
|
46
49
|
}, requestOptions);
|
|
50
|
+
if (keyOptions) {
|
|
51
|
+
return apiClient.retrieveConcurrencyLimitKey(name, keyOptions.concurrencyKey, $requestOptions);
|
|
52
|
+
}
|
|
47
53
|
return apiClient.retrieveConcurrencyLimit(name, $requestOptions);
|
|
48
54
|
}
|
|
49
|
-
/**
|
|
50
|
-
* Overrides a concurrency limit's bounds. Only the given fields change; the
|
|
51
|
-
* declared values are kept as the base and restored by `reset`. To stop runs
|
|
52
|
-
* holding a limit, prefer `pause` (it keeps the configured bounds); overriding
|
|
53
|
-
* `total` to `0` also blocks every run holding the limit.
|
|
54
|
-
*
|
|
55
|
-
* @example
|
|
56
|
-
*
|
|
57
|
-
* ```ts
|
|
58
|
-
* await concurrencyLimits.override("openai", { total: 50 });
|
|
59
|
-
* ```
|
|
60
|
-
* @param name - The limit's name
|
|
61
|
-
* @param override - The bounds to change (`perKey` and/or `total`)
|
|
62
|
-
* @returns The updated concurrency limit
|
|
63
|
-
*/
|
|
64
55
|
export function override(name, override, requestOptions) {
|
|
65
56
|
const apiClient = apiClientManager.clientOrThrow();
|
|
66
57
|
const $requestOptions = mergeRequestOptions({
|
|
67
58
|
tracer,
|
|
68
59
|
name: "concurrencyLimits.override()",
|
|
69
60
|
icon: "queue",
|
|
70
|
-
attributes: {
|
|
71
|
-
...flattenAttributes({ name, override }),
|
|
72
|
-
...accessoryAttributes({
|
|
73
|
-
items: [{ text: name, variant: "normal" }],
|
|
74
|
-
style: "codepath",
|
|
75
|
-
}),
|
|
76
|
-
},
|
|
61
|
+
attributes: limitAttributes(name, { override }),
|
|
77
62
|
}, requestOptions);
|
|
63
|
+
if (override.concurrencyKey !== undefined) {
|
|
64
|
+
return apiClient.overrideConcurrencyLimitKey(name, override, $requestOptions);
|
|
65
|
+
}
|
|
78
66
|
return apiClient.overrideConcurrencyLimit(name, override, $requestOptions);
|
|
79
67
|
}
|
|
80
|
-
|
|
81
|
-
* Resets a concurrency limit back to its declared values, clearing any override.
|
|
82
|
-
*
|
|
83
|
-
* @param name - The limit's name
|
|
84
|
-
* @returns The updated concurrency limit
|
|
85
|
-
*/
|
|
86
|
-
export function reset(name, requestOptions) {
|
|
68
|
+
export function reset(name, optionsOrRequestOptions, maybeRequestOptions) {
|
|
87
69
|
const apiClient = apiClientManager.clientOrThrow();
|
|
70
|
+
const { keyOptions, requestOptions } = splitKeyOptions(optionsOrRequestOptions, maybeRequestOptions);
|
|
88
71
|
const $requestOptions = mergeRequestOptions({
|
|
89
72
|
tracer,
|
|
90
73
|
name: "concurrencyLimits.reset()",
|
|
91
74
|
icon: "queue",
|
|
92
|
-
attributes: {
|
|
93
|
-
...flattenAttributes({ name }),
|
|
94
|
-
...accessoryAttributes({
|
|
95
|
-
items: [{ text: name, variant: "normal" }],
|
|
96
|
-
style: "codepath",
|
|
97
|
-
}),
|
|
98
|
-
},
|
|
75
|
+
attributes: limitAttributes(name, keyOptions ? { concurrencyKey: keyOptions.concurrencyKey } : {}),
|
|
99
76
|
}, requestOptions);
|
|
77
|
+
if (keyOptions) {
|
|
78
|
+
return apiClient.resetConcurrencyLimitKey(name, { concurrencyKey: keyOptions.concurrencyKey }, $requestOptions);
|
|
79
|
+
}
|
|
100
80
|
return apiClient.resetConcurrencyLimit(name, $requestOptions);
|
|
101
81
|
}
|
|
102
82
|
/**
|
|
@@ -117,13 +97,7 @@ export function pause(name, requestOptions) {
|
|
|
117
97
|
tracer,
|
|
118
98
|
name: "concurrencyLimits.pause()",
|
|
119
99
|
icon: "queue",
|
|
120
|
-
attributes:
|
|
121
|
-
...flattenAttributes({ name }),
|
|
122
|
-
...accessoryAttributes({
|
|
123
|
-
items: [{ text: name, variant: "normal" }],
|
|
124
|
-
style: "codepath",
|
|
125
|
-
}),
|
|
126
|
-
},
|
|
100
|
+
attributes: limitAttributes(name),
|
|
127
101
|
}, requestOptions);
|
|
128
102
|
return apiClient.pauseConcurrencyLimit(name, "pause", $requestOptions);
|
|
129
103
|
}
|
|
@@ -145,13 +119,7 @@ export function resume(name, requestOptions) {
|
|
|
145
119
|
tracer,
|
|
146
120
|
name: "concurrencyLimits.resume()",
|
|
147
121
|
icon: "queue",
|
|
148
|
-
attributes:
|
|
149
|
-
...flattenAttributes({ name }),
|
|
150
|
-
...accessoryAttributes({
|
|
151
|
-
items: [{ text: name, variant: "normal" }],
|
|
152
|
-
style: "codepath",
|
|
153
|
-
}),
|
|
154
|
-
},
|
|
122
|
+
attributes: limitAttributes(name),
|
|
155
123
|
}, requestOptions);
|
|
156
124
|
return apiClient.pauseConcurrencyLimit(name, "resume", $requestOptions);
|
|
157
125
|
}
|