sdk-logs 0.6.12 → 0.7.0
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/domain.objects/LogTrail.d.ts +20 -4
- package/dist/domain.operations/formatLogContentsForEnvironment.d.ts +20 -1
- package/dist/domain.operations/formatLogContentsForEnvironment.js +22 -6
- package/dist/domain.operations/formatLogContentsForEnvironment.js.map +1 -1
- package/dist/domain.operations/genContextLogTrail.d.ts +28 -0
- package/dist/domain.operations/genContextLogTrail.js +58 -0
- package/dist/domain.operations/genContextLogTrail.js.map +1 -0
- package/dist/domain.operations/{generateLogMethods.d.ts → genLogMethods.d.ts} +7 -1
- package/dist/domain.operations/{generateLogMethods.js → genLogMethods.js} +5 -4
- package/dist/domain.operations/genLogMethods.js.map +1 -0
- package/dist/domain.operations/generateLogMethod.d.ts +6 -1
- package/dist/domain.operations/generateLogMethod.js +3 -1
- package/dist/domain.operations/generateLogMethod.js.map +1 -1
- package/dist/domain.operations/withLogTrail.d.ts +1 -1
- package/dist/domain.operations/withLogTrail.js +58 -26
- package/dist/domain.operations/withLogTrail.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/package.json +34 -32
- package/dist/domain.operations/generateLogMethods.js.map +0 -1
|
@@ -1,20 +1,36 @@
|
|
|
1
1
|
import type { Procedure, ProcedureContext } from 'domain-glossary-procedure';
|
|
2
|
-
import type { LogMethods } from '../domain.operations/
|
|
2
|
+
import type { LogMethods } from '../domain.operations/genLogMethods';
|
|
3
3
|
/**
|
|
4
|
-
* .what = the procedure invocation trail
|
|
4
|
+
* .what = the procedure invocation trail with external identifier
|
|
5
5
|
*/
|
|
6
|
-
export
|
|
6
|
+
export interface LogTrail {
|
|
7
|
+
/**
|
|
8
|
+
* .what = external identifier for request correlation
|
|
9
|
+
* .why = enables log correlation across a single request
|
|
10
|
+
*/
|
|
11
|
+
exid: string | null;
|
|
12
|
+
/**
|
|
13
|
+
* .what = the procedure call stack
|
|
14
|
+
* .why = tracks call depth through withLogTrail wraps
|
|
15
|
+
*/
|
|
16
|
+
stack: string[];
|
|
17
|
+
}
|
|
7
18
|
export interface ContextLogTrail {
|
|
8
19
|
/**
|
|
9
20
|
* .what = the log context which can be used; methods, trail, etc
|
|
10
21
|
*/
|
|
11
22
|
log: LogMethods & {
|
|
12
23
|
_orig?: LogMethods;
|
|
13
|
-
} & {
|
|
14
24
|
/**
|
|
15
25
|
* .what = the log trail which has been collected
|
|
16
26
|
*/
|
|
17
27
|
trail?: LogTrail;
|
|
28
|
+
/**
|
|
29
|
+
* .what = environment context for log output
|
|
30
|
+
*/
|
|
31
|
+
env?: {
|
|
32
|
+
commit: string;
|
|
33
|
+
};
|
|
18
34
|
};
|
|
19
35
|
}
|
|
20
36
|
export type HasContextLogTrail<T extends Procedure> = ProcedureContext<T> extends ContextLogTrail ? T : never;
|
|
@@ -1,15 +1,34 @@
|
|
|
1
1
|
import { type LogLevel } from '../domain.objects/constants';
|
|
2
|
-
|
|
2
|
+
import type { LogTrail } from '../domain.objects/LogTrail';
|
|
3
|
+
export declare const formatLogContentsForEnvironment: ({ level, timestamp, message, metadata, trail, env, }: {
|
|
3
4
|
level: LogLevel;
|
|
4
5
|
timestamp: string;
|
|
5
6
|
message: string;
|
|
6
7
|
metadata?: Record<string, any>;
|
|
8
|
+
trail?: LogTrail;
|
|
9
|
+
env?: {
|
|
10
|
+
commit: string;
|
|
11
|
+
};
|
|
7
12
|
}) => string | {
|
|
13
|
+
env?: {
|
|
14
|
+
commit: string;
|
|
15
|
+
} | undefined;
|
|
16
|
+
trail?: {
|
|
17
|
+
stack: string[];
|
|
18
|
+
exid?: string | undefined;
|
|
19
|
+
} | undefined;
|
|
8
20
|
level: LogLevel;
|
|
9
21
|
timestamp: string;
|
|
10
22
|
message: string;
|
|
11
23
|
metadata: string;
|
|
12
24
|
} | {
|
|
25
|
+
env?: {
|
|
26
|
+
commit: string;
|
|
27
|
+
} | undefined;
|
|
28
|
+
trail?: {
|
|
29
|
+
stack: string[];
|
|
30
|
+
exid?: string | undefined;
|
|
31
|
+
} | undefined;
|
|
13
32
|
level: LogLevel;
|
|
14
33
|
timestamp: string;
|
|
15
34
|
message: string;
|
|
@@ -1,39 +1,55 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.formatLogContentsForEnvironment = void 0;
|
|
4
|
+
const helpful_errors_1 = require("helpful-errors");
|
|
4
5
|
const constants_1 = require("../domain.objects/constants");
|
|
5
6
|
const identifyEnvironment_1 = require("./identifyEnvironment");
|
|
6
|
-
const formatLogContentsForEnvironment = ({ level, timestamp, message, metadata, }) => {
|
|
7
|
-
const
|
|
7
|
+
const formatLogContentsForEnvironment = ({ level, timestamp, message, metadata, trail, env, }) => {
|
|
8
|
+
const environment = (0, identifyEnvironment_1.identifyEnvironment)();
|
|
9
|
+
// build trail output: omit if not provided, omit exid if null
|
|
10
|
+
const trailOutput = trail
|
|
11
|
+
? {
|
|
12
|
+
...(trail.exid !== null ? { exid: trail.exid } : {}),
|
|
13
|
+
stack: trail.stack,
|
|
14
|
+
}
|
|
15
|
+
: undefined;
|
|
16
|
+
// build env output: omit if not provided or commit is null
|
|
17
|
+
const envOutput = env?.commit ? { commit: env.commit } : undefined;
|
|
8
18
|
// if its a "local" environment, then dont stringify the contents - but stringify the metadata to cut down on visual noise
|
|
9
|
-
if (
|
|
19
|
+
if (environment === constants_1.SupportedEnvironment.LOCAL) {
|
|
10
20
|
return {
|
|
11
21
|
level,
|
|
12
22
|
timestamp,
|
|
13
23
|
message,
|
|
14
24
|
metadata: JSON.stringify(metadata), // json stringify it to cut down on the visual noise in the console
|
|
25
|
+
...(trailOutput ? { trail: trailOutput } : {}),
|
|
26
|
+
...(envOutput ? { env: envOutput } : {}),
|
|
15
27
|
};
|
|
16
28
|
}
|
|
17
29
|
// if its an aws-lambda environment, then stringify the contents - without stringifying the metadata - to make sure log is fully readable and parseable by cloudwatch
|
|
18
|
-
if (
|
|
30
|
+
if (environment === constants_1.SupportedEnvironment.AWS_LAMBDA) {
|
|
19
31
|
return JSON.stringify({
|
|
20
32
|
level,
|
|
21
33
|
timestamp,
|
|
22
34
|
message,
|
|
23
35
|
metadata,
|
|
36
|
+
...(trailOutput ? { trail: trailOutput } : {}),
|
|
37
|
+
...(envOutput ? { env: envOutput } : {}),
|
|
24
38
|
});
|
|
25
39
|
}
|
|
26
40
|
// if its a web-browser environment, then dont stringify the contents - nor the metadata - to make sure log is fully accessible through console devtools
|
|
27
|
-
if (
|
|
41
|
+
if (environment === constants_1.SupportedEnvironment.WEB_BROWSER) {
|
|
28
42
|
return {
|
|
29
43
|
level,
|
|
30
44
|
timestamp,
|
|
31
45
|
message,
|
|
32
46
|
metadata,
|
|
47
|
+
...(trailOutput ? { trail: trailOutput } : {}),
|
|
48
|
+
...(envOutput ? { env: envOutput } : {}),
|
|
33
49
|
};
|
|
34
50
|
}
|
|
35
51
|
// if it was not one of the above, we have not supported this environment yet
|
|
36
|
-
throw new
|
|
52
|
+
throw new helpful_errors_1.UnexpectedCodePathError('unsupported environment detected. this should never occur - and is a bug within sdk-logs');
|
|
37
53
|
};
|
|
38
54
|
exports.formatLogContentsForEnvironment = formatLogContentsForEnvironment;
|
|
39
55
|
//# sourceMappingURL=formatLogContentsForEnvironment.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatLogContentsForEnvironment.js","sourceRoot":"","sources":["../../src/domain.operations/formatLogContentsForEnvironment.ts"],"names":[],"mappings":";;;AAAA,6DAGuC;
|
|
1
|
+
{"version":3,"file":"formatLogContentsForEnvironment.js","sourceRoot":"","sources":["../../src/domain.operations/formatLogContentsForEnvironment.ts"],"names":[],"mappings":";;;AAAA,mDAAyD;AAEzD,6DAGuC;AAGvC,+DAA4D;AAErD,MAAM,+BAA+B,GAAG,CAAC,EAC9C,KAAK,EACL,SAAS,EACT,OAAO,EACP,Q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EAAE,GAAG,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACzC,CAAC,CAAC;IACL,CAAC;IAED,wJAAwJ;IACxJ,IAAI,WAAW,KAAK,gCAAoB,CAAC,WAAW,EAAE,CAAC;QACrD,OAAO;YACL,KAAK;YACL,SAAS;YACT,OAAO;YACP,QAAQ;YACR,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC9C,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACzC,CAAC;IACJ,CAAC;IAED,6EAA6E;IAC7E,MAAM,IAAI,wCAAuB,CAC/B,0FAA0F,CAC3F,CAAC;AACJ,CAAC,CAAC;AApEW,QAAA,+BAA+B,mCAoE1C"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { LogLevel } from '../domain.objects/constants';
|
|
2
|
+
import type { ContextLogTrail } from '../domain.objects/LogTrail';
|
|
3
|
+
/**
|
|
4
|
+
* .what = create a log context with trail and env injection
|
|
5
|
+
* .why = enables request correlation via trail.exid and code version via env.commit
|
|
6
|
+
*/
|
|
7
|
+
export declare const genContextLogTrail: ({ trail, env, minimalLogLevel, }: {
|
|
8
|
+
/**
|
|
9
|
+
* .what = the trail context for log correlation
|
|
10
|
+
* .why = forces caller to explicitly provide or pass null
|
|
11
|
+
*/
|
|
12
|
+
trail: {
|
|
13
|
+
exid: string | null;
|
|
14
|
+
stack: string[];
|
|
15
|
+
} | null;
|
|
16
|
+
/**
|
|
17
|
+
* .what = the environment context
|
|
18
|
+
* .why = forces caller to explicitly provide or pass null
|
|
19
|
+
*/
|
|
20
|
+
env: {
|
|
21
|
+
commit: string | null;
|
|
22
|
+
} | null;
|
|
23
|
+
/**
|
|
24
|
+
* .what = the minimum log level to emit
|
|
25
|
+
* .why = allows filter of logs by level
|
|
26
|
+
*/
|
|
27
|
+
minimalLogLevel?: LogLevel;
|
|
28
|
+
}) => ContextLogTrail;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.genContextLogTrail = void 0;
|
|
4
|
+
const constants_1 = require("../domain.objects/constants");
|
|
5
|
+
const generateLogMethod_1 = require("./generateLogMethod");
|
|
6
|
+
const getRecommendedMinimalLogLevelForEnvironment_1 = require("./getRecommendedMinimalLogLevelForEnvironment");
|
|
7
|
+
/**
|
|
8
|
+
* .what = create a log context with trail and env injection
|
|
9
|
+
* .why = enables request correlation via trail.exid and code version via env.commit
|
|
10
|
+
*/
|
|
11
|
+
const genContextLogTrail = ({ trail, env, minimalLogLevel = (0, getRecommendedMinimalLogLevelForEnvironment_1.getRecommendedMinimalLogLevelForEnvironment)(), }) => {
|
|
12
|
+
// build the trail object: only include if provided
|
|
13
|
+
const trailForLog = trail
|
|
14
|
+
? { exid: trail.exid, stack: trail.stack }
|
|
15
|
+
: undefined;
|
|
16
|
+
// build the env object: only include if commit is not null
|
|
17
|
+
const envForLog = env?.commit !== null && env?.commit !== undefined
|
|
18
|
+
? { commit: env.commit }
|
|
19
|
+
: undefined;
|
|
20
|
+
// generate the log methods with trail/env injected
|
|
21
|
+
const logMethods = {
|
|
22
|
+
error: (0, generateLogMethod_1.generateLogMethod)({
|
|
23
|
+
level: constants_1.LogLevel.ERROR,
|
|
24
|
+
minimalLogLevel,
|
|
25
|
+
trail: trailForLog,
|
|
26
|
+
env: envForLog,
|
|
27
|
+
}),
|
|
28
|
+
warn: (0, generateLogMethod_1.generateLogMethod)({
|
|
29
|
+
level: constants_1.LogLevel.WARN,
|
|
30
|
+
minimalLogLevel,
|
|
31
|
+
trail: trailForLog,
|
|
32
|
+
env: envForLog,
|
|
33
|
+
}),
|
|
34
|
+
info: (0, generateLogMethod_1.generateLogMethod)({
|
|
35
|
+
level: constants_1.LogLevel.INFO,
|
|
36
|
+
minimalLogLevel,
|
|
37
|
+
trail: trailForLog,
|
|
38
|
+
env: envForLog,
|
|
39
|
+
}),
|
|
40
|
+
debug: (0, generateLogMethod_1.generateLogMethod)({
|
|
41
|
+
level: constants_1.LogLevel.DEBUG,
|
|
42
|
+
minimalLogLevel,
|
|
43
|
+
trail: trailForLog,
|
|
44
|
+
env: envForLog,
|
|
45
|
+
}),
|
|
46
|
+
};
|
|
47
|
+
// return the context with log methods, trail, env, and config
|
|
48
|
+
return {
|
|
49
|
+
log: {
|
|
50
|
+
...logMethods,
|
|
51
|
+
trail: trailForLog,
|
|
52
|
+
env: envForLog,
|
|
53
|
+
_: Object.freeze({ level: minimalLogLevel }),
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
exports.genContextLogTrail = genContextLogTrail;
|
|
58
|
+
//# sourceMappingURL=genContextLogTrail.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"genContextLogTrail.js","sourceRoot":"","sources":["../../src/domain.operations/genContextLogTrail.ts"],"names":[],"mappings":";;;AAAA,6DAAyD;AAGzD,2DAAwD;AACxD,+GAA4G;AAE5G;;;GAGG;AACI,MAAM,kBAAkB,GAAG,CAAC,EACjC,KAAK,EACL,GAAG,EACH,eAAe,GAAG,IAAA,yFAA2C,GAAE,GAwBhE,EAAmB,EAAE;IACpB,mDAAmD;IACnD,MAAM,WAAW,GAAyB,KAAK;QAC7C,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE;QAC1C,CAAC,CAAC,SAAS,CAAC;IAEd,2DAA2D;IAC3D,MAAM,SAAS,GACb,GAAG,EAAE,MAAM,KAAK,IAAI,IAAI,GAAG,EAAE,MAAM,KAAK,SAAS;QAC/C,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE;QACxB,CAAC,CAAC,SAAS,CAAC;IAEhB,mDAAmD;IACnD,MAAM,UAAU,GAAG;QACjB,KAAK,EAAE,IAAA,qCAAiB,EAAC;YACvB,KAAK,EAAE,oBAAQ,CAAC,KAAK;YACrB,eAAe;YACf,KAAK,EAAE,WAAW;YAClB,GAAG,EAAE,SAAS;SACf,CAAC;QACF,IAAI,EAAE,IAAA,qCAAiB,EAAC;YACtB,KAAK,EAAE,oBAAQ,CAAC,IAAI;YACpB,eAAe;YACf,KAAK,EAAE,WAAW;YAClB,GAAG,EAAE,SAAS;SACf,CAAC;QACF,IAAI,EAAE,IAAA,qCAAiB,EAAC;YACtB,KAAK,EAAE,oBAAQ,CAAC,IAAI;YACpB,eAAe;YACf,KAAK,EAAE,WAAW;YAClB,GAAG,EAAE,SAAS;SACf,CAAC;QACF,KAAK,EAAE,IAAA,qCAAiB,EAAC;YACvB,KAAK,EAAE,oBAAQ,CAAC,KAAK;YACrB,eAAe;YACf,KAAK,EAAE,WAAW;YAClB,GAAG,EAAE,SAAS;SACf,CAAC;KACH,CAAC;IAEF,8DAA8D;IAC9D,OAAO;QACL,GAAG,EAAE;YACH,GAAG,UAAU;YACb,KAAK,EAAE,WAAW;YAClB,GAAG,EAAE,SAAS;YACd,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,eAAe,EAAE,CAAC;SAC7C;KACF,CAAC;AACJ,CAAC,CAAC;AA5EW,QAAA,kBAAkB,sBA4E7B"}
|
|
@@ -25,12 +25,18 @@ export interface LogMethods {
|
|
|
25
25
|
* - when choosing to log something with a log level of "debug", you are saying that someone will only be interested in this information when debugging
|
|
26
26
|
*/
|
|
27
27
|
debug: LogMethod;
|
|
28
|
+
/**
|
|
29
|
+
* .what = internal config for log methods
|
|
30
|
+
*/
|
|
31
|
+
readonly _: Readonly<{
|
|
32
|
+
level: LogLevel;
|
|
33
|
+
}>;
|
|
28
34
|
}
|
|
29
35
|
/**
|
|
30
36
|
* define how to generate the log methods
|
|
31
37
|
* - allows you to specify the minimal log level to use for your application
|
|
32
38
|
* - defaults to recommended levels for the environment
|
|
33
39
|
*/
|
|
34
|
-
export declare const
|
|
40
|
+
export declare const genLogMethods: ({ minimalLogLevel, }?: {
|
|
35
41
|
minimalLogLevel?: LogLevel;
|
|
36
42
|
}) => LogMethods;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.genLogMethods = void 0;
|
|
4
4
|
const constants_1 = require("../domain.objects/constants");
|
|
5
5
|
const generateLogMethod_1 = require("./generateLogMethod");
|
|
6
6
|
const getRecommendedMinimalLogLevelForEnvironment_1 = require("./getRecommendedMinimalLogLevelForEnvironment");
|
|
@@ -9,14 +9,15 @@ const getRecommendedMinimalLogLevelForEnvironment_1 = require("./getRecommendedM
|
|
|
9
9
|
* - allows you to specify the minimal log level to use for your application
|
|
10
10
|
* - defaults to recommended levels for the environment
|
|
11
11
|
*/
|
|
12
|
-
const
|
|
12
|
+
const genLogMethods = ({ minimalLogLevel = (0, getRecommendedMinimalLogLevelForEnvironment_1.getRecommendedMinimalLogLevelForEnvironment)(), } = {}) => {
|
|
13
13
|
// generate the methods
|
|
14
14
|
return {
|
|
15
15
|
error: (0, generateLogMethod_1.generateLogMethod)({ level: constants_1.LogLevel.ERROR, minimalLogLevel }),
|
|
16
16
|
warn: (0, generateLogMethod_1.generateLogMethod)({ level: constants_1.LogLevel.WARN, minimalLogLevel }),
|
|
17
17
|
info: (0, generateLogMethod_1.generateLogMethod)({ level: constants_1.LogLevel.INFO, minimalLogLevel }),
|
|
18
18
|
debug: (0, generateLogMethod_1.generateLogMethod)({ level: constants_1.LogLevel.DEBUG, minimalLogLevel }),
|
|
19
|
+
_: Object.freeze({ level: minimalLogLevel }),
|
|
19
20
|
};
|
|
20
21
|
};
|
|
21
|
-
exports.
|
|
22
|
-
//# sourceMappingURL=
|
|
22
|
+
exports.genLogMethods = genLogMethods;
|
|
23
|
+
//# sourceMappingURL=genLogMethods.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"genLogMethods.js","sourceRoot":"","sources":["../../src/domain.operations/genLogMethods.ts"],"names":[],"mappings":";;;AAAA,6DAAyD;AAEzD,2DAAwE;AACxE,+GAA4G;AAqC5G;;;;GAIG;AACI,MAAM,aAAa,GAAG,CAAC,EAC5B,eAAe,GAAG,IAAA,yFAA2C,GAAE,MAG7D,EAAE,EAAc,EAAE;IACpB,uBAAuB;IACvB,OAAO;QACL,KAAK,EAAE,IAAA,qCAAiB,EAAC,EAAE,KAAK,EAAE,oBAAQ,CAAC,KAAK,EAAE,eAAe,EAAE,CAAC;QACpE,IAAI,EAAE,IAAA,qCAAiB,EAAC,EAAE,KAAK,EAAE,oBAAQ,CAAC,IAAI,EAAE,eAAe,EAAE,CAAC;QAClE,IAAI,EAAE,IAAA,qCAAiB,EAAC,EAAE,KAAK,EAAE,oBAAQ,CAAC,IAAI,EAAE,eAAe,EAAE,CAAC;QAClE,KAAK,EAAE,IAAA,qCAAiB,EAAC,EAAE,KAAK,EAAE,oBAAQ,CAAC,KAAK,EAAE,eAAe,EAAE,CAAC;QACpE,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,eAAe,EAAE,CAAC;KAC7C,CAAC;AACJ,CAAC,CAAC;AAbW,QAAA,aAAa,iBAaxB"}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { LogLevel } from '../domain.objects/constants';
|
|
2
|
+
import type { LogTrail } from '../domain.objects/LogTrail';
|
|
2
3
|
export type LogMethod = (message: string, metadata?: any) => void;
|
|
3
|
-
export declare const generateLogMethod: ({ level, minimalLogLevel, }: {
|
|
4
|
+
export declare const generateLogMethod: ({ level, minimalLogLevel, trail, env, }: {
|
|
4
5
|
level: LogLevel;
|
|
5
6
|
minimalLogLevel: LogLevel;
|
|
7
|
+
trail?: LogTrail;
|
|
8
|
+
env?: {
|
|
9
|
+
commit: string;
|
|
10
|
+
};
|
|
6
11
|
}) => (message: string, metadata?: object) => void;
|
|
@@ -13,7 +13,7 @@ const logLevelPriorityOrder = [
|
|
|
13
13
|
constants_1.LogLevel.DEBUG,
|
|
14
14
|
];
|
|
15
15
|
const aIsEqualOrMoreImportantThanB = ({ a, b }) => logLevelPriorityOrder.indexOf(a) - logLevelPriorityOrder.indexOf(b) <= 0;
|
|
16
|
-
const generateLogMethod = ({ level, minimalLogLevel, }) => {
|
|
16
|
+
const generateLogMethod = ({ level, minimalLogLevel, trail, env, }) => {
|
|
17
17
|
return (message, metadata) => {
|
|
18
18
|
if (aIsEqualOrMoreImportantThanB({ a: level, b: minimalLogLevel })) {
|
|
19
19
|
// determine the console level (i.e., use warn if we can to make the logs stand out more)
|
|
@@ -29,6 +29,8 @@ const generateLogMethod = ({ level, minimalLogLevel, }) => {
|
|
|
29
29
|
timestamp: new Date().toISOString(),
|
|
30
30
|
message,
|
|
31
31
|
metadata,
|
|
32
|
+
trail,
|
|
33
|
+
env,
|
|
32
34
|
}));
|
|
33
35
|
}
|
|
34
36
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateLogMethod.js","sourceRoot":"","sources":["../../src/domain.operations/generateLogMethod.ts"],"names":[],"mappings":";;;AAAA,6DAAyD;
|
|
1
|
+
{"version":3,"file":"generateLogMethod.js","sourceRoot":"","sources":["../../src/domain.operations/generateLogMethod.ts"],"names":[],"mappings":";;;AAAA,6DAAyD;AAGzD,uFAAoF;AAEpF;;EAEE;AACF,MAAM,qBAAqB,GAAG;IAC5B,oBAAQ,CAAC,KAAK;IACd,oBAAQ,CAAC,IAAI;IACb,oBAAQ,CAAC,IAAI;IACb,oBAAQ,CAAC,KAAK;CACf,CAAC;AACF,MAAM,4BAA4B,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,EAAgC,EAAE,EAAE,CAC9E,qBAAqB,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,qBAAqB,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AAUpE,MAAM,iBAAiB,GAAG,CAAC,EAChC,KAAK,EACL,eAAe,EACf,KAAK,EACL,GAAG,GAMJ,EAAE,EAAE;IACH,OAAO,CAAC,OAAe,EAAE,QAAiB,EAAE,EAAE;QAC5C,IAAI,4BAA4B,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,eAAe,EAAE,CAAC,EAAE,CAAC;YACnE,yFAAyF;YACzF,MAAM,aAAa,GAAG,4BAA4B,CAAC;gBACjD,CAAC,EAAE,KAAK;gBACR,CAAC,EAAE,oBAAQ,CAAC,IAAI;aACjB,CAAC;gBACA,CAAC,CAAC,OAAO,CAAC,IAAI;gBACd,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,iCAAiC;YAElD,wGAAwG;YACxG,aAAa,CACX,IAAA,iEAA+B,EAAC;gBAC9B,KAAK;gBACL,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;gBACnC,OAAO;gBACP,QAAQ;gBACR,KAAK;gBACL,GAAG;aACJ,CAAC,CACH,CAAC;QACJ,CAAC;IACH,CAAC,CAAC;AACJ,CAAC,CAAC;AAlCW,QAAA,iBAAiB,qBAkC5B"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type IsoDuration } from 'iso-time';
|
|
2
|
-
import
|
|
2
|
+
import { LogLevel } from '../domain.objects/constants';
|
|
3
3
|
import type { ContextLogTrail } from '../domain.objects/LogTrail';
|
|
4
4
|
/**
|
|
5
5
|
* enables input output logging and tracing for a method
|
|
@@ -4,6 +4,8 @@ exports.withLogTrail = void 0;
|
|
|
4
4
|
const helpful_errors_1 = require("helpful-errors");
|
|
5
5
|
const iso_time_1 = require("iso-time");
|
|
6
6
|
const type_fns_1 = require("type-fns");
|
|
7
|
+
const constants_1 = require("../domain.objects/constants");
|
|
8
|
+
const generateLogMethod_1 = require("./generateLogMethod");
|
|
7
9
|
const noOp = (...input) => input;
|
|
8
10
|
const omitContext = (...input) => input[0]; // standard pattern for args = [input, context]
|
|
9
11
|
const pickErrorMessage = (input) => ({
|
|
@@ -58,17 +60,53 @@ const withLogTrail = (logic, { name: declaredName, log: logOptions, duration = {
|
|
|
58
60
|
});
|
|
59
61
|
// begin tracking duration
|
|
60
62
|
const startTimeInMilliseconds = new Date().getTime();
|
|
63
|
+
// build the updated trail: preserve exid, append name to stack
|
|
64
|
+
const updatedTrail = {
|
|
65
|
+
exid: context.log.trail?.exid ?? null,
|
|
66
|
+
stack: [...(context.log.trail?.stack ?? []), name],
|
|
67
|
+
};
|
|
68
|
+
// extract env from context (top-level property)
|
|
69
|
+
const env = context.log.env;
|
|
70
|
+
// use level from context
|
|
71
|
+
const minimalLogLevel = context.log._.level;
|
|
72
|
+
// create base log methods with updated trail
|
|
73
|
+
const baseDebug = (0, generateLogMethod_1.generateLogMethod)({
|
|
74
|
+
level: constants_1.LogLevel.DEBUG,
|
|
75
|
+
minimalLogLevel,
|
|
76
|
+
trail: updatedTrail,
|
|
77
|
+
env,
|
|
78
|
+
});
|
|
79
|
+
const baseInfo = (0, generateLogMethod_1.generateLogMethod)({
|
|
80
|
+
level: constants_1.LogLevel.INFO,
|
|
81
|
+
minimalLogLevel,
|
|
82
|
+
trail: updatedTrail,
|
|
83
|
+
env,
|
|
84
|
+
});
|
|
85
|
+
const baseWarn = (0, generateLogMethod_1.generateLogMethod)({
|
|
86
|
+
level: constants_1.LogLevel.WARN,
|
|
87
|
+
minimalLogLevel,
|
|
88
|
+
trail: updatedTrail,
|
|
89
|
+
env,
|
|
90
|
+
});
|
|
91
|
+
const baseError = (0, generateLogMethod_1.generateLogMethod)({
|
|
92
|
+
level: constants_1.LogLevel.ERROR,
|
|
93
|
+
minimalLogLevel,
|
|
94
|
+
trail: updatedTrail,
|
|
95
|
+
env,
|
|
96
|
+
});
|
|
61
97
|
// define the context.log method that will be given to the logic
|
|
62
98
|
const logMethodsWithContext = {
|
|
63
|
-
// add the trail
|
|
64
|
-
trail:
|
|
99
|
+
// add the trail, env, and config
|
|
100
|
+
trail: updatedTrail,
|
|
101
|
+
env,
|
|
102
|
+
_: Object.freeze({ level: minimalLogLevel }),
|
|
65
103
|
// track the orig logger
|
|
66
104
|
_orig: context.log?._orig ?? context.log,
|
|
67
|
-
// add the scoped methods
|
|
68
|
-
debug: (message, metadata) =>
|
|
69
|
-
info: (message, metadata) =>
|
|
70
|
-
warn: (message, metadata) =>
|
|
71
|
-
error: (message, metadata) =>
|
|
105
|
+
// add the scoped methods with message prefix
|
|
106
|
+
debug: (message, metadata) => baseDebug(`${name}.progress: ${message}`, metadata),
|
|
107
|
+
info: (message, metadata) => baseInfo(`${name}.progress: ${message}`, metadata),
|
|
108
|
+
warn: (message, metadata) => baseWarn(`${name}.progress: ${message}`, metadata),
|
|
109
|
+
error: (message, metadata) => baseError(`${name}.progress: ${message}`, metadata),
|
|
72
110
|
};
|
|
73
111
|
// define what to do when we have an error
|
|
74
112
|
const logError = (error) => {
|
|
@@ -97,22 +135,6 @@ const withLogTrail = (logic, { name: declaredName, log: logOptions, duration = {
|
|
|
97
135
|
logError(error);
|
|
98
136
|
throw error;
|
|
99
137
|
}
|
|
100
|
-
// if the result was a promise, log when that method crosses the reporting threshold, to identify which procedures are slow
|
|
101
|
-
if ((0, type_fns_1.isAPromise)(result)) {
|
|
102
|
-
// define how to log the breach, on breach
|
|
103
|
-
const onDurationBreach = () => context.log[logLevelOutput](`${name}.duration.breach`, {
|
|
104
|
-
input: logInputMethod(input, context),
|
|
105
|
-
already: { duration: `${durationReportingThresholdInSeconds} sec` },
|
|
106
|
-
});
|
|
107
|
-
// define a timeout which will trigger on duration threshold
|
|
108
|
-
const onBreachTrigger = setTimeout(onDurationBreach, durationReportingThresholdInSeconds * 1000);
|
|
109
|
-
// remove the timeout when the operation completes, to prevent logging if completes before duration
|
|
110
|
-
void result
|
|
111
|
-
.finally(() => clearTimeout(onBreachTrigger))
|
|
112
|
-
.catch(() => {
|
|
113
|
-
// do nothing when there's an error; just catch it, to ensure it doesn't get propagated further as an uncaught exception
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
138
|
// define what to do when we have output
|
|
117
139
|
const logOutput = (output) => {
|
|
118
140
|
const endTimeInMilliseconds = new Date().getTime();
|
|
@@ -126,9 +148,18 @@ const withLogTrail = (logic, { name: declaredName, log: logOptions, duration = {
|
|
|
126
148
|
: {}),
|
|
127
149
|
});
|
|
128
150
|
};
|
|
129
|
-
// if result
|
|
130
|
-
if ((0, type_fns_1.isAPromise)(result))
|
|
151
|
+
// if the result was a promise, log when that method crosses the threshold, to identify which procedures are slow
|
|
152
|
+
if ((0, type_fns_1.isAPromise)(result)) {
|
|
153
|
+
// define how to log the breach, on breach
|
|
154
|
+
const onDurationBreach = () => context.log[logLevelOutput](`${name}.duration.breach`, {
|
|
155
|
+
input: logInputMethod(input, context),
|
|
156
|
+
already: { duration: `${durationReportingThresholdInSeconds} sec` },
|
|
157
|
+
});
|
|
158
|
+
// define a timeout which will trigger on duration threshold
|
|
159
|
+
const onBreachTrigger = setTimeout(onDurationBreach, durationReportingThresholdInSeconds * 1000);
|
|
160
|
+
// clear timeout when promise settles, then log output or error
|
|
131
161
|
return result
|
|
162
|
+
.finally(() => clearTimeout(onBreachTrigger))
|
|
132
163
|
.then((output) => {
|
|
133
164
|
logOutput(output);
|
|
134
165
|
return output;
|
|
@@ -137,7 +168,8 @@ const withLogTrail = (logic, { name: declaredName, log: logOptions, duration = {
|
|
|
137
168
|
logError(error);
|
|
138
169
|
throw error;
|
|
139
170
|
});
|
|
140
|
-
|
|
171
|
+
}
|
|
172
|
+
// otherwise, not a promise, so done now — log and return the result
|
|
141
173
|
logOutput(result);
|
|
142
174
|
return result;
|
|
143
175
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withLogTrail.js","sourceRoot":"","sources":["../../src/domain.operations/withLogTrail.ts"],"names":[],"mappings":";;;AAKA,mDAAyD;AACzD,uCAA4D;AAC5D,uCA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C,GAAG,IAAI,kBAAkB,EAAE;gBACrD,KAAK,EAAE,cAAc,CAAC,KAAK,EAAE,OAAO,CAAC;gBACrC,OAAO,EAAE,EAAE,QAAQ,EAAE,GAAG,mCAAmC,MAAM,EAAE;aACpE,CAAC,CAAC;YAEL,4DAA4D;YAC5D,MAAM,eAAe,GAAG,UAAU,CAChC,gBAAgB,EAChB,mCAAmC,GAAG,IAAI,CAC3C,CAAC;YAEF,+DAA+D;YAC/D,OAAO,MAAM;iBACV,OAAO,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,eAAe,CAAC,CAAC;iBAC5C,IAAI,CAAC,CAAC,MAA8C,EAAE,EAAE;gBACvD,SAAS,CAAC,MAAM,CAAC,CAAC;gBAClB,OAAO,MAAM,CAAC;YAChB,CAAC,CAAC;iBACD,KAAK,CAAC,CAAC,KAAY,EAAE,EAAE;gBACtB,QAAQ,CAAC,KAAK,CAAC,CAAC;gBAChB,MAAM,KAAK,CAAC;YACd,CAAC,CAAY,CAAC;QAClB,CAAC;QAED,oEAAoE;QACpE,SAAS,CAAC,MAAgD,CAAC,CAAC;QAC5D,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC,CAAC;AAhQW,QAAA,YAAY,gBAgQvB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { LogLevel } from './domain.objects/constants';
|
|
2
2
|
export type { ContextLogTrail, HasContextLogTrail, LogTrail, } from './domain.objects/LogTrail';
|
|
3
|
+
export { genContextLogTrail } from './domain.operations/genContextLogTrail';
|
|
3
4
|
export type { LogMethod } from './domain.operations/generateLogMethod';
|
|
4
|
-
export type { LogMethods } from './domain.operations/
|
|
5
|
-
export {
|
|
5
|
+
export type { LogMethods } from './domain.operations/genLogMethods';
|
|
6
|
+
export { genLogMethods } from './domain.operations/genLogMethods';
|
|
6
7
|
export { withLogTrail } from './domain.operations/withLogTrail';
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.withLogTrail = exports.
|
|
3
|
+
exports.withLogTrail = exports.genLogMethods = exports.genContextLogTrail = exports.LogLevel = void 0;
|
|
4
4
|
var constants_1 = require("./domain.objects/constants");
|
|
5
5
|
Object.defineProperty(exports, "LogLevel", { enumerable: true, get: function () { return constants_1.LogLevel; } });
|
|
6
|
-
var
|
|
7
|
-
Object.defineProperty(exports, "
|
|
6
|
+
var genContextLogTrail_1 = require("./domain.operations/genContextLogTrail");
|
|
7
|
+
Object.defineProperty(exports, "genContextLogTrail", { enumerable: true, get: function () { return genContextLogTrail_1.genContextLogTrail; } });
|
|
8
|
+
var genLogMethods_1 = require("./domain.operations/genLogMethods");
|
|
9
|
+
Object.defineProperty(exports, "genLogMethods", { enumerable: true, get: function () { return genLogMethods_1.genLogMethods; } });
|
|
8
10
|
var withLogTrail_1 = require("./domain.operations/withLogTrail");
|
|
9
11
|
Object.defineProperty(exports, "withLogTrail", { enumerable: true, get: function () { return withLogTrail_1.withLogTrail; } });
|
|
10
12
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,wDAAsD;AAA7C,qGAAA,QAAQ,OAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,wDAAsD;AAA7C,qGAAA,QAAQ,OAAA;AAMjB,6EAA4E;AAAnE,wHAAA,kBAAkB,OAAA;AAG3B,mEAAkE;AAAzD,8GAAA,aAAa,OAAA;AACtB,iEAAgE;AAAvD,4GAAA,YAAY,OAAA"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "sdk-logs",
|
|
3
3
|
"author": "ehmpathy",
|
|
4
4
|
"description": "a simple and opinionated logging library. plays well with aws lambda + cloudwatch.",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.7.0",
|
|
6
6
|
"repository": "ehmpathy/sdk-logs",
|
|
7
7
|
"homepage": "https://github.com/ehmpathy/sdk-logs",
|
|
8
8
|
"keywords": [
|
|
@@ -25,6 +25,37 @@
|
|
|
25
25
|
"files": [
|
|
26
26
|
"/dist"
|
|
27
27
|
],
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build:ts": "tsc -p ./tsconfig.build.json",
|
|
30
|
+
"commit:with-cli": "npx cz",
|
|
31
|
+
"fix:format:biome": "biome check --write",
|
|
32
|
+
"fix:format": "npm run fix:format:biome",
|
|
33
|
+
"fix:lint": "biome check --write",
|
|
34
|
+
"fix": "npm run fix:format && npm run fix:lint",
|
|
35
|
+
"build:clean": "chmod -R u+w dist 2>/dev/null; rm -rf dist/",
|
|
36
|
+
"build:compile": "tsc -p ./tsconfig.build.json && tsc-alias -p ./tsconfig.build.json",
|
|
37
|
+
"build": "npm run build:clean && npm run build:compile && npm run build:complete --if-present",
|
|
38
|
+
"test:commits": "LAST_TAG=$(git describe --tags --abbrev=0 @^ 2> /dev/null || git rev-list --max-parents=0 HEAD) && npx commitlint --from $LAST_TAG --to HEAD --verbose",
|
|
39
|
+
"test:types": "tsc -p ./tsconfig.json --noEmit",
|
|
40
|
+
"test:format:biome": "biome format",
|
|
41
|
+
"test:format": "npm run test:format:biome",
|
|
42
|
+
"test:lint:deps": "npx depcheck -c ./.depcheckrc.yml",
|
|
43
|
+
"test:lint:biome": "biome check --diagnostic-level=error",
|
|
44
|
+
"test:lint:biome:all": "biome check",
|
|
45
|
+
"test:lint": "npm run test:lint:biome && npm run test:lint:deps",
|
|
46
|
+
"test:unit": "jest -c ./jest.unit.config.ts --forceExit --verbose --passWithNoTests $([ -z $THOROUGH ] && echo '--changedSince=main') $([ -n $RESNAP ] && echo '--updateSnapshot')",
|
|
47
|
+
"test:integration": "jest -c ./jest.integration.config.ts --forceExit --verbose --passWithNoTests $([ -z $THOROUGH ] && echo '--changedSince=main') $([ -n $RESNAP ] && echo '--updateSnapshot')",
|
|
48
|
+
"test:acceptance:locally": "npm run build && LOCALLY=true jest -c ./jest.acceptance.config.ts --forceExit --verbose --runInBand --passWithNoTests $([ -n $RESNAP ] && echo '--updateSnapshot')",
|
|
49
|
+
"test": "npm run test:commits && npm run test:types && npm run test:format && npm run test:lint && npm run test:unit && npm run test:integration && npm run test:acceptance:locally",
|
|
50
|
+
"test:acceptance": "npm run build && jest -c ./jest.acceptance.config.ts --forceExit --verbose --runInBand --passWithNoTests $([ -n $RESNAP ] && echo '--updateSnapshot')",
|
|
51
|
+
"prepush": "npm run test && npm run build",
|
|
52
|
+
"prepublish": "npm run build",
|
|
53
|
+
"preversion": "npm run prepush",
|
|
54
|
+
"postversion": "git push origin HEAD --tags --no-verify",
|
|
55
|
+
"prepare:husky": "husky install && chmod ug+x .husky/*",
|
|
56
|
+
"prepare:rhachet": "rhachet init --hooks --roles mechanic behaver driver reviewer librarian ergonomist architect reflector dreamer dispatcher",
|
|
57
|
+
"prepare": "if [ -e .git ] && [ -z $CI ]; then npm run prepare:husky && npm run prepare:rhachet; fi"
|
|
58
|
+
},
|
|
28
59
|
"dependencies": {
|
|
29
60
|
"@ehmpathy/error-fns": "^1.3.7",
|
|
30
61
|
"domain-glossary-procedure": "^1.0.0",
|
|
@@ -70,34 +101,5 @@
|
|
|
70
101
|
"path": "./node_modules/cz-conventional-changelog"
|
|
71
102
|
}
|
|
72
103
|
},
|
|
73
|
-
"
|
|
74
|
-
|
|
75
|
-
"commit:with-cli": "npx cz",
|
|
76
|
-
"fix:format:biome": "biome check --write",
|
|
77
|
-
"fix:format": "npm run fix:format:biome",
|
|
78
|
-
"fix:lint": "biome check --write",
|
|
79
|
-
"fix": "npm run fix:format && npm run fix:lint",
|
|
80
|
-
"build:clean": "chmod -R u+w dist 2>/dev/null; rm -rf dist/",
|
|
81
|
-
"build:compile": "tsc -p ./tsconfig.build.json && tsc-alias -p ./tsconfig.build.json",
|
|
82
|
-
"build": "npm run build:clean && npm run build:compile && npm run build:complete --if-present",
|
|
83
|
-
"test:commits": "LAST_TAG=$(git describe --tags --abbrev=0 @^ 2> /dev/null || git rev-list --max-parents=0 HEAD) && npx commitlint --from $LAST_TAG --to HEAD --verbose",
|
|
84
|
-
"test:types": "tsc -p ./tsconfig.json --noEmit",
|
|
85
|
-
"test:format:biome": "biome format",
|
|
86
|
-
"test:format": "npm run test:format:biome",
|
|
87
|
-
"test:lint:deps": "npx depcheck -c ./.depcheckrc.yml",
|
|
88
|
-
"test:lint:biome": "biome check --diagnostic-level=error",
|
|
89
|
-
"test:lint:biome:all": "biome check",
|
|
90
|
-
"test:lint": "npm run test:lint:biome && npm run test:lint:deps",
|
|
91
|
-
"test:unit": "jest -c ./jest.unit.config.ts --forceExit --verbose --passWithNoTests $([ -z $THOROUGH ] && echo '--changedSince=main') $([ -n $RESNAP ] && echo '--updateSnapshot')",
|
|
92
|
-
"test:integration": "jest -c ./jest.integration.config.ts --forceExit --verbose --passWithNoTests $([ -z $THOROUGH ] && echo '--changedSince=main') $([ -n $RESNAP ] && echo '--updateSnapshot')",
|
|
93
|
-
"test:acceptance:locally": "npm run build && LOCALLY=true jest -c ./jest.acceptance.config.ts --forceExit --verbose --runInBand --passWithNoTests $([ -n $RESNAP ] && echo '--updateSnapshot')",
|
|
94
|
-
"test": "npm run test:commits && npm run test:types && npm run test:format && npm run test:lint && npm run test:unit && npm run test:integration && npm run test:acceptance:locally",
|
|
95
|
-
"test:acceptance": "npm run build && jest -c ./jest.acceptance.config.ts --forceExit --verbose --runInBand --passWithNoTests $([ -n $RESNAP ] && echo '--updateSnapshot')",
|
|
96
|
-
"prepush": "npm run test && npm run build",
|
|
97
|
-
"prepublish": "npm run build",
|
|
98
|
-
"preversion": "npm run prepush",
|
|
99
|
-
"postversion": "git push origin HEAD --tags --no-verify",
|
|
100
|
-
"prepare:husky": "husky install && chmod ug+x .husky/*",
|
|
101
|
-
"prepare:rhachet": "rhachet init --hooks --roles mechanic behaver driver reviewer librarian ergonomist architect reflector dreamer dispatcher"
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
+
"packageManager": "pnpm@10.24.0"
|
|
105
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generateLogMethods.js","sourceRoot":"","sources":["../../src/domain.operations/generateLogMethods.ts"],"names":[],"mappings":";;;AAAA,6DAAyD;AAEzD,2DAAwE;AACxE,+GAA4G;AAgC5G;;;;GAIG;AACI,MAAM,kBAAkB,GAAG,CAAC,EACjC,eAAe,GAAG,IAAA,yFAA2C,GAAE,MAG7D,EAAE,EAAc,EAAE;IACpB,uBAAuB;IACvB,OAAO;QACL,KAAK,EAAE,IAAA,qCAAiB,EAAC,EAAE,KAAK,EAAE,oBAAQ,CAAC,KAAK,EAAE,eAAe,EAAE,CAAC;QACpE,IAAI,EAAE,IAAA,qCAAiB,EAAC,EAAE,KAAK,EAAE,oBAAQ,CAAC,IAAI,EAAE,eAAe,EAAE,CAAC;QAClE,IAAI,EAAE,IAAA,qCAAiB,EAAC,EAAE,KAAK,EAAE,oBAAQ,CAAC,IAAI,EAAE,eAAe,EAAE,CAAC;QAClE,KAAK,EAAE,IAAA,qCAAiB,EAAC,EAAE,KAAK,EAAE,oBAAQ,CAAC,KAAK,EAAE,eAAe,EAAE,CAAC;KACrE,CAAC;AACJ,CAAC,CAAC;AAZW,QAAA,kBAAkB,sBAY7B"}
|