hierarchical-approval 0.3.1 → 0.4.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 (43) hide show
  1. package/CHANGELOG.md +66 -0
  2. package/README.md +217 -140
  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/plugins/resilience.d.cts +2 -1
  30. package/dist/plugins/resilience.d.ts +2 -1
  31. package/dist/plugins/tracing.cjs +117 -0
  32. package/dist/plugins/tracing.cjs.map +1 -0
  33. package/dist/plugins/tracing.d.cts +134 -0
  34. package/dist/plugins/tracing.d.ts +134 -0
  35. package/dist/plugins/tracing.js +112 -0
  36. package/dist/plugins/tracing.js.map +1 -0
  37. package/dist/testing.cjs +25 -1
  38. package/dist/testing.cjs.map +1 -1
  39. package/dist/testing.d.cts +4 -3
  40. package/dist/testing.d.ts +4 -3
  41. package/dist/testing.js +25 -1
  42. package/dist/testing.js.map +1 -1
  43. package/package.json +10 -2
package/CHANGELOG.md CHANGED
@@ -3,6 +3,72 @@
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.4.0] - 2026-07-23
7
+
8
+ ### Added — per-template analytics
9
+
10
+ - **Per-template breakdown in `getStatistics()`** — the returned
11
+ `ApprovalStatistics` now includes a `byTemplate` map keyed by template name,
12
+ each entry carrying `{ total, approved, rejected, pending }`. This lets
13
+ dashboards break down approval volume and approval rate per workflow template
14
+ without callers hand-rolling per-template queries.
15
+ - To support this, `InstanceFilter` gained an optional `templateName` field,
16
+ now honoured by `MemoryAdapter` (`getInstancesByFilter`,
17
+ `getInstancesByCursor`) and `PostgresAdapter` (`getInstancesByFilter`,
18
+ `getInstancesByCursor`). Both adapters remain backward-compatible — existing
19
+ callers that omit the field are unaffected.
20
+ - `byTemplate` is adapter-agnostic: built only from existing
21
+ `getInstancesByFilter` counts plus `TemplateRegistry.list()`, so it works
22
+ with any storage adapter with no new adapter methods. It respects the other
23
+ filters (`documentType`, `submittedBy`, date range) and is empty when no
24
+ templates are defined.
25
+
26
+ ### Added — OpenTelemetry tracing plug-in
27
+
28
+ - **`hierarchical-approval/plugins/tracing`** — distributed tracing as an
29
+ `IOperationMiddleware`, published on its own tree-shakeable subpath with
30
+ **zero runtime dependencies**.
31
+ - `TracingMiddleware` wraps every engine operation in a span named
32
+ `approval.<operation>` carrying `approval.tenant_id`, `approval.actor_id`,
33
+ and `approval.instance_id` attributes. On success it records
34
+ `approval.result_status`/`approval.result_level` and status `OK`; on failure
35
+ it calls `recordException`, tags `approval.error_code`, sets status `ERROR`,
36
+ and re-throws (tracing never swallows an error). Overlapping same-key
37
+ operations are paired LIFO via a per-correlation-key span stack.
38
+ - `Tracer`/`TraceSpan`/`SpanStatus` ports model the `@opentelemetry/api`
39
+ surface, so a real OpenTelemetry `Tracer` (`trace.getTracer(...)`) is
40
+ structurally assignable and can be passed directly — the library never
41
+ imports `@opentelemetry/api`. `SpanStatusCode` mirrors OTel's numeric codes.
42
+ - `noopTracer` is the default, so adding the middleware without wiring a
43
+ backend is a no-op.
44
+
45
+ ### Added — repository governance & supply chain
46
+
47
+ - `SECURITY.md` (private vulnerability disclosure policy, supported versions),
48
+ `CONTRIBUTING.md`, and a Contributor Covenant `CODE_OF_CONDUCT.md`.
49
+ - GitHub issue forms (bug report, feature request) + `config.yml`, a pull-request
50
+ template, and `CODEOWNERS`.
51
+ - Dependabot configuration for weekly npm and GitHub Actions updates.
52
+
53
+ ### Added — API documentation
54
+
55
+ - TypeDoc API reference generation via `npm run docs` (and `docs:watch`),
56
+ covering the main entry point and every published subpath.
57
+ - CI validates that the API reference generates; a `docs.yml` workflow deploys it
58
+ to GitHub Pages on release tags and manual dispatch.
59
+
60
+ ### Changed
61
+
62
+ - `package.json` `exports` and the build now also expose the `plugins/tracing`
63
+ subpath in ESM, CJS, and `.d.ts`.
64
+
65
+ ### Tests
66
+
67
+ - Test suite grew from 380 to 397 passing tests covering the tracing span
68
+ lifecycle, creation attributes, LIFO concurrency pairing, configuration, the
69
+ no-op default, the public-export surface, and the per-template statistics
70
+ breakdown (combined filtering and the empty-template case).
71
+
6
72
  ## [0.3.1] - 2026-06-26
7
73
 
8
74
  ### Docs