@nmtjs/core 0.6.2 → 0.6.3
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/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/lib/logger.js.map +1 -1
- package/dist/lib/registry.js.map +1 -1
- package/index.ts +4 -4
- package/lib/logger.ts +1 -1
- package/lib/registry.ts +1 -1
- package/package.json +3 -4
- package/tsconfig.json +0 -3
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export * from "./lib/constants.js";
|
|
2
|
-
export * from "./lib/
|
|
2
|
+
export * from "./lib/container.js";
|
|
3
3
|
export * from "./lib/enums.js";
|
|
4
4
|
export * from "./lib/hooks.js";
|
|
5
|
+
export * from "./lib/injectables.js";
|
|
5
6
|
export * from "./lib/logger.js";
|
|
7
|
+
export * from "./lib/plugin.js";
|
|
6
8
|
export * from "./lib/registry.js";
|
|
7
|
-
export * from "./lib/container.js";
|
|
8
|
-
export * from "./lib/injectables.js";
|
|
9
9
|
export * from "./lib/types.js";
|
|
10
|
-
export * from "./lib/
|
|
10
|
+
export * from "./lib/types.js";
|
|
11
11
|
export * from "./lib/utils/index.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../index.ts"],"sourcesContent":["export * from './lib/constants.ts'\nexport * from './lib/
|
|
1
|
+
{"version":3,"sources":["../../index.ts"],"sourcesContent":["export * from './lib/constants.ts'\nexport * from './lib/container.ts'\nexport * from './lib/enums.ts'\nexport * from './lib/hooks.ts'\nexport * from './lib/injectables.ts'\nexport * from './lib/logger.ts'\nexport * from './lib/plugin.ts'\nexport * from './lib/registry.ts'\nexport * from './lib/types.ts'\nexport * from './lib/types.ts'\nexport * from './lib/utils/index.ts'\n"],"names":[],"mappings":"AAAA,cAAc,qBAAoB;AAClC,cAAc,qBAAoB;AAClC,cAAc,iBAAgB;AAC9B,cAAc,iBAAgB;AAC9B,cAAc,uBAAsB;AACpC,cAAc,kBAAiB;AAC/B,cAAc,kBAAiB;AAC/B,cAAc,oBAAmB;AACjC,cAAc,iBAAgB;AAC9B,cAAc,iBAAgB;AAC9B,cAAc,uBAAsB"}
|
package/dist/lib/logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../lib/logger.ts"],"sourcesContent":["import { threadId } from 'node:worker_threads'\nimport {\n type DestinationStream,\n type Level,\n type Logger as PinoLogger,\n type StreamEntry,\n
|
|
1
|
+
{"version":3,"sources":["../../../lib/logger.ts"],"sourcesContent":["import { threadId } from 'node:worker_threads'\nimport {\n type DestinationStream,\n type Level,\n type Logger as PinoLogger,\n pino,\n type StreamEntry,\n stdTimeFunctions,\n} from 'pino'\nimport { build as pretty } from 'pino-pretty'\n\nexport type Logger = PinoLogger\nexport type LoggingOptions = {\n destinations?: Array<DestinationStream | StreamEntry<Level>>\n pinoOptions?: any\n}\n\n// TODO: use node:util inspect\nconst bg = (value, color) => `\\x1b[${color}m${value}\\x1b[0m`\nconst fg = (value, color) => `\\x1b[38;5;${color}m${value}\\x1b[0m`\n\nconst levelColors = {\n 10: 100,\n 20: 102,\n 30: 106,\n 40: 104,\n 50: 101,\n 60: 105,\n [Number.POSITIVE_INFINITY]: 0,\n}\nconst messageColors = {\n 10: 0,\n 20: 2,\n 30: 6,\n 40: 4,\n 50: 1,\n 60: 5,\n [Number.POSITIVE_INFINITY]: 0,\n}\n\nconst levelLabels = {\n 10: ' TRACE ',\n 20: ' DEBUG ',\n 30: ' INFO ',\n 40: ' WARN ',\n 50: ' ERROR ',\n 60: ' FATAL ',\n [Number.POSITIVE_INFINITY]: 'SILENT',\n}\n\nexport const createLogger = (options: LoggingOptions = {}, $group: string) => {\n let { destinations, pinoOptions } = options\n\n if (!destinations || !destinations?.length) {\n destinations = [createConsolePrettyDestination('info')]\n }\n\n const lowestLevelValue = destinations!.reduce(\n (acc, destination) =>\n Math.min(\n acc,\n 'stream' in destination\n ? pino.levels.values[destination.level!]\n : Number.POSITIVE_INFINITY,\n ),\n Number.POSITIVE_INFINITY,\n )\n const level = pino.levels.labels[lowestLevelValue]\n return pino(\n {\n timestamp: stdTimeFunctions.isoTime,\n ...pinoOptions,\n level,\n },\n pino.multistream(destinations!),\n ).child({ $group, $threadId: threadId })\n}\n\nexport const createConsolePrettyDestination = (\n level: Level,\n sync = true,\n): StreamEntry => ({\n level,\n stream: pretty({\n colorize: true,\n ignore: 'hostname,$group,$threadId',\n errorLikeObjectKeys: ['err', 'error', 'cause'],\n messageFormat: (log, messageKey) => {\n const group = fg(`[${log.$group}]`, 11)\n const msg = fg(log[messageKey], messageColors[log.level as number])\n const thread = fg(`(Thread-${log.$threadId})`, 89)\n return `\\x1b[0m${thread} ${group} ${msg}`\n },\n customPrettifiers: {\n level: (level: any) => bg(levelLabels[level], levelColors[level]),\n },\n sync,\n }),\n})\n"],"names":["threadId","pino","stdTimeFunctions","build","pretty","bg","value","color","fg","levelColors","Number","POSITIVE_INFINITY","messageColors","levelLabels","createLogger","options","$group","destinations","pinoOptions","length","createConsolePrettyDestination","lowestLevelValue","reduce","acc","destination","Math","min","levels","values","level","labels","timestamp","isoTime","multistream","child","$threadId","sync","stream","colorize","ignore","errorLikeObjectKeys","messageFormat","log","messageKey","group","msg","thread","customPrettifiers"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,sBAAqB;AAC9C,SAIEC,IAAI,EAEJC,gBAAgB,QACX,OAAM;AACb,SAASC,SAASC,MAAM,QAAQ,cAAa;AAS7C,MAAMC,KAAK,CAACC,OAAOC,QAAU,CAAC,KAAK,EAAEA,MAAM,CAAC,EAAED,MAAM,OAAO,CAAC;AAC5D,MAAME,KAAK,CAACF,OAAOC,QAAU,CAAC,UAAU,EAAEA,MAAM,CAAC,EAAED,MAAM,OAAO,CAAC;AAEjE,MAAMG,cAAc;IAClB,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAA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AC,CAAC,EAAE;gBACpC,MAAM6B,MAAMrC,GAAGkC,GAAG,CAACC,WAAW,EAAE/B,aAAa,CAAC8B,IAAIb,KAAK,CAAW;gBAClE,MAAMiB,SAAStC,GAAG,CAAC,QAAQ,EAAEkC,IAAIP,SAAS,CAAC,CAAC,CAAC,EAAE;gBAC/C,OAAO,CAAC,OAAO,EAAEW,OAAO,CAAC,EAAEF,MAAM,CAAC,EAAEC,IAAI,CAAC;YAC3C;YACAE,mBAAmB;gBACjBlB,OAAO,CAACA,QAAexB,GAAGQ,WAAW,CAACgB,MAAM,EAAEpB,WAAW,CAACoB,MAAM;YAClE;YACAO;QACF;IACF,CAAA,EAAE"}
|
package/dist/lib/registry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../lib/registry.ts"],"sourcesContent":["import {\n type AnyInjectable,\n type Dependant,\n getInjectableScope,\n} from './container.ts'\nimport { type Hook, Scope } from './enums.ts'\nimport { type HookType
|
|
1
|
+
{"version":3,"sources":["../../../lib/registry.ts"],"sourcesContent":["import {\n type AnyInjectable,\n type Dependant,\n getInjectableScope,\n} from './container.ts'\nimport { type Hook, Scope } from './enums.ts'\nimport { Hooks, type HookType } from './hooks.ts'\nimport type { Logger } from './logger.ts'\n\nexport class Registry {\n readonly hooks = new Hooks()\n\n constructor(\n protected readonly application: {\n logger: Logger\n },\n ) {}\n\n registerHooks<T extends Hooks>(hooks: T) {\n Hooks.merge(hooks, this.hooks)\n }\n\n registerHook<T extends Hook>(name: T, callback: HookType[T]) {\n this.hooks.add(name, callback)\n }\n\n *getDependants(): Generator<Dependant> {}\n\n clear() {\n this.hooks.clear()\n }\n}\n\nexport const scopeErrorMessage = (name, scope = Scope.Global) =>\n `${name} must be a ${scope} scope (including all nested dependencies)`\n\nexport function hasInvalidScopeDeps(\n injectables: AnyInjectable[],\n scope = Scope.Global,\n) {\n return injectables.some(\n (injectable) => getInjectableScope(injectable) !== scope,\n )\n}\n"],"names":["getInjectableScope","Scope","Hooks","Registry","hooks","constructor","application","registerHooks","merge","registerHook","name","callback","add","getDependants","clear","scopeErrorMessage","scope","Global","hasInvalidScopeDeps","injectables","some","injectable"],"mappings":"AAAA,SAGEA,kBAAkB,QACb,iBAAgB;AACvB,SAAoBC,KAAK,QAAQ,aAAY;AAC7C,SAASC,KAAK,QAAuB,aAAY;AAGjD,OAAO,MAAMC;;IACFC,MAAmB;IAE5BC,YACE,AAAmBC,WAElB,CACD;aAHmBA,cAAAA;aAHZF,QAAQ,IAAIF;IAMlB;IAEHK,cAA+BH,KAAQ,EAAE;QACvCF,MAAMM,KAAK,CAACJ,OAAO,IAAI,CAACA,KAAK;IAC/B;IAEAK,aAA6BC,IAAO,EAAEC,QAAqB,EAAE;QAC3D,IAAI,CAACP,KAAK,CAACQ,GAAG,CAACF,MAAMC;IACvB;IAEA,CAACE,gBAAsC,CAAC;IAExCC,QAAQ;QACN,IAAI,CAACV,KAAK,CAACU,KAAK;IAClB;AACF;AAEA,OAAO,MAAMC,oBAAoB,CAACL,MAAMM,QAAQf,MAAMgB,MAAM,GAC1D,CAAC,EAAEP,KAAK,WAAW,EAAEM,MAAM,0CAA0C,CAAC,CAAA;AAExE,OAAO,SAASE,oBACdC,WAA4B,EAC5BH,QAAQf,MAAMgB,MAAM;IAEpB,OAAOE,YAAYC,IAAI,CACrB,CAACC,aAAerB,mBAAmBqB,gBAAgBL;AAEvD"}
|
package/index.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export * from './lib/constants.ts'
|
|
2
|
-
export * from './lib/
|
|
2
|
+
export * from './lib/container.ts'
|
|
3
3
|
export * from './lib/enums.ts'
|
|
4
4
|
export * from './lib/hooks.ts'
|
|
5
|
+
export * from './lib/injectables.ts'
|
|
5
6
|
export * from './lib/logger.ts'
|
|
7
|
+
export * from './lib/plugin.ts'
|
|
6
8
|
export * from './lib/registry.ts'
|
|
7
|
-
export * from './lib/container.ts'
|
|
8
|
-
export * from './lib/injectables.ts'
|
|
9
9
|
export * from './lib/types.ts'
|
|
10
|
-
export * from './lib/
|
|
10
|
+
export * from './lib/types.ts'
|
|
11
11
|
export * from './lib/utils/index.ts'
|
package/lib/logger.ts
CHANGED
package/lib/registry.ts
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
getInjectableScope,
|
|
5
5
|
} from './container.ts'
|
|
6
6
|
import { type Hook, Scope } from './enums.ts'
|
|
7
|
-
import { type HookType
|
|
7
|
+
import { Hooks, type HookType } from './hooks.ts'
|
|
8
8
|
import type { Logger } from './logger.ts'
|
|
9
9
|
|
|
10
10
|
export class Registry {
|
package/package.json
CHANGED
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"pino": "^9.0.0",
|
|
13
13
|
"pino-pretty": "^11.0.0",
|
|
14
|
-
"@nmtjs/
|
|
15
|
-
"@nmtjs/
|
|
14
|
+
"@nmtjs/type": "0.6.3",
|
|
15
|
+
"@nmtjs/common": "0.6.3"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"@types/node": "^20"
|
|
@@ -21,11 +21,10 @@
|
|
|
21
21
|
"index.ts",
|
|
22
22
|
"lib",
|
|
23
23
|
"dist",
|
|
24
|
-
"tsconfig.json",
|
|
25
24
|
"LICENSE.md",
|
|
26
25
|
"README.md"
|
|
27
26
|
],
|
|
28
|
-
"version": "0.6.
|
|
27
|
+
"version": "0.6.3",
|
|
29
28
|
"scripts": {
|
|
30
29
|
"build": "neemata-build ./index.ts './lib/**/*.ts'",
|
|
31
30
|
"type-check": "tsc --noEmit"
|
package/tsconfig.json
DELETED