@privateaim/server-kit 0.7.0
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 +205 -0
- package/LICENSE +202 -0
- package/dist/core/aggregator/index.d.ts +2 -0
- package/dist/core/aggregator/index.d.ts.map +1 -0
- package/dist/core/aggregator/type.d.ts +4 -0
- package/dist/core/aggregator/type.d.ts.map +1 -0
- package/dist/core/component/error.d.ts +6 -0
- package/dist/core/component/error.d.ts.map +1 -0
- package/dist/core/component/helper.d.ts +3 -0
- package/dist/core/component/helper.d.ts.map +1 -0
- package/dist/core/component/index.d.ts +4 -0
- package/dist/core/component/index.d.ts.map +1 -0
- package/dist/core/component/type.d.ts +17 -0
- package/dist/core/component/type.d.ts.map +1 -0
- package/dist/core/index.d.ts +5 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/queue/index.d.ts +3 -0
- package/dist/core/queue/index.d.ts.map +1 -0
- package/dist/core/queue/type.d.ts +12 -0
- package/dist/core/queue/type.d.ts.map +1 -0
- package/dist/core/queue/utils.d.ts +3 -0
- package/dist/core/queue/utils.d.ts.map +1 -0
- package/dist/core/queue-router/constants.d.ts +5 -0
- package/dist/core/queue-router/constants.d.ts.map +1 -0
- package/dist/core/queue-router/helpers.d.ts +4 -0
- package/dist/core/queue-router/helpers.d.ts.map +1 -0
- package/dist/core/queue-router/index.d.ts +6 -0
- package/dist/core/queue-router/index.d.ts.map +1 -0
- package/dist/core/queue-router/module.d.ts +9 -0
- package/dist/core/queue-router/module.d.ts.map +1 -0
- package/dist/core/queue-router/singleton.d.ts +4 -0
- package/dist/core/queue-router/singleton.d.ts.map +1 -0
- package/dist/core/queue-router/types.d.ts +31 -0
- package/dist/core/queue-router/types.d.ts.map +1 -0
- package/dist/domain-event/index.d.ts +5 -0
- package/dist/domain-event/index.d.ts.map +1 -0
- package/dist/domain-event/publish.d.ts +5 -0
- package/dist/domain-event/publish.d.ts.map +1 -0
- package/dist/domain-event/redis/index.d.ts +2 -0
- package/dist/domain-event/redis/index.d.ts.map +1 -0
- package/dist/domain-event/redis/publish.d.ts +5 -0
- package/dist/domain-event/redis/publish.d.ts.map +1 -0
- package/dist/domain-event/socket/index.d.ts +2 -0
- package/dist/domain-event/socket/index.d.ts.map +1 -0
- package/dist/domain-event/socket/publish.d.ts +5 -0
- package/dist/domain-event/socket/publish.d.ts.map +1 -0
- package/dist/domain-event/type.d.ts +7 -0
- package/dist/domain-event/type.d.ts.map +1 -0
- package/dist/domain-event/utils.d.ts +4 -0
- package/dist/domain-event/utils.d.ts.map +1 -0
- package/dist/index.cjs +492 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.mjs +422 -0
- package/dist/index.mjs.map +1 -0
- package/dist/services/amqp/index.d.ts +2 -0
- package/dist/services/amqp/index.d.ts.map +1 -0
- package/dist/services/amqp/module.d.ts +6 -0
- package/dist/services/amqp/module.d.ts.map +1 -0
- package/dist/services/authup/helpers.d.ts +3 -0
- package/dist/services/authup/helpers.d.ts.map +1 -0
- package/dist/services/authup/index.d.ts +4 -0
- package/dist/services/authup/index.d.ts.map +1 -0
- package/dist/services/authup/module.d.ts +7 -0
- package/dist/services/authup/module.d.ts.map +1 -0
- package/dist/services/authup/singleton.d.ts +6 -0
- package/dist/services/authup/singleton.d.ts.map +1 -0
- package/dist/services/index.d.ts +6 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/logger/index.d.ts +4 -0
- package/dist/services/logger/index.d.ts.map +1 -0
- package/dist/services/logger/module.d.ts +4 -0
- package/dist/services/logger/module.d.ts.map +1 -0
- package/dist/services/logger/singleton.d.ts +7 -0
- package/dist/services/logger/singleton.d.ts.map +1 -0
- package/dist/services/logger/types.d.ts +8 -0
- package/dist/services/logger/types.d.ts.map +1 -0
- package/dist/services/redis/helpers.d.ts +3 -0
- package/dist/services/redis/helpers.d.ts.map +1 -0
- package/dist/services/redis/index.d.ts +6 -0
- package/dist/services/redis/index.d.ts.map +1 -0
- package/dist/services/redis/module.d.ts +3 -0
- package/dist/services/redis/module.d.ts.map +1 -0
- package/dist/services/redis/singleton-publish.d.ts +3 -0
- package/dist/services/redis/singleton-publish.d.ts.map +1 -0
- package/dist/services/redis/singleton-subscribe.d.ts +3 -0
- package/dist/services/redis/singleton-subscribe.d.ts.map +1 -0
- package/dist/services/redis/singleton.d.ts +7 -0
- package/dist/services/redis/singleton.d.ts.map +1 -0
- package/dist/services/vault/index.d.ts +3 -0
- package/dist/services/vault/index.d.ts.map +1 -0
- package/dist/services/vault/module.d.ts +3 -0
- package/dist/services/vault/module.d.ts.map +1 -0
- package/dist/services/vault/singleton.d.ts +6 -0
- package/dist/services/vault/singleton.d.ts.map +1 -0
- package/dist/type.d.ts +2 -0
- package/dist/type.d.ts.map +1 -0
- package/dist/utils/has-property.d.ts +2 -0
- package/dist/utils/has-property.d.ts.map +1 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/package.json +54 -0
- package/rollup.config.mjs +14 -0
- package/src/core/aggregator/index.ts +8 -0
- package/src/core/aggregator/type.ts +10 -0
- package/src/core/component/error.ts +18 -0
- package/src/core/component/helper.ts +28 -0
- package/src/core/component/index.ts +10 -0
- package/src/core/component/type.ts +32 -0
- package/src/core/index.ts +11 -0
- package/src/core/queue/index.ts +9 -0
- package/src/core/queue/type.ts +23 -0
- package/src/core/queue/utils.ts +17 -0
- package/src/core/queue-router/constants.ts +11 -0
- package/src/core/queue-router/helpers.ts +33 -0
- package/src/core/queue-router/index.ts +12 -0
- package/src/core/queue-router/module.ts +111 -0
- package/src/core/queue-router/singleton.ts +27 -0
- package/src/core/queue-router/types.ts +58 -0
- package/src/domain-event/index.ts +11 -0
- package/src/domain-event/publish.ts +21 -0
- package/src/domain-event/redis/index.ts +8 -0
- package/src/domain-event/redis/publish.ts +41 -0
- package/src/domain-event/socket/index.ts +8 -0
- package/src/domain-event/socket/publish.ts +57 -0
- package/src/domain-event/type.ts +14 -0
- package/src/domain-event/utils.ts +34 -0
- package/src/index.ts +12 -0
- package/src/services/amqp/index.ts +8 -0
- package/src/services/amqp/module.ts +26 -0
- package/src/services/authup/helpers.ts +28 -0
- package/src/services/authup/index.ts +10 -0
- package/src/services/authup/module.ts +28 -0
- package/src/services/authup/singleton.ts +26 -0
- package/src/services/index.ts +12 -0
- package/src/services/logger/index.ts +10 -0
- package/src/services/logger/module.ts +56 -0
- package/src/services/logger/singleton.ts +29 -0
- package/src/services/logger/types.ts +19 -0
- package/src/services/redis/helpers.ts +12 -0
- package/src/services/redis/index.ts +12 -0
- package/src/services/redis/module.ts +22 -0
- package/src/services/redis/singleton-publish.ts +19 -0
- package/src/services/redis/singleton-subscribe.ts +19 -0
- package/src/services/redis/singleton.ts +30 -0
- package/src/services/vault/index.ts +9 -0
- package/src/services/vault/module.ts +13 -0
- package/src/services/vault/singleton.ts +26 -0
- package/src/type.ts +8 -0
- package/src/utils/has-property.ts +13 -0
- package/src/utils/index.ts +8 -0
- package/tsconfig.build.json +11 -0
- package/tsconfig.json +9 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,422 @@
|
|
|
1
|
+
import { isObject, hasOwnProperty as hasOwnProperty$1, createNanoID } from '@privateaim/kit';
|
|
2
|
+
import { ExchangeType } from 'amqp-extension';
|
|
3
|
+
import { singa } from 'singa';
|
|
4
|
+
export { VaultClient, createClient as createVaultClient } from '@hapic/vault';
|
|
5
|
+
import { Client, mountClientResponseErrorTokenHook } from '@authup/core-http-kit';
|
|
6
|
+
export { mountClientResponseErrorTokenHook as mountAuthupClientResponseErrorTokenHook } from '@authup/core-http-kit';
|
|
7
|
+
import { read } from 'envix';
|
|
8
|
+
import path from 'node:path';
|
|
9
|
+
import { EnvironmentName } from 'typeorm-extension';
|
|
10
|
+
import { transports, createLogger as createLogger$1, format } from 'winston';
|
|
11
|
+
export { Cache as RedisCache, Client as RedisClient, ClientOptions as RedisClientOptions, KeyPathID as RedisKeyPathID, buildKeyPath as buildRedisKeyPath, createClient as createRedisClient } from 'redis-extension';
|
|
12
|
+
import { DomainEventName, buildDomainEventFullName } from '@privateaim/core-kit';
|
|
13
|
+
import { Emitter } from '@socket.io/redis-emitter';
|
|
14
|
+
|
|
15
|
+
/*
|
|
16
|
+
* Copyright (c) 2023-2024.
|
|
17
|
+
* Author Peter Placzek (tada5hi)
|
|
18
|
+
* For the full copyright and license information,
|
|
19
|
+
* view the LICENSE file that was distributed with this source code.
|
|
20
|
+
*/ function _define_property$1(obj, key, value) {
|
|
21
|
+
if (key in obj) {
|
|
22
|
+
Object.defineProperty(obj, key, {
|
|
23
|
+
value: value,
|
|
24
|
+
enumerable: true,
|
|
25
|
+
configurable: true,
|
|
26
|
+
writable: true
|
|
27
|
+
});
|
|
28
|
+
} else {
|
|
29
|
+
obj[key] = value;
|
|
30
|
+
}
|
|
31
|
+
return obj;
|
|
32
|
+
}
|
|
33
|
+
class ComponentError extends Error {
|
|
34
|
+
constructor(input){
|
|
35
|
+
super(input.message, {
|
|
36
|
+
cause: input.cause
|
|
37
|
+
});
|
|
38
|
+
_define_property$1(this, "code", void 0);
|
|
39
|
+
this.code = input.code;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function isComponentError(input) {
|
|
44
|
+
if (!isObject(input)) {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
if (typeof input.message !== 'undefined' && typeof input.message !== 'string') {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
if (typeof input.code === 'undefined') {
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
return typeof input.code === 'string' || input.code === null;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function isQueuePayload(input) {
|
|
57
|
+
return isObject(input) && hasOwnProperty$1(input, 'data') && isObject(input.data) && hasOwnProperty$1(input, 'metadata') && isObject(input.metadata);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/*
|
|
61
|
+
* Copyright (c) 2024.
|
|
62
|
+
* Author Peter Placzek (tada5hi)
|
|
63
|
+
* For the full copyright and license information,
|
|
64
|
+
* view the LICENSE file that was distributed with this source code.
|
|
65
|
+
*/ var QueueRouterRoutingType;
|
|
66
|
+
(function(QueueRouterRoutingType) {
|
|
67
|
+
QueueRouterRoutingType["WORK"] = "work";
|
|
68
|
+
QueueRouterRoutingType["PUB_SUB"] = "pubSub";
|
|
69
|
+
})(QueueRouterRoutingType || (QueueRouterRoutingType = {}));
|
|
70
|
+
|
|
71
|
+
function buildQueueRouterPublishPayload(input) {
|
|
72
|
+
return {
|
|
73
|
+
id: input.id || createNanoID(),
|
|
74
|
+
type: input.type,
|
|
75
|
+
data: input.data || {},
|
|
76
|
+
metadata: {
|
|
77
|
+
timestamp: Date.now(),
|
|
78
|
+
...input.metadata
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
function isQueueRouterPayload(input) {
|
|
83
|
+
return isObject(input) && typeof input.id === 'string' && typeof input.type === 'string' && hasOwnProperty$1(input, 'data') && isObject(input.data) && hasOwnProperty$1(input, 'metadata') && isObject(input.metadata);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const instance$7 = singa({
|
|
87
|
+
name: 'amqp'
|
|
88
|
+
});
|
|
89
|
+
function setAmqpClientFactory(factory) {
|
|
90
|
+
instance$7.setFactory(factory);
|
|
91
|
+
}
|
|
92
|
+
function isAmqpClientUsable() {
|
|
93
|
+
return instance$7.has() || instance$7.hasFactory();
|
|
94
|
+
}
|
|
95
|
+
function useAmqpClient() {
|
|
96
|
+
return instance$7.use();
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const instance$6 = singa({
|
|
100
|
+
name: 'vault'
|
|
101
|
+
});
|
|
102
|
+
function setVaultFactory(factory) {
|
|
103
|
+
instance$6.setFactory(factory);
|
|
104
|
+
}
|
|
105
|
+
function isVaultClientUsable() {
|
|
106
|
+
return instance$6.has() || instance$6.hasFactory();
|
|
107
|
+
}
|
|
108
|
+
function useVaultClient() {
|
|
109
|
+
return instance$6.use();
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function guessAuthupTokenCreatorOptions() {
|
|
113
|
+
let options;
|
|
114
|
+
if (isVaultClientUsable()) {
|
|
115
|
+
options = {
|
|
116
|
+
type: 'robotInVault',
|
|
117
|
+
name: 'system',
|
|
118
|
+
vault: useVaultClient()
|
|
119
|
+
};
|
|
120
|
+
} else {
|
|
121
|
+
options = {
|
|
122
|
+
type: 'user',
|
|
123
|
+
name: 'admin',
|
|
124
|
+
password: 'start123'
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
return options;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
class AuthupClient extends Client {
|
|
131
|
+
constructor(options = {}){
|
|
132
|
+
super(options);
|
|
133
|
+
mountClientResponseErrorTokenHook(this, {
|
|
134
|
+
baseURL: options.baseURL,
|
|
135
|
+
tokenCreator: guessAuthupTokenCreatorOptions()
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const instance$5 = singa({
|
|
141
|
+
name: 'authup'
|
|
142
|
+
});
|
|
143
|
+
function useAuthupClient() {
|
|
144
|
+
return instance$5.use();
|
|
145
|
+
}
|
|
146
|
+
function isAuthupClientUsable() {
|
|
147
|
+
return instance$5.has() || instance$5.hasFactory();
|
|
148
|
+
}
|
|
149
|
+
function setAuthupClientFactory(factory) {
|
|
150
|
+
instance$5.setFactory(factory);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function createLogger(ctx = {}) {
|
|
154
|
+
const { directory, options = {} } = ctx;
|
|
155
|
+
let loggerTransports;
|
|
156
|
+
if (read('env') === EnvironmentName.PRODUCTION) {
|
|
157
|
+
loggerTransports = [
|
|
158
|
+
new transports.Console({
|
|
159
|
+
level: 'info'
|
|
160
|
+
}),
|
|
161
|
+
new transports.File({
|
|
162
|
+
filename: path.join(directory || process.cwd(), 'access.log'),
|
|
163
|
+
level: 'http',
|
|
164
|
+
maxsize: 10 * 1024 * 1024,
|
|
165
|
+
maxFiles: 5
|
|
166
|
+
}),
|
|
167
|
+
new transports.File({
|
|
168
|
+
filename: path.join(directory || process.cwd(), 'error.log'),
|
|
169
|
+
level: 'warn',
|
|
170
|
+
maxsize: 10 * 1024 * 1024,
|
|
171
|
+
maxFiles: 5
|
|
172
|
+
})
|
|
173
|
+
];
|
|
174
|
+
} else {
|
|
175
|
+
loggerTransports = [
|
|
176
|
+
new transports.Console({
|
|
177
|
+
level: 'debug'
|
|
178
|
+
})
|
|
179
|
+
];
|
|
180
|
+
}
|
|
181
|
+
return createLogger$1({
|
|
182
|
+
format: format.combine(format.timestamp(), format.colorize(), format.simple()),
|
|
183
|
+
level: 'debug',
|
|
184
|
+
transports: loggerTransports,
|
|
185
|
+
// todo: deeply merge options
|
|
186
|
+
...options || {}
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const instance$4 = singa({
|
|
191
|
+
name: 'logger'
|
|
192
|
+
});
|
|
193
|
+
function setLoggerFactory(factory) {
|
|
194
|
+
instance$4.setFactory(factory);
|
|
195
|
+
}
|
|
196
|
+
function isLoggerUsable() {
|
|
197
|
+
return instance$4.has() || instance$4.hasFactory();
|
|
198
|
+
}
|
|
199
|
+
function setLogger(input) {
|
|
200
|
+
instance$4.set(input);
|
|
201
|
+
}
|
|
202
|
+
function useLogger() {
|
|
203
|
+
return instance$4.use();
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
const instance$3 = singa({
|
|
207
|
+
name: 'redis'
|
|
208
|
+
});
|
|
209
|
+
function setRedisFactory(factory) {
|
|
210
|
+
instance$3.setFactory(factory);
|
|
211
|
+
}
|
|
212
|
+
function isRedisClientUsable() {
|
|
213
|
+
return instance$3.has() || instance$3.hasFactory();
|
|
214
|
+
}
|
|
215
|
+
function setRedisClient(input) {
|
|
216
|
+
instance$3.set(input);
|
|
217
|
+
}
|
|
218
|
+
function useRedisClient() {
|
|
219
|
+
return instance$3.use();
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
const instance$2 = singa({
|
|
223
|
+
name: 'redisPublish',
|
|
224
|
+
factory: ()=>useRedisClient().duplicate()
|
|
225
|
+
});
|
|
226
|
+
function useRedisPublishClient() {
|
|
227
|
+
return instance$2.use();
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
const instance$1 = singa({
|
|
231
|
+
name: 'redisSubscribe',
|
|
232
|
+
factory: ()=>useRedisClient().duplicate()
|
|
233
|
+
});
|
|
234
|
+
function useRedisSubscribeClient() {
|
|
235
|
+
return instance$1.use();
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/*
|
|
239
|
+
* Copyright (c) 2024.
|
|
240
|
+
* Author Peter Placzek (tada5hi)
|
|
241
|
+
* For the full copyright and license information,
|
|
242
|
+
* view the LICENSE file that was distributed with this source code.
|
|
243
|
+
*/ function _define_property(obj, key, value) {
|
|
244
|
+
if (key in obj) {
|
|
245
|
+
Object.defineProperty(obj, key, {
|
|
246
|
+
value: value,
|
|
247
|
+
enumerable: true,
|
|
248
|
+
configurable: true,
|
|
249
|
+
writable: true
|
|
250
|
+
});
|
|
251
|
+
} else {
|
|
252
|
+
obj[key] = value;
|
|
253
|
+
}
|
|
254
|
+
return obj;
|
|
255
|
+
}
|
|
256
|
+
class QueueRouter {
|
|
257
|
+
//----------------------------------------------------------------
|
|
258
|
+
publish(message) {
|
|
259
|
+
let exchange;
|
|
260
|
+
if (message.metadata.routing.type === 'work') {
|
|
261
|
+
exchange = this.driver.of({
|
|
262
|
+
type: ExchangeType.DIRECT,
|
|
263
|
+
name: message.metadata.routing.namespace || ''
|
|
264
|
+
});
|
|
265
|
+
} else {
|
|
266
|
+
exchange = this.driver.of({
|
|
267
|
+
type: ExchangeType.TOPIC,
|
|
268
|
+
name: message.metadata.routing.namespace || 'FLAME'
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
if (isLoggerUsable()) {
|
|
272
|
+
useLogger().debug(`Publishing queue message ${message.type} in ${message.metadata.routing.key}`);
|
|
273
|
+
}
|
|
274
|
+
return exchange.publish(message.metadata.routing.key, message, {
|
|
275
|
+
type: message.type,
|
|
276
|
+
messageId: message.id,
|
|
277
|
+
persistent: message.metadata.persistent ?? message.metadata.routing.type === QueueRouterRoutingType.WORK
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
consume(routing, handlers) {
|
|
281
|
+
let exchange;
|
|
282
|
+
if (routing.type === 'work') {
|
|
283
|
+
exchange = this.driver.of({
|
|
284
|
+
type: ExchangeType.DIRECT,
|
|
285
|
+
name: routing.namespace || ''
|
|
286
|
+
});
|
|
287
|
+
} else {
|
|
288
|
+
exchange = this.driver.of({
|
|
289
|
+
type: ExchangeType.TOPIC,
|
|
290
|
+
name: routing.namespace || 'FLAME'
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
return exchange.consume(routing.key, {
|
|
294
|
+
prefetchCount: routing.type === QueueRouterRoutingType.WORK ? 1 : undefined,
|
|
295
|
+
// noAck: routing.type !== QueueRouterRoutingType.WORK,
|
|
296
|
+
requeueOnFailure: routing.type === QueueRouterRoutingType.WORK
|
|
297
|
+
}, {
|
|
298
|
+
$any: async (input)=>{
|
|
299
|
+
const payload = JSON.parse(input.content.toString('utf-8'));
|
|
300
|
+
if (!isQueueRouterPayload(payload)) {
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
if (isLoggerUsable()) {
|
|
304
|
+
useLogger().debug(`Consuming queue message ${input.properties.type} in ${routing.key}`);
|
|
305
|
+
}
|
|
306
|
+
let handler;
|
|
307
|
+
if (typeof input.properties.type === 'string' && handlers[input.properties.type]) {
|
|
308
|
+
handler = handlers[input.properties.type];
|
|
309
|
+
} else {
|
|
310
|
+
handler = handlers.$any;
|
|
311
|
+
}
|
|
312
|
+
if (typeof handler !== 'function') {
|
|
313
|
+
if (isLoggerUsable()) {
|
|
314
|
+
useLogger().debug(`No queue handler to consume message ${input.properties.type} in ${routing.key}`);
|
|
315
|
+
}
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
await handler(payload);
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
//----------------------------------------------------------------
|
|
323
|
+
constructor(driver){
|
|
324
|
+
_define_property(this, "driver", void 0);
|
|
325
|
+
this.driver = driver;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
const instance = singa({
|
|
330
|
+
name: 'queueRouter',
|
|
331
|
+
factory: ()=>{
|
|
332
|
+
const amqp = useAmqpClient();
|
|
333
|
+
return new QueueRouter(amqp);
|
|
334
|
+
}
|
|
335
|
+
});
|
|
336
|
+
function isQueueRouterUsable() {
|
|
337
|
+
return instance.has() || isAmqpClientUsable();
|
|
338
|
+
}
|
|
339
|
+
function useQueueRouter() {
|
|
340
|
+
return instance.use();
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
function transformDomainEventData(input) {
|
|
344
|
+
if (isObject(input)) {
|
|
345
|
+
const keys = Object.keys(input);
|
|
346
|
+
for(let i = 0; i < keys.length; i++){
|
|
347
|
+
const value = input[keys[i]];
|
|
348
|
+
if (value instanceof Date) {
|
|
349
|
+
input[keys[i]] = value.toISOString();
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
return input;
|
|
354
|
+
}
|
|
355
|
+
function buildDomainEventChannelName(input, id) {
|
|
356
|
+
if (typeof input === 'string') {
|
|
357
|
+
return input;
|
|
358
|
+
}
|
|
359
|
+
return input(id);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
async function publishDomainRedisEvent(client, context, destinations) {
|
|
363
|
+
context = transformDomainEventData(context);
|
|
364
|
+
const json = JSON.stringify(context);
|
|
365
|
+
const pipeline = client.pipeline();
|
|
366
|
+
for(let i = 0; i < destinations.length; i++){
|
|
367
|
+
const { namespace } = destinations[i];
|
|
368
|
+
const keyPrefix = namespace ? `${namespace}:` : '';
|
|
369
|
+
let key = keyPrefix + buildDomainEventChannelName(destinations[i].channel);
|
|
370
|
+
pipeline.publish(key, json);
|
|
371
|
+
if (context.event !== DomainEventName.CREATED && typeof destinations[i].channel === 'function') {
|
|
372
|
+
key = keyPrefix + buildDomainEventChannelName(destinations[i].channel, context.data.id);
|
|
373
|
+
pipeline.publish(key, json);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
return pipeline.exec();
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
function publishDomainSocketEvent(client, context, destinations) {
|
|
380
|
+
context = transformDomainEventData(context);
|
|
381
|
+
for(let i = 0; i < destinations.length; i++){
|
|
382
|
+
let emitter = new Emitter(client);
|
|
383
|
+
if (destinations[i].namespace) {
|
|
384
|
+
emitter = emitter.of(destinations[i].namespace);
|
|
385
|
+
}
|
|
386
|
+
let roomName = buildDomainEventChannelName(destinations[i].channel);
|
|
387
|
+
const fullEventName = buildDomainEventFullName(context.type, context.event);
|
|
388
|
+
emitter.in(roomName).emit(fullEventName, {
|
|
389
|
+
...context,
|
|
390
|
+
meta: {
|
|
391
|
+
roomName
|
|
392
|
+
}
|
|
393
|
+
});
|
|
394
|
+
if (context.event !== DomainEventName.CREATED && typeof destinations[i].channel === 'function') {
|
|
395
|
+
roomName = buildDomainEventChannelName(destinations[i].channel, context.data.id);
|
|
396
|
+
emitter.in(roomName).emit(fullEventName, {
|
|
397
|
+
...context,
|
|
398
|
+
meta: {
|
|
399
|
+
roomName,
|
|
400
|
+
roomId: context.data.id
|
|
401
|
+
}
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
async function publishDomainEvent(client, context, destinations) {
|
|
408
|
+
await publishDomainRedisEvent(client, context, destinations);
|
|
409
|
+
publishDomainSocketEvent(client, context, destinations);
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
/*
|
|
413
|
+
* Copyright (c) 2022-2024.
|
|
414
|
+
* Author Peter Placzek (tada5hi)
|
|
415
|
+
* For the full copyright and license information,
|
|
416
|
+
* view the LICENSE file that was distributed with this source code.
|
|
417
|
+
*/ function hasOwnProperty(obj, prop) {
|
|
418
|
+
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
export { AuthupClient, ComponentError, QueueRouter, QueueRouterRoutingType, buildQueueRouterPublishPayload, createLogger, guessAuthupTokenCreatorOptions, hasOwnProperty, isAmqpClientUsable, isAuthupClientUsable, isComponentError, isLoggerUsable, isQueuePayload, isQueueRouterPayload, isQueueRouterUsable, isRedisClientUsable, isVaultClientUsable, publishDomainEvent, publishDomainRedisEvent, publishDomainSocketEvent, setAmqpClientFactory, setAuthupClientFactory, setLogger, setLoggerFactory, setRedisClient, setRedisFactory, setVaultFactory, useAmqpClient, useAuthupClient, useLogger, useQueueRouter, useRedisClient, useRedisPublishClient, useRedisSubscribeClient, useVaultClient };
|
|
422
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../src/core/component/error.ts","../src/core/component/helper.ts","../src/core/queue/utils.ts","../src/core/queue-router/constants.ts","../src/core/queue-router/helpers.ts","../src/services/amqp/module.ts","../src/services/vault/singleton.ts","../src/services/authup/helpers.ts","../src/services/authup/module.ts","../src/services/authup/singleton.ts","../src/services/logger/module.ts","../src/services/logger/singleton.ts","../src/services/redis/singleton.ts","../src/services/redis/singleton-publish.ts","../src/services/redis/singleton-subscribe.ts","../src/core/queue-router/module.ts","../src/core/queue-router/singleton.ts","../src/domain-event/utils.ts","../src/domain-event/redis/publish.ts","../src/domain-event/socket/publish.ts","../src/domain-event/publish.ts","../src/utils/has-property.ts"],"sourcesContent":["/*\n * Copyright (c) 2023-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { ComponentErrorOptions } from './type';\n\nexport class ComponentError extends Error {\n public code?: string | null;\n\n constructor(input: ComponentErrorOptions) {\n super(input.message, { cause: input.cause });\n\n this.code = input.code;\n }\n}\n","/*\n * Copyright (c) 2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { isObject } from '@privateaim/kit';\nimport type { ComponentError } from './error';\n\nexport function isComponentError(input: unknown) : input is ComponentError {\n if (!isObject(input)) {\n return false;\n }\n\n if (\n typeof input.message !== 'undefined' &&\n typeof input.message !== 'string'\n ) {\n return false;\n }\n\n if (typeof input.code === 'undefined') {\n return true;\n }\n\n return typeof input.code === 'string' || input.code === null;\n}\n","/*\n * Copyright (c) 2023-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { hasOwnProperty, isObject } from '@privateaim/kit';\nimport type { QueuePayload } from './type';\n\nexport function isQueuePayload(input: unknown) : input is QueuePayload {\n return isObject(input) &&\n hasOwnProperty(input, 'data') &&\n isObject(input.data) &&\n hasOwnProperty(input, 'metadata') &&\n isObject(input.metadata);\n}\n","/*\n * Copyright (c) 2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport enum QueueRouterRoutingType {\n WORK = 'work',\n PUB_SUB = 'pubSub',\n}\n","/*\n * Copyright (c) 2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { createNanoID, hasOwnProperty, isObject } from '@privateaim/kit';\nimport type { QueueRouterPayload, QueueRouterPayloadInput } from './types';\n\nexport function buildQueueRouterPublishPayload(\n input: QueueRouterPayloadInput,\n) : QueueRouterPayload {\n return {\n id: input.id || createNanoID(),\n type: input.type,\n data: input.data || {},\n metadata: {\n timestamp: Date.now(),\n ...input.metadata,\n },\n };\n}\n\nexport function isQueueRouterPayload(input: unknown) : input is QueueRouterPayload {\n return isObject(input) &&\n typeof input.id === 'string' &&\n typeof input.type === 'string' &&\n hasOwnProperty(input, 'data') &&\n isObject(input.data) &&\n hasOwnProperty(input, 'metadata') &&\n isObject(input.metadata);\n}\n","/*\n * Copyright (c) 2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { Client } from 'amqp-extension';\nimport type { Factory } from 'singa';\nimport { singa } from 'singa';\n\nconst instance = singa<Client>({\n name: 'amqp',\n});\n\nexport function setAmqpClientFactory(factory: Factory<Client>) {\n instance.setFactory(factory);\n}\n\nexport function isAmqpClientUsable() {\n return instance.has() || instance.hasFactory();\n}\n\nexport function useAmqpClient() {\n return instance.use();\n}\n","/*\n * Copyright (c) 2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { Factory } from 'singa';\nimport { singa } from 'singa';\nimport type { VaultClient } from '@hapic/vault';\n\nconst instance = singa<VaultClient>({\n name: 'vault',\n});\n\nexport function setVaultFactory(factory: Factory<VaultClient>) {\n instance.setFactory(factory);\n}\n\nexport function isVaultClientUsable() {\n return instance.has() || instance.hasFactory();\n}\n\nexport function useVaultClient() {\n return instance.use();\n}\n","/*\n * Copyright (c) 2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { TokenCreatorOptions } from '@authup/core-http-kit';\nimport { isVaultClientUsable, useVaultClient } from '../vault';\n\nexport function guessAuthupTokenCreatorOptions() : TokenCreatorOptions {\n let options : TokenCreatorOptions;\n if (isVaultClientUsable()) {\n options = {\n type: 'robotInVault',\n name: 'system',\n vault: useVaultClient(),\n };\n } else {\n options = {\n type: 'user',\n name: 'admin',\n password: 'start123',\n };\n }\n\n return options;\n}\n","/*\n * Copyright (c) 2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { ClientOptions } from '@authup/core-http-kit';\nimport {\n Client, mountClientResponseErrorTokenHook as mountAuthupClientResponseErrorTokenHook,\n mountClientResponseErrorTokenHook,\n} from '@authup/core-http-kit';\nimport { guessAuthupTokenCreatorOptions } from './helpers';\n\nexport {\n mountAuthupClientResponseErrorTokenHook,\n};\n\nexport class AuthupClient extends Client {\n constructor(options: ClientOptions = {}) {\n super(options);\n\n mountClientResponseErrorTokenHook(this, {\n baseURL: options.baseURL,\n tokenCreator: guessAuthupTokenCreatorOptions(),\n });\n }\n}\n","/*\n * Copyright (c) 2023-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { Client } from '@authup/core-http-kit';\nimport type { Factory } from 'singa';\nimport { singa } from 'singa';\n\nconst instance = singa<Client>({\n name: 'authup',\n});\n\nexport function useAuthupClient() {\n return instance.use();\n}\n\nexport function isAuthupClientUsable() {\n return instance.has() || instance.hasFactory();\n}\n\nexport function setAuthupClientFactory(factory: Factory<Client>) {\n instance.setFactory(factory);\n}\n","/*\n * Copyright (c) 2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { read } from 'envix';\nimport path from 'node:path';\nimport { EnvironmentName } from 'typeorm-extension';\nimport type { Logger } from 'winston';\nimport { createLogger as create, format, transports } from 'winston';\nimport type { LoggerCreateContext, LoggerTransports } from './types';\n\nexport function createLogger(ctx: LoggerCreateContext = {}) : Logger {\n const { directory, options = {} } = ctx;\n\n let loggerTransports : LoggerTransports;\n if (read('env') === EnvironmentName.PRODUCTION) {\n loggerTransports = [\n new transports.Console({\n level: 'info',\n }),\n new transports.File({\n filename: path.join(directory || process.cwd(), 'access.log'),\n level: 'http',\n maxsize: 10 * 1024 * 1024, // 10MB\n maxFiles: 5,\n }),\n new transports.File({\n filename: path.join(directory || process.cwd(), 'error.log'),\n level: 'warn',\n maxsize: 10 * 1024 * 1024, // 10MB\n maxFiles: 5,\n }),\n ];\n } else {\n loggerTransports = [\n new transports.Console({\n level: 'debug',\n }),\n ];\n }\n\n return create({\n format: format.combine(\n format.timestamp(),\n format.colorize(),\n format.simple(),\n ),\n level: 'debug',\n transports: loggerTransports,\n // todo: deeply merge options\n ...(options || {}),\n });\n}\n","/*\n * Copyright (c) 2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { type Factory, singa } from 'singa';\nimport type { Logger } from 'winston';\n\nconst instance = singa<Logger>({\n name: 'logger',\n});\n\nexport function setLoggerFactory(factory: Factory<Logger>) {\n instance.setFactory(factory);\n}\n\nexport function isLoggerUsable() {\n return instance.has() || instance.hasFactory();\n}\n\nexport function setLogger(input: Logger) {\n instance.set(input);\n}\n\nexport function useLogger() {\n return instance.use();\n}\n","/*\n * Copyright (c) 2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { Client } from 'redis-extension';\nimport type { Factory } from 'singa';\nimport { singa } from 'singa';\n\nconst instance = singa<Client>({\n name: 'redis',\n});\n\nexport function setRedisFactory(factory: Factory<Client>) {\n instance.setFactory(factory);\n}\n\nexport function isRedisClientUsable() {\n return instance.has() || instance.hasFactory();\n}\n\nexport function setRedisClient(input: Client) {\n instance.set(input);\n}\n\nexport function useRedisClient() {\n return instance.use();\n}\n","/*\n * Copyright (c) 2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { Client } from 'redis-extension';\nimport { singa } from 'singa';\nimport { useRedisClient } from './singleton';\n\nconst instance = singa<Client>({\n name: 'redisPublish',\n factory: () => useRedisClient().duplicate(),\n});\n\nexport function useRedisPublishClient() {\n return instance.use();\n}\n","/*\n * Copyright (c) 2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { Client } from 'redis-extension';\nimport { singa } from 'singa';\nimport { useRedisClient } from './singleton';\n\nconst instance = singa<Client>({\n name: 'redisSubscribe',\n factory: () => useRedisClient().duplicate(),\n});\n\nexport function useRedisSubscribeClient() {\n return instance.use();\n}\n","/*\n * Copyright (c) 2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { ExchangeType } from 'amqp-extension';\nimport type { Client } from 'amqp-extension';\nimport { isLoggerUsable, useLogger } from '../../services';\nimport { QueueRouterRoutingType } from './constants';\nimport { isQueueRouterPayload } from './helpers';\nimport type {\n QueueRouterHandler,\n QueueRouterHandlers,\n QueueRouterPayload, QueueRouterRouting,\n} from './types';\n\nexport class QueueRouter {\n protected driver : Client;\n\n //----------------------------------------------------------------\n\n constructor(driver: Client) {\n this.driver = driver;\n }\n\n //----------------------------------------------------------------\n\n publish(message: QueueRouterPayload) : Promise<boolean> {\n let exchange : Client;\n if (message.metadata.routing.type === 'work') {\n exchange = this.driver.of({\n type: ExchangeType.DIRECT,\n name: message.metadata.routing.namespace || '',\n });\n } else {\n exchange = this.driver.of({\n type: ExchangeType.TOPIC,\n name: message.metadata.routing.namespace || 'FLAME',\n });\n }\n\n if (isLoggerUsable()) {\n useLogger()\n .debug(`Publishing queue message ${message.type} in ${message.metadata.routing.key}`);\n }\n\n return exchange.publish(message.metadata.routing.key, message, {\n type: message.type,\n messageId: message.id,\n persistent: message.metadata.persistent ??\n message.metadata.routing.type === QueueRouterRoutingType.WORK,\n });\n }\n\n consume(routing: QueueRouterRouting, handlers: QueueRouterHandlers) : Promise<void> {\n let exchange : Client;\n if (routing.type === 'work') {\n exchange = this.driver.of({\n type: ExchangeType.DIRECT,\n name: routing.namespace || '',\n });\n } else {\n exchange = this.driver.of({\n type: ExchangeType.TOPIC,\n name: routing.namespace || 'FLAME',\n });\n }\n\n return exchange.consume(routing.key, {\n prefetchCount: routing.type === QueueRouterRoutingType.WORK ? 1 : undefined,\n // noAck: routing.type !== QueueRouterRoutingType.WORK,\n requeueOnFailure: routing.type === QueueRouterRoutingType.WORK,\n }, {\n $any: async (input) => {\n const payload = JSON.parse(input.content.toString('utf-8'));\n if (!isQueueRouterPayload(payload)) {\n return;\n }\n\n if (isLoggerUsable()) {\n useLogger()\n .debug(`Consuming queue message ${input.properties.type} in ${routing.key}`);\n }\n\n let handler : QueueRouterHandler | undefined;\n\n if (\n typeof input.properties.type === 'string' &&\n handlers[input.properties.type]\n ) {\n handler = handlers[input.properties.type];\n } else {\n handler = handlers.$any;\n }\n\n if (typeof handler !== 'function') {\n if (isLoggerUsable()) {\n useLogger()\n .debug(`No queue handler to consume message ${input.properties.type} in ${routing.key}`);\n }\n\n return;\n }\n\n await handler(payload);\n },\n });\n }\n}\n","/*\n * Copyright (c) 2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { singa } from 'singa';\nimport { isAmqpClientUsable, useAmqpClient } from '../../services';\nimport { QueueRouter } from './module';\n\nconst instance = singa<QueueRouter>({\n name: 'queueRouter',\n factory: () => {\n const amqp = useAmqpClient();\n\n return new QueueRouter(amqp);\n },\n});\n\nexport function isQueueRouterUsable() {\n return instance.has() || isAmqpClientUsable();\n}\n\nexport function useQueueRouter() {\n return instance.use();\n}\n","/*\n * Copyright (c) 2023-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { isObject } from '@privateaim/kit';\nimport type { DomainEventChannelName } from './type';\n\nexport function transformDomainEventData<T>(input: T) : T {\n if (isObject(input)) {\n const keys = Object.keys(input);\n for (let i = 0; i < keys.length; i++) {\n const value = input[keys[i]];\n if (value instanceof Date) {\n input[keys[i]] = value.toISOString();\n }\n }\n }\n\n return input;\n}\n\nexport function buildDomainEventChannelName(\n input: DomainEventChannelName,\n id?: string | number,\n) : string {\n if (typeof input === 'string') {\n return input;\n }\n\n return input(id);\n}\n","/*\n * Copyright (c) 2023-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { DomainEventName } from '@privateaim/core-kit';\nimport type { DomainsEventContext } from '@privateaim/core-kit';\nimport type { Client } from 'redis-extension';\nimport type { DomainEventDestinations } from '../type';\nimport { buildDomainEventChannelName, transformDomainEventData } from '../utils';\n\nexport async function publishDomainRedisEvent(\n client: Client,\n context: DomainsEventContext,\n destinations: DomainEventDestinations,\n) : Promise<any> {\n context = transformDomainEventData(context);\n\n const json = JSON.stringify(context);\n\n const pipeline = client.pipeline();\n for (let i = 0; i < destinations.length; i++) {\n const { namespace } = destinations[i];\n const keyPrefix = (namespace ? `${namespace}:` : '');\n\n let key = keyPrefix + buildDomainEventChannelName(destinations[i].channel);\n pipeline.publish(key, json);\n\n if (\n context.event !== DomainEventName.CREATED &&\n typeof destinations[i].channel === 'function'\n ) {\n key = keyPrefix + buildDomainEventChannelName(destinations[i].channel, context.data.id);\n pipeline.publish(key, json);\n }\n }\n\n return pipeline.exec();\n}\n","/*\n * Copyright (c) 2022-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { DomainsEventContext } from '@privateaim/core-kit';\nimport { DomainEventName, buildDomainEventFullName } from '@privateaim/core-kit';\nimport { Emitter } from '@socket.io/redis-emitter';\nimport type { Client } from 'redis-extension';\nimport type { DomainEventDestinations } from '../type';\nimport { buildDomainEventChannelName, transformDomainEventData } from '../utils';\n\nexport function publishDomainSocketEvent(\n client: Client,\n context: DomainsEventContext,\n destinations: DomainEventDestinations,\n) {\n context = transformDomainEventData(context);\n\n for (let i = 0; i < destinations.length; i++) {\n let emitter = new Emitter(client);\n if (destinations[i].namespace) {\n emitter = emitter.of(destinations[i].namespace);\n }\n\n let roomName = buildDomainEventChannelName(destinations[i].channel);\n\n const fullEventName = buildDomainEventFullName(context.type, context.event);\n\n emitter\n .in(roomName)\n .emit(fullEventName, {\n ...context,\n meta: {\n roomName,\n },\n });\n\n if (\n context.event !== DomainEventName.CREATED &&\n typeof destinations[i].channel === 'function'\n ) {\n roomName = buildDomainEventChannelName(destinations[i].channel, context.data.id);\n emitter\n .in(roomName)\n .emit(fullEventName, {\n ...context,\n meta: {\n roomName,\n roomId: context.data.id,\n },\n });\n }\n }\n}\n","/*\n * Copyright (c) 2023-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { DomainsEventContext } from '@privateaim/core-kit';\nimport type { Client } from 'redis-extension';\nimport { publishDomainRedisEvent } from './redis';\nimport { publishDomainSocketEvent } from './socket';\nimport type { DomainEventDestinations } from './type';\n\nexport async function publishDomainEvent(\n client: Client,\n context: DomainsEventContext,\n destinations: DomainEventDestinations,\n) {\n await publishDomainRedisEvent(client, context, destinations);\n publishDomainSocketEvent(client, context, destinations);\n}\n","/*\n * Copyright (c) 2022-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport function hasOwnProperty<X extends Record<string, any>, Y extends PropertyKey>(\n obj: X,\n prop: Y,\n): obj is X & Record<Y, unknown> {\n return Object.prototype.hasOwnProperty.call(obj, prop);\n}\n"],"names":["_define_property","ComponentError","Error","constructor","input","message","cause","code","isComponentError","isObject","isQueuePayload","hasOwnProperty","data","metadata","QueueRouterRoutingType","buildQueueRouterPublishPayload","id","createNanoID","type","timestamp","Date","now","isQueueRouterPayload","instance","singa","name","setAmqpClientFactory","factory","setFactory","isAmqpClientUsable","has","hasFactory","useAmqpClient","use","setVaultFactory","isVaultClientUsable","useVaultClient","guessAuthupTokenCreatorOptions","options","vault","password","AuthupClient","Client","mountClientResponseErrorTokenHook","baseURL","tokenCreator","useAuthupClient","isAuthupClientUsable","setAuthupClientFactory","createLogger","ctx","directory","loggerTransports","read","EnvironmentName","PRODUCTION","transports","Console","level","File","filename","path","join","process","cwd","maxsize","maxFiles","create","format","combine","colorize","simple","setLoggerFactory","isLoggerUsable","setLogger","set","useLogger","setRedisFactory","isRedisClientUsable","setRedisClient","useRedisClient","duplicate","useRedisPublishClient","useRedisSubscribeClient","QueueRouter","publish","exchange","routing","driver","of","ExchangeType","DIRECT","namespace","TOPIC","debug","key","messageId","persistent","WORK","consume","handlers","prefetchCount","undefined","requeueOnFailure","$any","payload","JSON","parse","content","toString","properties","handler","amqp","isQueueRouterUsable","useQueueRouter","transformDomainEventData","keys","Object","i","length","value","toISOString","buildDomainEventChannelName","publishDomainRedisEvent","client","context","destinations","json","stringify","pipeline","keyPrefix","channel","event","DomainEventName","CREATED","exec","publishDomainSocketEvent","emitter","Emitter","roomName","fullEventName","buildDomainEventFullName","in","emit","meta","roomId","publishDomainEvent","obj","prop","prototype","call"],"mappings":";;;;;;;;;;;;;;AAAA;;;;;AAKC,IAAA,SAAAA,kBAAA,CAAA,GAAA,EAAA,GAAA,EAAA,KAAA,EAAA;;;;;;;;;;;;;AAIM,MAAMC,cAAuBC,SAAAA,KAAAA,CAAAA;AAGhCC,IAAAA,WAAAA,CAAYC,KAA4B,CAAE;QACtC,KAAK,CAACA,KAAMC,CAAAA,OAAO,EAAE;AAAEC,YAAAA,KAAAA,EAAOF,MAAME,KAAK;AAAC,SAAA,CAAA,CAAA;AAH9C,QAAAN,kBAAA,CAAA,IAAA,EAAOO,QAAP,KAAA,CAAA,CAAA,CAAA;AAKI,QAAA,IAAI,CAACA,IAAI,GAAGH,KAAAA,CAAMG,IAAI,CAAA;AAC1B,KAAA;AACJ;;ACPO,SAASC,iBAAiBJ,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B,CAAAA,MAAc,EACdC,OAA4B,EAC5BC,YAAqC,EAAA;IAErC,MAAMH,uBAAAA,CAAwBC,QAAQC,OAASC,EAAAA,YAAAA,CAAAA,CAAAA;AAC/CU,IAAAA,wBAAAA,CAAyBZ,QAAQC,OAASC,EAAAA,YAAAA,CAAAA,CAAAA;AAC9C;;ACpBA;;;;;AAKC,IAEM,SAASnH,cACZwI,CAAAA,GAAM,EACNC,IAAO,EAAA;AAEP,IAAA,OAAO/B,OAAOgC,SAAS,CAAC1I,cAAc,CAAC2I,IAAI,CAACH,GAAKC,EAAAA,IAAAA,CAAAA,CAAAA;AACrD;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/amqp/index.ts"],"names":[],"mappings":"AAOA,cAAc,UAAU,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Client } from 'amqp-extension';
|
|
2
|
+
import type { Factory } from 'singa';
|
|
3
|
+
export declare function setAmqpClientFactory(factory: Factory<Client>): void;
|
|
4
|
+
export declare function isAmqpClientUsable(): boolean;
|
|
5
|
+
export declare function useAmqpClient(): Client;
|
|
6
|
+
//# sourceMappingURL=module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../../src/services/amqp/module.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAOrC,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,QAE5D;AAED,wBAAgB,kBAAkB,YAEjC;AAED,wBAAgB,aAAa,WAE5B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/services/authup/helpers.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAGjE,wBAAgB,8BAA8B,IAAK,mBAAmB,CAiBrE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/authup/index.ts"],"names":[],"mappings":"AAOA,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ClientOptions } from '@authup/core-http-kit';
|
|
2
|
+
import { Client, mountClientResponseErrorTokenHook as mountAuthupClientResponseErrorTokenHook } from '@authup/core-http-kit';
|
|
3
|
+
export { mountAuthupClientResponseErrorTokenHook, };
|
|
4
|
+
export declare class AuthupClient extends Client {
|
|
5
|
+
constructor(options?: ClientOptions);
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../../src/services/authup/module.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EACH,MAAM,EAAE,iCAAiC,IAAI,uCAAuC,EAEvF,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EACH,uCAAuC,GAC1C,CAAC;AAEF,qBAAa,YAAa,SAAQ,MAAM;gBACxB,OAAO,GAAE,aAAkB;CAQ1C"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Client } from '@authup/core-http-kit';
|
|
2
|
+
import type { Factory } from 'singa';
|
|
3
|
+
export declare function useAuthupClient(): Client;
|
|
4
|
+
export declare function isAuthupClientUsable(): boolean;
|
|
5
|
+
export declare function setAuthupClientFactory(factory: Factory<Client>): void;
|
|
6
|
+
//# sourceMappingURL=singleton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"singleton.d.ts","sourceRoot":"","sources":["../../../src/services/authup/singleton.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAOrC,wBAAgB,eAAe,WAE9B;AAED,wBAAgB,oBAAoB,YAEnC;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,QAE9D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAOA,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/logger/index.ts"],"names":[],"mappings":"AAOA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../../src/services/logger/module.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEtC,OAAO,KAAK,EAAE,mBAAmB,EAAoB,MAAM,SAAS,CAAC;AAErE,wBAAgB,YAAY,CAAC,GAAG,GAAE,mBAAwB,GAAI,MAAM,CAyCnE"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type Factory } from 'singa';
|
|
2
|
+
import type { Logger } from 'winston';
|
|
3
|
+
export declare function setLoggerFactory(factory: Factory<Logger>): void;
|
|
4
|
+
export declare function isLoggerUsable(): boolean;
|
|
5
|
+
export declare function setLogger(input: Logger): void;
|
|
6
|
+
export declare function useLogger(): Logger;
|
|
7
|
+
//# sourceMappingURL=singleton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"singleton.d.ts","sourceRoot":"","sources":["../../../src/services/logger/singleton.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,OAAO,EAAS,MAAM,OAAO,CAAC;AAC5C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAMtC,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,QAExD;AAED,wBAAgB,cAAc,YAE7B;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,QAEtC;AAED,wBAAgB,SAAS,WAExB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Logger, LoggerOptions } from 'winston';
|
|
2
|
+
export type LoggerCreateContext = {
|
|
3
|
+
directory?: string;
|
|
4
|
+
options?: Partial<LoggerOptions>;
|
|
5
|
+
};
|
|
6
|
+
export type LoggerTransports = LoggerOptions['transports'];
|
|
7
|
+
export type { Logger, };
|
|
8
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/services/logger/types.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAErD,MAAM,MAAM,mBAAmB,GAAG;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,CAAA;CACnC,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,aAAa,CAAC,YAAY,CAAC,CAAC;AAE3D,YAAY,EACR,MAAM,GACT,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/services/redis/helpers.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,YAAY,IAAI,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEpE,OAAO,EACH,iBAAiB,GACpB,CAAC"}
|