yaxa-svelte 2.3.0 → 2.4.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.
@@ -0,0 +1,136 @@
1
+ import type { AnyDb } from '../db';
2
+ import type { JobStatus } from '../db/types';
3
+ /**
4
+ * Persisted Job record structure.
5
+ */
6
+ export interface JobRecord<TPayload = any> {
7
+ id: string;
8
+ queue: string;
9
+ name: string;
10
+ payload: TPayload;
11
+ status: JobStatus;
12
+ priority: number;
13
+ attempts: number;
14
+ maxAttempts: number;
15
+ runAt: Date;
16
+ lockedAt?: Date | null;
17
+ lockedBy?: string | null;
18
+ failedReason?: string | null;
19
+ createdAt: Date;
20
+ updatedAt: Date;
21
+ completedAt?: Date | null;
22
+ }
23
+ /**
24
+ * Delay specifier:
25
+ * - String format: '30s', '5m', '2h', '1d'
26
+ * - Number: delay in milliseconds
27
+ * - Date: absolute execution timestamp
28
+ */
29
+ export type JobDelay = string | number | Date;
30
+ export interface EnqueueJobOptions {
31
+ /**
32
+ * Queue partition name (default: 'default').
33
+ */
34
+ queue?: string;
35
+ /**
36
+ * Execution delay or scheduled Date.
37
+ */
38
+ delay?: JobDelay;
39
+ /**
40
+ * Job execution priority (higher number = higher priority). Default: 0.
41
+ */
42
+ priority?: number;
43
+ /**
44
+ * Maximum retry attempts before routing to Dead Letter Queue (DLQ). Default: 3.
45
+ */
46
+ maxAttempts?: number;
47
+ /**
48
+ * Optional Drizzle transaction object for the Transactional Outbox pattern.
49
+ */
50
+ tx?: any;
51
+ /**
52
+ * Optional custom Drizzle DB client instance.
53
+ */
54
+ db?: AnyDb;
55
+ }
56
+ export interface WorkerContext<TPayload = any> {
57
+ job: JobRecord<TPayload>;
58
+ logger: {
59
+ info: (msg: string, ...args: any[]) => void;
60
+ warn: (msg: string, ...args: any[]) => void;
61
+ error: (msg: string, ...args: any[]) => void;
62
+ };
63
+ }
64
+ export type WorkerHandler<TPayload = any> = (payload: TPayload, context: WorkerContext<TPayload>) => Promise<void> | void;
65
+ export interface WorkerDefinition<TPayload = any> {
66
+ name: string;
67
+ handler: WorkerHandler<TPayload>;
68
+ queue?: string;
69
+ }
70
+ export interface JobRunnerOptions {
71
+ /**
72
+ * Drizzle database instance (Neon or Turso).
73
+ */
74
+ db?: AnyDb;
75
+ /**
76
+ * Database driver ('neon' | 'turso' | 'sqlite').
77
+ */
78
+ driver?: 'neon' | 'turso' | 'sqlite';
79
+ /**
80
+ * List of registered worker handlers.
81
+ */
82
+ workers: WorkerDefinition<any>[];
83
+ /**
84
+ * Target queue name to poll (default: 'default').
85
+ */
86
+ queue?: string;
87
+ /**
88
+ * Maximum jobs to lease and process per batch (default: 10).
89
+ */
90
+ batchSize?: number;
91
+ /**
92
+ * Polling interval in milliseconds for daemon mode (default: 3000ms).
93
+ */
94
+ pollIntervalMs?: number;
95
+ /**
96
+ * Lock timeout in milliseconds before a processing job is considered stale (default: 5 minutes).
97
+ */
98
+ lockTimeoutMs?: number;
99
+ /**
100
+ * Worker instance identifier (default: generated worker id).
101
+ */
102
+ workerId?: string;
103
+ }
104
+ export interface JobBatchResult {
105
+ processed: number;
106
+ succeeded: number;
107
+ failed: number;
108
+ }
109
+ export interface JobRunner {
110
+ /**
111
+ * Processes the next batch of pending jobs. Perfect for serverless cron endpoints (/api/cron/jobs).
112
+ */
113
+ processNextBatch: () => Promise<JobBatchResult>;
114
+ /**
115
+ * Starts the continuous background polling loop (for long-lived Node.js servers).
116
+ */
117
+ start: () => void;
118
+ /**
119
+ * Stops the background polling loop.
120
+ */
121
+ stop: () => void;
122
+ /**
123
+ * Returns true if the polling runner is currently active.
124
+ */
125
+ isRunning: () => boolean;
126
+ }
127
+ export type EventHandler<TData = any> = (data: TData) => Promise<void> | void;
128
+ export interface EventSubscription {
129
+ unsubscribe: () => void;
130
+ }
131
+ export interface IEventBus {
132
+ publish: <TData = any>(eventName: string, data: TData) => Promise<void>;
133
+ subscribe: <TData = any>(eventName: string, handler: EventHandler<TData>) => EventSubscription;
134
+ once: <TData = any>(eventName: string, handler: EventHandler<TData>) => EventSubscription;
135
+ clear: () => void;
136
+ }
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yaxa-svelte",
3
- "version": "2.3.0",
3
+ "version": "2.4.0",
4
4
  "description": "The Intuitive Svelte UI Library — Nuxt UI v4 equivalent for SvelteKit 2 & 3 & Svelte 5 with automated SEO, dynamic OpenGraph cards, sitemaps, robots.txt, and Tailwind CSS v4.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://yaxa.vercel.app",