@eliware/common 13.0.0 → 14.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 +20 -6
- package/README.md +3 -2
- package/RELEASE_NOTES.md +9 -7
- package/docs/api.md +24 -8
- package/docs/package.md +1 -1
- package/docs/usage.md +12 -0
- package/package.json +8 -8
- package/specs/directives.yaml +1 -1
- package/src/errors.d.mts +37 -0
- package/src/index.d.ts +9 -12
- package/src/index.mjs +1 -0
- package/src/log.d.mts +29 -0
- package/src/path.d.mts +47 -0
- package/src/path.mjs +2 -0
- package/src/snowflake.d.mts +22 -0
package/AGENTS.md
CHANGED
|
@@ -2,27 +2,38 @@
|
|
|
2
2
|
|
|
3
3
|
## Project
|
|
4
4
|
|
|
5
|
+
See `README.md` for the repository purpose, owner, scope, and boundaries.
|
|
6
|
+
|
|
5
7
|
## Scope and boundaries
|
|
6
8
|
|
|
7
|
-
Keep requirements in
|
|
9
|
+
Keep repository requirements in `specs/directives.yaml`.
|
|
8
10
|
|
|
9
11
|
## Layout
|
|
10
12
|
|
|
13
|
+
Use `README.md` and `specs/README.md` to find maintained files.
|
|
14
|
+
|
|
11
15
|
## Development
|
|
12
16
|
|
|
17
|
+
Give each source and test module one cohesive purpose.
|
|
18
|
+
|
|
13
19
|
## Validation
|
|
14
20
|
|
|
15
21
|
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.
|
|
22
|
+
Run `npm test` for aggregate validation.
|
|
23
|
+
Run `npm run lint` for lint checks.
|
|
24
|
+
Run `npm run audit` for dependency checks.
|
|
25
|
+
Run `npm run format` to format files.
|
|
26
|
+
Run `npm run format:check` to check formatting.
|
|
21
27
|
|
|
22
28
|
## Security
|
|
23
29
|
|
|
30
|
+
Keep credentials, secret values, private data, and runtime state out of Git.
|
|
31
|
+
|
|
24
32
|
## Changes
|
|
25
33
|
|
|
34
|
+
Describe each user-visible change in `RELEASE_NOTES.md`.
|
|
35
|
+
Keep release notes accurate.
|
|
36
|
+
|
|
26
37
|
## Library
|
|
27
38
|
|
|
28
39
|
Run focused tests first during development.
|
|
@@ -32,3 +43,6 @@ Prevent repeated full-suite runs during development.
|
|
|
32
43
|
Run the full `npm test` suite for final validation before a commit, milestone, or release.
|
|
33
44
|
|
|
34
45
|
## npm publication
|
|
46
|
+
|
|
47
|
+
Run `npm run pack` to check package contents.
|
|
48
|
+
Publish only after approved release steps.
|
package/README.md
CHANGED
|
@@ -23,7 +23,8 @@ A shared ESM compatibility package for Eliware filesystem, path, logging, error,
|
|
|
23
23
|
|
|
24
24
|
## Features
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
Eliware maintains this shared package for common Node.js APIs.
|
|
27
|
+
It re-exports filesystem, path, logger, error, signal, redaction, and Snowflake APIs.
|
|
27
28
|
|
|
28
29
|
## Requirements
|
|
29
30
|
|
|
@@ -63,7 +64,7 @@ Read the [API reference](docs/api.md).
|
|
|
63
64
|
|
|
64
65
|
## Packaging
|
|
65
66
|
|
|
66
|
-
|
|
67
|
+
Read the [package guide](docs/package.md).
|
|
67
68
|
|
|
68
69
|
## Examples
|
|
69
70
|
|
package/RELEASE_NOTES.md
CHANGED
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
# Release Notes
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 14.0.0 — 2026-10-21
|
|
4
4
|
|
|
5
5
|
### Added
|
|
6
6
|
|
|
7
7
|
- Re-exported the complete runtime APIs and public types from the Eliware errors, log, path, redact, signals, and snowflake packages.
|
|
8
|
-
- Added
|
|
8
|
+
- Added `createPathHelpers` with structured operation records and added type parity checks for dependency APIs.
|
|
9
9
|
|
|
10
10
|
### Changed
|
|
11
11
|
|
|
12
|
-
- Upgraded the package and its Eliware runtime and test dependencies to major version
|
|
13
|
-
- Aligned package metadata, specifications, CI, npm publication, and Knit workflows with convention version
|
|
14
|
-
-
|
|
15
|
-
- Simplified `
|
|
12
|
+
- Upgraded the package and its Eliware runtime and test dependencies to major version 14.
|
|
13
|
+
- Aligned package metadata, specifications, CI, npm publication, and Knit workflows with convention version 14.
|
|
14
|
+
- Expanded and corrected the API, setup, usage, package, and troubleshooting guides.
|
|
15
|
+
- Simplified `README.md` and `AGENTS.md` while keeping the content required by repository conventions.
|
|
16
|
+
- Removed invalid Log type aliases from Common and kept Common's valid public types available.
|
|
17
|
+
- Added a strict packed-consumer check for Common's retained public types.
|
|
16
18
|
|
|
17
19
|
### Breaking changes
|
|
18
20
|
|
|
19
|
-
- Require major version
|
|
21
|
+
- Require major version 14 of the Eliware runtime dependencies.
|
|
20
22
|
|
|
21
23
|
## 12.0.1 — 2026-10-12
|
|
22
24
|
|
package/docs/api.md
CHANGED
|
@@ -18,6 +18,7 @@ Read the [Node.js file system API](https://nodejs.org/api/fs.html) for functions
|
|
|
18
18
|
| Export | Call | Result |
|
|
19
19
|
| -------------------- | ------------------------------------------ | -------------------------------------------------- |
|
|
20
20
|
| `path` | `path(metaOrDir, ...segments)` | Add segments to a module directory. |
|
|
21
|
+
| `createPathHelpers` | `createPathHelpers(options?)` | Create path helpers that log each operation. |
|
|
21
22
|
| `pathUrl` | `pathUrl(metaOrDir, ...segments)` | Return a file URL string. |
|
|
22
23
|
| `getCurrentDirname` | `getCurrentDirname(metaOrDir, dirnameFn?)` | Return the module directory. |
|
|
23
24
|
| `getCurrentFilename` | `getCurrentFilename(metaOrDir)` | Return the module filename or input string. |
|
|
@@ -26,6 +27,11 @@ Read the [Node.js file system API](https://nodejs.org/api/fs.html) for functions
|
|
|
26
27
|
| `fileUrlToPath` | `fileUrlToPath(fileUrl)` | Convert a file URL string or `URL` to a file path. |
|
|
27
28
|
|
|
28
29
|
Pass `import.meta` or a directory string as `metaOrDir`. Pass `dirnameFn` only with `import.meta`.
|
|
30
|
+
|
|
31
|
+
Call `createPathHelpers()` to use the default logger. Pass `options.logger` to set the logger.
|
|
32
|
+
The helpers write debug records after operations. They write error records before they throw an error.
|
|
33
|
+
The default logger uses the `info` level, so it filters debug records. Set its level to `debug` to receive operation records.
|
|
34
|
+
|
|
29
35
|
The default export from `@eliware/path` is named `path` here.
|
|
30
36
|
Read the [path package docs](https://github.com/eliware/path/tree/main/docs) for details.
|
|
31
37
|
|
|
@@ -116,21 +122,31 @@ Read the [signals API docs](https://github.com/eliware/signals/blob/main/docs/ap
|
|
|
116
122
|
|
|
117
123
|
Call `createSnowflakeGenerator(options?)` to make a generator. Each call returns a decimal string.
|
|
118
124
|
|
|
119
|
-
| Option | Type | Default | Purpose
|
|
120
|
-
| ----------- | -------------------- | ------------------ |
|
|
121
|
-
| `epoch` | `number` or `bigint` | `365662380000n` | Set the epoch in Unix milliseconds.
|
|
122
|
-
| `workerId` | `number` or `bigint` | `0` | Set a worker value from 0 through 31.
|
|
123
|
-
| `processId` | `number` or `bigint` | `process.pid % 32` | Set a process value from 0 through 31.
|
|
124
|
-
| `now` | function | `Date.now` | Set a clock that returns Unix milliseconds.
|
|
125
|
+
| Option | Type | Default | Purpose |
|
|
126
|
+
| ----------- | -------------------- | ------------------ | ------------------------------------------------- |
|
|
127
|
+
| `epoch` | `number` or `bigint` | `365662380000n` | Set the epoch in Unix milliseconds. |
|
|
128
|
+
| `workerId` | `number` or `bigint` | `0` | Set a worker value from 0 through 31. |
|
|
129
|
+
| `processId` | `number` or `bigint` | `process.pid % 32` | Set a process value from 0 through 31. |
|
|
130
|
+
| `now` | function | `Date.now` | Set a clock that returns Unix milliseconds. |
|
|
131
|
+
| `logger` | Winston `Logger` | None | Record generator events with a structured logger. |
|
|
125
132
|
|
|
126
133
|
Use one epoch for all generators in one application. Give each active generator a unique worker and process ID pair.
|
|
127
134
|
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.
|
|
128
135
|
|
|
129
136
|
Each generator can create 4096 IDs for each millisecond. It throws `RangeError` when time or sequence limits fail.
|
|
137
|
+
|
|
130
138
|
Pass a safe integer or `bigint` to `epoch`, `workerId`, and `processId`.
|
|
139
|
+
Set `epoch` from zero through `(1n << 42n) - 1n`. Set `workerId` and `processId` from 0 through 31.
|
|
131
140
|
|
|
132
141
|
Pass a clock that returns Unix milliseconds as a safe integer or `bigint`.
|
|
133
|
-
|
|
142
|
+
Set the first clock value at or after the epoch.
|
|
143
|
+
After the first ID, the generator uses its last timestamp when the clock moves to an earlier time.
|
|
144
|
+
|
|
145
|
+
The generator increments its sequence during a clock rollback. It throws `RangeError` when one generator creates more than 4096 IDs in one millisecond.
|
|
146
|
+
|
|
147
|
+
Pass a logger with `error`, `warn`, `info`, and `debug` methods to record generator events. The generator writes no records when you omit the logger.
|
|
148
|
+
The records do not include generated IDs, credentials, tokens, or error messages.
|
|
149
|
+
|
|
134
150
|
The exports `generate`, `snowflake`, and the default export from `@eliware/snowflake` use one shared generator.
|
|
135
151
|
The `constants` export provides `epoch`, `sequenceBits`, `processBits`, and `workerBits` values as `bigint`.
|
|
136
152
|
|
|
@@ -141,7 +157,7 @@ Read the [Snowflake usage guide](https://github.com/eliware/snowflake/blob/main/
|
|
|
141
157
|
The package exports these types:
|
|
142
158
|
|
|
143
159
|
- `Logger`
|
|
144
|
-
- `
|
|
160
|
+
- `PathLogger`, `PathHelpersOptions`, and `PathHelpers`
|
|
145
161
|
- `NodeSignal`, `SignalsLogger`, and `SignalsProcessLike`
|
|
146
162
|
- `ProcessEvent`, `ProcessListener`, and `ProcessLike`
|
|
147
163
|
- `RegisterHandlersOptions` and `RegisteredHandlers`
|
package/docs/package.md
CHANGED
package/docs/usage.md
CHANGED
|
@@ -86,6 +86,18 @@ const localFile = fileUrlToPath(url);
|
|
|
86
86
|
Pass a directory string when code does not have `import.meta`.
|
|
87
87
|
Read the [API reference](api.md) for each path helper.
|
|
88
88
|
|
|
89
|
+
Use `createPathHelpers` when your app must record path operations with a custom logger.
|
|
90
|
+
|
|
91
|
+
```js
|
|
92
|
+
import { createPathHelpers } from "@eliware/common";
|
|
93
|
+
|
|
94
|
+
const records = [];
|
|
95
|
+
const helpers = createPathHelpers({ logger: { log: (record) => records.push(record) } });
|
|
96
|
+
const file = helpers.path(import.meta, "data", "input.json");
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
The helper writes a debug record after it completes a path operation.
|
|
100
|
+
|
|
89
101
|
## Use logger APIs
|
|
90
102
|
|
|
91
103
|
Use the default `log` object or create a logger with `createLogger(options)`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eliware/common",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "14.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,15 +44,15 @@
|
|
|
44
44
|
"node": ">=26"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@eliware/errors": "^
|
|
48
|
-
"@eliware/log": "^
|
|
49
|
-
"@eliware/path": "^
|
|
50
|
-
"@eliware/redact": "^
|
|
51
|
-
"@eliware/signals": "^
|
|
52
|
-
"@eliware/snowflake": "^
|
|
47
|
+
"@eliware/errors": "^14.0.0",
|
|
48
|
+
"@eliware/log": "^14.0.0",
|
|
49
|
+
"@eliware/path": "^14.0.0",
|
|
50
|
+
"@eliware/redact": "^14.0.0",
|
|
51
|
+
"@eliware/signals": "^14.0.0",
|
|
52
|
+
"@eliware/snowflake": "^14.0.0"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@eliware/test": "^
|
|
55
|
+
"@eliware/test": "^14.0.0",
|
|
56
56
|
"typescript": "^7.0.2"
|
|
57
57
|
},
|
|
58
58
|
"jest": {
|
package/specs/directives.yaml
CHANGED
package/src/errors.d.mts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export type ProcessEvent = "uncaughtException" | "unhandledRejection" | "warning";
|
|
2
|
+
|
|
3
|
+
export declare const defaultEvents: readonly ProcessEvent[];
|
|
4
|
+
|
|
5
|
+
export type ProcessListener = (...args: unknown[]) => void;
|
|
6
|
+
|
|
7
|
+
export interface Logger {
|
|
8
|
+
error(message: string, metadata: unknown): unknown;
|
|
9
|
+
warn(message: string, metadata: unknown): unknown;
|
|
10
|
+
debug(message: string): unknown;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export type ProcessLike = {
|
|
14
|
+
on(event: ProcessEvent, listener: ProcessListener): unknown;
|
|
15
|
+
once?(event: ProcessEvent, listener: ProcessListener): unknown;
|
|
16
|
+
listeners?(event: ProcessEvent): ProcessListener[];
|
|
17
|
+
} & (
|
|
18
|
+
| { off(event: ProcessEvent, listener: ProcessListener): unknown }
|
|
19
|
+
| { removeListener(event: ProcessEvent, listener: ProcessListener): unknown }
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
export interface RegisterHandlersOptions {
|
|
23
|
+
processObj?: ProcessLike;
|
|
24
|
+
log?: Logger;
|
|
25
|
+
events?: ProcessEvent[];
|
|
26
|
+
once?: boolean;
|
|
27
|
+
signal?: AbortSignal;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface RegisteredHandlers {
|
|
31
|
+
readonly removed: boolean;
|
|
32
|
+
removeHandlers(): void;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export declare function registerHandlers(options?: RegisterHandlersOptions): RegisteredHandlers;
|
|
36
|
+
|
|
37
|
+
export default registerHandlers;
|
package/src/index.d.ts
CHANGED
|
@@ -1,27 +1,24 @@
|
|
|
1
1
|
import * as fs from "fs";
|
|
2
2
|
export { fs };
|
|
3
|
-
export { createLogger, default as log, safeSerialize } from "
|
|
4
|
-
export type {
|
|
5
|
-
LoggerWithConfiguredLevels,
|
|
6
|
-
RedactionOptions,
|
|
7
|
-
SafeSerializedValue,
|
|
8
|
-
} from "@eliware/log";
|
|
3
|
+
export { createLogger, default as log, safeSerialize } from "./log.mjs";
|
|
9
4
|
export {
|
|
10
5
|
path,
|
|
6
|
+
createPathHelpers,
|
|
11
7
|
pathUrl,
|
|
12
8
|
getCurrentDirname,
|
|
13
9
|
getCurrentFilename,
|
|
14
10
|
resolvePath,
|
|
15
11
|
relativePath,
|
|
16
12
|
fileUrlToPath,
|
|
17
|
-
} from "
|
|
13
|
+
} from "./path.mjs";
|
|
14
|
+
export type { PathLogger, PathHelpersOptions, PathHelpers } from "./path.mjs";
|
|
18
15
|
export {
|
|
19
16
|
createSnowflakeGenerator,
|
|
20
17
|
generate,
|
|
21
18
|
default as snowflake,
|
|
22
19
|
constants,
|
|
23
|
-
} from "
|
|
24
|
-
export type { SnowflakeGeneratorOptions, SnowflakeConstants } from "
|
|
20
|
+
} from "./snowflake.mjs";
|
|
21
|
+
export type { SnowflakeGeneratorOptions, SnowflakeConstants } from "./snowflake.mjs";
|
|
25
22
|
export {
|
|
26
23
|
createPolicy,
|
|
27
24
|
defaultPolicy,
|
|
@@ -36,8 +33,8 @@ export type {
|
|
|
36
33
|
StructuredRedactionOptions,
|
|
37
34
|
TextRedactionOptions,
|
|
38
35
|
} from "@eliware/redact";
|
|
39
|
-
export { default as registerHandlers } from "
|
|
40
|
-
export { defaultEvents } from "
|
|
36
|
+
export { default as registerHandlers } from "./errors.mjs";
|
|
37
|
+
export { defaultEvents } from "./errors.mjs";
|
|
41
38
|
export { default as registerSignals } from "@eliware/signals";
|
|
42
39
|
export type {
|
|
43
40
|
Logger,
|
|
@@ -46,7 +43,7 @@ export type {
|
|
|
46
43
|
ProcessLike,
|
|
47
44
|
RegisterHandlersOptions,
|
|
48
45
|
RegisteredHandlers,
|
|
49
|
-
} from "
|
|
46
|
+
} from "./errors.mjs";
|
|
50
47
|
export type {
|
|
51
48
|
NodeSignal,
|
|
52
49
|
ProcessLike as SignalsProcessLike,
|
package/src/index.mjs
CHANGED
package/src/log.d.mts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
type SafeSerializedValue =
|
|
2
|
+
null | boolean | number | string | SafeSerializedValue[] | { [key: string]: SafeSerializedValue };
|
|
3
|
+
|
|
4
|
+
export declare function createLogger(options?: {
|
|
5
|
+
level?: string;
|
|
6
|
+
transports?: import("winston-transport")[];
|
|
7
|
+
format?: "text" | "json";
|
|
8
|
+
timestamp?: boolean;
|
|
9
|
+
keys?: string[];
|
|
10
|
+
}): import("winston").Logger & {
|
|
11
|
+
debug(message: unknown, meta?: unknown, ...args: unknown[]): import("winston").Logger;
|
|
12
|
+
info(message: unknown, meta?: unknown, ...args: unknown[]): import("winston").Logger;
|
|
13
|
+
warn(message: unknown, meta?: unknown, ...args: unknown[]): import("winston").Logger;
|
|
14
|
+
error(message: unknown, meta?: unknown, ...args: unknown[]): import("winston").Logger;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export declare function safeSerialize(
|
|
18
|
+
value: unknown,
|
|
19
|
+
options?: import("@eliware/redact").SerializationOptions,
|
|
20
|
+
): SafeSerializedValue;
|
|
21
|
+
|
|
22
|
+
export declare const log: import("winston").Logger & {
|
|
23
|
+
debug(message: unknown, meta?: unknown, ...args: unknown[]): import("winston").Logger;
|
|
24
|
+
info(message: unknown, meta?: unknown, ...args: unknown[]): import("winston").Logger;
|
|
25
|
+
warn(message: unknown, meta?: unknown, ...args: unknown[]): import("winston").Logger;
|
|
26
|
+
error(message: unknown, meta?: unknown, ...args: unknown[]): import("winston").Logger;
|
|
27
|
+
} & { [level: string]: unknown };
|
|
28
|
+
|
|
29
|
+
export default log;
|
package/src/path.d.mts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/** Returns the current filename from import.meta or the supplied directory string. */
|
|
2
|
+
export declare function getCurrentFilename(metaOrDir: ImportMeta | string): string;
|
|
3
|
+
|
|
4
|
+
/** Returns the current directory from import.meta or the supplied directory string. */
|
|
5
|
+
export declare function getCurrentDirname(
|
|
6
|
+
metaOrDir: ImportMeta | string,
|
|
7
|
+
dirnameFn?: (path: string) => string,
|
|
8
|
+
): string;
|
|
9
|
+
|
|
10
|
+
/** Joins the current directory with path segments. */
|
|
11
|
+
export declare const path: (metaOrDir: ImportMeta | string, ...segments: string[]) => string;
|
|
12
|
+
|
|
13
|
+
/** Converts a resolved path to a file URL string. */
|
|
14
|
+
export declare function pathUrl(metaOrDir: ImportMeta | string, ...segments: string[]): string;
|
|
15
|
+
|
|
16
|
+
/** Resolves path segments from the module directory. */
|
|
17
|
+
export declare function resolvePath(metaOrDir: ImportMeta | string, ...segments: string[]): string;
|
|
18
|
+
|
|
19
|
+
/** Returns a path relative to the module directory. */
|
|
20
|
+
export declare function relativePath(metaOrDir: ImportMeta | string, ...segments: string[]): string;
|
|
21
|
+
|
|
22
|
+
/** Converts a file URL string or URL object to a file path. */
|
|
23
|
+
export declare function fileUrlToPath(fileUrl: string | URL): string;
|
|
24
|
+
|
|
25
|
+
/** A logger that accepts structured Winston-style records. */
|
|
26
|
+
export type PathLogger = Pick<import("winston").Logger, "log">;
|
|
27
|
+
|
|
28
|
+
/** Options for path helpers with an injected logger. */
|
|
29
|
+
export interface PathHelpersOptions {
|
|
30
|
+
logger?: PathLogger;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Path helper functions that write structured records to the supplied logger. */
|
|
34
|
+
export interface PathHelpers {
|
|
35
|
+
getCurrentFilename(metaOrDir: ImportMeta | string): string;
|
|
36
|
+
getCurrentDirname(metaOrDir: ImportMeta | string, dirnameFn?: (path: string) => string): string;
|
|
37
|
+
path(metaOrDir: ImportMeta | string, ...segments: string[]): string;
|
|
38
|
+
pathUrl(metaOrDir: ImportMeta | string, ...segments: string[]): string;
|
|
39
|
+
resolvePath(metaOrDir: ImportMeta | string, ...segments: string[]): string;
|
|
40
|
+
relativePath(metaOrDir: ImportMeta | string, ...segments: string[]): string;
|
|
41
|
+
fileUrlToPath(fileUrl: string | URL): string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Creates path helpers that write safe operation records. */
|
|
45
|
+
export declare function createPathHelpers(options?: PathHelpersOptions): PathHelpers;
|
|
46
|
+
|
|
47
|
+
export default path;
|
package/src/path.mjs
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface SnowflakeGeneratorOptions {
|
|
2
|
+
epoch?: number | bigint;
|
|
3
|
+
workerId?: number | bigint;
|
|
4
|
+
processId?: number | bigint;
|
|
5
|
+
now?: () => number | bigint;
|
|
6
|
+
logger?: import("winston").Logger;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface SnowflakeConstants {
|
|
10
|
+
readonly epoch: bigint;
|
|
11
|
+
readonly sequenceBits: bigint;
|
|
12
|
+
readonly processBits: bigint;
|
|
13
|
+
readonly workerBits: bigint;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export declare function createSnowflakeGenerator(options?: SnowflakeGeneratorOptions): () => string;
|
|
17
|
+
|
|
18
|
+
export declare const generate: () => string;
|
|
19
|
+
export declare const snowflake: typeof generate;
|
|
20
|
+
export declare const constants: SnowflakeConstants;
|
|
21
|
+
|
|
22
|
+
export default generate;
|