@scenario-labs/sdk 2.2.1 → 2.4.0-alpha.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/CHANGELOG.md +35 -0
- package/client.d.mts.map +1 -1
- package/client.d.ts.map +1 -1
- package/client.js +9 -1
- package/client.js.map +1 -1
- package/client.mjs +9 -1
- package/client.mjs.map +1 -1
- package/index.d.mts +1 -0
- package/index.d.mts.map +1 -1
- package/index.d.ts +1 -0
- package/index.d.ts.map +1 -1
- package/index.js +3 -1
- package/index.js.map +1 -1
- package/index.mjs +1 -0
- package/index.mjs.map +1 -1
- package/lib/auth-refresh.d.mts +52 -0
- package/lib/auth-refresh.d.mts.map +1 -0
- package/lib/auth-refresh.d.ts +52 -0
- package/lib/auth-refresh.d.ts.map +1 -0
- package/lib/auth-refresh.js +81 -0
- package/lib/auth-refresh.js.map +1 -0
- package/lib/auth-refresh.mjs +78 -0
- package/lib/auth-refresh.mjs.map +1 -0
- package/lib/generate.js +7 -7
- package/lib/generate.js.map +1 -1
- package/lib/generate.mjs +7 -7
- package/lib/generate.mjs.map +1 -1
- package/lib/job.d.mts +15 -3
- package/lib/job.d.mts.map +1 -1
- package/lib/job.d.ts +15 -3
- package/lib/job.d.ts.map +1 -1
- package/lib/job.js +22 -8
- package/lib/job.js.map +1 -1
- package/lib/job.mjs +22 -8
- package/lib/job.mjs.map +1 -1
- package/lib/models.d.mts +8 -2
- package/lib/models.d.mts.map +1 -1
- package/lib/models.d.ts +8 -2
- package/lib/models.d.ts.map +1 -1
- package/lib/models.js +13 -5
- package/lib/models.js.map +1 -1
- package/lib/models.mjs +13 -5
- package/lib/models.mjs.map +1 -1
- package/lib/scenario.d.mts +28 -13
- package/lib/scenario.d.mts.map +1 -1
- package/lib/scenario.d.ts +28 -13
- package/lib/scenario.d.ts.map +1 -1
- package/lib/scenario.js +31 -12
- package/lib/scenario.js.map +1 -1
- package/lib/scenario.mjs +31 -12
- package/lib/scenario.mjs.map +1 -1
- package/lib/scope.d.mts +41 -0
- package/lib/scope.d.mts.map +1 -0
- package/lib/scope.d.ts +41 -0
- package/lib/scope.d.ts.map +1 -0
- package/lib/scope.js +55 -0
- package/lib/scope.js.map +1 -0
- package/lib/scope.mjs +49 -0
- package/lib/scope.mjs.map +1 -0
- package/lib/upload.d.mts +15 -3
- package/lib/upload.d.mts.map +1 -1
- package/lib/upload.d.ts +15 -3
- package/lib/upload.d.ts.map +1 -1
- package/lib/upload.js +29 -12
- package/lib/upload.js.map +1 -1
- package/lib/upload.mjs +29 -12
- package/lib/upload.mjs.map +1 -1
- package/lib/workflow.d.mts +8 -2
- package/lib/workflow.d.mts.map +1 -1
- package/lib/workflow.d.ts +8 -2
- package/lib/workflow.d.ts.map +1 -1
- package/lib/workflow.js +14 -6
- package/lib/workflow.js.map +1 -1
- package/lib/workflow.mjs +14 -6
- package/lib/workflow.mjs.map +1 -1
- package/lib/workflow_converter.d.mts +8 -2
- package/lib/workflow_converter.d.mts.map +1 -1
- package/lib/workflow_converter.d.ts +8 -2
- package/lib/workflow_converter.d.ts.map +1 -1
- package/lib/workflow_converter.js +83 -19
- package/lib/workflow_converter.js.map +1 -1
- package/lib/workflow_converter.mjs +83 -19
- package/lib/workflow_converter.mjs.map +1 -1
- package/lib/workflow_import_validator.d.mts +1 -1
- package/lib/workflow_import_validator.d.mts.map +1 -1
- package/lib/workflow_import_validator.d.ts +1 -1
- package/lib/workflow_import_validator.d.ts.map +1 -1
- package/lib/workflow_import_validator.js +1 -0
- package/lib/workflow_import_validator.js.map +1 -1
- package/lib/workflow_import_validator.mjs +1 -0
- package/lib/workflow_import_validator.mjs.map +1 -1
- package/package.json +9 -3
- package/resources/assets/assets.d.mts +1 -1
- package/resources/assets/assets.d.mts.map +1 -1
- package/resources/assets/assets.d.ts +1 -1
- package/resources/assets/assets.d.ts.map +1 -1
- package/resources/generate.d.mts +594 -10
- package/resources/generate.d.mts.map +1 -1
- package/resources/generate.d.ts +594 -10
- package/resources/generate.d.ts.map +1 -1
- package/resources/generate.js +2 -2
- package/resources/generate.js.map +1 -1
- package/resources/generate.mjs +2 -2
- package/resources/generate.mjs.map +1 -1
- package/resources/jobs.d.mts +3 -3
- package/resources/jobs.d.mts.map +1 -1
- package/resources/jobs.d.ts +3 -3
- package/resources/jobs.d.ts.map +1 -1
- package/resources/models/examples.d.mts +2 -2
- package/resources/models/examples.d.mts.map +1 -1
- package/resources/models/examples.d.ts +2 -2
- package/resources/models/examples.d.ts.map +1 -1
- package/resources/models/models.d.mts +126 -7
- package/resources/models/models.d.mts.map +1 -1
- package/resources/models/models.d.ts +126 -7
- package/resources/models/models.d.ts.map +1 -1
- package/resources/models/models.js.map +1 -1
- package/resources/models/models.mjs.map +1 -1
- package/resources/models/train.d.mts +106 -3
- package/resources/models/train.d.mts.map +1 -1
- package/resources/models/train.d.ts +106 -3
- package/resources/models/train.d.ts.map +1 -1
- package/resources/usages.d.mts +23 -3
- package/resources/usages.d.mts.map +1 -1
- package/resources/usages.d.ts +23 -3
- package/resources/usages.d.ts.map +1 -1
- package/resources/workflows.d.mts +22 -5
- package/resources/workflows.d.mts.map +1 -1
- package/resources/workflows.d.ts +22 -5
- package/resources/workflows.d.ts.map +1 -1
- package/resources/workflows.js +4 -1
- package/resources/workflows.js.map +1 -1
- package/resources/workflows.mjs +4 -1
- package/resources/workflows.mjs.map +1 -1
- package/src/client.ts +9 -1
- package/src/index.ts +1 -0
- package/src/lib/auth-refresh.ts +98 -0
- package/src/lib/generate.ts +7 -7
- package/src/lib/job.ts +29 -7
- package/src/lib/models.ts +14 -4
- package/src/lib/scenario.ts +51 -13
- package/src/lib/scope.ts +68 -0
- package/src/lib/upload.ts +36 -11
- package/src/lib/workflow.ts +15 -5
- package/src/lib/workflow_converter.ts +128 -19
- package/src/lib/workflow_import_validator.ts +3 -1
- package/src/resources/assets/assets.ts +1 -1
- package/src/resources/generate.ts +713 -12
- package/src/resources/jobs.ts +3 -3
- package/src/resources/models/examples.ts +2 -2
- package/src/resources/models/models.ts +189 -7
- package/src/resources/models/train.ts +138 -3
- package/src/resources/usages.ts +27 -1
- package/src/resources/workflows.ts +24 -5
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.mts.map +1 -1
- package/version.d.ts +1 -1
- package/version.d.ts.map +1 -1
- package/version.js +1 -1
- package/version.js.map +1 -1
- package/version.mjs +1 -1
- package/version.mjs.map +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-refresh.d.ts","sourceRoot":"","sources":["../src/lib/auth-refresh.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,EACrC,OAAO,CAAC,EAAE,oBAAoB,GAC7B,OAAO,KAAK,CA2Cd;AAED,MAAM,WAAW,oBAAoB;IACnC;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;OAIG;IACH,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;CACtB"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withBearerRefresh = withBearerRefresh;
|
|
4
|
+
/**
|
|
5
|
+
* Wrap `fetch` so that AWS API Gateway authorizer rejections (i.e. expired
|
|
6
|
+
* bearer JWTs) automatically trigger a refresh + retry.
|
|
7
|
+
*
|
|
8
|
+
* Use case: bearer (JWT) auth only. Clerk session tokens default to ~60s
|
|
9
|
+
* validity, so any single SDK call that outlives that window — typically a
|
|
10
|
+
* `.wait()` poll on a long job, or a slow `uploadFile()` — risks getting a
|
|
11
|
+
* 403 mid-flight even though the user is still authenticated. This wrapper
|
|
12
|
+
* intercepts those 403s, calls a caller-provided refresh callback to mint a
|
|
13
|
+
* fresh JWT, and retries the same request transparently.
|
|
14
|
+
*
|
|
15
|
+
* Not applicable to API-key auth: API keys are long-lived credentials and
|
|
16
|
+
* don't expire mid-session.
|
|
17
|
+
*
|
|
18
|
+
* Detection: AWS API Gateway sets `x-amzn-errortype: AccessDeniedException`
|
|
19
|
+
* on authorizer rejections. Real downstream permission denials return 403
|
|
20
|
+
* *without* that header — those are propagated unchanged so we don't refresh
|
|
21
|
+
* pointlessly on a genuine "you don't have access" response.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* import { Scenario, withBearerRefresh } from '@scenario-labs/sdk';
|
|
26
|
+
*
|
|
27
|
+
* const client = new Scenario({
|
|
28
|
+
* bearerAuth: initialJwt,
|
|
29
|
+
* fetch: withBearerRefresh(async () => {
|
|
30
|
+
* // app-specific: re-mint a JWT from Clerk, your IdP, etc.
|
|
31
|
+
* return await mintFreshJwt();
|
|
32
|
+
* }),
|
|
33
|
+
* });
|
|
34
|
+
*
|
|
35
|
+
* // Long-running poll — JWT can expire mid-flight, wrapper handles it:
|
|
36
|
+
* const job = await client.workflows.run(wfId, { body }).then(r => r.job);
|
|
37
|
+
* const completed = await job.wait({ timeoutMs: 600_000 });
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
function withBearerRefresh(refresh, options) {
|
|
41
|
+
const inner = options?.fetch ?? globalThis.fetch;
|
|
42
|
+
const maxRefreshes = options?.maxRefreshes ?? 2;
|
|
43
|
+
let refreshCount = 0;
|
|
44
|
+
// Concurrent requests that all hit a gateway 403 must share a single
|
|
45
|
+
// refresh — otherwise each call mints its own JWT, wastes the refresh
|
|
46
|
+
// budget, and risks token-version races. We coalesce them onto one
|
|
47
|
+
// in-flight promise (single-flight).
|
|
48
|
+
let inflightRefresh = null;
|
|
49
|
+
return async (input, init) => {
|
|
50
|
+
const response = await inner(input, init);
|
|
51
|
+
const isAuthorizerReject = response.status === 403 && response.headers.get('x-amzn-errortype') === 'AccessDeniedException';
|
|
52
|
+
if (!isAuthorizerReject)
|
|
53
|
+
return response;
|
|
54
|
+
// Budget only blocks NEW refreshes — followers awaiting an in-flight
|
|
55
|
+
// refresh aren't paying for it, so let them through.
|
|
56
|
+
if (refreshCount >= maxRefreshes && inflightRefresh === null)
|
|
57
|
+
return response;
|
|
58
|
+
if (inflightRefresh === null) {
|
|
59
|
+
// Leader for this round: charge the budget now (not on result) so
|
|
60
|
+
// followers awaiting the same promise don't each increment.
|
|
61
|
+
refreshCount += 1;
|
|
62
|
+
inflightRefresh = refresh().finally(() => {
|
|
63
|
+
inflightRefresh = null;
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
const freshJwt = await inflightRefresh;
|
|
67
|
+
if (!freshJwt) {
|
|
68
|
+
// Refresh failed — propagate the original 403 with its body intact so
|
|
69
|
+
// the SDK / caller can still read the error message. Draining here
|
|
70
|
+
// would leave them with an empty/closed stream.
|
|
71
|
+
return response;
|
|
72
|
+
}
|
|
73
|
+
// Refresh succeeded; we're about to retry. Drain the rejected response's
|
|
74
|
+
// body so we don't leak the underlying socket.
|
|
75
|
+
response.body?.cancel().catch(() => undefined);
|
|
76
|
+
const newHeaders = new Headers(init?.headers);
|
|
77
|
+
newHeaders.set('Authorization', `Bearer ${freshJwt}`);
|
|
78
|
+
return inner(input, { ...init, headers: newHeaders });
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=auth-refresh.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-refresh.js","sourceRoot":"","sources":["../src/lib/auth-refresh.ts"],"names":[],"mappings":";;AAoCA,8CA8CC;AAlFD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,SAAgB,iBAAiB,CAC/B,OAAqC,EACrC,OAA8B;IAE9B,MAAM,KAAK,GAAG,OAAO,EAAE,KAAK,IAAI,UAAU,CAAC,KAAK,CAAC;IACjD,MAAM,YAAY,GAAG,OAAO,EAAE,YAAY,IAAI,CAAC,CAAC;IAChD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AK,CAAC,KAAK,EAAE,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,CAAC;IACxD,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wrap `fetch` so that AWS API Gateway authorizer rejections (i.e. expired
|
|
3
|
+
* bearer JWTs) automatically trigger a refresh + retry.
|
|
4
|
+
*
|
|
5
|
+
* Use case: bearer (JWT) auth only. Clerk session tokens default to ~60s
|
|
6
|
+
* validity, so any single SDK call that outlives that window — typically a
|
|
7
|
+
* `.wait()` poll on a long job, or a slow `uploadFile()` — risks getting a
|
|
8
|
+
* 403 mid-flight even though the user is still authenticated. This wrapper
|
|
9
|
+
* intercepts those 403s, calls a caller-provided refresh callback to mint a
|
|
10
|
+
* fresh JWT, and retries the same request transparently.
|
|
11
|
+
*
|
|
12
|
+
* Not applicable to API-key auth: API keys are long-lived credentials and
|
|
13
|
+
* don't expire mid-session.
|
|
14
|
+
*
|
|
15
|
+
* Detection: AWS API Gateway sets `x-amzn-errortype: AccessDeniedException`
|
|
16
|
+
* on authorizer rejections. Real downstream permission denials return 403
|
|
17
|
+
* *without* that header — those are propagated unchanged so we don't refresh
|
|
18
|
+
* pointlessly on a genuine "you don't have access" response.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* import { Scenario, withBearerRefresh } from '@scenario-labs/sdk';
|
|
23
|
+
*
|
|
24
|
+
* const client = new Scenario({
|
|
25
|
+
* bearerAuth: initialJwt,
|
|
26
|
+
* fetch: withBearerRefresh(async () => {
|
|
27
|
+
* // app-specific: re-mint a JWT from Clerk, your IdP, etc.
|
|
28
|
+
* return await mintFreshJwt();
|
|
29
|
+
* }),
|
|
30
|
+
* });
|
|
31
|
+
*
|
|
32
|
+
* // Long-running poll — JWT can expire mid-flight, wrapper handles it:
|
|
33
|
+
* const job = await client.workflows.run(wfId, { body }).then(r => r.job);
|
|
34
|
+
* const completed = await job.wait({ timeoutMs: 600_000 });
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export function withBearerRefresh(refresh, options) {
|
|
38
|
+
const inner = options?.fetch ?? globalThis.fetch;
|
|
39
|
+
const maxRefreshes = options?.maxRefreshes ?? 2;
|
|
40
|
+
let refreshCount = 0;
|
|
41
|
+
// Concurrent requests that all hit a gateway 403 must share a single
|
|
42
|
+
// refresh — otherwise each call mints its own JWT, wastes the refresh
|
|
43
|
+
// budget, and risks token-version races. We coalesce them onto one
|
|
44
|
+
// in-flight promise (single-flight).
|
|
45
|
+
let inflightRefresh = null;
|
|
46
|
+
return async (input, init) => {
|
|
47
|
+
const response = await inner(input, init);
|
|
48
|
+
const isAuthorizerReject = response.status === 403 && response.headers.get('x-amzn-errortype') === 'AccessDeniedException';
|
|
49
|
+
if (!isAuthorizerReject)
|
|
50
|
+
return response;
|
|
51
|
+
// Budget only blocks NEW refreshes — followers awaiting an in-flight
|
|
52
|
+
// refresh aren't paying for it, so let them through.
|
|
53
|
+
if (refreshCount >= maxRefreshes && inflightRefresh === null)
|
|
54
|
+
return response;
|
|
55
|
+
if (inflightRefresh === null) {
|
|
56
|
+
// Leader for this round: charge the budget now (not on result) so
|
|
57
|
+
// followers awaiting the same promise don't each increment.
|
|
58
|
+
refreshCount += 1;
|
|
59
|
+
inflightRefresh = refresh().finally(() => {
|
|
60
|
+
inflightRefresh = null;
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
const freshJwt = await inflightRefresh;
|
|
64
|
+
if (!freshJwt) {
|
|
65
|
+
// Refresh failed — propagate the original 403 with its body intact so
|
|
66
|
+
// the SDK / caller can still read the error message. Draining here
|
|
67
|
+
// would leave them with an empty/closed stream.
|
|
68
|
+
return response;
|
|
69
|
+
}
|
|
70
|
+
// Refresh succeeded; we're about to retry. Drain the rejected response's
|
|
71
|
+
// body so we don't leak the underlying socket.
|
|
72
|
+
response.body?.cancel().catch(() => undefined);
|
|
73
|
+
const newHeaders = new Headers(init?.headers);
|
|
74
|
+
newHeaders.set('Authorization', `Bearer ${freshJwt}`);
|
|
75
|
+
return inner(input, { ...init, headers: newHeaders });
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=auth-refresh.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-refresh.mjs","sourceRoot":"","sources":["../src/lib/auth-refresh.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,MAAM,UAAU,iBAAiB,CAC/B,OAAqC,EACrC,OAA8B;IAE9B,MAAM,KAAK,GAAG,OAAO,EAAE,KAAK,IAAI,UAAU,CAAC,KAAK,CAAC;IACjD,MAAM,YAAY,GAAG,OAAO,EAAE,YAAY,IAAI,CAAC,CAAC;IAChD,IAAI,YAAY,GAAG,CAAC,CAAC;IACrB,qEAAqE;IACrE,sEAAsE;IACtE,mEAAmE;IACnE,qCAAqC;IACrC,IAAI,eAAe,GAAkC,IAAI,CAAC;IAE1D,OAAO,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QAC3B,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAC1C,MAAM,kBAAkB,GACtB,QAAQ,CAAC,MAAM,KAAK,GAAG,IAAI,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,KAAK,uBAAuB,CAAC;QAClG,IAAI,CAAC,kBAAkB;YAAE,OAAO,QAAQ,CAAC;QACzC,qEAAqE;QACrE,qDAAqD;QACrD,IAAI,YAAY,IAAI,YAAY,IAAI,eAAe,KAAK,IAAI;YAAE,OAAO,QAAQ,CAAC;QAE9E,IAAI,eAAe,KAAK,IAAI,EAAE,CAAC;YAC7B,kEAAkE;YAClE,4DAA4D;YAC5D,YAAY,IAAI,CAAC,CAAC;YAClB,eAAe,GAAG,OAAO,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE;gBACvC,eAAe,GAAG,IAAI,CAAC;YACzB,CAAC,CAAC,CAAC;QACL,CAAC;QACD,MAAM,QAAQ,GAAG,MAAM,eAAe,CAAC;QACvC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,sEAAsE;YACtE,mEAAmE;YACnE,gDAAgD;YAChD,OAAO,QAAQ,CAAC;QAClB,CAAC;QAED,yEAAyE;QACzE,+CAA+C;QAC/C,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAE/C,MAAM,UAAU,GAAG,IAAI,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAC9C,UAAU,CAAC,GAAG,CAAC,eAAe,EAAE,UAAU,QAAQ,EAAE,CAAC,CAAC;QACtD,OAAO,KAAK,CAAC,KAAK,EAAE,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,CAAC;IACxD,CAAC,CAAC;AACJ,CAAC"}
|
package/lib/generate.js
CHANGED
|
@@ -10,25 +10,25 @@ const job_1 = require("./job.js");
|
|
|
10
10
|
*/
|
|
11
11
|
class EnhancedGenerate extends generate_1.Generate {
|
|
12
12
|
caption(params, options) {
|
|
13
|
-
return (0, job_1.enhanceJob)(this._client, super.caption(params, options));
|
|
13
|
+
return (0, job_1.enhanceJob)(this._client, super.caption(params, options), options);
|
|
14
14
|
}
|
|
15
15
|
describeStyle(params, options) {
|
|
16
|
-
return (0, job_1.enhanceJob)(this._client, super.describeStyle(params, options));
|
|
16
|
+
return (0, job_1.enhanceJob)(this._client, super.describeStyle(params, options), options);
|
|
17
17
|
}
|
|
18
18
|
detect(params, options) {
|
|
19
|
-
return (0, job_1.enhanceJob)(this._client, super.detect(params, options));
|
|
19
|
+
return (0, job_1.enhanceJob)(this._client, super.detect(params, options), options);
|
|
20
20
|
}
|
|
21
21
|
embed(params, options) {
|
|
22
|
-
return (0, job_1.enhanceJob)(this._client, super.embed(params, options));
|
|
22
|
+
return (0, job_1.enhanceJob)(this._client, super.embed(params, options), options);
|
|
23
23
|
}
|
|
24
24
|
patch(params, options) {
|
|
25
|
-
return (0, job_1.enhanceJob)(this._client, super.patch(params, options));
|
|
25
|
+
return (0, job_1.enhanceJob)(this._client, super.patch(params, options), options);
|
|
26
26
|
}
|
|
27
27
|
runModel(modelID, params, options) {
|
|
28
|
-
return (0, job_1.enhanceJob)(this._client, super.runModel(modelID, params, options));
|
|
28
|
+
return (0, job_1.enhanceJob)(this._client, super.runModel(modelID, params, options), options);
|
|
29
29
|
}
|
|
30
30
|
translate(params, options) {
|
|
31
|
-
return (0, job_1.enhanceJob)(this._client, super.translate(params, options));
|
|
31
|
+
return (0, job_1.enhanceJob)(this._client, super.translate(params, options), options);
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
exports.EnhancedGenerate = EnhancedGenerate;
|
package/lib/generate.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../src/lib/generate.ts"],"names":[],"mappings":";;;AAEA,uDAgB+B;AAC/B,kCAAiD;AAEjD;;;;GAIG;AACH,MAAa,gBAAiB,SAAQ,mBAAQ;IACnC,OAAO,CACd,MAA6B,EAC7B,OAAwB;QAExB,OAAO,IAAA,gBAAU,EAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../src/lib/generate.ts"],"names":[],"mappings":";;;AAEA,uDAgB+B;AAC/B,kCAAiD;AAEjD;;;;GAIG;AACH,MAAa,gBAAiB,SAAQ,mBAAQ;IACnC,OAAO,CACd,MAA6B,EAC7B,OAAwB;QAExB,OAAO,IAAA,gBAAU,EAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,EA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
|
|
|
7
7
|
*/
|
|
8
8
|
export class EnhancedGenerate extends Generate {
|
|
9
9
|
caption(params, options) {
|
|
10
|
-
return enhanceJob(this._client, super.caption(params, options));
|
|
10
|
+
return enhanceJob(this._client, super.caption(params, options), options);
|
|
11
11
|
}
|
|
12
12
|
describeStyle(params, options) {
|
|
13
|
-
return enhanceJob(this._client, super.describeStyle(params, options));
|
|
13
|
+
return enhanceJob(this._client, super.describeStyle(params, options), options);
|
|
14
14
|
}
|
|
15
15
|
detect(params, options) {
|
|
16
|
-
return enhanceJob(this._client, super.detect(params, options));
|
|
16
|
+
return enhanceJob(this._client, super.detect(params, options), options);
|
|
17
17
|
}
|
|
18
18
|
embed(params, options) {
|
|
19
|
-
return enhanceJob(this._client, super.embed(params, options));
|
|
19
|
+
return enhanceJob(this._client, super.embed(params, options), options);
|
|
20
20
|
}
|
|
21
21
|
patch(params, options) {
|
|
22
|
-
return enhanceJob(this._client, super.patch(params, options));
|
|
22
|
+
return enhanceJob(this._client, super.patch(params, options), options);
|
|
23
23
|
}
|
|
24
24
|
runModel(modelID, params, options) {
|
|
25
|
-
return enhanceJob(this._client, super.runModel(modelID, params, options));
|
|
25
|
+
return enhanceJob(this._client, super.runModel(modelID, params, options), options);
|
|
26
26
|
}
|
|
27
27
|
translate(params, options) {
|
|
28
|
-
return enhanceJob(this._client, super.translate(params, options));
|
|
28
|
+
return enhanceJob(this._client, super.translate(params, options), options);
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
//# sourceMappingURL=generate.mjs.map
|
package/lib/generate.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.mjs","sourceRoot":"","sources":["../src/lib/generate.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,QAAQ,GAeT,kCAA8B;AAC/B,OAAO,EAAgB,UAAU,EAAE,kBAAc;AAEjD;;;;GAIG;AACH,MAAM,OAAO,gBAAiB,SAAQ,QAAQ;IACnC,OAAO,CACd,MAA6B,E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8B,EAC9B,OAAwB;QAExB,OAAO,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC;IACrF,CAAC;IAEQ,SAAS,CAChB,MAA+B,EAC/B,OAAwB;QAExB,OAAO,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC;IAC7E,CAAC;CACF"}
|
package/lib/job.d.mts
CHANGED
|
@@ -2,15 +2,24 @@ import type { Scenario } from "../client.mjs";
|
|
|
2
2
|
import type { APIPromise } from "../core/api-promise.mjs";
|
|
3
3
|
import type { RequestOptions } from "../internal/request-options.mjs";
|
|
4
4
|
import { Jobs, type JobRetrieveResponse, type JobTriggerActionParams, type JobTriggerActionResponse } from "../resources/jobs.mjs";
|
|
5
|
+
import { type Scope } from "./scope.mjs";
|
|
5
6
|
export interface WaitOptions {
|
|
6
7
|
/** Polling interval in milliseconds. Default: 3000 */
|
|
7
8
|
intervalMs?: number;
|
|
8
9
|
/** Maximum wait time in milliseconds. Default: 120000 */
|
|
9
10
|
timeoutMs?: number;
|
|
11
|
+
/**
|
|
12
|
+
* Override the project scope used for the polling requests. Defaults to
|
|
13
|
+
* the scope captured on the job (per-call override on the originating
|
|
14
|
+
* call, else the client's default project).
|
|
15
|
+
*/
|
|
16
|
+
projectId?: string;
|
|
10
17
|
}
|
|
11
18
|
/** Job methods added on top of the original job fields. */
|
|
12
19
|
export declare class JobMethods {
|
|
13
20
|
/** @internal */ readonly _client: Scenario;
|
|
21
|
+
/** @internal scope captured from the originating call — replayed on every `.wait()` poll. */
|
|
22
|
+
readonly _scope?: Scope;
|
|
14
23
|
/**
|
|
15
24
|
* Poll until the job reaches a terminal status (success, failure, or canceled).
|
|
16
25
|
*
|
|
@@ -22,8 +31,8 @@ export declare class JobMethods {
|
|
|
22
31
|
* ```
|
|
23
32
|
*/
|
|
24
33
|
wait(this: Job, options?: WaitOptions): Promise<Job>;
|
|
25
|
-
/** @internal Create a Job from raw job data. */
|
|
26
|
-
static from(client: Scenario, data: JobRetrieveResponse['job']): Job;
|
|
34
|
+
/** @internal Create a Job from raw job data, optionally remembering the originating scope. */
|
|
35
|
+
static from(client: Scenario, data: JobRetrieveResponse['job'], scope?: Scope): Job;
|
|
27
36
|
}
|
|
28
37
|
/** A job with all original fields plus `.wait()`. */
|
|
29
38
|
export type Job = JobRetrieveResponse.Job & JobMethods;
|
|
@@ -39,13 +48,16 @@ export type WithJob<T extends {
|
|
|
39
48
|
};
|
|
40
49
|
/**
|
|
41
50
|
* @internal Wrap `_thenUnwrap` to replace `response.job` with an enhanced Job.
|
|
51
|
+
* Captures the effective scope (per-call override or client default) so
|
|
52
|
+
* `.wait()` can replay it on every poll — keeping follow-up calls in sync
|
|
53
|
+
* with the project the job was originally created in.
|
|
42
54
|
*/
|
|
43
55
|
export declare function enhanceJob<T extends {
|
|
44
56
|
job: {
|
|
45
57
|
jobId: string;
|
|
46
58
|
status: string;
|
|
47
59
|
};
|
|
48
|
-
}>(client: Scenario, promise: APIPromise<T
|
|
60
|
+
}>(client: Scenario, promise: APIPromise<T>, options?: RequestOptions): APIPromise<WithJob<T>>;
|
|
49
61
|
/**
|
|
50
62
|
* Enhanced Jobs resource. `retrieve` and `triggerAction` responses' `job`
|
|
51
63
|
* field gains a `.wait()` helper — previously only job-creating endpoints
|
package/lib/job.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"job.d.mts","sourceRoot":"","sources":["../src/lib/job.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,sBAAkB;AAC1C,OAAO,KAAK,EAAE,UAAU,EAAE,gCAA4B;AACtD,OAAO,KAAK,EAAE,cAAc,EAAE,wCAAoC;AAClE,OAAO,EACL,IAAI,EACJ,KAAK,mBAAmB,EACxB,KAAK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I,CAAC,GAAG;IAAE,GAAG,EAAE,UAAU,CAAA;CAAE,CAAC;AAE1E;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS;IAAE,GAAG,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,EAC7E,MAAM,EAAE,QAAQ,EAChB,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,EACtB,OAAO,CAAC,EAAE,cAAc,GACvB,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAMxB;AAED;;;;;;GAMG;AACH,qBAAa,YAAa,SAAQ,IAAI;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAI3F,aAAa,CACpB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,sBAAsB,EAC9B,OAAO,CAAC,EAAE,cAAc,GACvB,UAAU,CAAC,OAAO,CAAC,wBAAwB,CAAC,CAAC;CAGjD"}
|
package/lib/job.d.ts
CHANGED
|
@@ -2,15 +2,24 @@ import type { Scenario } from "../client.js";
|
|
|
2
2
|
import type { APIPromise } from "../core/api-promise.js";
|
|
3
3
|
import type { RequestOptions } from "../internal/request-options.js";
|
|
4
4
|
import { Jobs, type JobRetrieveResponse, type JobTriggerActionParams, type JobTriggerActionResponse } from "../resources/jobs.js";
|
|
5
|
+
import { type Scope } from "./scope.js";
|
|
5
6
|
export interface WaitOptions {
|
|
6
7
|
/** Polling interval in milliseconds. Default: 3000 */
|
|
7
8
|
intervalMs?: number;
|
|
8
9
|
/** Maximum wait time in milliseconds. Default: 120000 */
|
|
9
10
|
timeoutMs?: number;
|
|
11
|
+
/**
|
|
12
|
+
* Override the project scope used for the polling requests. Defaults to
|
|
13
|
+
* the scope captured on the job (per-call override on the originating
|
|
14
|
+
* call, else the client's default project).
|
|
15
|
+
*/
|
|
16
|
+
projectId?: string;
|
|
10
17
|
}
|
|
11
18
|
/** Job methods added on top of the original job fields. */
|
|
12
19
|
export declare class JobMethods {
|
|
13
20
|
/** @internal */ readonly _client: Scenario;
|
|
21
|
+
/** @internal scope captured from the originating call — replayed on every `.wait()` poll. */
|
|
22
|
+
readonly _scope?: Scope;
|
|
14
23
|
/**
|
|
15
24
|
* Poll until the job reaches a terminal status (success, failure, or canceled).
|
|
16
25
|
*
|
|
@@ -22,8 +31,8 @@ export declare class JobMethods {
|
|
|
22
31
|
* ```
|
|
23
32
|
*/
|
|
24
33
|
wait(this: Job, options?: WaitOptions): Promise<Job>;
|
|
25
|
-
/** @internal Create a Job from raw job data. */
|
|
26
|
-
static from(client: Scenario, data: JobRetrieveResponse['job']): Job;
|
|
34
|
+
/** @internal Create a Job from raw job data, optionally remembering the originating scope. */
|
|
35
|
+
static from(client: Scenario, data: JobRetrieveResponse['job'], scope?: Scope): Job;
|
|
27
36
|
}
|
|
28
37
|
/** A job with all original fields plus `.wait()`. */
|
|
29
38
|
export type Job = JobRetrieveResponse.Job & JobMethods;
|
|
@@ -39,13 +48,16 @@ export type WithJob<T extends {
|
|
|
39
48
|
};
|
|
40
49
|
/**
|
|
41
50
|
* @internal Wrap `_thenUnwrap` to replace `response.job` with an enhanced Job.
|
|
51
|
+
* Captures the effective scope (per-call override or client default) so
|
|
52
|
+
* `.wait()` can replay it on every poll — keeping follow-up calls in sync
|
|
53
|
+
* with the project the job was originally created in.
|
|
42
54
|
*/
|
|
43
55
|
export declare function enhanceJob<T extends {
|
|
44
56
|
job: {
|
|
45
57
|
jobId: string;
|
|
46
58
|
status: string;
|
|
47
59
|
};
|
|
48
|
-
}>(client: Scenario, promise: APIPromise<T
|
|
60
|
+
}>(client: Scenario, promise: APIPromise<T>, options?: RequestOptions): APIPromise<WithJob<T>>;
|
|
49
61
|
/**
|
|
50
62
|
* Enhanced Jobs resource. `retrieve` and `triggerAction` responses' `job`
|
|
51
63
|
* field gains a `.wait()` helper — previously only job-creating endpoints
|
package/lib/job.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"job.d.ts","sourceRoot":"","sources":["../src/lib/job.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,qBAAkB;AAC1C,OAAO,KAAK,EAAE,UAAU,EAAE,+BAA4B;AACtD,OAAO,KAAK,EAAE,cAAc,EAAE,uCAAoC;AAClE,OAAO,EACL,IAAI,EACJ,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,wBAAwB,EAC9B,6BAA0B;
|
|
1
|
+
{"version":3,"file":"job.d.ts","sourceRoot":"","sources":["../src/lib/job.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,qBAAkB;AAC1C,OAAO,KAAK,EAAE,UAAU,EAAE,+BAA4B;AACtD,OAAO,KAAK,EAAE,cAAc,EAAE,uCAAoC;AAClE,OAAO,EACL,IAAI,EACJ,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,wBAAwB,EAC9B,6BAA0B;AAC3B,OAAO,EAAE,KAAK,KAAK,EAA8C,mBAAgB;AAEjF,MAAM,WAAW,WAAW;IAC1B,sDAAsD;IACtD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,yDAAyD;IACzD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAMD,2DAA2D;AAC3D,qBAAa,UAAU;IACrB,gBAAgB,CAAC,SAAiB,OAAO,EAAE,QAAQ,CAAC;IACpD,6FAA6F;IAC7F,SAAiB,MAAM,CAAC,EAAE,KAAK,CAAC;IAEhC;;;;;;;;;OASG;IACG,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC;IAoB1D,8FAA8F;IAC9F,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,mBAAmB,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,EAAE,KAAK,GAAG,GAAG;CAMpF;AAED,qDAAqD;AACrD,MAAM,MAAM,GAAG,GAAG,mBAAmB,CAAC,GAAG,GAAG,UAAU,CAAC;AACvD,eAAO,MAAM,GAAG,mBAAa,CAAC;AAE9B;;;GAGG;AACH,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS;IAAE,GAAG,EAAE,OAAO,CAAA;CAAE,IAAI,CAAC,GAAG;IAAE,GAAG,EAAE,UAAU,CAAA;CAAE,CAAC;AAE1E;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS;IAAE,GAAG,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,EAC7E,MAAM,EAAE,QAAQ,EAChB,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,EACtB,OAAO,CAAC,EAAE,cAAc,GACvB,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAMxB;AAED;;;;;;GAMG;AACH,qBAAa,YAAa,SAAQ,IAAI;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAI3F,aAAa,CACpB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,sBAAsB,EAC9B,OAAO,CAAC,EAAE,cAAc,GACvB,UAAU,CAAC,OAAO,CAAC,wBAAwB,CAAC,CAAC;CAGjD"}
|
package/lib/job.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.EnhancedJobs = exports.Job = exports.JobMethods = void 0;
|
|
4
4
|
exports.enhanceJob = enhanceJob;
|
|
5
5
|
const jobs_1 = require("../resources/jobs.js");
|
|
6
|
+
const scope_1 = require("./scope.js");
|
|
6
7
|
const TERMINAL_STATUSES = new Set(['success', 'failure', 'canceled']);
|
|
7
8
|
/** Job methods added on top of the original job fields. */
|
|
8
9
|
class JobMethods {
|
|
@@ -19,21 +20,24 @@ class JobMethods {
|
|
|
19
20
|
async wait(options) {
|
|
20
21
|
const intervalMs = options?.intervalMs ?? 3_000;
|
|
21
22
|
const timeoutMs = options?.timeoutMs ?? 120_000;
|
|
23
|
+
const scope = waitOverrideScope(options) ?? this._scope;
|
|
22
24
|
let elapsed = 0;
|
|
23
25
|
while (elapsed < timeoutMs) {
|
|
24
|
-
const response = await this._client.jobs.retrieve(this.jobId);
|
|
26
|
+
const response = await this._client.jobs.retrieve(this.jobId, (0, scope_1.withScope)(scope));
|
|
25
27
|
if (TERMINAL_STATUSES.has(response.job.status)) {
|
|
26
|
-
return exports.Job.from(this._client, response.job);
|
|
28
|
+
return exports.Job.from(this._client, response.job, scope);
|
|
27
29
|
}
|
|
28
30
|
await new Promise((resolve) => setTimeout(resolve, intervalMs));
|
|
29
31
|
elapsed += intervalMs;
|
|
30
32
|
}
|
|
31
33
|
throw new Error(`Job ${this.jobId} did not complete within ${timeoutMs / 1_000}s`);
|
|
32
34
|
}
|
|
33
|
-
/** @internal Create a Job from raw job data. */
|
|
34
|
-
static from(client, data) {
|
|
35
|
+
/** @internal Create a Job from raw job data, optionally remembering the originating scope. */
|
|
36
|
+
static from(client, data, scope) {
|
|
35
37
|
const job = Object.assign(Object.create(JobMethods.prototype), data);
|
|
36
38
|
Object.defineProperty(job, '_client', { value: client, enumerable: false });
|
|
39
|
+
if (scope)
|
|
40
|
+
Object.defineProperty(job, '_scope', { value: scope, enumerable: false });
|
|
37
41
|
return job;
|
|
38
42
|
}
|
|
39
43
|
}
|
|
@@ -41,11 +45,15 @@ exports.JobMethods = JobMethods;
|
|
|
41
45
|
exports.Job = JobMethods;
|
|
42
46
|
/**
|
|
43
47
|
* @internal Wrap `_thenUnwrap` to replace `response.job` with an enhanced Job.
|
|
48
|
+
* Captures the effective scope (per-call override or client default) so
|
|
49
|
+
* `.wait()` can replay it on every poll — keeping follow-up calls in sync
|
|
50
|
+
* with the project the job was originally created in.
|
|
44
51
|
*/
|
|
45
|
-
function enhanceJob(client, promise) {
|
|
52
|
+
function enhanceJob(client, promise, options) {
|
|
53
|
+
const scope = (0, scope_1.effectiveScope)(options, (0, scope_1.clientProjectId)(client));
|
|
46
54
|
return promise._thenUnwrap((data) => ({
|
|
47
55
|
...data,
|
|
48
|
-
job: exports.Job.from(client, data.job),
|
|
56
|
+
job: exports.Job.from(client, data.job, scope),
|
|
49
57
|
}));
|
|
50
58
|
}
|
|
51
59
|
/**
|
|
@@ -57,11 +65,17 @@ function enhanceJob(client, promise) {
|
|
|
57
65
|
*/
|
|
58
66
|
class EnhancedJobs extends jobs_1.Jobs {
|
|
59
67
|
retrieve(jobID, options) {
|
|
60
|
-
return enhanceJob(this._client, super.retrieve(jobID, options));
|
|
68
|
+
return enhanceJob(this._client, super.retrieve(jobID, options), options);
|
|
61
69
|
}
|
|
62
70
|
triggerAction(jobID, params, options) {
|
|
63
|
-
return enhanceJob(this._client, super.triggerAction(jobID, params, options));
|
|
71
|
+
return enhanceJob(this._client, super.triggerAction(jobID, params, options), options);
|
|
64
72
|
}
|
|
65
73
|
}
|
|
66
74
|
exports.EnhancedJobs = EnhancedJobs;
|
|
75
|
+
/** Resolve the scope override carried by a `WaitOptions`, if any. */
|
|
76
|
+
function waitOverrideScope(options) {
|
|
77
|
+
if (!options?.projectId)
|
|
78
|
+
return undefined;
|
|
79
|
+
return { projectId: options.projectId };
|
|
80
|
+
}
|
|
67
81
|
//# sourceMappingURL=job.js.map
|
package/lib/job.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"job.js","sourceRoot":"","sources":["../src/lib/job.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"job.js","sourceRoot":"","sources":["../src/lib/job.ts"],"names":[],"mappings":";;;AAyFA,gCAUC;AA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CAAC;IACxF,CAAC;CACF;AAZD,oCAYC;AAED,qEAAqE;AACrE,SAAS,iBAAiB,CAAC,OAAqB;IAC9C,IAAI,CAAC,OAAO,EAAE,SAAS;QAAE,OAAO,SAAS,CAAC;IAC1C,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC;AAC1C,CAAC"}
|
package/lib/job.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Jobs, } from "../resources/jobs.mjs";
|
|
2
|
+
import { clientProjectId, effectiveScope, withScope } from "./scope.mjs";
|
|
2
3
|
const TERMINAL_STATUSES = new Set(['success', 'failure', 'canceled']);
|
|
3
4
|
/** Job methods added on top of the original job fields. */
|
|
4
5
|
export class JobMethods {
|
|
@@ -15,32 +16,39 @@ export class JobMethods {
|
|
|
15
16
|
async wait(options) {
|
|
16
17
|
const intervalMs = options?.intervalMs ?? 3_000;
|
|
17
18
|
const timeoutMs = options?.timeoutMs ?? 120_000;
|
|
19
|
+
const scope = waitOverrideScope(options) ?? this._scope;
|
|
18
20
|
let elapsed = 0;
|
|
19
21
|
while (elapsed < timeoutMs) {
|
|
20
|
-
const response = await this._client.jobs.retrieve(this.jobId);
|
|
22
|
+
const response = await this._client.jobs.retrieve(this.jobId, withScope(scope));
|
|
21
23
|
if (TERMINAL_STATUSES.has(response.job.status)) {
|
|
22
|
-
return Job.from(this._client, response.job);
|
|
24
|
+
return Job.from(this._client, response.job, scope);
|
|
23
25
|
}
|
|
24
26
|
await new Promise((resolve) => setTimeout(resolve, intervalMs));
|
|
25
27
|
elapsed += intervalMs;
|
|
26
28
|
}
|
|
27
29
|
throw new Error(`Job ${this.jobId} did not complete within ${timeoutMs / 1_000}s`);
|
|
28
30
|
}
|
|
29
|
-
/** @internal Create a Job from raw job data. */
|
|
30
|
-
static from(client, data) {
|
|
31
|
+
/** @internal Create a Job from raw job data, optionally remembering the originating scope. */
|
|
32
|
+
static from(client, data, scope) {
|
|
31
33
|
const job = Object.assign(Object.create(JobMethods.prototype), data);
|
|
32
34
|
Object.defineProperty(job, '_client', { value: client, enumerable: false });
|
|
35
|
+
if (scope)
|
|
36
|
+
Object.defineProperty(job, '_scope', { value: scope, enumerable: false });
|
|
33
37
|
return job;
|
|
34
38
|
}
|
|
35
39
|
}
|
|
36
40
|
export const Job = JobMethods;
|
|
37
41
|
/**
|
|
38
42
|
* @internal Wrap `_thenUnwrap` to replace `response.job` with an enhanced Job.
|
|
43
|
+
* Captures the effective scope (per-call override or client default) so
|
|
44
|
+
* `.wait()` can replay it on every poll — keeping follow-up calls in sync
|
|
45
|
+
* with the project the job was originally created in.
|
|
39
46
|
*/
|
|
40
|
-
export function enhanceJob(client, promise) {
|
|
47
|
+
export function enhanceJob(client, promise, options) {
|
|
48
|
+
const scope = effectiveScope(options, clientProjectId(client));
|
|
41
49
|
return promise._thenUnwrap((data) => ({
|
|
42
50
|
...data,
|
|
43
|
-
job: Job.from(client, data.job),
|
|
51
|
+
job: Job.from(client, data.job, scope),
|
|
44
52
|
}));
|
|
45
53
|
}
|
|
46
54
|
/**
|
|
@@ -52,10 +60,16 @@ export function enhanceJob(client, promise) {
|
|
|
52
60
|
*/
|
|
53
61
|
export class EnhancedJobs extends Jobs {
|
|
54
62
|
retrieve(jobID, options) {
|
|
55
|
-
return enhanceJob(this._client, super.retrieve(jobID, options));
|
|
63
|
+
return enhanceJob(this._client, super.retrieve(jobID, options), options);
|
|
56
64
|
}
|
|
57
65
|
triggerAction(jobID, params, options) {
|
|
58
|
-
return enhanceJob(this._client, super.triggerAction(jobID, params, options));
|
|
66
|
+
return enhanceJob(this._client, super.triggerAction(jobID, params, options), options);
|
|
59
67
|
}
|
|
60
68
|
}
|
|
69
|
+
/** Resolve the scope override carried by a `WaitOptions`, if any. */
|
|
70
|
+
function waitOverrideScope(options) {
|
|
71
|
+
if (!options?.projectId)
|
|
72
|
+
return undefined;
|
|
73
|
+
return { projectId: options.projectId };
|
|
74
|
+
}
|
|
61
75
|
//# sourceMappingURL=job.mjs.map
|
package/lib/job.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"job.mjs","sourceRoot":"","sources":["../src/lib/job.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,IAAI,GAIL,8BAA0B;
|
|
1
|
+
{"version":3,"file":"job.mjs","sourceRoot":"","sources":["../src/lib/job.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,IAAI,GAIL,8BAA0B;AAC3B,OAAO,EAAc,eAAe,EAAE,cAAc,EAAE,SAAS,EAAE,oBAAgB;AAiBjF,MAAM,iBAAiB,GAAmB,IAAI,GAAG,CAAC,CAAC,SAAS,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC;AAEtF,2DAA2D;AAC3D,MAAM,OAAO,UAAU;IAKrB;;;;;;;;;OASG;IACH,KAAK,CAAC,IAAI,CAAY,OAAqB;QACzC,MAAM,UAAU,GAAG,OAAO,EAAE,UAAU,IAAI,KAAK,CAAC;QAChD,MAAM,SAAS,GAAG,OAAO,EAAE,SAAS,IAAI,OAAO,CAAC;QAChD,MAAM,KAAK,GAAG,iBAAiB,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC;QACxD,IAAI,OAAO,GAAG,CAAC,CAAC;QAEhB,OAAO,OAAO,GAAG,SAAS,EAAE,CAAC;YAC3B,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;YAEhF,IAAI,iBAAiB,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;gBAC/C,OAAO,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;YACrD,CAAC;YAED,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,C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D,OAAO,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC;IAC3E,CAAC;IAEQ,aAAa,CACpB,KAAa,EACb,MAA8B,EAC9B,OAAwB;QAExB,OAAO,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC;IACxF,CAAC;CACF;AAED,qEAAqE;AACrE,SAAS,iBAAiB,CAAC,OAAqB;IAC9C,IAAI,CAAC,OAAO,EAAE,SAAS;QAAE,OAAO,SAAS,CAAC;IAC1C,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC;AAC1C,CAAC"}
|
package/lib/models.d.mts
CHANGED
|
@@ -4,6 +4,7 @@ import type { GenerateRunModelParams, GenerateRunModelResponse } from "../resour
|
|
|
4
4
|
import { Models, type ModelRetrieveParams, type ModelRetrieveResponse } from "../resources/models/models.mjs";
|
|
5
5
|
import { Train, type TrainTriggerParams, type TrainTriggerResponse } from "../resources/models/train.mjs";
|
|
6
6
|
import { type WithJob } from "./job.mjs";
|
|
7
|
+
import { type Scope } from "./scope.mjs";
|
|
7
8
|
import type { Scenario } from "./scenario.mjs";
|
|
8
9
|
/**
|
|
9
10
|
* Enhanced Model entity with helper methods.
|
|
@@ -18,15 +19,20 @@ import type { Scenario } from "./scenario.mjs";
|
|
|
18
19
|
*/
|
|
19
20
|
export declare class ModelEntity {
|
|
20
21
|
/** @internal */ readonly _client: Scenario;
|
|
22
|
+
/** @internal scope captured from the retrieve call — replayed when `.run()` is invoked without an explicit query override. */
|
|
23
|
+
readonly _scope?: Scope;
|
|
21
24
|
/**
|
|
22
25
|
* Generate with this model. Shortcut for
|
|
23
26
|
* `client.generate.runModel(this.id, params)`.
|
|
24
27
|
*
|
|
25
28
|
* Returns an enhanced response where `response.job` has `.wait()`.
|
|
29
|
+
* If the model was fetched with a `projectId` scope (per-call override or
|
|
30
|
+
* client default), that scope is reused unless overridden by
|
|
31
|
+
* `options.query`.
|
|
26
32
|
*/
|
|
27
33
|
run(this: ModelEntity & ModelRetrieveResponse.Model, params: GenerateRunModelParams, options?: RequestOptions): APIPromise<WithJob<GenerateRunModelResponse>>;
|
|
28
|
-
/** @internal Create a ModelEntity wrapping raw model data. */
|
|
29
|
-
static from(client: Scenario, data: ModelRetrieveResponse.Model): ModelRetrieveResponse.Model & ModelEntity;
|
|
34
|
+
/** @internal Create a ModelEntity wrapping raw model data, optionally remembering the originating scope. */
|
|
35
|
+
static from(client: Scenario, data: ModelRetrieveResponse.Model, scope?: Scope): ModelRetrieveResponse.Model & ModelEntity;
|
|
30
36
|
}
|
|
31
37
|
/** Enhanced retrieve response where `model` has `.run()` on top of its original fields. */
|
|
32
38
|
export type EnhancedModelRetrieveResponse = Omit<ModelRetrieveResponse, 'model'> & {
|
package/lib/models.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"models.d.mts","sourceRoot":"","sources":["../src/lib/models.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,gCAA4B;AACtD,OAAO,KAAK,EAAE,cAAc,EAAE,wCAAoC;AAClE,OAAO,KAAK,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,kCAA8B;AAC9F,OAAO,EAAE,MAAM,EAAE,KAAK,mBAAmB,EAAE,KAAK,qBAAqB,EAAE,uCAAmC;AAC1G,OAAO,EAAE,KAAK,EAAE,KAAK,kBAAkB,EAAE,KAAK,oBAAoB,EAAE,sCAAkC;AACtG,OAAO,EAAE,KAAK,OAAO,EAAc,kBAAc;
|
|
1
|
+
{"version":3,"file":"models.d.mts","sourceRoot":"","sources":["../src/lib/models.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,gCAA4B;AACtD,OAAO,KAAK,EAAE,cAAc,EAA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