hierarchical-approval 0.4.0 → 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.
- package/CHANGELOG.md +27 -0
- package/README.md +65 -1
- package/dist/nestjs.cjs +1841 -0
- package/dist/nestjs.cjs.map +1 -0
- package/dist/nestjs.d.cts +79 -0
- package/dist/nestjs.d.ts +79 -0
- package/dist/nestjs.js +1833 -0
- package/dist/nestjs.js.map +1 -0
- package/package.json +34 -4
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,33 @@
|
|
|
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
|
+
|
|
6
33
|
## [0.4.0] - 2026-07-23
|
|
7
34
|
|
|
8
35
|
### Added — per-template analytics
|
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ Multi-tenant · audit-ready · fully pluggable · zero runtime dependencies you
|
|
|
11
11
|
[](https://www.typescriptlang.org/)
|
|
12
12
|
[](https://bundlephobia.com/package/hierarchical-approval)
|
|
13
13
|
[](./LICENSE)
|
|
14
|
-
[](./tests)
|
|
15
15
|
|
|
16
16
|
[**Documentation**](https://hierarchical-approval.matthewswong.com) ·
|
|
17
17
|
[**npm**](https://www.npmjs.com/package/hierarchical-approval) ·
|
|
@@ -28,6 +28,11 @@ npm install pg @types/pg
|
|
|
28
28
|
|
|
29
29
|
> 📖 Full docs & live guides: **[hierarchical-approval.matthewswong.com](https://hierarchical-approval.matthewswong.com)**
|
|
30
30
|
|
|
31
|
+
### ▶️ Try it live (no install)
|
|
32
|
+
|
|
33
|
+
- **[Run in your browser on RunKit →](https://npm.runkit.com/hierarchical-approval)** — `require('hierarchical-approval')` in an instant notebook.
|
|
34
|
+
- **[Open the interactive playground on StackBlitz →](https://stackblitz.com/github/matthews-wong/hierarchical-approval/tree/main/examples/playground)** — a full purchase-order approval chain running in-browser.
|
|
35
|
+
|
|
31
36
|
<details>
|
|
32
37
|
<summary><strong>Table of contents</strong></summary>
|
|
33
38
|
|
|
@@ -1069,6 +1074,65 @@ Every operation is wrapped in a span named `approval.<operation>` (e.g. `approva
|
|
|
1069
1074
|
|
|
1070
1075
|
---
|
|
1071
1076
|
|
|
1077
|
+
## NestJS integration
|
|
1078
|
+
|
|
1079
|
+
First-class NestJS support ships as the `hierarchical-approval/nestjs` subpath. `@nestjs/common` is an **optional peer dependency** — you only pull it in if you use this module.
|
|
1080
|
+
|
|
1081
|
+
```ts
|
|
1082
|
+
import { Module } from '@nestjs/common';
|
|
1083
|
+
import { HierarchicalApprovalModule } from 'hierarchical-approval/nestjs';
|
|
1084
|
+
import { MemoryAdapter } from 'hierarchical-approval/adapters/memory';
|
|
1085
|
+
|
|
1086
|
+
@Module({
|
|
1087
|
+
imports: [
|
|
1088
|
+
HierarchicalApprovalModule.forRoot({
|
|
1089
|
+
adapter: new MemoryAdapter(),
|
|
1090
|
+
isGlobal: true, // inject ApprovalEngine anywhere without re-importing
|
|
1091
|
+
}),
|
|
1092
|
+
],
|
|
1093
|
+
})
|
|
1094
|
+
export class AppModule {}
|
|
1095
|
+
```
|
|
1096
|
+
|
|
1097
|
+
Inject the configured engine with the `@InjectApprovalEngine()` decorator:
|
|
1098
|
+
|
|
1099
|
+
```ts
|
|
1100
|
+
import { Injectable } from '@nestjs/common';
|
|
1101
|
+
import { ApprovalEngine } from 'hierarchical-approval';
|
|
1102
|
+
import { InjectApprovalEngine } from 'hierarchical-approval/nestjs';
|
|
1103
|
+
|
|
1104
|
+
@Injectable()
|
|
1105
|
+
export class InvoiceService {
|
|
1106
|
+
constructor(@InjectApprovalEngine() private readonly approvals: ApprovalEngine) {}
|
|
1107
|
+
|
|
1108
|
+
submit(invoiceId: string, amount: number) {
|
|
1109
|
+
return this.approvals.submit({
|
|
1110
|
+
templateName: 'Invoice',
|
|
1111
|
+
documentId: invoiceId,
|
|
1112
|
+
documentType: 'invoice',
|
|
1113
|
+
submittedBy: 'system',
|
|
1114
|
+
data: { amount },
|
|
1115
|
+
});
|
|
1116
|
+
}
|
|
1117
|
+
}
|
|
1118
|
+
```
|
|
1119
|
+
|
|
1120
|
+
Configure asynchronously from your `ConfigService` (or any provider) with `forRootAsync`:
|
|
1121
|
+
|
|
1122
|
+
```ts
|
|
1123
|
+
HierarchicalApprovalModule.forRootAsync({
|
|
1124
|
+
imports: [ConfigModule],
|
|
1125
|
+
inject: [ConfigService],
|
|
1126
|
+
useFactory: (config: ConfigService) => ({
|
|
1127
|
+
adapter: new PostgresAdapter({ connectionString: config.get('DATABASE_URL') }),
|
|
1128
|
+
}),
|
|
1129
|
+
});
|
|
1130
|
+
```
|
|
1131
|
+
|
|
1132
|
+
The module registers the engine under the `APPROVAL_ENGINE` token and stops its escalation scheduler on application shutdown via `onModuleDestroy` (call `app.enableShutdownHooks()` to activate Nest's shutdown lifecycle).
|
|
1133
|
+
|
|
1134
|
+
---
|
|
1135
|
+
|
|
1072
1136
|
## Custom storage adapter
|
|
1073
1137
|
|
|
1074
1138
|
Implement `IStorageAdapter` to use any database:
|