@zeltjs/redis 0.8.1 → 0.8.2-canary.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.cjs +69 -0
- package/dist/index.d.cts +15 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/redis.config-B6qdgxs7.cjs +35 -0
- package/dist/redis.config-Bq3ZfBPI.d.cts +13 -0
- package/dist/redis.config-Bq3ZfBPI.d.cts.map +1 -0
- package/dist/testing/index.cjs +54 -0
- package/dist/testing/index.d.cts +16 -0
- package/dist/testing/index.d.cts.map +1 -0
- package/package.json +22 -9
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region \0rolldown/runtime.js
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
|
+
get: ((k) => from[k]).bind(null, key),
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
20
|
+
value: mod,
|
|
21
|
+
enumerable: true
|
|
22
|
+
}) : target, mod));
|
|
23
|
+
//#endregion
|
|
24
|
+
const require_redis_config = require("./redis.config-B6qdgxs7.cjs");
|
|
25
|
+
let _zeltjs_core = require("@zeltjs/core");
|
|
26
|
+
let ioredis = require("ioredis");
|
|
27
|
+
ioredis = __toESM(ioredis, 1);
|
|
28
|
+
//#region src/redis.service.ts
|
|
29
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
30
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
31
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
32
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
33
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
34
|
+
}
|
|
35
|
+
function _ts_metadata(k, v) {
|
|
36
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
37
|
+
}
|
|
38
|
+
var RedisService = class {
|
|
39
|
+
get client() {
|
|
40
|
+
return this._client;
|
|
41
|
+
}
|
|
42
|
+
async startup() {}
|
|
43
|
+
async shutdown() {
|
|
44
|
+
this._client.disconnect();
|
|
45
|
+
}
|
|
46
|
+
constructor(config = (0, _zeltjs_core.inject)(require_redis_config.RedisConfig), lifecycle = (0, _zeltjs_core.inject)(_zeltjs_core.LifecycleManager)) {
|
|
47
|
+
this._client = new ioredis.default(config.url, config.options);
|
|
48
|
+
lifecycle.register(this);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
RedisService = _ts_decorate([
|
|
52
|
+
(0, _zeltjs_core.Injectable)(),
|
|
53
|
+
_ts_metadata("design:type", Function),
|
|
54
|
+
_ts_metadata("design:paramtypes", [void 0, void 0])
|
|
55
|
+
], RedisService);
|
|
56
|
+
//#endregion
|
|
57
|
+
Object.defineProperty(exports, "RedisConfig", {
|
|
58
|
+
enumerable: true,
|
|
59
|
+
get: function() {
|
|
60
|
+
return require_redis_config.RedisConfig;
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
Object.defineProperty(exports, "RedisService", {
|
|
64
|
+
enumerable: true,
|
|
65
|
+
get: function() {
|
|
66
|
+
return RedisService;
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
exports.__toESM = __toESM;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { t as RedisConfig } from "./redis.config-Bq3ZfBPI.cjs";
|
|
2
|
+
import { Lifecycle, LifecycleManager } from "@zeltjs/core";
|
|
3
|
+
import Redis from "ioredis";
|
|
4
|
+
|
|
5
|
+
//#region src/redis.service.d.ts
|
|
6
|
+
declare class RedisService implements Lifecycle {
|
|
7
|
+
private readonly _client;
|
|
8
|
+
constructor(config?: RedisConfig, lifecycle?: LifecycleManager);
|
|
9
|
+
get client(): Redis;
|
|
10
|
+
startup(): Promise<void>;
|
|
11
|
+
shutdown(): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { RedisConfig, RedisService };
|
|
15
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/redis.service.ts"],"mappings":";;;;;cAOa,YAAA,YAAwB,SAAA;EAAA,iBAClB,OAAA;cAEL,MAAA,GAAM,WAAA,EAAwB,SAAA,GAAS,gBAAA;EAAA,IAK/C,MAAA,CAAA,GAAU,KAAA;EAIR,OAAA,CAAA,GAAW,OAAA;EAEX,QAAA,CAAA,GAAY,OAAA;AAAA"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
require("./index.cjs");
|
|
2
|
+
let _zeltjs_core = require("@zeltjs/core");
|
|
3
|
+
//#region src/redis.config.ts
|
|
4
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
5
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
6
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
7
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
8
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
9
|
+
}
|
|
10
|
+
function _ts_metadata(k, v) {
|
|
11
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
12
|
+
}
|
|
13
|
+
var RedisConfig = class {
|
|
14
|
+
get url() {
|
|
15
|
+
return this.env.getString("REDIS_URL", "redis://localhost:6379");
|
|
16
|
+
}
|
|
17
|
+
get options() {
|
|
18
|
+
return {};
|
|
19
|
+
}
|
|
20
|
+
constructor(env = (0, _zeltjs_core.inject)(_zeltjs_core.Env)) {
|
|
21
|
+
this.env = env;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
RedisConfig = _ts_decorate([
|
|
25
|
+
_zeltjs_core.Config,
|
|
26
|
+
_ts_metadata("design:type", Function),
|
|
27
|
+
_ts_metadata("design:paramtypes", [void 0])
|
|
28
|
+
], RedisConfig);
|
|
29
|
+
//#endregion
|
|
30
|
+
Object.defineProperty(exports, "RedisConfig", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function() {
|
|
33
|
+
return RedisConfig;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Env } from "@zeltjs/core";
|
|
2
|
+
import { RedisOptions } from "ioredis";
|
|
3
|
+
|
|
4
|
+
//#region src/redis.config.d.ts
|
|
5
|
+
declare class RedisConfig {
|
|
6
|
+
protected readonly env: Env;
|
|
7
|
+
constructor(env?: Env);
|
|
8
|
+
get url(): string;
|
|
9
|
+
get options(): RedisOptions;
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { RedisConfig as t };
|
|
13
|
+
//# sourceMappingURL=redis.config-Bq3ZfBPI.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redis.config-Bq3ZfBPI.d.cts","names":[],"sources":["../src/redis.config.ts"],"mappings":";;;;cAIa,WAAA;EAAA,mBACoB,GAAA,EAAG,GAAA;cAAH,GAAA,GAAG,GAAA;EAAA,IAE9B,GAAA,CAAA;EAAA,IAIA,OAAA,CAAA,GAAW,YAAA;AAAA"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_redis_config = require("../redis.config-B6qdgxs7.cjs");
|
|
3
|
+
require("../index.cjs");
|
|
4
|
+
let _zeltjs_core = require("@zeltjs/core");
|
|
5
|
+
let testcontainers = require("testcontainers");
|
|
6
|
+
//#region src/testing/redis-test-container.config.ts
|
|
7
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
8
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
10
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
11
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
12
|
+
}
|
|
13
|
+
function _ts_metadata(k, v) {
|
|
14
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
15
|
+
}
|
|
16
|
+
var RedisTestContainerConfig = class extends require_redis_config.RedisConfig {
|
|
17
|
+
get image() {
|
|
18
|
+
return "redis:7-alpine";
|
|
19
|
+
}
|
|
20
|
+
async startup() {
|
|
21
|
+
this.state.container = await new testcontainers.GenericContainer(this.image).withExposedPorts(6379).start();
|
|
22
|
+
const host = this.state.container.getHost();
|
|
23
|
+
const port = this.state.container.getMappedPort(6379);
|
|
24
|
+
this.state.connectionUrl = `redis://${host}:${port}`;
|
|
25
|
+
}
|
|
26
|
+
async shutdown() {
|
|
27
|
+
await this.state.container?.stop();
|
|
28
|
+
}
|
|
29
|
+
get url() {
|
|
30
|
+
return this.state.connectionUrl;
|
|
31
|
+
}
|
|
32
|
+
get options() {
|
|
33
|
+
return {};
|
|
34
|
+
}
|
|
35
|
+
constructor(lifecycle = (0, _zeltjs_core.inject)(_zeltjs_core.LifecycleManager)) {
|
|
36
|
+
super(), this.state = {
|
|
37
|
+
container: void 0,
|
|
38
|
+
connectionUrl: ""
|
|
39
|
+
};
|
|
40
|
+
lifecycle.register(this);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
RedisTestContainerConfig = _ts_decorate([
|
|
44
|
+
_zeltjs_core.Config,
|
|
45
|
+
_ts_metadata("design:type", Function),
|
|
46
|
+
_ts_metadata("design:paramtypes", [void 0])
|
|
47
|
+
], RedisTestContainerConfig);
|
|
48
|
+
//#endregion
|
|
49
|
+
Object.defineProperty(exports, "RedisTestContainerConfig", {
|
|
50
|
+
enumerable: true,
|
|
51
|
+
get: function() {
|
|
52
|
+
return RedisTestContainerConfig;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { t as RedisConfig } from "../redis.config-Bq3ZfBPI.cjs";
|
|
2
|
+
import { Lifecycle, LifecycleManager } from "@zeltjs/core";
|
|
3
|
+
|
|
4
|
+
//#region src/testing/redis-test-container.config.d.ts
|
|
5
|
+
declare class RedisTestContainerConfig extends RedisConfig implements Lifecycle {
|
|
6
|
+
private readonly state;
|
|
7
|
+
constructor(lifecycle?: LifecycleManager);
|
|
8
|
+
protected get image(): string;
|
|
9
|
+
startup(): Promise<void>;
|
|
10
|
+
shutdown(): Promise<void>;
|
|
11
|
+
get url(): string;
|
|
12
|
+
get options(): RedisConfig['options'];
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { RedisTestContainerConfig };
|
|
16
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/testing/redis-test-container.config.ts"],"mappings":";;;;cAca,wBAAA,SAAiC,WAAA,YAAuB,SAAA;EAAA,iBAClD,KAAA;cAEL,SAAA,GAAS,gBAAA;EAAA,cAKP,KAAA,CAAA;EAIR,OAAA,CAAA,GAAW,OAAA;EAOX,QAAA,CAAA,GAAY,OAAA;EAAA,IAIL,GAAA,CAAA;EAAA,IAIA,OAAA,CAAA,GAAW,WAAA;AAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeltjs/redis",
|
|
3
|
-
"version": "0.8.1",
|
|
3
|
+
"version": "0.8.2-canary.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -13,12 +13,24 @@
|
|
|
13
13
|
},
|
|
14
14
|
"exports": {
|
|
15
15
|
".": {
|
|
16
|
-
"
|
|
17
|
-
|
|
16
|
+
"import": {
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"default": "./dist/index.js"
|
|
19
|
+
},
|
|
20
|
+
"require": {
|
|
21
|
+
"types": "./dist/index.d.cts",
|
|
22
|
+
"default": "./dist/index.cjs"
|
|
23
|
+
}
|
|
18
24
|
},
|
|
19
25
|
"./testing": {
|
|
20
|
-
"
|
|
21
|
-
|
|
26
|
+
"import": {
|
|
27
|
+
"types": "./dist/testing/index.d.ts",
|
|
28
|
+
"default": "./dist/testing/index.js"
|
|
29
|
+
},
|
|
30
|
+
"require": {
|
|
31
|
+
"types": "./dist/testing/index.d.cts",
|
|
32
|
+
"default": "./dist/testing/index.cjs"
|
|
33
|
+
}
|
|
22
34
|
}
|
|
23
35
|
},
|
|
24
36
|
"files": [
|
|
@@ -26,8 +38,8 @@
|
|
|
26
38
|
],
|
|
27
39
|
"peerDependencies": {
|
|
28
40
|
"testcontainers": ">=10 <12",
|
|
29
|
-
"@zeltjs/core": "0.8.1",
|
|
30
|
-
"@zeltjs/testing": "0.8.1"
|
|
41
|
+
"@zeltjs/core": "0.8.2-canary.1",
|
|
42
|
+
"@zeltjs/testing": "0.8.2-canary.1"
|
|
31
43
|
},
|
|
32
44
|
"peerDependenciesMeta": {
|
|
33
45
|
"@zeltjs/testing": {
|
|
@@ -43,12 +55,13 @@
|
|
|
43
55
|
"devDependencies": {
|
|
44
56
|
"@types/node": "22.19.17",
|
|
45
57
|
"testcontainers": "10.25.0",
|
|
46
|
-
"@zeltjs/
|
|
47
|
-
"@zeltjs/
|
|
58
|
+
"@zeltjs/testing": "0.8.2-canary.1",
|
|
59
|
+
"@zeltjs/core": "0.8.2-canary.1"
|
|
48
60
|
},
|
|
49
61
|
"volta": {
|
|
50
62
|
"extends": "../../package.json"
|
|
51
63
|
},
|
|
64
|
+
"main": "./dist/index.cjs",
|
|
52
65
|
"scripts": {
|
|
53
66
|
"build": "tsdown",
|
|
54
67
|
"test": "vitest run",
|