Compare commits

...

18 Commits

Author SHA1 Message Date
7f09f1b6f4 2.2.1 2025-01-25 01:23:27 +01:00
842784f2ee fix(core): Remove unused logcontext classes and update exports 2025-01-25 01:23:27 +01:00
8ba3b9085b 2.2.0 2025-01-25 01:22:12 +01:00
b0b4de3ab3 feat(tests): Added a new test script to demonstrate and validate AsyncContext functionality 2025-01-25 01:22:11 +01:00
33e2d01aca 2.1.8 2025-01-23 20:11:40 +01:00
c829b9c41e fix(core): Refactor and clean up class imports and exports 2025-01-23 20:11:40 +01:00
6332bf671a 2.1.7 2025-01-23 20:06:18 +01:00
6a373a93b3 fix(core): Enhanced debugging and improved dependency tracking 2025-01-23 20:06:18 +01:00
57d1dc3fe0 2.1.6 2025-01-19 20:06:19 +01:00
98f6afec7e fix(core): Updated dependencies and improved AsyncStore debugging and cleanup 2025-01-19 20:06:18 +01:00
8548ad9684 2.1.5 2025-01-19 11:15:46 +01:00
702fbcbded fix(dependencies): Update dependencies for improved compatibility 2025-01-19 11:15:46 +01:00
62b2f976cf 2.1.4 2025-01-19 00:30:21 +01:00
39ec78f358 fix(documentation): Remove unnecessary conclusion section from the README for better clarity. 2025-01-19 00:30:21 +01:00
f0c6b96648 2.1.3 2025-01-19 00:29:01 +01:00
18f63b07f7 fix(readme): Update README.md for better clarity and examples. 2025-01-19 00:29:00 +01:00
36d52a9e03 2.1.2 2025-01-19 00:27:07 +01:00
9c0b53f373 fix(core): Improve scope handling in async contexts. 2025-01-19 00:27:06 +01:00
23 changed files with 725 additions and 729 deletions

View File

@ -1,5 +1,66 @@
# Changelog
## 2025-01-25 - 2.2.1 - fix(core)
Remove unused logcontext classes and update exports
- Removed classes and plugins from logcontext that were not in use.
- Adjusted exports to not include deprecated logger-related modules.
## 2025-01-25 - 2.2.0 - feat(tests)
Added a new test script to demonstrate and validate AsyncContext functionality
- Introduced jstrial.js in the test directory to ensure the correct working of AsyncContext.
- The new tests handle various scenarios, including the independence of child stores and data deletion.
## 2025-01-23 - 2.1.8 - fix(core)
Refactor and clean up class imports and exports
- Simplified class file structure by unifying imports and exports.
- Removed redundant `logcontext.*` prefixes from filenames.
- Ensured consistent path references in index.ts.
## 2025-01-23 - 2.1.7 - fix(core)
Enhanced debugging and improved dependency tracking
- Updated @types/node to version ^22.10.10.
- Updated simple-async-context to version ^0.0.23.
- Enhanced the logDebug method to check for the existence of process and environment variables.
- Fixed dependency versions in package.json.
## 2025-01-19 - 2.1.6 - fix(core)
Updated dependencies and improved AsyncStore debugging and cleanup
- Upgraded 'simple-async-context' dependency to version ^0.0.16 for consistency and improvements.
- Added detailed debugging information in AsyncStore when DEBUG environment variable is set.
- Enhanced cleanup process for deleted keys in AsyncStore.
- Removed redundant dependencies from package.json and logcontext.plugins.ts.
## 2025-01-19 - 2.1.5 - fix(dependencies)
Update dependencies for improved compatibility
- Updated @types/node to version ^22.10.7
- Updated @types/shortid to version 2.2.0
- Updated simple-async-context to version ^0.0.15
## 2025-01-19 - 2.1.4 - fix(documentation)
Remove unnecessary conclusion section from the README for better clarity.
- Removed the 'Conclusion' header which was redundant in the README.
## 2025-01-19 - 2.1.3 - fix(readme)
Update README.md for better clarity and examples.
- Enhanced documentation with clearer examples of AsyncContext usage.
- Reorganized sections for improved understanding of `runScoped` and its benefits.
- Added detailed test script example in README.md.
- Clarified data isolation and deletion mechanisms within scoped functions.
## 2025-01-19 - 2.1.2 - fix(core)
Improve scope handling in async contexts.
- Modified the handling of scoped stores within `AsyncContext.runScoped` to simplify the API usage.
- Refactored tests to verify the context's behavior and isolation between parent and child stores.
## 2025-01-18 - 2.1.1 - fix(build)
Fix tsbuild script to include missing flag

1
dist/index.d.ts vendored
View File

@ -1 +0,0 @@
export * from './logcontext.classes.logger';

7
dist/index.js vendored
View File

@ -1,7 +0,0 @@
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./logcontext.classes.logger"));
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUFBLGlEQUE0QyJ9

View File

@ -1,60 +0,0 @@
import * as plugins from './logcontext.plugins';
import { LogMap } from './logcontext.classes.logmap';
export declare class Logger {
namespaceString: string;
clsNameSpace: plugins.smartcls.Namespace;
logmap: LogMap;
thirdPartyLogger: any;
child: any;
settings: {
enableScope: () => void;
disableScope: () => void;
enableAddData: () => void;
disableAddData: () => void;
};
private settingsParams;
constructor(namespaceArg?: string);
addData(paramNameArg: string, dataArg: any): void;
addThirdPartyLogger(thirdPartyLoggerArg: any): void;
/**
* debug
* @param logMessageArg
*/
debug(logMessageArg: any): void;
/**
* log
* @param logMessageArg
*/
log(logMessageArg: any): void;
/**
* info
* @param logObjectArg
*/
info(logObjectArg: any): void;
/**
* error
* @param logMessageArg
* @param args
*/
error(logMessageArg: any, ...args: any[]): void;
/**
* warn
* @param logMessageArg
* @param args
*/
warn(logMessageArg: any, ...args: any[]): void;
/**
* fatal
* @param logMessageArg
* @param args
*/
fatal(logMessageArg: any, ...args: any[]): void;
scope(funcArg: any): void;
/**
* routes the log according to whats available in the environment
* @param {string} logMethod
* @param {any} message
* @param {any[]} ...args
*/
private routeLog(logMethod, message, ...args);
}

View File

@ -1,113 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const plugins = require("./logcontext.plugins");
const logcontext_classes_logmap_1 = require("./logcontext.classes.logmap");
class Logger {
constructor(namespaceArg = plugins.shortid()) {
this.settings = {
enableScope: () => {
this.settingsParams.scope = true;
},
disableScope: () => {
this.settingsParams.scope = false;
},
enableAddData: () => {
this.settingsParams.addData = true;
},
disableAddData: () => {
this.settingsParams.addData = false;
}
};
this.settingsParams = {
scope: true,
addData: true
};
this.namespaceString = namespaceArg;
this.clsNameSpace = plugins.smartcls.createNamespace(this.namespaceString);
this.logmap = new logcontext_classes_logmap_1.LogMap(this.clsNameSpace);
}
addData(paramNameArg, dataArg) {
if (this.settingsParams.addData) {
this.logmap.addData(paramNameArg, dataArg);
}
}
addThirdPartyLogger(thirdPartyLoggerArg) {
this.thirdPartyLogger = thirdPartyLoggerArg;
}
/**
* debug
* @param logMessageArg
*/
debug(logMessageArg) {
this.routeLog('debug', logMessageArg);
}
/**
* log
* @param logMessageArg
*/
log(logMessageArg) {
this.routeLog('log', logMessageArg);
}
/**
* info
* @param logObjectArg
*/
info(logObjectArg) {
this.routeLog('info', logObjectArg);
}
/**
* error
* @param logMessageArg
* @param args
*/
error(logMessageArg, ...args) {
this.routeLog('error', logMessageArg, ...args);
}
/**
* warn
* @param logMessageArg
* @param args
*/
warn(logMessageArg, ...args) {
this.routeLog('warn', logMessageArg, ...args);
}
/**
* fatal
* @param logMessageArg
* @param args
*/
fatal(logMessageArg, ...args) {
this.routeLog('fatal', logMessageArg, ...args);
}
// creates a new async scope
scope(funcArg) {
// create node continuation scope
if (this.settingsParams.scope) {
this.clsNameSpace.run(funcArg);
}
else {
funcArg();
}
}
/**
* routes the log according to whats available in the environment
* @param {string} logMethod
* @param {any} message
* @param {any[]} ...args
*/
routeLog(logMethod, message, ...args) {
let logObject = {
message: message,
type: logMethod,
logContext: this.logmap.getAllData()
};
if (this.thirdPartyLogger && this.thirdPartyLogger[logMethod]) {
this.thirdPartyLogger[logMethod](logObject, ...args);
}
else {
console.log(logObject);
}
}
}
exports.Logger = Logger;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibG9nY29udGV4dC5jbGFzc2VzLmxvZ2dlci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL2xvZ2NvbnRleHQuY2xhc3Nlcy5sb2dnZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSxnREFBZ0Q7QUFDaEQsMkVBQXFEO0FBRXJEO0lBeUJFLFlBQVksZUFBdUIsT0FBTyxDQUFDLE9BQU8sRUFBRTtRQW5CcEQsYUFBUSxHQUFHO1lBQ1QsV0FBVyxFQUFFLEdBQUcsRUFBRTtnQkFDaEIsSUFBSSxDQUFDLGNBQWMsQ0FBQyxLQUFLLEdBQUcsSUFBSSxDQUFDO1lBQ25DLENBQUM7WUFDRCxZQUFZLEVBQUUsR0FBRyxFQUFFO2dCQUNqQixJQUFJLENBQUMsY0FBYyxDQUFDLEtBQUssR0FBRyxLQUFLLENBQUM7WUFDcEMsQ0FBQztZQUNELGFBQWEsRUFBRSxHQUFHLEVBQUU7Z0JBQ2xCLElBQUksQ0FBQyxjQUFjLENBQUMsT0FBTyxHQUFHLElBQUksQ0FBQztZQUNyQyxDQUFDO1lBQ0QsY0FBYyxFQUFFLEdBQUcsRUFBRTtnQkFDbkIsSUFBSSxDQUFDLGNBQWMsQ0FBQyxPQUFPLEdBQUcsS0FBSyxDQUFDO1lBQ3RDLENBQUM7U0FDRixDQUFDO1FBQ00sbUJBQWMsR0FBeUM7WUFDN0QsS0FBSyxFQUFFLElBQUk7WUFDWCxPQUFPLEVBQUUsSUFBSTtTQUNkLENBQUM7UUFHQSxJQUFJLENBQUMsZUFBZSxHQUFHLFlBQVksQ0FBQztRQUNwQyxJQUFJLENBQUMsWUFBWSxHQUFHLE9BQU8sQ0FBQyxRQUFRLENBQUMsZUFBZSxDQUFDLElBQUksQ0FBQyxlQUFlLENBQUMsQ0FBQztRQUMzRSxJQUFJLENBQUMsTUFBTSxHQUFHLElBQUksa0NBQU0sQ0FBQyxJQUFJLENBQUMsWUFBWSxDQUFDLENBQUM7SUFDOUMsQ0FBQztJQUVELE9BQU8sQ0FBQyxZQUFvQixFQUFFLE9BQVk7UUFDeEMsRUFBRSxDQUFDLENBQUMsSUFBSSxDQUFDLGNBQWMsQ0FBQyxPQUFPLENBQUMsQ0FBQyxDQUFDO1lBQ2hDLElBQUksQ0FBQyxNQUFNLENBQUMsT0FBTyxDQUFDLFlBQVksRUFBRSxPQUFPLENBQUMsQ0FBQztRQUM3QyxDQUFDO0lBQ0gsQ0FBQztJQUVELG1CQUFtQixDQUFDLG1CQUFtQjtRQUNyQyxJQUFJLENBQUMsZ0JBQWdCLEdBQUcsbUJBQW1CLENBQUM7SUFDOUMsQ0FBQztJQUVEOzs7T0FHRztJQUNILEtBQUssQ0FBQyxhQUFhO1FBQ2pCLElBQUksQ0FBQyxRQUFRLENBQUMsT0FBTyxFQUFFLGFBQWEsQ0FBQyxDQUFDO0lBQ3hDLENBQUM7SUFFRDs7O09BR0c7SUFDSCxHQUFHLENBQUMsYUFBYTtRQUNmLElBQUksQ0FBQyxRQUFRLENBQUMsS0FBSyxFQUFFLGFBQWEsQ0FBQyxDQUFDO0lBQ3RDLENBQUM7SUFFRDs7O09BR0c7SUFDSCxJQUFJLENBQUMsWUFBWTtRQUNmLElBQUksQ0FBQyxRQUFRLENBQUMsTUFBTSxFQUFFLFlBQVksQ0FBQyxDQUFDO0lBQ3RDLENBQUM7SUFFRDs7OztPQUlHO0lBQ0gsS0FBSyxDQUFDLGFBQWEsRUFBRSxHQUFHLElBQUk7UUFDMUIsSUFBSSxDQUFDLFFBQVEsQ0FBQyxPQUFPLEVBQUUsYUFBYSxFQUFFLEdBQUcsSUFBSSxDQUFDLENBQUM7SUFDakQsQ0FBQztJQUVEOzs7O09BSUc7SUFDSCxJQUFJLENBQUMsYUFBYSxFQUFFLEdBQUcsSUFBSTtRQUN6QixJQUFJLENBQUMsUUFBUSxDQUFDLE1BQU0sRUFBRSxhQUFhLEVBQUUsR0FBRyxJQUFJLENBQUMsQ0FBQztJQUNoRCxDQUFDO0lBRUQ7Ozs7T0FJRztJQUNILEtBQUssQ0FBQyxhQUFhLEVBQUUsR0FBRyxJQUFJO1FBQzFCLElBQUksQ0FBQyxRQUFRLENBQUMsT0FBTyxFQUFFLGFBQWEsRUFBRSxHQUFHLElBQUksQ0FBQyxDQUFDO0lBQ2pELENBQUM7SUFFRCw0QkFBNEI7SUFDNUIsS0FBSyxDQUFDLE9BQVk7UUFDaEIsaUNBQWlDO1FBQ2pDLEVBQUUsQ0FBQyxDQUFDLElBQUksQ0FBQyxjQUFjLENBQUMsS0FBSyxDQUFDLENBQUMsQ0FBQztZQUM5QixJQUFJLENBQUMsWUFBWSxDQUFDLEdBQUcsQ0FBQyxPQUFPLENBQUMsQ0FBQztRQUNqQyxDQUFDO1FBQUMsSUFBSSxDQUFDLENBQUM7WUFDTixPQUFPLEVBQUUsQ0FBQztRQUNaLENBQUM7SUFDSCxDQUFDO0lBRUQ7Ozs7O09BS0c7SUFDSyxRQUFRLENBQUMsU0FBUyxFQUFFLE9BQU8sRUFBRSxHQUFHLElBQUk7UUFDMUMsSUFBSSxTQUFTLEdBQUc7WUFDZCxPQUFPLEVBQUUsT0FBTztZQUNoQixJQUFJLEVBQUUsU0FBUztZQUNmLFVBQVUsRUFBRSxJQUFJLENBQUMsTUFBTSxDQUFDLFVBQVUsRUFBRTtTQUNyQyxDQUFDO1FBQ0YsRUFBRSxDQUFDLENBQUMsSUFBSSxDQUFDLGdCQUFnQixJQUFJLElBQUksQ0FBQyxnQkFBZ0IsQ0FBQyxTQUFTLENBQUMsQ0FBQyxDQUFDLENBQUM7WUFDOUQsSUFBSSxDQUFDLGdCQUFnQixDQUFDLFNBQVMsQ0FBQyxDQUFDLFNBQVMsRUFBRSxHQUFHLElBQUksQ0FBQyxDQUFDO1FBQ3ZELENBQUM7UUFBQyxJQUFJLENBQUMsQ0FBQztZQUNOLE9BQU8sQ0FBQyxHQUFHLENBQUMsU0FBUyxDQUFDLENBQUM7UUFDekIsQ0FBQztJQUNILENBQUM7Q0FDRjtBQXhIRCx3QkF3SEMifQ==

View File

@ -1,11 +0,0 @@
import * as plugins from './logcontext.plugins';
import { Namespace } from 'smartcls';
export declare class LogMap {
clsNamespace: Namespace;
paramMap: plugins.lik.Stringmap;
constructor(clsNamespaceArg: Namespace);
addData(paramName: string, logData: any): void;
deleteData(paramName: string): void;
getData(paramName: string): any;
getAllData(): {};
}

View File

@ -1,28 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const plugins = require("./logcontext.plugins");
class LogMap {
constructor(clsNamespaceArg) {
this.paramMap = new plugins.lik.Stringmap();
this.clsNamespace = clsNamespaceArg;
}
addData(paramName, logData) {
this.paramMap.addString(paramName);
this.clsNamespace.set(paramName, logData);
}
deleteData(paramName) {
this.clsNamespace.set(paramName, null);
}
getData(paramName) {
return this.clsNamespace.get(paramName);
}
getAllData() {
let returnObject = {};
for (let stringArg of this.paramMap.getStringArray()) {
returnObject[stringArg] = this.clsNamespace.get(stringArg);
}
return returnObject;
}
}
exports.LogMap = LogMap;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibG9nY29udGV4dC5jbGFzc2VzLmxvZ21hcC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL2xvZ2NvbnRleHQuY2xhc3Nlcy5sb2dtYXAudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSxnREFBZ0Q7QUFLaEQ7SUFJRSxZQUFZLGVBQTBCO1FBRnRDLGFBQVEsR0FBRyxJQUFJLE9BQU8sQ0FBQyxHQUFHLENBQUMsU0FBUyxFQUFFLENBQUM7UUFHckMsSUFBSSxDQUFDLFlBQVksR0FBRyxlQUFlLENBQUM7SUFDdEMsQ0FBQztJQUVELE9BQU8sQ0FBQyxTQUFpQixFQUFFLE9BQU87UUFDaEMsSUFBSSxDQUFDLFFBQVEsQ0FBQyxTQUFTLENBQUMsU0FBUyxDQUFDLENBQUM7UUFDbkMsSUFBSSxDQUFDLFlBQVksQ0FBQyxHQUFHLENBQUMsU0FBUyxFQUFFLE9BQU8sQ0FBQyxDQUFDO0lBQzVDLENBQUM7SUFFRCxVQUFVLENBQUMsU0FBaUI7UUFDMUIsSUFBSSxDQUFDLFlBQVksQ0FBQyxHQUFHLENBQUMsU0FBUyxFQUFFLElBQUksQ0FBQyxDQUFDO0lBQ3pDLENBQUM7SUFFRCxPQUFPLENBQUMsU0FBaUI7UUFDdkIsTUFBTSxDQUFDLElBQUksQ0FBQyxZQUFZLENBQUMsR0FBRyxDQUFDLFNBQVMsQ0FBQyxDQUFDO0lBQzFDLENBQUM7SUFFRCxVQUFVO1FBQ1IsSUFBSSxZQUFZLEdBQUcsRUFBRSxDQUFDO1FBQ3RCLEdBQUcsQ0FBQyxDQUFDLElBQUksU0FBUyxJQUFJLElBQUksQ0FBQyxRQUFRLENBQUMsY0FBYyxFQUFFLENBQUMsQ0FBQyxDQUFDO1lBQ3JELFlBQVksQ0FBQyxTQUFTLENBQUMsR0FBRyxJQUFJLENBQUMsWUFBWSxDQUFDLEdBQUcsQ0FBQyxTQUFTLENBQUMsQ0FBQztRQUM3RCxDQUFDO1FBQ0QsTUFBTSxDQUFDLFlBQVksQ0FBQztJQUN0QixDQUFDO0NBQ0Y7QUE1QkQsd0JBNEJDIn0=

View File

@ -1,5 +0,0 @@
import 'typings-global';
import * as lik from 'lik';
import * as smartcls from 'smartcls';
import * as shortid from 'shortid';
export { lik, smartcls, shortid };

View File

@ -1,10 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
require("typings-global");
const lik = require("lik");
exports.lik = lik;
const smartcls = require("smartcls");
exports.smartcls = smartcls;
const shortid = require("shortid");
exports.shortid = shortid;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibG9nY29udGV4dC5wbHVnaW5zLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvbG9nY29udGV4dC5wbHVnaW5zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUEsMEJBQXdCO0FBRXhCLDJCQUEyQjtBQUlsQixrQkFBRztBQUhaLHFDQUFxQztBQUd2Qiw0QkFBUTtBQUZ0QixtQ0FBbUM7QUFFWCwwQkFBTyJ9

View File

@ -1,6 +1,6 @@
{
"name": "@push.rocks/smartcontext",
"version": "2.1.1",
"version": "2.2.1",
"description": "A module providing advanced asynchronous context management to enrich logs with context and manage scope effectively in Node.js applications.",
"exports": {
".": "./dist_ts/index.js"
@ -17,17 +17,13 @@
"@git.zone/tsbuild": "^2.1.27",
"@git.zone/tsbundle": "^2.0.7",
"@git.zone/tsrun": "^1.2.39",
"@git.zone/tstest": "^1.0.57",
"@git.zone/tstest": "^1.0.96",
"@push.rocks/smartdelay": "^3.0.5",
"@push.rocks/tapbundle": "^5.0.4",
"@types/node": "^18.11.18"
"@push.rocks/tapbundle": "^5.5.6",
"@types/node": "^22.10.10"
},
"dependencies": {
"@push.rocks/lik": "^6.0.0",
"@push.rocks/smartcls": "^1.0.9",
"@push.rocks/smartunique": "^3.0.3",
"@types/shortid": "0.0.29",
"simple-async-context": "^0.0.13"
"simple-async-context": "^0.0.23"
},
"private": false,
"browserslist": [

212
pnpm-lock.yaml generated
View File

@ -8,21 +8,9 @@ importers:
.:
dependencies:
'@push.rocks/lik':
specifier: ^6.0.0
version: 6.1.0
'@push.rocks/smartcls':
specifier: ^1.0.9
version: 1.0.14
'@push.rocks/smartunique':
specifier: ^3.0.3
version: 3.0.9
'@types/shortid':
specifier: 0.0.29
version: 0.0.29
simple-async-context:
specifier: ^0.0.13
version: 0.0.13
specifier: ^0.0.23
version: 0.0.23
devDependencies:
'@git.zone/tsbuild':
specifier: ^2.1.27
@ -34,17 +22,17 @@ importers:
specifier: ^1.2.39
version: 1.3.3
'@git.zone/tstest':
specifier: ^1.0.57
version: 1.0.90(@aws-sdk/credential-providers@3.731.1)(socks@2.8.3)
specifier: ^1.0.96
version: 1.0.96(@aws-sdk/credential-providers@3.731.1)(socks@2.8.3)
'@push.rocks/smartdelay':
specifier: ^3.0.5
version: 3.0.5
'@push.rocks/tapbundle':
specifier: ^5.0.4
version: 5.5.4(@aws-sdk/credential-providers@3.731.1)(socks@2.8.3)
specifier: ^5.5.6
version: 5.5.6(@aws-sdk/credential-providers@3.731.1)(socks@2.8.3)
'@types/node':
specifier: ^18.11.18
version: 18.19.71
specifier: ^22.10.10
version: 22.10.10
packages:
@ -238,8 +226,8 @@ packages:
resolution: {integrity: sha512-2Yv65nlWnWlSpe3fXEyX5i7fx5kIKo4Qbcj+hMO0odwaneFjfXw5fdum+4yL20O0QiaHpia0cYQ9xpNMqrBwHg==}
engines: {node: '>=6.9.0'}
'@cloudflare/workers-types@4.20250109.0':
resolution: {integrity: sha512-Y1zgSaEOOevl9ORpzgMcm4j535p3nK2lrblHHvYM2yxR50SBKGh+wvkRFAIxWRfjUGZEU+Fp6923EGioDBbobA==}
'@cloudflare/workers-types@4.20250121.0':
resolution: {integrity: sha512-2bBosmudcwvUOKzuCL/Jum18LDh3QoU0QnTNMXIgcVwuq3LaNzyZnOW14bFXPhLU/84ZjNO3zO5R/U11Zgag2Q==}
'@colors/colors@1.6.0':
resolution: {integrity: sha512-Ir+AOibqzrIsL6ajt3Rz3LskB7OiMVHqltZmspbW/TJuTVuyOMirVqAkjfY6JISiLHgyNqicAC8AyHHGzNd/dA==}
@ -573,8 +561,8 @@ packages:
resolution: {integrity: sha512-DDzWunkxXLtXJTxBf4EioXLwhuqdA2VzdTmOzWrw4Z4Qnms/YM67q36yajwNohAajPYyRz5DayU0ikrceFXyVw==}
hasBin: true
'@git.zone/tstest@1.0.90':
resolution: {integrity: sha512-McytXK46GiReEps7wHWW6zOHYCFF4sywjj6auHjhGqzOogA2Wju1YtZRL+o+OAUb61kQxNFRras6Xg/4Zth0Bw==}
'@git.zone/tstest@1.0.96':
resolution: {integrity: sha512-c1FlIiRmMiLB56BP5JlPrJ9VTYCSjOjA7v0avVMAjLqBl06GB3Urun0sAXHjcjr2h5lOmTiw0KprRlJ7KF2XFA==}
hasBin: true
'@hapi/bourne@3.0.0':
@ -729,9 +717,6 @@ packages:
'@push.rocks/smartcli@4.0.11':
resolution: {integrity: sha512-KDWfUqWBoUZsOEtsDx36d6qc8GG7Zo5E+HHamYY68KVDO8BMu6jbBucoUUPDksczLEmbXKLmroBP1mn/xozQOA==}
'@push.rocks/smartcls@1.0.14':
resolution: {integrity: sha512-1Sew9ZVTS8mdaKMlOOKZ9uCcSa6QXAfT7yX8xgqF24bXZvyUcf0Lf0d6VvlAMiFJ3bA0H8AsmRFJ8F7HlKW1RA==}
'@push.rocks/smartcrypto@2.0.4':
resolution: {integrity: sha512-1+/5bsjyataf5uUkUNnnVXGRAt+gHVk1KDzozjTqgqJxHvQk1d9fVDohL6CxUhUucTPtu5VR5xNBiV8YCDuGyw==}
@ -825,6 +810,12 @@ packages:
'@push.rocks/smartpromise@4.1.0':
resolution: {integrity: sha512-1E4QZx1bYFMEgbK1C9gb4CB3YRhfkvSeffc5CnT83n7NV4Qly/Sxe9G1Jn0sQBB5+sbFHwTlj/0al5+q4gXiDw==}
'@push.rocks/smartpromise@4.2.0':
resolution: {integrity: sha512-1Yb0u/Yu68D1GPuxPhfMe2MefffqqzK+WmtrCipQl75cBXyaiNiwwrRKaG47ZJquMS+BYxqC/P40cDVAWDvMfw==}
'@push.rocks/smartpromise@4.2.1':
resolution: {integrity: sha512-toRH6DThNlyfMNCCAuUx20INaD5nbLD+q/ipzGZMZ7FR9ata3csjdnM0DUj81tuqypqkgeorZWKiDY2C85UO4Q==}
'@push.rocks/smartpuppeteer@2.0.2':
resolution: {integrity: sha512-EcYCT0PX++WjfHp7W5UYX3t8x5gSNpJMMUvhA7SHz8b2t76ItslNWxprRcF0CUQyN1fozbf5StZf7dwdGc/dIA==}
@ -882,8 +873,8 @@ packages:
'@push.rocks/smartyaml@2.0.5':
resolution: {integrity: sha512-tBcf+HaOIfeEsTMwgUZDtZERCxXQyRsWO8Ar5DjBdiSRchbhVGZQEBzXswMS0W5ZoRenjgPK+4tPW3JQGRTfbg==}
'@push.rocks/tapbundle@5.5.4':
resolution: {integrity: sha512-FDL9I95vRENAZmqyQ9/45I1aDaDqFm62rNZOaroqbYX86R7pK75YtwqA0AqQ+QYALX055xw02xlRND5tZmPByQ==}
'@push.rocks/tapbundle@5.5.6':
resolution: {integrity: sha512-V6u+nZwt4fNccxbm3ztZgHr/QAj/uKhaaOUFgtaae0jzYdds4jNEI+mXLpfXuNMgm7Nx93Lk5XUxWKTI8drjNw==}
'@push.rocks/taskbuffer@3.1.7':
resolution: {integrity: sha512-QktGVJPucqQmW/QNGnscf4FAigT1H7JWKFGFdRuDEaOHKFh9qN+PXG3QY7DtZ4jfXdGLxPN4yAufDuPSAJYFnw==}
@ -1422,8 +1413,8 @@ packages:
'@types/node-forge@1.3.11':
resolution: {integrity: sha512-FQx220y22OKNTqaByeBGqHWYz4cl94tpcxeFdvBo3wjG6XPBuZ0BNgNZRV5J5TFmmcsJ4IzsLkmGRiQbnYsBEQ==}
'@types/node@18.19.71':
resolution: {integrity: sha512-evXpcgtZm8FY4jqBSN8+DmOTcVkkvTmAayeo4Wf3m1xAruyVGzGuDh/Fb/WWX2yLItUiho42ozyJjB0dw//Tkw==}
'@types/node@22.10.10':
resolution: {integrity: sha512-X47y/mPNzxviAGY5TcYPtYL8JsY3kAq2n8fMmKoRCxq/c4v4pyGNCzM2R6+M5/umG4ZfHuT+sgqDYqWc9rJ6ww==}
'@types/parse5@6.0.3':
resolution: {integrity: sha512-SuT16Q1K51EAVPz1K29DJ/sXjhSQ0zjvsypYJ6tlwVsRV9jwW5Adq2ch8Dq8kDBCkYnELS7N7VNCSB5nC56t/g==}
@ -1455,9 +1446,6 @@ packages:
'@types/serve-static@1.15.7':
resolution: {integrity: sha512-W8Ym+h8nhuRwaKPaDw34QUkwsGi6Rc4yYqvKFo5rm2FUEhCFbzVWrxXUxuKK8TASjWsysJY0nsmNCGhCOIsrOw==}
'@types/shortid@0.0.29':
resolution: {integrity: sha1-gJPuBBam4r8qpjOBCRFLP7/6Dps=}
'@types/sinon-chai@3.2.12':
resolution: {integrity: sha512-9y0Gflk3b0+NhQZ/oxGtaAJDvRywCa5sIyaVnounqLvmf93yBF4EgIRspePtkMs3Tr844nCclYMlcCNmLCvjuQ==}
@ -1515,8 +1503,8 @@ packages:
'@types/ws@7.4.7':
resolution: {integrity: sha512-JQbbmxZTZehdc2iszGKs5oC3NFnjeay7mtAWrdt7qNtAVK0g19muApzAy4bm9byz79xa2ZnO/BOBC2R8RC5Lww==}
'@types/ws@8.5.13':
resolution: {integrity: sha512-osM/gWBTPKgHV8XkTunnegTRIsvF6owmf5w+JtAfOw472dptdm0dlGv4xCt6GwQRcC2XVOvvRE/0bAoQcL2QkA==}
'@types/ws@8.5.14':
resolution: {integrity: sha512-bd/YFLW+URhBzMXurx7lWByOu+xzU9+kb3RboOteXYDfW+tr+JZa99OyNmPINEGB/ahzKrEuc8rcv4gnpJmxTw==}
'@types/yargs-parser@21.0.3':
resolution: {integrity: sha512-I4q9QU9MQv4oEOz4tAHJtNz1cwuLxn2F3xcc2iV5WdqLPpUnj30aUuxt1mAxYTG+oe8CZMV/+6rU4S4gRDzqtQ==}
@ -1527,8 +1515,8 @@ packages:
'@types/yauzl@2.10.3':
resolution: {integrity: sha512-oJoftv0LSuaDZE3Le4DbKX+KS9G36NzOeSap90UIK0yMA/NhKJhqlSGtNDORNRaIbQfzjXDrQa0ytJ6mNRGz/Q==}
'@ungap/structured-clone@1.2.1':
resolution: {integrity: sha512-fEzPV3hSkSMltkw152tJKNARhOupqbH96MZWyRjNaYZOMIzbrTeQDG+MTc6Mr2pgzFQzFxAfmhGDNP5QK++2ZA==}
'@ungap/structured-clone@1.3.0':
resolution: {integrity: sha512-WmoN8qaIAo7WTYWbAZuG8PYEhn5fkz7dZrqTBZ7dtt//lL2Gwms1IcnQ5yHqjDfX8Ft5j4YzDM23f87zBfDe9g==}
'@web/browser-logs@0.4.1':
resolution: {integrity: sha512-ypmMG+72ERm+LvP+loj9A64MTXvWMXHUOu773cPO4L1SV/VWg6xA9Pv7vkvkXQX+ItJtCJt+KQ+U6ui2HhSFUw==}
@ -2946,8 +2934,8 @@ packages:
micromark-extension-gfm-strikethrough@2.1.0:
resolution: {integrity: sha512-ADVjpOOkjz1hhkZLlBiYA9cR2Anf8F4HqZUO6e5eDcPQd0Txw5fxLzzxnEkSkfnD0wziSGiv7sYhk/ktvbf1uw==}
micromark-extension-gfm-table@2.1.0:
resolution: {integrity: sha512-Ub2ncQv+fwD70/l4ou27b4YzfNaCJOvyX4HxXU15m7mpYY+rjuWzsLIPZHJL253Z643RpbcP1oeIJlQ/SKW67g==}
micromark-extension-gfm-table@2.1.1:
resolution: {integrity: sha512-t2OU/dXXioARrC6yWfJ4hqB7rct14e8f7m0cbI5hUmDyyIlwv5vEtooptH8INkbLzOatzKuVbQmAYcbWoyz6Dg==}
micromark-extension-gfm-tagfilter@2.0.0:
resolution: {integrity: sha512-xHlTOmuCSotIA8TW1mDIM6X2O1SiX5P9IuDtqGonFhEK0qgRI4yeC6vMxEV2dgyr2TiD+2PQ10o+cOhdVAcwfg==}
@ -3006,8 +2994,8 @@ packages:
micromark-util-sanitize-uri@2.0.1:
resolution: {integrity: sha512-9N9IomZ/YuGGZZmQec1MbgxtlgougxTodVwDzzEouPKo3qFWvymFHWcnDi2vzV1ff6kas9ucW+o3yzJK9YB1AQ==}
micromark-util-subtokenize@2.0.3:
resolution: {integrity: sha512-VXJJuNxYWSoYL6AJ6OQECCFGhIU2GGHMw8tahogePBrjkG8aCCas3ibkp7RnVOSTClg2is05/R7maAhF1XyQMg==}
micromark-util-subtokenize@2.0.4:
resolution: {integrity: sha512-N6hXjrin2GTJDe3MVjf5FuXpm12PGm80BrUAeub9XFXca8JZbP+oIwY4LJSVwFUCL1IPm/WwSVUN7goFHmSGGQ==}
micromark-util-symbol@2.0.1:
resolution: {integrity: sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==}
@ -3643,8 +3631,8 @@ packages:
resolution: {integrity: sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==}
engines: {node: '>=14'}
simple-async-context@0.0.13:
resolution: {integrity: sha512-dD45zmw9HBlSyWVQJ38VTP5RpuVED8zIiwHrouimeHxDIlNxt66j+iWHQIvbTrsd1SnWVRaLwbPvsVsy+rfjpw==}
simple-async-context@0.0.23:
resolution: {integrity: sha512-kHxBJjXJcFv6LucWaNayVx5ntp8+DU74kE8FjzyZDp5Bpo3aX5Lfgu4OmFP5QsWmF1xyv2JPlrIF3elpDxuF5w==}
simple-swizzle@0.2.2:
resolution: {integrity: sha1-pNprY1/8zMoz9w0Xy5JZLeleVXo=}
@ -3922,8 +3910,8 @@ packages:
unbzip2-stream@1.4.3:
resolution: {integrity: sha512-mlExGW4w71ebDJviH16lQLtZS32VKqsSfk80GCfUlwT/4/hNRFsoscrF/c++9xinkMzECL1uL9DDwXqFWkruPg==}
undici-types@5.26.5:
resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==}
undici-types@6.20.0:
resolution: {integrity: sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==}
unified@11.0.5:
resolution: {integrity: sha512-xKvGhPWw3k84Qjh8bI3ZeJjqnyadK+GEFtazSfZv/rKeTkTjOJho6mFqh2SM96iIcZokxiOpg78GazTSg8+KHA==}
@ -4172,7 +4160,7 @@ snapshots:
'@api.global/typedrequest': 3.1.10
'@api.global/typedrequest-interfaces': 3.0.19
'@api.global/typedsocket': 3.0.1
'@cloudflare/workers-types': 4.20250109.0
'@cloudflare/workers-types': 4.20250121.0
'@design.estate/dees-comms': 1.0.27
'@push.rocks/lik': 6.1.0
'@push.rocks/smartchok': 1.0.34
@ -4190,7 +4178,7 @@ snapshots:
'@push.rocks/smartntml': 2.0.8
'@push.rocks/smartopen': 2.0.0
'@push.rocks/smartpath': 5.0.18
'@push.rocks/smartpromise': 4.1.0
'@push.rocks/smartpromise': 4.2.1
'@push.rocks/smartrequest': 2.0.23
'@push.rocks/smartrx': 3.0.7
'@push.rocks/smartsitemap': 2.0.3
@ -4774,7 +4762,7 @@ snapshots:
dependencies:
regenerator-runtime: 0.14.1
'@cloudflare/workers-types@4.20250109.0': {}
'@cloudflare/workers-types@4.20250121.0': {}
'@colors/colors@1.6.0': {}
@ -4803,7 +4791,7 @@ snapshots:
'@push.rocks/smartdelay': 3.0.5
'@push.rocks/smartjson': 5.0.20
'@push.rocks/smartmarkdown': 3.0.3
'@push.rocks/smartpromise': 4.1.0
'@push.rocks/smartpromise': 4.2.1
'@push.rocks/smartrouter': 1.3.2
'@push.rocks/smartrx': 3.0.7
'@push.rocks/smartstate': 2.0.19
@ -5028,7 +5016,7 @@ snapshots:
'@push.rocks/smartshell': 3.2.2
tsx: 4.19.2
'@git.zone/tstest@1.0.90(@aws-sdk/credential-providers@3.731.1)(socks@2.8.3)':
'@git.zone/tstest@1.0.96(@aws-sdk/credential-providers@3.731.1)(socks@2.8.3)':
dependencies:
'@api.global/typedserver': 3.0.53
'@git.zone/tsbundle': 2.1.0
@ -5038,10 +5026,10 @@ snapshots:
'@push.rocks/smartdelay': 3.0.5
'@push.rocks/smartfile': 11.1.5
'@push.rocks/smartlog': 3.0.7
'@push.rocks/smartpromise': 4.1.0
'@push.rocks/smartpromise': 4.2.1
'@push.rocks/smartshell': 3.2.2
'@push.rocks/tapbundle': 5.5.4(@aws-sdk/credential-providers@3.731.1)(socks@2.8.3)
'@types/ws': 8.5.13
'@push.rocks/tapbundle': 5.5.6(@aws-sdk/credential-providers@3.731.1)(socks@2.8.3)
'@types/ws': 8.5.14
figures: 6.1.0
ws: 8.18.0
transitivePeerDependencies:
@ -5086,7 +5074,7 @@ snapshots:
'@jest/schemas': 29.6.3
'@types/istanbul-lib-coverage': 2.0.6
'@types/istanbul-reports': 3.0.4
'@types/node': 18.19.71
'@types/node': 22.10.10
'@types/yargs': 17.0.33
chalk: 4.1.2
@ -5322,7 +5310,7 @@ snapshots:
'@push.rocks/smartchok@1.0.34':
dependencies:
'@push.rocks/lik': 6.1.0
'@push.rocks/smartpromise': 4.1.0
'@push.rocks/smartpromise': 4.2.1
'@push.rocks/smartrx': 3.0.7
'@tempfix/watcher': 2.3.0
@ -5335,11 +5323,9 @@ snapshots:
'@push.rocks/smartrx': 3.0.7
yargs-parser: 21.1.1
'@push.rocks/smartcls@1.0.14': {}
'@push.rocks/smartcrypto@2.0.4':
dependencies:
'@push.rocks/smartpromise': 4.1.0
'@push.rocks/smartpromise': 4.2.0
'@types/node-forge': 1.3.11
node-forge: 1.3.1
@ -5349,7 +5335,7 @@ snapshots:
'@push.rocks/smartdelay': 3.0.5
'@push.rocks/smartlog': 3.0.7
'@push.rocks/smartmongo': 2.0.10(@aws-sdk/credential-providers@3.731.1)(socks@2.8.3)
'@push.rocks/smartpromise': 4.1.0
'@push.rocks/smartpromise': 4.2.0
'@push.rocks/smartrx': 3.0.7
'@push.rocks/smartstring': 4.0.15
'@push.rocks/smarttime': 4.1.1
@ -5386,7 +5372,7 @@ snapshots:
'@push.rocks/smartexpect@1.4.0':
dependencies:
'@push.rocks/smartdelay': 3.0.5
'@push.rocks/smartpromise': 4.1.0
'@push.rocks/smartpromise': 4.2.0
fast-deep-equal: 3.1.3
'@push.rocks/smartfeed@1.0.11':
@ -5511,7 +5497,7 @@ snapshots:
'@push.rocks/mongodump': 1.0.8
'@push.rocks/smartdata': 5.2.10(@aws-sdk/credential-providers@3.731.1)(socks@2.8.3)
'@push.rocks/smartpath': 5.0.18
'@push.rocks/smartpromise': 4.1.0
'@push.rocks/smartpromise': 4.2.0
mongodb-memory-server: 8.16.1
transitivePeerDependencies:
- '@aws-sdk/credential-providers'
@ -5553,7 +5539,7 @@ snapshots:
dependencies:
'@design.estate/dees-element': 2.0.39
'@happy-dom/global-registrator': 15.11.7
'@push.rocks/smartpromise': 4.1.0
'@push.rocks/smartpromise': 4.2.1
fake-indexeddb: 6.0.0
transitivePeerDependencies:
- supports-color
@ -5576,7 +5562,7 @@ snapshots:
'@push.rocks/smartfile': 11.1.5
'@push.rocks/smartnetwork': 3.0.2
'@push.rocks/smartpath': 5.0.18
'@push.rocks/smartpromise': 4.1.0
'@push.rocks/smartpromise': 4.2.1
'@push.rocks/smartpuppeteer': 2.0.2
'@push.rocks/smartunique': 3.0.9
'@tsclass/tsclass': 4.4.0
@ -5593,6 +5579,10 @@ snapshots:
'@push.rocks/smartpromise@4.1.0': {}
'@push.rocks/smartpromise@4.2.0': {}
'@push.rocks/smartpromise@4.2.1': {}
'@push.rocks/smartpuppeteer@2.0.2':
dependencies:
'@pushrocks/smartdelay': 2.0.13
@ -5664,7 +5654,7 @@ snapshots:
'@push.rocks/smartenv': 5.0.12
'@push.rocks/smartjson': 5.0.20
'@push.rocks/smartlog': 3.0.7
'@push.rocks/smartpromise': 4.1.0
'@push.rocks/smartpromise': 4.2.1
'@push.rocks/smartrx': 3.0.7
'@push.rocks/smarttime': 4.1.1
engine.io: 6.5.4
@ -5689,7 +5679,7 @@ snapshots:
'@push.rocks/isohash': 2.0.1
'@push.rocks/lik': 6.1.0
'@push.rocks/smartjson': 5.0.20
'@push.rocks/smartpromise': 4.1.0
'@push.rocks/smartpromise': 4.2.1
'@push.rocks/smartrx': 3.0.7
'@push.rocks/webstore': 2.0.20
@ -5754,7 +5744,7 @@ snapshots:
'@types/js-yaml': 3.12.10
js-yaml: 3.14.1
'@push.rocks/tapbundle@5.5.4(@aws-sdk/credential-providers@3.731.1)(socks@2.8.3)':
'@push.rocks/tapbundle@5.5.6(@aws-sdk/credential-providers@3.731.1)(socks@2.8.3)':
dependencies:
'@open-wc/testing': 4.0.0
'@push.rocks/consolecolor': 2.0.2
@ -5767,7 +5757,7 @@ snapshots:
'@push.rocks/smartjson': 5.0.20
'@push.rocks/smartmongo': 2.0.10(@aws-sdk/credential-providers@3.731.1)(socks@2.8.3)
'@push.rocks/smartpath': 5.0.18
'@push.rocks/smartpromise': 4.1.0
'@push.rocks/smartpromise': 4.2.0
'@push.rocks/smartrequest': 2.0.23
'@push.rocks/smarts3': 2.2.5
'@push.rocks/smartshell': 3.2.2
@ -6378,14 +6368,14 @@ snapshots:
'@types/accepts@1.3.7':
dependencies:
'@types/node': 18.19.71
'@types/node': 22.10.10
'@types/babel__code-frame@7.0.6': {}
'@types/body-parser@1.19.5':
dependencies:
'@types/connect': 3.4.38
'@types/node': 18.19.71
'@types/node': 22.10.10
'@types/buffer-json@2.0.3': {}
@ -6401,17 +6391,17 @@ snapshots:
'@types/clean-css@4.2.11':
dependencies:
'@types/node': 18.19.71
'@types/node': 22.10.10
source-map: 0.6.1
'@types/co-body@6.1.3':
dependencies:
'@types/node': 18.19.71
'@types/node': 22.10.10
'@types/qs': 6.9.18
'@types/connect@3.4.38':
dependencies:
'@types/node': 18.19.71
'@types/node': 22.10.10
'@types/content-disposition@0.5.8': {}
@ -6424,11 +6414,11 @@ snapshots:
'@types/connect': 3.4.38
'@types/express': 5.0.0
'@types/keygrip': 1.0.6
'@types/node': 18.19.71
'@types/node': 22.10.10
'@types/cors@2.8.17':
dependencies:
'@types/node': 18.19.71
'@types/node': 22.10.10
'@types/debounce@1.2.4': {}
@ -6442,14 +6432,14 @@ snapshots:
'@types/express-serve-static-core@4.19.6':
dependencies:
'@types/node': 18.19.71
'@types/node': 22.10.10
'@types/qs': 6.9.18
'@types/range-parser': 1.2.7
'@types/send': 0.17.4
'@types/express-serve-static-core@5.0.5':
dependencies:
'@types/node': 18.19.71
'@types/node': 22.10.10
'@types/qs': 6.9.18
'@types/range-parser': 1.2.7
'@types/send': 0.17.4
@ -6474,30 +6464,30 @@ snapshots:
'@types/from2@2.3.5':
dependencies:
'@types/node': 18.19.71
'@types/node': 22.10.10
'@types/fs-extra@11.0.4':
dependencies:
'@types/jsonfile': 6.1.4
'@types/node': 18.19.71
'@types/node': 22.10.10
'@types/fs-extra@9.0.13':
dependencies:
'@types/node': 18.19.71
'@types/node': 22.10.10
'@types/glob@7.2.0':
dependencies:
'@types/minimatch': 5.1.2
'@types/node': 18.19.71
'@types/node': 22.10.10
'@types/glob@8.1.0':
dependencies:
'@types/minimatch': 5.1.2
'@types/node': 18.19.71
'@types/node': 22.10.10
'@types/gunzip-maybe@1.4.2':
dependencies:
'@types/node': 18.19.71
'@types/node': 22.10.10
'@types/hast@3.0.4':
dependencies:
@ -6531,7 +6521,7 @@ snapshots:
'@types/jsonfile@6.1.4':
dependencies:
'@types/node': 18.19.71
'@types/node': 22.10.10
'@types/keygrip@1.0.6': {}
@ -6548,7 +6538,7 @@ snapshots:
'@types/http-errors': 2.0.4
'@types/keygrip': 1.0.6
'@types/koa-compose': 3.2.8
'@types/node': 18.19.71
'@types/node': 22.10.10
'@types/mdast@4.0.4':
dependencies:
@ -6566,11 +6556,11 @@ snapshots:
'@types/node-forge@1.3.11':
dependencies:
'@types/node': 18.19.71
'@types/node': 22.10.10
'@types/node@18.19.71':
'@types/node@22.10.10':
dependencies:
undici-types: 5.26.5
undici-types: 6.20.0
'@types/parse5@6.0.3': {}
@ -6586,23 +6576,21 @@ snapshots:
'@types/s3rver@3.7.4':
dependencies:
'@types/node': 18.19.71
'@types/node': 22.10.10
'@types/semver@7.5.8': {}
'@types/send@0.17.4':
dependencies:
'@types/mime': 1.3.5
'@types/node': 18.19.71
'@types/node': 22.10.10
'@types/serve-static@1.15.7':
dependencies:
'@types/http-errors': 2.0.4
'@types/node': 18.19.71
'@types/node': 22.10.10
'@types/send': 0.17.4
'@types/shortid@0.0.29': {}
'@types/sinon-chai@3.2.12':
dependencies:
'@types/chai': 5.0.1
@ -6620,11 +6608,11 @@ snapshots:
'@types/tar-stream@2.2.3':
dependencies:
'@types/node': 18.19.71
'@types/node': 22.10.10
'@types/through2@2.0.41':
dependencies:
'@types/node': 18.19.71
'@types/node': 22.10.10
'@types/triple-beam@1.3.5': {}
@ -6648,7 +6636,7 @@ snapshots:
'@types/whatwg-url@8.2.2':
dependencies:
'@types/node': 18.19.71
'@types/node': 22.10.10
'@types/webidl-conversions': 7.0.3
'@types/which@2.0.2': {}
@ -6657,11 +6645,11 @@ snapshots:
'@types/ws@7.4.7':
dependencies:
'@types/node': 18.19.71
'@types/node': 22.10.10
'@types/ws@8.5.13':
'@types/ws@8.5.14':
dependencies:
'@types/node': 18.19.71
'@types/node': 22.10.10
'@types/yargs-parser@21.0.3': {}
@ -6671,10 +6659,10 @@ snapshots:
'@types/yauzl@2.10.3':
dependencies:
'@types/node': 18.19.71
'@types/node': 22.10.10
optional: true
'@ungap/structured-clone@1.2.1': {}
'@ungap/structured-clone@1.3.0': {}
'@web/browser-logs@0.4.1':
dependencies:
@ -7256,7 +7244,7 @@ snapshots:
dependencies:
'@types/cookie': 0.4.1
'@types/cors': 2.8.17
'@types/node': 18.19.71
'@types/node': 22.10.10
accepts: 1.3.8
base64id: 2.0.0
cookie: 0.4.2
@ -7722,7 +7710,7 @@ snapshots:
hast-util-sanitize@5.0.2:
dependencies:
'@types/hast': 3.0.4
'@ungap/structured-clone': 1.2.1
'@ungap/structured-clone': 1.3.0
unist-util-position: 5.0.0
hast-util-to-html@9.0.4:
@ -7977,7 +7965,7 @@ snapshots:
jest-util@29.7.0:
dependencies:
'@jest/types': 29.6.3
'@types/node': 18.19.71
'@types/node': 22.10.10
chalk: 4.1.2
ci-info: 3.9.0
graceful-fs: 4.2.11
@ -8308,7 +8296,7 @@ snapshots:
dependencies:
'@types/hast': 3.0.4
'@types/mdast': 4.0.4
'@ungap/structured-clone': 1.2.1
'@ungap/structured-clone': 1.3.0
devlop: 1.1.0
micromark-util-sanitize-uri: 2.0.1
trim-lines: 3.0.1
@ -8359,7 +8347,7 @@ snapshots:
micromark-util-html-tag-name: 2.0.1
micromark-util-normalize-identifier: 2.0.1
micromark-util-resolve-all: 2.0.1
micromark-util-subtokenize: 2.0.3
micromark-util-subtokenize: 2.0.4
micromark-util-symbol: 2.0.1
micromark-util-types: 2.0.1
@ -8397,7 +8385,7 @@ snapshots:
micromark-util-symbol: 2.0.1
micromark-util-types: 2.0.1
micromark-extension-gfm-table@2.1.0:
micromark-extension-gfm-table@2.1.1:
dependencies:
devlop: 1.1.0
micromark-factory-space: 2.0.1
@ -8422,7 +8410,7 @@ snapshots:
micromark-extension-gfm-autolink-literal: 2.1.0
micromark-extension-gfm-footnote: 2.1.0
micromark-extension-gfm-strikethrough: 2.1.0
micromark-extension-gfm-table: 2.1.0
micromark-extension-gfm-table: 2.1.1
micromark-extension-gfm-tagfilter: 2.0.0
micromark-extension-gfm-task-list-item: 2.1.0
micromark-util-combine-extensions: 2.0.1
@ -8509,7 +8497,7 @@ snapshots:
micromark-util-encode: 2.0.1
micromark-util-symbol: 2.0.1
micromark-util-subtokenize@2.0.3:
micromark-util-subtokenize@2.0.4:
dependencies:
devlop: 1.1.0
micromark-util-chunked: 2.0.1
@ -8536,7 +8524,7 @@ snapshots:
micromark-util-normalize-identifier: 2.0.1
micromark-util-resolve-all: 2.0.1
micromark-util-sanitize-uri: 2.0.1
micromark-util-subtokenize: 2.0.3
micromark-util-subtokenize: 2.0.4
micromark-util-symbol: 2.0.1
micromark-util-types: 2.0.1
transitivePeerDependencies:
@ -9190,7 +9178,7 @@ snapshots:
signal-exit@4.1.0: {}
simple-async-context@0.0.13: {}
simple-async-context@0.0.23: {}
simple-swizzle@0.2.2:
dependencies:
@ -9493,7 +9481,7 @@ snapshots:
buffer: 5.7.1
through: 2.3.8
undici-types@5.26.5: {}
undici-types@6.20.0: {}
unified@11.0.5:
dependencies:

355
readme.md
View File

@ -2,251 +2,220 @@
A module to enrich logs with context, featuring async log contexts and scope management.
Special thanks to Ilias Bhallil for his awesome simple-async-context library.
## Install
To install the `@push.rocks/smartcontext` module, you can use npm. Make sure you have Node.js and npm installed on your system. Navigate to your project directory and run the following command:
Make sure you have Node.js and npm installed, then run:
```bash
npm install @push.rocks/smartcontext
```
This command will download and install the module and its dependencies into your project's `node_modules` directory.
This will install the library and its dependencies into your local `node_modules` folder.
## Usage
The `@push.rocks/smartcontext` module provides an efficient way to enrich your logging with contextual information. It features asynchronous log contexts and scope management, especially useful in complex asynchronous workflows in Node.js applications. This documentation will guide you through its core components: `AsyncContext` and `AsyncStore`.
The `@push.rocks/smartcontext` module provides an efficient way to enrich your code (often for logging) with contextual information. It uses asynchronous context management to support hierarchical scopes—particularly helpful in complex or nested asynchronous operations in Node.js.
### Setting Up and Basic Usage
First, import the necessary classes from the module in your TypeScript application:
```typescript
import { AsyncContext, AsyncStore } from '@push.rocks/smartcontext';
```
#### Creating a Context
You can create an `AsyncContext` for managing scope-based data sharing. Each context maintains a top-level `AsyncStore` instance. Lets create a simple context and store some data:
```typescript
const mainContext = new AsyncContext();
// Add some data to the store
mainContext.store.add('username', 'john_doe');
mainContext.store.add('role', 'admin');
console.log(mainContext.store.get('username')); // Outputs: 'john_doe'
console.log(mainContext.store.get('role')); // Outputs: 'admin'
```
This `mainContext` acts as a container for contextual data throughout the lifecycle of your application or a specific code block.
### Scoping with `runScoped`
The `runScoped` method allows you to run a function within a specific child `AsyncStore` scope. This is vital for isolating child data during asynchronous operations, while still having access to any relevant parent data:
```typescript
await mainContext.runScoped(async (childStore: AsyncStore) => {
childStore.add('transactionId', 'txn_123456');
console.log(childStore.get('transactionId')); // Outputs: 'txn_123456'
// Child store can also access data from the parent context:
console.log(childStore.get('username')); // Outputs: 'john_doe'
console.log(childStore.get('role')); // Outputs: 'admin'
});
```
Changes made within this child store do not leak back to the parent unless explicitly intended.
#### Isolating Data in Scoped Functions
Data added within a child scope is only stored locally, unless you decide to propagate it to the parent. Additionally, you can delete data in the child without affecting the parent:
```typescript
await mainContext.runScoped(async (childStore: AsyncStore) => {
childStore.add('temporaryData', 'tempValue');
console.log(childStore.get('temporaryData')); // Outputs: 'tempValue'
// Delete data in child scope
childStore.delete('temporaryData');
console.log(childStore.get('temporaryData')); // Outputs: undefined
});
```
In this example, `temporaryData` is never propagated to the parent. Once deleted within the scope, its gone for that child context.
### Advanced Usage
Below are some patterns to demonstrate more advanced scenarios.
#### Handling Complex Asynchronous Flows
Consider a scenario where you process a list of user requests asynchronously, assigning each request its own temporary data:
```typescript
import { AsyncContext } from '@push.rocks/smartcontext';
import { v4 as uuidv4 } from 'uuid';
async function processUserRequests(users: string[], asyncContext: AsyncContext) {
for (const user of users) {
await asyncContext.runScoped(async (childStore: AsyncStore) => {
// Assign a unique request ID
const requestId = uuidv4();
childStore.add('currentUser', user);
childStore.add('requestId', requestId);
console.log(`Processing user: ${childStore.get('currentUser')} with Request ID: ${childStore.get('requestId')}`);
// Simulate an async operation
await new Promise((resolve) => setTimeout(resolve, 1000));
console.log(`Completed processing for user: ${childStore.get('currentUser')}`);
});
}
}
const mainContext = new AsyncContext();
processUserRequests(['alice', 'bob'], mainContext);
```
Each users scope remains neatly contained while still sharing any parent data (if present). This is highly beneficial in servers that handle multiple requests or tasks in parallel.
#### Sharing Data Across Scopes
Occasionally, you may want the child scope to add or modify data that persists in the parent. By default, `childStore` only extends the parent for lookup; changes remain local to the child. If you need truly shared data, you can write data directly to the parent store as well:
```typescript
const newContext = new AsyncContext();
await newContext.runScoped(async (childStore: AsyncStore) => {
// This affects only the child store
childStore.add('childMessage', 'I am a child.');
// Directly manipulate the parent store if needed:
newContext.store.add('parentMessage', 'I am the parent (updated).');
});
// Checking the parent store:
console.log(newContext.store.get('parentMessage')); // Outputs: 'I am the parent (updated)'
console.log(newContext.store.get('childMessage')); // Outputs: undefined (child-only)
```
This approach helps you maintain clarity on what data belongs to the parent vs. a transient child operation.
#### Parallel Scopes
When dealing with parallel asynchronous operations, each scope can be maintained independently. For instance, multiple login operations can be handled by the same parent context yet remain separate at runtime:
### Basic Setup
```typescript
import { AsyncContext } from '@push.rocks/smartcontext';
const userContext = new AsyncContext();
userContext.store.add('appVersion', '1.2.0');
const asyncContext = new AsyncContext();
async function handleUserLogin(userId: string, context: AsyncContext) {
await context.runScoped(async (childStore: AsyncStore) => {
childStore.add('sessionUser', userId);
console.log(`User: ${childStore.get('sessionUser')}, App: ${childStore.get('appVersion')}`);
// More processing for the user...
});
}
await Promise.all([
handleUserLogin('user123', userContext),
handleUserLogin('user456', userContext),
]);
// The parent store is always accessible through `asyncContext.store`
asyncContext.store.add('username', 'john_doe');
console.log(asyncContext.store.get('username')); // 'john_doe'
```
In this example, the `userContext` store data (like `appVersion`) is accessible within each child scope, but each user session remains isolated. The parents data is shared and read-only for the children, unless children write specifically to the parent context.
#### Error Handling and Context-Enriched Logging
### `runScoped`
By leveraging contextual data, your logs can capture additional diagnostic details automatically:
When you call `asyncContext.runScoped(async () => { ... })`, the library automatically creates a **child** `AsyncStore`. Inside that scoped function, `asyncContext.store` refers to the child store. Any data you add or delete there is isolated from the parent store. However, you can still read parent data if it hasnt been overridden.
```typescript
async function performTaskWithLogging(taskId: string, context: AsyncContext) {
try {
await context.runScoped(async (childStore: AsyncStore) => {
childStore.add('taskId', taskId);
// Simulate some failing operation
throw new Error('Task failed due to unexpected error');
});
} catch (error) {
console.error(`[Error] Task ID: ${context.store.get('taskId')}, Error: ${error.message}`);
}
}
await asyncContext.runScoped(async () => {
// Inside this callback, `asyncContext.store` is a *child* store
asyncContext.store.add('transactionId', 'txn_abc123');
console.log(asyncContext.store.get('transactionId')); // 'txn_abc123'
const loggingContext = new AsyncContext();
performTaskWithLogging('task_789', loggingContext);
// We can also see parent data like 'username'
console.log(asyncContext.store.get('username')); // 'john_doe'
});
// Outside `runScoped`, asyncContext.store reverts to the parent store
console.log(asyncContext.store.get('transactionId')); // undefined
```
In the example above, we track `taskId` in the context store, ensuring that any error logs or additional logging statements automatically include that identifying information.
### Managing Contexts Across Modules
### Isolating Data
In large applications, you might want different modules to read or update shared context data without tight coupling between modules. One pattern is to define an `AsyncContext` in a root or shared location and pass it as needed:
Because each call to `runScoped` returns control to the parent store afterward, any keys added in a child scope disappear once the scope completes (unless you explicitly move them to the parent). This mechanism keeps data from leaking between scopes.
```typescript
// main.ts
import { AsyncContext } from '@push.rocks/smartcontext';
import { userModule } from './userModule';
import { billingModule } from './billingModule';
// Parent store
asyncContext.store.add('someParentKey', 'parentValue');
const globalContext = new AsyncContext();
globalContext.store.add('appName', 'SmartContextApp');
// Child scope
await asyncContext.runScoped(async () => {
asyncContext.store.add('scopedKey', 'childValue');
console.log(asyncContext.store.get('scopedKey')); // 'childValue'
});
userModule(globalContext);
billingModule(globalContext);
// Outside, the child key is gone
console.log(asyncContext.store.get('scopedKey')); // undefined
```
Then, each module file can utilize that shared context:
### Deleting Data
If the child deletes a key that exists in the parent, it will only remove it from the childs view of the store. Once the scope completes, the parent store is unaffected.
```typescript
// userModule.ts
export async function userModule(context: AsyncContext) {
await context.runScoped(async (childStore) => {
childStore.add('moduleName', 'UserModule');
console.log(`[UserModule] appName: ${childStore.get('appName')}`);
});
}
asyncContext.store.add('deletableKey', 'originalValue');
await asyncContext.runScoped(async () => {
console.log(asyncContext.store.get('deletableKey')); // 'originalValue'
asyncContext.store.delete('deletableKey');
console.log(asyncContext.store.get('deletableKey')); // undefined in child
});
console.log(asyncContext.store.get('deletableKey')); // 'originalValue' remains in parent
```
### Parallel or Sequential Scopes
You can call `runScoped` multiple times, whether sequentially or in parallel (with `Promise.all`). Each invocation creates its own isolated child store, preventing data collisions across asynchronous tasks.
```typescript
// billingModule.ts
export async function billingModule(context: AsyncContext) {
await context.runScoped(async (childStore) => {
childStore.add('moduleName', 'BillingModule');
console.log(`[BillingModule] appName: ${childStore.get('appName')}`);
});
}
await asyncContext.runScoped(async () => {
asyncContext.store.add('childKey1', 'childValue1');
console.log(asyncContext.store.get('childKey1')); // 'childValue1'
});
await asyncContext.runScoped(async () => {
asyncContext.store.add('childKey2', 'childValue2');
console.log(asyncContext.store.get('childKey2')); // 'childValue2'
});
// Both keys were added in separate scopes, so they won't exist in the parent
console.log(asyncContext.store.get('childKey1')); // undefined
console.log(asyncContext.store.get('childKey2')); // undefined
```
This approach keeps the code cleaner and ensures each module has access to shared data while retaining isolation where needed.
`@push.rocks/smartcontext` equips developers with a sophisticated asynchronous context management system, helping maintain clarity and consistency in logging and context sharing. Heres a recap of the benefits:
### Testing Example
- **Scoped Data**: Run logical operations within isolated child scopes, reducing contamination of global or parent-level data.
- **Asynchronous Safety**: Each asynchronous operation can track its own context, preventing race conditions on shared state.
- **Enhanced Logging**: Include relevant contextual data in your logs automatically for easier debugging and tracing.
- **Module-Friendly**: Share contexts without introducing deep module interdependencies.
The following is a complete test script (using [tapbundle](https://www.npmjs.com/package/@push.rocks/tapbundle)) demonstrating how child stores inherit data from the parent but remain isolated. After each scoped block, new child keys vanish, and any parent keys deleted inside the child remain intact in the parent.
These features simplify building robust Node.js applications, where concurrency and context tracking can otherwise become unwieldy. Enjoy exploring the breadth of this modules functionality, and tailor it to meet your projects unique challenges.
```typescript
import { tap, expect } from '@push.rocks/tapbundle';
import { AsyncContext } from '../ts/logcontext.classes.asynccontext.js';
const asyncContext = new AsyncContext();
tap.test('should run a scoped function and add data to a child store', async () => {
// Add some default data to the parent store
asyncContext.store.add('parentKey', 'parentValue');
expect(asyncContext.store.get('parentKey')).toEqual('parentValue');
// Now run a child scope, add some data, and check that parent data is still accessible
await asyncContext.runScoped(async () => {
asyncContext.store.add('childKey', 'childValue');
// Child sees its own data
expect(asyncContext.store.get('childKey')).toEqual('childValue');
// Child also sees parent data
expect(asyncContext.store.get('parentKey')).toEqual('parentValue');
});
});
tap.test('should not contaminate the parent store with child-only data', async () => {
// Create a new child scope
await asyncContext.runScoped(async () => {
asyncContext.store.add('temporaryKey', 'temporaryValue');
expect(asyncContext.store.get('temporaryKey')).toEqual('temporaryValue');
});
// After scope finishes, 'temporaryKey' won't exist in the parent
expect(asyncContext.store.get('temporaryKey')).toBeUndefined();
});
tap.test('should allow adding data in multiple scopes independently', async () => {
// Add data in the first scope
await asyncContext.runScoped(async () => {
asyncContext.store.add('childKey1', 'childValue1');
expect(asyncContext.store.get('childKey1')).toEqual('childValue1');
});
// Add data in the second scope
await asyncContext.runScoped(async () => {
asyncContext.store.add('childKey2', 'childValue2');
expect(asyncContext.store.get('childKey2')).toEqual('childValue2');
});
// Neither childKey1 nor childKey2 should exist in the parent store
expect(asyncContext.store.get('childKey1')).toBeUndefined();
expect(asyncContext.store.get('childKey2')).toBeUndefined();
});
tap.test('should allow deleting data in a child store without removing it from the parent store', async () => {
// Ensure parent has some data
asyncContext.store.add('deletableKey', 'iShouldStayInParent');
await asyncContext.runScoped(async () => {
// Child sees the parent's data
expect(asyncContext.store.get('deletableKey')).toEqual('iShouldStayInParent');
// Delete it in the child
asyncContext.store.delete('deletableKey');
// Child no longer sees it
expect(asyncContext.store.get('deletableKey')).toBeUndefined();
});
// Parent still has it
expect(asyncContext.store.get('deletableKey')).toEqual('iShouldStayInParent');
});
tap.test('should allow multiple child scopes to share the same parent store data', async () => {
// Add a key to the parent store
asyncContext.store.add('sharedKey', 'sharedValue');
expect(asyncContext.store.get('sharedKey')).toEqual('sharedValue');
// First child scope
await asyncContext.runScoped(async () => {
expect(asyncContext.store.get('sharedKey')).toEqual('sharedValue');
});
// Second child scope
await asyncContext.runScoped(async () => {
expect(asyncContext.store.get('sharedKey')).toEqual('sharedValue');
});
});
export default tap.start();
```
With this updated `runScoped` design, theres no need to explicitly instantiate or manage child stores. The context automatically switches from the parent store to the child store while within the callback, then reverts back to the parent store afterwards. This structure makes it easy to:
- Keep each async operations state isolated
- Preserve read-access to parent context data
- Avoid overwriting or polluting other operations data
This pattern works particularly well for logging or any scenario where you need to pass metadata through deeply nested async calls without manually juggling that data everywhere in your code.
## License and Legal Information
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
This repository is under the [MIT License](./license). Please note that the MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as necessary for reasonable use in describing the origin of the work.
### Trademarks
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Usage must be approved in writing by Task Venture Capital GmbH.
### Company Information
Task Venture Capital GmbH
Registered at District Court Bremen HRB 35230 HB, Germany
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
For any legal inquiries, please contact us at hello@task.vc. By using this repository, you acknowledge that you have read this section and agree to comply with its terms.

110
test/jstrial.js Normal file
View File

@ -0,0 +1,110 @@
import { tap, expect } from '@push.rocks/tapbundle';
import * as asynccontext from '../dist_ts/index.js';
if (typeof process !== 'undefined') {
// process.env.DEBUG = 'true';
}
/**
* This test file demonstrates how to use the AsyncContext and ensures
* that runScoped() properly creates child AsyncStore contexts and merges parent data.
*/
const asyncContext = new asynccontext.AsyncContext();
tap.test('should run a scoped function and add data to a child store', async () => {
// add some default data to the parent store
asyncContext.store.add('parentKey', 'parentValue');
expect(asyncContext.store.get('parentKey')).toEqual('parentValue');
// now run a child scope, add some data, and check that parent's data is still accessible
await asyncContext.runScoped(async () => {
asyncContext.store.add('childKey', 'childValue');
// child should see its own data
expect(asyncContext.store.get('childKey')).toEqual('childValue');
// child should also see parent data
expect(asyncContext.store.get('parentKey')).toEqual('parentValue');
});
});
tap.test('should not contaminate the parent store with child-only data', async () => {
// create a new child scope
await asyncContext.runScoped(async () => {
asyncContext.store.add('temporaryKey', 'temporaryValue');
expect(asyncContext.store.get('temporaryKey')).toEqual('temporaryValue');
});
// after the child scope finishes, 'temporaryKey' should not exist in the parent
expect(asyncContext.store.get('temporaryKey')).toBeUndefined();
});
tap.test('should allow adding data in multiple scopes independently', async (toolsArg) => {
const done = toolsArg.cumulativeDefer();
// add data in first scope
asyncContext.runScoped(async () => {
const subDone = done.subDefer();
asyncContext.store.add('childKey1', 'childValue1-v1');
await toolsArg.delayFor(2000);
expect(asyncContext.store.get('childKey1')).toEqual('childValue1-v1');
subDone.resolve();
});
asyncContext.runScoped(async () => {
const subDone = done.subDefer();
asyncContext.store.add('childKey1', 'childValue1-v2');
await toolsArg.delayFor(1000);
expect(asyncContext.store.get('childKey1')).toEqual('childValue1-v2');
subDone.resolve();
});
// add data in second scope
asyncContext.runScoped(async () => {
asyncContext.store.add('childKey2', 'childValue2');
expect(asyncContext.store.get('childKey2')).toEqual('childValue2');
});
// neither childKey1 nor childKey2 should exist in the parent store
expect(asyncContext.store.get('childKey1')).toBeUndefined();
expect(asyncContext.store.get('childKey2')).toBeUndefined();
await done.promise;
});
tap.test(
'should allow deleting data in a child store without removing it from the parent store',
async (toolsArg) => {
// ensure parent has some data
asyncContext.store.add('deletableKey', 'iShouldStayInParent');
await asyncContext.runScoped(async () => {
// child sees the parent's data
expect(asyncContext.store.get('deletableKey')).toEqual('iShouldStayInParent');
// attempt to delete it in the child
asyncContext.store.delete('deletableKey');
// child no longer sees it
expect(asyncContext.store.get('deletableKey')).toBeUndefined();
// but parent still has it
});
expect(asyncContext.store.get('deletableKey')).toEqual('iShouldStayInParent');
}
);
tap.test('should allow multiple child scopes to share the same parent store data', async () => {
// add a key to the parent store
asyncContext.store.add('sharedKey', 'sharedValue');
expect(asyncContext.store.get('sharedKey')).toEqual('sharedValue');
// first child scope
await asyncContext.runScoped(async () => {
expect(asyncContext.store.get('sharedKey')).toEqual('sharedValue');
});
// second child scope
await asyncContext.runScoped(async () => {
expect(asyncContext.store.get('sharedKey')).toEqual('sharedValue');
});
});
export default tap.start();

110
test/test.both.ts Normal file
View File

@ -0,0 +1,110 @@
import { tap, expect } from '@push.rocks/tapbundle';
import * as asynccontext from '../ts/index.js';
if (typeof process !== 'undefined') {
process.env.DEBUG = 'true';
}
/**
* This test file demonstrates how to use the AsyncContext and ensures
* that runScoped() properly creates child AsyncStore contexts and merges parent data.
*/
const asyncContext = new asynccontext.AsyncContext();
tap.test('should run a scoped function and add data to a child store', async () => {
// add some default data to the parent store
asyncContext.store.add('parentKey', 'parentValue');
expect(asyncContext.store.get('parentKey')).toEqual('parentValue');
// now run a child scope, add some data, and check that parent's data is still accessible
await asyncContext.runScoped(async () => {
asyncContext.store.add('childKey', 'childValue');
// child should see its own data
expect(asyncContext.store.get('childKey')).toEqual('childValue');
// child should also see parent data
expect(asyncContext.store.get('parentKey')).toEqual('parentValue');
});
});
tap.test('should not contaminate the parent store with child-only data', async () => {
// create a new child scope
await asyncContext.runScoped(async () => {
asyncContext.store.add('temporaryKey', 'temporaryValue');
expect(asyncContext.store.get('temporaryKey')).toEqual('temporaryValue');
});
// after the child scope finishes, 'temporaryKey' should not exist in the parent
expect(asyncContext.store.get('temporaryKey')).toBeUndefined();
});
tap.test('should allow adding data in multiple scopes independently', async (toolsArg) => {
const done = toolsArg.cumulativeDefer();
// add data in first scope
asyncContext.runScoped(async () => {
const subDone = done.subDefer();
asyncContext.store.add('childKey1', 'childValue1-v1');
await toolsArg.delayFor(2000);
expect(asyncContext.store.get('childKey1')).toEqual('childValue1-v1');
subDone.resolve();
});
asyncContext.runScoped(async () => {
const subDone = done.subDefer();
asyncContext.store.add('childKey1', 'childValue1-v2');
await toolsArg.delayFor(1000);
expect(asyncContext.store.get('childKey1')).toEqual('childValue1-v2');
subDone.resolve();
});
// add data in second scope
asyncContext.runScoped(async () => {
asyncContext.store.add('childKey2', 'childValue2');
expect(asyncContext.store.get('childKey2')).toEqual('childValue2');
});
// neither childKey1 nor childKey2 should exist in the parent store
expect(asyncContext.store.get('childKey1')).toBeUndefined();
expect(asyncContext.store.get('childKey2')).toBeUndefined();
await done.promise;
});
tap.test(
'should allow deleting data in a child store without removing it from the parent store',
async (toolsArg) => {
// ensure parent has some data
asyncContext.store.add('deletableKey', 'iShouldStayInParent');
await asyncContext.runScoped(async () => {
// child sees the parent's data
expect(asyncContext.store.get('deletableKey')).toEqual('iShouldStayInParent');
// attempt to delete it in the child
asyncContext.store.delete('deletableKey');
// child no longer sees it
expect(asyncContext.store.get('deletableKey')).toBeUndefined();
// but parent still has it
});
expect(asyncContext.store.get('deletableKey')).toEqual('iShouldStayInParent');
}
);
tap.test('should allow multiple child scopes to share the same parent store data', async () => {
// add a key to the parent store
asyncContext.store.add('sharedKey', 'sharedValue');
expect(asyncContext.store.get('sharedKey')).toEqual('sharedValue');
// first child scope
await asyncContext.runScoped(async () => {
expect(asyncContext.store.get('sharedKey')).toEqual('sharedValue');
});
// second child scope
await asyncContext.runScoped(async () => {
expect(asyncContext.store.get('sharedKey')).toEqual('sharedValue');
});
});
export default tap.start();

View File

@ -1,88 +0,0 @@
import { tap, expect } from '@push.rocks/tapbundle';
import { AsyncContext } from '../ts/logcontext.classes.asynccontext.js';
import { AsyncStore } from '../ts/logcontext.classes.asyncstore.js';
/**
* This test file demonstrates how to use the AsyncContext and ensures
* that runScoped() properly creates child AsyncStore contexts and merges parent data.
*/
const parentContext = new AsyncContext();
tap.test('should run a scoped function and add data to a child store', async () => {
// add some default data to the parent store
parentContext.store.add('parentKey', 'parentValue');
expect(parentContext.store.get('parentKey')).toEqual('parentValue');
// now run a child scope, add some data, and check that parent's data is still accessible
await parentContext.runScoped(async (childStore: AsyncStore) => {
childStore.add('childKey', 'childValue');
// child should see its own data
expect(childStore.get('childKey')).toEqual('childValue');
// child should also see parent data
expect(childStore.get('parentKey')).toEqual('parentValue');
});
});
tap.test('should not contaminate the parent store with child-only data', async () => {
// create a new child scope
await parentContext.runScoped(async (childStore: AsyncStore) => {
childStore.add('temporaryKey', 'temporaryValue');
expect(childStore.get('temporaryKey')).toEqual('temporaryValue');
});
// after the child scope finishes, 'temporaryKey' should not exist in the parent
expect(parentContext.store.get('temporaryKey')).toBeUndefined();
});
tap.test('should allow adding data in multiple scopes independently', async () => {
// add data in first scope
await parentContext.runScoped(async (childStore: AsyncStore) => {
childStore.add('childKey1', 'childValue1');
expect(childStore.get('childKey1')).toEqual('childValue1');
});
// add data in second scope
await parentContext.runScoped(async (childStore: AsyncStore) => {
childStore.add('childKey2', 'childValue2');
expect(childStore.get('childKey2')).toEqual('childValue2');
});
// neither childKey1 nor childKey2 should exist in the parent store
expect(parentContext.store.get('childKey1')).toBeUndefined();
expect(parentContext.store.get('childKey2')).toBeUndefined();
});
tap.test('should allow deleting data in a child store without removing it from the parent store', async () => {
// ensure parent has some data
parentContext.store.add('deletableKey', 'iShouldStayInParent');
await parentContext.runScoped(async (childStore: AsyncStore) => {
// child sees the parent's data
expect(childStore.get('deletableKey')).toEqual('iShouldStayInParent');
// attempt to delete it in the child
childStore.delete('deletableKey');
// child no longer sees it
expect(childStore.get('deletableKey')).toBeUndefined();
// but parent still has it
expect(parentContext.store.get('deletableKey')).toEqual('iShouldStayInParent');
});
});
tap.test('should allow multiple child scopes to share the same parent store data', async () => {
// add a key to the parent store
parentContext.store.add('sharedKey', 'sharedValue');
expect(parentContext.store.get('sharedKey')).toEqual('sharedValue');
// first child scope
await parentContext.runScoped(async (firstChild: AsyncStore) => {
expect(firstChild.get('sharedKey')).toEqual('sharedValue');
});
// second child scope
await parentContext.runScoped(async (secondChild: AsyncStore) => {
expect(secondChild.get('sharedKey')).toEqual('sharedValue');
});
});
tap.start();

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@push.rocks/smartcontext',
version: '2.1.1',
version: '2.2.1',
description: 'A module providing advanced asynchronous context management to enrich logs with context and manage scope effectively in Node.js applications.'
}

View File

@ -0,0 +1,18 @@
import * as plugins from './plugins.js';
import { AsyncStore } from './classes.asyncstore.js';
export class AsyncContext {
private _context = new plugins.simpleAsyncContext.AsyncContext.Variable<AsyncStore>();
private _store = new AsyncStore();
get store() {
return this._context.get() || this._store;
}
set store(value: AsyncStore) {
this._store = value;
}
public async runScoped(functionArg: () => Promise<void>) {
await this._context.run(new AsyncStore(this.store), async () => {
await functionArg()
});
}
}

135
ts/classes.asyncstore.ts Normal file
View File

@ -0,0 +1,135 @@
import * as plugins from './plugins.js';
export class AsyncStore {
private static idCounter = 0;
private id: number;
private parentStore?: AsyncStore;
private deletedKeys: string[] = [];
private dataObject: { [key: string]: any } = {};
constructor(parentStore?: AsyncStore) {
this.parentStore = parentStore;
this.id = AsyncStore.idCounter++;
}
/**
* Logs debug info if process.env.DEBUG is set.
*/
private logDebug(functionName: string, before: Record<string, any>, after: Record<string, any>) {
if (typeof process !== 'undefined' && process.env && process.env.DEBUG) {
console.log(`Store ID: ${this.id}`);
console.log(`Function: ${functionName}`);
console.log('--- Before ---');
console.log(before);
console.log('--- After ---');
console.log(after);
console.log('-----------------------');
}
}
/**
* Cleans up the deleted keys if they no longer exist in any parent store.
*/
private cleanUp() {
for (const key of this.deletedKeys) {
if (this.parentStore && this.parentStore.get(key)) {
// Parent still has it, so keep in deletedKeys
} else {
const index = this.deletedKeys.indexOf(key);
if (index !== -1) {
this.deletedKeys.splice(index, 1);
}
}
}
}
/**
* Adds or updates a value under a specific key in this store.
*/
public add(keyArg: string, objectArg: any) {
// capture the before state
const before = { ...this.dataObject, deletedKeys: [...this.deletedKeys] };
this.cleanUp();
// If this key was previously deleted, remove it from deletedKeys.
if (this.deletedKeys.includes(keyArg)) {
this.deletedKeys = this.deletedKeys.filter((key) => key !== keyArg);
}
this.dataObject[keyArg] = objectArg;
// capture the after state
const after = { ...this.dataObject, deletedKeys: [...this.deletedKeys] };
this.logDebug('add', before, after);
}
/**
* Deletes a key from the current store.
* If a parent store has the key, we record it in `deletedKeys` so the child store "shadows" it.
*/
public delete(paramName: string) {
// capture the before state
const before = { ...this.dataObject, deletedKeys: [...this.deletedKeys] };
this.cleanUp();
if (this.parentStore?.get(paramName)) {
// The parent store has this key; let's mark it as deleted in the child
this.deletedKeys.push(paramName);
}
delete this.dataObject[paramName];
// capture the after state
const after = { ...this.dataObject, deletedKeys: [...this.deletedKeys] };
this.logDebug('delete', before, after);
}
/**
* Gets the value of a key, checking this store first, then the parent store if necessary.
* Will log the store state before/after for debugging.
*/
public get(paramName: string) {
// capture the before state
const before = { ...this.dataObject, deletedKeys: [...this.deletedKeys] };
this.cleanUp();
// figure out if paramName is deleted or present
let result: any;
if (this.deletedKeys.includes(paramName)) {
result = undefined;
} else {
result = this.dataObject[paramName] ?? this.parentStore?.get(paramName);
}
// capture the after state; we can also show the `result` in the log
const after = {
...this.dataObject,
deletedKeys: [...this.deletedKeys],
retrievedKey: paramName,
result
};
this.logDebug('get', before, after);
return result;
}
/**
* Returns all keys and values, merged with the parent store, but
* does NOT include keys that are "deleted" in the child.
* Child store should override parent if the same key exists in both.
*/
public getAll() {
this.cleanUp();
// first, get parent's data as a shallow copy
const parentData = { ...(this.parentStore?.getAll() || {}) };
// remove keys from parent data that this child has deleted
for (const key of this.deletedKeys) {
delete parentData[key];
}
// child's data overrides parent data for any matching keys
return {
...parentData,
...this.dataObject
};
}
}

View File

@ -1 +1,2 @@
export * from './logcontext.classes.asynccontext.js';
export * from './classes.asynccontext.js';
export * from './classes.asyncstore.js';

View File

@ -1,13 +0,0 @@
import * as plugins from './logcontext.plugins.js';
import { AsyncStore } from './logcontext.classes.asyncstore.js';
export class AsyncContext {
private context = new plugins.simpleAsyncContext.AsyncContext.Variable<AsyncStore>();
public store = new AsyncStore();
public runScoped(functionArg: (storeArg: AsyncStore) => Promise<void>) {
this.context.run(this.store, async () => {
const childStore = new AsyncStore(this.store);
functionArg(childStore)
});
}
}

View File

@ -1,50 +0,0 @@
import * as plugins from './logcontext.plugins.js';
export class AsyncStore {
private parentStore?: AsyncStore;
private deletedKeys: string[] = [];
private dataObject: {[key: string]: any} = {};
constructor(parentStore?: AsyncStore) {
this.parentStore = parentStore;
}
private cleanUp() {
for (const key of this.deletedKeys) {
if (this.parentStore && this.parentStore.get(key)) {
// ok still valid
} else {
delete this.deletedKeys[key];
}
}
}
public add(keyArg: string, objectArg: any) {
this.cleanUp();
if (this.deletedKeys.includes(keyArg)) {
this.deletedKeys = this.deletedKeys.filter((key) => key !== keyArg);
}
this.dataObject[keyArg] = objectArg;
}
public delete(paramName: string) {
this.cleanUp();
if (this.parentStore.get(paramName)) {
this.deletedKeys.push(paramName);
}
delete this.dataObject[paramName];
}
public get(paramName: string) {
this.cleanUp();
if (this.deletedKeys.includes(paramName)) {
return undefined;
}
return this.dataObject[paramName] || this.parentStore?.get(paramName);
}
public getAll() {
this.cleanUp();
return {...this.dataObject, ...(this.parentStore?.getAll() || {})};
}
}

View File

@ -1,10 +0,0 @@
// pushrocks scope
import * as lik from '@push.rocks/lik';
import * as smartunique from '@push.rocks/smartunique';
export { lik, smartunique };
// third party scope
import simpleAsyncContext from 'simple-async-context';
export { simpleAsyncContext };

4
ts/plugins.ts Normal file
View File

@ -0,0 +1,4 @@
// third party scope
import simpleAsyncContext from 'simple-async-context';
export { simpleAsyncContext };