1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.ContextIdFactory = exports.createContextId = void 0;
|
4 | const request_constants_1 = require("../router/request/request-constants");
|
5 | function createContextId() {
|
6 | |
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 | return { id: Math.random() };
|
15 | }
|
16 | exports.createContextId = createContextId;
|
17 | class ContextIdFactory {
|
18 | |
19 |
|
20 |
|
21 | static create() {
|
22 | return createContextId();
|
23 | }
|
24 | |
25 |
|
26 |
|
27 |
|
28 | static getByRequest(request, propsToInspect = ['raw']) {
|
29 | var _a;
|
30 | if (!request) {
|
31 | return ContextIdFactory.create();
|
32 | }
|
33 | if (request[request_constants_1.REQUEST_CONTEXT_ID]) {
|
34 | return request[request_constants_1.REQUEST_CONTEXT_ID];
|
35 | }
|
36 | for (const key of propsToInspect) {
|
37 | if ((_a = request[key]) === null || _a === void 0 ? void 0 : _a[request_constants_1.REQUEST_CONTEXT_ID]) {
|
38 | return request[key][request_constants_1.REQUEST_CONTEXT_ID];
|
39 | }
|
40 | }
|
41 | return ContextIdFactory.create();
|
42 | }
|
43 | }
|
44 | exports.ContextIdFactory = ContextIdFactory;
|