pushq 0.1.0-beta.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/LICENSE +21 -0
- package/README.md +63 -0
- package/dist/index.cjs +447 -0
- package/dist/index.d.cts +232 -0
- package/dist/index.d.ts +232 -0
- package/dist/index.js +416 -0
- package/package.json +56 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
/** Rate limits for a queue (GCP Cloud Tasks semantics). */
|
|
2
|
+
interface RateLimits {
|
|
3
|
+
/** Tokens per second. Default 500. */
|
|
4
|
+
maxDispatchesPerSecond?: number;
|
|
5
|
+
/** Token bucket burst. 0/omitted = auto: clamp(ceil(rate), 1, 500). */
|
|
6
|
+
maxBurstSize?: number;
|
|
7
|
+
/** Max concurrent in-flight dispatches. Default 1000. */
|
|
8
|
+
maxConcurrentDispatches?: number;
|
|
9
|
+
}
|
|
10
|
+
/** Retry configuration (GCP Cloud Tasks semantics). */
|
|
11
|
+
interface RetryConfig {
|
|
12
|
+
/** Includes the first attempt; -1 = unlimited. Default 100. */
|
|
13
|
+
maxAttempts?: number;
|
|
14
|
+
/** Seconds from the first attempt; 0 = unlimited. */
|
|
15
|
+
maxRetryDurationSeconds?: number;
|
|
16
|
+
minBackoffSeconds?: number;
|
|
17
|
+
maxBackoffSeconds?: number;
|
|
18
|
+
/** Interval doubles this many times, then grows linearly, capped at maxBackoff. */
|
|
19
|
+
maxDoublings?: number;
|
|
20
|
+
}
|
|
21
|
+
interface Target {
|
|
22
|
+
/** Absolute http(s) URL; resolves tasks created with a relative `path`. */
|
|
23
|
+
baseUrl?: string;
|
|
24
|
+
/** Overrides every task's method when set. */
|
|
25
|
+
method?: string;
|
|
26
|
+
/** Merged over task headers at dispatch (queue wins). */
|
|
27
|
+
headers?: Record<string, string>;
|
|
28
|
+
/**
|
|
29
|
+
* Standard Webhooks secret ("whsec_…"). On upsert: undefined = keep the
|
|
30
|
+
* stored secret, "" = clear it.
|
|
31
|
+
*/
|
|
32
|
+
signingSecret?: string;
|
|
33
|
+
}
|
|
34
|
+
interface QueueConfig {
|
|
35
|
+
rateLimits?: RateLimits;
|
|
36
|
+
retry?: RetryConfig;
|
|
37
|
+
target?: Target;
|
|
38
|
+
deadLetterQueue?: string;
|
|
39
|
+
}
|
|
40
|
+
interface QueuePatch extends QueueConfig {
|
|
41
|
+
state?: "running" | "paused" | "disabled";
|
|
42
|
+
}
|
|
43
|
+
interface Queue {
|
|
44
|
+
name: string;
|
|
45
|
+
state: "running" | "paused" | "disabled";
|
|
46
|
+
rateLimits: Required<RateLimits>;
|
|
47
|
+
retry: Required<RetryConfig>;
|
|
48
|
+
target: {
|
|
49
|
+
baseUrl?: string;
|
|
50
|
+
method?: string;
|
|
51
|
+
headers?: Record<string, string>;
|
|
52
|
+
hasSigningSecret: boolean;
|
|
53
|
+
};
|
|
54
|
+
deadLetterQueue?: string;
|
|
55
|
+
purgedAt?: Date;
|
|
56
|
+
createdAt: Date;
|
|
57
|
+
updatedAt: Date;
|
|
58
|
+
}
|
|
59
|
+
interface QueueStats {
|
|
60
|
+
state: string;
|
|
61
|
+
pending: number;
|
|
62
|
+
running: number;
|
|
63
|
+
succeeded: number;
|
|
64
|
+
failed: number;
|
|
65
|
+
scheduledFuture: number;
|
|
66
|
+
oldestDueAt?: Date;
|
|
67
|
+
oldestDueAgeSeconds?: number;
|
|
68
|
+
dispatchedLast1m: number;
|
|
69
|
+
errorsLast1m: number;
|
|
70
|
+
dispatchedLast1h: number;
|
|
71
|
+
errorsLast1h: number;
|
|
72
|
+
lastPurge?: Date;
|
|
73
|
+
}
|
|
74
|
+
interface TaskCreate {
|
|
75
|
+
/** Client-chosen ID for dedup (409 on collision). Omitted = server UUIDv7. */
|
|
76
|
+
taskId?: string;
|
|
77
|
+
/** Absolute http(s) URL. Exactly one of url/path. */
|
|
78
|
+
url?: string;
|
|
79
|
+
/** Path resolved against the queue's target.baseUrl at dispatch time. */
|
|
80
|
+
path?: string;
|
|
81
|
+
method?: string;
|
|
82
|
+
headers?: Record<string, string>;
|
|
83
|
+
/** Raw body bytes or string. Exclusive with jsonBody. POST/PUT/PATCH only. */
|
|
84
|
+
body?: Uint8Array | string;
|
|
85
|
+
/** Any JSON value, sent with Content-Type: application/json. */
|
|
86
|
+
jsonBody?: unknown;
|
|
87
|
+
/** Exclusive with delaySeconds. */
|
|
88
|
+
scheduleTime?: Date | string;
|
|
89
|
+
delaySeconds?: number;
|
|
90
|
+
/** 15–1800; default 600. */
|
|
91
|
+
dispatchDeadlineSeconds?: number;
|
|
92
|
+
/** Per-task override of the queue retry config (any subset). */
|
|
93
|
+
retry?: RetryConfig;
|
|
94
|
+
}
|
|
95
|
+
interface Task {
|
|
96
|
+
id: string;
|
|
97
|
+
queue: string;
|
|
98
|
+
state: "pending" | "running" | "succeeded" | "failed";
|
|
99
|
+
url: string;
|
|
100
|
+
method: string;
|
|
101
|
+
headers?: Record<string, string>;
|
|
102
|
+
/** Only populated with view: "full". */
|
|
103
|
+
body?: Uint8Array;
|
|
104
|
+
scheduleTime: Date;
|
|
105
|
+
createdAt: Date;
|
|
106
|
+
dispatchDeadlineSeconds: number;
|
|
107
|
+
retry?: RetryConfig;
|
|
108
|
+
dispatchCount: number;
|
|
109
|
+
responseCount: number;
|
|
110
|
+
firstAttemptAt?: Date;
|
|
111
|
+
finishedAt?: Date;
|
|
112
|
+
lastAttempt?: {
|
|
113
|
+
at: Date;
|
|
114
|
+
status?: number;
|
|
115
|
+
error?: string;
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
interface Attempt {
|
|
119
|
+
number: number;
|
|
120
|
+
dispatchTime: Date;
|
|
121
|
+
responseTime?: Date;
|
|
122
|
+
responseStatus?: number;
|
|
123
|
+
errorKind?: string;
|
|
124
|
+
errorSnippet?: string;
|
|
125
|
+
durationMs: number;
|
|
126
|
+
}
|
|
127
|
+
interface BatchResult {
|
|
128
|
+
index: number;
|
|
129
|
+
task?: Task;
|
|
130
|
+
error?: {
|
|
131
|
+
code: string;
|
|
132
|
+
detail: string;
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
interface ListTasksParams {
|
|
136
|
+
state?: "pending" | "running" | "succeeded" | "failed";
|
|
137
|
+
idPrefix?: string;
|
|
138
|
+
view?: "basic" | "full";
|
|
139
|
+
pageSize?: number;
|
|
140
|
+
pageToken?: string;
|
|
141
|
+
}
|
|
142
|
+
interface ListQueuesParams {
|
|
143
|
+
namePrefix?: string;
|
|
144
|
+
pageSize?: number;
|
|
145
|
+
pageToken?: string;
|
|
146
|
+
}
|
|
147
|
+
interface Page<T> {
|
|
148
|
+
items: T[];
|
|
149
|
+
nextPageToken?: string;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/** Error thrown for any non-2xx API response (RFC 9457 problem+json). */
|
|
153
|
+
declare class PushqError extends Error {
|
|
154
|
+
readonly status: number;
|
|
155
|
+
/** Stable machine code: already_exists, not_found, failed_precondition, … */
|
|
156
|
+
readonly code: string;
|
|
157
|
+
readonly detail: string;
|
|
158
|
+
constructor(status: number, code: string, detail: string);
|
|
159
|
+
}
|
|
160
|
+
interface PushqOptions {
|
|
161
|
+
/** e.g. "http://localhost:8080" */
|
|
162
|
+
baseUrl: string;
|
|
163
|
+
apiKey?: string;
|
|
164
|
+
/** Per-request timeout in ms. Default 30_000. */
|
|
165
|
+
timeoutMs?: number;
|
|
166
|
+
/** Custom fetch (tests, polyfills). Defaults to globalThis.fetch. */
|
|
167
|
+
fetch?: typeof fetch;
|
|
168
|
+
}
|
|
169
|
+
declare class Pushq {
|
|
170
|
+
private readonly base;
|
|
171
|
+
private readonly apiKey?;
|
|
172
|
+
private readonly timeoutMs;
|
|
173
|
+
private readonly fetchFn;
|
|
174
|
+
constructor(opts: PushqOptions);
|
|
175
|
+
/** Create or replace queue config (idempotent; never changes run state). */
|
|
176
|
+
upsertQueue(name: string, cfg?: QueueConfig): Promise<Queue>;
|
|
177
|
+
/** Create a queue; rejects with already_exists if present. */
|
|
178
|
+
createQueue(name: string, cfg?: QueueConfig): Promise<Queue>;
|
|
179
|
+
getQueue(name: string): Promise<Queue>;
|
|
180
|
+
/** Update only the provided fields (can set state, including "disabled"). */
|
|
181
|
+
patchQueue(name: string, patch: QueuePatch): Promise<Queue>;
|
|
182
|
+
/** Admin role required. */
|
|
183
|
+
listQueues(params?: ListQueuesParams): Promise<Page<Queue>>;
|
|
184
|
+
/** Admin role required. Deletes the queue and every task in it. */
|
|
185
|
+
deleteQueue(name: string): Promise<void>;
|
|
186
|
+
pauseQueue(name: string): Promise<Queue>;
|
|
187
|
+
resumeQueue(name: string): Promise<Queue>;
|
|
188
|
+
/** Deletes every task created up to now (exact watermark; IDs become reusable). */
|
|
189
|
+
purgeQueue(name: string): Promise<Queue>;
|
|
190
|
+
queueStats(name: string, opts?: {
|
|
191
|
+
idPrefix?: string;
|
|
192
|
+
}): Promise<QueueStats>;
|
|
193
|
+
createTask(queue: string, task: TaskCreate): Promise<Task>;
|
|
194
|
+
/** Enqueue up to 500 tasks; non-atomic, per-item results in order. */
|
|
195
|
+
createTasks(queue: string, tasks: TaskCreate[]): Promise<BatchResult[]>;
|
|
196
|
+
getTask(queue: string, id: string, opts?: {
|
|
197
|
+
view?: "basic" | "full";
|
|
198
|
+
}): Promise<Task>;
|
|
199
|
+
listTasks(queue: string, params?: ListTasksParams): Promise<Page<Task>>;
|
|
200
|
+
/** Deletes a task; the ID stays reserved for the dedup window. */
|
|
201
|
+
deleteTask(queue: string, id: string): Promise<void>;
|
|
202
|
+
/** Force immediate dispatch, bypassing rate limits and PAUSED state. */
|
|
203
|
+
runTask(queue: string, id: string): Promise<Task>;
|
|
204
|
+
listAttempts(queue: string, id: string): Promise<Attempt[]>;
|
|
205
|
+
private request;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
declare class WebhookVerificationError extends Error {
|
|
209
|
+
constructor(message: string);
|
|
210
|
+
}
|
|
211
|
+
interface VerifyOptions {
|
|
212
|
+
/** The queue's signing secret ("whsec_…" or raw). */
|
|
213
|
+
secret: string;
|
|
214
|
+
/** Incoming request headers (Headers, or a plain object). */
|
|
215
|
+
headers: Headers | Record<string, string | string[] | undefined>;
|
|
216
|
+
/** The raw request body, exactly as received. */
|
|
217
|
+
payload: string | Uint8Array;
|
|
218
|
+
/** Reject timestamps further than this from now. Default 300s; 0 disables. */
|
|
219
|
+
toleranceSeconds?: number;
|
|
220
|
+
/** Override "now" (tests). */
|
|
221
|
+
now?: Date;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Verifies a pushq delivery. Resolves with the webhook id ("queue/task_id",
|
|
225
|
+
* stable across retries — usable as an idempotency key) or throws
|
|
226
|
+
* WebhookVerificationError.
|
|
227
|
+
*/
|
|
228
|
+
declare function verifySignature(opts: VerifyOptions): Promise<string>;
|
|
229
|
+
/** Computes a "v1,<base64>" signature (test/tooling helper). */
|
|
230
|
+
declare function sign(secret: string, msgId: string, timestampSeconds: number, payload: string | Uint8Array): Promise<string>;
|
|
231
|
+
|
|
232
|
+
export { type Attempt, type BatchResult, type ListQueuesParams, type ListTasksParams, type Page, Pushq, PushqError, type PushqOptions, type Queue, type QueueConfig, type QueuePatch, type QueueStats, type RateLimits, type RetryConfig, type Target, type Task, type TaskCreate, type VerifyOptions, WebhookVerificationError, sign, verifySignature };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
/** Rate limits for a queue (GCP Cloud Tasks semantics). */
|
|
2
|
+
interface RateLimits {
|
|
3
|
+
/** Tokens per second. Default 500. */
|
|
4
|
+
maxDispatchesPerSecond?: number;
|
|
5
|
+
/** Token bucket burst. 0/omitted = auto: clamp(ceil(rate), 1, 500). */
|
|
6
|
+
maxBurstSize?: number;
|
|
7
|
+
/** Max concurrent in-flight dispatches. Default 1000. */
|
|
8
|
+
maxConcurrentDispatches?: number;
|
|
9
|
+
}
|
|
10
|
+
/** Retry configuration (GCP Cloud Tasks semantics). */
|
|
11
|
+
interface RetryConfig {
|
|
12
|
+
/** Includes the first attempt; -1 = unlimited. Default 100. */
|
|
13
|
+
maxAttempts?: number;
|
|
14
|
+
/** Seconds from the first attempt; 0 = unlimited. */
|
|
15
|
+
maxRetryDurationSeconds?: number;
|
|
16
|
+
minBackoffSeconds?: number;
|
|
17
|
+
maxBackoffSeconds?: number;
|
|
18
|
+
/** Interval doubles this many times, then grows linearly, capped at maxBackoff. */
|
|
19
|
+
maxDoublings?: number;
|
|
20
|
+
}
|
|
21
|
+
interface Target {
|
|
22
|
+
/** Absolute http(s) URL; resolves tasks created with a relative `path`. */
|
|
23
|
+
baseUrl?: string;
|
|
24
|
+
/** Overrides every task's method when set. */
|
|
25
|
+
method?: string;
|
|
26
|
+
/** Merged over task headers at dispatch (queue wins). */
|
|
27
|
+
headers?: Record<string, string>;
|
|
28
|
+
/**
|
|
29
|
+
* Standard Webhooks secret ("whsec_…"). On upsert: undefined = keep the
|
|
30
|
+
* stored secret, "" = clear it.
|
|
31
|
+
*/
|
|
32
|
+
signingSecret?: string;
|
|
33
|
+
}
|
|
34
|
+
interface QueueConfig {
|
|
35
|
+
rateLimits?: RateLimits;
|
|
36
|
+
retry?: RetryConfig;
|
|
37
|
+
target?: Target;
|
|
38
|
+
deadLetterQueue?: string;
|
|
39
|
+
}
|
|
40
|
+
interface QueuePatch extends QueueConfig {
|
|
41
|
+
state?: "running" | "paused" | "disabled";
|
|
42
|
+
}
|
|
43
|
+
interface Queue {
|
|
44
|
+
name: string;
|
|
45
|
+
state: "running" | "paused" | "disabled";
|
|
46
|
+
rateLimits: Required<RateLimits>;
|
|
47
|
+
retry: Required<RetryConfig>;
|
|
48
|
+
target: {
|
|
49
|
+
baseUrl?: string;
|
|
50
|
+
method?: string;
|
|
51
|
+
headers?: Record<string, string>;
|
|
52
|
+
hasSigningSecret: boolean;
|
|
53
|
+
};
|
|
54
|
+
deadLetterQueue?: string;
|
|
55
|
+
purgedAt?: Date;
|
|
56
|
+
createdAt: Date;
|
|
57
|
+
updatedAt: Date;
|
|
58
|
+
}
|
|
59
|
+
interface QueueStats {
|
|
60
|
+
state: string;
|
|
61
|
+
pending: number;
|
|
62
|
+
running: number;
|
|
63
|
+
succeeded: number;
|
|
64
|
+
failed: number;
|
|
65
|
+
scheduledFuture: number;
|
|
66
|
+
oldestDueAt?: Date;
|
|
67
|
+
oldestDueAgeSeconds?: number;
|
|
68
|
+
dispatchedLast1m: number;
|
|
69
|
+
errorsLast1m: number;
|
|
70
|
+
dispatchedLast1h: number;
|
|
71
|
+
errorsLast1h: number;
|
|
72
|
+
lastPurge?: Date;
|
|
73
|
+
}
|
|
74
|
+
interface TaskCreate {
|
|
75
|
+
/** Client-chosen ID for dedup (409 on collision). Omitted = server UUIDv7. */
|
|
76
|
+
taskId?: string;
|
|
77
|
+
/** Absolute http(s) URL. Exactly one of url/path. */
|
|
78
|
+
url?: string;
|
|
79
|
+
/** Path resolved against the queue's target.baseUrl at dispatch time. */
|
|
80
|
+
path?: string;
|
|
81
|
+
method?: string;
|
|
82
|
+
headers?: Record<string, string>;
|
|
83
|
+
/** Raw body bytes or string. Exclusive with jsonBody. POST/PUT/PATCH only. */
|
|
84
|
+
body?: Uint8Array | string;
|
|
85
|
+
/** Any JSON value, sent with Content-Type: application/json. */
|
|
86
|
+
jsonBody?: unknown;
|
|
87
|
+
/** Exclusive with delaySeconds. */
|
|
88
|
+
scheduleTime?: Date | string;
|
|
89
|
+
delaySeconds?: number;
|
|
90
|
+
/** 15–1800; default 600. */
|
|
91
|
+
dispatchDeadlineSeconds?: number;
|
|
92
|
+
/** Per-task override of the queue retry config (any subset). */
|
|
93
|
+
retry?: RetryConfig;
|
|
94
|
+
}
|
|
95
|
+
interface Task {
|
|
96
|
+
id: string;
|
|
97
|
+
queue: string;
|
|
98
|
+
state: "pending" | "running" | "succeeded" | "failed";
|
|
99
|
+
url: string;
|
|
100
|
+
method: string;
|
|
101
|
+
headers?: Record<string, string>;
|
|
102
|
+
/** Only populated with view: "full". */
|
|
103
|
+
body?: Uint8Array;
|
|
104
|
+
scheduleTime: Date;
|
|
105
|
+
createdAt: Date;
|
|
106
|
+
dispatchDeadlineSeconds: number;
|
|
107
|
+
retry?: RetryConfig;
|
|
108
|
+
dispatchCount: number;
|
|
109
|
+
responseCount: number;
|
|
110
|
+
firstAttemptAt?: Date;
|
|
111
|
+
finishedAt?: Date;
|
|
112
|
+
lastAttempt?: {
|
|
113
|
+
at: Date;
|
|
114
|
+
status?: number;
|
|
115
|
+
error?: string;
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
interface Attempt {
|
|
119
|
+
number: number;
|
|
120
|
+
dispatchTime: Date;
|
|
121
|
+
responseTime?: Date;
|
|
122
|
+
responseStatus?: number;
|
|
123
|
+
errorKind?: string;
|
|
124
|
+
errorSnippet?: string;
|
|
125
|
+
durationMs: number;
|
|
126
|
+
}
|
|
127
|
+
interface BatchResult {
|
|
128
|
+
index: number;
|
|
129
|
+
task?: Task;
|
|
130
|
+
error?: {
|
|
131
|
+
code: string;
|
|
132
|
+
detail: string;
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
interface ListTasksParams {
|
|
136
|
+
state?: "pending" | "running" | "succeeded" | "failed";
|
|
137
|
+
idPrefix?: string;
|
|
138
|
+
view?: "basic" | "full";
|
|
139
|
+
pageSize?: number;
|
|
140
|
+
pageToken?: string;
|
|
141
|
+
}
|
|
142
|
+
interface ListQueuesParams {
|
|
143
|
+
namePrefix?: string;
|
|
144
|
+
pageSize?: number;
|
|
145
|
+
pageToken?: string;
|
|
146
|
+
}
|
|
147
|
+
interface Page<T> {
|
|
148
|
+
items: T[];
|
|
149
|
+
nextPageToken?: string;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/** Error thrown for any non-2xx API response (RFC 9457 problem+json). */
|
|
153
|
+
declare class PushqError extends Error {
|
|
154
|
+
readonly status: number;
|
|
155
|
+
/** Stable machine code: already_exists, not_found, failed_precondition, … */
|
|
156
|
+
readonly code: string;
|
|
157
|
+
readonly detail: string;
|
|
158
|
+
constructor(status: number, code: string, detail: string);
|
|
159
|
+
}
|
|
160
|
+
interface PushqOptions {
|
|
161
|
+
/** e.g. "http://localhost:8080" */
|
|
162
|
+
baseUrl: string;
|
|
163
|
+
apiKey?: string;
|
|
164
|
+
/** Per-request timeout in ms. Default 30_000. */
|
|
165
|
+
timeoutMs?: number;
|
|
166
|
+
/** Custom fetch (tests, polyfills). Defaults to globalThis.fetch. */
|
|
167
|
+
fetch?: typeof fetch;
|
|
168
|
+
}
|
|
169
|
+
declare class Pushq {
|
|
170
|
+
private readonly base;
|
|
171
|
+
private readonly apiKey?;
|
|
172
|
+
private readonly timeoutMs;
|
|
173
|
+
private readonly fetchFn;
|
|
174
|
+
constructor(opts: PushqOptions);
|
|
175
|
+
/** Create or replace queue config (idempotent; never changes run state). */
|
|
176
|
+
upsertQueue(name: string, cfg?: QueueConfig): Promise<Queue>;
|
|
177
|
+
/** Create a queue; rejects with already_exists if present. */
|
|
178
|
+
createQueue(name: string, cfg?: QueueConfig): Promise<Queue>;
|
|
179
|
+
getQueue(name: string): Promise<Queue>;
|
|
180
|
+
/** Update only the provided fields (can set state, including "disabled"). */
|
|
181
|
+
patchQueue(name: string, patch: QueuePatch): Promise<Queue>;
|
|
182
|
+
/** Admin role required. */
|
|
183
|
+
listQueues(params?: ListQueuesParams): Promise<Page<Queue>>;
|
|
184
|
+
/** Admin role required. Deletes the queue and every task in it. */
|
|
185
|
+
deleteQueue(name: string): Promise<void>;
|
|
186
|
+
pauseQueue(name: string): Promise<Queue>;
|
|
187
|
+
resumeQueue(name: string): Promise<Queue>;
|
|
188
|
+
/** Deletes every task created up to now (exact watermark; IDs become reusable). */
|
|
189
|
+
purgeQueue(name: string): Promise<Queue>;
|
|
190
|
+
queueStats(name: string, opts?: {
|
|
191
|
+
idPrefix?: string;
|
|
192
|
+
}): Promise<QueueStats>;
|
|
193
|
+
createTask(queue: string, task: TaskCreate): Promise<Task>;
|
|
194
|
+
/** Enqueue up to 500 tasks; non-atomic, per-item results in order. */
|
|
195
|
+
createTasks(queue: string, tasks: TaskCreate[]): Promise<BatchResult[]>;
|
|
196
|
+
getTask(queue: string, id: string, opts?: {
|
|
197
|
+
view?: "basic" | "full";
|
|
198
|
+
}): Promise<Task>;
|
|
199
|
+
listTasks(queue: string, params?: ListTasksParams): Promise<Page<Task>>;
|
|
200
|
+
/** Deletes a task; the ID stays reserved for the dedup window. */
|
|
201
|
+
deleteTask(queue: string, id: string): Promise<void>;
|
|
202
|
+
/** Force immediate dispatch, bypassing rate limits and PAUSED state. */
|
|
203
|
+
runTask(queue: string, id: string): Promise<Task>;
|
|
204
|
+
listAttempts(queue: string, id: string): Promise<Attempt[]>;
|
|
205
|
+
private request;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
declare class WebhookVerificationError extends Error {
|
|
209
|
+
constructor(message: string);
|
|
210
|
+
}
|
|
211
|
+
interface VerifyOptions {
|
|
212
|
+
/** The queue's signing secret ("whsec_…" or raw). */
|
|
213
|
+
secret: string;
|
|
214
|
+
/** Incoming request headers (Headers, or a plain object). */
|
|
215
|
+
headers: Headers | Record<string, string | string[] | undefined>;
|
|
216
|
+
/** The raw request body, exactly as received. */
|
|
217
|
+
payload: string | Uint8Array;
|
|
218
|
+
/** Reject timestamps further than this from now. Default 300s; 0 disables. */
|
|
219
|
+
toleranceSeconds?: number;
|
|
220
|
+
/** Override "now" (tests). */
|
|
221
|
+
now?: Date;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Verifies a pushq delivery. Resolves with the webhook id ("queue/task_id",
|
|
225
|
+
* stable across retries — usable as an idempotency key) or throws
|
|
226
|
+
* WebhookVerificationError.
|
|
227
|
+
*/
|
|
228
|
+
declare function verifySignature(opts: VerifyOptions): Promise<string>;
|
|
229
|
+
/** Computes a "v1,<base64>" signature (test/tooling helper). */
|
|
230
|
+
declare function sign(secret: string, msgId: string, timestampSeconds: number, payload: string | Uint8Array): Promise<string>;
|
|
231
|
+
|
|
232
|
+
export { type Attempt, type BatchResult, type ListQueuesParams, type ListTasksParams, type Page, Pushq, PushqError, type PushqOptions, type Queue, type QueueConfig, type QueuePatch, type QueueStats, type RateLimits, type RetryConfig, type Target, type Task, type TaskCreate, type VerifyOptions, WebhookVerificationError, sign, verifySignature };
|