@twin.org/context 0.0.3-next.3 → 0.0.3-next.31

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # TWIN Framework Context
2
2
 
3
- This package contains helper methods and classes for using contexts.
3
+ This package is part of the framework workspace and provides helper methods/classes for context handling to support consistent development workflows across the ecosystem.
4
4
 
5
5
  ## Installation
6
6
 
@@ -1,4 +1,2 @@
1
- // Copyright 2024 IOTA Stiftung.
2
- // SPDX-License-Identifier: Apache-2.0.
3
1
  export {};
4
2
  //# sourceMappingURL=IContextIdHandler.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"IContextIdHandler.js","sourceRoot":"","sources":["../../../src/models/IContextIdHandler.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Interface describing a context ID handler.\n */\nexport interface IContextIdHandler {\n\t/**\n\t * The short form version of the context ID, should be unique enough to partition data.\n\t * @param value The full context ID value.\n\t * @returns The short form version of the context ID.\n\t */\n\tshort?(value: string): string;\n\n\t/**\n\t * Performs a runtime guard on the provided context ID value.\n\t * @param value The context ID value to guard.\n\t * @throws Guard error if the value is invalid.\n\t */\n\tguard?(value: string): void;\n}\n"]}
1
+ {"version":3,"file":"IContextIdHandler.js","sourceRoot":"","sources":["../../../src/models/IContextIdHandler.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IComponent } from \"@twin.org/core\";\n\n/**\n * Interface describing a context ID handler.\n */\nexport interface IContextIdHandler extends IComponent {\n\t/**\n\t * The short form version of the context ID, should be unique enough to partition data.\n\t * @param value The full context ID value.\n\t * @returns The short form version of the context ID.\n\t */\n\tshort?(value: string): string;\n\n\t/**\n\t * Performs a runtime guard on the provided context ID value.\n\t * @param value The context ID value to guard.\n\t * @throws Guard error if the value is invalid.\n\t */\n\tguard?(value: string): void;\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { BaseError, GeneralError } from "@twin.org/core";
1
+ import { BaseError, GeneralError, Is, SharedStore } from "@twin.org/core";
2
2
  /**
3
3
  * Class to maintain context ids and execute an async method.
4
4
  */
@@ -7,10 +7,6 @@ export class ContextIdStore {
7
7
  * Runtime name for the class.
8
8
  */
9
9
  static CLASS_NAME = "ContextIdStore";
10
- /**
11
- * The async local storage for the context ids.
12
- */
13
- static _storage;
14
10
  /**
15
11
  * Execute the method wrapped in the context.
16
12
  * @param contextIds The context IDs.
@@ -18,32 +14,37 @@ export class ContextIdStore {
18
14
  * @returns Nothing.
19
15
  */
20
16
  static async run(contextIds, asyncMethod) {
21
- return (await ContextIdStore.createStorage()).run(contextIds, asyncMethod);
17
+ const storage = await ContextIdStore.getStorage();
18
+ return storage.run(contextIds, asyncMethod);
22
19
  }
23
20
  /**
24
21
  * Get the context IDs.
25
22
  * @returns The context IDs.
26
23
  */
27
24
  static async getContextIds() {
28
- return (await ContextIdStore.createStorage()).getStore();
25
+ const storage = await ContextIdStore.getStorage();
26
+ return storage.getStore();
29
27
  }
30
28
  /**
31
- * Create the storage if it doesn't exist.
29
+ * Get the storage and create it if it doesn't exist.
32
30
  * @returns The storage.
33
31
  */
34
- static async createStorage() {
35
- if (!ContextIdStore._storage) {
32
+ static async getStorage() {
33
+ let asyncHooksStore = SharedStore.get("asyncHooks");
34
+ if (Is.empty(asyncHooksStore?.contextIds)) {
36
35
  try {
37
36
  const hooks = await import("node:async_hooks");
38
- ContextIdStore._storage = new hooks.AsyncLocalStorage({
37
+ asyncHooksStore = asyncHooksStore ?? {};
38
+ asyncHooksStore.contextIds = new hooks.AsyncLocalStorage({
39
39
  name: "AsyncContextIdsStorage"
40
40
  });
41
41
  }
42
42
  catch (err) {
43
43
  throw new GeneralError(ContextIdStore.CLASS_NAME, "asyncHooksNotAvailable", undefined, BaseError.fromError(err));
44
44
  }
45
+ SharedStore.set("asyncHooks", asyncHooksStore);
45
46
  }
46
- return ContextIdStore._storage;
47
+ return asyncHooksStore.contextIds;
47
48
  }
48
49
  }
49
50
  //# sourceMappingURL=contextIdStore.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"contextIdStore.js","sourceRoot":"","sources":["../../../src/utils/contextIdStore.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAIzD;;GAEG;AACH,MAAM,OAAO,cAAc;IAC1B;;OAEG;IACI,MAAM,CAAU,UAAU,oBAAoC;IAErE;;OAEG;IACK,MAAM,CAAC,QAAQ,CAAiC;IAExD;;;;;OAKG;IACI,MAAM,CAAC,KAAK,CAAC,GAAG,CAAc,UAAuB,EAAE,WAAoB;QACjF,OAAO,CAAC,MAAM,cAAc,CAAC,aAAa,EAAE,CAAC,CAAC,GAAG,CAAI,UAAU,EAAE,WAAW,CAAC,CAAC;IAC/E,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,KAAK,CAAC,aAAa;QAChC,OAAO,CAAC,MAAM,cAAc,CAAC,aAAa,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC;IAC1D,CAAC;IAED;;;OAGG;IACK,MAAM,CAAC,KAAK,CAAC,aAAa;QACjC,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC;YAC9B,IAAI,CAAC;gBACJ,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,kBAAkB,CAAC,CAAC;gBAC/C,cAAc,CAAC,QAAQ,GAAG,IAAI,KAAK,CAAC,iBAAiB,CAAc;oBAClE,IAAI,EAAE,wBAAwB;iBAC9B,CAAC,CAAC;YACJ,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACd,MAAM,IAAI,YAAY,CACrB,cAAc,CAAC,UAAU,EACzB,wBAAwB,EACxB,SAAS,EACT,SAAS,CAAC,SAAS,CAAC,GAAG,CAAC,CACxB,CAAC;YACH,CAAC;QACF,CAAC;QACD,OAAO,cAAc,CAAC,QAAQ,CAAC;IAChC,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { AsyncLocalStorage } from \"node:async_hooks\";\nimport { BaseError, GeneralError } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\nimport type { IContextIds } from \"../models/IContextIds.js\";\n\n/**\n * Class to maintain context ids and execute an async method.\n */\nexport class ContextIdStore {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<ContextIdStore>();\n\n\t/**\n\t * The async local storage for the context ids.\n\t */\n\tprivate static _storage: AsyncLocalStorage<IContextIds>;\n\n\t/**\n\t * Execute the method wrapped in the context.\n\t * @param contextIds The context IDs.\n\t * @param asyncMethod The async method to run.\n\t * @returns Nothing.\n\t */\n\tpublic static async run<T = unknown>(contextIds: IContextIds, asyncMethod: () => T): Promise<T> {\n\t\treturn (await ContextIdStore.createStorage()).run<T>(contextIds, asyncMethod);\n\t}\n\n\t/**\n\t * Get the context IDs.\n\t * @returns The context IDs.\n\t */\n\tpublic static async getContextIds(): Promise<IContextIds | undefined> {\n\t\treturn (await ContextIdStore.createStorage()).getStore();\n\t}\n\n\t/**\n\t * Create the storage if it doesn't exist.\n\t * @returns The storage.\n\t */\n\tprivate static async createStorage(): Promise<AsyncLocalStorage<IContextIds>> {\n\t\tif (!ContextIdStore._storage) {\n\t\t\ttry {\n\t\t\t\tconst hooks = await import(\"node:async_hooks\");\n\t\t\t\tContextIdStore._storage = new hooks.AsyncLocalStorage<IContextIds>({\n\t\t\t\t\tname: \"AsyncContextIdsStorage\"\n\t\t\t\t});\n\t\t\t} catch (err) {\n\t\t\t\tthrow new GeneralError(\n\t\t\t\t\tContextIdStore.CLASS_NAME,\n\t\t\t\t\t\"asyncHooksNotAvailable\",\n\t\t\t\t\tundefined,\n\t\t\t\t\tBaseError.fromError(err)\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\treturn ContextIdStore._storage;\n\t}\n}\n"]}
1
+ {"version":3,"file":"contextIdStore.js","sourceRoot":"","sources":["../../../src/utils/contextIdStore.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,EAAE,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAI1E;;GAEG;AACH,MAAM,OAAO,cAAc;IAC1B;;OAEG;IACI,MAAM,CAAU,UAAU,oBAAoC;IAErE;;;;;OAKG;IACI,MAAM,CAAC,KAAK,CAAC,GAAG,CAAc,UAAuB,EAAE,WAAoB;QACjF,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,UAAU,EAAE,CAAC;QAClD,OAAO,OAAO,CAAC,GAAG,CAAI,UAAU,EAAE,WAAW,CAAC,CAAC;IAChD,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,KAAK,CAAC,aAAa;QAChC,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,UAAU,EAAE,CAAC;QAClD,OAAO,OAAO,CAAC,QAAQ,EAAE,CAAC;IAC3B,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,KAAK,CAAC,UAAU;QAC7B,IAAI,eAAe,GAAG,WAAW,CAAC,GAAG,CACpC,YAAY,CACZ,CAAC;QAEF,IAAI,EAAE,CAAC,KAAK,CAAC,eAAe,EAAE,UAAU,CAAC,EAAE,CAAC;YAC3C,IAAI,CAAC;gBACJ,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,kBAAkB,CAAC,CAAC;gBAC/C,eAAe,GAAG,eAAe,IAAI,EAAE,CAAC;gBACxC,eAAe,CAAC,UAAU,GAAG,IAAI,KAAK,CAAC,iBAAiB,CAAc;oBACrE,IAAI,EAAE,wBAAwB;iBAC9B,CAAC,CAAC;YACJ,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACd,MAAM,IAAI,YAAY,CACrB,cAAc,CAAC,UAAU,EACzB,wBAAwB,EACxB,SAAS,EACT,SAAS,CAAC,SAAS,CAAC,GAAG,CAAC,CACxB,CAAC;YACH,CAAC;YACD,WAAW,CAAC,GAAG,CAAC,YAAY,EAAE,eAAe,CAAC,CAAC;QAChD,CAAC;QACD,OAAO,eAAe,CAAC,UAAU,CAAC;IACnC,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { AsyncLocalStorage } from \"node:async_hooks\";\nimport { BaseError, GeneralError, Is, SharedStore } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\nimport type { IContextIds } from \"../models/IContextIds.js\";\n\n/**\n * Class to maintain context ids and execute an async method.\n */\nexport class ContextIdStore {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<ContextIdStore>();\n\n\t/**\n\t * Execute the method wrapped in the context.\n\t * @param contextIds The context IDs.\n\t * @param asyncMethod The async method to run.\n\t * @returns Nothing.\n\t */\n\tpublic static async run<T = unknown>(contextIds: IContextIds, asyncMethod: () => T): Promise<T> {\n\t\tconst storage = await ContextIdStore.getStorage();\n\t\treturn storage.run<T>(contextIds, asyncMethod);\n\t}\n\n\t/**\n\t * Get the context IDs.\n\t * @returns The context IDs.\n\t */\n\tpublic static async getContextIds(): Promise<IContextIds | undefined> {\n\t\tconst storage = await ContextIdStore.getStorage();\n\t\treturn storage.getStore();\n\t}\n\n\t/**\n\t * Get the storage and create it if it doesn't exist.\n\t * @returns The storage.\n\t */\n\tpublic static async getStorage(): Promise<AsyncLocalStorage<IContextIds>> {\n\t\tlet asyncHooksStore = SharedStore.get<{ contextIds?: AsyncLocalStorage<IContextIds> }>(\n\t\t\t\"asyncHooks\"\n\t\t);\n\n\t\tif (Is.empty(asyncHooksStore?.contextIds)) {\n\t\t\ttry {\n\t\t\t\tconst hooks = await import(\"node:async_hooks\");\n\t\t\t\tasyncHooksStore = asyncHooksStore ?? {};\n\t\t\t\tasyncHooksStore.contextIds = new hooks.AsyncLocalStorage<IContextIds>({\n\t\t\t\t\tname: \"AsyncContextIdsStorage\"\n\t\t\t\t});\n\t\t\t} catch (err) {\n\t\t\t\tthrow new GeneralError(\n\t\t\t\t\tContextIdStore.CLASS_NAME,\n\t\t\t\t\t\"asyncHooksNotAvailable\",\n\t\t\t\t\tundefined,\n\t\t\t\t\tBaseError.fromError(err)\n\t\t\t\t);\n\t\t\t}\n\t\t\tSharedStore.set(\"asyncHooks\", asyncHooksStore);\n\t\t}\n\t\treturn asyncHooksStore.contextIds;\n\t}\n}\n"]}
@@ -1,7 +1,8 @@
1
+ import type { IComponent } from "@twin.org/core";
1
2
  /**
2
3
  * Interface describing a context ID handler.
3
4
  */
4
- export interface IContextIdHandler {
5
+ export interface IContextIdHandler extends IComponent {
5
6
  /**
6
7
  * The short form version of the context ID, should be unique enough to partition data.
7
8
  * @param value The full context ID value.
@@ -1,3 +1,4 @@
1
+ import type { AsyncLocalStorage } from "node:async_hooks";
1
2
  import type { IContextIds } from "../models/IContextIds.js";
2
3
  /**
3
4
  * Class to maintain context ids and execute an async method.
@@ -7,10 +8,6 @@ export declare class ContextIdStore {
7
8
  * Runtime name for the class.
8
9
  */
9
10
  static readonly CLASS_NAME: string;
10
- /**
11
- * The async local storage for the context ids.
12
- */
13
- private static _storage;
14
11
  /**
15
12
  * Execute the method wrapped in the context.
16
13
  * @param contextIds The context IDs.
@@ -24,8 +21,8 @@ export declare class ContextIdStore {
24
21
  */
25
22
  static getContextIds(): Promise<IContextIds | undefined>;
26
23
  /**
27
- * Create the storage if it doesn't exist.
24
+ * Get the storage and create it if it doesn't exist.
28
25
  * @returns The storage.
29
26
  */
30
- private static createStorage;
27
+ static getStorage(): Promise<AsyncLocalStorage<IContextIds>>;
31
28
  }
package/docs/changelog.md CHANGED
@@ -1,5 +1,552 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.0.3-next.31](https://github.com/twinfoundation/framework/compare/context-v0.0.3-next.30...context-v0.0.3-next.31) (2026-04-14)
4
+
5
+
6
+ ### Miscellaneous Chores
7
+
8
+ * **context:** Synchronize repo versions
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @twin.org/core bumped from 0.0.3-next.30 to 0.0.3-next.31
16
+ * @twin.org/nameof bumped from 0.0.3-next.30 to 0.0.3-next.31
17
+ * devDependencies
18
+ * @twin.org/nameof-transformer bumped from 0.0.3-next.30 to 0.0.3-next.31
19
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.3-next.30 to 0.0.3-next.31
20
+ * @twin.org/validate-locales bumped from 0.0.3-next.30 to 0.0.3-next.31
21
+
22
+ ## [0.0.3-next.30](https://github.com/twinfoundation/framework/compare/context-v0.0.3-next.29...context-v0.0.3-next.30) (2026-04-14)
23
+
24
+
25
+ ### Miscellaneous Chores
26
+
27
+ * **context:** Synchronize repo versions
28
+
29
+
30
+ ### Dependencies
31
+
32
+ * The following workspace dependencies were updated
33
+ * dependencies
34
+ * @twin.org/core bumped from 0.0.3-next.29 to 0.0.3-next.30
35
+ * @twin.org/nameof bumped from 0.0.3-next.29 to 0.0.3-next.30
36
+ * devDependencies
37
+ * @twin.org/nameof-transformer bumped from 0.0.3-next.29 to 0.0.3-next.30
38
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.3-next.29 to 0.0.3-next.30
39
+ * @twin.org/validate-locales bumped from 0.0.3-next.29 to 0.0.3-next.30
40
+
41
+ ## [0.0.3-next.29](https://github.com/twinfoundation/framework/compare/context-v0.0.3-next.28...context-v0.0.3-next.29) (2026-04-14)
42
+
43
+
44
+ ### Miscellaneous Chores
45
+
46
+ * **context:** Synchronize repo versions
47
+
48
+
49
+ ### Dependencies
50
+
51
+ * The following workspace dependencies were updated
52
+ * dependencies
53
+ * @twin.org/core bumped from 0.0.3-next.28 to 0.0.3-next.29
54
+ * @twin.org/nameof bumped from 0.0.3-next.28 to 0.0.3-next.29
55
+ * devDependencies
56
+ * @twin.org/nameof-transformer bumped from 0.0.3-next.28 to 0.0.3-next.29
57
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.3-next.28 to 0.0.3-next.29
58
+ * @twin.org/validate-locales bumped from 0.0.3-next.28 to 0.0.3-next.29
59
+
60
+ ## [0.0.3-next.28](https://github.com/twinfoundation/framework/compare/context-v0.0.3-next.27...context-v0.0.3-next.28) (2026-03-27)
61
+
62
+
63
+ ### Miscellaneous Chores
64
+
65
+ * **context:** Synchronize repo versions
66
+
67
+
68
+ ### Dependencies
69
+
70
+ * The following workspace dependencies were updated
71
+ * dependencies
72
+ * @twin.org/core bumped from 0.0.3-next.27 to 0.0.3-next.28
73
+ * @twin.org/nameof bumped from 0.0.3-next.27 to 0.0.3-next.28
74
+ * devDependencies
75
+ * @twin.org/nameof-transformer bumped from 0.0.3-next.27 to 0.0.3-next.28
76
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.3-next.27 to 0.0.3-next.28
77
+ * @twin.org/validate-locales bumped from 0.0.3-next.27 to 0.0.3-next.28
78
+
79
+ ## [0.0.3-next.27](https://github.com/twinfoundation/framework/compare/context-v0.0.3-next.26...context-v0.0.3-next.27) (2026-03-27)
80
+
81
+
82
+ ### Miscellaneous Chores
83
+
84
+ * **context:** Synchronize repo versions
85
+
86
+
87
+ ### Dependencies
88
+
89
+ * The following workspace dependencies were updated
90
+ * dependencies
91
+ * @twin.org/core bumped from 0.0.3-next.26 to 0.0.3-next.27
92
+ * @twin.org/nameof bumped from 0.0.3-next.26 to 0.0.3-next.27
93
+ * devDependencies
94
+ * @twin.org/nameof-transformer bumped from 0.0.3-next.26 to 0.0.3-next.27
95
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.3-next.26 to 0.0.3-next.27
96
+ * @twin.org/validate-locales bumped from 0.0.3-next.26 to 0.0.3-next.27
97
+
98
+ ## [0.0.3-next.26](https://github.com/twinfoundation/framework/compare/context-v0.0.3-next.25...context-v0.0.3-next.26) (2026-03-24)
99
+
100
+
101
+ ### Miscellaneous Chores
102
+
103
+ * **context:** Synchronize repo versions
104
+
105
+
106
+ ### Dependencies
107
+
108
+ * The following workspace dependencies were updated
109
+ * dependencies
110
+ * @twin.org/core bumped from 0.0.3-next.25 to 0.0.3-next.26
111
+ * @twin.org/nameof bumped from 0.0.3-next.25 to 0.0.3-next.26
112
+ * devDependencies
113
+ * @twin.org/nameof-transformer bumped from 0.0.3-next.25 to 0.0.3-next.26
114
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.3-next.25 to 0.0.3-next.26
115
+ * @twin.org/validate-locales bumped from 0.0.3-next.25 to 0.0.3-next.26
116
+
117
+ ## [0.0.3-next.25](https://github.com/twinfoundation/framework/compare/context-v0.0.3-next.24...context-v0.0.3-next.25) (2026-03-23)
118
+
119
+
120
+ ### Miscellaneous Chores
121
+
122
+ * **context:** Synchronize repo versions
123
+
124
+
125
+ ### Dependencies
126
+
127
+ * The following workspace dependencies were updated
128
+ * dependencies
129
+ * @twin.org/core bumped from 0.0.3-next.24 to 0.0.3-next.25
130
+ * @twin.org/nameof bumped from 0.0.3-next.24 to 0.0.3-next.25
131
+ * devDependencies
132
+ * @twin.org/nameof-transformer bumped from 0.0.3-next.24 to 0.0.3-next.25
133
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.3-next.24 to 0.0.3-next.25
134
+ * @twin.org/validate-locales bumped from 0.0.3-next.24 to 0.0.3-next.25
135
+
136
+ ## [0.0.3-next.24](https://github.com/twinfoundation/framework/compare/context-v0.0.3-next.23...context-v0.0.3-next.24) (2026-03-19)
137
+
138
+
139
+ ### Bug Fixes
140
+
141
+ * ensure __decorate is defined for decorators ([103a563](https://github.com/twinfoundation/framework/commit/103a563ce01ebdef6240d2e590e7b026e8692684))
142
+
143
+
144
+ ### Dependencies
145
+
146
+ * The following workspace dependencies were updated
147
+ * dependencies
148
+ * @twin.org/core bumped from 0.0.3-next.23 to 0.0.3-next.24
149
+ * @twin.org/nameof bumped from 0.0.3-next.23 to 0.0.3-next.24
150
+ * devDependencies
151
+ * @twin.org/nameof-transformer bumped from 0.0.3-next.23 to 0.0.3-next.24
152
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.3-next.23 to 0.0.3-next.24
153
+ * @twin.org/validate-locales bumped from 0.0.3-next.23 to 0.0.3-next.24
154
+
155
+ ## [0.0.3-next.23](https://github.com/twinfoundation/framework/compare/context-v0.0.3-next.22...context-v0.0.3-next.23) (2026-03-17)
156
+
157
+
158
+ ### Miscellaneous Chores
159
+
160
+ * **context:** Synchronize repo versions
161
+
162
+
163
+ ### Dependencies
164
+
165
+ * The following workspace dependencies were updated
166
+ * dependencies
167
+ * @twin.org/core bumped from 0.0.3-next.22 to 0.0.3-next.23
168
+ * @twin.org/nameof bumped from 0.0.3-next.22 to 0.0.3-next.23
169
+ * devDependencies
170
+ * @twin.org/nameof-transformer bumped from 0.0.3-next.22 to 0.0.3-next.23
171
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.3-next.22 to 0.0.3-next.23
172
+ * @twin.org/validate-locales bumped from 0.0.3-next.22 to 0.0.3-next.23
173
+
174
+ ## [0.0.3-next.22](https://github.com/twinfoundation/framework/compare/context-v0.0.3-next.21...context-v0.0.3-next.22) (2026-02-26)
175
+
176
+
177
+ ### Miscellaneous Chores
178
+
179
+ * **context:** Synchronize repo versions
180
+
181
+
182
+ ### Dependencies
183
+
184
+ * The following workspace dependencies were updated
185
+ * dependencies
186
+ * @twin.org/core bumped from 0.0.3-next.21 to 0.0.3-next.22
187
+ * @twin.org/nameof bumped from 0.0.3-next.21 to 0.0.3-next.22
188
+ * devDependencies
189
+ * @twin.org/nameof-transformer bumped from 0.0.3-next.21 to 0.0.3-next.22
190
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.3-next.21 to 0.0.3-next.22
191
+ * @twin.org/validate-locales bumped from 0.0.3-next.21 to 0.0.3-next.22
192
+
193
+ ## [0.0.3-next.21](https://github.com/twinfoundation/framework/compare/context-v0.0.3-next.20...context-v0.0.3-next.21) (2026-02-26)
194
+
195
+
196
+ ### Features
197
+
198
+ * add context id features ([#206](https://github.com/twinfoundation/framework/issues/206)) ([ef0d4ee](https://github.com/twinfoundation/framework/commit/ef0d4ee11a4f5fc6cc6f52a4958ce905c04ee13b))
199
+ * context id handler derives from component ([c868ec2](https://github.com/twinfoundation/framework/commit/c868ec21d3a576d4faa222bf130270a21936e50e))
200
+
201
+
202
+ ### Bug Fixes
203
+
204
+ * use singleton pattern for context storage ([c69f358](https://github.com/twinfoundation/framework/commit/c69f358e45361b45d4e46f19846cd5b8c99b0ccd))
205
+ * use singleton pattern for context storage ([5cc706a](https://github.com/twinfoundation/framework/commit/5cc706a2bbfc601fa3d00f3efd8b764052e9f91d))
206
+
207
+
208
+ ### Dependencies
209
+
210
+ * The following workspace dependencies were updated
211
+ * dependencies
212
+ * @twin.org/core bumped from 0.0.3-next.20 to 0.0.3-next.21
213
+ * @twin.org/nameof bumped from 0.0.3-next.20 to 0.0.3-next.21
214
+ * devDependencies
215
+ * @twin.org/nameof-transformer bumped from 0.0.3-next.20 to 0.0.3-next.21
216
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.3-next.20 to 0.0.3-next.21
217
+ * @twin.org/validate-locales bumped from 0.0.3-next.20 to 0.0.3-next.21
218
+
219
+ ## [0.0.3-next.20](https://github.com/twinfoundation/framework/compare/context-v0.0.3-next.19...context-v0.0.3-next.20) (2026-02-26)
220
+
221
+
222
+ ### Miscellaneous Chores
223
+
224
+ * **context:** Synchronize repo versions
225
+
226
+
227
+ ### Dependencies
228
+
229
+ * The following workspace dependencies were updated
230
+ * dependencies
231
+ * @twin.org/core bumped from 0.0.3-next.19 to 0.0.3-next.20
232
+ * @twin.org/nameof bumped from 0.0.3-next.19 to 0.0.3-next.20
233
+ * devDependencies
234
+ * @twin.org/nameof-transformer bumped from 0.0.3-next.19 to 0.0.3-next.20
235
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.3-next.19 to 0.0.3-next.20
236
+ * @twin.org/validate-locales bumped from 0.0.3-next.19 to 0.0.3-next.20
237
+
238
+ ## [0.0.3-next.19](https://github.com/twinfoundation/framework/compare/context-v0.0.3-next.18...context-v0.0.3-next.19) (2026-02-26)
239
+
240
+
241
+ ### Miscellaneous Chores
242
+
243
+ * **context:** Synchronize repo versions
244
+
245
+
246
+ ### Dependencies
247
+
248
+ * The following workspace dependencies were updated
249
+ * dependencies
250
+ * @twin.org/core bumped from 0.0.3-next.18 to 0.0.3-next.19
251
+ * @twin.org/nameof bumped from 0.0.3-next.18 to 0.0.3-next.19
252
+ * devDependencies
253
+ * @twin.org/nameof-transformer bumped from 0.0.3-next.18 to 0.0.3-next.19
254
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.3-next.18 to 0.0.3-next.19
255
+ * @twin.org/validate-locales bumped from 0.0.3-next.18 to 0.0.3-next.19
256
+
257
+ ## [0.0.3-next.18](https://github.com/twinfoundation/framework/compare/context-v0.0.3-next.17...context-v0.0.3-next.18) (2026-02-23)
258
+
259
+
260
+ ### Miscellaneous Chores
261
+
262
+ * **context:** Synchronize repo versions
263
+
264
+
265
+ ### Dependencies
266
+
267
+ * The following workspace dependencies were updated
268
+ * dependencies
269
+ * @twin.org/core bumped from 0.0.3-next.17 to 0.0.3-next.18
270
+ * @twin.org/nameof bumped from 0.0.3-next.17 to 0.0.3-next.18
271
+ * devDependencies
272
+ * @twin.org/nameof-transformer bumped from 0.0.3-next.17 to 0.0.3-next.18
273
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.3-next.17 to 0.0.3-next.18
274
+ * @twin.org/validate-locales bumped from 0.0.3-next.17 to 0.0.3-next.18
275
+
276
+ ## [0.0.3-next.17](https://github.com/twinfoundation/framework/compare/context-v0.0.3-next.16...context-v0.0.3-next.17) (2026-02-09)
277
+
278
+
279
+ ### Miscellaneous Chores
280
+
281
+ * **context:** Synchronize repo versions
282
+
283
+
284
+ ### Dependencies
285
+
286
+ * The following workspace dependencies were updated
287
+ * dependencies
288
+ * @twin.org/core bumped from 0.0.3-next.16 to 0.0.3-next.17
289
+ * @twin.org/nameof bumped from 0.0.3-next.16 to 0.0.3-next.17
290
+ * devDependencies
291
+ * @twin.org/nameof-transformer bumped from 0.0.3-next.16 to 0.0.3-next.17
292
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.3-next.16 to 0.0.3-next.17
293
+ * @twin.org/validate-locales bumped from 0.0.3-next.16 to 0.0.3-next.17
294
+
295
+ ## [0.0.3-next.16](https://github.com/twinfoundation/framework/compare/context-v0.0.3-next.15...context-v0.0.3-next.16) (2026-02-06)
296
+
297
+
298
+ ### Miscellaneous Chores
299
+
300
+ * **context:** Synchronize repo versions
301
+
302
+
303
+ ### Dependencies
304
+
305
+ * The following workspace dependencies were updated
306
+ * dependencies
307
+ * @twin.org/core bumped from 0.0.3-next.15 to 0.0.3-next.16
308
+ * @twin.org/nameof bumped from 0.0.3-next.15 to 0.0.3-next.16
309
+ * devDependencies
310
+ * @twin.org/nameof-transformer bumped from 0.0.3-next.15 to 0.0.3-next.16
311
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.3-next.15 to 0.0.3-next.16
312
+ * @twin.org/validate-locales bumped from 0.0.3-next.15 to 0.0.3-next.16
313
+
314
+ ## [0.0.3-next.15](https://github.com/twinfoundation/framework/compare/context-v0.0.3-next.14...context-v0.0.3-next.15) (2026-01-29)
315
+
316
+
317
+ ### Miscellaneous Chores
318
+
319
+ * **context:** Synchronize repo versions
320
+
321
+
322
+ ### Dependencies
323
+
324
+ * The following workspace dependencies were updated
325
+ * dependencies
326
+ * @twin.org/core bumped from 0.0.3-next.14 to 0.0.3-next.15
327
+ * @twin.org/nameof bumped from 0.0.3-next.14 to 0.0.3-next.15
328
+ * devDependencies
329
+ * @twin.org/nameof-transformer bumped from 0.0.3-next.14 to 0.0.3-next.15
330
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.3-next.14 to 0.0.3-next.15
331
+ * @twin.org/validate-locales bumped from 0.0.3-next.14 to 0.0.3-next.15
332
+
333
+ ## [0.0.3-next.14](https://github.com/twinfoundation/framework/compare/context-v0.0.3-next.13...context-v0.0.3-next.14) (2026-01-22)
334
+
335
+
336
+ ### Miscellaneous Chores
337
+
338
+ * **context:** Synchronize repo versions
339
+
340
+
341
+ ### Dependencies
342
+
343
+ * The following workspace dependencies were updated
344
+ * dependencies
345
+ * @twin.org/core bumped from 0.0.3-next.13 to 0.0.3-next.14
346
+ * @twin.org/nameof bumped from 0.0.3-next.13 to 0.0.3-next.14
347
+ * devDependencies
348
+ * @twin.org/nameof-transformer bumped from 0.0.3-next.13 to 0.0.3-next.14
349
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.3-next.13 to 0.0.3-next.14
350
+ * @twin.org/validate-locales bumped from 0.0.3-next.13 to 0.0.3-next.14
351
+
352
+ ## [0.0.3-next.13](https://github.com/twinfoundation/framework/compare/context-v0.0.3-next.12...context-v0.0.3-next.13) (2026-01-08)
353
+
354
+
355
+ ### Miscellaneous Chores
356
+
357
+ * **context:** Synchronize repo versions
358
+
359
+
360
+ ### Dependencies
361
+
362
+ * The following workspace dependencies were updated
363
+ * dependencies
364
+ * @twin.org/core bumped from 0.0.3-next.12 to 0.0.3-next.13
365
+ * @twin.org/nameof bumped from 0.0.3-next.12 to 0.0.3-next.13
366
+ * devDependencies
367
+ * @twin.org/nameof-transformer bumped from 0.0.3-next.12 to 0.0.3-next.13
368
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.3-next.12 to 0.0.3-next.13
369
+ * @twin.org/validate-locales bumped from 0.0.3-next.12 to 0.0.3-next.13
370
+
371
+ ## [0.0.3-next.12](https://github.com/twinfoundation/framework/compare/context-v0.0.3-next.11...context-v0.0.3-next.12) (2026-01-08)
372
+
373
+
374
+ ### Miscellaneous Chores
375
+
376
+ * **context:** Synchronize repo versions
377
+
378
+
379
+ ### Dependencies
380
+
381
+ * The following workspace dependencies were updated
382
+ * dependencies
383
+ * @twin.org/core bumped from 0.0.3-next.11 to 0.0.3-next.12
384
+ * @twin.org/nameof bumped from 0.0.3-next.11 to 0.0.3-next.12
385
+ * devDependencies
386
+ * @twin.org/nameof-transformer bumped from 0.0.3-next.11 to 0.0.3-next.12
387
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.3-next.11 to 0.0.3-next.12
388
+ * @twin.org/validate-locales bumped from 0.0.3-next.11 to 0.0.3-next.12
389
+
390
+ ## [0.0.3-next.11](https://github.com/twinfoundation/framework/compare/context-v0.0.3-next.10...context-v0.0.3-next.11) (2026-01-07)
391
+
392
+
393
+ ### Miscellaneous Chores
394
+
395
+ * **context:** Synchronize repo versions
396
+
397
+
398
+ ### Dependencies
399
+
400
+ * The following workspace dependencies were updated
401
+ * dependencies
402
+ * @twin.org/core bumped from 0.0.3-next.10 to 0.0.3-next.11
403
+ * @twin.org/nameof bumped from 0.0.3-next.10 to 0.0.3-next.11
404
+ * devDependencies
405
+ * @twin.org/nameof-transformer bumped from 0.0.3-next.10 to 0.0.3-next.11
406
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.3-next.10 to 0.0.3-next.11
407
+ * @twin.org/validate-locales bumped from 0.0.3-next.10 to 0.0.3-next.11
408
+
409
+ ## [0.0.3-next.10](https://github.com/twinfoundation/framework/compare/context-v0.0.3-next.9...context-v0.0.3-next.10) (2026-01-07)
410
+
411
+
412
+ ### Miscellaneous Chores
413
+
414
+ * **context:** Synchronize repo versions
415
+
416
+
417
+ ### Dependencies
418
+
419
+ * The following workspace dependencies were updated
420
+ * dependencies
421
+ * @twin.org/core bumped from 0.0.3-next.9 to 0.0.3-next.10
422
+ * @twin.org/nameof bumped from 0.0.3-next.9 to 0.0.3-next.10
423
+ * devDependencies
424
+ * @twin.org/nameof-transformer bumped from 0.0.3-next.9 to 0.0.3-next.10
425
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.3-next.9 to 0.0.3-next.10
426
+ * @twin.org/validate-locales bumped from 0.0.3-next.9 to 0.0.3-next.10
427
+
428
+ ## [0.0.3-next.9](https://github.com/twinfoundation/framework/compare/context-v0.0.3-next.8...context-v0.0.3-next.9) (2026-01-05)
429
+
430
+
431
+ ### Miscellaneous Chores
432
+
433
+ * **context:** Synchronize repo versions
434
+
435
+
436
+ ### Dependencies
437
+
438
+ * The following workspace dependencies were updated
439
+ * dependencies
440
+ * @twin.org/core bumped from 0.0.3-next.8 to 0.0.3-next.9
441
+ * @twin.org/nameof bumped from 0.0.3-next.8 to 0.0.3-next.9
442
+ * devDependencies
443
+ * @twin.org/nameof-transformer bumped from 0.0.3-next.8 to 0.0.3-next.9
444
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.3-next.8 to 0.0.3-next.9
445
+ * @twin.org/validate-locales bumped from 0.0.3-next.8 to 0.0.3-next.9
446
+
447
+ ## [0.0.3-next.8](https://github.com/twinfoundation/framework/compare/context-v0.0.3-next.7...context-v0.0.3-next.8) (2025-11-26)
448
+
449
+
450
+ ### Miscellaneous Chores
451
+
452
+ * **context:** Synchronize repo versions
453
+
454
+
455
+ ### Dependencies
456
+
457
+ * The following workspace dependencies were updated
458
+ * dependencies
459
+ * @twin.org/core bumped from 0.0.3-next.7 to 0.0.3-next.8
460
+ * @twin.org/nameof bumped from 0.0.3-next.7 to 0.0.3-next.8
461
+ * devDependencies
462
+ * @twin.org/nameof-transformer bumped from 0.0.3-next.7 to 0.0.3-next.8
463
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.3-next.7 to 0.0.3-next.8
464
+ * @twin.org/validate-locales bumped from 0.0.3-next.7 to 0.0.3-next.8
465
+
466
+ ## [0.0.3-next.7](https://github.com/twinfoundation/framework/compare/context-v0.0.3-next.6...context-v0.0.3-next.7) (2025-11-25)
467
+
468
+
469
+ ### Features
470
+
471
+ * add context id features ([#206](https://github.com/twinfoundation/framework/issues/206)) ([ef0d4ee](https://github.com/twinfoundation/framework/commit/ef0d4ee11a4f5fc6cc6f52a4958ce905c04ee13b))
472
+ * context id handler derives from component ([c868ec2](https://github.com/twinfoundation/framework/commit/c868ec21d3a576d4faa222bf130270a21936e50e))
473
+
474
+
475
+ ### Bug Fixes
476
+
477
+ * use singleton pattern for context storage ([c69f358](https://github.com/twinfoundation/framework/commit/c69f358e45361b45d4e46f19846cd5b8c99b0ccd))
478
+ * use singleton pattern for context storage ([5cc706a](https://github.com/twinfoundation/framework/commit/5cc706a2bbfc601fa3d00f3efd8b764052e9f91d))
479
+
480
+
481
+ ### Dependencies
482
+
483
+ * The following workspace dependencies were updated
484
+ * dependencies
485
+ * @twin.org/core bumped from 0.0.3-next.6 to 0.0.3-next.7
486
+ * @twin.org/nameof bumped from 0.0.3-next.6 to 0.0.3-next.7
487
+ * devDependencies
488
+ * @twin.org/nameof-transformer bumped from 0.0.3-next.6 to 0.0.3-next.7
489
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.3-next.6 to 0.0.3-next.7
490
+ * @twin.org/validate-locales bumped from 0.0.3-next.6 to 0.0.3-next.7
491
+
492
+ ## [0.0.3-next.6](https://github.com/twinfoundation/framework/compare/context-v0.0.3-next.5...context-v0.0.3-next.6) (2025-11-25)
493
+
494
+
495
+ ### Miscellaneous Chores
496
+
497
+ * **context:** Synchronize repo versions
498
+
499
+
500
+ ### Dependencies
501
+
502
+ * The following workspace dependencies were updated
503
+ * dependencies
504
+ * @twin.org/core bumped from 0.0.3-next.5 to 0.0.3-next.6
505
+ * @twin.org/nameof bumped from 0.0.3-next.5 to 0.0.3-next.6
506
+ * devDependencies
507
+ * @twin.org/nameof-transformer bumped from 0.0.3-next.5 to 0.0.3-next.6
508
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.3-next.5 to 0.0.3-next.6
509
+ * @twin.org/validate-locales bumped from 0.0.3-next.5 to 0.0.3-next.6
510
+
511
+ ## [0.0.3-next.5](https://github.com/twinfoundation/framework/compare/context-v0.0.3-next.4...context-v0.0.3-next.5) (2025-11-20)
512
+
513
+
514
+ ### Features
515
+
516
+ * context id handler derives from component ([c868ec2](https://github.com/twinfoundation/framework/commit/c868ec21d3a576d4faa222bf130270a21936e50e))
517
+
518
+
519
+ ### Dependencies
520
+
521
+ * The following workspace dependencies were updated
522
+ * dependencies
523
+ * @twin.org/core bumped from 0.0.3-next.4 to 0.0.3-next.5
524
+ * @twin.org/nameof bumped from 0.0.3-next.4 to 0.0.3-next.5
525
+ * devDependencies
526
+ * @twin.org/nameof-transformer bumped from 0.0.3-next.4 to 0.0.3-next.5
527
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.3-next.4 to 0.0.3-next.5
528
+ * @twin.org/validate-locales bumped from 0.0.3-next.4 to 0.0.3-next.5
529
+
530
+ ## [0.0.3-next.4](https://github.com/twinfoundation/framework/compare/context-v0.0.3-next.3...context-v0.0.3-next.4) (2025-11-13)
531
+
532
+
533
+ ### Bug Fixes
534
+
535
+ * use singleton pattern for context storage ([c69f358](https://github.com/twinfoundation/framework/commit/c69f358e45361b45d4e46f19846cd5b8c99b0ccd))
536
+ * use singleton pattern for context storage ([5cc706a](https://github.com/twinfoundation/framework/commit/5cc706a2bbfc601fa3d00f3efd8b764052e9f91d))
537
+
538
+
539
+ ### Dependencies
540
+
541
+ * The following workspace dependencies were updated
542
+ * dependencies
543
+ * @twin.org/core bumped from 0.0.3-next.3 to 0.0.3-next.4
544
+ * @twin.org/nameof bumped from 0.0.3-next.3 to 0.0.3-next.4
545
+ * devDependencies
546
+ * @twin.org/nameof-transformer bumped from 0.0.3-next.3 to 0.0.3-next.4
547
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.3-next.3 to 0.0.3-next.4
548
+ * @twin.org/validate-locales bumped from 0.0.3-next.3 to 0.0.3-next.4
549
+
3
550
  ## [0.0.3-next.3](https://github.com/twinfoundation/framework/compare/context-v0.0.3-next.2...context-v0.0.3-next.3) (2025-11-12)
4
551
 
5
552
 
@@ -57,4 +604,4 @@
57
604
  * @twin.org/nameof-vitest-plugin bumped from 0.0.3-next.0 to 0.0.3-next.1
58
605
  * @twin.org/validate-locales bumped from 0.0.3-next.0 to 0.0.3-next.1
59
606
 
60
- ## @twin.org/context - Changelog
607
+ ## Changelog
package/docs/examples.md CHANGED
@@ -1 +1,57 @@
1
- # @twin.org/context - Examples
1
+ # Context Examples
2
+
3
+ Use these snippets to keep trace identifiers consistent across asynchronous operations and service boundaries.
4
+
5
+ ## ContextIdHelper
6
+
7
+ ```typescript
8
+ import { ContextIdHelper } from '@twin.org/context';
9
+
10
+ const traceContext = {
11
+ traceId: 'trc-0011223344556677',
12
+ spanId: 'spn-9a8b7c6d5e4f3210'
13
+ };
14
+
15
+ ContextIdHelper.short(traceContext.traceId); // '0011223344556677'
16
+ ContextIdHelper.shortAll(traceContext); // { traceId: '0011223344556677', spanId: '9a8b7c6d5e4f3210' }
17
+ ```
18
+
19
+ ```typescript
20
+ import { ContextIdHelper } from '@twin.org/context';
21
+
22
+ const contextIds = {
23
+ traceId: 'trace-1234',
24
+ spanId: 'span-5678',
25
+ requestId: 'req-90ab'
26
+ };
27
+
28
+ const combined = ContextIdHelper.shortCombined(contextIds); // '1234:5678:90ab'
29
+ ContextIdHelper.shortSplit(combined); // ['1234', '5678', '90ab']
30
+ ```
31
+
32
+ ## ContextIdStore
33
+
34
+ ```typescript
35
+ import { ContextIdStore } from '@twin.org/context';
36
+
37
+ await ContextIdStore.run({ traceId: 'trc-01', spanId: 'spn-02' }, async () => {
38
+ ContextIdStore.getContextIds(); // { traceId: 'trc-01', spanId: 'spn-02' }
39
+ });
40
+ ```
41
+
42
+ ## ContextIdHandlerFactory
43
+
44
+ ```typescript
45
+ import { ContextIdHandlerFactory } from '@twin.org/context';
46
+ import type { IContextIdHandler } from '@twin.org/context';
47
+
48
+ class RequestContextHandler implements IContextIdHandler {
49
+ public getContextIds() {
50
+ return { traceId: 'trc-1001', spanId: 'spn-2002' };
51
+ }
52
+ }
53
+
54
+ ContextIdHandlerFactory.register('request', () => new RequestContextHandler());
55
+ const handler = ContextIdHandlerFactory.create('request');
56
+ handler.getContextIds().traceId; // 'trc-1001'
57
+ ```
@@ -14,7 +14,7 @@ Class to help with context IDs.
14
14
 
15
15
  ## Properties
16
16
 
17
- ### CLASS\_NAME
17
+ ### CLASS\_NAME {#class_name}
18
18
 
19
19
  > `readonly` `static` **CLASS\_NAME**: `string`
20
20
 
@@ -22,7 +22,7 @@ Runtime name for the class.
22
22
 
23
23
  ## Methods
24
24
 
25
- ### guard()
25
+ ### guard() {#guard}
26
26
 
27
27
  > `static` **guard**\<`T`, `K`\>(`contextIds`, `key`): `asserts contextIds is T & { [P in string]: string }`
28
28
 
@@ -42,9 +42,9 @@ Perform a runtime guard on the provided context ID value.
42
42
 
43
43
  ##### contextIds
44
44
 
45
- The context IDs to guard.
45
+ `T` \| `undefined`
46
46
 
47
- `T` | `undefined`
47
+ The context IDs to guard.
48
48
 
49
49
  ##### key
50
50
 
@@ -62,7 +62,7 @@ Guard error if the value is invalid.
62
62
 
63
63
  ***
64
64
 
65
- ### short()
65
+ ### short() {#short}
66
66
 
67
67
  > `static` **short**(`contextIds`, `key`): `string`
68
68
 
@@ -72,9 +72,9 @@ Gets the short version of a context ID.
72
72
 
73
73
  ##### contextIds
74
74
 
75
- The context IDs to get the short version from.
75
+ [`IContextIds`](../interfaces/IContextIds.md) \| `undefined`
76
76
 
77
- [`IContextIds`](../interfaces/IContextIds.md) | `undefined`
77
+ The context IDs to get the short version from.
78
78
 
79
79
  ##### key
80
80
 
@@ -94,7 +94,7 @@ Guard error if the value is invalid.
94
94
 
95
95
  ***
96
96
 
97
- ### guardAll()
97
+ ### guardAll() {#guardall}
98
98
 
99
99
  > `static` **guardAll**\<`T`, `K`\>(`contextIds`, `keys`): `asserts contextIds is T & { [P in string]: string }`
100
100
 
@@ -114,15 +114,15 @@ Perform a runtime guard on the provided context ID values.
114
114
 
115
115
  ##### contextIds
116
116
 
117
- The context IDs to guard.
117
+ `T` \| `undefined`
118
118
 
119
- `T` | `undefined`
119
+ The context IDs to guard.
120
120
 
121
121
  ##### keys
122
122
 
123
- The context ID keys to guard.
123
+ readonly `K`[] \| `undefined`
124
124
 
125
- readonly `K`[] | `undefined`
125
+ The context ID keys to guard.
126
126
 
127
127
  #### Returns
128
128
 
@@ -134,7 +134,7 @@ Guard error if the value is invalid.
134
134
 
135
135
  ***
136
136
 
137
- ### shortAll()
137
+ ### shortAll() {#shortall}
138
138
 
139
139
  > `static` **shortAll**(`contextIds`, `keys`): [`IContextIds`](../interfaces/IContextIds.md)
140
140
 
@@ -144,15 +144,15 @@ Gets the short versions of multiple context IDs.
144
144
 
145
145
  ##### contextIds
146
146
 
147
- The context IDs to get the short versions from.
147
+ [`IContextIds`](../interfaces/IContextIds.md) \| `undefined`
148
148
 
149
- [`IContextIds`](../interfaces/IContextIds.md) | `undefined`
149
+ The context IDs to get the short versions from.
150
150
 
151
151
  ##### keys
152
152
 
153
- The context ID keys to get the short versions for.
153
+ `string`[] \| `undefined`
154
154
 
155
- `string`[] | `undefined`
155
+ The context ID keys to get the short versions for.
156
156
 
157
157
  #### Returns
158
158
 
@@ -162,9 +162,9 @@ The short versions of the context IDs.
162
162
 
163
163
  ***
164
164
 
165
- ### shortCombined()
165
+ ### shortCombined() {#shortcombined}
166
166
 
167
- > `static` **shortCombined**(`contextIds`, `keys`, `separator`): `string` \| `undefined`
167
+ > `static` **shortCombined**(`contextIds`, `keys`, `separator?`): `string` \| `undefined`
168
168
 
169
169
  Gets the combined short version.
170
170
 
@@ -172,17 +172,17 @@ Gets the combined short version.
172
172
 
173
173
  ##### contextIds
174
174
 
175
- The context IDs to get the short versions from.
175
+ [`IContextIds`](../interfaces/IContextIds.md) \| `undefined`
176
176
 
177
- [`IContextIds`](../interfaces/IContextIds.md) | `undefined`
177
+ The context IDs to get the short versions from.
178
178
 
179
179
  ##### keys
180
180
 
181
- The context ID keys to get the short versions for.
181
+ `string`[] \| `undefined`
182
182
 
183
- `string`[] | `undefined`
183
+ The context ID keys to get the short versions for.
184
184
 
185
- ##### separator
185
+ ##### separator?
186
186
 
187
187
  `string` = `"/"`
188
188
 
@@ -196,9 +196,9 @@ The short version combined.
196
196
 
197
197
  ***
198
198
 
199
- ### shortSplit()
199
+ ### shortSplit() {#shortsplit}
200
200
 
201
- > `static` **shortSplit**(`keys`, `combined`, `separator`): [`IContextIds`](../interfaces/IContextIds.md)
201
+ > `static` **shortSplit**(`keys`, `combined`, `separator?`): [`IContextIds`](../interfaces/IContextIds.md)
202
202
 
203
203
  Split a combined short version in to the separate context IDs.
204
204
 
@@ -216,7 +216,7 @@ The context ID keys to get the short versions for.
216
216
 
217
217
  The combined short version to separate.
218
218
 
219
- ##### separator
219
+ ##### separator?
220
220
 
221
221
  `string` = `"/"`
222
222
 
@@ -234,9 +234,9 @@ GeneralError if the number of parts does not match the number of keys.
234
234
 
235
235
  ***
236
236
 
237
- ### combinedContextKey()
237
+ ### combinedContextKey() {#combinedcontextkey}
238
238
 
239
- > `static` **combinedContextKey**(`contextIds`, `keys`, `separator`): `string` \| `undefined`
239
+ > `static` **combinedContextKey**(`contextIds`, `keys`, `separator?`): `string` \| `undefined`
240
240
 
241
241
  Create a combined key.
242
242
 
@@ -244,17 +244,17 @@ Create a combined key.
244
244
 
245
245
  ##### contextIds
246
246
 
247
- The context IDs to create the combined key for.
247
+ [`IContextIds`](../interfaces/IContextIds.md) \| `undefined`
248
248
 
249
- [`IContextIds`](../interfaces/IContextIds.md) | `undefined`
249
+ The context IDs to create the combined key for.
250
250
 
251
251
  ##### keys
252
252
 
253
- The context ID keys to get the short versions for.
253
+ `string`[] \| `undefined`
254
254
 
255
- `string`[] | `undefined`
255
+ The context ID keys to get the short versions for.
256
256
 
257
- ##### separator
257
+ ##### separator?
258
258
 
259
259
  `string` = `"/"`
260
260
 
@@ -268,7 +268,7 @@ The short version combined.
268
268
 
269
269
  ***
270
270
 
271
- ### pickKeysFromAvailable()
271
+ ### pickKeysFromAvailable() {#pickkeysfromavailable}
272
272
 
273
273
  > `static` **pickKeysFromAvailable**(`availableKeys?`, `desiredKeys?`): `string`[]
274
274
 
@@ -14,7 +14,7 @@ Class to maintain context ids and execute an async method.
14
14
 
15
15
  ## Properties
16
16
 
17
- ### CLASS\_NAME
17
+ ### CLASS\_NAME {#class_name}
18
18
 
19
19
  > `readonly` `static` **CLASS\_NAME**: `string`
20
20
 
@@ -22,7 +22,7 @@ Runtime name for the class.
22
22
 
23
23
  ## Methods
24
24
 
25
- ### run()
25
+ ### run() {#run}
26
26
 
27
27
  > `static` **run**\<`T`\>(`contextIds`, `asyncMethod`): `Promise`\<`T`\>
28
28
 
@@ -56,7 +56,7 @@ Nothing.
56
56
 
57
57
  ***
58
58
 
59
- ### getContextIds()
59
+ ### getContextIds() {#getcontextids}
60
60
 
61
61
  > `static` **getContextIds**(): `Promise`\<[`IContextIds`](../interfaces/IContextIds.md) \| `undefined`\>
62
62
 
@@ -67,3 +67,17 @@ Get the context IDs.
67
67
  `Promise`\<[`IContextIds`](../interfaces/IContextIds.md) \| `undefined`\>
68
68
 
69
69
  The context IDs.
70
+
71
+ ***
72
+
73
+ ### getStorage() {#getstorage}
74
+
75
+ > `static` **getStorage**(): `Promise`\<`AsyncLocalStorage`\<[`IContextIds`](../interfaces/IContextIds.md)\>\>
76
+
77
+ Get the storage and create it if it doesn't exist.
78
+
79
+ #### Returns
80
+
81
+ `Promise`\<`AsyncLocalStorage`\<[`IContextIds`](../interfaces/IContextIds.md)\>\>
82
+
83
+ The storage.
@@ -2,9 +2,13 @@
2
2
 
3
3
  Interface describing a context ID handler.
4
4
 
5
+ ## Extends
6
+
7
+ - `IComponent`
8
+
5
9
  ## Methods
6
10
 
7
- ### short()?
11
+ ### short()? {#short}
8
12
 
9
13
  > `optional` **short**(`value`): `string`
10
14
 
@@ -26,7 +30,7 @@ The short form version of the context ID.
26
30
 
27
31
  ***
28
32
 
29
- ### guard()?
33
+ ### guard()? {#guard}
30
34
 
31
35
  > `optional` **guard**(`value`): `void`
32
36
 
@@ -47,3 +51,99 @@ The context ID value to guard.
47
51
  #### Throws
48
52
 
49
53
  Guard error if the value is invalid.
54
+
55
+ ***
56
+
57
+ ### className() {#classname}
58
+
59
+ > **className**(): `string`
60
+
61
+ Returns the class name of the component.
62
+
63
+ #### Returns
64
+
65
+ `string`
66
+
67
+ The class name of the component.
68
+
69
+ #### Inherited from
70
+
71
+ `IComponent.className`
72
+
73
+ ***
74
+
75
+ ### bootstrap()? {#bootstrap}
76
+
77
+ > `optional` **bootstrap**(`nodeLoggingComponentType?`): `Promise`\<`boolean`\>
78
+
79
+ Bootstrap the component by creating and initializing any resources it needs.
80
+
81
+ #### Parameters
82
+
83
+ ##### nodeLoggingComponentType?
84
+
85
+ `string`
86
+
87
+ The node logging component type.
88
+
89
+ #### Returns
90
+
91
+ `Promise`\<`boolean`\>
92
+
93
+ True if the bootstrapping process was successful.
94
+
95
+ #### Inherited from
96
+
97
+ `IComponent.bootstrap`
98
+
99
+ ***
100
+
101
+ ### start()? {#start}
102
+
103
+ > `optional` **start**(`nodeLoggingComponentType?`): `Promise`\<`void`\>
104
+
105
+ The component needs to be started when the node is initialized.
106
+
107
+ #### Parameters
108
+
109
+ ##### nodeLoggingComponentType?
110
+
111
+ `string`
112
+
113
+ The node logging component type.
114
+
115
+ #### Returns
116
+
117
+ `Promise`\<`void`\>
118
+
119
+ Nothing.
120
+
121
+ #### Inherited from
122
+
123
+ `IComponent.start`
124
+
125
+ ***
126
+
127
+ ### stop()? {#stop}
128
+
129
+ > `optional` **stop**(`nodeLoggingComponentType?`): `Promise`\<`void`\>
130
+
131
+ The component needs to be stopped when the node is closed.
132
+
133
+ #### Parameters
134
+
135
+ ##### nodeLoggingComponentType?
136
+
137
+ `string`
138
+
139
+ The node logging component type.
140
+
141
+ #### Returns
142
+
143
+ `Promise`\<`void`\>
144
+
145
+ Nothing.
146
+
147
+ #### Inherited from
148
+
149
+ `IComponent.stop`
@@ -4,6 +4,6 @@ Interface describing context ids which can be accessed async from a request.
4
4
 
5
5
  ## Indexable
6
6
 
7
- \[`id`: `string`\]: `string` \| `undefined`
7
+ > \[`id`: `string`\]: `string` \| `undefined`
8
8
 
9
9
  The context id keys and values.
@@ -6,25 +6,25 @@ Default definition of some context keys.
6
6
 
7
7
  ## Type Declaration
8
8
 
9
- ### Node
9
+ ### Node {#node}
10
10
 
11
11
  > `readonly` **Node**: `"node"` = `"node"`
12
12
 
13
13
  Standard property type definition for node.
14
14
 
15
- ### Tenant
15
+ ### Tenant {#tenant}
16
16
 
17
17
  > `readonly` **Tenant**: `"tenant"` = `"tenant"`
18
18
 
19
19
  Standard property type definition for tenant.
20
20
 
21
- ### Organization
21
+ ### Organization {#organization}
22
22
 
23
23
  > `readonly` **Organization**: `"organization"` = `"organization"`
24
24
 
25
25
  Standard property type definition for organization.
26
26
 
27
- ### User
27
+ ### User {#user}
28
28
 
29
29
  > `readonly` **User**: `"user"` = `"user"`
30
30
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/context",
3
- "version": "0.0.3-next.3",
3
+ "version": "0.0.3-next.31",
4
4
  "description": "Helper methods/classes for context handling",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,8 +14,8 @@
14
14
  "node": ">=20.0.0"
15
15
  },
16
16
  "dependencies": {
17
- "@twin.org/core": "0.0.3-next.3",
18
- "@twin.org/nameof": "0.0.3-next.3"
17
+ "@twin.org/core": "0.0.3-next.31",
18
+ "@twin.org/nameof": "0.0.3-next.31"
19
19
  },
20
20
  "main": "./dist/es/index.js",
21
21
  "types": "./dist/types/index.d.ts",