@eliware/common 12.0.0 → 13.0.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/AGENTS.md +12 -33
- package/README.md +6 -6
- package/RELEASE_NOTES.md +26 -63
- package/docs/api.md +56 -21
- package/docs/package.md +3 -2
- package/docs/troubleshooting.md +5 -5
- package/docs/usage.md +61 -9
- package/package.json +8 -7
- package/specs/directives.yaml +4 -4
- package/src/errors.mjs +2 -2
- package/src/index.d.ts +30 -7
- package/src/index.mjs +9 -1
package/AGENTS.md
CHANGED
|
@@ -2,54 +2,33 @@
|
|
|
2
2
|
|
|
3
3
|
## Project
|
|
4
4
|
|
|
5
|
-
Maintain `@eliware/common`, a native ESM library for shared Eliware APIs.
|
|
6
|
-
Use Node.js 26 or later.
|
|
7
|
-
|
|
8
5
|
## Scope and boundaries
|
|
9
6
|
|
|
10
|
-
Keep
|
|
11
|
-
Get Eliware Operations approval before publication.
|
|
7
|
+
Keep requirements in their authoritative specifications.
|
|
12
8
|
|
|
13
9
|
## Layout
|
|
14
10
|
|
|
15
|
-
Put runtime modules and declarations in `src/`.
|
|
16
|
-
Put one matching test in `tests/` for each runtime module.
|
|
17
|
-
Put user docs in `docs/`, examples in `examples/`, and specs in `specs/`.
|
|
18
|
-
|
|
19
11
|
## Development
|
|
20
12
|
|
|
21
|
-
Use native ESM.
|
|
22
|
-
Keep `src/index.mjs` as the public export barrel.
|
|
23
|
-
Keep docs, declarations, package data, and tests in sync.
|
|
24
|
-
|
|
25
13
|
## Validation
|
|
26
14
|
|
|
27
|
-
|
|
28
|
-
Run
|
|
29
|
-
Run
|
|
30
|
-
Run
|
|
31
|
-
Run
|
|
32
|
-
Run
|
|
33
|
-
Run `npm run pack` to check package contents.
|
|
15
|
+
Use Node.js 26 or later and native ESM for maintained JavaScript modules.
|
|
16
|
+
Run npm test for aggregate validation.
|
|
17
|
+
Run npm run lint for lint checks.
|
|
18
|
+
Run npm run audit for dependency checks.
|
|
19
|
+
Run npm run format to format files.
|
|
20
|
+
Run npm run format:check to check formatting.
|
|
34
21
|
|
|
35
22
|
## Security
|
|
36
23
|
|
|
37
|
-
Keep secrets, credentials, private data, and machine paths out of tracked files.
|
|
38
|
-
Review dependency behavior and update dependencies before publication.
|
|
39
|
-
|
|
40
24
|
## Changes
|
|
41
25
|
|
|
42
|
-
Describe user-visible changes in `RELEASE_NOTES.md`.
|
|
43
|
-
Keep release notes accurate.
|
|
44
|
-
|
|
45
26
|
## Library
|
|
46
27
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
28
|
+
Run focused tests first during development.
|
|
29
|
+
Run one test file with `npm test -- tests/path/to/example.test.mjs`.
|
|
30
|
+
Run multiple test files with `npm test -- tests/path/to/first.test.mjs tests/path/to/second.test.mjs`.
|
|
31
|
+
Prevent repeated full-suite runs during development.
|
|
32
|
+
Run the full `npm test` suite for final validation before a commit, milestone, or release.
|
|
50
33
|
|
|
51
34
|
## npm publication
|
|
52
|
-
|
|
53
|
-
Set the package version in `package.json`.
|
|
54
|
-
Use the Eliware Operations publication checklist.
|
|
55
|
-
Passing checks does not approve publication.
|
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ A shared ESM compatibility package for Eliware filesystem, path, logging, error,
|
|
|
23
23
|
|
|
24
24
|
## Features
|
|
25
25
|
|
|
26
|
-
Import shared Eliware APIs from `@eliware/common`.
|
|
26
|
+
Import shared Eliware APIs and redaction tools from `@eliware/common`.
|
|
27
27
|
|
|
28
28
|
## Requirements
|
|
29
29
|
|
|
@@ -43,7 +43,7 @@ Read the [user docs](docs/README.md) and [release notes](RELEASE_NOTES.md).
|
|
|
43
43
|
|
|
44
44
|
## Development
|
|
45
45
|
|
|
46
|
-
Read the [
|
|
46
|
+
Read the [specifications index](specs/README.md) before you change files.
|
|
47
47
|
|
|
48
48
|
## Testing
|
|
49
49
|
|
|
@@ -55,19 +55,19 @@ Read the [troubleshooting guide](docs/troubleshooting.md).
|
|
|
55
55
|
|
|
56
56
|
## Security
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
Read the [redaction API guide](docs/api.md#redaction-apis) before you use sensitive data.
|
|
59
59
|
|
|
60
60
|
## API
|
|
61
61
|
|
|
62
|
-
Read the [API reference](docs/api.md)
|
|
62
|
+
Read the [API reference](docs/api.md).
|
|
63
63
|
|
|
64
64
|
## Packaging
|
|
65
65
|
|
|
66
|
-
Use native ESM. Read the [package guide](docs/package.md)
|
|
66
|
+
Use native ESM. Read the [package guide](docs/package.md).
|
|
67
67
|
|
|
68
68
|
## Examples
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
Read the [examples index](examples/README.md).
|
|
71
71
|
|
|
72
72
|
## Support
|
|
73
73
|
|
package/RELEASE_NOTES.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# Release Notes
|
|
2
2
|
|
|
3
|
+
## 13.0.0 — 2026-10-19
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- Re-exported the complete runtime APIs and public types from the Eliware errors, log, path, redact, signals, and snowflake packages.
|
|
8
|
+
- Added the `defaultEvents` errors export and TypeScript coverage for the public type exports.
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- Upgraded the package and its Eliware runtime and test dependencies to major version 13.
|
|
13
|
+
- Aligned package metadata, specifications, CI, npm publication, and Knit workflows with convention version 13.
|
|
14
|
+
- Updated API, usage, and package documentation for the current exports, dependencies, and common tasks.
|
|
15
|
+
- Simplified `AGENTS.md` and `README.md` to the content required by the conventions.
|
|
16
|
+
|
|
17
|
+
### Breaking changes
|
|
18
|
+
|
|
19
|
+
- Require major version 13 of the Eliware runtime dependencies.
|
|
20
|
+
|
|
21
|
+
## 12.0.1 — 2026-10-12
|
|
22
|
+
|
|
23
|
+
### Added
|
|
24
|
+
|
|
25
|
+
- Added `@eliware/redact` APIs and TypeScript option types.
|
|
26
|
+
|
|
3
27
|
## 12.0.0 — 2026-10-12
|
|
4
28
|
|
|
5
29
|
### Added
|
|
@@ -22,72 +46,11 @@
|
|
|
22
46
|
### Changed
|
|
23
47
|
|
|
24
48
|
- Modernized the package for the shared Eliware conventions and Node.js `>=26`.
|
|
25
|
-
- Replaced direct Jest tooling with `@eliware/test`,
|
|
49
|
+
- Replaced direct Jest tooling with `@eliware/test`, with enforced 100×4 coverage and shared linting.
|
|
26
50
|
- Updated CI for Ubuntu and Windows validation on `main`, pull requests, and `v*` tags, with gated publishing.
|
|
27
|
-
- Updated package metadata, documentation, and dependency
|
|
51
|
+
- Updated package metadata, documentation, and dependency checks.
|
|
28
52
|
|
|
29
53
|
### Breaking changes
|
|
30
54
|
|
|
31
55
|
- Required Node.js `>=26`.
|
|
32
56
|
- Replaced direct Jest and Oxlint project tooling with the shared `@eliware/test` harness.
|
|
33
|
-
|
|
34
|
-
## 1.1.8 — 2026-08-10
|
|
35
|
-
|
|
36
|
-
### Changed
|
|
37
|
-
|
|
38
|
-
- Updated `@eliware/errors` to 1.1.9, `@eliware/log` to 1.1.12, and `@eliware/signals` to 1.1.7.
|
|
39
|
-
- Added the `safeSerialize` TypeScript declaration to match the runtime export.
|
|
40
|
-
- Updated signal handler contract coverage for the current upstream listener behavior.
|
|
41
|
-
|
|
42
|
-
## 1.1.7 — 2026-08-07
|
|
43
|
-
|
|
44
|
-
### Changed
|
|
45
|
-
|
|
46
|
-
- Standardized package layout, validation scripts, TypeScript checking, CI, and package contents.
|
|
47
|
-
- Updated internal dependencies to the latest released Eliware versions.
|
|
48
|
-
- Expanded troubleshooting, development, and security documentation.
|
|
49
|
-
|
|
50
|
-
## 1.1.6 — 2026-08-07
|
|
51
|
-
|
|
52
|
-
### Changed
|
|
53
|
-
|
|
54
|
-
- Updated `@eliware/errors`, `@eliware/log`, `@eliware/path`, and `@eliware/signals` to current releases.
|
|
55
|
-
- Standardized Jest coverage on the V8 provider for accurate ESM coverage reporting.
|
|
56
|
-
|
|
57
|
-
## 1.1.5 — 2026-08-06
|
|
58
|
-
|
|
59
|
-
### Changed
|
|
60
|
-
|
|
61
|
-
- Refactored the package into focused ESM modules under `src/`.
|
|
62
|
-
- Expanded the unified export surface to include the current public APIs from four shared packages.
|
|
63
|
-
- Added logger and path exports, including `safeSerialize`, `resolvePath`, `relativePath`, and `fileUrlToPath`.
|
|
64
|
-
- Updated TypeScript declarations for the expanded API and dependency option types.
|
|
65
|
-
- Replaced CommonJS entry points and tests with ESM-only files.
|
|
66
|
-
- Expanded contract tests for public exports, helper APIs, handlers, cleanup, and shutdown hooks.
|
|
67
|
-
- Updated the README, examples, dependencies, package files, and development guidance.
|
|
68
|
-
- Standardized linting, coverage scripts, CI, and repository artifact ignores.
|
|
69
|
-
|
|
70
|
-
## 1.1.4 — 2026-07-01
|
|
71
|
-
|
|
72
|
-
### Changed
|
|
73
|
-
|
|
74
|
-
- Updated package metadata and dependencies.
|
|
75
|
-
- Refreshed the lockfile and standardized repository tooling.
|
|
76
|
-
|
|
77
|
-
## 1.1.3 — 2025-12-21
|
|
78
|
-
|
|
79
|
-
### Changed
|
|
80
|
-
|
|
81
|
-
- Released maintenance updates.
|
|
82
|
-
|
|
83
|
-
## 1.1.2 — 2025-12-21
|
|
84
|
-
|
|
85
|
-
### Changed
|
|
86
|
-
|
|
87
|
-
- Released maintenance updates.
|
|
88
|
-
|
|
89
|
-
## 1.1.1 — 2025-12-09
|
|
90
|
-
|
|
91
|
-
### Added
|
|
92
|
-
|
|
93
|
-
- Released the first tagged version of the common ESM utility package.
|
package/docs/api.md
CHANGED
|
@@ -17,7 +17,7 @@ Read the [Node.js file system API](https://nodejs.org/api/fs.html) for functions
|
|
|
17
17
|
|
|
18
18
|
| Export | Call | Result |
|
|
19
19
|
| -------------------- | ------------------------------------------ | -------------------------------------------------- |
|
|
20
|
-
| `path` | `path(metaOrDir, ...segments)` |
|
|
20
|
+
| `path` | `path(metaOrDir, ...segments)` | Add segments to a module directory. |
|
|
21
21
|
| `pathUrl` | `pathUrl(metaOrDir, ...segments)` | Return a file URL string. |
|
|
22
22
|
| `getCurrentDirname` | `getCurrentDirname(metaOrDir, dirnameFn?)` | Return the module directory. |
|
|
23
23
|
| `getCurrentFilename` | `getCurrentFilename(metaOrDir)` | Return the module filename or input string. |
|
|
@@ -29,7 +29,7 @@ Pass `import.meta` or a directory string as `metaOrDir`. Pass `dirnameFn` only w
|
|
|
29
29
|
The default export from `@eliware/path` is named `path` here.
|
|
30
30
|
Read the [path package docs](https://github.com/eliware/path/tree/main/docs) for details.
|
|
31
31
|
|
|
32
|
-
##
|
|
32
|
+
## Logger APIs
|
|
33
33
|
|
|
34
34
|
| Export | Call | Result |
|
|
35
35
|
| --------------- | ----------------------------------------------- | ------------------------------------------------ |
|
|
@@ -40,21 +40,46 @@ Read the [path package docs](https://github.com/eliware/path/tree/main/docs) for
|
|
|
40
40
|
`createLogger` accepts `level`, `transports`, `format`, `timestamp`, and `keys` options.
|
|
41
41
|
Use `format: "text"` or `format: "json"`. The default level is `info`.
|
|
42
42
|
The other defaults are a console transport, text format, no timestamp, and no custom redaction keys.
|
|
43
|
+
|
|
43
44
|
`safeSerialize` accepts `keys`, `redactKeys`, `marker`, `circularMarker`, `maxDepth`, `maxKeys`, `maxArray`, and `maxString` options.
|
|
44
45
|
It does not call `toJSON`. It uses default secret keys and limits when you omit options.
|
|
45
46
|
It returns JSON-safe values. It converts BigInt values to text and marks circular or truncated values.
|
|
46
|
-
Read the [
|
|
47
|
+
Read the [logger package docs](https://github.com/eliware/log/tree/main/docs) for defaults and details.
|
|
48
|
+
|
|
49
|
+
## Redaction APIs
|
|
50
|
+
|
|
51
|
+
`defaultPolicy` provides the default sensitive key names and marker.
|
|
52
|
+
Call `createPolicy(options?)` to make a frozen policy with custom key names or markers.
|
|
53
|
+
Call `redactValue(value, options?)` to return a redacted copy of an object or array.
|
|
54
|
+
Call `redactHeaders(headers, options?)` to redact header values in an object, pair array, or entries object.
|
|
55
|
+
Call `redactText(value, options?)` to redact standard credential patterns, custom key values, and literal secrets.
|
|
56
|
+
Call `replaceLiteralSecret(value, secret, marker?)` to replace one exact secret in text.
|
|
57
|
+
|
|
58
|
+
Policy options include `keys`, `redactKeys`, `marker`, and `circularMarker`.
|
|
59
|
+
Structured values also support `maxDepth`, `maxKeys`, and `maxArray` limits.
|
|
60
|
+
Text also supports `secrets` and the `maxOutputLength` limit.
|
|
61
|
+
|
|
62
|
+
The default marker is `[REDACTED]`. The default text limit is 10,000 characters.
|
|
63
|
+
`redactText` detects authorization values, secret assignments, provider tokens, JWT-like strings, and key blocks.
|
|
64
|
+
|
|
65
|
+
`redactValue` returns a copy and does not change its input.
|
|
66
|
+
`redactHeaders` keeps the input shape for objects and pair arrays. It returns a lowercase object for entries objects.
|
|
67
|
+
|
|
68
|
+
The `safeSerialize` export in Logger APIs matches the `safeSerialize` export from `@eliware/redact`.
|
|
69
|
+
|
|
70
|
+
Read the [Redact API guide](https://github.com/eliware/redact/blob/main/docs/api.md) for full rules and limits.
|
|
47
71
|
|
|
48
72
|
## Error handlers
|
|
49
73
|
|
|
50
|
-
Call `registerHandlers(options?)` to
|
|
74
|
+
Call `registerHandlers(options?)` to add handlers for process events.
|
|
51
75
|
The default events are `uncaughtException`, `unhandledRejection`, and `warning`.
|
|
76
|
+
The `defaultEvents` export contains the default event names.
|
|
52
77
|
|
|
53
78
|
| Option | Default | Purpose |
|
|
54
79
|
| ------------ | -------------------------- | --------------------------------------------- |
|
|
55
80
|
| `processObj` | `process` | Set the process-like event source. |
|
|
56
81
|
| `log` | `@eliware/log` | Set the logger. |
|
|
57
|
-
| `events` | Three process error events | Set the events
|
|
82
|
+
| `events` | Three process error events | Set the events for this function. |
|
|
58
83
|
| `once` | `false` | Set one-time handler behavior. |
|
|
59
84
|
| `signal` | None | Remove handlers when an `AbortSignal` aborts. |
|
|
60
85
|
|
|
@@ -65,23 +90,26 @@ Read the [errors package docs](https://github.com/eliware/errors/tree/main/docs)
|
|
|
65
90
|
|
|
66
91
|
## Shutdown handlers
|
|
67
92
|
|
|
68
|
-
Call `registerSignals(options?)` to
|
|
93
|
+
Call `registerSignals(options?)` to add process shutdown handlers.
|
|
69
94
|
The default signals are `SIGTERM`, `SIGINT`, and `SIGHUP`.
|
|
70
95
|
|
|
71
|
-
| Option | Default | Purpose
|
|
72
|
-
| -------------- | ----------------------------- |
|
|
73
|
-
| `processObj` | `process` | Set the process-like event source.
|
|
74
|
-
| `log` | `@eliware/log` | Set the logger.
|
|
75
|
-
| `signals` | `SIGTERM`, `SIGINT`, `SIGHUP` | Set the signals
|
|
76
|
-
| `shutdownHook` | None | Set cleanup work.
|
|
77
|
-
| `exitCode` | `0` | Set the process exit code.
|
|
78
|
-
| `exit` | `true` | Allow or prevent process exit.
|
|
79
|
-
| `signal` | None | Remove handlers when an `AbortSignal` aborts.
|
|
96
|
+
| Option | Default | Purpose |
|
|
97
|
+
| -------------- | ----------------------------- | ----------------------------------------------------- |
|
|
98
|
+
| `processObj` | `process` | Set the process-like event source. |
|
|
99
|
+
| `log` | `@eliware/log` | Set the logger. |
|
|
100
|
+
| `signals` | `SIGTERM`, `SIGINT`, `SIGHUP` | Set the signals for this function. |
|
|
101
|
+
| `shutdownHook` | None | Set cleanup work. This function can return a promise. |
|
|
102
|
+
| `exitCode` | `0` | Set the process exit code. |
|
|
103
|
+
| `exit` | `true` | Allow or prevent process exit. |
|
|
104
|
+
| `signal` | None | Remove handlers when an `AbortSignal` aborts. |
|
|
80
105
|
|
|
81
106
|
The result has `removed`, `shutdown(signal?)`, `getShuttingDown()`, and `removeHandlers()` members.
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
107
|
+
|
|
108
|
+
The default `exit` value is `true`. Set `exit: false` when your app controls process exit.
|
|
109
|
+
|
|
110
|
+
Each callback runs once. The package calls callbacks in order and continues after an error.
|
|
111
|
+
|
|
112
|
+
Pass an empty `signals` array to disable signal events. A `beforeExit` handler also runs.
|
|
85
113
|
Read the [signals API docs](https://github.com/eliware/signals/blob/main/docs/api.md) for shutdown order and error behavior.
|
|
86
114
|
|
|
87
115
|
## Snowflake IDs
|
|
@@ -97,21 +125,28 @@ Call `createSnowflakeGenerator(options?)` to make a generator. Each call returns
|
|
|
97
125
|
|
|
98
126
|
Use one epoch for all generators in one application. Give each active generator a unique worker and process ID pair.
|
|
99
127
|
Keep each ID as a string. An ID uses a 42-bit timestamp, 5-bit worker value, 5-bit process value, and 12-bit sequence.
|
|
100
|
-
|
|
128
|
+
|
|
129
|
+
Each generator can create 4096 IDs for each millisecond. It throws `RangeError` when time or sequence limits fail.
|
|
101
130
|
Pass a safe integer or `bigint` to `epoch`, `workerId`, and `processId`.
|
|
131
|
+
|
|
102
132
|
Pass a clock that returns Unix milliseconds as a safe integer or `bigint`.
|
|
103
|
-
The generator uses its last timestamp when the clock moves
|
|
133
|
+
The generator uses its last timestamp when the clock moves to an earlier time.
|
|
104
134
|
The exports `generate`, `snowflake`, and the default export from `@eliware/snowflake` use one shared generator.
|
|
105
135
|
The `constants` export provides `epoch`, `sequenceBits`, `processBits`, and `workerBits` values as `bigint`.
|
|
106
|
-
|
|
136
|
+
|
|
137
|
+
Read the [Snowflake usage guide](https://github.com/eliware/snowflake/blob/main/docs/usage.md) for timestamp limits and clock behavior.
|
|
107
138
|
|
|
108
139
|
## TypeScript types
|
|
109
140
|
|
|
110
141
|
The package exports these types:
|
|
111
142
|
|
|
112
143
|
- `Logger`
|
|
144
|
+
- `LoggerWithConfiguredLevels`, `SafeSerializedValue`, and `RedactionOptions`
|
|
145
|
+
- `NodeSignal`, `SignalsLogger`, and `SignalsProcessLike`
|
|
146
|
+
- `ProcessEvent`, `ProcessListener`, and `ProcessLike`
|
|
113
147
|
- `RegisterHandlersOptions` and `RegisteredHandlers`
|
|
114
148
|
- `RegisterSignalsOptions` and `SignalsRegistration`
|
|
149
|
+
- `RedactionPolicy`, `SerializationOptions`, `StructuredRedactionOptions`, and `TextRedactionOptions`
|
|
115
150
|
- `SnowflakeGeneratorOptions` and `SnowflakeConstants`
|
|
116
151
|
|
|
117
152
|
Read the [declaration file](../src/index.d.ts) for the current type exports.
|
package/docs/package.md
CHANGED
|
@@ -14,15 +14,16 @@ The package does not provide a CommonJS entry point.
|
|
|
14
14
|
|
|
15
15
|
## Runtime dependencies
|
|
16
16
|
|
|
17
|
-
The package uses major version
|
|
17
|
+
The package uses major version 13 of these Eliware packages:
|
|
18
18
|
|
|
19
19
|
- `@eliware/errors`
|
|
20
20
|
- `@eliware/log`
|
|
21
21
|
- `@eliware/path`
|
|
22
|
+
- `@eliware/redact`
|
|
22
23
|
- `@eliware/signals`
|
|
23
24
|
- `@eliware/snowflake`
|
|
24
25
|
|
|
25
|
-
Use the exports in this package. Use
|
|
26
|
+
Use the exports in this package. Use a dependency directly when your app requires its own entry point.
|
|
26
27
|
Read the [API reference](api.md) for each exported value.
|
|
27
28
|
|
|
28
29
|
## Published files
|
package/docs/troubleshooting.md
CHANGED
|
@@ -19,15 +19,15 @@ Pass `import.meta` or a directory string to a path helper.
|
|
|
19
19
|
Pass a file URL to `fileUrlToPath`.
|
|
20
20
|
Read the [path API section](api.md#path-helpers) for each helper's result.
|
|
21
21
|
|
|
22
|
-
##
|
|
22
|
+
## Logger errors
|
|
23
23
|
|
|
24
24
|
Check the `level`, `transports`, and `format` options passed to `createLogger`.
|
|
25
25
|
Pass a logger with `debug`, `info`, `warn`, and `error` methods where required.
|
|
26
|
-
Remove secret values before you write metadata to
|
|
26
|
+
Remove secret values before you write metadata to logger output.
|
|
27
27
|
|
|
28
28
|
## Process handler errors
|
|
29
29
|
|
|
30
|
-
Keep each handler registration while
|
|
30
|
+
Keep each handler registration while it is required.
|
|
31
31
|
Call `removeHandlers()` to remove error or signal handlers.
|
|
32
32
|
Pass a valid process-like object and event names.
|
|
33
33
|
Read the [API reference](api.md#error-handlers) and [shutdown handler guide](api.md#shutdown-handlers).
|
|
@@ -36,7 +36,7 @@ Read the [API reference](api.md#error-handlers) and [shutdown handler guide](api
|
|
|
36
36
|
|
|
37
37
|
Give each active generator a unique worker and process ID pair.
|
|
38
38
|
Keep generated IDs as decimal strings. Do not convert them to `number`.
|
|
39
|
-
Wait
|
|
39
|
+
Wait until the clock value changes after a sequence limit error.
|
|
40
40
|
Check the epoch and clock when the generator reports a timestamp error.
|
|
41
41
|
Read [Snowflake IDs](api.md#snowflake-ids) for limits and clock behavior.
|
|
42
42
|
|
|
@@ -44,4 +44,4 @@ Read [Snowflake IDs](api.md#snowflake-ids) for limits and clock behavior.
|
|
|
44
44
|
|
|
45
45
|
Run `npm ci` to install locked dependencies.
|
|
46
46
|
Run `npm test` to check the repository.
|
|
47
|
-
|
|
47
|
+
Repair the first reported error, then run `npm test` again.
|
package/docs/usage.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Requirements
|
|
4
4
|
|
|
5
|
-
Use Node.js 26 or later. Use a project
|
|
5
|
+
Use Node.js 26 or later. Use a project that supports native ESM.
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
@@ -14,9 +14,22 @@ npm install @eliware/common
|
|
|
14
14
|
|
|
15
15
|
The package installs its Eliware runtime dependencies.
|
|
16
16
|
|
|
17
|
+
## Read a file
|
|
18
|
+
|
|
19
|
+
Use the Node.js `fs` namespace for file operations. This example reads a file as UTF-8 text.
|
|
20
|
+
|
|
21
|
+
```js
|
|
22
|
+
import { fs } from "@eliware/common";
|
|
23
|
+
|
|
24
|
+
const text = await fs.promises.readFile("./config.json", "utf8");
|
|
25
|
+
const config = JSON.parse(text);
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Use Node.js `fs` documentation for available methods, options, and errors.
|
|
29
|
+
|
|
17
30
|
## Import public APIs
|
|
18
31
|
|
|
19
|
-
Import the APIs that your
|
|
32
|
+
Import the APIs that your app requires.
|
|
20
33
|
|
|
21
34
|
```js
|
|
22
35
|
import {
|
|
@@ -45,8 +58,8 @@ registerSignals({
|
|
|
45
58
|
console.log(fs.existsSync(configFile));
|
|
46
59
|
```
|
|
47
60
|
|
|
48
|
-
This code
|
|
49
|
-
The shutdown
|
|
61
|
+
This code writes one Snowflake ID and checks one file. It stays active until a signal starts shutdown.
|
|
62
|
+
The shutdown callback stops the timer and removes the error handlers.
|
|
50
63
|
|
|
51
64
|
## Use path helpers
|
|
52
65
|
|
|
@@ -73,7 +86,7 @@ const localFile = fileUrlToPath(url);
|
|
|
73
86
|
Pass a directory string when code does not have `import.meta`.
|
|
74
87
|
Read the [API reference](api.md) for each path helper.
|
|
75
88
|
|
|
76
|
-
## Use
|
|
89
|
+
## Use logger APIs
|
|
77
90
|
|
|
78
91
|
Use the default `log` object or create a logger with `createLogger(options)`.
|
|
79
92
|
|
|
@@ -84,12 +97,51 @@ const logger = createLogger({ format: "json", timestamp: true });
|
|
|
84
97
|
logger.info("Request complete", safeSerialize({ requestId: "example" }));
|
|
85
98
|
```
|
|
86
99
|
|
|
87
|
-
Pass metadata as the second logger argument. Use `safeSerialize` to remove secret fields before you
|
|
100
|
+
Pass metadata as the second logger argument. Use `safeSerialize` to remove secret fields and limit nested values before you write records.
|
|
101
|
+
|
|
102
|
+
```js
|
|
103
|
+
import { createLogger, safeSerialize } from "@eliware/common";
|
|
104
|
+
|
|
105
|
+
const logger = createLogger({ format: "json" });
|
|
106
|
+
logger.info("Request complete", safeSerialize({ token: "example", status: 200 }));
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
The serializer returns a bounded representation. It does not guarantee that all sensitive data has been removed.
|
|
110
|
+
|
|
111
|
+
## Redact sensitive values
|
|
112
|
+
|
|
113
|
+
Use `redactText` to remove credentials from text before you write or store it.
|
|
114
|
+
|
|
115
|
+
```js
|
|
116
|
+
import { redactText, redactValue } from "@eliware/common";
|
|
117
|
+
|
|
118
|
+
const message = redactText("Authorization: Bearer example-token");
|
|
119
|
+
const record = redactValue({ user: "alex", token: "example-token" });
|
|
120
|
+
console.log(message, record);
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
`redactText` applies standard credential rules. Pass `secrets` to replace known literal values.
|
|
124
|
+
`redactValue` returns a copy with sensitive property values replaced.
|
|
125
|
+
Read the [Redaction APIs](api.md#redaction-apis) for policies, options, limits, and header handling.
|
|
126
|
+
|
|
127
|
+
Use `redactHeaders` for HTTP header data. Use `createPolicy` to add a sensitive property name.
|
|
128
|
+
|
|
129
|
+
```js
|
|
130
|
+
import { createPolicy, redactHeaders, redactValue } from "@eliware/common";
|
|
131
|
+
|
|
132
|
+
const policy = createPolicy({ keys: ["token", "sessionId"] });
|
|
133
|
+
const record = redactValue({ sessionId: "example", status: 200 }, policy);
|
|
134
|
+
const headers = redactHeaders({ Authorization: "Bearer example", Accept: "application/json" });
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
The policy replaces the default sensitive names with the names that you provide. Include the default names when you want to keep them.
|
|
88
138
|
|
|
89
|
-
##
|
|
139
|
+
## Process errors and signals
|
|
90
140
|
|
|
91
|
-
Call `registerHandlers(options)` to add process error handlers.
|
|
92
|
-
Call `
|
|
141
|
+
Call `registerHandlers(options)` to add process error handlers.
|
|
142
|
+
Call its `removeHandlers()` method when the handlers are no longer required.
|
|
143
|
+
Call `registerSignals(options)` to add shutdown handlers.
|
|
144
|
+
Pass `shutdownHook` to run cleanup.
|
|
93
145
|
Read the [API reference](api.md) for defaults, options, return values, and dependency guides.
|
|
94
146
|
|
|
95
147
|
## Create Snowflake IDs
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eliware/common",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "13.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A shared ESM compatibility package for Eliware filesystem, path, logging, error, and signal APIs.",
|
|
6
6
|
"keywords": [
|
|
@@ -44,14 +44,15 @@
|
|
|
44
44
|
"node": ">=26"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@eliware/errors": "^
|
|
48
|
-
"@eliware/log": "^
|
|
49
|
-
"@eliware/path": "^
|
|
50
|
-
"@eliware/
|
|
51
|
-
"@eliware/
|
|
47
|
+
"@eliware/errors": "^13.0.0",
|
|
48
|
+
"@eliware/log": "^13.0.0",
|
|
49
|
+
"@eliware/path": "^13.0.0",
|
|
50
|
+
"@eliware/redact": "^13.0.0",
|
|
51
|
+
"@eliware/signals": "^13.0.0",
|
|
52
|
+
"@eliware/snowflake": "^13.0.0"
|
|
52
53
|
},
|
|
53
54
|
"devDependencies": {
|
|
54
|
-
"@eliware/test": "^
|
|
55
|
+
"@eliware/test": "^13.0.0",
|
|
55
56
|
"typescript": "^7.0.2"
|
|
56
57
|
},
|
|
57
58
|
"jest": {
|
package/specs/directives.yaml
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
version: "
|
|
2
|
-
description: Defines requirements for the Eliware
|
|
1
|
+
version: "13.0"
|
|
2
|
+
description: Defines requirements for the Eliware shared package.
|
|
3
3
|
directives:
|
|
4
4
|
- id: E-199.0
|
|
5
5
|
dos:
|
|
6
|
-
- Export
|
|
6
|
+
- Export shared file system, path, logger, error, signal, Redact, and Snowflake APIs.
|
|
7
7
|
- Keep the package entry point and declaration file under src/.
|
|
8
8
|
- Mirror every source module with one test module under tests/.
|
|
9
9
|
- Use the shared Eliware packages for delegated runtime behavior.
|
|
10
10
|
- Run repository validation through eliware-test.
|
|
11
|
-
-
|
|
11
|
+
- Limit published files to package code and user docs.
|
|
12
12
|
donts:
|
|
13
13
|
- Do not add global configuration or import-time work.
|
|
14
14
|
- Do not duplicate behavior owned by shared Eliware packages.
|
package/src/errors.mjs
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import * as fs from "fs";
|
|
2
|
-
import type logger from "@eliware/log";
|
|
3
|
-
import type { RegisterHandlersOptions, RegisteredHandlers } from "@eliware/errors";
|
|
4
|
-
import type { RegisterSignalsOptions, SignalsRegistration } from "@eliware/signals";
|
|
5
|
-
|
|
6
2
|
export { fs };
|
|
7
3
|
export { createLogger, default as log, safeSerialize } from "@eliware/log";
|
|
4
|
+
export type {
|
|
5
|
+
LoggerWithConfiguredLevels,
|
|
6
|
+
RedactionOptions,
|
|
7
|
+
SafeSerializedValue,
|
|
8
|
+
} from "@eliware/log";
|
|
8
9
|
export {
|
|
9
10
|
path,
|
|
10
11
|
pathUrl,
|
|
@@ -21,13 +22,35 @@ export {
|
|
|
21
22
|
constants,
|
|
22
23
|
} from "@eliware/snowflake";
|
|
23
24
|
export type { SnowflakeGeneratorOptions, SnowflakeConstants } from "@eliware/snowflake";
|
|
25
|
+
export {
|
|
26
|
+
createPolicy,
|
|
27
|
+
defaultPolicy,
|
|
28
|
+
redactValue,
|
|
29
|
+
redactHeaders,
|
|
30
|
+
redactText,
|
|
31
|
+
replaceLiteralSecret,
|
|
32
|
+
} from "@eliware/redact";
|
|
33
|
+
export type {
|
|
34
|
+
RedactionPolicy,
|
|
35
|
+
SerializationOptions,
|
|
36
|
+
StructuredRedactionOptions,
|
|
37
|
+
TextRedactionOptions,
|
|
38
|
+
} from "@eliware/redact";
|
|
24
39
|
export { default as registerHandlers } from "@eliware/errors";
|
|
40
|
+
export { defaultEvents } from "@eliware/errors";
|
|
25
41
|
export { default as registerSignals } from "@eliware/signals";
|
|
26
42
|
export type {
|
|
43
|
+
Logger,
|
|
44
|
+
ProcessEvent,
|
|
45
|
+
ProcessListener,
|
|
46
|
+
ProcessLike,
|
|
27
47
|
RegisterHandlersOptions,
|
|
28
48
|
RegisteredHandlers,
|
|
49
|
+
} from "@eliware/errors";
|
|
50
|
+
export type {
|
|
51
|
+
NodeSignal,
|
|
52
|
+
ProcessLike as SignalsProcessLike,
|
|
53
|
+
SignalsLogger,
|
|
29
54
|
RegisterSignalsOptions,
|
|
30
55
|
SignalsRegistration,
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export type Logger = typeof logger;
|
|
56
|
+
} from "@eliware/signals";
|
package/src/index.mjs
CHANGED
|
@@ -15,5 +15,13 @@ export {
|
|
|
15
15
|
generate,
|
|
16
16
|
constants,
|
|
17
17
|
} from "@eliware/snowflake";
|
|
18
|
-
export {
|
|
18
|
+
export {
|
|
19
|
+
createPolicy,
|
|
20
|
+
defaultPolicy,
|
|
21
|
+
redactValue,
|
|
22
|
+
redactHeaders,
|
|
23
|
+
redactText,
|
|
24
|
+
replaceLiteralSecret,
|
|
25
|
+
} from "@eliware/redact";
|
|
26
|
+
export { defaultEvents, default as registerHandlers } from "./errors.mjs";
|
|
19
27
|
export { default as registerSignals } from "./signals.mjs";
|