@privateaim/server-kit 0.8.4 → 0.8.6
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 +42 -0
- package/dist/core/index.d.ts +0 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/domain-event/publish.d.ts +2 -2
- package/dist/domain-event/publish.d.ts.map +1 -1
- package/dist/domain-event/redis/publish.d.ts +2 -2
- package/dist/domain-event/redis/publish.d.ts.map +1 -1
- package/dist/domain-event/socket/publish.d.ts +2 -2
- package/dist/domain-event/socket/publish.d.ts.map +1 -1
- package/dist/index.cjs +251 -107
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +247 -106
- package/dist/index.mjs.map +1 -1
- package/dist/services/cache/adapters/factory.d.ts +4 -0
- package/dist/services/cache/adapters/factory.d.ts.map +1 -0
- package/dist/services/cache/adapters/index.d.ts +5 -0
- package/dist/services/cache/adapters/index.d.ts.map +1 -0
- package/dist/services/cache/adapters/memory.d.ts +15 -0
- package/dist/services/cache/adapters/memory.d.ts.map +1 -0
- package/dist/services/cache/adapters/redis.d.ts +16 -0
- package/dist/services/cache/adapters/redis.d.ts.map +1 -0
- package/dist/services/cache/adapters/types.d.ts +10 -0
- package/dist/services/cache/adapters/types.d.ts.map +1 -0
- package/dist/services/cache/helper.d.ts +3 -0
- package/dist/services/cache/helper.d.ts.map +1 -0
- package/dist/services/cache/index.d.ts +6 -0
- package/dist/services/cache/index.d.ts.map +1 -0
- package/dist/services/cache/module.d.ts +13 -0
- package/dist/services/cache/module.d.ts.map +1 -0
- package/dist/services/cache/singleton.d.ts +3 -0
- package/dist/services/cache/singleton.d.ts.map +1 -0
- package/dist/services/cache/types.d.ts +16 -0
- package/dist/services/cache/types.d.ts.map +1 -0
- package/dist/services/index.d.ts +1 -0
- package/dist/services/index.d.ts.map +1 -1
- package/package.json +13 -13
- package/src/core/index.ts +0 -1
- package/src/domain-event/publish.ts +2 -2
- package/src/domain-event/redis/publish.ts +2 -2
- package/src/domain-event/socket/publish.ts +6 -3
- package/src/services/cache/adapters/factory.ts +18 -0
- package/src/services/cache/adapters/index.ts +11 -0
- package/src/services/cache/adapters/memory.ts +67 -0
- package/src/services/cache/adapters/redis.ts +69 -0
- package/src/services/cache/adapters/types.ts +22 -0
- package/src/services/cache/helper.ts +13 -0
- package/src/{core/memory-cache → services/cache}/index.ts +4 -1
- package/src/services/cache/module.ts +41 -0
- package/src/services/cache/singleton.ts +30 -0
- package/src/services/cache/types.ts +24 -0
- package/src/services/index.ts +1 -0
- package/test/unit/memory-cache.spec.ts +10 -9
- package/dist/core/memory-cache/index.d.ts +0 -3
- package/dist/core/memory-cache/index.d.ts.map +0 -1
- package/dist/core/memory-cache/module.d.ts +0 -15
- package/dist/core/memory-cache/module.d.ts.map +0 -1
- package/dist/core/memory-cache/singleton.d.ts +0 -3
- package/dist/core/memory-cache/singleton.d.ts.map +0 -1
- package/src/core/memory-cache/module.ts +0 -48
- package/src/core/memory-cache/singleton.ts +0 -18
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,47 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.8.6](https://github.com/PrivateAIM/hub/compare/v0.8.5...v0.8.6) (2025-03-04)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* **deps:** bump the minorandpatch group across 1 directory with 4 updates ([#997](https://github.com/PrivateAIM/hub/issues/997)) ([949ba29](https://github.com/PrivateAIM/hub/commit/949ba29f66ef6840b9e92b2504b26b7a7a7036e0))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* The following workspace dependencies were updated
|
|
14
|
+
* dependencies
|
|
15
|
+
* @privateaim/core-kit bumped from ^0.8.5 to ^0.8.6
|
|
16
|
+
* @privateaim/kit bumped from ^0.8.5 to ^0.8.6
|
|
17
|
+
|
|
18
|
+
## [0.8.5](https://github.com/PrivateAIM/hub/compare/v0.8.4...v0.8.5) (2025-01-22)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Features
|
|
22
|
+
|
|
23
|
+
* bump authup dependencies & adjusted code base ([90f7131](https://github.com/PrivateAIM/hub/commit/90f7131723e4e00dad04cb5ababa3e3f232e9c24))
|
|
24
|
+
* enhance typing for doamin entities ([9d7c516](https://github.com/PrivateAIM/hub/commit/9d7c51644b66c9361e5436e2c43f463f4f219f90))
|
|
25
|
+
* initial hybrid cache (redis or memory) implementation ([b1cd569](https://github.com/PrivateAIM/hub/commit/b1cd569ff52d222f61d4b87abc921cb769de8264))
|
|
26
|
+
* refactor http controller validation ([#880](https://github.com/PrivateAIM/hub/issues/880)) ([6e11074](https://github.com/PrivateAIM/hub/commit/6e110742f946d4d0e827f4beb497ba2612568b9a))
|
|
27
|
+
* refactoring of master-image workflow ([#845](https://github.com/PrivateAIM/hub/issues/845)) ([7d2b866](https://github.com/PrivateAIM/hub/commit/7d2b8662b24dcf411d3ae8232152fecf53167382))
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
### Bug Fixes
|
|
31
|
+
|
|
32
|
+
* **deps:** bump authup to v1.0.0-beta.24 ([#963](https://github.com/PrivateAIM/hub/issues/963)) ([90c40c0](https://github.com/PrivateAIM/hub/commit/90c40c0d55018557ee8bb381aad7e3cfbcd29b83))
|
|
33
|
+
* **deps:** bump the minorandpatch group across 1 directory with 31 updates ([#945](https://github.com/PrivateAIM/hub/issues/945)) ([448e9b8](https://github.com/PrivateAIM/hub/commit/448e9b86bf80f83c4aa8bb32ee0a75190a1d5cb8))
|
|
34
|
+
* **deps:** bump the minorandpatch group across 1 directory with 4 updates ([#906](https://github.com/PrivateAIM/hub/issues/906)) ([e11bc5f](https://github.com/PrivateAIM/hub/commit/e11bc5f3b565347af3180e8e29b4e3b79ace5961))
|
|
35
|
+
* **deps:** bump winston from 3.15.0 to 3.16.0 ([#878](https://github.com/PrivateAIM/hub/issues/878)) ([71a2fcd](https://github.com/PrivateAIM/hub/commit/71a2fcd6b507dc44543645acd9622d5d9372dd80))
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
### Dependencies
|
|
39
|
+
|
|
40
|
+
* The following workspace dependencies were updated
|
|
41
|
+
* dependencies
|
|
42
|
+
* @privateaim/core-kit bumped from ^0.8.4 to ^0.8.5
|
|
43
|
+
* @privateaim/kit bumped from ^0.8.4 to ^0.8.5
|
|
44
|
+
|
|
3
45
|
## [0.8.4](https://github.com/PrivateAIM/hub/compare/v0.8.3...v0.8.4) (2024-10-24)
|
|
4
46
|
|
|
5
47
|
|
package/dist/core/index.d.ts
CHANGED
package/dist/core/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAOA,cAAc,cAAc,CAAC;AAC7B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAOA,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { DomainsEvents } from '@privateaim/core-kit';
|
|
2
2
|
import type { Client } from 'redis-extension';
|
|
3
3
|
import type { DomainEventDestinations } from './type';
|
|
4
|
-
export declare function publishDomainEvent(client: Client, context:
|
|
4
|
+
export declare function publishDomainEvent(client: Client, context: DomainsEvents, destinations: DomainEventDestinations): Promise<void>;
|
|
5
5
|
//# sourceMappingURL=publish.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publish.d.ts","sourceRoot":"","sources":["../../src/domain-event/publish.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"publish.d.ts","sourceRoot":"","sources":["../../src/domain-event/publish.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAG9C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,QAAQ,CAAC;AAEtD,wBAAsB,kBAAkB,CACpC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,aAAa,EACtB,YAAY,EAAE,uBAAuB,iBAIxC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { DomainsEvents } from '@privateaim/core-kit';
|
|
2
2
|
import type { Client } from 'redis-extension';
|
|
3
3
|
import type { DomainEventDestinations } from '../type';
|
|
4
|
-
export declare function publishDomainRedisEvent(client: Client, context:
|
|
4
|
+
export declare function publishDomainRedisEvent(client: Client, context: DomainsEvents, destinations: DomainEventDestinations): Promise<any>;
|
|
5
5
|
//# sourceMappingURL=publish.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publish.d.ts","sourceRoot":"","sources":["../../../src/domain-event/redis/publish.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"publish.d.ts","sourceRoot":"","sources":["../../../src/domain-event/redis/publish.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAGvD,wBAAsB,uBAAuB,CACzC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,aAAa,EACtB,YAAY,EAAE,uBAAuB,GACrC,OAAO,CAAC,GAAG,CAAC,CAuBf"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { DomainsEvents } from '@privateaim/core-kit';
|
|
2
2
|
import type { Client } from 'redis-extension';
|
|
3
3
|
import type { DomainEventDestinations } from '../type';
|
|
4
|
-
export declare function publishDomainSocketEvent(client: Client, context:
|
|
4
|
+
export declare function publishDomainSocketEvent(client: Client, context: DomainsEvents, destinations: DomainEventDestinations): void;
|
|
5
5
|
//# sourceMappingURL=publish.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publish.d.ts","sourceRoot":"","sources":["../../../src/domain-event/socket/publish.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"publish.d.ts","sourceRoot":"","sources":["../../../src/domain-event/socket/publish.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAG1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAGvD,wBAAgB,wBAAwB,CACpC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,aAAa,EACtB,YAAY,EAAE,uBAAuB,QA0CxC"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,78 +1,25 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var TTLCache = require('@isaacs/ttlcache');
|
|
4
|
-
var singa = require('singa');
|
|
5
3
|
var kit = require('@privateaim/kit');
|
|
6
4
|
var amqpExtension = require('amqp-extension');
|
|
5
|
+
var singa = require('singa');
|
|
7
6
|
var vault = require('@hapic/vault');
|
|
8
7
|
var coreHttpKit = require('@authup/core-http-kit');
|
|
8
|
+
var redisExtension = require('redis-extension');
|
|
9
|
+
var TTLCache = require('@isaacs/ttlcache');
|
|
9
10
|
var envix = require('envix');
|
|
10
11
|
var path = require('node:path');
|
|
11
12
|
var typeormExtension = require('typeorm-extension');
|
|
12
13
|
var winston = require('winston');
|
|
13
|
-
var redisExtension = require('redis-extension');
|
|
14
14
|
var coreKit = require('@privateaim/core-kit');
|
|
15
15
|
var redisEmitter = require('@socket.io/redis-emitter');
|
|
16
16
|
|
|
17
|
-
/*
|
|
18
|
-
* Copyright (c) 2024.
|
|
19
|
-
* Author Peter Placzek (tada5hi)
|
|
20
|
-
* For the full copyright and license information,
|
|
21
|
-
* view the LICENSE file that was distributed with this source code.
|
|
22
|
-
*/ function _define_property$2(obj, key, value) {
|
|
23
|
-
if (key in obj) {
|
|
24
|
-
Object.defineProperty(obj, key, {
|
|
25
|
-
value: value,
|
|
26
|
-
enumerable: true,
|
|
27
|
-
configurable: true,
|
|
28
|
-
writable: true
|
|
29
|
-
});
|
|
30
|
-
} else {
|
|
31
|
-
obj[key] = value;
|
|
32
|
-
}
|
|
33
|
-
return obj;
|
|
34
|
-
}
|
|
35
|
-
class MemoryCache {
|
|
36
|
-
set(id, value, options) {
|
|
37
|
-
this.cache.set(id, value, {
|
|
38
|
-
ttl: options.ttl
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
get(id) {
|
|
42
|
-
return this.cache.get(id);
|
|
43
|
-
}
|
|
44
|
-
del(id) {
|
|
45
|
-
this.cache.delete(id);
|
|
46
|
-
}
|
|
47
|
-
has(id) {
|
|
48
|
-
return this.cache.has(id);
|
|
49
|
-
}
|
|
50
|
-
constructor(options = {}){
|
|
51
|
-
_define_property$2(this, "options", void 0);
|
|
52
|
-
_define_property$2(this, "cache", void 0);
|
|
53
|
-
this.options = {
|
|
54
|
-
// 60 seconds
|
|
55
|
-
ttl: 1000 * 60,
|
|
56
|
-
...options
|
|
57
|
-
};
|
|
58
|
-
this.cache = new TTLCache();
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const instance$8 = singa.singa({
|
|
63
|
-
name: 'queueRouter',
|
|
64
|
-
factory: ()=>new MemoryCache()
|
|
65
|
-
});
|
|
66
|
-
function useMemoryCache() {
|
|
67
|
-
return instance$8.use();
|
|
68
|
-
}
|
|
69
|
-
|
|
70
17
|
/*
|
|
71
18
|
* Copyright (c) 2023-2024.
|
|
72
19
|
* Author Peter Placzek (tada5hi)
|
|
73
20
|
* For the full copyright and license information,
|
|
74
21
|
* view the LICENSE file that was distributed with this source code.
|
|
75
|
-
*/ function _define_property$
|
|
22
|
+
*/ function _define_property$4(obj, key, value) {
|
|
76
23
|
if (key in obj) {
|
|
77
24
|
Object.defineProperty(obj, key, {
|
|
78
25
|
value: value,
|
|
@@ -89,7 +36,7 @@ class ComponentError extends Error {
|
|
|
89
36
|
constructor(input){
|
|
90
37
|
super(input.message, {
|
|
91
38
|
cause: input.cause
|
|
92
|
-
}), _define_property$
|
|
39
|
+
}), _define_property$4(this, "code", void 0);
|
|
93
40
|
this.code = input.code;
|
|
94
41
|
}
|
|
95
42
|
}
|
|
@@ -137,30 +84,30 @@ function isQueueRouterPayload(input) {
|
|
|
137
84
|
return kit.isObject(input) && typeof input.id === 'string' && typeof input.type === 'string' && kit.hasOwnProperty(input, 'data') && kit.isObject(input.data) && kit.hasOwnProperty(input, 'metadata') && kit.isObject(input.metadata);
|
|
138
85
|
}
|
|
139
86
|
|
|
140
|
-
const instance$
|
|
87
|
+
const instance$8 = singa.singa({
|
|
141
88
|
name: 'amqp'
|
|
142
89
|
});
|
|
143
90
|
function setAmqpClientFactory(factory) {
|
|
144
|
-
instance$
|
|
91
|
+
instance$8.setFactory(factory);
|
|
145
92
|
}
|
|
146
93
|
function isAmqpClientUsable() {
|
|
147
|
-
return instance$
|
|
94
|
+
return instance$8.has() || instance$8.hasFactory();
|
|
148
95
|
}
|
|
149
96
|
function useAmqpClient() {
|
|
150
|
-
return instance$
|
|
97
|
+
return instance$8.use();
|
|
151
98
|
}
|
|
152
99
|
|
|
153
|
-
const instance$
|
|
100
|
+
const instance$7 = singa.singa({
|
|
154
101
|
name: 'vault'
|
|
155
102
|
});
|
|
156
103
|
function setVaultFactory(factory) {
|
|
157
|
-
instance$
|
|
104
|
+
instance$7.setFactory(factory);
|
|
158
105
|
}
|
|
159
106
|
function isVaultClientUsable() {
|
|
160
|
-
return instance$
|
|
107
|
+
return instance$7.has() || instance$7.hasFactory();
|
|
161
108
|
}
|
|
162
109
|
function useVaultClient() {
|
|
163
|
-
return instance$
|
|
110
|
+
return instance$7.use();
|
|
164
111
|
}
|
|
165
112
|
|
|
166
113
|
function guessAuthupTokenCreatorOptions() {
|
|
@@ -199,18 +146,243 @@ class AuthupClient extends coreHttpKit.Client {
|
|
|
199
146
|
}
|
|
200
147
|
}
|
|
201
148
|
|
|
202
|
-
const instance$
|
|
149
|
+
const instance$6 = singa.singa({
|
|
203
150
|
name: 'authup'
|
|
204
151
|
});
|
|
205
152
|
function useAuthupClient() {
|
|
206
|
-
return instance$
|
|
153
|
+
return instance$6.use();
|
|
207
154
|
}
|
|
208
155
|
function isAuthupClientUsable() {
|
|
209
|
-
return instance$
|
|
156
|
+
return instance$6.has() || instance$6.hasFactory();
|
|
210
157
|
}
|
|
211
158
|
function setAuthupClientFactory(factory) {
|
|
159
|
+
instance$6.setFactory(factory);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const instance$5 = singa.singa({
|
|
163
|
+
name: 'redis'
|
|
164
|
+
});
|
|
165
|
+
function setRedisFactory(factory) {
|
|
212
166
|
instance$5.setFactory(factory);
|
|
213
167
|
}
|
|
168
|
+
function isRedisClientUsable() {
|
|
169
|
+
return instance$5.has() || instance$5.hasFactory();
|
|
170
|
+
}
|
|
171
|
+
function setRedisClient(input) {
|
|
172
|
+
instance$5.set(input);
|
|
173
|
+
}
|
|
174
|
+
function useRedisClient() {
|
|
175
|
+
return instance$5.use();
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const instance$4 = singa.singa({
|
|
179
|
+
name: 'redisPublish',
|
|
180
|
+
factory: ()=>useRedisClient().duplicate()
|
|
181
|
+
});
|
|
182
|
+
function useRedisPublishClient() {
|
|
183
|
+
return instance$4.use();
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
const instance$3 = singa.singa({
|
|
187
|
+
name: 'redisSubscribe',
|
|
188
|
+
factory: ()=>useRedisClient().duplicate()
|
|
189
|
+
});
|
|
190
|
+
function useRedisSubscribeClient() {
|
|
191
|
+
return instance$3.use();
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/*
|
|
195
|
+
* Copyright (c) 2024-2024.
|
|
196
|
+
* Author Peter Placzek (tada5hi)
|
|
197
|
+
* For the full copyright and license information,
|
|
198
|
+
* view the LICENSE file that was distributed with this source code.
|
|
199
|
+
*/ function _define_property$3(obj, key, value) {
|
|
200
|
+
if (key in obj) {
|
|
201
|
+
Object.defineProperty(obj, key, {
|
|
202
|
+
value: value,
|
|
203
|
+
enumerable: true,
|
|
204
|
+
configurable: true,
|
|
205
|
+
writable: true
|
|
206
|
+
});
|
|
207
|
+
} else {
|
|
208
|
+
obj[key] = value;
|
|
209
|
+
}
|
|
210
|
+
return obj;
|
|
211
|
+
}
|
|
212
|
+
class MemoryCacheAdapter {
|
|
213
|
+
async get(key) {
|
|
214
|
+
return this.instance.get(key);
|
|
215
|
+
}
|
|
216
|
+
async has(key) {
|
|
217
|
+
return this.instance.has(key);
|
|
218
|
+
}
|
|
219
|
+
async set(key, value, options) {
|
|
220
|
+
this.instance.set(key, value, {
|
|
221
|
+
ttl: options.ttl
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
async drop(key) {
|
|
225
|
+
this.instance.delete(key);
|
|
226
|
+
}
|
|
227
|
+
async dropMany(keys) {
|
|
228
|
+
for(let i = 0; i < keys.length; i++){
|
|
229
|
+
this.instance.delete(keys[i]);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
async clear(options = {}) {
|
|
233
|
+
if (options.prefix) {
|
|
234
|
+
const keys = this.instance.keys();
|
|
235
|
+
let iterator = keys.next();
|
|
236
|
+
while(!iterator.done){
|
|
237
|
+
if (iterator.value.startsWith(options.prefix)) {
|
|
238
|
+
this.instance.delete(iterator.value);
|
|
239
|
+
}
|
|
240
|
+
iterator = keys.next();
|
|
241
|
+
}
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
this.instance.clear();
|
|
245
|
+
}
|
|
246
|
+
constructor(options = {}){
|
|
247
|
+
_define_property$3(this, "instance", void 0);
|
|
248
|
+
this.instance = new TTLCache({
|
|
249
|
+
checkAgeOnGet: true,
|
|
250
|
+
ttl: Infinity,
|
|
251
|
+
...options || {}
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/*
|
|
257
|
+
* Copyright (c) 2024-2024.
|
|
258
|
+
* Author Peter Placzek (tada5hi)
|
|
259
|
+
* For the full copyright and license information,
|
|
260
|
+
* view the LICENSE file that was distributed with this source code.
|
|
261
|
+
*/ function _define_property$2(obj, key, value) {
|
|
262
|
+
if (key in obj) {
|
|
263
|
+
Object.defineProperty(obj, key, {
|
|
264
|
+
value: value,
|
|
265
|
+
enumerable: true,
|
|
266
|
+
configurable: true,
|
|
267
|
+
writable: true
|
|
268
|
+
});
|
|
269
|
+
} else {
|
|
270
|
+
obj[key] = value;
|
|
271
|
+
}
|
|
272
|
+
return obj;
|
|
273
|
+
}
|
|
274
|
+
class RedisCacheAdapter {
|
|
275
|
+
async get(key) {
|
|
276
|
+
return this.instance.get(key);
|
|
277
|
+
}
|
|
278
|
+
async has(key) {
|
|
279
|
+
const exists = await this.client.exists(key);
|
|
280
|
+
return !!exists;
|
|
281
|
+
}
|
|
282
|
+
async set(key, value, options) {
|
|
283
|
+
await this.instance.set(key, value, {
|
|
284
|
+
milliseconds: options.ttl
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
async drop(key) {
|
|
288
|
+
await this.instance.drop(key);
|
|
289
|
+
}
|
|
290
|
+
async dropMany(keys) {
|
|
291
|
+
const pipeline = this.client.pipeline();
|
|
292
|
+
for(let i = 0; i < keys.length; i++){
|
|
293
|
+
pipeline.del(keys[i]);
|
|
294
|
+
}
|
|
295
|
+
await pipeline.exec();
|
|
296
|
+
}
|
|
297
|
+
async clear(options = {}) {
|
|
298
|
+
if (options.prefix) {
|
|
299
|
+
const pipeline = this.client.pipeline();
|
|
300
|
+
const keys = await this.client.keys(`${options.prefix}*`);
|
|
301
|
+
for(let i = 0; i < keys.length; i++){
|
|
302
|
+
pipeline.del(keys[i]);
|
|
303
|
+
}
|
|
304
|
+
await pipeline.exec();
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
await this.client.flushdb();
|
|
308
|
+
}
|
|
309
|
+
constructor(){
|
|
310
|
+
_define_property$2(this, "client", void 0);
|
|
311
|
+
_define_property$2(this, "instance", void 0);
|
|
312
|
+
this.client = useRedisClient();
|
|
313
|
+
this.instance = new redisExtension.JsonAdapter(this.client);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
function createCacheAdapter() {
|
|
318
|
+
if (isRedisClientUsable()) {
|
|
319
|
+
return new RedisCacheAdapter();
|
|
320
|
+
}
|
|
321
|
+
return new MemoryCacheAdapter();
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
function buildCacheKey(options) {
|
|
325
|
+
return redisExtension.buildKeyPath(options);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/*
|
|
329
|
+
* Copyright (c) 2024.
|
|
330
|
+
* Author Peter Placzek (tada5hi)
|
|
331
|
+
* For the full copyright and license information,
|
|
332
|
+
* view the LICENSE file that was distributed with this source code.
|
|
333
|
+
*/ function _define_property$1(obj, key, value) {
|
|
334
|
+
if (key in obj) {
|
|
335
|
+
Object.defineProperty(obj, key, {
|
|
336
|
+
value: value,
|
|
337
|
+
enumerable: true,
|
|
338
|
+
configurable: true,
|
|
339
|
+
writable: true
|
|
340
|
+
});
|
|
341
|
+
} else {
|
|
342
|
+
obj[key] = value;
|
|
343
|
+
}
|
|
344
|
+
return obj;
|
|
345
|
+
}
|
|
346
|
+
class Cache {
|
|
347
|
+
async set(key, value, options = {}) {
|
|
348
|
+
await this.adapter.set(key, value, options);
|
|
349
|
+
}
|
|
350
|
+
async get(key) {
|
|
351
|
+
return this.adapter.get(key);
|
|
352
|
+
}
|
|
353
|
+
async has(key) {
|
|
354
|
+
return this.adapter.has(key);
|
|
355
|
+
}
|
|
356
|
+
async drop(key) {
|
|
357
|
+
return this.adapter.drop(key);
|
|
358
|
+
}
|
|
359
|
+
async dropMany(keys) {
|
|
360
|
+
return this.adapter.dropMany(keys);
|
|
361
|
+
}
|
|
362
|
+
async clear(options = {}) {
|
|
363
|
+
return this.adapter.clear(options);
|
|
364
|
+
}
|
|
365
|
+
constructor(adapter){
|
|
366
|
+
_define_property$1(this, "adapter", void 0);
|
|
367
|
+
this.adapter = adapter;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
const instance$2 = singa.singa({
|
|
372
|
+
name: 'cache',
|
|
373
|
+
factory: ()=>{
|
|
374
|
+
let adapter;
|
|
375
|
+
if (isRedisClientUsable()) {
|
|
376
|
+
adapter = new RedisCacheAdapter();
|
|
377
|
+
} else {
|
|
378
|
+
adapter = new MemoryCacheAdapter();
|
|
379
|
+
}
|
|
380
|
+
return new Cache(adapter);
|
|
381
|
+
}
|
|
382
|
+
});
|
|
383
|
+
function useCache() {
|
|
384
|
+
return instance$2.use();
|
|
385
|
+
}
|
|
214
386
|
|
|
215
387
|
function createLogger(ctx = {}) {
|
|
216
388
|
const { directory, options = {} } = ctx;
|
|
@@ -251,51 +423,19 @@ function createLogger(ctx = {}) {
|
|
|
251
423
|
});
|
|
252
424
|
}
|
|
253
425
|
|
|
254
|
-
const instance$
|
|
426
|
+
const instance$1 = singa.singa({
|
|
255
427
|
name: 'logger'
|
|
256
428
|
});
|
|
257
429
|
function setLoggerFactory(factory) {
|
|
258
|
-
instance$
|
|
430
|
+
instance$1.setFactory(factory);
|
|
259
431
|
}
|
|
260
432
|
function isLoggerUsable() {
|
|
261
|
-
return instance$
|
|
433
|
+
return instance$1.has() || instance$1.hasFactory();
|
|
262
434
|
}
|
|
263
435
|
function setLogger(input) {
|
|
264
|
-
instance$
|
|
436
|
+
instance$1.set(input);
|
|
265
437
|
}
|
|
266
438
|
function useLogger() {
|
|
267
|
-
return instance$4.use();
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
const instance$3 = singa.singa({
|
|
271
|
-
name: 'redis'
|
|
272
|
-
});
|
|
273
|
-
function setRedisFactory(factory) {
|
|
274
|
-
instance$3.setFactory(factory);
|
|
275
|
-
}
|
|
276
|
-
function isRedisClientUsable() {
|
|
277
|
-
return instance$3.has() || instance$3.hasFactory();
|
|
278
|
-
}
|
|
279
|
-
function setRedisClient(input) {
|
|
280
|
-
instance$3.set(input);
|
|
281
|
-
}
|
|
282
|
-
function useRedisClient() {
|
|
283
|
-
return instance$3.use();
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
const instance$2 = singa.singa({
|
|
287
|
-
name: 'redisPublish',
|
|
288
|
-
factory: ()=>useRedisClient().duplicate()
|
|
289
|
-
});
|
|
290
|
-
function useRedisPublishClient() {
|
|
291
|
-
return instance$2.use();
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
const instance$1 = singa.singa({
|
|
295
|
-
name: 'redisSubscribe',
|
|
296
|
-
factory: ()=>useRedisClient().duplicate()
|
|
297
|
-
});
|
|
298
|
-
function useRedisSubscribeClient() {
|
|
299
439
|
return instance$1.use();
|
|
300
440
|
}
|
|
301
441
|
|
|
@@ -517,11 +657,15 @@ Object.defineProperty(exports, "createRedisClient", {
|
|
|
517
657
|
get: function () { return redisExtension.createClient; }
|
|
518
658
|
});
|
|
519
659
|
exports.AuthupClient = AuthupClient;
|
|
660
|
+
exports.Cache = Cache;
|
|
520
661
|
exports.ComponentError = ComponentError;
|
|
521
|
-
exports.
|
|
662
|
+
exports.MemoryCacheAdapter = MemoryCacheAdapter;
|
|
522
663
|
exports.QueueRouter = QueueRouter;
|
|
523
664
|
exports.QueueRouterRoutingType = QueueRouterRoutingType;
|
|
665
|
+
exports.RedisCacheAdapter = RedisCacheAdapter;
|
|
666
|
+
exports.buildCacheKey = buildCacheKey;
|
|
524
667
|
exports.buildQueueRouterPublishPayload = buildQueueRouterPublishPayload;
|
|
668
|
+
exports.createCacheAdapter = createCacheAdapter;
|
|
525
669
|
exports.createLogger = createLogger;
|
|
526
670
|
exports.guessAuthupTokenCreatorOptions = guessAuthupTokenCreatorOptions;
|
|
527
671
|
exports.hasOwnProperty = hasOwnProperty;
|
|
@@ -546,8 +690,8 @@ exports.setRedisFactory = setRedisFactory;
|
|
|
546
690
|
exports.setVaultFactory = setVaultFactory;
|
|
547
691
|
exports.useAmqpClient = useAmqpClient;
|
|
548
692
|
exports.useAuthupClient = useAuthupClient;
|
|
693
|
+
exports.useCache = useCache;
|
|
549
694
|
exports.useLogger = useLogger;
|
|
550
|
-
exports.useMemoryCache = useMemoryCache;
|
|
551
695
|
exports.useQueueRouter = useQueueRouter;
|
|
552
696
|
exports.useRedisClient = useRedisClient;
|
|
553
697
|
exports.useRedisPublishClient = useRedisPublishClient;
|