@ecodrix/erix-client 1.0.0 → 1.0.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/dist/index.d.ts CHANGED
@@ -38,6 +38,29 @@ export interface RateLimitResult {
38
38
  remaining: number;
39
39
  resetAt: number;
40
40
  }
41
+ export interface JobV2<T = JsonValue> {
42
+ id: string;
43
+ queueName: string;
44
+ data: T;
45
+ status: "waiting" | "active" | "completed" | "failed" | "delayed";
46
+ attempts: number;
47
+ maxAttempts: number;
48
+ priority: number;
49
+ createdAt: string;
50
+ runAt: string;
51
+ clientCode?: string;
52
+ progress?: number;
53
+ error?: string;
54
+ result?: JsonValue;
55
+ }
56
+ export interface EnqueueOptionsV2 {
57
+ priority?: number;
58
+ maxAttempts?: number;
59
+ delayMs?: number;
60
+ runAt?: Date | string;
61
+ clientCode?: string;
62
+ metadata?: Record<string, JsonValue>;
63
+ }
41
64
  export declare class ErixClient {
42
65
  private readonly baseUrl;
43
66
  private readonly headers;
@@ -77,11 +100,26 @@ export declare class ErixClient {
77
100
  lpop: <T = JsonValue>(key: string) => Promise<T | null>;
78
101
  };
79
102
  queue: {
80
- /** Enqueue a job payload into a named queue */
103
+ /** Enqueue a job payload into a named queue (simple list-based) */
81
104
  push: (name: string, data: JsonValue) => Promise<void>;
82
105
  /** Dequeue the oldest job from a named queue. Returns `null` if empty. */
83
106
  pop: <T = JsonValue>(name: string) => Promise<T | null>;
84
107
  };
108
+ /** Advanced Queue (v2) — supports priority, delay, retries, and persistence */
109
+ queueV2: {
110
+ /** Enqueue a job into an advanced queue */
111
+ push: <T = JsonValue>(queueName: string, data: T, options?: EnqueueOptionsV2) => Promise<JobV2<T>>;
112
+ /** Claim the next eligible job from the queue */
113
+ claim: <T = JsonValue>(queueName: string) => Promise<JobV2<T> | null>;
114
+ /** Mark a job as completed */
115
+ complete: (jobId: string, result?: JsonValue) => Promise<void>;
116
+ /** Mark a job as failed */
117
+ fail: (jobId: string, error: string) => Promise<void>;
118
+ /** Update job progress (0-100) */
119
+ updateProgress: (jobId: string, progress: number) => Promise<void>;
120
+ /** Get job by ID */
121
+ get: <T = JsonValue>(jobId: string) => Promise<JobV2<T> | null>;
122
+ };
85
123
  pubsub: {
86
124
  /** Publish a message to a channel */
87
125
  publish: (channel: string, message: JsonValue) => Promise<void>;
package/dist/index.js CHANGED
@@ -81,7 +81,7 @@ export class ErixClient {
81
81
  };
82
82
  // ─── Queue (FIFO job queue, built on List) ────────────────────────────
83
83
  this.queue = {
84
- /** Enqueue a job payload into a named queue */
84
+ /** Enqueue a job payload into a named queue (simple list-based) */
85
85
  push: async (name, data) => {
86
86
  await this.list.rpush(`q:${name}`, data);
87
87
  },
@@ -90,6 +90,36 @@ export class ErixClient {
90
90
  return this.list.lpop(`q:${name}`);
91
91
  },
92
92
  };
93
+ /** Advanced Queue (v2) — supports priority, delay, retries, and persistence */
94
+ this.queueV2 = {
95
+ /** Enqueue a job into an advanced queue */
96
+ push: async (queueName, data, options = {}) => {
97
+ const res = await this.req("POST", `/queue/v2/${queueName}/jobs`, { data, ...options });
98
+ return res.job;
99
+ },
100
+ /** Claim the next eligible job from the queue */
101
+ claim: async (queueName) => {
102
+ const res = await this.req("POST", `/queue/v2/${queueName}/claim`);
103
+ return res.job;
104
+ },
105
+ /** Mark a job as completed */
106
+ complete: async (jobId, result) => {
107
+ await this.req("POST", `/queue/v2/jobs/${jobId}/complete`, { result });
108
+ },
109
+ /** Mark a job as failed */
110
+ fail: async (jobId, error) => {
111
+ await this.req("POST", `/queue/v2/jobs/${jobId}/fail`, { error });
112
+ },
113
+ /** Update job progress (0-100) */
114
+ updateProgress: async (jobId, progress) => {
115
+ await this.req("PATCH", `/queue/v2/jobs/${jobId}/progress`, { progress });
116
+ },
117
+ /** Get job by ID */
118
+ get: async (jobId) => {
119
+ const res = await this.req("GET", `/queue/v2/jobs/${jobId}`);
120
+ return res.job;
121
+ },
122
+ };
93
123
  // ─── PubSub ───────────────────────────────────────────────────────────
94
124
  this.pubsub = {
95
125
  /** Publish a message to a channel */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ecodrix/erix-client",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Type-safe HTTP client for the erix-store in-memory data service. Zero dependencies — uses native fetch.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -15,10 +15,6 @@
15
15
  "dist",
16
16
  "README.md"
17
17
  ],
18
- "scripts": {
19
- "build": "tsc",
20
- "prepublishOnly": "npm run build"
21
- },
22
18
  "keywords": [
23
19
  "erix-store",
24
20
  "cache",
@@ -42,5 +38,8 @@
42
38
  "repository": {
43
39
  "type": "git",
44
40
  "url": "https://github.com/dhanesh125/erix-store"
41
+ },
42
+ "scripts": {
43
+ "build": "tsc"
45
44
  }
46
- }
45
+ }