@cryptexlabs/codex-nodejs-common 0.10.22 → 0.10.24
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/lib/package.json +2 -2
- package/lib/src/context/context.builder.d.ts +7 -2
- package/lib/src/context/context.builder.js +7 -1
- package/lib/src/context/context.builder.js.map +1 -1
- package/lib/src/context/context.d.ts +2 -1
- package/lib/src/context/context.js +3 -2
- package/lib/src/context/context.js.map +1 -1
- package/lib/src/message/message-meta.d.ts +4 -3
- package/lib/src/message/message-meta.js +2 -1
- package/lib/src/message/message-meta.js.map +1 -1
- package/package.json +2 -2
- package/src/context/context.builder.ts +15 -3
- package/src/context/context.ts +4 -2
- package/src/message/message-meta.ts +5 -2
package/lib/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cryptexlabs/codex-nodejs-common",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.24",
|
|
4
4
|
"description": "Common code for Codex framework",
|
|
5
5
|
"main": "lib/src/index.js",
|
|
6
6
|
"repository": "git@gitlab.com:cryptexlabs/public/codex-nodejs-common.git",
|
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
"Josh Woodcock <josh.woodcock@cryptexlabs.com>"
|
|
13
13
|
],
|
|
14
14
|
"peerDependencies": {
|
|
15
|
-
"@cryptexlabs/codex-data-model": "0.1.7",
|
|
16
15
|
"@elastic/elasticsearch": "8.15.0",
|
|
17
16
|
"@nestjs/common": "8.0.6",
|
|
18
17
|
"@nestjs/core": "8.0.6",
|
|
@@ -27,6 +26,7 @@
|
|
|
27
26
|
},
|
|
28
27
|
"dependencies": {
|
|
29
28
|
"@cryptexlabs/authf-data-model": "^0.9.9",
|
|
29
|
+
"@cryptexlabs/codex-data-model": "0.1.9",
|
|
30
30
|
"@cryptexlabs/merge-anything": "^6.0.6",
|
|
31
31
|
"@types/express": "4.17.8",
|
|
32
32
|
"@types/express-serve-static-core": "4.17.24",
|
|
@@ -11,11 +11,16 @@ export declare class ContextBuilder {
|
|
|
11
11
|
private locale;
|
|
12
12
|
private correlationId;
|
|
13
13
|
private started;
|
|
14
|
+
private _path?;
|
|
14
15
|
constructor(logger: LoggerService, config: DefaultConfig, client: ClientInterface, messageContext: MessageContextInterface, i18nDir?: string);
|
|
15
16
|
build(): ContextBuilder;
|
|
16
17
|
setI18nDir(i18nDir: string): this;
|
|
17
|
-
setMetaFromHeaders(headers: ApiMetaHeadersInterface
|
|
18
|
-
|
|
18
|
+
setMetaFromHeaders(headers: ApiMetaHeadersInterface & {
|
|
19
|
+
"x-forwarded-uri"?: string;
|
|
20
|
+
}): this;
|
|
21
|
+
setMetaFromHeadersForNewMessage(headers: ApiMetaHeadersInterface & {
|
|
22
|
+
"x-forwarded-uri"?: string;
|
|
23
|
+
}): this;
|
|
19
24
|
setMeta(meta: MessageMetaInterface): this;
|
|
20
25
|
setCorrelationId(correlationId: string): ContextBuilder;
|
|
21
26
|
setLocale(locale: LocaleInterface): this;
|
|
@@ -47,6 +47,9 @@ let ContextBuilder = ContextBuilder_1 = class ContextBuilder {
|
|
|
47
47
|
if (headers["x-client-variant"]) {
|
|
48
48
|
this.client.variant = headers["x-client-variant"];
|
|
49
49
|
}
|
|
50
|
+
if (headers["x-forwarded-uri"]) {
|
|
51
|
+
this._path = headers["x-forwarded-uri"];
|
|
52
|
+
}
|
|
50
53
|
return this;
|
|
51
54
|
}
|
|
52
55
|
setMetaFromHeadersForNewMessage(headers) {
|
|
@@ -59,6 +62,9 @@ let ContextBuilder = ContextBuilder_1 = class ContextBuilder {
|
|
|
59
62
|
if (headers["x-context-id"]) {
|
|
60
63
|
this.messageContext.id = headers["x-context-id"];
|
|
61
64
|
}
|
|
65
|
+
if (headers["x-forwarded-uri"]) {
|
|
66
|
+
this._path = headers["x-forwarded-uri"];
|
|
67
|
+
}
|
|
62
68
|
return this;
|
|
63
69
|
}
|
|
64
70
|
setMeta(meta) {
|
|
@@ -101,7 +107,7 @@ let ContextBuilder = ContextBuilder_1 = class ContextBuilder {
|
|
|
101
107
|
directory: this.i18nDir,
|
|
102
108
|
defaultLocale: local.i18n,
|
|
103
109
|
});
|
|
104
|
-
return new context_1.Context(this._getCorrelationId(), this.logger, this.config, this.client, this._getLocale(), this.messageContext, this._getStarted(), i18nInstance);
|
|
110
|
+
return new context_1.Context(this._getCorrelationId(), this.logger, this.config, this.client, this._getLocale(), this.messageContext, this._getStarted(), i18nInstance, this._path);
|
|
105
111
|
}
|
|
106
112
|
};
|
|
107
113
|
exports.ContextBuilder = ContextBuilder;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.builder.js","sourceRoot":"","sources":["../../../src/context/context.builder.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAA2D;AAC3D,oEAQuC;AACvC,sCAA0C;AAC1C,uCAAoC;AACpC,+BAAoC;AACpC,kCAAqC;AACrC,+BAA4B;AAGrB,IAAM,cAAc,sBAApB,MAAM,cAAc;
|
|
1
|
+
{"version":3,"file":"context.builder.js","sourceRoot":"","sources":["../../../src/context/context.builder.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAA2D;AAC3D,oEAQuC;AACvC,sCAA0C;AAC1C,uCAAoC;AACpC,+BAAoC;AACpC,kCAAqC;AACrC,+BAA4B;AAGrB,IAAM,cAAc,sBAApB,MAAM,cAAc;IAMzB,YACmB,MAAqB,EACrB,MAAqB,EAC/B,MAAuB,EACb,cAAuC,EAChD,OAAgB;QAJP,WAAM,GAAN,MAAM,CAAe;QACrB,WAAM,GAAN,MAAM,CAAe;QAC/B,WAAM,GAAN,MAAM,CAAiB;QACb,mBAAc,GAAd,cAAc,CAAyB;QAChD,YAAO,GAAP,OAAO,CAAS;IACvB,CAAC;IAEG,KAAK;QACV,OAAO,IAAI,gBAAc,CACvB,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,MAAM,oBACN,IAAI,CAAC,MAAM,qBACX,IAAI,CAAC,c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AC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAEO,WAAW;QACjB,OAAO,IAAI,CAAC,OAAO,IAAI,IAAI,IAAI,EAAE,CAAC;IACpC,CAAC;IAEO,iBAAiB;QACvB,OAAO,IAAI,CAAC,aAAa,IAAI,IAAA,SAAM,GAAE,CAAC;IACxC,CAAC;IAEO,UAAU;QAChB,OAAO,IAAI,CAAC,MAAM,IAAI,IAAI,yBAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC/C,CAAC;IAEM,SAAS;QACd,MAAM,YAAY,GAAG,IAAI,WAAI,EAAE,CAAC;QAChC,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;QAChC,YAAY,CAAC,SAAS,CAAC;YACrB,OAAO,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC;YACrB,SAAS,EAAE,IAAI,CAAC,OAAO;YACvB,aAAa,EAAE,KAAK,CAAC,IAAI;SAC1B,CAAC,CAAC;QAEH,OAAO,IAAI,iBAAO,CAChB,IAAI,CAAC,iBAAiB,EAAE,EACxB,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,UAAU,EAAE,EACjB,IAAI,CAAC,cAAc,EACnB,IAAI,CAAC,WAAW,EAAE,EAClB,YAAY,EACZ,IAAI,CAAC,KAAK,CACX,CAAC;IACJ,CAAC;CACF,CAAA;AAjIY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,mBAAU,GAAE;6CASgB,sBAAa;QACvB,kCAAe;GATrB,cAAc,CAiI1B"}
|
|
@@ -9,8 +9,9 @@ export declare class Context {
|
|
|
9
9
|
readonly locale: LocaleI18nInterface;
|
|
10
10
|
readonly messageContext: MessageContextInterface;
|
|
11
11
|
readonly i18n?: I18n;
|
|
12
|
+
private readonly _path?;
|
|
12
13
|
readonly logger: LoggerService;
|
|
13
14
|
started: Date;
|
|
14
|
-
constructor(correlationId: string, logger: LoggerService, config: DefaultConfig, client: ClientInterface, locale: LocaleI18nInterface, messageContext: MessageContextInterface, started?: Date, i18n?: I18n);
|
|
15
|
+
constructor(correlationId: string, logger: LoggerService, config: DefaultConfig, client: ClientInterface, locale: LocaleI18nInterface, messageContext: MessageContextInterface, started?: Date, i18n?: I18n, _path?: string);
|
|
15
16
|
getMessageMeta(type: string): MessageMetaInterface;
|
|
16
17
|
}
|
|
@@ -4,18 +4,19 @@ exports.Context = void 0;
|
|
|
4
4
|
const logger_1 = require("../logger");
|
|
5
5
|
const message_1 = require("../message");
|
|
6
6
|
class Context {
|
|
7
|
-
constructor(correlationId, logger, config, client, locale, messageContext, started, i18n) {
|
|
7
|
+
constructor(correlationId, logger, config, client, locale, messageContext, started, i18n, _path) {
|
|
8
8
|
this.correlationId = correlationId;
|
|
9
9
|
this.config = config;
|
|
10
10
|
this.client = client;
|
|
11
11
|
this.locale = locale;
|
|
12
12
|
this.messageContext = messageContext;
|
|
13
13
|
this.i18n = i18n;
|
|
14
|
+
this._path = _path;
|
|
14
15
|
this.logger = new logger_1.ContextLogger(correlationId, config, client, logger);
|
|
15
16
|
this.started = started || new Date(Date.now());
|
|
16
17
|
}
|
|
17
18
|
getMessageMeta(type) {
|
|
18
|
-
return new message_1.MessageMeta(type, this.locale, this.config, this.correlationId, this.started);
|
|
19
|
+
return new message_1.MessageMeta(type, this.locale, this.config, this.correlationId, this.started, this._path);
|
|
19
20
|
}
|
|
20
21
|
}
|
|
21
22
|
exports.Context = Context;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/context/context.ts"],"names":[],"mappings":";;;AAQA,sCAA0C;AAC1C,wCAAyC;AAGzC,MAAa,OAAO;IAIlB,YACS,aAAqB,EAC5B,MAAqB,EACd,MAAqB,EACrB,MAAuB,EACd,MAA2B,EAC3B,cAAuC,EACvD,OAAc,EACE,IAAW;
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/context/context.ts"],"names":[],"mappings":";;;AAQA,sCAA0C;AAC1C,wCAAyC;AAGzC,MAAa,OAAO;IAIlB,YACS,aAAqB,EAC5B,MAAqB,EACd,MAAqB,EACrB,MAAuB,EACd,MAA2B,EAC3B,cAAuC,EACvD,OAAc,EACE,IAAW,EACV,KAAc;QARxB,kBAAa,GAAb,aAAa,CAAQ;QAErB,WAAM,GAAN,MAAM,CAAe;QACrB,WAAM,GAAN,MAAM,CAAiB;QACd,WAAM,GAAN,MAAM,CAAqB;QAC3B,mBAAc,GAAd,cAAc,CAAyB;QAEvC,SAAI,GAAJ,IAAI,CAAO;QACV,UAAK,GAAL,KAAK,CAAS;QAE/B,IAAI,CAAC,MAAM,GAAG,IAAI,sBAAa,CAAC,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QACvE,IAAI,CAAC,OAAO,GAAG,OAAO,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;IACjD,CAAC;IAED,cAAc,CAAC,IAAY;QACzB,OAAO,IAAI,qBAAW,CACpB,IAAI,EACJ,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,aAAa,EAClB,IAAI,CAAC,OAAO,EACZ,IAAI,CAAC,KAAK,CACX,CAAC;IACJ,CAAC;CACF;AA7BD,0BA6BC"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { ClientInterface, LocaleInterface, MessageContextInterface, MessageMetaInterface, MetaTimeInterface } from "@cryptexlabs/codex-data-model";
|
|
1
|
+
import { ClientInterface, LocaleInterface, MessageContextInterface, MessageMetaHttpInterface, MessageMetaInterface, MetaTimeInterface } from "@cryptexlabs/codex-data-model";
|
|
2
2
|
import { DefaultConfig } from "../config";
|
|
3
3
|
import { JsonSerializableInterface } from "./json-serializable.interface";
|
|
4
|
-
export declare class MessageMeta implements MessageMetaInterface, JsonSerializableInterface<MessageMetaInterface
|
|
4
|
+
export declare class MessageMeta implements MessageMetaInterface, JsonSerializableInterface<MessageMetaInterface>, MessageMetaHttpInterface {
|
|
5
5
|
readonly type: string;
|
|
6
6
|
readonly locale: LocaleInterface;
|
|
7
7
|
private readonly started?;
|
|
8
|
+
path?: any;
|
|
8
9
|
time: MetaTimeInterface;
|
|
9
10
|
context: MessageContextInterface;
|
|
10
11
|
interactionId: string | null;
|
|
@@ -12,6 +13,6 @@ export declare class MessageMeta implements MessageMetaInterface, JsonSerializab
|
|
|
12
13
|
private _correlationId;
|
|
13
14
|
get correlationId(): string;
|
|
14
15
|
client: ClientInterface;
|
|
15
|
-
constructor(type: string, locale: LocaleInterface, config: DefaultConfig, correlationId?: string, started?: Date);
|
|
16
|
+
constructor(type: string, locale: LocaleInterface, config: DefaultConfig, correlationId?: string, started?: Date, path?: any);
|
|
16
17
|
toJSON(): MessageMetaInterface;
|
|
17
18
|
}
|
|
@@ -11,10 +11,11 @@ class MessageMeta {
|
|
|
11
11
|
}
|
|
12
12
|
return this._correlationId;
|
|
13
13
|
}
|
|
14
|
-
constructor(type, locale, config, correlationId, started) {
|
|
14
|
+
constructor(type, locale, config, correlationId, started, path) {
|
|
15
15
|
this.type = type;
|
|
16
16
|
this.locale = locale;
|
|
17
17
|
this.started = started;
|
|
18
|
+
this.path = path;
|
|
18
19
|
const now = new Date(Date.now());
|
|
19
20
|
const start = started || now;
|
|
20
21
|
this.time = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message-meta.js","sourceRoot":"","sources":["../../../src/message/message-meta.ts"],"names":[],"mappings":";;;AAAA,+BAAoC;AACpC,
|
|
1
|
+
{"version":3,"file":"message-meta.js","sourceRoot":"","sources":["../../../src/message/message-meta.ts"],"names":[],"mappings":";;;AAAA,+BAAoC;AACpC,oEAQuC;AACvC,sCAA0C;AAI1C,MAAa,WAAW;IAmBtB,IAAW,aAAa;QACtB,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC;YACzB,IAAI,CAAC,cAAc,GAAG,IAAA,SAA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": "@cryptexlabs/codex-nodejs-common",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.24",
|
|
4
4
|
"description": "Common code for Codex framework",
|
|
5
5
|
"main": "lib/src/index.js",
|
|
6
6
|
"repository": "git@gitlab.com:cryptexlabs/public/codex-nodejs-common.git",
|
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
"Josh Woodcock <josh.woodcock@cryptexlabs.com>"
|
|
13
13
|
],
|
|
14
14
|
"peerDependencies": {
|
|
15
|
-
"@cryptexlabs/codex-data-model": "0.1.7",
|
|
16
15
|
"@elastic/elasticsearch": "8.15.0",
|
|
17
16
|
"@nestjs/common": "8.0.6",
|
|
18
17
|
"@nestjs/core": "8.0.6",
|
|
@@ -27,6 +26,7 @@
|
|
|
27
26
|
},
|
|
28
27
|
"dependencies": {
|
|
29
28
|
"@cryptexlabs/authf-data-model": "^0.9.9",
|
|
29
|
+
"@cryptexlabs/codex-data-model": "0.1.9",
|
|
30
30
|
"@cryptexlabs/merge-anything": "^6.0.6",
|
|
31
31
|
"@types/express": "4.17.8",
|
|
32
32
|
"@types/express-serve-static-core": "4.17.24",
|
|
@@ -19,6 +19,7 @@ export class ContextBuilder {
|
|
|
19
19
|
private locale: LocaleI18nInterface;
|
|
20
20
|
private correlationId: string;
|
|
21
21
|
private started: Date;
|
|
22
|
+
private _path?: string;
|
|
22
23
|
|
|
23
24
|
constructor(
|
|
24
25
|
private readonly logger: LoggerService,
|
|
@@ -43,7 +44,9 @@ export class ContextBuilder {
|
|
|
43
44
|
return this;
|
|
44
45
|
}
|
|
45
46
|
|
|
46
|
-
public setMetaFromHeaders(
|
|
47
|
+
public setMetaFromHeaders(
|
|
48
|
+
headers: ApiMetaHeadersInterface & { "x-forwarded-uri"?: string }
|
|
49
|
+
) {
|
|
47
50
|
this.setMetaFromHeadersForNewMessage(headers);
|
|
48
51
|
if (headers["x-client-version"]) {
|
|
49
52
|
this.client.version = headers["x-client-version"];
|
|
@@ -57,11 +60,16 @@ export class ContextBuilder {
|
|
|
57
60
|
if (headers["x-client-variant"]) {
|
|
58
61
|
this.client.variant = headers["x-client-variant"];
|
|
59
62
|
}
|
|
63
|
+
if (headers["x-forwarded-uri"]) {
|
|
64
|
+
this._path = headers["x-forwarded-uri"];
|
|
65
|
+
}
|
|
60
66
|
|
|
61
67
|
return this;
|
|
62
68
|
}
|
|
63
69
|
|
|
64
|
-
public setMetaFromHeadersForNewMessage(
|
|
70
|
+
public setMetaFromHeadersForNewMessage(
|
|
71
|
+
headers: ApiMetaHeadersInterface & { "x-forwarded-uri"?: string }
|
|
72
|
+
) {
|
|
65
73
|
this.setCorrelationId(headers["x-correlation-id"]);
|
|
66
74
|
this.setLocale(LocaleUtil.getLocaleFromHeaders(headers, this.getResult()));
|
|
67
75
|
this.setStarted(headers["x-started"]);
|
|
@@ -71,6 +79,9 @@ export class ContextBuilder {
|
|
|
71
79
|
if (headers["x-context-id"]) {
|
|
72
80
|
this.messageContext.id = headers["x-context-id"];
|
|
73
81
|
}
|
|
82
|
+
if (headers["x-forwarded-uri"]) {
|
|
83
|
+
this._path = headers["x-forwarded-uri"];
|
|
84
|
+
}
|
|
74
85
|
return this;
|
|
75
86
|
}
|
|
76
87
|
|
|
@@ -129,7 +140,8 @@ export class ContextBuilder {
|
|
|
129
140
|
this._getLocale(),
|
|
130
141
|
this.messageContext,
|
|
131
142
|
this._getStarted(),
|
|
132
|
-
i18nInstance
|
|
143
|
+
i18nInstance,
|
|
144
|
+
this._path
|
|
133
145
|
);
|
|
134
146
|
}
|
|
135
147
|
}
|
package/src/context/context.ts
CHANGED
|
@@ -22,7 +22,8 @@ export class Context {
|
|
|
22
22
|
public readonly locale: LocaleI18nInterface,
|
|
23
23
|
public readonly messageContext: MessageContextInterface,
|
|
24
24
|
started?: Date,
|
|
25
|
-
public readonly i18n?: I18n
|
|
25
|
+
public readonly i18n?: I18n,
|
|
26
|
+
private readonly _path?: string
|
|
26
27
|
) {
|
|
27
28
|
this.logger = new ContextLogger(correlationId, config, client, logger);
|
|
28
29
|
this.started = started || new Date(Date.now());
|
|
@@ -34,7 +35,8 @@ export class Context {
|
|
|
34
35
|
this.locale,
|
|
35
36
|
this.config,
|
|
36
37
|
this.correlationId,
|
|
37
|
-
this.started
|
|
38
|
+
this.started,
|
|
39
|
+
this._path
|
|
38
40
|
);
|
|
39
41
|
}
|
|
40
42
|
}
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
ClientInterface,
|
|
4
4
|
LocaleInterface,
|
|
5
5
|
MessageContextInterface,
|
|
6
|
+
MessageMetaHttpInterface,
|
|
6
7
|
MessageMetaInterface,
|
|
7
8
|
MetaTimeInterface,
|
|
8
9
|
Version,
|
|
@@ -14,7 +15,8 @@ import { JsonSerializableInterface } from "./json-serializable.interface";
|
|
|
14
15
|
export class MessageMeta
|
|
15
16
|
implements
|
|
16
17
|
MessageMetaInterface,
|
|
17
|
-
JsonSerializableInterface<MessageMetaInterface
|
|
18
|
+
JsonSerializableInterface<MessageMetaInterface>,
|
|
19
|
+
MessageMetaHttpInterface {
|
|
18
20
|
//
|
|
19
21
|
time: MetaTimeInterface;
|
|
20
22
|
|
|
@@ -43,7 +45,8 @@ export class MessageMeta
|
|
|
43
45
|
public readonly locale: LocaleInterface,
|
|
44
46
|
config: DefaultConfig,
|
|
45
47
|
correlationId?: string,
|
|
46
|
-
private readonly started?: Date
|
|
48
|
+
private readonly started?: Date,
|
|
49
|
+
public path?
|
|
47
50
|
) {
|
|
48
51
|
const now = new Date(Date.now());
|
|
49
52
|
const start = started || now;
|