@privateaim/telemetry-kit 0.8.16
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 +30 -0
- package/LICENSE +202 -0
- package/dist/domains/base.d.ts +8 -0
- package/dist/domains/base.d.ts.map +1 -0
- package/dist/domains/constants.d.ts +5 -0
- package/dist/domains/constants.d.ts.map +1 -0
- package/dist/domains/event/api.d.ts +12 -0
- package/dist/domains/event/api.d.ts.map +1 -0
- package/dist/domains/event/entity.d.ts +50 -0
- package/dist/domains/event/entity.d.ts.map +1 -0
- package/dist/domains/event/index.d.ts +4 -0
- package/dist/domains/event/index.d.ts.map +1 -0
- package/dist/domains/event/validator.d.ts +6 -0
- package/dist/domains/event/validator.d.ts.map +1 -0
- package/dist/domains/index.d.ts +5 -0
- package/dist/domains/index.d.ts.map +1 -0
- package/dist/domains/log/api.d.ts +10 -0
- package/dist/domains/log/api.d.ts.map +1 -0
- package/dist/domains/log/constants.d.ts +65 -0
- package/dist/domains/log/constants.d.ts.map +1 -0
- package/dist/domains/log/entity.d.ts +31 -0
- package/dist/domains/log/entity.d.ts.map +1 -0
- package/dist/domains/log/helpers.d.ts +3 -0
- package/dist/domains/log/helpers.d.ts.map +1 -0
- package/dist/domains/log/index.d.ts +6 -0
- package/dist/domains/log/index.d.ts.map +1 -0
- package/dist/domains/log/validator.d.ts +6 -0
- package/dist/domains/log/validator.d.ts.map +1 -0
- package/dist/domains/types-base.d.ts +14 -0
- package/dist/domains/types-base.d.ts.map +1 -0
- package/dist/domains/types.d.ts +12 -0
- package/dist/domains/types.d.ts.map +1 -0
- package/dist/http/api-client/index.d.ts +2 -0
- package/dist/http/api-client/index.d.ts.map +1 -0
- package/dist/http/api-client/module.d.ts +9 -0
- package/dist/http/api-client/module.d.ts.map +1 -0
- package/dist/http/index.d.ts +2 -0
- package/dist/http/index.d.ts.map +1 -0
- package/dist/index.cjs +414 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.mjs +402 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +51 -0
- package/rollup.config.mjs +19 -0
- package/src/domains/base.ts +30 -0
- package/src/domains/constants.ts +11 -0
- package/src/domains/event/api.ts +43 -0
- package/src/domains/event/entity.ts +85 -0
- package/src/domains/event/index.ts +10 -0
- package/src/domains/event/validator.ts +148 -0
- package/src/domains/index.ts +12 -0
- package/src/domains/log/api.ts +29 -0
- package/src/domains/log/constants.ts +84 -0
- package/src/domains/log/entity.ts +44 -0
- package/src/domains/log/helpers.ts +17 -0
- package/src/domains/log/index.ts +12 -0
- package/src/domains/log/validator.ts +79 -0
- package/src/domains/types-base.ts +22 -0
- package/src/domains/types.ts +19 -0
- package/src/http/api-client/index.ts +8 -0
- package/src/http/api-client/module.ts +39 -0
- package/src/http/index.ts +8 -0
- package/src/index.ts +9 -0
- package/tsconfig.build.json +11 -0
- package/tsconfig.json +8 -0
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
import { createClient, isClient, Client, HookName, isClientError } from 'hapic';
|
|
2
|
+
import { buildQuery } from 'rapiq';
|
|
3
|
+
import { createValidator } from '@validup/adapter-zod';
|
|
4
|
+
import { Container } from 'validup';
|
|
5
|
+
import zod from 'zod';
|
|
6
|
+
import { nanoSeconds } from '@privateaim/kit';
|
|
7
|
+
|
|
8
|
+
/*
|
|
9
|
+
* Copyright (c) 2023-2024.
|
|
10
|
+
* Author Peter Placzek (tada5hi)
|
|
11
|
+
* For the full copyright and license information,
|
|
12
|
+
* view the LICENSE file that was distributed with this source code.
|
|
13
|
+
*/ function _define_property$2(obj, key, value) {
|
|
14
|
+
if (key in obj) {
|
|
15
|
+
Object.defineProperty(obj, key, {
|
|
16
|
+
value: value,
|
|
17
|
+
enumerable: true,
|
|
18
|
+
configurable: true,
|
|
19
|
+
writable: true
|
|
20
|
+
});
|
|
21
|
+
} else {
|
|
22
|
+
obj[key] = value;
|
|
23
|
+
}
|
|
24
|
+
return obj;
|
|
25
|
+
}
|
|
26
|
+
class BaseAPI {
|
|
27
|
+
// -----------------------------------------------------------------------------------
|
|
28
|
+
setClient(input) {
|
|
29
|
+
this.client = isClient(input) ? input : createClient(input);
|
|
30
|
+
}
|
|
31
|
+
// -----------------------------------------------------------------------------------
|
|
32
|
+
constructor(context){
|
|
33
|
+
_define_property$2(this, "client", void 0);
|
|
34
|
+
context = context || {};
|
|
35
|
+
this.setClient(context.client);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/*
|
|
40
|
+
* Copyright (c) 2021-2024.
|
|
41
|
+
* Author Peter Placzek (tada5hi)
|
|
42
|
+
* For the full copyright and license information,
|
|
43
|
+
* view the LICENSE file that was distributed with this source code.
|
|
44
|
+
*/ function asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, key, arg) {
|
|
45
|
+
try {
|
|
46
|
+
var info = gen[key](arg);
|
|
47
|
+
var value = info.value;
|
|
48
|
+
} catch (error) {
|
|
49
|
+
reject(error);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (info.done) {
|
|
53
|
+
resolve(value);
|
|
54
|
+
} else {
|
|
55
|
+
Promise.resolve(value).then(_next, _throw);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function _async_to_generator$1(fn) {
|
|
59
|
+
return function() {
|
|
60
|
+
var self = this, args = arguments;
|
|
61
|
+
return new Promise(function(resolve, reject) {
|
|
62
|
+
var gen = fn.apply(self, args);
|
|
63
|
+
function _next(value) {
|
|
64
|
+
asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "next", value);
|
|
65
|
+
}
|
|
66
|
+
function _throw(err) {
|
|
67
|
+
asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "throw", err);
|
|
68
|
+
}
|
|
69
|
+
_next(undefined);
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
class EventAPI extends BaseAPI {
|
|
74
|
+
getMany(options) {
|
|
75
|
+
return _async_to_generator$1(function*() {
|
|
76
|
+
const { data: response } = yield this.client.get(`events${buildQuery(options)}`);
|
|
77
|
+
return response;
|
|
78
|
+
}).call(this);
|
|
79
|
+
}
|
|
80
|
+
getOne(id) {
|
|
81
|
+
return _async_to_generator$1(function*() {
|
|
82
|
+
const { data: response } = yield this.client.get(`events/${id}`);
|
|
83
|
+
return response;
|
|
84
|
+
}).call(this);
|
|
85
|
+
}
|
|
86
|
+
delete(id) {
|
|
87
|
+
return _async_to_generator$1(function*() {
|
|
88
|
+
const { data: response } = yield this.client.delete(`events/${id}`);
|
|
89
|
+
return response;
|
|
90
|
+
}).call(this);
|
|
91
|
+
}
|
|
92
|
+
update(id, data) {
|
|
93
|
+
return _async_to_generator$1(function*() {
|
|
94
|
+
const { data: response } = yield this.client.post(`events/${id}`, data);
|
|
95
|
+
return response;
|
|
96
|
+
}).call(this);
|
|
97
|
+
}
|
|
98
|
+
create(data) {
|
|
99
|
+
return _async_to_generator$1(function*() {
|
|
100
|
+
const { data: response } = yield this.client.post('events', data);
|
|
101
|
+
return response;
|
|
102
|
+
}).call(this);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
class EventValidator extends Container {
|
|
107
|
+
initialize() {
|
|
108
|
+
super.initialize();
|
|
109
|
+
this.mount('ref_type', createValidator(zod.string().min(3).max(128)));
|
|
110
|
+
this.mount('ref_id', {
|
|
111
|
+
optional: true
|
|
112
|
+
}, createValidator(zod.uuidv4().nullable()));
|
|
113
|
+
// ----------------------------------------------
|
|
114
|
+
this.mount('scope', createValidator(zod.string().min(3).max(128)));
|
|
115
|
+
this.mount('name', createValidator(zod.string().min(3).max(128)));
|
|
116
|
+
// ----------------------------------------------
|
|
117
|
+
this.mount('data', {
|
|
118
|
+
optional: true
|
|
119
|
+
}, createValidator(zod.record(zod.string(), zod.any()).nullable()));
|
|
120
|
+
// ----------------------------------------------
|
|
121
|
+
this.mount('expiring', {
|
|
122
|
+
optional: true
|
|
123
|
+
}, createValidator(zod.boolean().nullable()));
|
|
124
|
+
// ----------------------------------------------
|
|
125
|
+
this.mount('request_path', {
|
|
126
|
+
optional: true
|
|
127
|
+
}, createValidator(zod.string().min(3).max(256).nullable()));
|
|
128
|
+
this.mount('request_method', {
|
|
129
|
+
optional: true
|
|
130
|
+
}, createValidator(zod.string().min(3).max(10).nullable()));
|
|
131
|
+
this.mount('request_ip_address', {
|
|
132
|
+
optional: true
|
|
133
|
+
}, createValidator(zod.ipv4().nullable()));
|
|
134
|
+
this.mount('request_user_agent', {
|
|
135
|
+
optional: true
|
|
136
|
+
}, createValidator(zod.string().min(3).max(512).nullable()));
|
|
137
|
+
// ----------------------------------------------
|
|
138
|
+
this.mount('actor_type', {
|
|
139
|
+
optional: true
|
|
140
|
+
}, createValidator(zod.string().min(3).max(64).nullable()));
|
|
141
|
+
this.mount('actor_id', {
|
|
142
|
+
optional: true
|
|
143
|
+
}, createValidator(zod.uuidv4().nullable()));
|
|
144
|
+
this.mount('actor_name', {
|
|
145
|
+
optional: true
|
|
146
|
+
}, createValidator(zod.string().min(3).max(64).nullable()));
|
|
147
|
+
// ----------------------------------------------
|
|
148
|
+
this.mount('realm_id', {
|
|
149
|
+
optional: true
|
|
150
|
+
}, createValidator(zod.uuidv4().nullable()));
|
|
151
|
+
// ----------------------------------------------
|
|
152
|
+
this.mount('expires_at', {
|
|
153
|
+
optional: true
|
|
154
|
+
}, createValidator(zod.iso.datetime().nullable()));
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/*
|
|
159
|
+
* Copyright (c) 2021-2024.
|
|
160
|
+
* Author Peter Placzek (tada5hi)
|
|
161
|
+
* For the full copyright and license information,
|
|
162
|
+
* view the LICENSE file that was distributed with this source code.
|
|
163
|
+
*/ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
164
|
+
try {
|
|
165
|
+
var info = gen[key](arg);
|
|
166
|
+
var value = info.value;
|
|
167
|
+
} catch (error) {
|
|
168
|
+
reject(error);
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
if (info.done) {
|
|
172
|
+
resolve(value);
|
|
173
|
+
} else {
|
|
174
|
+
Promise.resolve(value).then(_next, _throw);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
function _async_to_generator(fn) {
|
|
178
|
+
return function() {
|
|
179
|
+
var self = this, args = arguments;
|
|
180
|
+
return new Promise(function(resolve, reject) {
|
|
181
|
+
var gen = fn.apply(self, args);
|
|
182
|
+
function _next(value) {
|
|
183
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
184
|
+
}
|
|
185
|
+
function _throw(err) {
|
|
186
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
187
|
+
}
|
|
188
|
+
_next(undefined);
|
|
189
|
+
});
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
class LogAPI extends BaseAPI {
|
|
193
|
+
getMany(options) {
|
|
194
|
+
return _async_to_generator(function*() {
|
|
195
|
+
const { data: response } = yield this.client.get(`logs${buildQuery(options)}`);
|
|
196
|
+
return response;
|
|
197
|
+
}).call(this);
|
|
198
|
+
}
|
|
199
|
+
deleteMany(options) {
|
|
200
|
+
return _async_to_generator(function*() {
|
|
201
|
+
yield this.client.delete(`logs${buildQuery(options)}`);
|
|
202
|
+
}).call(this);
|
|
203
|
+
}
|
|
204
|
+
create(data) {
|
|
205
|
+
return _async_to_generator(function*() {
|
|
206
|
+
const { data: response } = yield this.client.post('logs', data);
|
|
207
|
+
return response;
|
|
208
|
+
}).call(this);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/*
|
|
213
|
+
* Copyright (c) 2025.
|
|
214
|
+
* Author Peter Placzek (tada5hi)
|
|
215
|
+
* For the full copyright and license information,
|
|
216
|
+
* view the LICENSE file that was distributed with this source code.
|
|
217
|
+
*/ var LogLevel = /*#__PURE__*/ function(LogLevel) {
|
|
218
|
+
/**
|
|
219
|
+
* indicates that the system is unusable
|
|
220
|
+
* and requires immediate attention
|
|
221
|
+
*/ LogLevel["EMERGENCE"] = "emerg";
|
|
222
|
+
/**
|
|
223
|
+
* indicates that immediate action is necessary
|
|
224
|
+
* to resolve a critical issue.
|
|
225
|
+
*/ LogLevel["ALERT"] = "alert";
|
|
226
|
+
/**
|
|
227
|
+
* signifies critical conditions in the program that demand
|
|
228
|
+
* intervention to prevent system failure.
|
|
229
|
+
*/ LogLevel["CRITICAL"] = "crit";
|
|
230
|
+
/**
|
|
231
|
+
* indicates error conditions that impair
|
|
232
|
+
* some operation but are less severe than critical situations.
|
|
233
|
+
*/ LogLevel["ERROR"] = "error";
|
|
234
|
+
/**
|
|
235
|
+
* signifies potential issues that may lead to errors
|
|
236
|
+
* or unexpected behavior in the future if not addressed.
|
|
237
|
+
*/ LogLevel["WARNING"] = "warn";
|
|
238
|
+
/**
|
|
239
|
+
* applies to normal but significant
|
|
240
|
+
* conditions that may require monitoring
|
|
241
|
+
*/ LogLevel["NOTICE"] = "notice";
|
|
242
|
+
/**
|
|
243
|
+
* includes messages that provide a record
|
|
244
|
+
* of the normal operation of the system.
|
|
245
|
+
*/ LogLevel["INFORMATIONAL"] = "info";
|
|
246
|
+
/**
|
|
247
|
+
* intended for logging detailed information about the system
|
|
248
|
+
* for debugging purposes.
|
|
249
|
+
*/ LogLevel["DEBUG"] = "debug";
|
|
250
|
+
return LogLevel;
|
|
251
|
+
}({});
|
|
252
|
+
var LogLevelColor = /*#__PURE__*/ function(LogLevelColor) {
|
|
253
|
+
LogLevelColor["EMERGENCE"] = "#8B0000";
|
|
254
|
+
LogLevelColor["ALERT"] = "#FF0000";
|
|
255
|
+
LogLevelColor["CRITICAL"] = "#FF4500";
|
|
256
|
+
LogLevelColor["ERROR"] = "#FF6347";
|
|
257
|
+
LogLevelColor["WARNING"] = "#FFD700";
|
|
258
|
+
LogLevelColor["NOTICE"] = "#1E90FF";
|
|
259
|
+
LogLevelColor["INFORMATIONAL"] = "#228B22";
|
|
260
|
+
LogLevelColor["DEBUG"] = "#A9A9A9";
|
|
261
|
+
return LogLevelColor;
|
|
262
|
+
}({});
|
|
263
|
+
var LogFlag = /*#__PURE__*/ function(LogFlag) {
|
|
264
|
+
LogFlag["CHANNEL"] = "channel";
|
|
265
|
+
LogFlag["COMPONENT"] = "component";
|
|
266
|
+
LogFlag["SERVICE"] = "service";
|
|
267
|
+
LogFlag["LEVEL"] = "level";
|
|
268
|
+
return LogFlag;
|
|
269
|
+
}({});
|
|
270
|
+
var LogChannel = /*#__PURE__*/ function(LogChannel) {
|
|
271
|
+
LogChannel["HTTP"] = "http";
|
|
272
|
+
LogChannel["WEBSOCKET"] = "websocket";
|
|
273
|
+
LogChannel["BACKGROUND"] = "background";
|
|
274
|
+
LogChannel["SYSTEM"] = "system";
|
|
275
|
+
return LogChannel;
|
|
276
|
+
}({});
|
|
277
|
+
|
|
278
|
+
/*
|
|
279
|
+
* Copyright (c) 2025.
|
|
280
|
+
* Author Peter Placzek (tada5hi)
|
|
281
|
+
* For the full copyright and license information,
|
|
282
|
+
* view the LICENSE file that was distributed with this source code.
|
|
283
|
+
*/ function _define_property$1(obj, key, value) {
|
|
284
|
+
if (key in obj) {
|
|
285
|
+
Object.defineProperty(obj, key, {
|
|
286
|
+
value: value,
|
|
287
|
+
enumerable: true,
|
|
288
|
+
configurable: true,
|
|
289
|
+
writable: true
|
|
290
|
+
});
|
|
291
|
+
} else {
|
|
292
|
+
obj[key] = value;
|
|
293
|
+
}
|
|
294
|
+
return obj;
|
|
295
|
+
}
|
|
296
|
+
function _object_spread(target) {
|
|
297
|
+
for(var i = 1; i < arguments.length; i++){
|
|
298
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
299
|
+
var ownKeys = Object.keys(source);
|
|
300
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
301
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
302
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
303
|
+
}));
|
|
304
|
+
}
|
|
305
|
+
ownKeys.forEach(function(key) {
|
|
306
|
+
_define_property$1(target, key, source[key]);
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
return target;
|
|
310
|
+
}
|
|
311
|
+
function ownKeys(object, enumerableOnly) {
|
|
312
|
+
var keys = Object.keys(object);
|
|
313
|
+
if (Object.getOwnPropertySymbols) {
|
|
314
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
315
|
+
keys.push.apply(keys, symbols);
|
|
316
|
+
}
|
|
317
|
+
return keys;
|
|
318
|
+
}
|
|
319
|
+
function _object_spread_props(target, source) {
|
|
320
|
+
source = source != null ? source : {};
|
|
321
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
322
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
323
|
+
} else {
|
|
324
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
325
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
return target;
|
|
329
|
+
}
|
|
330
|
+
function normalizeLogInput(input) {
|
|
331
|
+
return _object_spread_props(_object_spread({}, input), {
|
|
332
|
+
time: input.time || nanoSeconds(),
|
|
333
|
+
labels: input.labels || {}
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
class LogValidator extends Container {
|
|
338
|
+
initialize() {
|
|
339
|
+
super.initialize();
|
|
340
|
+
this.mount('time', {
|
|
341
|
+
optional: true
|
|
342
|
+
}, createValidator(zod.string().min(0).max(20).or(zod.bigint()).optional()));
|
|
343
|
+
this.mount('message', createValidator(zod.string().min(3).max(512)));
|
|
344
|
+
this.mount('service', createValidator(zod.string().min(3).max(64)));
|
|
345
|
+
// ----------------------------------------------
|
|
346
|
+
this.mount('level', createValidator(zod.enum(Object.values(LogLevel))));
|
|
347
|
+
this.mount('channel', createValidator(zod.enum(Object.values(LogChannel))));
|
|
348
|
+
this.mount('labels', {
|
|
349
|
+
optional: true
|
|
350
|
+
}, createValidator(zod.record(zod.string(), zod.string()).nullable()));
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/*
|
|
355
|
+
* Copyright (c) 2025.
|
|
356
|
+
* Author Peter Placzek (tada5hi)
|
|
357
|
+
* For the full copyright and license information,
|
|
358
|
+
* view the LICENSE file that was distributed with this source code.
|
|
359
|
+
*/ var DomainType = /*#__PURE__*/ function(DomainType) {
|
|
360
|
+
DomainType["EVENT"] = "event";
|
|
361
|
+
DomainType["LOG"] = "log";
|
|
362
|
+
return DomainType;
|
|
363
|
+
}({});
|
|
364
|
+
|
|
365
|
+
/*
|
|
366
|
+
* Copyright (c) 2022-2024.
|
|
367
|
+
* Author Peter Placzek (tada5hi)
|
|
368
|
+
* For the full copyright and license information,
|
|
369
|
+
* view the LICENSE file that was distributed with this source code.
|
|
370
|
+
*/ function _define_property(obj, key, value) {
|
|
371
|
+
if (key in obj) {
|
|
372
|
+
Object.defineProperty(obj, key, {
|
|
373
|
+
value: value,
|
|
374
|
+
enumerable: true,
|
|
375
|
+
configurable: true,
|
|
376
|
+
writable: true
|
|
377
|
+
});
|
|
378
|
+
} else {
|
|
379
|
+
obj[key] = value;
|
|
380
|
+
}
|
|
381
|
+
return obj;
|
|
382
|
+
}
|
|
383
|
+
class APIClient extends Client {
|
|
384
|
+
constructor(config){
|
|
385
|
+
super(config), _define_property(this, "event", void 0), _define_property(this, "log", void 0);
|
|
386
|
+
this.event = new EventAPI({
|
|
387
|
+
client: this
|
|
388
|
+
});
|
|
389
|
+
this.log = new LogAPI({
|
|
390
|
+
client: this
|
|
391
|
+
});
|
|
392
|
+
this.on(HookName.RESPONSE_ERROR, (error)=>{
|
|
393
|
+
if (isClientError(error) && error.response && error.response.data && typeof error.response.data.message === 'string') {
|
|
394
|
+
error.message = error.response.data.message;
|
|
395
|
+
}
|
|
396
|
+
throw error;
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
export { APIClient, DomainType, EventAPI, EventValidator, LogAPI, LogChannel, LogFlag, LogLevel, LogLevelColor, LogValidator, normalizeLogInput };
|
|
402
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../src/domains/base.ts","../src/domains/event/api.ts","../src/domains/event/validator.ts","../src/domains/log/api.ts","../src/domains/log/constants.ts","../src/domains/log/helpers.ts","../src/domains/log/validator.ts","../src/domains/constants.ts","../src/http/api-client/module.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 { createClient, isClient } from 'hapic';\nimport type { Client, RequestBaseOptions } from 'hapic';\nimport type { BaseAPIContext } from './types-base';\n\nexport class BaseAPI {\n protected client! : Client;\n\n // -----------------------------------------------------------------------------------\n\n constructor(context?: BaseAPIContext) {\n context = context || {};\n\n this.setClient(context.client);\n }\n\n // -----------------------------------------------------------------------------------\n\n setClient(input?: Client | RequestBaseOptions) {\n this.client = isClient(input) ?\n input :\n createClient(input);\n }\n}\n","/*\n * Copyright (c) 2021-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 { BuildInput } from 'rapiq';\nimport { buildQuery } from 'rapiq';\nimport type { Event } from './entity';\nimport type { CollectionResourceResponse, SingleResourceResponse } from '../types-base';\nimport { BaseAPI } from '../base';\n\nexport class EventAPI extends BaseAPI {\n async getMany(options?: BuildInput<Event>): Promise<CollectionResourceResponse<Event>> {\n const { data: response } = await this.client.get(`events${buildQuery(options)}`);\n return response;\n }\n\n async getOne(id: Event['id']): Promise<SingleResourceResponse<Event>> {\n const { data: response } = await this.client.get(`events/${id}`);\n\n return response;\n }\n\n async delete(id: Event['id']): Promise<SingleResourceResponse<Event>> {\n const { data: response } = await this.client.delete(`events/${id}`);\n\n return response;\n }\n\n async update(id: Event['id'], data: Partial<Event>): Promise<SingleResourceResponse<Event>> {\n const { data: response } = await this.client.post(`events/${id}`, data);\n\n return response;\n }\n\n async create(data: Partial<Event>): Promise<SingleResourceResponse<Event>> {\n const { data: response } = await this.client.post('events', data);\n\n return response;\n }\n}\n","/*\n * Copyright (c) 2025.\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 { createValidator } from '@validup/adapter-zod';\nimport { Container } from 'validup';\nimport zod from 'zod';\nimport type { Event } from './entity';\n\nexport class EventValidator extends Container<Event> {\n protected initialize() {\n super.initialize();\n\n this.mount(\n 'ref_type',\n createValidator(\n zod\n .string()\n .min(3)\n .max(128),\n ),\n );\n\n this.mount(\n 'ref_id',\n { optional: true },\n createValidator(\n zod\n .uuidv4()\n .nullable(),\n ),\n );\n\n // ----------------------------------------------\n\n this.mount(\n 'scope',\n createValidator(\n zod\n .string()\n .min(3)\n .max(128),\n ),\n );\n\n this.mount(\n 'name',\n createValidator(\n zod\n .string()\n .min(3)\n .max(128),\n ),\n );\n\n // ----------------------------------------------\n\n this.mount(\n 'data',\n { optional: true },\n createValidator(\n zod\n .record(zod.string(), zod.any())\n .nullable(),\n ),\n );\n\n // ----------------------------------------------\n\n this.mount(\n 'expiring',\n { optional: true },\n createValidator(\n zod\n .boolean()\n .nullable(),\n ),\n );\n\n // ----------------------------------------------\n\n this.mount(\n 'request_path',\n { optional: true },\n createValidator(zod.string().min(3).max(256).nullable()),\n );\n\n this.mount(\n 'request_method',\n { optional: true },\n createValidator(zod.string().min(3).max(10).nullable()),\n );\n\n this.mount(\n 'request_ip_address',\n { optional: true },\n createValidator(zod.ipv4().nullable()),\n );\n\n this.mount(\n 'request_user_agent',\n { optional: true },\n createValidator(zod.string().min(3).max(512).nullable()),\n );\n\n // ----------------------------------------------\n\n this.mount(\n 'actor_type',\n { optional: true },\n createValidator(zod.string().min(3).max(64).nullable()),\n );\n\n this.mount(\n 'actor_id',\n { optional: true },\n createValidator(zod.uuidv4().nullable()),\n );\n\n this.mount(\n 'actor_name',\n { optional: true },\n createValidator(zod.string().min(3).max(64).nullable()),\n );\n\n // ----------------------------------------------\n\n this.mount(\n 'realm_id',\n { optional: true },\n createValidator(zod.uuidv4().nullable()),\n );\n\n // ----------------------------------------------\n\n this.mount(\n 'expires_at',\n { optional: true },\n createValidator(\n zod.iso.datetime()\n .nullable(),\n ),\n );\n }\n}\n","/*\n * Copyright (c) 2021-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 { BuildInput } from 'rapiq';\nimport { buildQuery } from 'rapiq';\nimport type { Log, LogInput } from './entity';\nimport type { CollectionResourceResponse, SingleResourceResponse } from '../types-base';\nimport { BaseAPI } from '../base';\n\nexport class LogAPI extends BaseAPI {\n async getMany(options?: BuildInput<Log>): Promise<CollectionResourceResponse<Log>> {\n const { data: response } = await this.client.get(`logs${buildQuery(options)}`);\n return response;\n }\n\n async deleteMany(options?: BuildInput<Log>): Promise<void> {\n await this.client.delete(`logs${buildQuery(options)}`);\n }\n\n async create(data: Partial<LogInput>): Promise<SingleResourceResponse<Log>> {\n const { data: response } = await this.client.post('logs', data);\n\n return response;\n }\n}\n","/*\n * Copyright (c) 2025.\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 LogLevel {\n /**\n * indicates that the system is unusable\n * and requires immediate attention\n */\n EMERGENCE = 'emerg',\n\n /**\n * indicates that immediate action is necessary\n * to resolve a critical issue.\n */\n ALERT = 'alert',\n\n /**\n * signifies critical conditions in the program that demand\n * intervention to prevent system failure.\n */\n CRITICAL = 'crit',\n\n /**\n * indicates error conditions that impair\n * some operation but are less severe than critical situations.\n */\n ERROR = 'error',\n\n /**\n * signifies potential issues that may lead to errors\n * or unexpected behavior in the future if not addressed.\n */\n WARNING = 'warn',\n\n /**\n * applies to normal but significant\n * conditions that may require monitoring\n */\n NOTICE = 'notice',\n\n /**\n * includes messages that provide a record\n * of the normal operation of the system.\n */\n INFORMATIONAL = 'info',\n\n /**\n * intended for logging detailed information about the system\n * for debugging purposes.\n */\n DEBUG = 'debug',\n}\n\nexport enum LogLevelColor {\n EMERGENCE = '#8B0000',\n ALERT = '#FF0000',\n CRITICAL = '#FF4500',\n ERROR = '#FF6347',\n WARNING = '#FFD700',\n NOTICE = '#1E90FF',\n INFORMATIONAL = '#228B22',\n DEBUG = '#A9A9A9',\n}\n\nexport enum LogFlag {\n CHANNEL = 'channel',\n\n COMPONENT = 'component',\n\n SERVICE = 'service',\n\n LEVEL = 'level',\n}\n\nexport enum LogChannel {\n HTTP = 'http',\n WEBSOCKET = 'websocket',\n BACKGROUND = 'background',\n SYSTEM = 'system',\n}\n","/*\n * Copyright (c) 2025.\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 { nanoSeconds } from '@privateaim/kit';\nimport type { Log, LogInput } from './entity';\n\nexport function normalizeLogInput(input: LogInput) : Log {\n return {\n ...input,\n time: input.time || nanoSeconds(),\n labels: input.labels || {},\n };\n}\n","/*\n * Copyright (c) 2025.\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 { createValidator } from '@validup/adapter-zod';\nimport { Container } from 'validup';\nimport zod from 'zod';\nimport { LogChannel, LogLevel } from './constants';\nimport type { LogInput } from './entity';\n\nexport class LogValidator extends Container<LogInput> {\n protected initialize() {\n super.initialize();\n\n this.mount(\n 'time',\n { optional: true },\n createValidator(\n zod\n .string()\n .min(0)\n .max(20)\n .or(zod.bigint())\n .optional(),\n ),\n );\n\n this.mount(\n 'message',\n createValidator(\n zod\n .string()\n .min(3)\n .max(512),\n ),\n );\n\n this.mount(\n 'service',\n createValidator(\n zod\n .string()\n .min(3)\n .max(64),\n ),\n );\n\n // ----------------------------------------------\n\n this.mount(\n 'level',\n createValidator(\n zod\n .enum(Object.values(LogLevel)),\n ),\n );\n\n this.mount(\n 'channel',\n createValidator(\n zod\n .enum(Object.values(LogChannel)),\n ),\n );\n\n this.mount(\n 'labels',\n { optional: true },\n createValidator(\n zod\n .record(zod.string(), zod.string())\n .nullable(),\n ),\n );\n }\n}\n","/*\n * Copyright (c) 2025.\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 DomainType {\n EVENT = 'event',\n LOG = 'log',\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 { RequestBaseOptions } from 'hapic';\nimport { Client, HookName, isClientError } from 'hapic';\nimport {\n EventAPI,\n LogAPI,\n} from '../../domains';\n\nexport class APIClient extends Client {\n public readonly event : EventAPI;\n\n public readonly log : LogAPI;\n\n constructor(config: RequestBaseOptions) {\n super(config);\n\n this.event = new EventAPI({ client: this });\n this.log = new LogAPI({ client: this });\n\n this.on(HookName.RESPONSE_ERROR, ((error) => {\n if (\n isClientError(error) &&\n error.response &&\n error.response.data &&\n typeof error.response.data.message === 'string'\n ) {\n error.message = error.response.data.message;\n }\n\n throw error;\n }));\n }\n}\n"],"names":["_define_property","BaseAPI","setClient","input","client","isClient","createClient","context","asyncGeneratorStep","EventAPI","getMany","options","data","response","get","buildQuery","getOne","id","delete","update","post","create","EventValidator","Container","initialize","mount","createValidator","zod","string","min","max","optional","uuidv4","nullable","record","any","boolean","ipv4","iso","datetime","LogAPI","deleteMany","LogLevel","LogLevelColor","LogFlag","LogChannel","normalizeLogInput","time","nanoSeconds","labels","LogValidator","or","bigint","enum","Object","values","DomainType","APIClient","Client","config","event","log","on","HookName","RESPONSE_ERROR","error","isClientError","message"],"mappings":";;;;;;;AAAA;;;;;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AA,EAEA,gBAAA,CAAA,IAAA,EAAgBC,OAAhB,MAAA,CAAA;AAKI,QAAA,IAAI,CAACD,KAAK,GAAG,IAAInD,QAAAA,CAAS;AAAEL,YAAAA,MAAAA,EAAQ;AAAK,SAAA,CAAA;AACzC,QAAA,IAAI,CAACyD,GAAG,GAAG,IAAIrB,MAAAA,CAAO;AAAEpC,YAAAA,MAAAA,EAAQ;AAAK,SAAA,CAAA;AAErC,QAAA,IAAI,CAAC0D,EAAE,CAACC,QAAAA,CAASC,cAAc,EAAG,CAACC,KAAAA,GAAAA;AAC/B,YAAA,IACIC,cAAcD,KAAAA,CAAAA,IACdA,KAAAA,CAAMpD,QAAQ,IACdoD,KAAAA,CAAMpD,QAAQ,CAACD,IAAI,IACnB,OAAOqD,MAAMpD,QAAQ,CAACD,IAAI,CAACuD,OAAO,KAAK,QAAA,EACzC;AACEF,gBAAAA,KAAAA,CAAME,OAAO,GAAGF,KAAAA,CAAMpD,QAAQ,CAACD,IAAI,CAACuD,OAAO;AAC/C,YAAA;YAEA,MAAMF,KAAAA;AACV,QAAA,CAAA,CAAA;AACJ,IAAA;AACJ;;;;"}
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@privateaim/telemetry-kit",
|
|
3
|
+
"version": "0.8.16",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
|
+
"description": "",
|
|
6
|
+
"exports": {
|
|
7
|
+
"./package.json": "./package.json",
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.mjs",
|
|
11
|
+
"require": "./dist/index.cjs"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"main": "./dist/index.cjs",
|
|
15
|
+
"module": "./dist/index.mjs",
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"author": {
|
|
18
|
+
"name": "Peter Placzek",
|
|
19
|
+
"email": "admin@tada5hi.net",
|
|
20
|
+
"url": "https://github.com/tada5hi"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@validup/adapter-zod": "^0.1.11",
|
|
24
|
+
"validup": "^0.1.9",
|
|
25
|
+
"zod": "^4.1.1"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@authup/kit": "^1.0.0-beta.27",
|
|
29
|
+
"@authup/core-kit": "^1.0.0-beta.27",
|
|
30
|
+
"@privateaim/kit": "^0.8.16",
|
|
31
|
+
"hapic": "^2.7.0",
|
|
32
|
+
"rapiq": "^0.9.0"
|
|
33
|
+
},
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"@authup/kit": "^1.0.0-beta.27",
|
|
36
|
+
"@authup/core-kit": "^1.0.0-beta.27",
|
|
37
|
+
"@privateaim/kit": "^0.8.16",
|
|
38
|
+
"hapic": "^2.7.0",
|
|
39
|
+
"rapiq": "^0.9.0"
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build:types": "tsc --emitDeclarationOnly -p tsconfig.build.json",
|
|
43
|
+
"build:js": "rollup -c",
|
|
44
|
+
"build": "rimraf ./dist && cross-env NODE_ENV=production npm run build:js && npm run build:types",
|
|
45
|
+
"build-watch": "rimraf ./dist && tsc -p tsconfig.build.json --watch"
|
|
46
|
+
},
|
|
47
|
+
"gitHead": "5d3b6f4ce1edf2383bdfbf66e913a08c8a3a2e40",
|
|
48
|
+
"publishConfig": {
|
|
49
|
+
"access": "public"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2022-2024.
|
|
3
|
+
* Author Peter Placzek (tada5hi)
|
|
4
|
+
* For the full copyright and license information,
|
|
5
|
+
* view the LICENSE file that was distributed with this source code.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import fs from 'node:fs';
|
|
9
|
+
|
|
10
|
+
import { createConfig } from '../../rollup.config.mjs';
|
|
11
|
+
|
|
12
|
+
export default createConfig({
|
|
13
|
+
pkg: JSON.parse(fs.readFileSync(new URL('./package.json', import.meta.url), {encoding: 'utf-8'})),
|
|
14
|
+
swc: {
|
|
15
|
+
jsc: {
|
|
16
|
+
target: 'es2016'
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023-2024.
|
|
3
|
+
* Author Peter Placzek (tada5hi)
|
|
4
|
+
* For the full copyright and license information,
|
|
5
|
+
* view the LICENSE file that was distributed with this source code.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { createClient, isClient } from 'hapic';
|
|
9
|
+
import type { Client, RequestBaseOptions } from 'hapic';
|
|
10
|
+
import type { BaseAPIContext } from './types-base';
|
|
11
|
+
|
|
12
|
+
export class BaseAPI {
|
|
13
|
+
protected client! : Client;
|
|
14
|
+
|
|
15
|
+
// -----------------------------------------------------------------------------------
|
|
16
|
+
|
|
17
|
+
constructor(context?: BaseAPIContext) {
|
|
18
|
+
context = context || {};
|
|
19
|
+
|
|
20
|
+
this.setClient(context.client);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// -----------------------------------------------------------------------------------
|
|
24
|
+
|
|
25
|
+
setClient(input?: Client | RequestBaseOptions) {
|
|
26
|
+
this.client = isClient(input) ?
|
|
27
|
+
input :
|
|
28
|
+
createClient(input);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2021-2024.
|
|
3
|
+
* Author Peter Placzek (tada5hi)
|
|
4
|
+
* For the full copyright and license information,
|
|
5
|
+
* view the LICENSE file that was distributed with this source code.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { BuildInput } from 'rapiq';
|
|
9
|
+
import { buildQuery } from 'rapiq';
|
|
10
|
+
import type { Event } from './entity';
|
|
11
|
+
import type { CollectionResourceResponse, SingleResourceResponse } from '../types-base';
|
|
12
|
+
import { BaseAPI } from '../base';
|
|
13
|
+
|
|
14
|
+
export class EventAPI extends BaseAPI {
|
|
15
|
+
async getMany(options?: BuildInput<Event>): Promise<CollectionResourceResponse<Event>> {
|
|
16
|
+
const { data: response } = await this.client.get(`events${buildQuery(options)}`);
|
|
17
|
+
return response;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
async getOne(id: Event['id']): Promise<SingleResourceResponse<Event>> {
|
|
21
|
+
const { data: response } = await this.client.get(`events/${id}`);
|
|
22
|
+
|
|
23
|
+
return response;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async delete(id: Event['id']): Promise<SingleResourceResponse<Event>> {
|
|
27
|
+
const { data: response } = await this.client.delete(`events/${id}`);
|
|
28
|
+
|
|
29
|
+
return response;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async update(id: Event['id'], data: Partial<Event>): Promise<SingleResourceResponse<Event>> {
|
|
33
|
+
const { data: response } = await this.client.post(`events/${id}`, data);
|
|
34
|
+
|
|
35
|
+
return response;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async create(data: Partial<Event>): Promise<SingleResourceResponse<Event>> {
|
|
39
|
+
const { data: response } = await this.client.post('events', data);
|
|
40
|
+
|
|
41
|
+
return response;
|
|
42
|
+
}
|
|
43
|
+
}
|