@rendobar/sdk 5.4.0 → 5.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +70 -5
- package/dist/index.d.cts +54 -1
- package/dist/index.d.mts +54 -1
- package/dist/index.mjs +70 -5
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -181,16 +181,31 @@ const TERMINAL_JOB_STATUSES$1 = /* @__PURE__ */ new Set([
|
|
|
181
181
|
"failed",
|
|
182
182
|
"cancelled"
|
|
183
183
|
]);
|
|
184
|
+
/** Wait bound used until the server reports the job's own budget, and the floor. */
|
|
185
|
+
const DEFAULT_WAIT_TIMEOUT_MS = 3e5;
|
|
186
|
+
/** Headroom past the execution budget for upload + terminal callback delivery. */
|
|
187
|
+
const WAIT_GRACE_MS = 12e4;
|
|
184
188
|
function createJobsResource(request) {
|
|
185
189
|
async function wait(id, options = {}) {
|
|
186
|
-
const { timeout
|
|
187
|
-
const
|
|
190
|
+
const { timeout, interval = 2e3, maxInterval = 1e4, onProgress, signal, throwOnFailure = false } = options;
|
|
191
|
+
const waitStartedAt = Date.now();
|
|
192
|
+
let effectiveTimeout = timeout ?? DEFAULT_WAIT_TIMEOUT_MS;
|
|
193
|
+
let deadline = waitStartedAt + effectiveTimeout;
|
|
194
|
+
let adoptedJobBudget = false;
|
|
188
195
|
let currentInterval = interval;
|
|
189
196
|
while (Date.now() < deadline) {
|
|
190
197
|
if (signal?.aborted) throw new DOMException("Wait aborted", "AbortError");
|
|
191
198
|
const job = await request(`/jobs/${id}`, { signal });
|
|
192
199
|
onProgress?.(job);
|
|
193
200
|
if (TERMINAL_JOB_STATUSES$1.has(job.status)) return resolveTerminal(id, job, throwOnFailure);
|
|
201
|
+
if (timeout === void 0 && !adoptedJobBudget && typeof job.timeoutMs === "number") {
|
|
202
|
+
adoptedJobBudget = true;
|
|
203
|
+
const budgetDeadline = waitStartedAt + job.timeoutMs + WAIT_GRACE_MS;
|
|
204
|
+
if (budgetDeadline > deadline) {
|
|
205
|
+
deadline = budgetDeadline;
|
|
206
|
+
effectiveTimeout = deadline - waitStartedAt;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
194
209
|
const remaining = deadline - Date.now();
|
|
195
210
|
const delay = Math.min(currentInterval, remaining);
|
|
196
211
|
if (delay <= 0) break;
|
|
@@ -200,7 +215,7 @@ function createJobsResource(request) {
|
|
|
200
215
|
const job = await request(`/jobs/${id}`, { signal });
|
|
201
216
|
onProgress?.(job);
|
|
202
217
|
if (TERMINAL_JOB_STATUSES$1.has(job.status)) return resolveTerminal(id, job, throwOnFailure);
|
|
203
|
-
throw new WaitTimeoutError(id, job.status,
|
|
218
|
+
throw new WaitTimeoutError(id, job.status, effectiveTimeout);
|
|
204
219
|
}
|
|
205
220
|
async function create(params, options) {
|
|
206
221
|
return request("/jobs", {
|
|
@@ -687,7 +702,46 @@ function createOrgsResource(request) {
|
|
|
687
702
|
body,
|
|
688
703
|
signal: options?.signal
|
|
689
704
|
});
|
|
690
|
-
}
|
|
705
|
+
},
|
|
706
|
+
/**
|
|
707
|
+
* Organization membership. Replaces `client.team.*`, which named a
|
|
708
|
+
* resource the API does not have: there is no team, only an organization
|
|
709
|
+
* with members and invitations.
|
|
710
|
+
*/
|
|
711
|
+
members: {
|
|
712
|
+
/** Invite someone to the current organization. Owner or admin only. */
|
|
713
|
+
async invite(params, options) {
|
|
714
|
+
return request("/orgs/current/members", {
|
|
715
|
+
method: "POST",
|
|
716
|
+
body: params,
|
|
717
|
+
signal: options?.signal
|
|
718
|
+
});
|
|
719
|
+
},
|
|
720
|
+
/** Change a member's role. Owner or admin only. */
|
|
721
|
+
async changeRole(params, options) {
|
|
722
|
+
return request(`/orgs/current/members/${params.memberId}`, {
|
|
723
|
+
method: "PATCH",
|
|
724
|
+
body: { role: params.role },
|
|
725
|
+
signal: options?.signal
|
|
726
|
+
});
|
|
727
|
+
},
|
|
728
|
+
/** Remove a member, or pass your own member id to leave. */
|
|
729
|
+
async remove(params, options) {
|
|
730
|
+
return request(`/orgs/current/members/${params.memberId}`, {
|
|
731
|
+
method: "DELETE",
|
|
732
|
+
signal: options?.signal
|
|
733
|
+
});
|
|
734
|
+
}
|
|
735
|
+
},
|
|
736
|
+
/** Pending invitations to the current organization. */
|
|
737
|
+
invitations: {
|
|
738
|
+
/** Cancel a pending invitation. Owner or admin only. */
|
|
739
|
+
async revoke(params, options) {
|
|
740
|
+
return request(`/orgs/current/invitations/${params.invitationId}`, {
|
|
741
|
+
method: "DELETE",
|
|
742
|
+
signal: options?.signal
|
|
743
|
+
});
|
|
744
|
+
} }
|
|
691
745
|
};
|
|
692
746
|
}
|
|
693
747
|
//#endregion
|
|
@@ -722,8 +776,16 @@ function createAssetsResource(request) {
|
|
|
722
776
|
}
|
|
723
777
|
//#endregion
|
|
724
778
|
//#region src/resources/team.ts
|
|
779
|
+
/**
|
|
780
|
+
* DEPRECATED. Use `client.orgs.members` and `client.orgs.invitations`.
|
|
781
|
+
*
|
|
782
|
+
* These wrap `/team/*`, which names a resource the API does not have: there is
|
|
783
|
+
* no team, only an organization with members and invitations. The endpoints
|
|
784
|
+
* still work and will keep working until the next major.
|
|
785
|
+
*/
|
|
725
786
|
function createTeamResource(request) {
|
|
726
787
|
return {
|
|
788
|
+
/** @deprecated Use `client.orgs.members.invite()`. */
|
|
727
789
|
async invite(params, options) {
|
|
728
790
|
return request("/team/invite", {
|
|
729
791
|
method: "POST",
|
|
@@ -731,13 +793,15 @@ function createTeamResource(request) {
|
|
|
731
793
|
signal: options?.signal
|
|
732
794
|
});
|
|
733
795
|
},
|
|
796
|
+
/** @deprecated Use `client.orgs.members.changeRole()`. */
|
|
734
797
|
async changeRole(params, options) {
|
|
735
798
|
await request("/team/role", {
|
|
736
|
-
method: "
|
|
799
|
+
method: "PATCH",
|
|
737
800
|
body: params,
|
|
738
801
|
signal: options?.signal
|
|
739
802
|
});
|
|
740
803
|
},
|
|
804
|
+
/** @deprecated Use `client.orgs.members.remove()`. */
|
|
741
805
|
async remove(params, options) {
|
|
742
806
|
await request("/team/remove", {
|
|
743
807
|
method: "POST",
|
|
@@ -745,6 +809,7 @@ function createTeamResource(request) {
|
|
|
745
809
|
signal: options?.signal
|
|
746
810
|
});
|
|
747
811
|
},
|
|
812
|
+
/** @deprecated Use `client.orgs.invitations.revoke()`. */
|
|
748
813
|
async revokeInvitation(params, options) {
|
|
749
814
|
await request("/team/revoke-invitation", {
|
|
750
815
|
method: "POST",
|
package/dist/index.d.cts
CHANGED
|
@@ -2298,6 +2298,7 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2298
2298
|
resourcesAvailable: ZodBoolean;
|
|
2299
2299
|
metricsAvailable: ZodOptional<ZodBoolean>;
|
|
2300
2300
|
region: ZodOptional<ZodNullable<ZodString>>;
|
|
2301
|
+
timeoutMs: ZodNullable<ZodNumber>;
|
|
2301
2302
|
createdAt: ZodNumber;
|
|
2302
2303
|
dispatchedAt: ZodNullable<ZodNumber>;
|
|
2303
2304
|
startedAt: ZodNullable<ZodNumber>;
|
|
@@ -2352,6 +2353,7 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2352
2353
|
resourcesAvailable: ZodBoolean;
|
|
2353
2354
|
metricsAvailable: ZodOptional<ZodBoolean>;
|
|
2354
2355
|
region: ZodOptional<ZodNullable<ZodString>>;
|
|
2356
|
+
timeoutMs: ZodNullable<ZodNumber>;
|
|
2355
2357
|
createdAt: ZodNumber;
|
|
2356
2358
|
dispatchedAt: ZodNullable<ZodNumber>;
|
|
2357
2359
|
startedAt: ZodNullable<ZodNumber>;
|
|
@@ -2415,6 +2417,7 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2415
2417
|
resourcesAvailable: ZodBoolean;
|
|
2416
2418
|
metricsAvailable: ZodOptional<ZodBoolean>;
|
|
2417
2419
|
region: ZodOptional<ZodNullable<ZodString>>;
|
|
2420
|
+
timeoutMs: ZodNullable<ZodNumber>;
|
|
2418
2421
|
createdAt: ZodNumber;
|
|
2419
2422
|
dispatchedAt: ZodNullable<ZodNumber>;
|
|
2420
2423
|
startedAt: ZodNullable<ZodNumber>;
|
|
@@ -2471,6 +2474,7 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2471
2474
|
resourcesAvailable: ZodBoolean;
|
|
2472
2475
|
metricsAvailable: ZodOptional<ZodBoolean>;
|
|
2473
2476
|
region: ZodOptional<ZodNullable<ZodString>>;
|
|
2477
|
+
timeoutMs: ZodNullable<ZodNumber>;
|
|
2474
2478
|
createdAt: ZodNumber;
|
|
2475
2479
|
dispatchedAt: ZodNullable<ZodNumber>;
|
|
2476
2480
|
startedAt: ZodNullable<ZodNumber>;
|
|
@@ -2571,6 +2575,7 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2571
2575
|
resourcesAvailable: ZodBoolean;
|
|
2572
2576
|
metricsAvailable: ZodOptional<ZodBoolean>;
|
|
2573
2577
|
region: ZodOptional<ZodNullable<ZodString>>;
|
|
2578
|
+
timeoutMs: ZodNullable<ZodNumber>;
|
|
2574
2579
|
createdAt: ZodNumber;
|
|
2575
2580
|
dispatchedAt: ZodNullable<ZodNumber>;
|
|
2576
2581
|
startedAt: ZodNullable<ZodNumber>;
|
|
@@ -2636,6 +2641,7 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2636
2641
|
resourcesAvailable: ZodBoolean;
|
|
2637
2642
|
metricsAvailable: ZodOptional<ZodBoolean>;
|
|
2638
2643
|
region: ZodOptional<ZodNullable<ZodString>>;
|
|
2644
|
+
timeoutMs: ZodNullable<ZodNumber>;
|
|
2639
2645
|
createdAt: ZodNumber;
|
|
2640
2646
|
dispatchedAt: ZodNullable<ZodNumber>;
|
|
2641
2647
|
startedAt: ZodNullable<ZodNumber>;
|
|
@@ -3542,6 +3548,44 @@ declare function createClient(config?: ClientConfig): {
|
|
|
3542
3548
|
updateSettings(body: Partial<Pick<OrgSettings, "billingEmailsEnabled" | "defaultRegion" | "regionPinned">>, options?: {
|
|
3543
3549
|
signal?: AbortSignal;
|
|
3544
3550
|
}): Promise<OrgSettings>;
|
|
3551
|
+
members: {
|
|
3552
|
+
invite(params: {
|
|
3553
|
+
email: string;
|
|
3554
|
+
role: "admin" | "member";
|
|
3555
|
+
}, options?: {
|
|
3556
|
+
signal?: AbortSignal;
|
|
3557
|
+
}): Promise<{
|
|
3558
|
+
id: string;
|
|
3559
|
+
email: string;
|
|
3560
|
+
role: string;
|
|
3561
|
+
expiresAt: number;
|
|
3562
|
+
}>;
|
|
3563
|
+
changeRole(params: {
|
|
3564
|
+
memberId: string;
|
|
3565
|
+
role: "admin" | "member";
|
|
3566
|
+
}, options?: {
|
|
3567
|
+
signal?: AbortSignal;
|
|
3568
|
+
}): Promise<{
|
|
3569
|
+
memberId: string;
|
|
3570
|
+
role: string;
|
|
3571
|
+
}>;
|
|
3572
|
+
remove(params: {
|
|
3573
|
+
memberId: string;
|
|
3574
|
+
}, options?: {
|
|
3575
|
+
signal?: AbortSignal;
|
|
3576
|
+
}): Promise<{
|
|
3577
|
+
removed: boolean;
|
|
3578
|
+
}>;
|
|
3579
|
+
};
|
|
3580
|
+
invitations: {
|
|
3581
|
+
revoke(params: {
|
|
3582
|
+
invitationId: string;
|
|
3583
|
+
}, options?: {
|
|
3584
|
+
signal?: AbortSignal;
|
|
3585
|
+
}): Promise<{
|
|
3586
|
+
revoked: boolean;
|
|
3587
|
+
}>;
|
|
3588
|
+
};
|
|
3545
3589
|
};
|
|
3546
3590
|
assets: {
|
|
3547
3591
|
list(params?: ListAssetsParams, options?: {
|
|
@@ -3832,7 +3876,16 @@ type StatsParams = {
|
|
|
3832
3876
|
window?: "24h" | "7d" | "30d";
|
|
3833
3877
|
};
|
|
3834
3878
|
type WaitOptions = {
|
|
3835
|
-
/**
|
|
3879
|
+
/**
|
|
3880
|
+
* Max wait time in ms.
|
|
3881
|
+
*
|
|
3882
|
+
* Omit it and the wait follows the job's own execution budget (`job.timeoutMs`,
|
|
3883
|
+
* your plan's per-job limit) plus grace for upload and callback, so a long job
|
|
3884
|
+
* is not reported as timed out while it is still running. Until the server
|
|
3885
|
+
* reports that budget the bound is 5 minutes, which is also the floor.
|
|
3886
|
+
*
|
|
3887
|
+
* Pass a number to bound the wait yourself regardless of the job's budget.
|
|
3888
|
+
*/
|
|
3836
3889
|
timeout?: number;
|
|
3837
3890
|
/** Initial poll interval in ms. Default: 2_000. Grows with exponential backoff. */
|
|
3838
3891
|
interval?: number;
|
package/dist/index.d.mts
CHANGED
|
@@ -2298,6 +2298,7 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2298
2298
|
resourcesAvailable: ZodBoolean;
|
|
2299
2299
|
metricsAvailable: ZodOptional<ZodBoolean>;
|
|
2300
2300
|
region: ZodOptional<ZodNullable<ZodString>>;
|
|
2301
|
+
timeoutMs: ZodNullable<ZodNumber>;
|
|
2301
2302
|
createdAt: ZodNumber;
|
|
2302
2303
|
dispatchedAt: ZodNullable<ZodNumber>;
|
|
2303
2304
|
startedAt: ZodNullable<ZodNumber>;
|
|
@@ -2352,6 +2353,7 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2352
2353
|
resourcesAvailable: ZodBoolean;
|
|
2353
2354
|
metricsAvailable: ZodOptional<ZodBoolean>;
|
|
2354
2355
|
region: ZodOptional<ZodNullable<ZodString>>;
|
|
2356
|
+
timeoutMs: ZodNullable<ZodNumber>;
|
|
2355
2357
|
createdAt: ZodNumber;
|
|
2356
2358
|
dispatchedAt: ZodNullable<ZodNumber>;
|
|
2357
2359
|
startedAt: ZodNullable<ZodNumber>;
|
|
@@ -2415,6 +2417,7 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2415
2417
|
resourcesAvailable: ZodBoolean;
|
|
2416
2418
|
metricsAvailable: ZodOptional<ZodBoolean>;
|
|
2417
2419
|
region: ZodOptional<ZodNullable<ZodString>>;
|
|
2420
|
+
timeoutMs: ZodNullable<ZodNumber>;
|
|
2418
2421
|
createdAt: ZodNumber;
|
|
2419
2422
|
dispatchedAt: ZodNullable<ZodNumber>;
|
|
2420
2423
|
startedAt: ZodNullable<ZodNumber>;
|
|
@@ -2471,6 +2474,7 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2471
2474
|
resourcesAvailable: ZodBoolean;
|
|
2472
2475
|
metricsAvailable: ZodOptional<ZodBoolean>;
|
|
2473
2476
|
region: ZodOptional<ZodNullable<ZodString>>;
|
|
2477
|
+
timeoutMs: ZodNullable<ZodNumber>;
|
|
2474
2478
|
createdAt: ZodNumber;
|
|
2475
2479
|
dispatchedAt: ZodNullable<ZodNumber>;
|
|
2476
2480
|
startedAt: ZodNullable<ZodNumber>;
|
|
@@ -2571,6 +2575,7 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2571
2575
|
resourcesAvailable: ZodBoolean;
|
|
2572
2576
|
metricsAvailable: ZodOptional<ZodBoolean>;
|
|
2573
2577
|
region: ZodOptional<ZodNullable<ZodString>>;
|
|
2578
|
+
timeoutMs: ZodNullable<ZodNumber>;
|
|
2574
2579
|
createdAt: ZodNumber;
|
|
2575
2580
|
dispatchedAt: ZodNullable<ZodNumber>;
|
|
2576
2581
|
startedAt: ZodNullable<ZodNumber>;
|
|
@@ -2636,6 +2641,7 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2636
2641
|
resourcesAvailable: ZodBoolean;
|
|
2637
2642
|
metricsAvailable: ZodOptional<ZodBoolean>;
|
|
2638
2643
|
region: ZodOptional<ZodNullable<ZodString>>;
|
|
2644
|
+
timeoutMs: ZodNullable<ZodNumber>;
|
|
2639
2645
|
createdAt: ZodNumber;
|
|
2640
2646
|
dispatchedAt: ZodNullable<ZodNumber>;
|
|
2641
2647
|
startedAt: ZodNullable<ZodNumber>;
|
|
@@ -3542,6 +3548,44 @@ declare function createClient(config?: ClientConfig): {
|
|
|
3542
3548
|
updateSettings(body: Partial<Pick<OrgSettings, "billingEmailsEnabled" | "defaultRegion" | "regionPinned">>, options?: {
|
|
3543
3549
|
signal?: AbortSignal;
|
|
3544
3550
|
}): Promise<OrgSettings>;
|
|
3551
|
+
members: {
|
|
3552
|
+
invite(params: {
|
|
3553
|
+
email: string;
|
|
3554
|
+
role: "admin" | "member";
|
|
3555
|
+
}, options?: {
|
|
3556
|
+
signal?: AbortSignal;
|
|
3557
|
+
}): Promise<{
|
|
3558
|
+
id: string;
|
|
3559
|
+
email: string;
|
|
3560
|
+
role: string;
|
|
3561
|
+
expiresAt: number;
|
|
3562
|
+
}>;
|
|
3563
|
+
changeRole(params: {
|
|
3564
|
+
memberId: string;
|
|
3565
|
+
role: "admin" | "member";
|
|
3566
|
+
}, options?: {
|
|
3567
|
+
signal?: AbortSignal;
|
|
3568
|
+
}): Promise<{
|
|
3569
|
+
memberId: string;
|
|
3570
|
+
role: string;
|
|
3571
|
+
}>;
|
|
3572
|
+
remove(params: {
|
|
3573
|
+
memberId: string;
|
|
3574
|
+
}, options?: {
|
|
3575
|
+
signal?: AbortSignal;
|
|
3576
|
+
}): Promise<{
|
|
3577
|
+
removed: boolean;
|
|
3578
|
+
}>;
|
|
3579
|
+
};
|
|
3580
|
+
invitations: {
|
|
3581
|
+
revoke(params: {
|
|
3582
|
+
invitationId: string;
|
|
3583
|
+
}, options?: {
|
|
3584
|
+
signal?: AbortSignal;
|
|
3585
|
+
}): Promise<{
|
|
3586
|
+
revoked: boolean;
|
|
3587
|
+
}>;
|
|
3588
|
+
};
|
|
3545
3589
|
};
|
|
3546
3590
|
assets: {
|
|
3547
3591
|
list(params?: ListAssetsParams, options?: {
|
|
@@ -3832,7 +3876,16 @@ type StatsParams = {
|
|
|
3832
3876
|
window?: "24h" | "7d" | "30d";
|
|
3833
3877
|
};
|
|
3834
3878
|
type WaitOptions = {
|
|
3835
|
-
/**
|
|
3879
|
+
/**
|
|
3880
|
+
* Max wait time in ms.
|
|
3881
|
+
*
|
|
3882
|
+
* Omit it and the wait follows the job's own execution budget (`job.timeoutMs`,
|
|
3883
|
+
* your plan's per-job limit) plus grace for upload and callback, so a long job
|
|
3884
|
+
* is not reported as timed out while it is still running. Until the server
|
|
3885
|
+
* reports that budget the bound is 5 minutes, which is also the floor.
|
|
3886
|
+
*
|
|
3887
|
+
* Pass a number to bound the wait yourself regardless of the job's budget.
|
|
3888
|
+
*/
|
|
3836
3889
|
timeout?: number;
|
|
3837
3890
|
/** Initial poll interval in ms. Default: 2_000. Grows with exponential backoff. */
|
|
3838
3891
|
interval?: number;
|
package/dist/index.mjs
CHANGED
|
@@ -180,16 +180,31 @@ const TERMINAL_JOB_STATUSES$1 = /* @__PURE__ */ new Set([
|
|
|
180
180
|
"failed",
|
|
181
181
|
"cancelled"
|
|
182
182
|
]);
|
|
183
|
+
/** Wait bound used until the server reports the job's own budget, and the floor. */
|
|
184
|
+
const DEFAULT_WAIT_TIMEOUT_MS = 3e5;
|
|
185
|
+
/** Headroom past the execution budget for upload + terminal callback delivery. */
|
|
186
|
+
const WAIT_GRACE_MS = 12e4;
|
|
183
187
|
function createJobsResource(request) {
|
|
184
188
|
async function wait(id, options = {}) {
|
|
185
|
-
const { timeout
|
|
186
|
-
const
|
|
189
|
+
const { timeout, interval = 2e3, maxInterval = 1e4, onProgress, signal, throwOnFailure = false } = options;
|
|
190
|
+
const waitStartedAt = Date.now();
|
|
191
|
+
let effectiveTimeout = timeout ?? DEFAULT_WAIT_TIMEOUT_MS;
|
|
192
|
+
let deadline = waitStartedAt + effectiveTimeout;
|
|
193
|
+
let adoptedJobBudget = false;
|
|
187
194
|
let currentInterval = interval;
|
|
188
195
|
while (Date.now() < deadline) {
|
|
189
196
|
if (signal?.aborted) throw new DOMException("Wait aborted", "AbortError");
|
|
190
197
|
const job = await request(`/jobs/${id}`, { signal });
|
|
191
198
|
onProgress?.(job);
|
|
192
199
|
if (TERMINAL_JOB_STATUSES$1.has(job.status)) return resolveTerminal(id, job, throwOnFailure);
|
|
200
|
+
if (timeout === void 0 && !adoptedJobBudget && typeof job.timeoutMs === "number") {
|
|
201
|
+
adoptedJobBudget = true;
|
|
202
|
+
const budgetDeadline = waitStartedAt + job.timeoutMs + WAIT_GRACE_MS;
|
|
203
|
+
if (budgetDeadline > deadline) {
|
|
204
|
+
deadline = budgetDeadline;
|
|
205
|
+
effectiveTimeout = deadline - waitStartedAt;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
193
208
|
const remaining = deadline - Date.now();
|
|
194
209
|
const delay = Math.min(currentInterval, remaining);
|
|
195
210
|
if (delay <= 0) break;
|
|
@@ -199,7 +214,7 @@ function createJobsResource(request) {
|
|
|
199
214
|
const job = await request(`/jobs/${id}`, { signal });
|
|
200
215
|
onProgress?.(job);
|
|
201
216
|
if (TERMINAL_JOB_STATUSES$1.has(job.status)) return resolveTerminal(id, job, throwOnFailure);
|
|
202
|
-
throw new WaitTimeoutError(id, job.status,
|
|
217
|
+
throw new WaitTimeoutError(id, job.status, effectiveTimeout);
|
|
203
218
|
}
|
|
204
219
|
async function create(params, options) {
|
|
205
220
|
return request("/jobs", {
|
|
@@ -686,7 +701,46 @@ function createOrgsResource(request) {
|
|
|
686
701
|
body,
|
|
687
702
|
signal: options?.signal
|
|
688
703
|
});
|
|
689
|
-
}
|
|
704
|
+
},
|
|
705
|
+
/**
|
|
706
|
+
* Organization membership. Replaces `client.team.*`, which named a
|
|
707
|
+
* resource the API does not have: there is no team, only an organization
|
|
708
|
+
* with members and invitations.
|
|
709
|
+
*/
|
|
710
|
+
members: {
|
|
711
|
+
/** Invite someone to the current organization. Owner or admin only. */
|
|
712
|
+
async invite(params, options) {
|
|
713
|
+
return request("/orgs/current/members", {
|
|
714
|
+
method: "POST",
|
|
715
|
+
body: params,
|
|
716
|
+
signal: options?.signal
|
|
717
|
+
});
|
|
718
|
+
},
|
|
719
|
+
/** Change a member's role. Owner or admin only. */
|
|
720
|
+
async changeRole(params, options) {
|
|
721
|
+
return request(`/orgs/current/members/${params.memberId}`, {
|
|
722
|
+
method: "PATCH",
|
|
723
|
+
body: { role: params.role },
|
|
724
|
+
signal: options?.signal
|
|
725
|
+
});
|
|
726
|
+
},
|
|
727
|
+
/** Remove a member, or pass your own member id to leave. */
|
|
728
|
+
async remove(params, options) {
|
|
729
|
+
return request(`/orgs/current/members/${params.memberId}`, {
|
|
730
|
+
method: "DELETE",
|
|
731
|
+
signal: options?.signal
|
|
732
|
+
});
|
|
733
|
+
}
|
|
734
|
+
},
|
|
735
|
+
/** Pending invitations to the current organization. */
|
|
736
|
+
invitations: {
|
|
737
|
+
/** Cancel a pending invitation. Owner or admin only. */
|
|
738
|
+
async revoke(params, options) {
|
|
739
|
+
return request(`/orgs/current/invitations/${params.invitationId}`, {
|
|
740
|
+
method: "DELETE",
|
|
741
|
+
signal: options?.signal
|
|
742
|
+
});
|
|
743
|
+
} }
|
|
690
744
|
};
|
|
691
745
|
}
|
|
692
746
|
//#endregion
|
|
@@ -721,8 +775,16 @@ function createAssetsResource(request) {
|
|
|
721
775
|
}
|
|
722
776
|
//#endregion
|
|
723
777
|
//#region src/resources/team.ts
|
|
778
|
+
/**
|
|
779
|
+
* DEPRECATED. Use `client.orgs.members` and `client.orgs.invitations`.
|
|
780
|
+
*
|
|
781
|
+
* These wrap `/team/*`, which names a resource the API does not have: there is
|
|
782
|
+
* no team, only an organization with members and invitations. The endpoints
|
|
783
|
+
* still work and will keep working until the next major.
|
|
784
|
+
*/
|
|
724
785
|
function createTeamResource(request) {
|
|
725
786
|
return {
|
|
787
|
+
/** @deprecated Use `client.orgs.members.invite()`. */
|
|
726
788
|
async invite(params, options) {
|
|
727
789
|
return request("/team/invite", {
|
|
728
790
|
method: "POST",
|
|
@@ -730,13 +792,15 @@ function createTeamResource(request) {
|
|
|
730
792
|
signal: options?.signal
|
|
731
793
|
});
|
|
732
794
|
},
|
|
795
|
+
/** @deprecated Use `client.orgs.members.changeRole()`. */
|
|
733
796
|
async changeRole(params, options) {
|
|
734
797
|
await request("/team/role", {
|
|
735
|
-
method: "
|
|
798
|
+
method: "PATCH",
|
|
736
799
|
body: params,
|
|
737
800
|
signal: options?.signal
|
|
738
801
|
});
|
|
739
802
|
},
|
|
803
|
+
/** @deprecated Use `client.orgs.members.remove()`. */
|
|
740
804
|
async remove(params, options) {
|
|
741
805
|
await request("/team/remove", {
|
|
742
806
|
method: "POST",
|
|
@@ -744,6 +808,7 @@ function createTeamResource(request) {
|
|
|
744
808
|
signal: options?.signal
|
|
745
809
|
});
|
|
746
810
|
},
|
|
811
|
+
/** @deprecated Use `client.orgs.invitations.revoke()`. */
|
|
747
812
|
async revokeInvitation(params, options) {
|
|
748
813
|
await request("/team/revoke-invitation", {
|
|
749
814
|
method: "POST",
|