hierarchical-approval 0.3.1 → 0.5.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.
Files changed (49) hide show
  1. package/CHANGELOG.md +93 -0
  2. package/README.md +282 -141
  3. package/dist/{ApprovalEngine-DLyhejR-.d.ts → ApprovalEngine-jy4cYeES.d.ts} +15 -2
  4. package/dist/{ApprovalEngine-Bmg1bbrd.d.cts → ApprovalEngine-mkh6D9n9.d.cts} +15 -2
  5. package/dist/IAuthorizationPolicy-B6JzRNUk.d.cts +19 -0
  6. package/dist/IAuthorizationPolicy-CZESF3CJ.d.ts +19 -0
  7. package/dist/{IOperationMiddleware-Dk_xOKxR.d.ts → IOperationMiddleware-CXgXmGUF.d.cts} +2 -18
  8. package/dist/{IOperationMiddleware-CkRh93Wf.d.cts → IOperationMiddleware-KGAwT9f-.d.ts} +2 -18
  9. package/dist/{IStorageAdapter-EdwtErKD.d.ts → IStorageAdapter-8ajiGUeu.d.ts} +1 -0
  10. package/dist/{IStorageAdapter-DbeWhtCG.d.cts → IStorageAdapter-ClBdEeTj.d.cts} +1 -0
  11. package/dist/adapters/MemoryAdapter.cjs +1 -0
  12. package/dist/adapters/MemoryAdapter.cjs.map +1 -1
  13. package/dist/adapters/MemoryAdapter.d.cts +1 -1
  14. package/dist/adapters/MemoryAdapter.d.ts +1 -1
  15. package/dist/adapters/MemoryAdapter.js +1 -0
  16. package/dist/adapters/MemoryAdapter.js.map +1 -1
  17. package/dist/adapters/PostgresAdapter.cjs +8 -0
  18. package/dist/adapters/PostgresAdapter.cjs.map +1 -1
  19. package/dist/adapters/PostgresAdapter.d.cts +1 -1
  20. package/dist/adapters/PostgresAdapter.d.ts +1 -1
  21. package/dist/adapters/PostgresAdapter.js +8 -0
  22. package/dist/adapters/PostgresAdapter.js.map +1 -1
  23. package/dist/index.cjs +25 -1
  24. package/dist/index.cjs.map +1 -1
  25. package/dist/index.d.cts +5 -4
  26. package/dist/index.d.ts +5 -4
  27. package/dist/index.js +25 -1
  28. package/dist/index.js.map +1 -1
  29. package/dist/nestjs.cjs +1841 -0
  30. package/dist/nestjs.cjs.map +1 -0
  31. package/dist/nestjs.d.cts +79 -0
  32. package/dist/nestjs.d.ts +79 -0
  33. package/dist/nestjs.js +1833 -0
  34. package/dist/nestjs.js.map +1 -0
  35. package/dist/plugins/resilience.d.cts +2 -1
  36. package/dist/plugins/resilience.d.ts +2 -1
  37. package/dist/plugins/tracing.cjs +117 -0
  38. package/dist/plugins/tracing.cjs.map +1 -0
  39. package/dist/plugins/tracing.d.cts +134 -0
  40. package/dist/plugins/tracing.d.ts +134 -0
  41. package/dist/plugins/tracing.js +112 -0
  42. package/dist/plugins/tracing.js.map +1 -0
  43. package/dist/testing.cjs +25 -1
  44. package/dist/testing.cjs.map +1 -1
  45. package/dist/testing.d.cts +4 -3
  46. package/dist/testing.d.ts +4 -3
  47. package/dist/testing.js +25 -1
  48. package/dist/testing.js.map +1 -1
  49. package/package.json +43 -5
package/CHANGELOG.md CHANGED
@@ -3,6 +3,99 @@
3
3
  All notable changes to `hierarchical-approval` are documented here. This project
4
4
  adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
5
5
 
6
+ ## [0.5.0] - 2026-07-23
7
+
8
+ ### Added — NestJS integration
9
+
10
+ - **`hierarchical-approval/nestjs`** — first-class NestJS support on its own
11
+ tree-shakeable subpath. `@nestjs/common` is an **optional peer dependency**.
12
+ - `HierarchicalApprovalModule.forRoot(options)` and `.forRootAsync(asyncOptions)`
13
+ provide a configured `ApprovalEngine` under the `APPROVAL_ENGINE` token, with
14
+ an `isGlobal` flag and `imports`/`inject`/`useFactory` async wiring.
15
+ - `@InjectApprovalEngine()` decorator for injecting the engine into services.
16
+ - The module stops the engine's escalation scheduler on application shutdown
17
+ via `onModuleDestroy`.
18
+
19
+ ### Added — adoption & discoverability
20
+
21
+ - `examples/playground/` — a StackBlitz-ready, in-browser runnable demo of a
22
+ purchase-order approval chain, plus "Try it live" (RunKit + StackBlitz) links
23
+ in the README.
24
+ - Expanded npm `keywords` for problem-based search (approval-workflow,
25
+ maker-checker, four-eyes, delegation, escalation, …).
26
+
27
+ ### Fixed
28
+
29
+ - Replaced the non-standard `peerDependenciesOptional` field with the correct
30
+ `peerDependenciesMeta`, so `pg` (and now `@nestjs/common`) are properly marked
31
+ optional and no longer emit install-time peer warnings.
32
+
33
+ ## [0.4.0] - 2026-07-23
34
+
35
+ ### Added — per-template analytics
36
+
37
+ - **Per-template breakdown in `getStatistics()`** — the returned
38
+ `ApprovalStatistics` now includes a `byTemplate` map keyed by template name,
39
+ each entry carrying `{ total, approved, rejected, pending }`. This lets
40
+ dashboards break down approval volume and approval rate per workflow template
41
+ without callers hand-rolling per-template queries.
42
+ - To support this, `InstanceFilter` gained an optional `templateName` field,
43
+ now honoured by `MemoryAdapter` (`getInstancesByFilter`,
44
+ `getInstancesByCursor`) and `PostgresAdapter` (`getInstancesByFilter`,
45
+ `getInstancesByCursor`). Both adapters remain backward-compatible — existing
46
+ callers that omit the field are unaffected.
47
+ - `byTemplate` is adapter-agnostic: built only from existing
48
+ `getInstancesByFilter` counts plus `TemplateRegistry.list()`, so it works
49
+ with any storage adapter with no new adapter methods. It respects the other
50
+ filters (`documentType`, `submittedBy`, date range) and is empty when no
51
+ templates are defined.
52
+
53
+ ### Added — OpenTelemetry tracing plug-in
54
+
55
+ - **`hierarchical-approval/plugins/tracing`** — distributed tracing as an
56
+ `IOperationMiddleware`, published on its own tree-shakeable subpath with
57
+ **zero runtime dependencies**.
58
+ - `TracingMiddleware` wraps every engine operation in a span named
59
+ `approval.<operation>` carrying `approval.tenant_id`, `approval.actor_id`,
60
+ and `approval.instance_id` attributes. On success it records
61
+ `approval.result_status`/`approval.result_level` and status `OK`; on failure
62
+ it calls `recordException`, tags `approval.error_code`, sets status `ERROR`,
63
+ and re-throws (tracing never swallows an error). Overlapping same-key
64
+ operations are paired LIFO via a per-correlation-key span stack.
65
+ - `Tracer`/`TraceSpan`/`SpanStatus` ports model the `@opentelemetry/api`
66
+ surface, so a real OpenTelemetry `Tracer` (`trace.getTracer(...)`) is
67
+ structurally assignable and can be passed directly — the library never
68
+ imports `@opentelemetry/api`. `SpanStatusCode` mirrors OTel's numeric codes.
69
+ - `noopTracer` is the default, so adding the middleware without wiring a
70
+ backend is a no-op.
71
+
72
+ ### Added — repository governance & supply chain
73
+
74
+ - `SECURITY.md` (private vulnerability disclosure policy, supported versions),
75
+ `CONTRIBUTING.md`, and a Contributor Covenant `CODE_OF_CONDUCT.md`.
76
+ - GitHub issue forms (bug report, feature request) + `config.yml`, a pull-request
77
+ template, and `CODEOWNERS`.
78
+ - Dependabot configuration for weekly npm and GitHub Actions updates.
79
+
80
+ ### Added — API documentation
81
+
82
+ - TypeDoc API reference generation via `npm run docs` (and `docs:watch`),
83
+ covering the main entry point and every published subpath.
84
+ - CI validates that the API reference generates; a `docs.yml` workflow deploys it
85
+ to GitHub Pages on release tags and manual dispatch.
86
+
87
+ ### Changed
88
+
89
+ - `package.json` `exports` and the build now also expose the `plugins/tracing`
90
+ subpath in ESM, CJS, and `.d.ts`.
91
+
92
+ ### Tests
93
+
94
+ - Test suite grew from 380 to 397 passing tests covering the tracing span
95
+ lifecycle, creation attributes, LIFO concurrency pairing, configuration, the
96
+ no-op default, the public-export surface, and the per-template statistics
97
+ breakdown (combined filtering and the empty-template case).
98
+
6
99
  ## [0.3.1] - 2026-06-26
7
100
 
8
101
  ### Docs