@imqueue/core 3.2.1 → 3.2.3

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/AGENTS.md ADDED
@@ -0,0 +1,103 @@
1
+ # AGENTS.md — orientation for coding agents
2
+
3
+ This file is for AI coding agents (and humans who like density) working on
4
+ `@imqueue/core`. It captures how the codebase is built, tested and structured,
5
+ plus the invariants that are easy to get wrong. Read it before making changes.
6
+ For contribution *process/terms* see [CONTRIBUTING.md](./CONTRIBUTING.md); for
7
+ end-user docs see the [README](./README.md) and https://imqueue.org/.
8
+
9
+ ## What this is
10
+
11
+ `@imqueue/core` is the foundation of the @imqueue framework: a fast,
12
+ JSON-message queue for inter-service communication, implemented over **Redis**.
13
+ It is the transport that [`@imqueue/rpc`](https://github.com/imqueue/rpc) builds
14
+ its typed RPC layer on top of. No timers, no polling — delivery is driven by
15
+ Redis blocking list moves and keyspace notifications.
16
+
17
+ ## Toolchain & invariants (do not fight these)
18
+
19
+ - **ESM only**, `"type": "module"`. Use `import`, not `require()`. Import
20
+ sibling modules with the **`.js`** extension (NodeNext resolves it to the
21
+ `.ts` source), e.g. `import { RedisQueue } from './RedisQueue.js'`.
22
+ - **TypeScript, `module`/`moduleResolution: nodenext`**, `target: es2024`,
23
+ `verbatimModuleSyntax: true`, `isolatedModules: true`, `strict: true`. Use
24
+ `import type` / `import { type X }` for type-only imports.
25
+ - **Node ≥ 22.12.**
26
+ - **Single runtime dependency: `ioredis`.** Do not add heavyweight deps; this
27
+ package is meant to stay small.
28
+ - **Lint/format:** `oxlint` + `oxfmt`. Run `npm run format` before committing;
29
+ CI checks `npm run format:check`.
30
+ - Build **emits `.js`/`.d.ts`/`.js.map` next to sources**; these are
31
+ **gitignored, not committed** (`build` runs `clean-compiled` first, so stale
32
+ artifacts never linger). Never commit compiled output.
33
+ - `removeComments` is intentionally **`false`** — downstream tooling and
34
+ `@imqueue/rpc` rely on doc-blocks surviving compilation. Keep it that way.
35
+
36
+ ## Commands
37
+
38
+ ```bash
39
+ npm install
40
+ npm run build # clean-compiled + tsc (emits alongside sources)
41
+ npm test # build + node:test over every test/**/*.spec.js
42
+ npm run lint # oxlint
43
+ npm run format # oxfmt (write) | npm run format:check (verify)
44
+ npm run test-coverage # tests + experimental coverage summary
45
+ npm run test-lcov # writes coverage/lcov.info
46
+ npm run benchmark # message-throughput benchmark (see below)
47
+ ```
48
+
49
+ Tests use the native `node:test` runner with
50
+ `--experimental-test-module-mocks` and preload `./test/mocks/index.js`;
51
+ timeout is 15s per test. Run a single spec after a build with
52
+ `node --experimental-test-module-mocks --import ./test/mocks/index.js --test test/src/RedisQueue.spec.js`.
53
+
54
+ ## Layout
55
+
56
+ | Path | Role |
57
+ |---|---|
58
+ | `index.ts` | Public entry: default export `IMQ` (factory — `IMQ.create(name, opts)`) plus `export * from './src/index.js'` |
59
+ | `src/IMessageQueue.ts` | The `IMessageQueue` interface + options/types + the `'message'`/`'error'` event contract. The abstraction every adapter implements. |
60
+ | `src/RedisQueue.ts` | Single-Redis-instance queue implementation (the default). |
61
+ | `src/ClusteredRedisQueue.ts` | Round-robin queue across multiple Redis instances for horizontal scaling. |
62
+ | `src/ClusterManager.ts`, `src/UDPClusterManager.ts`, `src/UDPWorker.ts` | Cluster membership / worker coordination (UDP-based discovery). |
63
+ | `src/IMQMode.ts` | `IMQMode` enum (queue role/mode). |
64
+ | `src/redis.ts` | `ioredis` wiring / connection helpers. |
65
+ | `src/profile.ts` | Profiling helper used across the library. |
66
+ | `benchmark/**` | Throughput benchmark (CPU-affinity pinned). |
67
+ | `test/**` | `node:test` specs + `test/mocks/` preload. |
68
+
69
+ ## Delivery model (behavioural invariants)
70
+
71
+ - **Two delivery modes**, selected by the `safeDelivery` option: *unreliable*
72
+ (fast; a message is lost if a consumer grabs it and dies) and *safe/guaranteed*
73
+ (1.5–2× slower; a grabbed-then-lost message is rescheduled). Safe delivery
74
+ relies on Redis `LMOVE`/`BLMOVE` — **Redis 6.2+ is required.**
75
+ - **No polling / no timers.** Delivery uses blocking Redis ops + keyspace
76
+ notification events. If Redis has the `CONFIG` command disabled (e.g. AWS
77
+ ElastiCache), keyspace notifications must be enabled out of band:
78
+ `notify-keyspace-events Ex`.
79
+ - **Messages must be JSON-serializable** (`IJson`/`JsonObject`). Delayed
80
+ delivery is supported via the send `delay` argument.
81
+ - Scaling the number of workers must **not** increase Redis traffic — preserve
82
+ this property in any queue change. `ClusteredRedisQueue` balances round-robin
83
+ across instances.
84
+ - Idle queues must consume no resources — do not introduce background intervals.
85
+
86
+ ## Using this package correctly (for consumer-facing code an agent writes)
87
+
88
+ ```typescript
89
+ import IMQ, { IMessageQueue, IJson } from '@imqueue/core';
90
+
91
+ const q: IMessageQueue = IMQ.create('MyQueue'); // default: RedisQueue
92
+ await q.start();
93
+ q.on('message', (msg: IJson, id: string, from: string) => { /* handle */ });
94
+ await q.send('OtherQueue', { hello: 'world' }); // JSON-serializable only
95
+ await q.send('MyQueue', { later: true }, 1000); // delayed 1000ms
96
+ ```
97
+
98
+ Prefer `@imqueue/rpc` for typed service-to-service calls; use `core` directly
99
+ only when you need raw queue semantics.
100
+
101
+ ## License
102
+
103
+ GPL-3.0. Commercial licensing for closed-source products: https://imqueue.com/.
package/CLAUDE.md ADDED
@@ -0,0 +1,2 @@
1
+ See [AGENTS.md](./AGENTS.md) for build, test, layout and the invariants to
2
+ respect when working on `@imqueue/core`. End-user docs: https://imqueue.org/.
@@ -0,0 +1,58 @@
1
+ # Contributing to @imqueue
2
+
3
+ Thanks for your interest in improving @imqueue! Contributions of all kinds are
4
+ welcome — bug fixes, features, tests, and documentation.
5
+
6
+ ## Contribution terms — please read first
7
+
8
+ @imqueue is **dual-licensed**: it is free to everyone under **GPL-3.0**, and it is
9
+ also offered under **commercial licenses** for closed-source use. To make that
10
+ sustainable, contributions are accepted under the
11
+ **[@imqueue Contribution Terms](./CONTRIBUTION-TERMS.md)**.
12
+
13
+ **By opening a pull request — or otherwise contributing — you agree to those
14
+ terms.** In short:
15
+
16
+ - You **keep the copyright** in your contribution.
17
+ - Your contribution stays available to everyone under **GPL-3.0**.
18
+ - You grant the project owner the right to **also license your contribution
19
+ commercially**, royalty-free — you will not receive a fee for it.
20
+
21
+ **If you do not agree, please do not contribute.** Read the full text in
22
+ [CONTRIBUTION-TERMS.md](./CONTRIBUTION-TERMS.md).
23
+
24
+ ## How to contribute
25
+
26
+ 1. **Open an issue first** for anything non-trivial, so we can agree on the
27
+ approach before you invest time.
28
+ 2. **Fork** the repository and create a topic branch from `master`
29
+ (e.g. `fix/redis-reconnect` or `feat/lock-timeout`).
30
+ 3. **Make your change**, following the existing code style. Keep pull requests
31
+ focused — one logical change per PR.
32
+ 4. **Add or update tests** so the change is covered, and make sure the full suite
33
+ passes locally:
34
+ ```bash
35
+ npm ci
36
+ npm test
37
+ ```
38
+ 5. **Write clear commit messages** and a descriptive PR title and summary.
39
+ 6. **Open the pull request** against `master` and fill in the PR template,
40
+ including the contribution-terms checkbox.
41
+
42
+ ## Guidelines
43
+
44
+ - Match the existing TypeScript style and formatting already used in the file you
45
+ are editing.
46
+ - Keep public API changes documented (doc-blocks / README as appropriate).
47
+ - Be respectful and constructive in reviews and discussions.
48
+
49
+ ## Reporting security issues
50
+
51
+ Please **do not** open a public issue for security vulnerabilities. Report them
52
+ privately to the maintainers (see the repository's security policy or contact
53
+ address) so they can be addressed responsibly.
54
+
55
+ ---
56
+
57
+ Questions about the terms or a larger/corporate contribution? Reach out before you
58
+ start and we'll help.
@@ -0,0 +1,79 @@
1
+ # @imqueue Contribution Terms (v1.0)
2
+
3
+ These terms apply to every contribution to any repository of the **@imqueue**
4
+ project — the packages published under the `@imqueue` npm scope and any repository
5
+ in the imqueue GitHub organisation.
6
+
7
+ **By submitting a contribution — opening a pull request, pushing a commit, sending
8
+ a patch, or otherwise offering work for inclusion — you accept these terms in
9
+ full. If you do not agree with them, do not contribute.**
10
+
11
+ In these terms, **"Owner"** means Mykhailo Stadnyk, together with his successors,
12
+ assigns and any entity he controls (including VaryLogic s.r.o.), and
13
+ **"Contribution"** means any work of authorship — code, documentation or other
14
+ material — you submit to an @imqueue repository.
15
+
16
+ ## 1. What you grant
17
+
18
+ You grant the Owner a **perpetual, worldwide, irrevocable, royalty-free,
19
+ non-exclusive, transferable and sublicensable** license to use, reproduce,
20
+ modify, adapt, publish, distribute and otherwise exploit your Contribution and
21
+ derivative works of it, **and to license and sub-license it under any terms the
22
+ Owner chooses — including commercial and proprietary (closed-source) licenses,
23
+ without any obligation to release source code.**
24
+
25
+ In plain terms: the Owner may include your Contribution in @imqueue and **sell
26
+ commercial licenses that cover it**, alongside the open-source edition.
27
+
28
+ ## 2. No royalties, fees or compensation
29
+
30
+ The rights above are granted **free of charge**. You **waive** any right to
31
+ royalties, license fees, revenue share or any other compensation arising from the
32
+ Owner's use or licensing of your Contribution, including its commercial licensing,
33
+ and you agree not to seek any such payment now or in the future.
34
+
35
+ ## 3. You keep your copyright
36
+
37
+ You **retain ownership** of the copyright in your Contribution and may use it
38
+ elsewhere for your own purposes. You are granting the Owner the rights in Section
39
+ 1 — you are not required to transfer ownership. Your Contribution also remains
40
+ available to the public under the repository's open-source license (GPL-3.0).
41
+
42
+ ## 4. Patent license
43
+
44
+ You grant the Owner and all downstream recipients a perpetual, worldwide,
45
+ royalty-free, irrevocable (except as stated) patent license to make, use, sell,
46
+ offer to sell, import and transfer your Contribution, limited to the patent claims
47
+ you can license that are necessarily infringed by your Contribution alone or in
48
+ combination with the project. If you start patent litigation alleging the project
49
+ or your Contribution infringes your patents, the patent license you received
50
+ terminates.
51
+
52
+ ## 5. Your promises
53
+
54
+ You confirm that: (a) the Contribution is your own original work, or you have the
55
+ right to submit it and to grant these rights; (b) if your employer has any rights
56
+ in your work, you have their permission to contribute, or they have waived those
57
+ rights; and (c) you have identified any third-party material in your Contribution
58
+ and its license.
59
+
60
+ ## 6. Moral rights
61
+
62
+ To the maximum extent permitted by applicable law, you waive, or agree not to
63
+ exercise, any moral rights in your Contribution in a way that would prevent the
64
+ Owner from exercising the rights in Section 1. (Certain moral rights are
65
+ inalienable under Slovak/EU law; nothing here purports to transfer those.)
66
+
67
+ ## 7. No obligation; "as is"
68
+
69
+ The Owner is under no obligation to use your Contribution. It is provided **"as
70
+ is"**, without warranty of any kind.
71
+
72
+ ## 8. Governing law
73
+
74
+ These terms are governed by the laws of the Slovak Republic, without regard to its
75
+ conflict-of-laws rules.
76
+
77
+ ---
78
+
79
+ **If you do not agree to all of the above, do not contribute to @imqueue.**
package/README.md CHANGED
@@ -2,7 +2,16 @@
2
2
 
3
3
  [![License](https://img.shields.io/badge/license-GPL-blue.svg)](https://rawgit.com/imqueue/core/master/LICENSE)
4
4
 
5
- Simple JSON-based messaging queue for inter-service communication
5
+ Simple JSON-based messaging queue for inter-service communication in Node.js &
6
+ TypeScript back-ends — the Redis-backed transport that powers the @imqueue
7
+ framework. Fast, poll-free delivery with optional guaranteed mode.
8
+
9
+ **Documentation:** full guides, tutorial and API reference at
10
+ [imqueue.org](https://imqueue.org/). Commercial licensing & support for
11
+ closed-source products at [imqueue.com](https://imqueue.com/).
12
+
13
+ **Using an AI assistant?** Point it at [imqueue.org/llms.txt](https://imqueue.org/llms.txt)
14
+ for a machine-readable index of the docs, or see [AGENTS.md](./AGENTS.md).
6
15
 
7
16
  **Related packages:**
8
17
 
package/SECURITY.md ADDED
@@ -0,0 +1,40 @@
1
+ # Security Policy
2
+
3
+ ## Reporting a vulnerability
4
+
5
+ If you believe you have found a security vulnerability in **@imqueue/core** (or any
6
+ `@imqueue/*` package), please report it **privately** — do not open a public issue,
7
+ pull request, or discussion for it.
8
+
9
+ Two private channels:
10
+
11
+ - **GitHub** — use *Security → Report a vulnerability* on this repository to open a
12
+ private advisory (preferred; it keeps the report and the fix coordinated in one
13
+ place).
14
+ - **Email** — <support@imqueue.com> with the details below.
15
+
16
+ Please include:
17
+
18
+ - the affected package and version(s);
19
+ - a description of the issue and its impact;
20
+ - steps to reproduce, or a proof of concept, where possible.
21
+
22
+ ## What to expect
23
+
24
+ - We aim to acknowledge a report within a few business days.
25
+ - We'll confirm the issue, keep you updated on progress, and coordinate a fix and a
26
+ disclosure timeline with you.
27
+ - Once a fix is released we'll credit the reporter in the advisory unless you prefer
28
+ to remain anonymous.
29
+
30
+ ## Supported versions
31
+
32
+ Security fixes land on the latest published release line of each `@imqueue/*`
33
+ package on npm. Please make sure you can reproduce an issue against the current
34
+ release before reporting.
35
+
36
+ ## Scope
37
+
38
+ The `@imqueue` framework is open source under GPL-3.0. This policy covers the code
39
+ in the `@imqueue/*` packages. Vulnerabilities in third-party dependencies should be
40
+ reported to those projects, though we're glad to help coordinate an upgrade.
package/context7.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "$schema": "https://context7.com/schema/context7.json",
3
+ "projectTitle": "@imqueue/core",
4
+ "description": "Fast JSON message queue over Redis for inter-service communication in Node.js & TypeScript microservices — the transport layer of the @imqueue framework.",
5
+ "excludeFolders": ["src", "lib", "node_modules", "test", "tests", "coverage", "docs/api"],
6
+ "excludeFiles": ["CHANGELOG.md", "LICENSE"],
7
+ "rules": [
8
+ "Use ClusteredRedisQueue as the reliable queue implementation for production; it owns delivery, blocking reads and reconnection.",
9
+ "The queue serializes rich types correctly — do not hand-roll JSON.stringify, which drops Date, Map, Set, BigInt and undefined.",
10
+ "Delivery is at-least-once, so message handlers should be idempotent.",
11
+ "@imqueue/core is the transport under @imqueue/rpc; most apps consume it through @imqueue/rpc rather than directly.",
12
+ "@imqueue is GPL-3.0; a commercial license is available for closed-source use (see imqueue.com/license)."
13
+ ]
14
+ }
package/package.json CHANGED
@@ -1,14 +1,21 @@
1
1
  {
2
2
  "name": "@imqueue/core",
3
- "version": "3.2.1",
4
- "description": "Simple JSON-based messaging queue for inter service communication",
3
+ "version": "3.2.3",
4
+ "description": "Fast JSON message queue over Redis for inter-service communication in Node.js & TypeScript microservices — the transport layer of the @imqueue framework",
5
5
  "keywords": [
6
6
  "message-queue",
7
7
  "redis",
8
8
  "redis-queue",
9
9
  "inter-service-communication",
10
10
  "json",
11
- "json-message"
11
+ "json-message",
12
+ "typescript",
13
+ "nodejs",
14
+ "microservices",
15
+ "message-broker",
16
+ "rpc",
17
+ "soa",
18
+ "imqueue"
12
19
  ],
13
20
  "scripts": {
14
21
  "benchmark": "node benchmark -c $(( $(nproc) - 2 )) -m 100000",
@@ -37,7 +44,8 @@
37
44
  "bugs": {
38
45
  "url": "https://github.com/imqueue/core/issues"
39
46
  },
40
- "homepage": "https://imqueue.com/",
47
+ "homepage": "https://imqueue.org/",
48
+ "funding": "https://imqueue.com/",
41
49
  "author": "imqueue.com <support@imqueue.com> (https://imqueue.com)",
42
50
  "license": "GPL-3.0-only",
43
51
  "dependencies": {