@athosjs/pro 0.1.4-alpha
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/README.md +518 -0
- package/bootstrap.cjs +107 -0
- package/bootstrap.cjs.map +1 -0
- package/bootstrap.d.ts +8 -0
- package/bootstrap.d.ts.map +1 -0
- package/bootstrap.js +103 -0
- package/bootstrap.js.map +1 -0
- package/core/athos-application.cjs +362 -0
- package/core/athos-application.cjs.map +1 -0
- package/core/athos-application.d.ts +17 -0
- package/core/athos-application.d.ts.map +1 -0
- package/core/athos-application.js +357 -0
- package/core/athos-application.js.map +1 -0
- package/core/discovery.cjs +47 -0
- package/core/discovery.cjs.map +1 -0
- package/core/discovery.d.ts +6 -0
- package/core/discovery.d.ts.map +1 -0
- package/core/discovery.js +45 -0
- package/core/discovery.js.map +1 -0
- package/core/i18n.cjs +12 -0
- package/core/i18n.cjs.map +1 -0
- package/core/i18n.d.ts +4 -0
- package/core/i18n.d.ts.map +1 -0
- package/core/i18n.js +10 -0
- package/core/i18n.js.map +1 -0
- package/core/pipeline.cjs +251 -0
- package/core/pipeline.cjs.map +1 -0
- package/core/pipeline.d.ts +11 -0
- package/core/pipeline.d.ts.map +1 -0
- package/core/pipeline.js +246 -0
- package/core/pipeline.js.map +1 -0
- package/core/router-initializer.cjs +158 -0
- package/core/router-initializer.cjs.map +1 -0
- package/core/router-initializer.d.ts +26 -0
- package/core/router-initializer.d.ts.map +1 -0
- package/core/router-initializer.js +156 -0
- package/core/router-initializer.js.map +1 -0
- package/core/scanner.cjs +141 -0
- package/core/scanner.cjs.map +1 -0
- package/core/scanner.d.ts +7 -0
- package/core/scanner.d.ts.map +1 -0
- package/core/scanner.js +139 -0
- package/core/scanner.js.map +1 -0
- package/experimental.cjs +23 -0
- package/experimental.cjs.map +1 -0
- package/experimental.d.ts +9 -0
- package/experimental.d.ts.map +1 -0
- package/experimental.js +5 -0
- package/experimental.js.map +1 -0
- package/functions.cjs +67 -0
- package/functions.cjs.map +1 -0
- package/functions.d.ts +10 -0
- package/functions.d.ts.map +1 -0
- package/functions.js +62 -0
- package/functions.js.map +1 -0
- package/http-profile.cjs +48 -0
- package/http-profile.cjs.map +1 -0
- package/http-profile.d.ts +6 -0
- package/http-profile.d.ts.map +1 -0
- package/http-profile.js +44 -0
- package/http-profile.js.map +1 -0
- package/index.cjs +281 -0
- package/index.cjs.map +1 -0
- package/index.d.ts +23 -0
- package/index.d.ts.map +1 -0
- package/index.js +23 -0
- package/index.js.map +1 -0
- package/observability.cjs +191 -0
- package/observability.cjs.map +1 -0
- package/observability.d.ts +8 -0
- package/observability.d.ts.map +1 -0
- package/observability.js +188 -0
- package/observability.js.map +1 -0
- package/package.json +42 -0
- package/policies.cjs +30 -0
- package/policies.cjs.map +1 -0
- package/policies.d.ts +21 -0
- package/policies.d.ts.map +1 -0
- package/policies.js +27 -0
- package/policies.js.map +1 -0
- package/resilience.cjs +280 -0
- package/resilience.cjs.map +1 -0
- package/resilience.d.ts +6 -0
- package/resilience.d.ts.map +1 -0
- package/resilience.js +276 -0
- package/resilience.js.map +1 -0
- package/security.cjs +142 -0
- package/security.cjs.map +1 -0
- package/security.d.ts +11 -0
- package/security.d.ts.map +1 -0
- package/security.js +136 -0
- package/security.js.map +1 -0
- package/types.d.ts +3 -0
- package/types.d.ts.map +1 -0
package/index.cjs
ADDED
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var auth = require('@athosjs/auth');
|
|
4
|
+
var config = require('@athosjs/config');
|
|
5
|
+
var constants = require('@athosjs/constants');
|
|
6
|
+
var core = require('@athosjs/core');
|
|
7
|
+
var i18n = require('@athosjs/i18n');
|
|
8
|
+
var di = require('@athosjs/di');
|
|
9
|
+
var http = require('@athosjs/http');
|
|
10
|
+
var metadata = require('@athosjs/metadata');
|
|
11
|
+
var module$1 = require('@athosjs/module');
|
|
12
|
+
var observability = require('@athosjs/observability');
|
|
13
|
+
var openapi = require('@athosjs/openapi');
|
|
14
|
+
var validation = require('@athosjs/validation');
|
|
15
|
+
var bootstrap = require('./bootstrap.cjs');
|
|
16
|
+
var functions = require('./functions.cjs');
|
|
17
|
+
var policies = require('./policies.cjs');
|
|
18
|
+
var athosApplication = require('./core/athos-application.cjs');
|
|
19
|
+
|
|
20
|
+
const AthosApplication = athosApplication.AthosApplicationDecorator;
|
|
21
|
+
|
|
22
|
+
Object.defineProperty(exports, "ATHOS_ERROR_CODES", {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
get: function () { return constants.ATHOS_ERROR_CODES; }
|
|
25
|
+
});
|
|
26
|
+
Object.defineProperty(exports, "ATHOS_STATE_KEYS", {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
get: function () { return constants.ATHOS_STATE_KEYS; }
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "AuthStrategyClass", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () { return core.AuthStrategyClass; }
|
|
33
|
+
});
|
|
34
|
+
Object.defineProperty(exports, "AuthorizationGuardClass", {
|
|
35
|
+
enumerable: true,
|
|
36
|
+
get: function () { return core.AuthorizationGuardClass; }
|
|
37
|
+
});
|
|
38
|
+
Object.defineProperty(exports, "AuthorizationPolicyClass", {
|
|
39
|
+
enumerable: true,
|
|
40
|
+
get: function () { return core.AuthorizationPolicyClass; }
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(exports, "Body", {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
get: function () { return core.Body; }
|
|
45
|
+
});
|
|
46
|
+
Object.defineProperty(exports, "CONTROLLER_METADATA_KEY", {
|
|
47
|
+
enumerable: true,
|
|
48
|
+
get: function () { return core.CONTROLLER_METADATA_KEY; }
|
|
49
|
+
});
|
|
50
|
+
Object.defineProperty(exports, "Component", {
|
|
51
|
+
enumerable: true,
|
|
52
|
+
get: function () { return core.Component; }
|
|
53
|
+
});
|
|
54
|
+
Object.defineProperty(exports, "Controller", {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function () { return core.Controller; }
|
|
57
|
+
});
|
|
58
|
+
Object.defineProperty(exports, "Cookie", {
|
|
59
|
+
enumerable: true,
|
|
60
|
+
get: function () { return core.Cookie; }
|
|
61
|
+
});
|
|
62
|
+
Object.defineProperty(exports, "Ctx", {
|
|
63
|
+
enumerable: true,
|
|
64
|
+
get: function () { return core.Ctx; }
|
|
65
|
+
});
|
|
66
|
+
Object.defineProperty(exports, "Delete", {
|
|
67
|
+
enumerable: true,
|
|
68
|
+
get: function () { return core.Delete; }
|
|
69
|
+
});
|
|
70
|
+
Object.defineProperty(exports, "Get", {
|
|
71
|
+
enumerable: true,
|
|
72
|
+
get: function () { return core.Get; }
|
|
73
|
+
});
|
|
74
|
+
Object.defineProperty(exports, "Header", {
|
|
75
|
+
enumerable: true,
|
|
76
|
+
get: function () { return core.Header; }
|
|
77
|
+
});
|
|
78
|
+
Object.defineProperty(exports, "HttpStatus", {
|
|
79
|
+
enumerable: true,
|
|
80
|
+
get: function () { return core.HttpStatus; }
|
|
81
|
+
});
|
|
82
|
+
Object.defineProperty(exports, "Inject", {
|
|
83
|
+
enumerable: true,
|
|
84
|
+
get: function () { return core.Inject; }
|
|
85
|
+
});
|
|
86
|
+
Object.defineProperty(exports, "Injectable", {
|
|
87
|
+
enumerable: true,
|
|
88
|
+
get: function () { return core.Injectable; }
|
|
89
|
+
});
|
|
90
|
+
Object.defineProperty(exports, "Optional", {
|
|
91
|
+
enumerable: true,
|
|
92
|
+
get: function () { return core.Optional; }
|
|
93
|
+
});
|
|
94
|
+
Object.defineProperty(exports, "PARAM_METADATA_KEY", {
|
|
95
|
+
enumerable: true,
|
|
96
|
+
get: function () { return core.PARAM_METADATA_KEY; }
|
|
97
|
+
});
|
|
98
|
+
Object.defineProperty(exports, "Param", {
|
|
99
|
+
enumerable: true,
|
|
100
|
+
get: function () { return core.Param; }
|
|
101
|
+
});
|
|
102
|
+
Object.defineProperty(exports, "Patch", {
|
|
103
|
+
enumerable: true,
|
|
104
|
+
get: function () { return core.Patch; }
|
|
105
|
+
});
|
|
106
|
+
Object.defineProperty(exports, "Post", {
|
|
107
|
+
enumerable: true,
|
|
108
|
+
get: function () { return core.Post; }
|
|
109
|
+
});
|
|
110
|
+
Object.defineProperty(exports, "Put", {
|
|
111
|
+
enumerable: true,
|
|
112
|
+
get: function () { return core.Put; }
|
|
113
|
+
});
|
|
114
|
+
Object.defineProperty(exports, "Query", {
|
|
115
|
+
enumerable: true,
|
|
116
|
+
get: function () { return core.Query; }
|
|
117
|
+
});
|
|
118
|
+
Object.defineProperty(exports, "ROUTE_METADATA_KEY", {
|
|
119
|
+
enumerable: true,
|
|
120
|
+
get: function () { return core.ROUTE_METADATA_KEY; }
|
|
121
|
+
});
|
|
122
|
+
Object.defineProperty(exports, "Repository", {
|
|
123
|
+
enumerable: true,
|
|
124
|
+
get: function () { return core.Repository; }
|
|
125
|
+
});
|
|
126
|
+
Object.defineProperty(exports, "Req", {
|
|
127
|
+
enumerable: true,
|
|
128
|
+
get: function () { return core.Req; }
|
|
129
|
+
});
|
|
130
|
+
Object.defineProperty(exports, "RequestFile", {
|
|
131
|
+
enumerable: true,
|
|
132
|
+
get: function () { return core.RequestFile; }
|
|
133
|
+
});
|
|
134
|
+
Object.defineProperty(exports, "RequestFiles", {
|
|
135
|
+
enumerable: true,
|
|
136
|
+
get: function () { return core.RequestFiles; }
|
|
137
|
+
});
|
|
138
|
+
Object.defineProperty(exports, "Res", {
|
|
139
|
+
enumerable: true,
|
|
140
|
+
get: function () { return core.Res; }
|
|
141
|
+
});
|
|
142
|
+
Object.defineProperty(exports, "Scoped", {
|
|
143
|
+
enumerable: true,
|
|
144
|
+
get: function () { return core.Scoped; }
|
|
145
|
+
});
|
|
146
|
+
Object.defineProperty(exports, "Service", {
|
|
147
|
+
enumerable: true,
|
|
148
|
+
get: function () { return core.Service; }
|
|
149
|
+
});
|
|
150
|
+
Object.defineProperty(exports, "Singleton", {
|
|
151
|
+
enumerable: true,
|
|
152
|
+
get: function () { return core.Singleton; }
|
|
153
|
+
});
|
|
154
|
+
Object.defineProperty(exports, "State", {
|
|
155
|
+
enumerable: true,
|
|
156
|
+
get: function () { return core.State; }
|
|
157
|
+
});
|
|
158
|
+
Object.defineProperty(exports, "Transient", {
|
|
159
|
+
enumerable: true,
|
|
160
|
+
get: function () { return core.Transient; }
|
|
161
|
+
});
|
|
162
|
+
Object.defineProperty(exports, "Version", {
|
|
163
|
+
enumerable: true,
|
|
164
|
+
get: function () { return core.Version; }
|
|
165
|
+
});
|
|
166
|
+
Object.defineProperty(exports, "applyDecorators", {
|
|
167
|
+
enumerable: true,
|
|
168
|
+
get: function () { return core.applyDecorators; }
|
|
169
|
+
});
|
|
170
|
+
Object.defineProperty(exports, "ATHOS_CONTAINER_INSPECTOR_TOKEN", {
|
|
171
|
+
enumerable: true,
|
|
172
|
+
get: function () { return di.ATHOS_CONTAINER_INSPECTOR_TOKEN; }
|
|
173
|
+
});
|
|
174
|
+
Object.defineProperty(exports, "ATHOS_CONTAINER_TOKEN", {
|
|
175
|
+
enumerable: true,
|
|
176
|
+
get: function () { return di.ATHOS_CONTAINER_TOKEN; }
|
|
177
|
+
});
|
|
178
|
+
Object.defineProperty(exports, "AthosContainer", {
|
|
179
|
+
enumerable: true,
|
|
180
|
+
get: function () { return di.AthosContainer; }
|
|
181
|
+
});
|
|
182
|
+
Object.defineProperty(exports, "classProvider", {
|
|
183
|
+
enumerable: true,
|
|
184
|
+
get: function () { return di.classProvider; }
|
|
185
|
+
});
|
|
186
|
+
Object.defineProperty(exports, "createContainer", {
|
|
187
|
+
enumerable: true,
|
|
188
|
+
get: function () { return di.createContainer; }
|
|
189
|
+
});
|
|
190
|
+
Object.defineProperty(exports, "createToken", {
|
|
191
|
+
enumerable: true,
|
|
192
|
+
get: function () { return di.createToken; }
|
|
193
|
+
});
|
|
194
|
+
Object.defineProperty(exports, "existingProvider", {
|
|
195
|
+
enumerable: true,
|
|
196
|
+
get: function () { return di.existingProvider; }
|
|
197
|
+
});
|
|
198
|
+
Object.defineProperty(exports, "factoryProvider", {
|
|
199
|
+
enumerable: true,
|
|
200
|
+
get: function () { return di.factoryProvider; }
|
|
201
|
+
});
|
|
202
|
+
Object.defineProperty(exports, "optional", {
|
|
203
|
+
enumerable: true,
|
|
204
|
+
get: function () { return di.optional; }
|
|
205
|
+
});
|
|
206
|
+
Object.defineProperty(exports, "valueProvider", {
|
|
207
|
+
enumerable: true,
|
|
208
|
+
get: function () { return di.valueProvider; }
|
|
209
|
+
});
|
|
210
|
+
exports.ProBootstrap = bootstrap.ProBootstrap;
|
|
211
|
+
exports.createProHttpApplication = bootstrap.createProHttpApplication;
|
|
212
|
+
exports.createStartedProApplication = bootstrap.createStartedProApplication;
|
|
213
|
+
exports.ProApplication = functions.ProApplication;
|
|
214
|
+
exports.createProApplication = functions.createProApplication;
|
|
215
|
+
exports.createProApplicationBuilder = functions.createProApplicationBuilder;
|
|
216
|
+
exports.createProApplicationSetup = functions.createProApplicationSetup;
|
|
217
|
+
exports.USE_POLICY_METADATA_KEY = policies.USE_POLICY_METADATA_KEY;
|
|
218
|
+
exports.UsePolicy = policies.UsePolicy;
|
|
219
|
+
exports.Athos = athosApplication.AthosApplication;
|
|
220
|
+
exports.AthosApplication = AthosApplication;
|
|
221
|
+
Object.keys(auth).forEach(function (k) {
|
|
222
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
223
|
+
enumerable: true,
|
|
224
|
+
get: function () { return auth[k]; }
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
Object.keys(config).forEach(function (k) {
|
|
228
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
229
|
+
enumerable: true,
|
|
230
|
+
get: function () { return config[k]; }
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
Object.keys(core).forEach(function (k) {
|
|
234
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
235
|
+
enumerable: true,
|
|
236
|
+
get: function () { return core[k]; }
|
|
237
|
+
});
|
|
238
|
+
});
|
|
239
|
+
Object.keys(i18n).forEach(function (k) {
|
|
240
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
241
|
+
enumerable: true,
|
|
242
|
+
get: function () { return i18n[k]; }
|
|
243
|
+
});
|
|
244
|
+
});
|
|
245
|
+
Object.keys(http).forEach(function (k) {
|
|
246
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
247
|
+
enumerable: true,
|
|
248
|
+
get: function () { return http[k]; }
|
|
249
|
+
});
|
|
250
|
+
});
|
|
251
|
+
Object.keys(metadata).forEach(function (k) {
|
|
252
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
253
|
+
enumerable: true,
|
|
254
|
+
get: function () { return metadata[k]; }
|
|
255
|
+
});
|
|
256
|
+
});
|
|
257
|
+
Object.keys(module$1).forEach(function (k) {
|
|
258
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
259
|
+
enumerable: true,
|
|
260
|
+
get: function () { return module$1[k]; }
|
|
261
|
+
});
|
|
262
|
+
});
|
|
263
|
+
Object.keys(observability).forEach(function (k) {
|
|
264
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
265
|
+
enumerable: true,
|
|
266
|
+
get: function () { return observability[k]; }
|
|
267
|
+
});
|
|
268
|
+
});
|
|
269
|
+
Object.keys(openapi).forEach(function (k) {
|
|
270
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
271
|
+
enumerable: true,
|
|
272
|
+
get: function () { return openapi[k]; }
|
|
273
|
+
});
|
|
274
|
+
});
|
|
275
|
+
Object.keys(validation).forEach(function (k) {
|
|
276
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
277
|
+
enumerable: true,
|
|
278
|
+
get: function () { return validation[k]; }
|
|
279
|
+
});
|
|
280
|
+
});
|
|
281
|
+
//# sourceMappingURL=index.cjs.map
|
package/index.cjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../packages/pro/src/index.ts"],"sourcesContent":["export * from \"@athosjs/auth\";\nexport * from \"@athosjs/config\";\nexport { ATHOS_ERROR_CODES, ATHOS_STATE_KEYS } from \"@athosjs/constants\";\nexport * from \"@athosjs/core\";\nexport * from \"@athosjs/i18n\";\nexport {\n\tAuthorizationGuardClass,\n\tAuthorizationPolicyClass,\n\tAuthStrategyClass,\n\tapplyDecorators,\n\tBody,\n\tCONTROLLER_METADATA_KEY,\n\tComponent,\n\tController,\n\tCookie,\n\tCtx,\n\tDelete,\n\tGet,\n\tHeader,\n\tHttpStatus,\n\tInject,\n\tInjectable,\n\tOptional,\n\tPARAM_METADATA_KEY,\n\tParam,\n\tPatch,\n\tPost,\n\tPut,\n\tQuery,\n\tRepository,\n\tReq,\n\tRequestFile,\n\tRequestFiles,\n\tRes,\n\tROUTE_METADATA_KEY,\n\tScoped,\n\tService,\n\tSingleton,\n\tState,\n\tTransient,\n\tVersion,\n} from \"@athosjs/core\";\nexport {\n\tclassProvider,\n\tcreateContainer,\n\tcreateToken,\n\texistingProvider,\n\tfactoryProvider,\n\tATHOS_CONTAINER_INSPECTOR_TOKEN,\n\tATHOS_CONTAINER_TOKEN,\n\tAthosContainer,\n\toptional,\n\tvalueProvider,\n} from \"@athosjs/di\";\nexport type { HttpInterceptor as Interceptor } from \"@athosjs/http\";\nexport * from \"@athosjs/http\";\nexport * from \"@athosjs/metadata\";\nexport * from \"@athosjs/module\";\nexport * from \"@athosjs/observability\";\nexport * from \"@athosjs/openapi\";\nexport * from \"@athosjs/validation\";\nexport * from \"./bootstrap\";\nexport * from \"./functions\";\nexport * from \"./policies\";\nexport * from \"./types\";\n\nimport {\n\tAthosApplication as AthosAppCore,\n\tAthosApplicationDecorator,\n\ttype AthosManifest,\n\ttype AthosRunOptions,\n} from \"./core/athos-application\";\n\nexport type { AthosManifest, AthosRunOptions };\nexport const AthosApplication = AthosApplicationDecorator;\nexport { AthosAppCore as Athos };\n"],"names":["AthosApplication","AthosApplicationDecorator"],"mappings":";;;;;;;;;;;;;;;;;;;AA0EO,MAAMA,mBAAmBC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export * from "@athosjs/auth";
|
|
2
|
+
export * from "@athosjs/config";
|
|
3
|
+
export { ATHOS_ERROR_CODES, ATHOS_STATE_KEYS } from "@athosjs/constants";
|
|
4
|
+
export * from "@athosjs/core";
|
|
5
|
+
export * from "@athosjs/i18n";
|
|
6
|
+
export { AuthorizationGuardClass, AuthorizationPolicyClass, AuthStrategyClass, applyDecorators, Body, CONTROLLER_METADATA_KEY, Component, Controller, Cookie, Ctx, Delete, Get, Header, HttpStatus, Inject, Injectable, Optional, PARAM_METADATA_KEY, Param, Patch, Post, Put, Query, Repository, Req, RequestFile, RequestFiles, Res, ROUTE_METADATA_KEY, Scoped, Service, Singleton, State, Transient, Version, } from "@athosjs/core";
|
|
7
|
+
export { classProvider, createContainer, createToken, existingProvider, factoryProvider, ATHOS_CONTAINER_INSPECTOR_TOKEN, ATHOS_CONTAINER_TOKEN, AthosContainer, optional, valueProvider, } from "@athosjs/di";
|
|
8
|
+
export type { HttpInterceptor as Interceptor } from "@athosjs/http";
|
|
9
|
+
export * from "@athosjs/http";
|
|
10
|
+
export * from "@athosjs/metadata";
|
|
11
|
+
export * from "@athosjs/module";
|
|
12
|
+
export * from "@athosjs/observability";
|
|
13
|
+
export * from "@athosjs/openapi";
|
|
14
|
+
export * from "@athosjs/validation";
|
|
15
|
+
export * from "./bootstrap";
|
|
16
|
+
export * from "./functions";
|
|
17
|
+
export * from "./policies";
|
|
18
|
+
export * from "./types";
|
|
19
|
+
import { AthosApplication as AthosAppCore, AthosApplicationDecorator, type AthosManifest, type AthosRunOptions } from "./core/athos-application";
|
|
20
|
+
export type { AthosManifest, AthosRunOptions };
|
|
21
|
+
export declare const AthosApplication: typeof AthosApplicationDecorator;
|
|
22
|
+
export { AthosAppCore as Athos };
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|
package/index.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../packages/pro/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACzE,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,OAAO,EACN,uBAAuB,EACvB,wBAAwB,EACxB,iBAAiB,EACjB,eAAe,EACf,IAAI,EACJ,uBAAuB,EACvB,SAAS,EACT,UAAU,EACV,MAAM,EACN,GAAG,EACH,MAAM,EACN,GAAG,EACH,MAAM,EACN,UAAU,EACV,MAAM,EACN,UAAU,EACV,QAAQ,EACR,kBAAkB,EAClB,KAAK,EACL,KAAK,EACL,IAAI,EACJ,GAAG,EACH,KAAK,EACL,UAAU,EACV,GAAG,EACH,WAAW,EACX,YAAY,EACZ,GAAG,EACH,kBAAkB,EAClB,MAAM,EACN,OAAO,EACP,SAAS,EACT,KAAK,EACL,SAAS,EACT,OAAO,GACP,MAAM,eAAe,CAAC;AACvB,OAAO,EACN,aAAa,EACb,eAAe,EACf,WAAW,EACX,gBAAgB,EAChB,eAAe,EACf,+BAA+B,EAC/B,qBAAqB,EACrB,cAAc,EACd,QAAQ,EACR,aAAa,GACb,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,eAAe,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC;AACpE,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AAExB,OAAO,EACN,gBAAgB,IAAI,YAAY,EAChC,yBAAyB,EACzB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,MAAM,0BAA0B,CAAC;AAElC,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,CAAC;AAC/C,eAAO,MAAM,gBAAgB,kCAA4B,CAAC;AAC1D,OAAO,EAAE,YAAY,IAAI,KAAK,EAAE,CAAC"}
|
package/index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export * from '@athosjs/auth';
|
|
2
|
+
export * from '@athosjs/config';
|
|
3
|
+
export { ATHOS_ERROR_CODES, ATHOS_STATE_KEYS } from '@athosjs/constants';
|
|
4
|
+
export * from '@athosjs/core';
|
|
5
|
+
export { AuthStrategyClass, AuthorizationGuardClass, AuthorizationPolicyClass, Body, CONTROLLER_METADATA_KEY, Component, Controller, Cookie, Ctx, Delete, Get, Header, HttpStatus, Inject, Injectable, Optional, PARAM_METADATA_KEY, Param, Patch, Post, Put, Query, ROUTE_METADATA_KEY, Repository, Req, RequestFile, RequestFiles, Res, Scoped, Service, Singleton, State, Transient, Version, applyDecorators } from '@athosjs/core';
|
|
6
|
+
export * from '@athosjs/i18n';
|
|
7
|
+
export { ATHOS_CONTAINER_INSPECTOR_TOKEN, ATHOS_CONTAINER_TOKEN, AthosContainer, classProvider, createContainer, createToken, existingProvider, factoryProvider, optional, valueProvider } from '@athosjs/di';
|
|
8
|
+
export * from '@athosjs/http';
|
|
9
|
+
export * from '@athosjs/metadata';
|
|
10
|
+
export * from '@athosjs/module';
|
|
11
|
+
export * from '@athosjs/observability';
|
|
12
|
+
export * from '@athosjs/openapi';
|
|
13
|
+
export * from '@athosjs/validation';
|
|
14
|
+
export { ProBootstrap, createProHttpApplication, createStartedProApplication } from './bootstrap.js';
|
|
15
|
+
export { ProApplication, createProApplication, createProApplicationBuilder, createProApplicationSetup } from './functions.js';
|
|
16
|
+
export { USE_POLICY_METADATA_KEY, UsePolicy } from './policies.js';
|
|
17
|
+
import { AthosApplicationDecorator } from './core/athos-application.js';
|
|
18
|
+
export { AthosApplication as Athos } from './core/athos-application.js';
|
|
19
|
+
|
|
20
|
+
const AthosApplication = AthosApplicationDecorator;
|
|
21
|
+
|
|
22
|
+
export { AthosApplication };
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../packages/pro/src/index.ts"],"sourcesContent":["export * from \"@athosjs/auth\";\nexport * from \"@athosjs/config\";\nexport { ATHOS_ERROR_CODES, ATHOS_STATE_KEYS } from \"@athosjs/constants\";\nexport * from \"@athosjs/core\";\nexport * from \"@athosjs/i18n\";\nexport {\n\tAuthorizationGuardClass,\n\tAuthorizationPolicyClass,\n\tAuthStrategyClass,\n\tapplyDecorators,\n\tBody,\n\tCONTROLLER_METADATA_KEY,\n\tComponent,\n\tController,\n\tCookie,\n\tCtx,\n\tDelete,\n\tGet,\n\tHeader,\n\tHttpStatus,\n\tInject,\n\tInjectable,\n\tOptional,\n\tPARAM_METADATA_KEY,\n\tParam,\n\tPatch,\n\tPost,\n\tPut,\n\tQuery,\n\tRepository,\n\tReq,\n\tRequestFile,\n\tRequestFiles,\n\tRes,\n\tROUTE_METADATA_KEY,\n\tScoped,\n\tService,\n\tSingleton,\n\tState,\n\tTransient,\n\tVersion,\n} from \"@athosjs/core\";\nexport {\n\tclassProvider,\n\tcreateContainer,\n\tcreateToken,\n\texistingProvider,\n\tfactoryProvider,\n\tATHOS_CONTAINER_INSPECTOR_TOKEN,\n\tATHOS_CONTAINER_TOKEN,\n\tAthosContainer,\n\toptional,\n\tvalueProvider,\n} from \"@athosjs/di\";\nexport type { HttpInterceptor as Interceptor } from \"@athosjs/http\";\nexport * from \"@athosjs/http\";\nexport * from \"@athosjs/metadata\";\nexport * from \"@athosjs/module\";\nexport * from \"@athosjs/observability\";\nexport * from \"@athosjs/openapi\";\nexport * from \"@athosjs/validation\";\nexport * from \"./bootstrap\";\nexport * from \"./functions\";\nexport * from \"./policies\";\nexport * from \"./types\";\n\nimport {\n\tAthosApplication as AthosAppCore,\n\tAthosApplicationDecorator,\n\ttype AthosManifest,\n\ttype AthosRunOptions,\n} from \"./core/athos-application\";\n\nexport type { AthosManifest, AthosRunOptions };\nexport const AthosApplication = AthosApplicationDecorator;\nexport { AthosAppCore as Athos };\n"],"names":["AthosApplication","AthosApplicationDecorator"],"mappings":";;;;;;;;;;;;;;;;;;;AA0EO,MAAMA,mBAAmBC;;;;"}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var constants = require('@athosjs/constants');
|
|
4
|
+
var observability = require('@athosjs/observability');
|
|
5
|
+
|
|
6
|
+
function attachProObservability(application, options = {}) {
|
|
7
|
+
if (options.enabled === false && !options.logger && !options.telemetrySink) {
|
|
8
|
+
return application;
|
|
9
|
+
}
|
|
10
|
+
const hooks = createProObservabilityHooks(application.kernel, options);
|
|
11
|
+
if (Object.keys(hooks).length === 0) {
|
|
12
|
+
return application;
|
|
13
|
+
}
|
|
14
|
+
application.hooks(hooks);
|
|
15
|
+
return application;
|
|
16
|
+
}
|
|
17
|
+
function createProObservabilityHooks(kernel, options = {}) {
|
|
18
|
+
const logger = resolveLogger(kernel, options);
|
|
19
|
+
const telemetrySink = resolveTelemetrySink(kernel, options);
|
|
20
|
+
if (!logger && !telemetrySink) {
|
|
21
|
+
return {};
|
|
22
|
+
}
|
|
23
|
+
const emitTelemetry = createBufferedTelemetryEmitter(telemetrySink, logger, options.maxPendingTelemetryEvents ?? 1024);
|
|
24
|
+
const logRequests = options.logRequests ?? "errors";
|
|
25
|
+
const sampleRate = normalizeSampleRate(options.sampleRate);
|
|
26
|
+
const alwaysSampleErrors = options.alwaysSampleErrors ?? true;
|
|
27
|
+
return {
|
|
28
|
+
onRequest (context) {
|
|
29
|
+
const hasLogger = logRequests === "all" && logger;
|
|
30
|
+
const willSample = sampleRate > 0 && telemetrySink;
|
|
31
|
+
if (!hasLogger && !willSample) return;
|
|
32
|
+
if (willSample && sampleRate < 1 && Math.random() > sampleRate) return;
|
|
33
|
+
const attributes = createBaseRequestAttributes(context);
|
|
34
|
+
if (willSample) {
|
|
35
|
+
emitTelemetry({
|
|
36
|
+
name: "http.request.started",
|
|
37
|
+
timestamp: Date.now(),
|
|
38
|
+
attributes
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
if (hasLogger) {
|
|
42
|
+
logger.info(formatRequestLog("started", attributes));
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
onResponse (context, response) {
|
|
46
|
+
const hasLogger = logRequests === "all" && logger;
|
|
47
|
+
const willSample = sampleRate > 0 && telemetrySink;
|
|
48
|
+
if (!hasLogger && !willSample) return;
|
|
49
|
+
if (willSample && sampleRate < 1 && Math.random() > sampleRate) return;
|
|
50
|
+
const metrics = context.state.get(constants.ATHOS_STATE_KEYS.HTTP_REQUEST_METRICS);
|
|
51
|
+
const attributes = {
|
|
52
|
+
requestId: context.request.requestId,
|
|
53
|
+
method: context.originalRequest.method,
|
|
54
|
+
path: context.originalRequest.path,
|
|
55
|
+
status: response.status
|
|
56
|
+
};
|
|
57
|
+
if (metrics) {
|
|
58
|
+
if (metrics.durationMs !== undefined) attributes.durationMs = metrics.durationMs;
|
|
59
|
+
if (metrics.bodyBytes !== undefined) attributes.bodyBytes = metrics.bodyBytes;
|
|
60
|
+
if (metrics.aborted !== undefined) attributes.aborted = metrics.aborted;
|
|
61
|
+
}
|
|
62
|
+
attributes.phase = context.execution.phase;
|
|
63
|
+
if (willSample) {
|
|
64
|
+
emitTelemetry({
|
|
65
|
+
name: "http.request.completed",
|
|
66
|
+
timestamp: Date.now(),
|
|
67
|
+
attributes
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
if (hasLogger) {
|
|
71
|
+
logger.info(formatRequestLog("completed", attributes));
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
onError (context, error) {
|
|
75
|
+
const hasLogger = logRequests !== "none" && logger;
|
|
76
|
+
const willSample = sampleRate > 0 || alwaysSampleErrors;
|
|
77
|
+
if (!hasLogger && !willSample) return;
|
|
78
|
+
const havenError = error;
|
|
79
|
+
const attributes = {
|
|
80
|
+
requestId: context.request.requestId,
|
|
81
|
+
method: context.originalRequest.method,
|
|
82
|
+
path: context.originalRequest.path,
|
|
83
|
+
status: havenError?.status,
|
|
84
|
+
code: havenError?.code
|
|
85
|
+
};
|
|
86
|
+
if (willSample) {
|
|
87
|
+
const event = {
|
|
88
|
+
name: "http.request.failed",
|
|
89
|
+
timestamp: Date.now(),
|
|
90
|
+
level: "error",
|
|
91
|
+
attributes
|
|
92
|
+
};
|
|
93
|
+
if (shouldSampleEvent(event, sampleRate, alwaysSampleErrors)) {
|
|
94
|
+
emitTelemetry(event);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (hasLogger) {
|
|
98
|
+
logger.error(formatRequestLog("failed", attributes));
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
function normalizeSampleRate(value) {
|
|
104
|
+
if (value === undefined) {
|
|
105
|
+
return 1;
|
|
106
|
+
}
|
|
107
|
+
if (Number.isNaN(value) || value < 0) {
|
|
108
|
+
return 0;
|
|
109
|
+
}
|
|
110
|
+
if (value > 1) {
|
|
111
|
+
return 1;
|
|
112
|
+
}
|
|
113
|
+
return value;
|
|
114
|
+
}
|
|
115
|
+
function shouldSampleEvent(event, sampleRate, alwaysSampleErrors) {
|
|
116
|
+
if (alwaysSampleErrors && event.level === "error") {
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
if (sampleRate >= 1) {
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
if (sampleRate <= 0) {
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
return deterministicSample(event) < sampleRate;
|
|
126
|
+
}
|
|
127
|
+
function resolveLogger(kernel, options) {
|
|
128
|
+
if (options.logger) {
|
|
129
|
+
return options.logger;
|
|
130
|
+
}
|
|
131
|
+
if (kernel.services.has(observability.ATHOS_LOGGER_TOKEN)) {
|
|
132
|
+
return kernel.services.resolve(observability.ATHOS_LOGGER_TOKEN);
|
|
133
|
+
}
|
|
134
|
+
return undefined;
|
|
135
|
+
}
|
|
136
|
+
function resolveTelemetrySink(kernel, options) {
|
|
137
|
+
if (options.telemetrySink) {
|
|
138
|
+
return options.telemetrySink;
|
|
139
|
+
}
|
|
140
|
+
if (kernel.services.has(observability.ATHOS_TELEMETRY_SINK_TOKEN)) {
|
|
141
|
+
return kernel.services.resolve(observability.ATHOS_TELEMETRY_SINK_TOKEN);
|
|
142
|
+
}
|
|
143
|
+
return undefined;
|
|
144
|
+
}
|
|
145
|
+
function createBufferedTelemetryEmitter(sink, logger, maxPendingTelemetryEvents) {
|
|
146
|
+
if (!sink) {
|
|
147
|
+
return ()=>undefined;
|
|
148
|
+
}
|
|
149
|
+
return (event)=>{
|
|
150
|
+
if (sink.emitBatch) {
|
|
151
|
+
sink.emitBatch([
|
|
152
|
+
event
|
|
153
|
+
]);
|
|
154
|
+
} else {
|
|
155
|
+
sink.emit(event);
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
function createBaseRequestAttributes(context) {
|
|
160
|
+
return {
|
|
161
|
+
requestId: context.request.requestId,
|
|
162
|
+
method: context.originalRequest.method,
|
|
163
|
+
path: context.originalRequest.path,
|
|
164
|
+
...context.route?.operationId ? {
|
|
165
|
+
operationId: context.route.operationId
|
|
166
|
+
} : {},
|
|
167
|
+
phase: context.execution.phase
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
function formatRequestLog(stage, attributes) {
|
|
171
|
+
return `[${stage}] ${attributes.method} ${attributes.path} (${attributes.requestId})`;
|
|
172
|
+
}
|
|
173
|
+
function deterministicSample(event) {
|
|
174
|
+
const seed = [
|
|
175
|
+
event.name,
|
|
176
|
+
event.level ?? "info",
|
|
177
|
+
String(event.attributes?.requestId ?? ""),
|
|
178
|
+
String(event.attributes?.path ?? ""),
|
|
179
|
+
String(event.timestamp)
|
|
180
|
+
].join("|");
|
|
181
|
+
let hash = 2166136261;
|
|
182
|
+
for(let index = 0; index < seed.length; index += 1){
|
|
183
|
+
hash ^= seed.charCodeAt(index);
|
|
184
|
+
hash = Math.imul(hash, 16777619);
|
|
185
|
+
}
|
|
186
|
+
return (hash >>> 0) / 0xffffffff;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
exports.attachProObservability = attachProObservability;
|
|
190
|
+
exports.createProObservabilityHooks = createProObservabilityHooks;
|
|
191
|
+
//# sourceMappingURL=observability.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"observability.cjs","sources":["../../../packages/pro/src/observability.ts"],"sourcesContent":["import { ATHOS_STATE_KEYS } from \"@athosjs/constants\";\nimport type { ApplicationKernel } from \"@athosjs/core\";\nimport type { HttpContext, HttpHooks, HttpRequestMetrics } from \"@athosjs/http\";\nimport type { HttpApplication } from \"@athosjs/http/experimental\";\nimport {\n\ttype ExecutionTelemetryEvent,\n\ttype ExecutionTelemetrySink,\n\tATHOS_LOGGER_TOKEN,\n\tATHOS_TELEMETRY_SINK_TOKEN,\n\ttype AthosLogger,\n} from \"@athosjs/observability\";\nimport type { ProObservabilityOptions } from \"@athosjs/types/pro\";\n\nexport type { ProObservabilityOptions };\n\nexport function attachProObservability(\n\tapplication: HttpApplication,\n\toptions: ProObservabilityOptions = {},\n): HttpApplication {\n\tif (options.enabled === false && !options.logger && !options.telemetrySink) {\n\t\treturn application;\n\t}\n\tconst hooks = createProObservabilityHooks(application.kernel, options);\n\tif (Object.keys(hooks).length === 0) {\n\t\treturn application;\n\t}\n\tapplication.hooks(hooks);\n\treturn application;\n}\n\nexport function createProObservabilityHooks(\n\tkernel: ApplicationKernel,\n\toptions: ProObservabilityOptions = {},\n): HttpHooks {\n\tconst logger = resolveLogger(kernel, options);\n\tconst telemetrySink = resolveTelemetrySink(kernel, options);\n\tif (!logger && !telemetrySink) {\n\t\treturn {};\n\t}\n\tconst emitTelemetry = createBufferedTelemetryEmitter(\n\t\ttelemetrySink,\n\t\tlogger,\n\t\toptions.maxPendingTelemetryEvents ?? 1024,\n\t);\n\tconst logRequests = options.logRequests ?? \"errors\";\n\tconst sampleRate = normalizeSampleRate(options.sampleRate);\n\tconst alwaysSampleErrors = options.alwaysSampleErrors ?? true;\n\n\treturn {\n\t\tonRequest(context: HttpContext): void {\n\t\t\tconst hasLogger = logRequests === \"all\" && logger;\n\t\t\tconst willSample = sampleRate > 0 && telemetrySink;\n\n\t\t\tif (!hasLogger && !willSample) return;\n\n\t\t\tif (willSample && sampleRate < 1 && Math.random() > sampleRate) return;\n\n\t\t\tconst attributes = createBaseRequestAttributes(context);\n\n\t\t\tif (willSample) {\n\t\t\t\temitTelemetry({\n\t\t\t\t\tname: \"http.request.started\",\n\t\t\t\t\ttimestamp: Date.now(),\n\t\t\t\t\tattributes,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tif (hasLogger) {\n\t\t\t\tlogger.info(formatRequestLog(\"started\", attributes));\n\t\t\t}\n\t\t},\n\t\tonResponse(context: HttpContext, response): void {\n\t\t\tconst hasLogger = logRequests === \"all\" && logger;\n\t\t\tconst willSample = sampleRate > 0 && telemetrySink;\n\n\t\t\tif (!hasLogger && !willSample) return;\n\n\t\t\tif (willSample && sampleRate < 1 && Math.random() > sampleRate) return;\n\n\t\t\tconst metrics = (context.state as { get<T>(k: string | symbol): T | undefined }).get<HttpRequestMetrics>(\n\t\t\t\tATHOS_STATE_KEYS.HTTP_REQUEST_METRICS,\n\t\t\t);\n\t\t\tconst attributes: Record<string, unknown> = {\n\t\t\t\trequestId: context.request.requestId,\n\t\t\t\tmethod: context.originalRequest.method,\n\t\t\t\tpath: context.originalRequest.path,\n\t\t\t\tstatus: response.status,\n\t\t\t};\n\t\t\tif (metrics) {\n\t\t\t\tif (metrics.durationMs !== undefined) attributes.durationMs = metrics.durationMs;\n\t\t\t\tif (metrics.bodyBytes !== undefined) attributes.bodyBytes = metrics.bodyBytes;\n\t\t\t\tif (metrics.aborted !== undefined) attributes.aborted = metrics.aborted;\n\t\t\t}\n\t\t\tattributes.phase = context.execution.phase;\n\n\t\t\tif (willSample) {\n\t\t\t\temitTelemetry({\n\t\t\t\t\tname: \"http.request.completed\",\n\t\t\t\t\ttimestamp: Date.now(),\n\t\t\t\t\tattributes,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tif (hasLogger) {\n\t\t\t\tlogger.info(formatRequestLog(\"completed\", attributes));\n\t\t\t}\n\t\t},\n\t\tonError(context: HttpContext, error: unknown): void {\n\t\t\tconst hasLogger = logRequests !== \"none\" && logger;\n\t\t\tconst willSample = sampleRate > 0 || alwaysSampleErrors;\n\n\t\t\tif (!hasLogger && !willSample) return;\n\n\t\t\tconst havenError = error as Record<string, unknown>;\n\t\t\tconst attributes = {\n\t\t\t\trequestId: context.request.requestId,\n\t\t\t\tmethod: context.originalRequest.method,\n\t\t\t\tpath: context.originalRequest.path,\n\t\t\t\tstatus: havenError?.status,\n\t\t\t\tcode: havenError?.code,\n\t\t\t};\n\n\t\t\tif (willSample) {\n\t\t\t\tconst event: ExecutionTelemetryEvent = {\n\t\t\t\t\tname: \"http.request.failed\",\n\t\t\t\t\ttimestamp: Date.now(),\n\t\t\t\t\tlevel: \"error\",\n\t\t\t\t\tattributes,\n\t\t\t\t};\n\t\t\t\tif (shouldSampleEvent(event, sampleRate, alwaysSampleErrors)) {\n\t\t\t\t\temitTelemetry(event);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (hasLogger) {\n\t\t\t\tlogger.error(formatRequestLog(\"failed\", attributes));\n\t\t\t}\n\t\t},\n\t};\n}\n\nfunction normalizeSampleRate(value: number | undefined): number {\n\tif (value === undefined) {\n\t\treturn 1;\n\t}\n\n\tif (Number.isNaN(value) || value < 0) {\n\t\treturn 0;\n\t}\n\n\tif (value > 1) {\n\t\treturn 1;\n\t}\n\n\treturn value;\n}\n\nfunction shouldSampleEvent(event: ExecutionTelemetryEvent, sampleRate: number, alwaysSampleErrors: boolean): boolean {\n\tif (alwaysSampleErrors && event.level === \"error\") {\n\t\treturn true;\n\t}\n\n\tif (sampleRate >= 1) {\n\t\treturn true;\n\t}\n\n\tif (sampleRate <= 0) {\n\t\treturn false;\n\t}\n\n\treturn deterministicSample(event) < sampleRate;\n}\n\nfunction resolveLogger(kernel: ApplicationKernel, options: ProObservabilityOptions): AthosLogger | undefined {\n\tif (options.logger) {\n\t\treturn options.logger as AthosLogger;\n\t}\n\n\tif (kernel.services.has(ATHOS_LOGGER_TOKEN)) {\n\t\treturn kernel.services.resolve(ATHOS_LOGGER_TOKEN);\n\t}\n\n\treturn undefined;\n}\n\nfunction resolveTelemetrySink(\n\tkernel: ApplicationKernel,\n\toptions: ProObservabilityOptions,\n): ExecutionTelemetrySink | undefined {\n\tif (options.telemetrySink) {\n\t\treturn options.telemetrySink as ExecutionTelemetrySink;\n\t}\n\n\tif (kernel.services.has(ATHOS_TELEMETRY_SINK_TOKEN)) {\n\t\treturn kernel.services.resolve(ATHOS_TELEMETRY_SINK_TOKEN);\n\t}\n\n\treturn undefined;\n}\n\nfunction createBufferedTelemetryEmitter(\n\tsink: ExecutionTelemetrySink | undefined,\n\tlogger: AthosLogger | undefined,\n\tmaxPendingTelemetryEvents: number,\n): (event: ExecutionTelemetryEvent) => void {\n\tif (!sink) {\n\t\treturn () => undefined;\n\t}\n\n\treturn (event: ExecutionTelemetryEvent) => {\n\t\tif (sink.emitBatch) {\n\t\t\tsink.emitBatch([event]);\n\t\t} else {\n\t\t\tsink.emit(event);\n\t\t}\n\t};\n}\n\nasync function flushTelemetryQueue(\n\tsink: ExecutionTelemetrySink,\n\tevents: readonly ExecutionTelemetryEvent[],\n\tlogger?: AthosLogger,\n): Promise<void> {\n\ttry {\n\t\tif (sink.emitBatch) {\n\t\t\tawait sink.emitBatch(events);\n\t\t} else {\n\t\t\tfor (const event of events) {\n\t\t\t\tawait sink.emit(event);\n\t\t\t}\n\t\t}\n\t} catch (error) {\n\t\tlogger?.warn(\n\t\t\t\"Failed to flush telemetry batch.\",\n\t\t\terror instanceof Error ? error.message : String(error),\n\t\t\t`events: ${events.length}`,\n\t\t);\n\t}\n}\n\nfunction createBaseRequestAttributes(context: HttpContext): Record<string, unknown> {\n\treturn {\n\t\trequestId: context.request.requestId,\n\t\tmethod: context.originalRequest.method,\n\t\tpath: context.originalRequest.path,\n\t\t...(context.route?.operationId ? { operationId: context.route.operationId } : {}),\n\t\tphase: context.execution.phase,\n\t};\n}\n\nfunction formatRequestLog(stage: string, attributes: Record<string, unknown>): string {\n\treturn `[${stage}] ${attributes.method} ${attributes.path} (${attributes.requestId})`;\n}\n\nfunction deterministicSample(event: ExecutionTelemetryEvent): number {\n\tconst seed = [\n\t\tevent.name,\n\t\tevent.level ?? \"info\",\n\t\tString(event.attributes?.requestId ?? \"\"),\n\t\tString(event.attributes?.path ?? \"\"),\n\t\tString(event.timestamp),\n\t].join(\"|\");\n\tlet hash = 2166136261;\n\n\tfor (let index = 0; index < seed.length; index += 1) {\n\t\thash ^= seed.charCodeAt(index);\n\t\thash = Math.imul(hash, 16777619);\n\t}\n\n\treturn (hash >>> 0) / 0xffffffff;\n}\n"],"names":["attachProObservability","application","options","enabled","logger","telemetrySink","hooks","createProObservabilityHooks","kernel","Object","keys","length","resolveLogger","resolveTelemetrySink","emitTelemetry","createBufferedTelemetryEmitter","maxPendingTelemetryEvents","logRequests","sampleRate","normalizeSampleRate","alwaysSampleErrors","onRequest","context","hasLogger","willSample","Math","random","attributes","createBaseRequestAttributes","name","timestamp","Date","now","info","formatRequestLog","onResponse","response","metrics","state","get","ATHOS_STATE_KEYS","HTTP_REQUEST_METRICS","requestId","request","method","originalRequest","path","status","durationMs","undefined","bodyBytes","aborted","phase","execution","onError","error","havenError","code","event","level","shouldSampleEvent","value","Number","isNaN","deterministicSample","services","has","ATHOS_LOGGER_TOKEN","resolve","ATHOS_TELEMETRY_SINK_TOKEN","sink","emitBatch","emit","route","operationId","stage","seed","String","join","hash","index","charCodeAt","imul"],"mappings":";;;;;AAeO,SAASA,sBAAAA,CACfC,WAA4B,EAC5BC,OAAAA,GAAmC,EAAE,EAAA;IAErC,IAAIA,OAAAA,CAAQC,OAAO,KAAK,KAAA,IAAS,CAACD,OAAAA,CAAQE,MAAM,IAAI,CAACF,OAAAA,CAAQG,aAAa,EAAE;QAC3E,OAAOJ,WAAAA;AACR,IAAA;AACA,IAAA,MAAMK,KAAAA,GAAQC,2BAAAA,CAA4BN,WAAAA,CAAYO,MAAM,EAAEN,OAAAA,CAAAA;AAC9D,IAAA,IAAIO,OAAOC,IAAI,CAACJ,KAAAA,CAAAA,CAAOK,MAAM,KAAK,CAAA,EAAG;QACpC,OAAOV,WAAAA;AACR,IAAA;AACAA,IAAAA,WAAAA,CAAYK,KAAK,CAACA,KAAAA,CAAAA;IAClB,OAAOL,WAAAA;AACR;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,CAAWmB,IAAI,CAAC,EAAE,EAAEnB,WAAWe,SAAS,CAAC,CAAC,CAAC;AACtF;AAEA,SAASsB,oBAAoBN,KAA8B,EAAA;AAC1D,IAAA,MAAMkB,IAAAA,GAAO;AACZlB,QAAAA,KAAAA,CAAM7B,IAAI;AACV6B,QAAAA,KAAAA,CAAMC,KAAK,IAAI,MAAA;QACfkB,MAAAA,CAAOnB,KAAAA,CAAM/B,UAAU,EAAEe,SAAAA,IAAa,EAAA,CAAA;QACtCmC,MAAAA,CAAOnB,KAAAA,CAAM/B,UAAU,EAAEmB,IAAAA,IAAQ,EAAA,CAAA;AACjC+B,QAAAA,MAAAA,CAAOnB,MAAM5B,SAAS;AACtB,KAAA,CAACgD,IAAI,CAAC,GAAA,CAAA;AACP,IAAA,IAAIC,IAAAA,GAAO,UAAA;IAEX,IAAK,IAAIC,QAAQ,CAAA,EAAGA,KAAAA,GAAQJ,KAAKjE,MAAM,EAAEqE,SAAS,CAAA,CAAG;QACpDD,IAAAA,IAAQH,IAAAA,CAAKK,UAAU,CAACD,KAAAA,CAAAA;QACxBD,IAAAA,GAAOtD,IAAAA,CAAKyD,IAAI,CAACH,IAAAA,EAAM,QAAA,CAAA;AACxB,IAAA;AAEA,IAAA,OAAO,CAACA,IAAAA,KAAS,CAAA,IAAK,UAAA;AACvB;;;;;"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ApplicationKernel } from "@athosjs/core";
|
|
2
|
+
import type { HttpHooks } from "@athosjs/http";
|
|
3
|
+
import type { HttpApplication } from "@athosjs/http/experimental";
|
|
4
|
+
import type { ProObservabilityOptions } from "@athosjs/types/pro";
|
|
5
|
+
export type { ProObservabilityOptions };
|
|
6
|
+
export declare function attachProObservability(application: HttpApplication, options?: ProObservabilityOptions): HttpApplication;
|
|
7
|
+
export declare function createProObservabilityHooks(kernel: ApplicationKernel, options?: ProObservabilityOptions): HttpHooks;
|
|
8
|
+
//# sourceMappingURL=observability.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"observability.d.ts","sourceRoot":"","sources":["../../../../../../packages/pro/src/observability.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,KAAK,EAAe,SAAS,EAAsB,MAAM,eAAe,CAAC;AAChF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAQlE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAElE,YAAY,EAAE,uBAAuB,EAAE,CAAC;AAExC,wBAAgB,sBAAsB,CACrC,WAAW,EAAE,eAAe,EAC5B,OAAO,GAAE,uBAA4B,GACnC,eAAe,CAUjB;AAED,wBAAgB,2BAA2B,CAC1C,MAAM,EAAE,iBAAiB,EACzB,OAAO,GAAE,uBAA4B,GACnC,SAAS,CA0GX"}
|