@birtalanrobert/context 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,53 @@
1
+ # Changelog
2
+
3
+ All packages share a version and are released together.
4
+
5
+ ## 0.2.0
6
+
7
+ Composing the packages into a real application surfaced three problems that
8
+ package-level tests could not.
9
+
10
+ ### Added
11
+
12
+ - **`forRootAsync` on every configurable module** — `LoggerModule`,
13
+ `DatabaseModule`, `RedisModule`, `HttpModule`, `TenancyModule`, `AuthModule`,
14
+ `IdempotencyModule` and `JobsModule`.
15
+
16
+ Previously each module took its options synchronously, which meant a consumer
17
+ had to read `process.env` at import time — before anything had validated it —
18
+ to configure a database URL or a Redis connection. That defeats having a
19
+ configuration layer at all. Options can now come from any provider, including
20
+ the validated config.
21
+
22
+ - **`ConfigModule.token()`**, so a wiring site can write
23
+ `inject: [ConfigModule.token()]` rather than importing the raw symbol.
24
+
25
+ - **`AsyncModuleOptions<T>`** in `@birtalanrobert/context`: the shared shape for
26
+ the above.
27
+
28
+ ### Fixed
29
+
30
+ - **`HttpModule` and `TenancyModule` no longer hold module options in static
31
+ fields.** Both middlewares now receive their options through dependency
32
+ injection. The previous arrangement meant a second `forRoot()` call silently
33
+ overwrote the first — which is exactly what happens when a test suite builds
34
+ more than one application in a process.
35
+
36
+ - **`@birtalanrobert/http` accepts `class-validator` 0.15**, which is current.
37
+ The peer range previously stopped at 0.14 and produced an unmet-peer warning
38
+ on every install.
39
+
40
+ - **Internal dependencies publish as `^x.y.z` rather than an exact pin.** Exact
41
+ pins across a family released together make npm install several copies of the
42
+ same package as soon as two versions coexist in one tree.
43
+
44
+ ### Note on compatibility
45
+
46
+ `HttpModule.contextOptions` and `TenancyModule.resolvers` are no longer present
47
+ as static properties. They were declared `private` and were never part of the
48
+ documented surface — TypeScript consumers could not reach them — but a
49
+ JavaScript consumer reading them would break. Nothing else changed shape.
50
+
51
+ ## 0.1.0
52
+
53
+ First release.
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export type { AsyncModuleOptions } from './module-options';
1
2
  export type { Actor, ContextSource, RequestContext } from './types';
2
3
  export { contextSnapshot, createContext, elapsedMs, getActor, getAttribute, getContext, getCorrelationId, getLocale, getRequestId, getTenantId, requireActor, requireContext, requireTenantId, runInChildContext, runInContext, runWithContext, setAttribute, setContextValues, type CreateContextOptions, } from './context';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACpE,OAAO,EACL,eAAe,EACf,aAAa,EACb,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,UAAU,EACV,gBAAgB,EAChB,SAAS,EACT,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,KAAK,oBAAoB,GAC1B,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,YAAY,EAAE,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACpE,OAAO,EACL,eAAe,EACf,aAAa,EACb,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,UAAU,EACV,gBAAgB,EAChB,SAAS,EACT,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,KAAK,oBAAoB,GAC1B,MAAM,WAAW,CAAC"}
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AACA,qCAoBmB;AAnBjB,0GAAA,eAAe,OAAA;AACf,wGAAA,aAAa,OAAA;AACb,oGAAA,SAAS,OAAA;AACT,mGAAA,QAAQ,OAAA;AACR,uGAAA,YAAY,OAAA;AACZ,qGAAA,UAAU,OAAA;AACV,2GAAA,gBAAgB,OAAA;AAChB,oGAAA,SAAS,OAAA;AACT,uGAAA,YAAY,OAAA;AACZ,sGAAA,WAAW,OAAA;AACX,uGAAA,YAAY,OAAA;AACZ,yGAAA,cAAc,OAAA;AACd,0GAAA,eAAe,OAAA;AACf,4GAAA,iBAAiB,OAAA;AACjB,uGAAA,YAAY,OAAA;AACZ,yGAAA,cAAc,OAAA;AACd,uGAAA,YAAY,OAAA;AACZ,2GAAA,gBAAgB,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAEA,qCAoBmB;AAnBjB,0GAAA,eAAe,OAAA;AACf,wGAAA,aAAa,OAAA;AACb,oGAAA,SAAS,OAAA;AACT,mGAAA,QAAQ,OAAA;AACR,uGAAA,YAAY,OAAA;AACZ,qGAAA,UAAU,OAAA;AACV,2GAAA,gBAAgB,OAAA;AAChB,oGAAA,SAAS,OAAA;AACT,uGAAA,YAAY,OAAA;AACZ,sGAAA,WAAW,OAAA;AACX,uGAAA,YAAY,OAAA;AACZ,yGAAA,cAAc,OAAA;AACd,0GAAA,eAAe,OAAA;AACf,4GAAA,iBAAiB,OAAA;AACjB,uGAAA,YAAY,OAAA;AACZ,yGAAA,cAAc,OAAA;AACd,uGAAA,YAAY,OAAA;AACZ,2GAAA,gBAAgB,OAAA"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * The standard shape for configuring a module from other providers.
3
+ *
4
+ * Every mortar module that takes options offers `forRootAsync`, because the
5
+ * options almost always come from validated configuration — and a module that
6
+ * can only be configured synchronously forces its consumer to read
7
+ * `process.env` directly at import time, which defeats having a config layer
8
+ * at all.
9
+ *
10
+ * Declared here rather than duplicated because it is a type, erased at
11
+ * runtime, and every mortar package already depends on this one.
12
+ */
13
+ export interface AsyncModuleOptions<TOptions> {
14
+ /** Modules whose providers the factory injects. Rarely needed for globals. */
15
+ imports?: unknown[];
16
+ /** Tokens passed to the factory, in order. */
17
+ inject?: unknown[];
18
+ useFactory: (...args: never[]) => TOptions | Promise<TOptions>;
19
+ }
20
+ //# sourceMappingURL=module-options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module-options.d.ts","sourceRoot":"","sources":["../src/module-options.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,kBAAkB,CAAC,QAAQ;IAC1C,8EAA8E;IAC9E,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC;IACpB,8CAA8C;IAC9C,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC;IACnB,UAAU,EAAE,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;CAChE"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=module-options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module-options.js","sourceRoot":"","sources":["../src/module-options.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@birtalanrobert/context",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "AsyncLocalStorage request context",
5
5
  "license": "AGPL-3.0-only",
6
6
  "type": "commonjs",
@@ -14,7 +14,8 @@
14
14
  "!src/**/__tests__",
15
15
  "README.md",
16
16
  "LICENSE",
17
- "NOTICE"
17
+ "NOTICE",
18
+ "CHANGELOG.md"
18
19
  ],
19
20
  "exports": {
20
21
  ".": {
package/src/index.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export type { AsyncModuleOptions } from './module-options';
1
2
  export type { Actor, ContextSource, RequestContext } from './types';
2
3
  export {
3
4
  contextSnapshot,
@@ -0,0 +1,19 @@
1
+ /**
2
+ * The standard shape for configuring a module from other providers.
3
+ *
4
+ * Every mortar module that takes options offers `forRootAsync`, because the
5
+ * options almost always come from validated configuration — and a module that
6
+ * can only be configured synchronously forces its consumer to read
7
+ * `process.env` directly at import time, which defeats having a config layer
8
+ * at all.
9
+ *
10
+ * Declared here rather than duplicated because it is a type, erased at
11
+ * runtime, and every mortar package already depends on this one.
12
+ */
13
+ export interface AsyncModuleOptions<TOptions> {
14
+ /** Modules whose providers the factory injects. Rarely needed for globals. */
15
+ imports?: unknown[];
16
+ /** Tokens passed to the factory, in order. */
17
+ inject?: unknown[];
18
+ useFactory: (...args: never[]) => TOptions | Promise<TOptions>;
19
+ }