@icd-iot-aicf/nestjs-logger 4.0.8 → 4.0.10
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.
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
# Log Snapshot — Pre-Upgrade Baseline Guide
|
|
2
|
+
|
|
3
|
+
> **AI Agent Instructions:** Read this file before doing anything in this worktree.
|
|
4
|
+
> Your job is to capture a snapshot of the current v3 log format so it can be compared against v4 after upgrading.
|
|
5
|
+
> Follow the steps below in order. Do not skip any step.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Context
|
|
10
|
+
|
|
11
|
+
This worktree is pinned to **v3** (`main` branch) of `@icd-iot-aicf/nestjs-logger`.
|
|
12
|
+
|
|
13
|
+
The goal is to capture a **baseline snapshot** of what the log output looks like right now — before upgrading to v4.
|
|
14
|
+
After upgrading, the same test file will be run against v4 output and Jest will diff the two, showing exactly what changed.
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Step 1 — Install dependencies
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
> If `@nestjs/testing` or `supertest` are missing, install them:
|
|
25
|
+
> ```bash
|
|
26
|
+
> npm install --save-dev @nestjs/testing supertest
|
|
27
|
+
> ```
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Step 2 — Verify the Jest E2E config supports ESM (uuid)
|
|
32
|
+
|
|
33
|
+
Open `test/jest-e2e.json` and confirm it contains `transformIgnorePatterns`:
|
|
34
|
+
|
|
35
|
+
```json
|
|
36
|
+
{
|
|
37
|
+
"transformIgnorePatterns": ["node_modules/(?!(uuid)/)"]
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
If it is missing, add it — otherwise the test will fail with a `SyntaxError: Unexpected token 'export'` from the `uuid` package.
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## Step 3 — Copy the snapshot script into the test folder
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
cp migration/log-snapshot-v3.e2e-spec.ts test/log-snapshot.e2e-spec.ts
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
> **Why rename it?** Jest keys snapshots by the test file name.
|
|
52
|
+
> Using `log-snapshot.e2e-spec.ts` in both v3 and v4 means the same `.snap` file is used for comparison after upgrading.
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## Step 4 — Capture the v3 baseline snapshot
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
npx jest --config ./test/jest-e2e.json --testPathPatterns=log-snapshot --updateSnapshot
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
This will:
|
|
63
|
+
- Spin up a minimal NestJS app using the v3 library
|
|
64
|
+
- Fire test HTTP requests
|
|
65
|
+
- Record the exact log structure and field values into `test/__snapshots__/log-snapshot.e2e-spec.ts.snap`
|
|
66
|
+
|
|
67
|
+
✅ Expected output: all tests pass, snapshot file created/updated.
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Step 5 — Commit the snapshot
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
git add test/__snapshots__/log-snapshot.e2e-spec.ts.snap
|
|
75
|
+
git commit -m "test: capture v3 log format baseline snapshot"
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
> This snapshot is the source of truth for comparison. Keep it committed.
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## Step 6 — Upgrade to v4
|
|
83
|
+
|
|
84
|
+
> ✅ Baseline captured. You are now ready to upgrade.
|
|
85
|
+
|
|
86
|
+
### 6.1 — Install v4
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
npm install @icd-iot-aicf/nestjs-logger@latest
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Or for the experimental release:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
npm install @icd-iot-aicf/nestjs-logger@experimental
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
### 6.2 — Apply breaking changes
|
|
101
|
+
|
|
102
|
+
The full breaking-changes list and rename guide is in `v3-to-v4-migration.md` (available in the v4 package repo).
|
|
103
|
+
Key things to check:
|
|
104
|
+
|
|
105
|
+
| Area | What changed |
|
|
106
|
+
|------|-------------|
|
|
107
|
+
| Middleware name | `HTTPLogsMiddleware` → `HttpLogsMiddleware` |
|
|
108
|
+
| Interceptor return types | `responseInterceptor` / `errorInterceptor` are now `void` |
|
|
109
|
+
| Error log HTTP status | `responseLogError` now handles HTTP status codes in addition to error codes |
|
|
110
|
+
| Module import | Review `AppLogConfigModule.forRoot()` options for any renamed fields |
|
|
111
|
+
|
|
112
|
+
> **Tip:** Feed `v3-to-v4-migration.md` to your AI coding assistant and ask it to apply all changes automatically.
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
### 6.3 — Compare log output against the baseline
|
|
117
|
+
|
|
118
|
+
After upgrading and fixing any TypeScript errors, run:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
npx jest --config ./test/jest-e2e.json --testPathPatterns=log-snapshot
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Jest will compare v4 output against this snapshot and report any differences.
|
|
125
|
+
|
|
126
|
+
**Reading the diff:**
|
|
127
|
+
```
|
|
128
|
+
- (minus) = what v3 produced ← the baseline
|
|
129
|
+
+ (plus) = what v4 produces ← the new output
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
### 6.4 — Accept or investigate differences
|
|
135
|
+
|
|
136
|
+
**If the diff matches expected breaking changes** (field renames from the table above) — accept and move on:
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
npx jest --config ./test/jest-e2e.json --testPathPatterns=log-snapshot --updateSnapshot
|
|
140
|
+
git add test/__snapshots__/log-snapshot.e2e-spec.ts.snap
|
|
141
|
+
git commit -m "test: update log format snapshot for v4"
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
**If the diff shows unexpected differences** — field names that should not have changed, missing fields, or wrong values — do **not** accept the snapshot. Report the diff to the library team before proceeding.
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## Files in this worktree
|
|
149
|
+
|
|
150
|
+
| File | Purpose |
|
|
151
|
+
|------|---------|
|
|
152
|
+
| `migration/log-snapshot-v3.e2e-spec.ts` | The v3 snapshot test script — copy to `test/` before running |
|
|
153
|
+
| `test/log-snapshot.e2e-spec.ts` | Where the script lives after Step 3 |
|
|
154
|
+
| `test/__snapshots__/log-snapshot.e2e-spec.ts.snap` | Auto-generated baseline — commit this after Step 4 |
|
|
@@ -70,6 +70,9 @@ export declare class AicfSummaryLog implements AICFSummary {
|
|
|
70
70
|
serviceEndTime: string;
|
|
71
71
|
serviceTime: number;
|
|
72
72
|
additionalInfo: object | null;
|
|
73
|
+
useCase?: string;
|
|
74
|
+
useCaseStep?: string;
|
|
75
|
+
useCaseSessionId?: string;
|
|
73
76
|
constructor(summaryData: SummaryData);
|
|
74
77
|
}
|
|
75
78
|
declare class BasicInfoDetail implements AICFDetail {
|
|
@@ -150,6 +153,9 @@ export interface AICFSummary {
|
|
|
150
153
|
serviceEndTime: string;
|
|
151
154
|
serviceTime: number;
|
|
152
155
|
additionalInfo?: object | null;
|
|
156
|
+
useCase?: string;
|
|
157
|
+
useCaseStep?: string;
|
|
158
|
+
useCaseSessionId?: string;
|
|
153
159
|
}
|
|
154
160
|
export interface RequestHTTPFormat {
|
|
155
161
|
method: string;
|
|
@@ -98,6 +98,15 @@ class AicfSummaryLog {
|
|
|
98
98
|
'x-session-path': originSession,
|
|
99
99
|
};
|
|
100
100
|
}
|
|
101
|
+
if (headers?.['x-ais-usecase']) {
|
|
102
|
+
this.useCase = headers['x-ais-usecase'];
|
|
103
|
+
}
|
|
104
|
+
if (headers?.['x-ais-usecase-step']) {
|
|
105
|
+
this.useCaseStep = headers['x-ais-usecase-step'];
|
|
106
|
+
}
|
|
107
|
+
if (headers?.['x-ais-usecase-session-id']) {
|
|
108
|
+
this.useCaseSessionId = headers['x-ais-usecase-session-id'];
|
|
109
|
+
}
|
|
101
110
|
}
|
|
102
111
|
}
|
|
103
112
|
exports.AicfSummaryLog = AicfSummaryLog;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aicf.dto.js","sourceRoot":"","sources":["../../../src/formats/aicf/aicf.dto.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"aicf.dto.js","sourceRoot":"","sources":["../../../src/formats/aicf/aicf.dto.ts"],"names":[],"mappings":";;;;;;AAqNA,4CAeC;AAED,8CAMC;AA5OD,0DAAkC;AAClC,8CAI4B;AAC5B,4CAAoB;AACpB,gFAA0E;AAE1E,IAAY,WAGX;AAHD,WAAY,WAAW;IACrB,kCAAmB,CAAA;IACnB,gCAAiB,CAAA;AACnB,CAAC,EAHW,WAAW,2BAAX,WAAW,QAGtB;AAED,IAAY,eAKX;AALD,WAAY,eAAe;IACzB,wDAAqC,CAAA;IACrC,wCAAqB,CAAA;IACrB,0CAAuB,CAAA;IACvB,0CAAuB,CAAA;AACzB,CAAC,EALW,eAAe,+BAAf,eAAe,QAK1B;AAED,IAAY,SAKX;AALD,WAAY,SAAS;IACnB,0BAAa,CAAA;IACb,gCAAmB,CAAA;IACnB,4BAAe,CAAA;IACf,4BAAe,CAAA;AACjB,CAAC,EALW,SAAS,yBAAT,SAAS,QAKpB;AAED,IAAY,iBAKX;AALD,WAAY,iBAAiB;IAC3B,kCAAa,CAAA;IACb,wCAAmB,CAAA;IACnB,oCAAe,CAAA;IACf,oCAAe,CAAA;AACjB,CAAC,EALW,iBAAiB,iCAAjB,iBAAiB,QAK5B;AAED,IAAY,WAWX;AAXD,WAAY,WAAW;IACrB,4BAAa,CAAA;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