@ti-engine/core 1.7.2 → 1.8.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/CHANGELOG.md +25 -0
- package/README.md +38 -6
- package/components/definitions.types.js +4 -4
- package/package.json +8 -7
- package/utils/tools.js +6 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
This document contains the list of changes made to the framework. The format is based on the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) specification.
|
|
4
4
|
|
|
5
|
+
## Version 1.8.1
|
|
6
|
+
|
|
7
|
+
Presentation and documentation only — no functional change. The npm page is the first thing a prospective user sees, and it was working against the package.
|
|
8
|
+
|
|
9
|
+
The two JSDoc corrections here were found while attempting to generate TypeScript declarations from the framework's JSDoc. That work is **deferred to a later release**: the generated declarations did not type-check for a consumer using TypeScript's default settings, and fixing that properly means rewiring the cross-file typedef graph rather than patching the output. These two fixes stand on their own regardless, because the JSDoc was wrong.
|
|
10
|
+
|
|
11
|
+
* fix(types): correct the `TiEnum` typedef's function-property annotations. `function( (number|string), [string] ): (string|undefined)` cannot be parsed — the JSDoc-optional bracket inside a function type is not readable — so `name`, `description` and `contains` were described as unnamed `Function` members. Documentation that reads correctly to a person and not at all to a parser
|
|
12
|
+
* refactor(tools): declare the enum factory as a named constant and export it as `module.exports.enum = createEnum`. Identical export name, arguments and behaviour; a direct assignment to a reserved word emits invalid syntax in a generated declaration, so this removes the obstacle ahead of the deferred work
|
|
13
|
+
* fix(docs): remove the CodeRabbit badge, which rendered as `provider or repo not found` — an error message sitting in the first line of the package page
|
|
14
|
+
* fix(docs): remove the `npms.io` popularity and quality badges. They were not broken; they worked, and published `popularity 4%` and `quality 47%` about this package on its own front page. Popularity is a restatement of the download count, which no niche framework wins, and there is no reason to advertise either
|
|
15
|
+
* feat(docs): show `npm version`, monthly downloads, the supported Node range, the licence and CI status instead — facts that stay true on their own, sourced from npm and GitHub rather than a third-party scoring service. Provenance needs no badge: npm renders it natively beside the version
|
|
16
|
+
* feat(docs): open the README with the install command and a minimal working service — the class and the handler — so the first screenful shows what using the framework looks like rather than three paragraphs about it
|
|
17
|
+
* fix(package): replace the description, which was the generic monorepo blurb shared verbatim with `tester`, with one that says what this package is. It is the line npm shows in search results
|
|
18
|
+
* fix(package): drop the `pubsub` keyword and add `message-queue`, `ioredis` and `microservice-framework`. The framework does not use Redis pub/sub at all — its exchange is built on lists, hashes and RedisJSON — so that keyword advertised something it does not do
|
|
19
|
+
|
|
20
|
+
## Version 1.8.0
|
|
21
|
+
|
|
22
|
+
`ioredis` 6 makes RESP3 its default wire protocol. The framework does not set the `protocol` option, so this changes how every `core` connection talks to Redis without a line of framework code changing — and the suite here never touches a live Redis, so a green test run says nothing about it either way. It was checked against a real server rather than assumed: for every command the framework issues — `hgetall`, `smembers`, `hget`, `get`, `brpop`, the same commands through the generic `call()` path used for RedisJSON, and again inside `multi` — RESP3 and RESP2 return **identical** JavaScript values, because `ioredis` maps the new protocol's map and set types back to the objects and arrays it always returned. No consumer code changes.
|
|
23
|
+
|
|
24
|
+
The cost is the Redis floor. `ioredis` negotiates with a `HELLO 3` on connect and **throws** when the server cannot answer it — there is no fallback to RESP2 — so a server older than 6.0 now fails to connect instead of working as it did before.
|
|
25
|
+
|
|
26
|
+
* build(deps)!: update `ioredis` from ^5.11.1 to ^6.0.0. **BREAKING**: raises the minimum Redis version from 5.0.14 to **6.0**, because `ioredis` 6 defaults to RESP3 and refuses a server that cannot negotiate it. A deployment pinned to Redis 5 must upgrade the server; a consumer that needs the old wire protocol for another reason can pass `protocol: 2` in its Redis options
|
|
27
|
+
* docs(core): correct the documented Redis prerequisite from 5.0.14 to 6.0 and record why the floor moved
|
|
28
|
+
* build(release): bump package version from `1.7.2` to `1.8.0`
|
|
29
|
+
|
|
5
30
|
## Version 1.7.2
|
|
6
31
|
|
|
7
32
|
No functional change — the framework code is what `1.7.1` shipped. The version exists to exercise the automated npm publish that replaced the release-triggered workflow, and to prove this package's own trusted publisher configuration on npmjs.com: OIDC trust is granted per package, so it is only ever validated by an actual publish of that package.
|
package/README.md
CHANGED
|
@@ -1,15 +1,45 @@
|
|
|
1
1
|
# ti-engine core
|
|
2
2
|
|
|
3
|
-
](https://www.npmjs.com/package/@ti-engine/core)
|
|
4
|
+
[](https://www.npmjs.com/package/@ti-engine/core)
|
|
5
|
+
[](https://nodejs.org/)
|
|
6
|
+
[](https://github.com/Belleal/ti-engine/blob/master/LICENSE.md)
|
|
7
|
+
[](https://github.com/Belleal/ti-engine/actions/workflows/ci.yml)
|
|
8
8
|
|
|
9
9
|

|
|
10
10
|
|
|
11
11
|
Flexible framework for the creation of microservices with [node.js](https://nodejs.org/).
|
|
12
12
|
|
|
13
|
+
Every release is published from CI with a [provenance attestation](https://docs.npmjs.com/generating-provenance-statements), so the tarball on npm is verifiably built from the commit it names.
|
|
14
|
+
|
|
15
|
+
```shell
|
|
16
|
+
npm install @ti-engine/core
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
A service is a class and a handler. The class declares the lifecycle; the handler is the business logic:
|
|
20
|
+
|
|
21
|
+
```javascript
|
|
22
|
+
// my-service.js — the instance
|
|
23
|
+
const ServiceProvider = require( "@ti-engine/core/service-provider" );
|
|
24
|
+
|
|
25
|
+
class MyService extends ServiceProvider {
|
|
26
|
+
onStart() {
|
|
27
|
+
return Promise.resolve();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
module.exports = MyService;
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
```javascript
|
|
35
|
+
// services/v1/greet.js — one service, registered in the service registry JSON
|
|
36
|
+
module.exports.service = ( serviceDefinition, serviceParams, serviceCallContext ) => {
|
|
37
|
+
return Promise.resolve( { greeting: `hello, ${ serviceParams.name }` } );
|
|
38
|
+
};
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Point `TI_INSTANCE_CLASS` at the class, `TI_INSTANCE_NAME` at the service domain, and start it with `node ./node_modules/@ti-engine/core/bin/start-instance.js`. Calls between instances travel over Redis as an envelope plus a payload, traced end to end. The rest of this document covers that machinery in detail — start with [Prerequisites & installation](#prerequisites--installation).
|
|
42
|
+
|
|
13
43
|
## Introduction
|
|
14
44
|
|
|
15
45
|
The **ti-engine** is an open source, free to use—both for personal and commercial projects—framework for the creation of microservice-based solutions using **node.js**. The architectural concept of the framework is based on a standard _messaging system_ that allows for certain customization but also provides predictability and traceability of its behavior.
|
|
@@ -36,7 +66,9 @@ Being a messaging system, the **ti-engine** relies on a message broker for the a
|
|
|
36
66
|
To run the basic **ti-engine** framework, you will need a couple of things:
|
|
37
67
|
|
|
38
68
|
* A local [node.js installation](https://nodejs.org/en/download/) with a minimum version of **20.12.0** (the `core` package requires `process.loadEnvFile`)
|
|
39
|
-
* A local or remote [Redis cache installation](https://redis.io/download) with a minimum version of **
|
|
69
|
+
* A local or remote [Redis cache installation](https://redis.io/download) with a minimum version of **6.0**
|
|
70
|
+
|
|
71
|
+
> The Redis floor moved from 5.0.14 to 6.0 in `core` 1.8.0, when `ioredis` 6 made RESP3 its default wire protocol. RESP3 arrived in Redis 6.0, and the client negotiates it with a `HELLO 3` on connect — an older server rejects that and the connection fails outright rather than falling back, so this is a hard requirement rather than a recommendation. Replies are unaffected: `ioredis` maps every RESP3 reply back to the same JavaScript value RESP2 produced, so nothing in your service code changes.
|
|
40
72
|
|
|
41
73
|
If you are working under Windows 10+ OS and you need to install Redis, take a look at this [guide](https://redis.com/blog/redis-on-windows-10/). You could also use [Redis Cloud](https://app.redislabs.com/) for development as it offers a free basic account.
|
|
42
74
|
|
|
@@ -117,10 +117,10 @@
|
|
|
117
117
|
|
|
118
118
|
/**
|
|
119
119
|
* @typedef {Object} TiEnum
|
|
120
|
-
* @property {Object.<
|
|
121
|
-
* @property {
|
|
122
|
-
* @property {
|
|
123
|
-
* @property {
|
|
120
|
+
* @property {Object.<string,TiEnumValue>} properties
|
|
121
|
+
* @property {(enumValue: number|string, placeholder?: string) => string|undefined} name
|
|
122
|
+
* @property {(enumValue: number|string, placeholder?: string) => string|undefined} description
|
|
123
|
+
* @property {(enumValue: number|string) => boolean} contains
|
|
124
124
|
*/
|
|
125
125
|
|
|
126
126
|
/**
|
package/package.json
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ti-engine/core",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.8.1",
|
|
4
|
+
"description": "Microservice framework for Node.js: a Redis-backed message exchange with end-to-end call tracing, retries and tamper-evident message envelopes.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"microservices",
|
|
7
|
+
"microservice-framework",
|
|
7
8
|
"framework",
|
|
8
9
|
"node",
|
|
9
10
|
"redis",
|
|
11
|
+
"ioredis",
|
|
10
12
|
"messaging",
|
|
11
|
-
"
|
|
13
|
+
"message-queue",
|
|
12
14
|
"distributed-systems"
|
|
13
15
|
],
|
|
14
16
|
"author": "Boris Kostadinov <kostadinov.boris@gmail.com>",
|
|
@@ -59,12 +61,11 @@
|
|
|
59
61
|
"#tools": "./utils/tools.js"
|
|
60
62
|
},
|
|
61
63
|
"dependencies": {
|
|
62
|
-
"ioredis": "^
|
|
64
|
+
"ioredis": "^6.0.0",
|
|
63
65
|
"lodash": "^4.18.1",
|
|
64
66
|
"node-schedule": "^2.1.1"
|
|
65
67
|
},
|
|
66
|
-
"optionalDependencies": {
|
|
67
|
-
},
|
|
68
|
+
"optionalDependencies": {},
|
|
68
69
|
"files": [
|
|
69
70
|
"bin/",
|
|
70
71
|
"components/",
|
|
@@ -87,4 +88,4 @@
|
|
|
87
88
|
"engines": {
|
|
88
89
|
"node": ">=20.12.0"
|
|
89
90
|
}
|
|
90
|
-
}
|
|
91
|
+
}
|
package/utils/tools.js
CHANGED
|
@@ -49,7 +49,11 @@ module.exports.deepFreeze = ( object, seen = new WeakSet() ) => {
|
|
|
49
49
|
* @returns {Object} This is a {@link TiEnum} object. Setting the proper reference here would unfortunately break IDE support.
|
|
50
50
|
* @public
|
|
51
51
|
*/
|
|
52
|
-
|
|
52
|
+
// Declared as a named constant and exported below rather than assigned straight onto `module.exports`:
|
|
53
|
+
// `enum` is a reserved word in TypeScript, and a direct assignment makes the generated declaration
|
|
54
|
+
// `export declare var enum`, which is a syntax error. Named and re-exported, it emits the aliased
|
|
55
|
+
// form instead. The runtime export is unchanged — this is still `tools.enum( ... )`.
|
|
56
|
+
const createEnum = ( seed ) => {
|
|
53
57
|
const enumObject = Object.create( null );
|
|
54
58
|
const properties = Object.create( null );
|
|
55
59
|
const reserved = new Set( [ "properties", "name", "description", "contains", "__proto__", "prototype", "constructor" ] );
|
|
@@ -147,6 +151,7 @@ module.exports.enum = ( seed ) => {
|
|
|
147
151
|
|
|
148
152
|
return enumObject;
|
|
149
153
|
};
|
|
154
|
+
module.exports.enum = createEnum;
|
|
150
155
|
|
|
151
156
|
/**
|
|
152
157
|
* Used to get the name of an {@link TiEnum} value if such exists.
|