pushq 0.1.0-beta.7 → 0.1.0-beta.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -13,7 +13,8 @@ npm install pushq
13
13
  ```ts
14
14
  import { Pushq } from "pushq";
15
15
 
16
- const pq = new Pushq({ baseUrl: "http://localhost:8080", apiKey: "pq_..." });
16
+ const pq = new Pushq({ apiKey: "pq_..." }); // hosted API at https://api.pushqueue.dev
17
+ // Self-hosting? new Pushq({ baseUrl: "http://localhost:8080", apiKey: "pq_..." })
17
18
 
18
19
  // Queues are created/updated at runtime — idempotent, safe to call on every enqueue.
19
20
  await pq.upsertQueue("account-42", {
package/dist/index.cjs CHANGED
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
+ DEFAULT_BASE_URL: () => DEFAULT_BASE_URL,
23
24
  Pushq: () => Pushq,
24
25
  PushqError: () => PushqError,
25
26
  WebhookVerificationError: () => WebhookVerificationError,
@@ -205,9 +206,10 @@ var PushqError = class extends Error {
205
206
  this.detail = detail;
206
207
  }
207
208
  };
209
+ var DEFAULT_BASE_URL = "https://api.pushqueue.dev";
208
210
  var Pushq = class {
209
- constructor(opts) {
210
- this.base = opts.baseUrl.replace(/\/+$/, "");
211
+ constructor(opts = {}) {
212
+ this.base = (opts.baseUrl?.trim() || DEFAULT_BASE_URL).replace(/\/+$/, "");
211
213
  this.apiKey = opts.apiKey;
212
214
  this.timeoutMs = opts.timeoutMs ?? 3e4;
213
215
  this.fetchFn = opts.fetch ?? globalThis.fetch;
@@ -439,6 +441,7 @@ function toArrayBuffer(view) {
439
441
  }
440
442
  // Annotate the CommonJS export names for ESM import in node:
441
443
  0 && (module.exports = {
444
+ DEFAULT_BASE_URL,
442
445
  Pushq,
443
446
  PushqError,
444
447
  WebhookVerificationError,
package/dist/index.d.cts CHANGED
@@ -157,9 +157,14 @@ declare class PushqError extends Error {
157
157
  readonly detail: string;
158
158
  constructor(status: number, code: string, detail: string);
159
159
  }
160
+ /** The hosted pushq API, used when no baseUrl is given. */
161
+ declare const DEFAULT_BASE_URL = "https://api.pushqueue.dev";
160
162
  interface PushqOptions {
161
- /** e.g. "http://localhost:8080" */
162
- baseUrl: string;
163
+ /**
164
+ * Your pushq server, e.g. "http://localhost:8080" when self-hosting.
165
+ * Defaults to the hosted API, {@link DEFAULT_BASE_URL}.
166
+ */
167
+ baseUrl?: string;
163
168
  apiKey?: string;
164
169
  /** Per-request timeout in ms. Default 30_000. */
165
170
  timeoutMs?: number;
@@ -171,7 +176,7 @@ declare class Pushq {
171
176
  private readonly apiKey?;
172
177
  private readonly timeoutMs;
173
178
  private readonly fetchFn;
174
- constructor(opts: PushqOptions);
179
+ constructor(opts?: PushqOptions);
175
180
  /** Create or replace queue config (idempotent; never changes run state). */
176
181
  upsertQueue(name: string, cfg?: QueueConfig): Promise<Queue>;
177
182
  /** Create a queue; rejects with already_exists if present. */
@@ -229,4 +234,4 @@ declare function verifySignature(opts: VerifyOptions): Promise<string>;
229
234
  /** Computes a "v1,<base64>" signature (test/tooling helper). */
230
235
  declare function sign(secret: string, msgId: string, timestampSeconds: number, payload: string | Uint8Array): Promise<string>;
231
236
 
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 };
237
+ export { type Attempt, type BatchResult, DEFAULT_BASE_URL, 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 CHANGED
@@ -157,9 +157,14 @@ declare class PushqError extends Error {
157
157
  readonly detail: string;
158
158
  constructor(status: number, code: string, detail: string);
159
159
  }
160
+ /** The hosted pushq API, used when no baseUrl is given. */
161
+ declare const DEFAULT_BASE_URL = "https://api.pushqueue.dev";
160
162
  interface PushqOptions {
161
- /** e.g. "http://localhost:8080" */
162
- baseUrl: string;
163
+ /**
164
+ * Your pushq server, e.g. "http://localhost:8080" when self-hosting.
165
+ * Defaults to the hosted API, {@link DEFAULT_BASE_URL}.
166
+ */
167
+ baseUrl?: string;
163
168
  apiKey?: string;
164
169
  /** Per-request timeout in ms. Default 30_000. */
165
170
  timeoutMs?: number;
@@ -171,7 +176,7 @@ declare class Pushq {
171
176
  private readonly apiKey?;
172
177
  private readonly timeoutMs;
173
178
  private readonly fetchFn;
174
- constructor(opts: PushqOptions);
179
+ constructor(opts?: PushqOptions);
175
180
  /** Create or replace queue config (idempotent; never changes run state). */
176
181
  upsertQueue(name: string, cfg?: QueueConfig): Promise<Queue>;
177
182
  /** Create a queue; rejects with already_exists if present. */
@@ -229,4 +234,4 @@ declare function verifySignature(opts: VerifyOptions): Promise<string>;
229
234
  /** Computes a "v1,<base64>" signature (test/tooling helper). */
230
235
  declare function sign(secret: string, msgId: string, timestampSeconds: number, payload: string | Uint8Array): Promise<string>;
231
236
 
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 };
237
+ export { type Attempt, type BatchResult, DEFAULT_BASE_URL, 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.js CHANGED
@@ -175,9 +175,10 @@ var PushqError = class extends Error {
175
175
  this.detail = detail;
176
176
  }
177
177
  };
178
+ var DEFAULT_BASE_URL = "https://api.pushqueue.dev";
178
179
  var Pushq = class {
179
- constructor(opts) {
180
- this.base = opts.baseUrl.replace(/\/+$/, "");
180
+ constructor(opts = {}) {
181
+ this.base = (opts.baseUrl?.trim() || DEFAULT_BASE_URL).replace(/\/+$/, "");
181
182
  this.apiKey = opts.apiKey;
182
183
  this.timeoutMs = opts.timeoutMs ?? 3e4;
183
184
  this.fetchFn = opts.fetch ?? globalThis.fetch;
@@ -408,6 +409,7 @@ function toArrayBuffer(view) {
408
409
  return view.buffer.slice(view.byteOffset, view.byteOffset + view.byteLength);
409
410
  }
410
411
  export {
412
+ DEFAULT_BASE_URL,
411
413
  Pushq,
412
414
  PushqError,
413
415
  WebhookVerificationError,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pushq",
3
- "version": "0.1.0-beta.7",
3
+ "version": "0.1.0-beta.8",
4
4
  "description": "Client for pushq — self-hosted HTTP push task queue (open-source Cloud Tasks alternative)",
5
5
  "license": "MIT",
6
6
  "repository": {