@plyaz/types 1.9.1 → 1.9.2
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/dist/logger/types.d.ts +46 -0
- package/package.json +2 -1
package/dist/logger/types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type pino from 'pino';
|
|
1
2
|
export interface LoggerInterface {
|
|
2
3
|
debug(message: string, ...supportingDetials: unknown[]): void;
|
|
3
4
|
info(message: string, ...supportingDetials: unknown[]): void;
|
|
@@ -7,3 +8,48 @@ export interface LoggerInterface {
|
|
|
7
8
|
}
|
|
8
9
|
export type LoggerMethodTypes = 'debug' | 'info' | 'warn' | 'error' | 'fatal';
|
|
9
10
|
export type LoggerEnvironment = 'development' | 'production';
|
|
11
|
+
/**
|
|
12
|
+
* Infers the parameter types for a specific logger method from the `pino.Logger` interface.
|
|
13
|
+
*
|
|
14
|
+
* @template T - The logger method name (e.g., `'info'`, `'error'`, `'warn'`, `'debug'`, `'fatal'`, `'trace'`).
|
|
15
|
+
*
|
|
16
|
+
* @description
|
|
17
|
+
* This utility type extracts the argument list of a given logger method dynamically.
|
|
18
|
+
* For example, if `T` is `'info'`, it will return the tuple type of parameters accepted by `pino.info()`.
|
|
19
|
+
*
|
|
20
|
+
* - It leverages TypeScript’s `infer` keyword to capture parameter types.
|
|
21
|
+
* - It returns a tuple type representing those arguments.
|
|
22
|
+
* - It never falls back to `any` or `unknown` — ensuring strict typing.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* type InfoArgs = LoggerFnArgs<'info'>;
|
|
27
|
+
* // => same as Parameters<pino.Logger['info']>
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export type LoggerFnArgs<T extends LoggerMethodTypes> = pino.Logger<'debug' | 'info' | 'warn' | 'error' | 'fatal' | 'trace', boolean>[T] extends (...args: infer A) => void ? A : never;
|
|
31
|
+
/**
|
|
32
|
+
* Defines the structure of the Logger React Context.
|
|
33
|
+
*
|
|
34
|
+
* @description
|
|
35
|
+
* Provides a generic, strongly-typed logging function that mirrors `pino`’s
|
|
36
|
+
* available log methods (`debug`, `info`, `warn`, `error`, `fatal`, `trace`).
|
|
37
|
+
*
|
|
38
|
+
* This ensures that:
|
|
39
|
+
* - Each log method infers the correct argument types.
|
|
40
|
+
* - No `any` or `unknown` is used anywhere in the type definitions.
|
|
41
|
+
*
|
|
42
|
+
* @template T - The specific log level method name.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* const context: LoggerContextType = {
|
|
47
|
+
* log: (level, ...args) => {
|
|
48
|
+
* // example usage: log('info', 'User created', { id: 123 });
|
|
49
|
+
* },
|
|
50
|
+
* };
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export type LoggerContextType = {
|
|
54
|
+
log: <T extends LoggerMethodTypes>(level: T, ...args: LoggerFnArgs<T>) => void;
|
|
55
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plyaz/types",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.2",
|
|
4
4
|
"author": "Redeemer Pace",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"description": "Provides shared TypeScript types and schema utilities for validation and parsing in the @playz ecosystem.",
|
|
@@ -172,6 +172,7 @@
|
|
|
172
172
|
"keywords": [],
|
|
173
173
|
"packageManager": "pnpm@10.11.0",
|
|
174
174
|
"dependencies": {
|
|
175
|
+
"pino": "^10.0.0",
|
|
175
176
|
"type-fest": "^4.41.0"
|
|
176
177
|
},
|
|
177
178
|
"devDependencies": {
|