Skip to content

Commit aaf8b72

Browse files
authoredOct 8, 2024··
fix: updates changelogs and wiki with migration guide (#65)
1 parent f074847 commit aaf8b72

File tree

3 files changed

+43
-28
lines changed

3 files changed

+43
-28
lines changed
 

‎.changeset/odd-spoons-sort.md

+5-27
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,12 @@
22
"@litehex/node-vault": major
33
---
44

5-
BREAKING: The responses are wrapped in a record of type `SafeReturn<T, VaultError>`. This record contains the `data` property for successful responses and the `error` property for error responses.
5+
BREAKING: The responses of commands are wrapped in a record with type of `SafeReturn<T, VaultError>`.
66

7-
This change only affects the return value of commands. Here is an example of how to use it:
7+
This record contains two properties:
88

9-
```typescript
10-
import { VaultError, Client } from '@litehex/node-vault';
9+
- `data`: The `data` property for successful responses. The value depends on the command.
10+
- `error`: The `error` property for error responses. The type is `VaultError`, which is a subclass of `Error`.
1111

12-
const { data, error } = await vc.write({
13-
path: 'secret/test',
14-
data: {
15-
foo: 'bar'
16-
}
17-
});
12+
Read [Migration guide](https://github.com/shahradelahi/node-vault/wiki/Migration) for more details on how to use it.
1813

19-
20-
if (error) {
21-
if (error instanceof VaultError) {
22-
return console.log(`Panic Mode: ${error.message}`);
23-
}
24-
return console.log(error); // Probably fetch failed. Should we retry?
25-
}
26-
27-
// The error is checked by the last statement above and the only possibility is the success response with the `data` property
28-
29-
console.log(error); // undefined
30-
console.log(data); // { request_id: '...', lease_id: '...', ... }
31-
```
32-
33-
This feature is called Atomic Responses, which means there are only two responses: `success` and `error`.
34-
35-
Your editor/IDE might not detect any errors, so please make sure to update and verify correctness with every usage.

‎.wiki/Migration.md

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
## Migration to v1
2+
3+
### Responses of commands
4+
5+
The responses of commands are wrapped in a record with type of `SafeReturn<T, VaultError>`.
6+
7+
This record contains two properties:
8+
9+
- `data`: The `data` property for successful responses. The value depends on the command.
10+
- `error`: The `error` property for error responses. The type is `VaultError`, which is a subclass of `Error`.
11+
12+
Your editor/IDE might not detect any errors, so please make sure to update and verify correctness of every usage.
13+
14+
###### Example
15+
16+
```typescript
17+
import { VaultError, Client } from '@litehex/node-vault';
18+
19+
const { data, error } = await vc.write({
20+
path: 'secret/test',
21+
data: {
22+
foo: 'bar'
23+
}
24+
});
25+
26+
if (error) {
27+
if (error instanceof VaultError) {
28+
return console.log(`Panic Mode: ${error.message}`);
29+
}
30+
return console.log(error); // Probably fetch failed. Should we retry?
31+
}
32+
33+
// The error is checked by the last statement above and the only possibility is the success response with the `data` property
34+
35+
console.log(error); // undefined
36+
console.log(data); // { request_id: '...', lease_id: '...', ... }
37+
```

‎README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ console.log(deleted); // { data: true }
104104

105105
For complete usages, please dive into the [Wiki](https://github.com/shahradelahi/node-vault/wiki).
106106

107-
For all configuration options, please see [the API docs](https://paka.dev/npm/@litehex/node-vault).
107+
For all configuration options, please see [the API docs](https://www.jsdocs.io/package/@litehex/node-vault).
108108

109109
### 🤝 Contributing
110110

0 commit comments

Comments
 (0)
Please sign in to comment.