oqronkit 0.0.1-alpha.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/README.md +127 -0
- package/dist/chunk-I6QFT3MR.mjs +1732 -0
- package/dist/chunk-PLN5A6LU.mjs +1447 -0
- package/dist/core/config/config-loader.d.ts +3 -0
- package/dist/core/config/config-loader.d.ts.map +1 -0
- package/dist/core/config/default-config.d.ts +4 -0
- package/dist/core/config/default-config.d.ts.map +1 -0
- package/dist/core/config/define-config.d.ts +3 -0
- package/dist/core/config/define-config.d.ts.map +1 -0
- package/dist/core/config/find-up.d.ts +2 -0
- package/dist/core/config/find-up.d.ts.map +1 -0
- package/dist/core/config/schema.d.ts +306 -0
- package/dist/core/config/schema.d.ts.map +1 -0
- package/dist/core/context/cron-context.d.ts +14 -0
- package/dist/core/context/cron-context.d.ts.map +1 -0
- package/dist/core/context/cron-context.interface.d.ts +14 -0
- package/dist/core/context/cron-context.interface.d.ts.map +1 -0
- package/dist/core/context/job-context.d.ts +22 -0
- package/dist/core/context/job-context.d.ts.map +1 -0
- package/dist/core/context/schedule-context.d.ts +31 -0
- package/dist/core/context/schedule-context.d.ts.map +1 -0
- package/dist/core/errors/base.error.d.ts +13 -0
- package/dist/core/errors/base.error.d.ts.map +1 -0
- package/dist/core/events/event-bus.d.ts +16 -0
- package/dist/core/events/event-bus.d.ts.map +1 -0
- package/dist/core/index.d.ts +24 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/logger/index.d.ts +30 -0
- package/dist/core/logger/index.d.ts.map +1 -0
- package/dist/core/registry.d.ts +13 -0
- package/dist/core/registry.d.ts.map +1 -0
- package/dist/core/types/config.types.d.ts +119 -0
- package/dist/core/types/config.types.d.ts.map +1 -0
- package/dist/core/types/cron.types.d.ts +53 -0
- package/dist/core/types/cron.types.d.ts.map +1 -0
- package/dist/core/types/db.types.d.ts +32 -0
- package/dist/core/types/db.types.d.ts.map +1 -0
- package/dist/core/types/index.d.ts +7 -0
- package/dist/core/types/index.d.ts.map +1 -0
- package/dist/core/types/lock.types.d.ts +7 -0
- package/dist/core/types/lock.types.d.ts.map +1 -0
- package/dist/core/types/module.types.d.ts +8 -0
- package/dist/core/types/module.types.d.ts.map +1 -0
- package/dist/core/types/scheduler.types.d.ts +62 -0
- package/dist/core/types/scheduler.types.d.ts.map +1 -0
- package/dist/cron-V0k1GcxJ.d.mts +102 -0
- package/dist/cron-V0k1GcxJ.d.ts +102 -0
- package/dist/cron.d.mts +2 -0
- package/dist/cron.d.ts +2 -0
- package/dist/cron.d.ts.map +1 -0
- package/dist/cron.js +215 -0
- package/dist/cron.mjs +1 -0
- package/dist/db/adapters/memory.adapter.d.ts +25 -0
- package/dist/db/adapters/memory.adapter.d.ts.map +1 -0
- package/dist/db/adapters/namespaced.adapter.d.ts +26 -0
- package/dist/db/adapters/namespaced.adapter.d.ts.map +1 -0
- package/dist/db/adapters/sqlite.adapter.d.ts +30 -0
- package/dist/db/adapters/sqlite.adapter.d.ts.map +1 -0
- package/dist/db/index.d.ts +4 -0
- package/dist/db/index.d.ts.map +1 -0
- package/dist/index.d.mts +797 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2738 -0
- package/dist/index.mjs +747 -0
- package/dist/lock/adapters/db-lock.adapter.d.ts +17 -0
- package/dist/lock/adapters/db-lock.adapter.d.ts.map +1 -0
- package/dist/lock/adapters/memory-lock.adapter.d.ts +13 -0
- package/dist/lock/adapters/memory-lock.adapter.d.ts.map +1 -0
- package/dist/lock/adapters/namespaced-lock.adapter.d.ts +12 -0
- package/dist/lock/adapters/namespaced-lock.adapter.d.ts.map +1 -0
- package/dist/lock/heartbeat-worker.d.ts +16 -0
- package/dist/lock/heartbeat-worker.d.ts.map +1 -0
- package/dist/lock/index.d.ts +7 -0
- package/dist/lock/index.d.ts.map +1 -0
- package/dist/lock/leader-election.d.ts +16 -0
- package/dist/lock/leader-election.d.ts.map +1 -0
- package/dist/lock/stall-detector.d.ts +23 -0
- package/dist/lock/stall-detector.d.ts.map +1 -0
- package/dist/scheduler/cron-engine.d.ts +42 -0
- package/dist/scheduler/cron-engine.d.ts.map +1 -0
- package/dist/scheduler/define-cron.d.ts +36 -0
- package/dist/scheduler/define-cron.d.ts.map +1 -0
- package/dist/scheduler/define-schedule.d.ts +52 -0
- package/dist/scheduler/define-schedule.d.ts.map +1 -0
- package/dist/scheduler/expression-parser.d.ts +2 -0
- package/dist/scheduler/expression-parser.d.ts.map +1 -0
- package/dist/scheduler/index.d.ts +10 -0
- package/dist/scheduler/index.d.ts.map +1 -0
- package/dist/scheduler/missed-fire.handler.d.ts +8 -0
- package/dist/scheduler/missed-fire.handler.d.ts.map +1 -0
- package/dist/scheduler/registry-schedule.d.ts +6 -0
- package/dist/scheduler/registry-schedule.d.ts.map +1 -0
- package/dist/scheduler/registry.d.ts +6 -0
- package/dist/scheduler/registry.d.ts.map +1 -0
- package/dist/scheduler/schedule-engine.d.ts +36 -0
- package/dist/scheduler/schedule-engine.d.ts.map +1 -0
- package/dist/scheduler-HRR3UXGE.mjs +1 -0
- package/dist/scheduler.d.mts +248 -0
- package/dist/scheduler.d.ts +248 -0
- package/dist/scheduler.js +1461 -0
- package/dist/scheduler.mjs +1 -0
- package/dist/server/express.d.ts +9 -0
- package/dist/server/express.d.ts.map +1 -0
- package/dist/server/fastify.d.ts +9 -0
- package/dist/server/fastify.d.ts.map +1 -0
- package/dist/server/handlers.d.ts +15 -0
- package/dist/server/handlers.d.ts.map +1 -0
- package/package.json +59 -0
package/README.md
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# OqronKit
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+
|
|
6
|
+
OqronKit is a high-performance, enterprise-ready cron and job scheduling framework for Node.js. Designed for extreme scaling, multi-tenancy, and distributed microservices architectures, it features seamless Global Locking, automated Leader Election, missed-fire recovery, and zero-configuration database persistence.
|
|
7
|
+
|
|
8
|
+
Stop struggling with broken internal intervals. Scale confidently across a single monolith or a distributed 50-node cluster using SQLite, Redis, or Memory natively.
|
|
9
|
+
|
|
10
|
+
## ๐ Key Features
|
|
11
|
+
|
|
12
|
+
- **Multi-Tenant Isolation**: Safely run `staging` and `production` environments off the exact same database without collision.
|
|
13
|
+
- **Global Distributed Locks**: Automatically prevents duplicate processing across clusters nativelyโyou will never accidentally bill a user twice!
|
|
14
|
+
- **Leader Election**: Dynamically promotes a master node to handle system polling intervals natively.
|
|
15
|
+
- **Missed-Fire Recovery**: Automatic detection and recovery strategies (`run_now`, `skip`, or `discard`) when the server goes offline during a schedule.
|
|
16
|
+
- **Fully Declarative (`oqron.config.ts`)**: Define a single TS configuration file natively without writing massive infrastructure boots.
|
|
17
|
+
- **Stall Detection**: Natively monitors and revokes jobs if an executing worker crashes silently or hangs indefinitely.
|
|
18
|
+
- **File-based Auto-Routing**: Magically discovers and registers jobs simply by dropping `.ts` files into your `./jobs` directory!
|
|
19
|
+
|
|
20
|
+
## ๐ฆ Installation
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install oqronkit
|
|
24
|
+
# or
|
|
25
|
+
yarn add oqronkit
|
|
26
|
+
# or
|
|
27
|
+
bun add oqronkit
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
*Note: OqronKit bundles standard SQLite and Memory adapters internally. No additional database ORMs are required.*
|
|
31
|
+
|
|
32
|
+
## ๐ Quick Start
|
|
33
|
+
|
|
34
|
+
### 1. Configuration (`oqron.config.ts`)
|
|
35
|
+
Create a single definition file at the root of your application to magically boot the entire underlying layer:
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
import { defineConfig } from "oqronkit";
|
|
39
|
+
|
|
40
|
+
export default defineConfig({
|
|
41
|
+
project: "my-saas-platform",
|
|
42
|
+
environment: process.env.NODE_ENV || "development",
|
|
43
|
+
modules: ["cron", "scheduler"], // Enable standard Crons & dynamic Timed Schedules
|
|
44
|
+
jobsDir: "./src/jobs", // OqronKit automatically finds jobs here
|
|
45
|
+
});
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### 2. Define a Job (`src/jobs/emails.ts`)
|
|
49
|
+
Declare a job logic structure. OqronKit strongly enforces execution wrappers to track success, failure, and execution limits!
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
import { cron } from "oqronkit";
|
|
53
|
+
|
|
54
|
+
export const dailyDigest = cron({
|
|
55
|
+
name: "daily-digest",
|
|
56
|
+
expression: "0 8 * * *", // Runs every day at 08:00 AM
|
|
57
|
+
timezone: "UTC",
|
|
58
|
+
overlap: "skip", // If it's still sending yesterday's batch, skip today's run
|
|
59
|
+
handler: async (ctx) => {
|
|
60
|
+
ctx.logger.info("Gathering active users...", {
|
|
61
|
+
env: ctx.environment
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
// Simulate complex DB queries natively
|
|
65
|
+
await new Promise((r) => setTimeout(r, 1000));
|
|
66
|
+
|
|
67
|
+
return { users_processed: 50 };
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### 3. Initialize Server
|
|
73
|
+
Simply inject `OqronKit.init()` natively into your backend bootstrapping logic!
|
|
74
|
+
|
|
75
|
+
```typescript
|
|
76
|
+
import { OqronKit } from "oqronkit";
|
|
77
|
+
|
|
78
|
+
async function boot() {
|
|
79
|
+
await OqronKit.init();
|
|
80
|
+
console.log("Enterprise Task Scheduling armed.");
|
|
81
|
+
}
|
|
82
|
+
boot();
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## ๐ Advanced Usage
|
|
88
|
+
|
|
89
|
+
### Dynamic Specific-Time Scheduling
|
|
90
|
+
Unlike generic Crons, `scheduler` natively handles firing dynamic "one-off" events inside user logic boundaries, explicitly persisting to the DB out of the box!
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
import { schedule } from "oqronkit";
|
|
94
|
+
|
|
95
|
+
// 1. Define the handler type structure
|
|
96
|
+
export const subscriptionHandler = schedule<{ userId: string }>({
|
|
97
|
+
name: "cancel-subscription-job",
|
|
98
|
+
keepHistory: true, // Keep an internal audit trail within the DB
|
|
99
|
+
handler: async (ctx) => {
|
|
100
|
+
const { userId } = ctx.payload;
|
|
101
|
+
console.log(`Cancelled user ${userId} natively!`);
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
// 2. Trigger the job dynamically in your Express routes natively
|
|
106
|
+
await subscriptionHandler({ userId: "u_abc123" }, {
|
|
107
|
+
runAfter: { days: 3 }
|
|
108
|
+
});
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## ๐ Architecture & Internal Isolation
|
|
114
|
+
|
|
115
|
+
By default, the `OqronAdapter` prefixes all Database identities mapping directly based on the config file context:
|
|
116
|
+
`${project}:${environment}:${job_name}`
|
|
117
|
+
|
|
118
|
+
This guarantees you can utilize the exact same Redis clusters, the same SQLite tables (`oqron_schedules`), and the identical physical database server for both your staging development servers and production monoliths flawlessly! The leader elections are mathematically isolated using the same prefix architecture natively.
|
|
119
|
+
|
|
120
|
+
## ๐ค Contributing
|
|
121
|
+
Issues and Pull Requests are welcome to natively expand support for PostgreSQL via `SKIP LOCKED` extensions and deeper Redis locks.
|
|
122
|
+
|
|
123
|
+
1. Fork the Project
|
|
124
|
+
2. Create your Feature Branch
|
|
125
|
+
3. Commit your Changes natively.
|
|
126
|
+
4. Push to the Branch natively.
|
|
127
|
+
5. Open a Pull Request!
|