@pristine-ts/networking 2.0.2 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/cjs/contexts/contexts.js +18 -0
- package/dist/lib/cjs/contexts/contexts.js.map +1 -0
- package/dist/lib/cjs/contexts/request-context.js +24 -0
- package/dist/lib/cjs/contexts/request-context.js.map +1 -0
- package/dist/lib/cjs/handlers/request.event-handler.js +2 -10
- package/dist/lib/cjs/handlers/request.event-handler.js.map +1 -1
- package/dist/lib/cjs/interceptors/body-mapping.request-interceptor.js +7 -0
- package/dist/lib/cjs/interceptors/body-mapping.request-interceptor.js.map +1 -1
- package/dist/lib/cjs/interceptors/default-content-type-response-header.interceptor.js +7 -0
- package/dist/lib/cjs/interceptors/default-content-type-response-header.interceptor.js.map +1 -1
- package/dist/lib/cjs/interceptors/error-response-sanitizer.request-interceptor.js +7 -0
- package/dist/lib/cjs/interceptors/error-response-sanitizer.request-interceptor.js.map +1 -1
- package/dist/lib/cjs/interceptors/request-body-converter.interceptor.js +9 -3
- package/dist/lib/cjs/interceptors/request-body-converter.interceptor.js.map +1 -1
- package/dist/lib/cjs/interceptors/response-headers.interceptor.js +10 -0
- package/dist/lib/cjs/interceptors/response-headers.interceptor.js.map +1 -1
- package/dist/lib/cjs/managers/managers.js +18 -0
- package/dist/lib/cjs/managers/managers.js.map +1 -0
- package/dist/lib/cjs/managers/request-context.manager.js +98 -0
- package/dist/lib/cjs/managers/request-context.manager.js.map +1 -0
- package/dist/lib/cjs/networking.module.js +2 -0
- package/dist/lib/cjs/networking.module.js.map +1 -1
- package/dist/lib/cjs/router.js +184 -155
- package/dist/lib/cjs/router.js.map +1 -1
- package/dist/lib/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/lib/esm/contexts/contexts.js +2 -0
- package/dist/lib/esm/contexts/contexts.js.map +1 -0
- package/dist/lib/esm/contexts/request-context.js +20 -0
- package/dist/lib/esm/contexts/request-context.js.map +1 -0
- package/dist/lib/esm/handlers/request.event-handler.js +2 -10
- package/dist/lib/esm/handlers/request.event-handler.js.map +1 -1
- package/dist/lib/esm/interceptors/body-mapping.request-interceptor.js +8 -1
- package/dist/lib/esm/interceptors/body-mapping.request-interceptor.js.map +1 -1
- package/dist/lib/esm/interceptors/default-content-type-response-header.interceptor.js +8 -1
- package/dist/lib/esm/interceptors/default-content-type-response-header.interceptor.js.map +1 -1
- package/dist/lib/esm/interceptors/error-response-sanitizer.request-interceptor.js +8 -1
- package/dist/lib/esm/interceptors/error-response-sanitizer.request-interceptor.js.map +1 -1
- package/dist/lib/esm/interceptors/request-body-converter.interceptor.js +10 -4
- package/dist/lib/esm/interceptors/request-body-converter.interceptor.js.map +1 -1
- package/dist/lib/esm/interceptors/response-headers.interceptor.js +11 -1
- package/dist/lib/esm/interceptors/response-headers.interceptor.js.map +1 -1
- package/dist/lib/esm/managers/managers.js +2 -0
- package/dist/lib/esm/managers/managers.js.map +1 -0
- package/dist/lib/esm/managers/request-context.manager.js +95 -0
- package/dist/lib/esm/managers/request-context.manager.js.map +1 -0
- package/dist/lib/esm/networking.module.js +2 -0
- package/dist/lib/esm/networking.module.js.map +1 -1
- package/dist/lib/esm/router.js +184 -155
- package/dist/lib/esm/router.js.map +1 -1
- package/dist/lib/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/types/contexts/contexts.d.ts +1 -0
- package/dist/types/contexts/request-context.d.ts +24 -0
- package/dist/types/handlers/request.event-handler.d.ts +2 -3
- package/dist/types/managers/managers.d.ts +1 -0
- package/dist/types/managers/request-context.manager.d.ts +43 -0
- package/dist/types/networking.module.d.ts +2 -0
- package/dist/types/router.d.ts +3 -1
- package/package.json +7 -7
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contexts.js","sourceRoot":"","sources":["../../../../src/contexts/contexts.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-HTTP-request state, scoped to the lifetime of one routed request. Layered
|
|
3
|
+
* **inside** the framework's `EventContext` (which holds `eventId`/`traceId`/`container`):
|
|
4
|
+
* a controller method running inside an HTTP request can read both the EventContext
|
|
5
|
+
* primitives and these networking-specific slots.
|
|
6
|
+
*
|
|
7
|
+
* Owned by `@pristine-ts/networking`. Apps that don't import the networking module
|
|
8
|
+
* never see this type — `Request`, `MethodRouterNode`, and `IdentityInterface` are
|
|
9
|
+
* concerns of HTTP-shaped flows, not of the framework as a whole.
|
|
10
|
+
*
|
|
11
|
+
* Populated incrementally as the router progresses through the request lifecycle:
|
|
12
|
+
* - `request` is set the moment the context is installed (route matching has
|
|
13
|
+
* succeeded by then; a 404 short-circuits before installation).
|
|
14
|
+
* - `methodNode` is set immediately after request (always together).
|
|
15
|
+
* - `identity` fills in once the authentication pipeline runs. Until then,
|
|
16
|
+
* downstream code that reads `identity` from the context sees `undefined`.
|
|
17
|
+
*/
|
|
18
|
+
export class RequestContext {
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=request-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-context.js","sourceRoot":"","sources":["../../../../src/contexts/request-context.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAO,cAAc;CAI1B"}
|
|
@@ -24,12 +24,11 @@ import { inject, injectable } from "tsyringe";
|
|
|
24
24
|
import { moduleScoped, Request, ServiceDefinitionTagEnum, tag } from "@pristine-ts/common";
|
|
25
25
|
import { NetworkingModuleKeyname } from "../networking.module.keyname";
|
|
26
26
|
let RequestEventHandler = class RequestEventHandler {
|
|
27
|
-
constructor(router, logHandler, tracingManager, dependencyContainer
|
|
27
|
+
constructor(router, logHandler, tracingManager, dependencyContainer) {
|
|
28
28
|
this.router = router;
|
|
29
29
|
this.logHandler = logHandler;
|
|
30
30
|
this.tracingManager = tracingManager;
|
|
31
31
|
this.dependencyContainer = dependencyContainer;
|
|
32
|
-
this.breadcrumbHandlerInterface = breadcrumbHandlerInterface;
|
|
33
32
|
this.priority = 10000; // Arbitrarily set to 10 000 so that another handler can have more priority, but be certain you know what you are doing.
|
|
34
33
|
}
|
|
35
34
|
supports(event) {
|
|
@@ -58,8 +57,6 @@ let RequestEventHandler = class RequestEventHandler {
|
|
|
58
57
|
extra: {
|
|
59
58
|
event,
|
|
60
59
|
},
|
|
61
|
-
eventId: event.id,
|
|
62
|
-
breadcrumb: `${NetworkingModuleKeyname}:request.event-handler:handle`,
|
|
63
60
|
});
|
|
64
61
|
const start = performance.now();
|
|
65
62
|
const response = yield this.router.execute(event.payload, this.dependencyContainer);
|
|
@@ -71,14 +68,10 @@ let RequestEventHandler = class RequestEventHandler {
|
|
|
71
68
|
responseBody: response.body,
|
|
72
69
|
responseHeaders: response.headers,
|
|
73
70
|
},
|
|
74
|
-
eventId: event.id,
|
|
75
71
|
extra: {
|
|
76
72
|
event,
|
|
77
73
|
response,
|
|
78
74
|
},
|
|
79
|
-
outputHints: {
|
|
80
|
-
outputBreadcrumbs: true,
|
|
81
|
-
}
|
|
82
75
|
});
|
|
83
76
|
//previous code:
|
|
84
77
|
// const requestSpan = tracingManager.startSpan(SpanKeynameEnum.RequestExecution);
|
|
@@ -94,8 +87,7 @@ RequestEventHandler = __decorate([
|
|
|
94
87
|
__param(1, inject("LogHandlerInterface")),
|
|
95
88
|
__param(2, inject("TracingManagerInterface")),
|
|
96
89
|
__param(3, inject(ServiceDefinitionTagEnum.CurrentChildContainer)),
|
|
97
|
-
|
|
98
|
-
__metadata("design:paramtypes", [Object, Object, Object, Object, Object])
|
|
90
|
+
__metadata("design:paramtypes", [Object, Object, Object, Object])
|
|
99
91
|
], RequestEventHandler);
|
|
100
92
|
export { RequestEventHandler };
|
|
101
93
|
//# sourceMappingURL=request.event-handler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.event-handler.js","sourceRoot":"","sources":["../../../../src/handlers/request.event-handler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAA+B,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAC9E,OAAO,EAAsB,MAAM,EAAE,UAAU,EAAC,MAAM,UAAU,CAAC;AAEjE,OAAO,EAAC,YAAY,EAAE,OAAO,EAAY,wBAAwB,EAAE,GAAG,EAAC,MAAM,qBAAqB,CAAC;AAEnG,OAAO,EAAC,uBAAuB,EAAC,MAAM,8BAA8B,CAAC;AAM9D,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAG9B,YAAuC,MAAwC,EACpC,UAAgD,EAC5C,cAAwD,EACnC,mBAAyD
|
|
1
|
+
{"version":3,"file":"request.event-handler.js","sourceRoot":"","sources":["../../../../src/handlers/request.event-handler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAA+B,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAC9E,OAAO,EAAsB,MAAM,EAAE,UAAU,EAAC,MAAM,UAAU,CAAC;AAEjE,OAAO,EAAC,YAAY,EAAE,OAAO,EAAY,wBAAwB,EAAE,GAAG,EAAC,MAAM,qBAAqB,CAAC;AAEnG,OAAO,EAAC,uBAAuB,EAAC,MAAM,8BAA8B,CAAC;AAM9D,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAG9B,YAAuC,MAAwC,EACpC,UAAgD,EAC5C,cAAwD,EACnC,mBAAyD;QAHrE,WAAM,GAAN,MAAM,CAAiB;QACnB,eAAU,GAAV,UAAU,CAAqB;QAC3B,mBAAc,GAAd,cAAc,CAAyB;QAClB,wBAAmB,GAAnB,mBAAmB,CAAqB;QAL7H,aAAQ,GAAW,KAAK,CAAC,CAAC,wHAAwH;IAOlJ,CAAC;IAED,QAAQ,CAAI,KAAe;QACzB,OAAO,KAAK,CAAC,OAAO,YAAY,OAAO,CAAC;IAC1C,CAAC;IAEK,MAAM,CAAC,KAAqB;;YAChC,8CAA8C;YAC9C,yCAAyC;Y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B,kFAAkF;YAElF,OAAO,IAAI,aAAa,CAAoB,KAAK,EAAE,QAAQ,CAAC,CAAC;QAC/D,CAAC;KAAA;CAEF,CAAA;AAlEY,mBAAmB;IAH/B,YAAY,CAAC,uBAAuB,CAAC;IACrC,GAAG,CAAC,wBAAwB,CAAC,YAAY,CAAC;IAC1C,UAAU,EAAE;IAIE,WAAA,MAAM,CAAC,iBAAiB,CAAC,CAAA;IACzB,WAAA,MAAM,CAAC,qBAAqB,CAAC,CAAA;IAC7B,WAAA,MAAM,CAAC,yBAAyB,CAAC,CAAA;IACjC,WAAA,MAAM,CAAC,wBAAwB,CAAC,qBAAqB,CAAC,CAAA;;GANxD,mBAAmB,CAkE/B"}
|
|
@@ -19,11 +19,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
19
19
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
20
|
});
|
|
21
21
|
};
|
|
22
|
-
import { moduleScoped, ServiceDefinitionTagEnum, tag } from "@pristine-ts/common";
|
|
22
|
+
import { moduleScoped, Request, ServiceDefinitionTagEnum, tag, traced } from "@pristine-ts/common";
|
|
23
23
|
import { inject, injectable } from "tsyringe";
|
|
24
24
|
import { NetworkingModuleKeyname } from "../networking.module.keyname";
|
|
25
25
|
import { DataMapper } from "@pristine-ts/data-mapping";
|
|
26
26
|
import { bodyMappingDecoratorMetadataKeyname } from "../decorators/body-mapping.decorator";
|
|
27
|
+
import { MethodRouterNode } from "../nodes/method-router.node";
|
|
27
28
|
import { RequestInterceptorPriorityEnum } from "../enums/request-interceptor-priority.enum";
|
|
28
29
|
/**
|
|
29
30
|
* This class is an interceptor that maps the body of an incoming request.
|
|
@@ -72,6 +73,12 @@ let BodyMappingRequestInterceptor = class BodyMappingRequestInterceptor {
|
|
|
72
73
|
});
|
|
73
74
|
}
|
|
74
75
|
};
|
|
76
|
+
__decorate([
|
|
77
|
+
traced(),
|
|
78
|
+
__metadata("design:type", Function),
|
|
79
|
+
__metadata("design:paramtypes", [Request, MethodRouterNode]),
|
|
80
|
+
__metadata("design:returntype", Promise)
|
|
81
|
+
], BodyMappingRequestInterceptor.prototype, "interceptRequest", null);
|
|
75
82
|
BodyMappingRequestInterceptor = __decorate([
|
|
76
83
|
moduleScoped(NetworkingModuleKeyname),
|
|
77
84
|
tag(ServiceDefinitionTagEnum.RequestInterceptor),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"body-mapping.request-interceptor.js","sourceRoot":"","sources":["../../../../src/interceptors/body-mapping.request-interceptor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAC,YAAY,
|
|
1
|
+
{"version":3,"file":"body-mapping.request-interceptor.js","sourceRoot":"","sources":["../../../../src/interceptors/body-mapping.request-interceptor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAC,YAAY,EAAE,OAAO,EAAE,wBAAwB,EAAE,GAAG,EAAE,MAAM,EAAC,MAAM,qBAAqB,CAAC;AACjG,OAAO,EAAC,MAAM,EAAE,UAAU,EAAC,MAAM,UAAU,CAAC;AAE5C,OAAO,EAAC,uBAAuB,EAAC,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAC,UAAU,EAAC,MAAM,2BAA2B,CAAC;AAMrD,OAAO,EAAC,mCAAmC,EAAC,MAAM,sCAAsC,CAAC;AAEzF,OAAO,EAAC,gBAAgB,EAAC,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAC,8BAA8B,EAAC,MAAM,4CAA4C,CAAC;AAE1F;;;;GAIG;AAII,IAAM,6BAA6B,GAAnC,MAAM,6BAA6B;IAGxC,YAA2C,UAAgD,EAC9D,UAAsB;QADS,eAAU,GAAV,UAAU,CAAqB;QAC9D,eAAU,GAAV,UAAU,CAAY;QAHnD,aAAQ,GAAG,8BAA8B,CAAC,WAAW,CAAC;IAItD,CAAC;IAED;;;;OAIG;IAEG,gBAAgB,CAAC,OAAgB,EAAE,UAA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,EAAE;IAIE,WAAA,MAAM,CAAC,qBAAqB,CAAC,CAAA;6CACD,UAAU;GAJxC,6BAA6B,CAgDzC"}
|
|
@@ -19,8 +19,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
19
19
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
20
|
});
|
|
21
21
|
};
|
|
22
|
-
import { moduleScoped, ServiceDefinitionTagEnum, tag } from "@pristine-ts/common";
|
|
22
|
+
import { moduleScoped, Request, Response, ServiceDefinitionTagEnum, tag, traced } from "@pristine-ts/common";
|
|
23
23
|
import { NetworkingModuleKeyname } from "../networking.module.keyname";
|
|
24
|
+
import { MethodRouterNode } from "../nodes/method-router.node";
|
|
24
25
|
import { inject, injectable } from "tsyringe";
|
|
25
26
|
import { RequestInterceptorPriorityEnum } from "../enums/request-interceptor-priority.enum";
|
|
26
27
|
/**
|
|
@@ -61,6 +62,12 @@ let DefaultContentTypeResponseHeaderInterceptor = class DefaultContentTypeRespon
|
|
|
61
62
|
});
|
|
62
63
|
}
|
|
63
64
|
};
|
|
65
|
+
__decorate([
|
|
66
|
+
traced(),
|
|
67
|
+
__metadata("design:type", Function),
|
|
68
|
+
__metadata("design:paramtypes", [Response, Request, MethodRouterNode]),
|
|
69
|
+
__metadata("design:returntype", Promise)
|
|
70
|
+
], DefaultContentTypeResponseHeaderInterceptor.prototype, "interceptResponse", null);
|
|
64
71
|
DefaultContentTypeResponseHeaderInterceptor = __decorate([
|
|
65
72
|
tag(ServiceDefinitionTagEnum.RequestInterceptor),
|
|
66
73
|
moduleScoped(NetworkingModuleKeyname),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default-content-type-response-header.interceptor.js","sourceRoot":"","sources":["../../../../src/interceptors/default-content-type-response-header.interceptor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAC,YAAY,
|
|
1
|
+
{"version":3,"file":"default-content-type-response-header.interceptor.js","s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M,EAAE;;qCACyB,QAAQ,EAAW,OAAO,EAAe,gBAAgB;;oFAa1F;AApCU,2CAA2C;IAHvD,GAAG,CAAC,wBAAwB,CAAC,kBAAkB,CAAC;IAChD,YAAY,CAAC,uBAAuB,CAAC;IACrC,UAAU,EAAE;IAYE,WAAA,MAAM,CAAC,IAAI,uBAAuB,oCAAoC,CAAC,CAAA;IACvE,WAAA,MAAM,CAAC,IAAI,uBAAuB,6CAA6C,CAAC,CAAA;IAChF,WAAA,MAAM,CAAC,qBAAqB,CAAC,CAAA;;GAb/B,2CAA2C,CAqCvD"}
|
|
@@ -21,7 +21,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
21
21
|
};
|
|
22
22
|
import { NetworkingModuleKeyname } from "../networking.module.keyname";
|
|
23
23
|
import { inject, injectable } from "tsyringe";
|
|
24
|
-
import { moduleScoped, ServiceDefinitionTagEnum, tag } from "@pristine-ts/common";
|
|
24
|
+
import { moduleScoped, Request, Response, ServiceDefinitionTagEnum, tag, traced } from "@pristine-ts/common";
|
|
25
|
+
import { MethodRouterNode } from "../nodes/method-router.node";
|
|
25
26
|
/**
|
|
26
27
|
* This Interceptor removes all stack, traces, etc.. before the response is returned. You can deactivate it using a config.
|
|
27
28
|
*/
|
|
@@ -40,6 +41,12 @@ let ErrorResponseSanitizerRequestInterceptor = class ErrorResponseSanitizerReque
|
|
|
40
41
|
});
|
|
41
42
|
}
|
|
42
43
|
};
|
|
44
|
+
__decorate([
|
|
45
|
+
traced(),
|
|
46
|
+
__metadata("design:type", Function),
|
|
47
|
+
__metadata("design:paramtypes", [Error, Response, Request, MethodRouterNode]),
|
|
48
|
+
__metadata("design:returntype", Promise)
|
|
49
|
+
], ErrorResponseSanitizerRequestInterceptor.prototype, "interceptError", null);
|
|
43
50
|
ErrorResponseSanitizerRequestInterceptor = __decorate([
|
|
44
51
|
tag(ServiceDefinitionTagEnum.RequestInterceptor),
|
|
45
52
|
moduleScoped(NetworkingModuleKeyname),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-response-sanitizer.request-interceptor.js","sourceRoot":"","sources":["../../../../src/interceptors/error-response-sanitizer.request-interceptor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AACA,OAAO,EAAC,uBAAuB,EAAC,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAC,MAAM,EAAE,UAAU,EAAC,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAC,YAAY,
|
|
1
|
+
{"version":3,"file":"error-response-sanitizer.request-interceptor.js","sourceRoot":"","sources":["../../../../src/interceptors/error-response-sanitizer.request-interceptor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AACA,OAAO,EAAC,uBAAuB,EAAC,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAC,MAAM,EAAE,UAAU,EAAC,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAC,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,wBAAwB,EAAE,GAAG,EAAE,MAAM,EAAC,MAAM,qBAAqB,CAAC;AAC3G,OAAO,EAAC,gBAAgB,EAAC,MAAM,6BAA6B,CAAC;AAE7D;;GAEG;AAII,IAAM,wCAAwC,GAA9C,MAAM,wCAAwC;IAEnD,YAC8F,QAAiB;QAAjB,aAAQ,GAAR,QAAQ,CAAS;IAE/G,CAAC;IAGK,cAAc,CAAC,KAAY,EAAE,QAAkB,EAAE,OAAgB,EAAE,UAA6B;;YACpG,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,CAAC,OAAO,QAAQ,CAAC,IAAI,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;gBAC3F,OAAO,QAAQ,CAAC;YAClB,CAAC;YAED,OAAO,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC;YAC3B,OAAO,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC;YAE3B,OAAO,QAAQ,CAAC;QAClB,CAAC;KAAA;CACF,CAAA;AAVO;IADL,MAAM,EAAE;;qCACmB,KAAK,EAAY,QAAQ,EAAW,OAAO,EAAe,gBAAgB;;8EASrG;AAjBU,wCAAwC;IAHpD,GAAG,CAAC,wBAAwB,CAAC,kBAAkB,CAAC;IAChD,YAAY,CAAC,uBAAuB,CAAC;IACrC,UAAU,EAAE;IAIR,WAAA,MAAM,CAAC,IAAI,uBAAuB,sCAAsC,CAAC,CAAA;;GAHjE,wCAAwC,CAkBpD"}
|
|
@@ -21,7 +21,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
21
21
|
};
|
|
22
22
|
import { inject, injectable } from "tsyringe";
|
|
23
23
|
import { NetworkingConfigurationKeys } from "../networking.configuration-keys";
|
|
24
|
-
import { injectConfig, moduleScoped, ServiceDefinitionTagEnum, tag } from "@pristine-ts/common";
|
|
24
|
+
import { injectConfig, moduleScoped, Request, ServiceDefinitionTagEnum, tag, traced } from "@pristine-ts/common";
|
|
25
25
|
import { NetworkingModuleKeyname } from "../networking.module.keyname";
|
|
26
26
|
import { InvalidBodyHttpError } from "../errors/invalid-body.http-error";
|
|
27
27
|
import { RequestInterceptorPriorityEnum } from "../enums/request-interceptor-priority.enum";
|
|
@@ -62,7 +62,7 @@ let RequestBodyConverterInterceptor = class RequestBodyConverterInterceptor {
|
|
|
62
62
|
case "object":
|
|
63
63
|
if (request.body.constructor === Date) {
|
|
64
64
|
const errorMessage = "RequestBodyConverterInterceptor: This request has the Content-Type header 'application/json' but the body is a Date object which is invalid JSON.";
|
|
65
|
-
this.logHandler.error(errorMessage
|
|
65
|
+
this.logHandler.error(errorMessage);
|
|
66
66
|
throw new InvalidBodyHttpError(errorMessage);
|
|
67
67
|
}
|
|
68
68
|
return request;
|
|
@@ -74,13 +74,13 @@ let RequestBodyConverterInterceptor = class RequestBodyConverterInterceptor {
|
|
|
74
74
|
}
|
|
75
75
|
catch (e) {
|
|
76
76
|
const errorMessage = "RequestBodyConverterInterceptor: This request has the Content-Type header 'application/json', and the body is of type string, but the body contains invalid JSON.";
|
|
77
|
-
this.logHandler.error(errorMessage
|
|
77
|
+
this.logHandler.error(errorMessage);
|
|
78
78
|
throw new InvalidBodyHttpError(errorMessage);
|
|
79
79
|
}
|
|
80
80
|
break;
|
|
81
81
|
default:
|
|
82
82
|
const errorMessage = "RequestBodyConverterInterceptor: This request has the Content-Type header 'application/json' but the body contains invalid JSON.";
|
|
83
|
-
this.logHandler.error(errorMessage
|
|
83
|
+
this.logHandler.error(errorMessage);
|
|
84
84
|
throw new InvalidBodyHttpError(errorMessage);
|
|
85
85
|
}
|
|
86
86
|
}
|
|
@@ -88,6 +88,12 @@ let RequestBodyConverterInterceptor = class RequestBodyConverterInterceptor {
|
|
|
88
88
|
});
|
|
89
89
|
}
|
|
90
90
|
};
|
|
91
|
+
__decorate([
|
|
92
|
+
traced(),
|
|
93
|
+
__metadata("design:type", Function),
|
|
94
|
+
__metadata("design:paramtypes", [Request]),
|
|
95
|
+
__metadata("design:returntype", Promise)
|
|
96
|
+
], RequestBodyConverterInterceptor.prototype, "interceptRequest", null);
|
|
91
97
|
RequestBodyConverterInterceptor = __decorate([
|
|
92
98
|
tag(ServiceDefinitionTagEnum.RequestInterceptor),
|
|
93
99
|
moduleScoped(NetworkingModuleKeyname),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request-body-converter.interceptor.js","sourceRoot":"","sources":["../../../../src/interceptors/request-body-converter.interceptor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAC,MAAM,EAAE,UAAU,EAAC,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAC,2BAA2B,EAAC,MAAM,kCAAkC,CAAC;AAE7E,OAAO,EAAC,YAAY,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"request-body-converter.interceptor.js","sourceRoot":"","sources":["../../../../src/interceptors/request-body-converter.interceptor.ts"],"names":[],"mappings":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,mJAAmJ,CAAC;gCACzK,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;gCAEpC,MAAM,IAAI,oBAAoB,CAAC,YAAY,CAAC,CAAC;4BAC/C,CAAC;4BACD,OAAO,OAAO,CAAC;wBAEjB,KAAK,QAAQ;4BACX,IAAI,CAAC;gCACH,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;oCACjB,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;gCAC1C,CAAC;4BACH,CAAC;4BAAC,OAAO,CAAC,EAAE,CAAC;gCACX,MAAM,YAAY,GAAG,mKAAmK,CAAC;gCACzL,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;gCAEpC,MAAM,IAAI,oBAAoB,CAAC,YAAY,CAAC,CAAC;4BAC/C,CAAC;4BACD,MAAM;wBAER;4BACE,MAAM,YAAY,GAAG,kIAAkI,CAAC;4BACxJ,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;4BAEpC,MAAM,IAAI,oBAAoB,CAAC,YAAY,CAAC,CAAC;oBACjD,CAAC;YAGL,CAAC;YAED,OAAO,OAAO,CAAC;QACjB,CAAC;KAAA;CAEF,CAAA;AArDO;IADL,MAAM,EAAE;;qCACuB,OAAO;;uEAmDtC;AAtEU,+BAA+B;IAH3C,GAAG,CAAC,wBAAwB,CAAC,kBAAkB,CAAC;IAChD,YAAY,CAAC,uBAAuB,CAAC;IACrC,UAAU,EAAE;IAWE,WAAA,YAAY,CAAC,2BAA2B,CAAC,4BAA4B,CAAC,CAAA;IACtE,WAAA,MAAM,CAAC,qBAAqB,CAAC,CAAA;;GAX/B,+BAA+B,CAwE3C"}
|
|
@@ -4,6 +4,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
7
10
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
8
11
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
9
12
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -13,8 +16,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
13
16
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
14
17
|
});
|
|
15
18
|
};
|
|
16
|
-
import { moduleScoped, ServiceDefinitionTagEnum, tag } from "@pristine-ts/common";
|
|
19
|
+
import { moduleScoped, Request, Response, ServiceDefinitionTagEnum, tag, traced } from "@pristine-ts/common";
|
|
17
20
|
import { NetworkingModuleKeyname } from "../networking.module.keyname";
|
|
21
|
+
import { MethodRouterNode } from "../nodes/method-router.node";
|
|
18
22
|
import { injectable } from "tsyringe";
|
|
19
23
|
import { responseHeaderMetadataKeyname } from "../decorators/response-header.decorator";
|
|
20
24
|
/**
|
|
@@ -37,6 +41,12 @@ let ResponseHeadersInterceptor = class ResponseHeadersInterceptor {
|
|
|
37
41
|
});
|
|
38
42
|
}
|
|
39
43
|
};
|
|
44
|
+
__decorate([
|
|
45
|
+
traced(),
|
|
46
|
+
__metadata("design:type", Function),
|
|
47
|
+
__metadata("design:paramtypes", [Response, Request, MethodRouterNode]),
|
|
48
|
+
__metadata("design:returntype", Promise)
|
|
49
|
+
], ResponseHeadersInterceptor.prototype, "interceptResponse", null);
|
|
40
50
|
ResponseHeadersInterceptor = __decorate([
|
|
41
51
|
tag(ServiceDefinitionTagEnum.RequestInterceptor),
|
|
42
52
|
moduleScoped(NetworkingModuleKeyname),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"response-headers.interceptor.js","sourceRoot":"","sources":["../../../../src/interceptors/response-headers.interceptor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"response-headers.interceptor.js","sourceRoot":"","sources":["../../../../src/interceptors/response-headers.interceptor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAC,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,wBAAwB,EAAE,GAAG,EAAE,MAAM,EAAC,MAAM,qBAAqB,CAAC;AAC3G,OAAO,EAAC,uBAAuB,EAAC,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAC,gBAAgB,EAAC,MAAM,6BAA6B,CAAC;AAE7D,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AACpC,OAAO,EAAC,6BAA6B,EAAC,MAAM,yCAAyC,CAAC;AAEtF;;;GAGG;AAII,IAAM,0BAA0B,GAAhC,MAAM,0BAA0B;IAErC;;;;;OAKG;IAEG,iBAAiB,CAAC,QAAkB,EAAE,OAAgB,EAAE,UAA6B;;YACzF,IAAI,UAAU,IAAI,UAAU,CAAC,KAAK,CAAC,OAAO,IAAI,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,6BAA6B,CAAC,EAAE,CAAC;gBACrH,QAAQ,CAAC,UAAU,iCAAK,QAAQ,CAAC,OAAO,GAAK,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,6BAA6B,CAAC,EAAE,CAAC;YACzG,CAAC;YAED,OAAO,QAAQ,CAAC;QAClB,CAAC;KAAA;CACF,CAAA;AAPO;IADL,MAAM,EAAE;;qCACyB,QAAQ,EAAW,OAAO,EAAe,gBAAgB;;mEAM1F;AAfU,0BAA0B;IAHtC,GAAG,CAAC,wBAAwB,CAAC,kBAAkB,CAAC;IAChD,YAAY,CAAC,uBAAuB,CAAC;IACrC,UAAU,EAAE;GACA,0BAA0B,CAgBtC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"managers.js","sourceRoot":"","sources":["../../../../src/managers/managers.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var RequestContextManager_1;
|
|
8
|
+
import { AsyncLocalStorage } from "async_hooks";
|
|
9
|
+
import { injectable } from "tsyringe";
|
|
10
|
+
import { EventContextManager } from "@pristine-ts/common";
|
|
11
|
+
/**
|
|
12
|
+
* Owns the `AsyncLocalStorage` instance that propagates the active `RequestContext`
|
|
13
|
+
* across `await` boundaries for HTTP-routed code.
|
|
14
|
+
*
|
|
15
|
+
* Nested inside the framework's `EventContext`: when the router installs a
|
|
16
|
+
* `RequestContext`, the surrounding `EventContext` (`eventId`/`traceId`/`container`)
|
|
17
|
+
* is still active, so application code inside a controller method can read both.
|
|
18
|
+
*
|
|
19
|
+
* Same shape as `EventContextManager` — `run` + read accessors + static convenience
|
|
20
|
+
* mirrors + `bind` for the background-work escape hatch.
|
|
21
|
+
*
|
|
22
|
+
* Application code outside the networking module never sees this manager. Code inside
|
|
23
|
+
* the networking module uses it to look up the active request without threading it
|
|
24
|
+
* through every method parameter.
|
|
25
|
+
*/
|
|
26
|
+
let RequestContextManager = RequestContextManager_1 = class RequestContextManager {
|
|
27
|
+
run(ctx, fn) {
|
|
28
|
+
return RequestContextManager_1.als.run(ctx, fn);
|
|
29
|
+
}
|
|
30
|
+
current() {
|
|
31
|
+
return RequestContextManager_1.als.getStore();
|
|
32
|
+
}
|
|
33
|
+
request() {
|
|
34
|
+
var _a;
|
|
35
|
+
return (_a = this.current()) === null || _a === void 0 ? void 0 : _a.request;
|
|
36
|
+
}
|
|
37
|
+
methodNode() {
|
|
38
|
+
var _a;
|
|
39
|
+
return (_a = this.current()) === null || _a === void 0 ? void 0 : _a.methodNode;
|
|
40
|
+
}
|
|
41
|
+
identity() {
|
|
42
|
+
var _a;
|
|
43
|
+
return (_a = this.current()) === null || _a === void 0 ? void 0 : _a.identity;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Convenience alias for `EventContextManager.eventId()`. The framework's correlation
|
|
47
|
+
* id (`eventId`) is the same value HTTP people often call "request id" — exposing it
|
|
48
|
+
* here as `requestId()` makes it discoverable next to `request()` / `identity()`
|
|
49
|
+
* without duplicating storage. There is no `RequestContext.requestId` field — the
|
|
50
|
+
* canonical slot lives on `EventContext` and we delegate at lookup time, so the two
|
|
51
|
+
* values can never drift.
|
|
52
|
+
*/
|
|
53
|
+
requestId() {
|
|
54
|
+
return EventContextManager.eventId();
|
|
55
|
+
}
|
|
56
|
+
bind(fn) {
|
|
57
|
+
const ctx = this.current();
|
|
58
|
+
if (ctx === undefined)
|
|
59
|
+
return fn;
|
|
60
|
+
const als = RequestContextManager_1.als;
|
|
61
|
+
return ((...args) => als.run(ctx, () => fn(...args)));
|
|
62
|
+
}
|
|
63
|
+
// ── Static convenience mirrors. ────────────────────────────────────────────────
|
|
64
|
+
static current() {
|
|
65
|
+
return RequestContextManager_1.als.getStore();
|
|
66
|
+
}
|
|
67
|
+
static request() {
|
|
68
|
+
var _a;
|
|
69
|
+
return (_a = RequestContextManager_1.current()) === null || _a === void 0 ? void 0 : _a.request;
|
|
70
|
+
}
|
|
71
|
+
static methodNode() {
|
|
72
|
+
var _a;
|
|
73
|
+
return (_a = RequestContextManager_1.current()) === null || _a === void 0 ? void 0 : _a.methodNode;
|
|
74
|
+
}
|
|
75
|
+
static identity() {
|
|
76
|
+
var _a;
|
|
77
|
+
return (_a = RequestContextManager_1.current()) === null || _a === void 0 ? void 0 : _a.identity;
|
|
78
|
+
}
|
|
79
|
+
static requestId() {
|
|
80
|
+
return EventContextManager.eventId();
|
|
81
|
+
}
|
|
82
|
+
static bind(fn) {
|
|
83
|
+
const ctx = RequestContextManager_1.current();
|
|
84
|
+
if (ctx === undefined)
|
|
85
|
+
return fn;
|
|
86
|
+
const als = RequestContextManager_1.als;
|
|
87
|
+
return ((...args) => als.run(ctx, () => fn(...args)));
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
RequestContextManager.als = new AsyncLocalStorage();
|
|
91
|
+
RequestContextManager = RequestContextManager_1 = __decorate([
|
|
92
|
+
injectable()
|
|
93
|
+
], RequestContextManager);
|
|
94
|
+
export { RequestContextManager };
|
|
95
|
+
//# sourceMappingURL=request-context.manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-context.manager.js","sourceRoot":"","sources":["../../../../src/managers/request-context.manager.ts"],"names":[],"mappings":";;;;;;;AAAA,OAAO,EAAC,iBAAiB,EAAC,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AACpC,OAAO,EAAC,mBAAmB,EAA6B,MAAM,qBAAqB,CAAC;AAIpF;;;;;;;;;;;;;;GAcG;AAEI,IAAM,qBAAqB,6BAA3B,MAAM,qBAAqB;IAKhC,GAAG,CAAI,GAAmB,EAAE,EAAwB;QAClD,OAAO,uBAAqB,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IAChD,CAAC;IAED,OAAO;QACL,OAAO,uBAAqB,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;IAC9C,CAAC;IAED,OAAO;;QACL,OAAO,MAAA,IAAI,CAAC,OA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5C,IAAI,GAAG,KAAK,SAAS;YAAE,OAAO,EAAE,CAAC;QACjC,MAAM,GAAG,GAAG,uBAAqB,CAAC,GAAG,CAAC;QACtC,OAAO,CAAC,CAAC,GAAG,IAAW,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAM,CAAC;IACpE,CAAC;;AAtEuB,yBAAG,GAAG,IAAI,iBAAiB,EAAkB,AAA1C,CAA2C;AAD3D,qBAAqB;IADjC,UAAU,EAAE;GACA,qBAAqB,CAwEjC"}
|
|
@@ -5,12 +5,14 @@ import { BooleanResolver, EnvironmentVariableResolver } from "@pristine-ts/confi
|
|
|
5
5
|
import { LoggingModule } from "@pristine-ts/logging";
|
|
6
6
|
import { DataMappingModule } from "@pristine-ts/data-mapping";
|
|
7
7
|
export * from "./cache/cache";
|
|
8
|
+
export * from "./contexts/contexts";
|
|
8
9
|
export * from "./decorators/decorators";
|
|
9
10
|
export * from "./enums/enums";
|
|
10
11
|
export * from "./errors/errors";
|
|
11
12
|
export * from "./handlers/handlers";
|
|
12
13
|
export * from "./interceptors/interceptors";
|
|
13
14
|
export * from "./interfaces/interfaces";
|
|
15
|
+
export * from "./managers/managers";
|
|
14
16
|
export * from "./mappers/mappers";
|
|
15
17
|
export * from "./models/models";
|
|
16
18
|
export * from "./nodes/nodes";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"networking.module.js","sourceRoot":"","sources":["../../../src/networking.module.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,uBAAuB,EAAC,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAC,cAAc,EAAC,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAC,eAAe,EAAC,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAC,eAAe,EAAE,2BAA2B,EAAC,MAAM,4BAA4B,CAAC;AACxF,OAAO,EAAC,aAAa,EAAC,MAAM,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AAuB;YAChE,UAAU,EAAE,KAAK;YACjB,YAAY,EAAE,KAAK;YACnB,gBAAgB,EAAE;gBAChB,IAAI,eAAe,CAAC,IAAI,2BAA2B,CAAC,4CAA4C,CAAC,CAAC;aACnG;SACF;QAED;;WAEG;QACH;YACE,aAAa,EAAE,uBAAuB,GAAG,qCAAqC;YAC9E,UAAU,EAAE,KAAK;YACjB,YAAY,EAAE,IAAI;YAClB,gBAAgB,EAAE;gBAChB,IAAI,eAAe,CAAC,IAAI,2BAA2B,CAAC,wDAAwD,CAAC,CAAC;aAC/G;SACF;KACF;CACF,CAAA"}
|
|
1
|
+
{"version":3,"file":"networking.module.js","sourceRoot":"","sources":["../../../src/networking.module.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,uBAAuB,EAAC,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAC,cAAc,EAAC,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAC,eAAe,EAAC,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAC,eAAe,EAAE,2BAA2B,EAAC,MAAM,4BAA4B,CAAC;AACxF,OAAO,EAAC,aAAa,EAAC,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAC,iBAAiB,EAAC,MAAM,2BAA2B,CAAC;AAE5D,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAE9B,cAAc,UAAU,CAAC;AAEzB,cAAc,iCAAiC,CAAC;AAChD,MAAM,CAAC,MAAM,gBAAgB,GAAoB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