WIP: bootstrap and partial real Solana watcher implementation
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -0,0 +1,66 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const util_1 = require("../util");
|
||||
exports.default = (0, util_1.createRule)({
|
||||
name: 'no-this-alias',
|
||||
meta: {
|
||||
type: 'suggestion',
|
||||
docs: {
|
||||
description: 'Disallow aliasing `this`',
|
||||
recommended: 'recommended',
|
||||
},
|
||||
messages: {
|
||||
thisAssignment: "Unexpected aliasing of 'this' to local variable.",
|
||||
thisDestructure: "Unexpected aliasing of members of 'this' to local variables.",
|
||||
},
|
||||
schema: [
|
||||
{
|
||||
type: 'object',
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
allowDestructuring: {
|
||||
type: 'boolean',
|
||||
description: 'Whether to ignore destructuring, such as `const { props, state } = this`.',
|
||||
},
|
||||
allowedNames: {
|
||||
type: 'array',
|
||||
description: 'Names to ignore, such as ["self"] for `const self = this;`.',
|
||||
items: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
defaultOptions: [
|
||||
{
|
||||
allowDestructuring: true,
|
||||
allowedNames: [],
|
||||
},
|
||||
],
|
||||
create(context, [{ allowDestructuring, allowedNames }]) {
|
||||
return {
|
||||
"VariableDeclarator[init.type='ThisExpression'], AssignmentExpression[right.type='ThisExpression']"(node) {
|
||||
const id = node.type === utils_1.AST_NODE_TYPES.VariableDeclarator ? node.id : node.left;
|
||||
if (allowDestructuring && id.type !== utils_1.AST_NODE_TYPES.Identifier) {
|
||||
return;
|
||||
}
|
||||
const hasAllowedName = id.type === utils_1.AST_NODE_TYPES.Identifier
|
||||
? // https://github.com/typescript-eslint/typescript-eslint/issues/5439
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
allowedNames.includes(id.name)
|
||||
: false;
|
||||
if (!hasAllowedName) {
|
||||
context.report({
|
||||
node: id,
|
||||
messageId: id.type === utils_1.AST_NODE_TYPES.Identifier
|
||||
? 'thisAssignment'
|
||||
: 'thisDestructure',
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,158 @@
|
||||
declare module 'readline' {
|
||||
import EventEmitter = require('events');
|
||||
|
||||
interface Key {
|
||||
sequence?: string | undefined;
|
||||
name?: string | undefined;
|
||||
ctrl?: boolean | undefined;
|
||||
meta?: boolean | undefined;
|
||||
shift?: boolean | undefined;
|
||||
}
|
||||
|
||||
class Interface extends EventEmitter {
|
||||
readonly terminal: boolean;
|
||||
|
||||
// Need direct access to line/cursor data, for use in external processes
|
||||
// see: https://github.com/nodejs/node/issues/30347
|
||||
/** The current input data */
|
||||
readonly line: string;
|
||||
/** The current cursor position in the input line */
|
||||
readonly cursor: number;
|
||||
|
||||
/**
|
||||
* NOTE: According to the documentation:
|
||||
*
|
||||
* > Instances of the `readline.Interface` class are constructed using the
|
||||
* > `readline.createInterface()` method.
|
||||
*
|
||||
* @see https://nodejs.org/dist/latest-v10.x/docs/api/readline.html#readline_class_interface
|
||||
*/
|
||||
protected constructor(input: NodeJS.ReadableStream, output?: NodeJS.WritableStream, completer?: Completer | AsyncCompleter, terminal?: boolean);
|
||||
/**
|
||||
* NOTE: According to the documentation:
|
||||
*
|
||||
* > Instances of the `readline.Interface` class are constructed using the
|
||||
* > `readline.createInterface()` method.
|
||||
*
|
||||
* @see https://nodejs.org/dist/latest-v10.x/docs/api/readline.html#readline_class_interface
|
||||
*/
|
||||
protected constructor(options: ReadLineOptions);
|
||||
|
||||
setPrompt(prompt: string): void;
|
||||
prompt(preserveCursor?: boolean): void;
|
||||
question(query: string, callback: (answer: string) => void): void;
|
||||
pause(): this;
|
||||
resume(): this;
|
||||
close(): void;
|
||||
write(data: string | Buffer, key?: Key): void;
|
||||
write(data: undefined | null | string | Buffer, key: Key): void;
|
||||
|
||||
/**
|
||||
* events.EventEmitter
|
||||
* 1. close
|
||||
* 2. line
|
||||
* 3. pause
|
||||
* 4. resume
|
||||
* 5. SIGCONT
|
||||
* 6. SIGINT
|
||||
* 7. SIGTSTP
|
||||
*/
|
||||
|
||||
addListener(event: string, listener: (...args: any[]) => void): this;
|
||||
addListener(event: "close", listener: () => void): this;
|
||||
addListener(event: "line", listener: (input: string) => void): this;
|
||||
addListener(event: "pause", listener: () => void): this;
|
||||
addListener(event: "resume", listener: () => void): this;
|
||||
addListener(event: "SIGCONT", listener: () => void): this;
|
||||
addListener(event: "SIGINT", listener: () => void): this;
|
||||
addListener(event: "SIGTSTP", listener: () => void): this;
|
||||
|
||||
emit(event: string | symbol, ...args: any[]): boolean;
|
||||
emit(event: "close"): boolean;
|
||||
emit(event: "line", input: string): boolean;
|
||||
emit(event: "pause"): boolean;
|
||||
emit(event: "resume"): boolean;
|
||||
emit(event: "SIGCONT"): boolean;
|
||||
emit(event: "SIGINT"): boolean;
|
||||
emit(event: "SIGTSTP"): boolean;
|
||||
|
||||
on(event: string, listener: (...args: any[]) => void): this;
|
||||
on(event: "close", listener: () => void): this;
|
||||
on(event: "line", listener: (input: string) => void): this;
|
||||
on(event: "pause", listener: () => void): this;
|
||||
on(event: "resume", listener: () => void): this;
|
||||
on(event: "SIGCONT", listener: () => void): this;
|
||||
on(event: "SIGINT", listener: () => void): this;
|
||||
on(event: "SIGTSTP", listener: () => void): this;
|
||||
|
||||
once(event: string, listener: (...args: any[]) => void): this;
|
||||
once(event: "close", listener: () => void): this;
|
||||
once(event: "line", listener: (input: string) => void): this;
|
||||
once(event: "pause", listener: () => void): this;
|
||||
once(event: "resume", listener: () => void): this;
|
||||
once(event: "SIGCONT", listener: () => void): this;
|
||||
once(event: "SIGINT", listener: () => void): this;
|
||||
once(event: "SIGTSTP", listener: () => void): this;
|
||||
|
||||
prependListener(event: string, listener: (...args: any[]) => void): this;
|
||||
prependListener(event: "close", listener: () => void): this;
|
||||
prependListener(event: "line", listener: (input: string) => void): this;
|
||||
prependListener(event: "pause", listener: () => void): this;
|
||||
prependListener(event: "resume", listener: () => void): this;
|
||||
prependListener(event: "SIGCONT", listener: () => void): this;
|
||||
prependListener(event: "SIGINT", listener: () => void): this;
|
||||
prependListener(event: "SIGTSTP", listener: () => void): this;
|
||||
|
||||
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
||||
prependOnceListener(event: "close", listener: () => void): this;
|
||||
prependOnceListener(event: "line", listener: (input: string) => void): this;
|
||||
prependOnceListener(event: "pause", listener: () => void): this;
|
||||
prependOnceListener(event: "resume", listener: () => void): this;
|
||||
prependOnceListener(event: "SIGCONT", listener: () => void): this;
|
||||
prependOnceListener(event: "SIGINT", listener: () => void): this;
|
||||
prependOnceListener(event: "SIGTSTP", listener: () => void): this;
|
||||
[Symbol.asyncIterator](): AsyncIterableIterator<string>;
|
||||
}
|
||||
|
||||
type ReadLine = Interface; // type forwarded for backwards compatiblity
|
||||
|
||||
type Completer = (line: string) => CompleterResult;
|
||||
type AsyncCompleter = (line: string, callback: (err?: null | Error, result?: CompleterResult) => void) => any;
|
||||
|
||||
type CompleterResult = [string[], string];
|
||||
|
||||
interface ReadLineOptions {
|
||||
input: NodeJS.ReadableStream;
|
||||
output?: NodeJS.WritableStream | undefined;
|
||||
completer?: Completer | AsyncCompleter | undefined;
|
||||
terminal?: boolean | undefined;
|
||||
historySize?: number | undefined;
|
||||
prompt?: string | undefined;
|
||||
crlfDelay?: number | undefined;
|
||||
removeHistoryDuplicates?: boolean | undefined;
|
||||
escapeCodeTimeout?: number | undefined;
|
||||
}
|
||||
|
||||
function createInterface(input: NodeJS.ReadableStream, output?: NodeJS.WritableStream, completer?: Completer | AsyncCompleter, terminal?: boolean): Interface;
|
||||
function createInterface(options: ReadLineOptions): Interface;
|
||||
function emitKeypressEvents(stream: NodeJS.ReadableStream, readlineInterface?: Interface): void;
|
||||
|
||||
type Direction = -1 | 0 | 1;
|
||||
|
||||
/**
|
||||
* Clears the current line of this WriteStream in a direction identified by `dir`.
|
||||
*/
|
||||
function clearLine(stream: NodeJS.WritableStream, dir: Direction, callback?: () => void): boolean;
|
||||
/**
|
||||
* Clears this `WriteStream` from the current cursor down.
|
||||
*/
|
||||
function clearScreenDown(stream: NodeJS.WritableStream, callback?: () => void): boolean;
|
||||
/**
|
||||
* Moves this WriteStream's cursor to the specified position.
|
||||
*/
|
||||
function cursorTo(stream: NodeJS.WritableStream, x: number, y?: number, callback?: () => void): boolean;
|
||||
/**
|
||||
* Moves this WriteStream's cursor relative to its current position.
|
||||
*/
|
||||
function moveCursor(stream: NodeJS.WritableStream, dx: number, dy: number, callback?: () => void): boolean;
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
{
|
||||
"name": "pg-connection-string",
|
||||
"version": "2.14.0",
|
||||
"description": "Functions for dealing with a PostgreSQL connection string",
|
||||
"main": "./index.js",
|
||||
"types": "./index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./index.d.ts",
|
||||
"import": "./esm/index.mjs",
|
||||
"require": "./index.js",
|
||||
"default": "./index.js"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"test": "nyc --reporter=lcov mocha && npm run check-coverage",
|
||||
"check-coverage": "nyc check-coverage --statements 100 --branches 100 --lines 100 --functions 100"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/brianc/node-postgres.git",
|
||||
"directory": "packages/pg-connection-string"
|
||||
},
|
||||
"keywords": [
|
||||
"pg",
|
||||
"connection",
|
||||
"string",
|
||||
"parse"
|
||||
],
|
||||
"author": "Blaine Bublitz <blaine@iceddev.com> (http://iceddev.com/)",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/brianc/node-postgres/issues"
|
||||
},
|
||||
"homepage": "https://github.com/brianc/node-postgres/tree/master/packages/pg-connection-string",
|
||||
"devDependencies": {
|
||||
"@types/pg": "^8.12.0",
|
||||
"chai": "^4.1.1",
|
||||
"coveralls": "^3.0.4",
|
||||
"istanbul": "^0.4.5",
|
||||
"mocha": "^11.7.5",
|
||||
"nyc": "^15",
|
||||
"tsx": "^4.19.4",
|
||||
"typescript": "^6.0.3"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts",
|
||||
"esm"
|
||||
],
|
||||
"gitHead": "b617619f9fb6fbd231731823e2732a2927ded4be"
|
||||
}
|
||||
@@ -0,0 +1,908 @@
|
||||
// Project: https://github.com/pinojs/pino.git, http://getpino.io
|
||||
// Definitions by: Peter Snider <https://github.com/psnider>
|
||||
// BendingBender <https://github.com/BendingBender>
|
||||
// Christian Rackerseder <https://github.com/screendriver>
|
||||
// GP <https://github.com/paambaati>
|
||||
// Alex Ferrando <https://github.com/alferpal>
|
||||
// Oleksandr Sidko <https://github.com/mortiy>
|
||||
// Harris Lummis <https://github.com/lummish>
|
||||
// Raoul Jaeckel <https://github.com/raoulus>
|
||||
// Cory Donkin <https://github.com/Cooryd>
|
||||
// Adam Vigneaux <https://github.com/AdamVig>
|
||||
// Austin Beer <https://github.com/austin-beer>
|
||||
// Michel Nemnom <https://github.com/Pegase745>
|
||||
// Igor Savin <https://github.com/kibertoad>
|
||||
// James Bromwell <https://github.com/thw0rted>
|
||||
|
||||
import type { EventEmitter } from "events";
|
||||
import * as pinoStdSerializers from "pino-std-serializers";
|
||||
import type { SonicBoom, SonicBoomOpts } from "sonic-boom";
|
||||
import ThreadStream from "thread-stream";
|
||||
import type { WorkerOptions } from "worker_threads";
|
||||
|
||||
declare namespace pino {
|
||||
//// Non-exported types and interfaces
|
||||
|
||||
type TimeFn = () => string;
|
||||
type MixinFn<CustomLevels extends string = never> = (mergeObject: object, level: number, logger:Logger<CustomLevels>) => object;
|
||||
type MixinMergeStrategyFn = (mergeObject: object, mixinObject: object) => object;
|
||||
|
||||
type CustomLevelLogger<CustomLevels extends string, UseOnlyCustomLevels extends boolean = boolean> = {
|
||||
/**
|
||||
* Define additional logging levels.
|
||||
*/
|
||||
customLevels: { [level in CustomLevels]: number };
|
||||
/**
|
||||
* Use only defined `customLevels` and omit Pino's levels.
|
||||
*/
|
||||
useOnlyCustomLevels: UseOnlyCustomLevels;
|
||||
} & {
|
||||
// This will override default log methods
|
||||
[K in Exclude<Level, CustomLevels>]: UseOnlyCustomLevels extends true ? never : LogFn;
|
||||
} & {
|
||||
[level in CustomLevels]: LogFn;
|
||||
};
|
||||
|
||||
/**
|
||||
* A synchronous callback that will run on each creation of a new child.
|
||||
* @param child: The newly created child logger instance.
|
||||
*/
|
||||
type OnChildCallback<CustomLevels extends string = never> = (child: Logger<CustomLevels>) => void
|
||||
|
||||
export interface redactOptions {
|
||||
paths: string[];
|
||||
censor?: string | ((value: unknown, path: string[]) => unknown);
|
||||
remove?: boolean;
|
||||
}
|
||||
|
||||
export interface LoggerExtras<CustomLevels extends string = never, UseOnlyCustomLevels extends boolean = boolean> extends EventEmitter {
|
||||
/**
|
||||
* Exposes the Pino package version. Also available on the exported pino function.
|
||||
*/
|
||||
readonly version: string;
|
||||
|
||||
levels: LevelMapping;
|
||||
|
||||
/**
|
||||
* Outputs the level as a string instead of integer.
|
||||
*/
|
||||
useLevelLabels: boolean;
|
||||
/**
|
||||
* Returns the integer value for the logger instance's logging level.
|
||||
*/
|
||||
levelVal: number;
|
||||
|
||||
/**
|
||||
* Creates a child logger, setting all key-value pairs in `bindings` as properties in the log lines. All serializers will be applied to the given pair.
|
||||
* Child loggers use the same output stream as the parent and inherit the current log level of the parent at the time they are spawned.
|
||||
* From v2.x.x the log level of a child is mutable (whereas in v1.x.x it was immutable), and can be set independently of the parent.
|
||||
* If a `level` property is present in the object passed to `child` it will override the child logger level.
|
||||
*
|
||||
* @param bindings: an object of key-value pairs to include in log lines as properties.
|
||||
* @param options: an options object that will override child logger inherited options.
|
||||
* @returns a child logger instance.
|
||||
*/
|
||||
child<ChildCustomLevels extends string = never>(bindings: Bindings, options?: ChildLoggerOptions<ChildCustomLevels>): Logger<CustomLevels | ChildCustomLevels>;
|
||||
|
||||
/**
|
||||
* This can be used to modify the callback function on creation of a new child.
|
||||
*/
|
||||
onChild: OnChildCallback<CustomLevels>;
|
||||
|
||||
/**
|
||||
* Registers a listener function that is triggered when the level is changed.
|
||||
* Note: When browserified, this functionality will only be available if the `events` module has been required elsewhere
|
||||
* (e.g. if you're using streams in the browser). This allows for a trade-off between bundle size and functionality.
|
||||
*
|
||||
* @param event: only ever fires the `'level-change'` event
|
||||
* @param listener: The listener is passed four arguments: `levelLabel`, `levelValue`, `previousLevelLabel`, `previousLevelValue`.
|
||||
*/
|
||||
on(event: "level-change", listener: LevelChangeEventListener<CustomLevels, UseOnlyCustomLevels>): this;
|
||||
addListener(event: "level-change", listener: LevelChangeEventListener<CustomLevels, UseOnlyCustomLevels>): this;
|
||||
once(event: "level-change", listener: LevelChangeEventListener<CustomLevels, UseOnlyCustomLevels>): this;
|
||||
prependListener(event: "level-change", listener: LevelChangeEventListener<CustomLevels, UseOnlyCustomLevels>): this;
|
||||
prependOnceListener(event: "level-change", listener: LevelChangeEventListener<CustomLevels, UseOnlyCustomLevels>): this;
|
||||
removeListener(event: "level-change", listener: LevelChangeEventListener<CustomLevels, UseOnlyCustomLevels>): this;
|
||||
|
||||
/**
|
||||
* A utility method for determining if a given log level will write to the destination.
|
||||
*/
|
||||
isLevelEnabled(level: LevelWithSilentOrString): boolean;
|
||||
|
||||
/**
|
||||
* Returns an object containing all the current bindings, cloned from the ones passed in via logger.child().
|
||||
*/
|
||||
bindings(): Bindings;
|
||||
|
||||
/**
|
||||
* Adds to the bindings of this logger instance.
|
||||
* Note: Does not overwrite bindings. Can potentially result in duplicate keys in log lines.
|
||||
*
|
||||
* @param bindings: an object of key-value pairs to include in log lines as properties.
|
||||
*/
|
||||
setBindings(bindings: Bindings): void;
|
||||
|
||||
/**
|
||||
* Flushes the content of the buffer when using pino.destination({ sync: false }).
|
||||
* call the callback when finished
|
||||
*/
|
||||
flush(cb?: (err?: Error) => void): void;
|
||||
}
|
||||
|
||||
//// Exported types and interfaces
|
||||
export interface BaseLogger {
|
||||
/**
|
||||
* Set this property to the desired logging level. In order of priority, available levels are:
|
||||
*
|
||||
* - 'fatal'
|
||||
* - 'error'
|
||||
* - 'warn'
|
||||
* - 'info'
|
||||
* - 'debug'
|
||||
* - 'trace'
|
||||
*
|
||||
* The logging level is a __minimum__ level. For instance if `logger.level` is `'info'` then all `'fatal'`, `'error'`, `'warn'`,
|
||||
* and `'info'` logs will be enabled.
|
||||
*
|
||||
* You can pass `'silent'` to disable logging.
|
||||
*/
|
||||
level: LevelWithSilentOrString;
|
||||
|
||||
/**
|
||||
* Log at `'fatal'` level the given msg. If the first argument is an object, all its properties will be included in the JSON line.
|
||||
* If more args follows `msg`, these will be used to format `msg` using `util.format`.
|
||||
*
|
||||
* @typeParam T: the interface of the object being serialized. Default is object.
|
||||
* @param obj: object to be serialized
|
||||
* @param msg: the log message to write
|
||||
* @param ...args: format string values when `msg` is a format string
|
||||
*/
|
||||
fatal: LogFn;
|
||||
/**
|
||||
* Log at `'error'` level the given msg. If the first argument is an object, all its properties will be included in the JSON line.
|
||||
* If more args follows `msg`, these will be used to format `msg` using `util.format`.
|
||||
*
|
||||
* @typeParam T: the interface of the object being serialized. Default is object.
|
||||
* @param obj: object to be serialized
|
||||
* @param msg: the log message to write
|
||||
* @param ...args: format string values when `msg` is a format string
|
||||
*/
|
||||
error: LogFn;
|
||||
/**
|
||||
* Log at `'warn'` level the given msg. If the first argument is an object, all its properties will be included in the JSON line.
|
||||
* If more args follows `msg`, these will be used to format `msg` using `util.format`.
|
||||
*
|
||||
* @typeParam T: the interface of the object being serialized. Default is object.
|
||||
* @param obj: object to be serialized
|
||||
* @param msg: the log message to write
|
||||
* @param ...args: format string values when `msg` is a format string
|
||||
*/
|
||||
warn: LogFn;
|
||||
/**
|
||||
* Log at `'info'` level the given msg. If the first argument is an object, all its properties will be included in the JSON line.
|
||||
* If more args follows `msg`, these will be used to format `msg` using `util.format`.
|
||||
*
|
||||
* @typeParam T: the interface of the object being serialized. Default is object.
|
||||
* @param obj: object to be serialized
|
||||
* @param msg: the log message to write
|
||||
* @param ...args: format string values when `msg` is a format string
|
||||
*/
|
||||
info: LogFn;
|
||||
/**
|
||||
* Log at `'debug'` level the given msg. If the first argument is an object, all its properties will be included in the JSON line.
|
||||
* If more args follows `msg`, these will be used to format `msg` using `util.format`.
|
||||
*
|
||||
* @typeParam T: the interface of the object being serialized. Default is object.
|
||||
* @param obj: object to be serialized
|
||||
* @param msg: the log message to write
|
||||
* @param ...args: format string values when `msg` is a format string
|
||||
*/
|
||||
debug: LogFn;
|
||||
/**
|
||||
* Log at `'trace'` level the given msg. If the first argument is an object, all its properties will be included in the JSON line.
|
||||
* If more args follows `msg`, these will be used to format `msg` using `util.format`.
|
||||
*
|
||||
* @typeParam T: the interface of the object being serialized. Default is object.
|
||||
* @param obj: object to be serialized
|
||||
* @param msg: the log message to write
|
||||
* @param ...args: format string values when `msg` is a format string
|
||||
*/
|
||||
trace: LogFn;
|
||||
/**
|
||||
* Noop function.
|
||||
*/
|
||||
silent: LogFn;
|
||||
|
||||
/**
|
||||
* Get `msgPrefix` of the logger instance.
|
||||
*
|
||||
* See {@link https://github.com/pinojs/pino/blob/main/docs/api.md#msgprefix-string}.
|
||||
*/
|
||||
get msgPrefix(): string | undefined;
|
||||
}
|
||||
|
||||
export type Bindings = Record<string, any>;
|
||||
|
||||
export type Level = "fatal" | "error" | "warn" | "info" | "debug" | "trace";
|
||||
export type LevelOrString = Level | (string & {});
|
||||
export type LevelWithSilent = Level | "silent";
|
||||
export type LevelWithSilentOrString = LevelWithSilent | (string & {});
|
||||
|
||||
export type SerializerFn = (value: any) => any;
|
||||
export type WriteFn = (o: object) => void;
|
||||
|
||||
export type LevelChangeEventListener<CustomLevels extends string = never, UseOnlyCustomLevels extends boolean = boolean> = (
|
||||
lvl: LevelWithSilentOrString,
|
||||
val: number,
|
||||
prevLvl: LevelWithSilentOrString,
|
||||
prevVal: number,
|
||||
logger: Logger<CustomLevels, UseOnlyCustomLevels>
|
||||
) => void;
|
||||
|
||||
export type LogDescriptor = Record<string, any>;
|
||||
|
||||
export type Logger<CustomLevels extends string = never, UseOnlyCustomLevels extends boolean = boolean> = BaseLogger & LoggerExtras<CustomLevels> & CustomLevelLogger<CustomLevels, UseOnlyCustomLevels>;
|
||||
|
||||
export type SerializedError = pinoStdSerializers.SerializedError;
|
||||
export type SerializedResponse = pinoStdSerializers.SerializedResponse;
|
||||
export type SerializedRequest = pinoStdSerializers.SerializedRequest;
|
||||
|
||||
|
||||
export interface TransportTargetOptions<TransportOptions = Record<string, any>> {
|
||||
target: string
|
||||
options?: TransportOptions
|
||||
level?: LevelWithSilentOrString
|
||||
}
|
||||
|
||||
export interface TransportBaseOptions<TransportOptions = Record<string, any>> {
|
||||
options?: TransportOptions
|
||||
worker?: WorkerOptions & { autoEnd?: boolean}
|
||||
}
|
||||
|
||||
export interface TransportSingleOptions<TransportOptions = Record<string, any>> extends TransportBaseOptions<TransportOptions>{
|
||||
target: string
|
||||
}
|
||||
|
||||
export interface TransportPipelineOptions<TransportOptions = Record<string, any>> extends TransportBaseOptions<TransportOptions>{
|
||||
pipeline: TransportSingleOptions<TransportOptions>[]
|
||||
level?: LevelWithSilentOrString
|
||||
}
|
||||
|
||||
export interface TransportMultiOptions<TransportOptions = Record<string, any>> extends TransportBaseOptions<TransportOptions>{
|
||||
targets: readonly (TransportTargetOptions<TransportOptions>|TransportPipelineOptions<TransportOptions>)[],
|
||||
levels?: Record<string, number>
|
||||
dedupe?: boolean
|
||||
}
|
||||
|
||||
export interface MultiStreamOptions {
|
||||
levels?: Record<string, number>
|
||||
dedupe?: boolean
|
||||
}
|
||||
|
||||
export interface DestinationStream {
|
||||
write(msg: string): void;
|
||||
}
|
||||
|
||||
interface DestinationStreamHasMetadata {
|
||||
[symbols.needsMetadataGsym]: true;
|
||||
lastLevel: number;
|
||||
lastTime: string;
|
||||
lastMsg: string;
|
||||
lastObj: object;
|
||||
lastLogger: Logger;
|
||||
}
|
||||
|
||||
export type DestinationStreamWithMetadata = DestinationStream & ({ [symbols.needsMetadataGsym]?: false } | DestinationStreamHasMetadata);
|
||||
|
||||
export interface StreamEntry<TLevel = Level> {
|
||||
stream: DestinationStream
|
||||
level?: TLevel
|
||||
}
|
||||
|
||||
export interface MultiStreamRes<TOriginLevel = Level> {
|
||||
write: (data: any) => void,
|
||||
add: <TLevel = Level>(dest: StreamEntry<TLevel> | DestinationStream) => MultiStreamRes<TOriginLevel & TLevel>,
|
||||
flushSync: () => void,
|
||||
minLevel: number,
|
||||
streams: StreamEntry<TOriginLevel>[],
|
||||
clone<const TLevel = Level>(level: TLevel): MultiStreamRes<TLevel>,
|
||||
}
|
||||
|
||||
export interface LevelMapping {
|
||||
/**
|
||||
* Returns the mappings of level names to their respective internal number representation.
|
||||
*/
|
||||
values: { [level: string]: number };
|
||||
/**
|
||||
* Returns the mappings of level internal level numbers to their string representations.
|
||||
*/
|
||||
labels: { [level: number]: string };
|
||||
}
|
||||
|
||||
type PlaceholderSpecifier = 'd' | 's' | 'j' | 'o' | 'O';
|
||||
type PlaceholderTypeMapping<T extends PlaceholderSpecifier> = T extends 'd'
|
||||
? number
|
||||
: T extends 's'
|
||||
? unknown
|
||||
: T extends 'j' | 'o' | 'O'
|
||||
? {} | null
|
||||
: never;
|
||||
|
||||
type ParseLogFnArgs<
|
||||
T,
|
||||
Acc extends unknown[] = [],
|
||||
> = T extends `${infer _}%${infer Placeholder}${infer Rest}`
|
||||
? Placeholder extends PlaceholderSpecifier
|
||||
? ParseLogFnArgs<Rest, [...Acc, PlaceholderTypeMapping<Placeholder>]>
|
||||
: ParseLogFnArgs<Rest, Acc>
|
||||
: Acc;
|
||||
|
||||
export interface LogFnFields {}
|
||||
|
||||
export interface LogFn {
|
||||
// Simple case: When first argument is always a string message, use parsed arguments directly
|
||||
<TMsg extends string = string>(msg: TMsg, ...args: ParseLogFnArgs<TMsg>): void;
|
||||
// Complex case: When first argument can be any type - if it's a string, no message needed; otherwise require a message
|
||||
<T, TMsg extends string = string>(obj: [T] extends [object] ? T & LogFnFields : T, msg?: T extends string ? never: TMsg, ...args: ParseLogFnArgs<TMsg> | []): void;
|
||||
// Complex case with type safety: Same as above but ensures ParseLogFnArgs is a valid tuple before using it
|
||||
<T, TMsg extends string = string>(obj: [T] extends [object] ? T & LogFnFields : T, msg?: T extends string ? never : TMsg, ...args: ParseLogFnArgs<TMsg> extends [unknown, ...unknown[]] ? ParseLogFnArgs<TMsg> : unknown[]): void;
|
||||
}
|
||||
|
||||
export interface LoggerOptions<CustomLevels extends string = never, UseOnlyCustomLevels extends boolean = boolean> {
|
||||
transport?: TransportSingleOptions | TransportMultiOptions | TransportPipelineOptions
|
||||
/**
|
||||
* Avoid error causes by circular references in the object tree. Default: `true`.
|
||||
*/
|
||||
safe?: boolean;
|
||||
/**
|
||||
* The name of the logger. Default: `undefined`.
|
||||
*/
|
||||
name?: string;
|
||||
/**
|
||||
* an object containing functions for custom serialization of objects.
|
||||
* These functions should return an JSONifiable object and they should never throw. When logging an object,
|
||||
* each top-level property matching the exact key of a serializer will be serialized using the defined serializer.
|
||||
*/
|
||||
serializers?: { [key: string]: SerializerFn };
|
||||
/**
|
||||
* Enables or disables the inclusion of a timestamp in the log message. If a function is supplied, it must
|
||||
* synchronously return a JSON string representation of the time. If set to `false`, no timestamp will be included in the output.
|
||||
* See stdTimeFunctions for a set of available functions for passing in as a value for this option.
|
||||
* Caution: any sort of formatted time will significantly slow down Pino's performance.
|
||||
*/
|
||||
timestamp?: TimeFn | boolean;
|
||||
/**
|
||||
* One of the supported levels or `silent` to disable logging. Any other value defines a custom level and
|
||||
* requires supplying a level value via `levelVal`. Default: 'info'.
|
||||
*/
|
||||
level?: LevelWithSilentOrString;
|
||||
|
||||
/**
|
||||
* Use this option to define additional logging levels.
|
||||
* The keys of the object correspond the namespace of the log level, and the values should be the numerical value of the level.
|
||||
*/
|
||||
customLevels?: { [level in CustomLevels]: number };
|
||||
|
||||
/**
|
||||
* Use this option to only use defined `customLevels` and omit Pino's levels.
|
||||
* Logger's default `level` must be changed to a value in `customLevels` in order to use `useOnlyCustomLevels`
|
||||
* Warning: this option may not be supported by downstream transports.
|
||||
*/
|
||||
useOnlyCustomLevels?: UseOnlyCustomLevels;
|
||||
|
||||
/**
|
||||
* Use this option to define custom comparison of log levels.
|
||||
* Useful to compare custom log levels or non-standard level values.
|
||||
* Default: "ASC"
|
||||
*/
|
||||
levelComparison?: "ASC" | "DESC" | ((current: number, expected: number) => boolean);
|
||||
|
||||
/**
|
||||
* If provided, the `mixin` function is called each time one of the active logging methods
|
||||
* is called. The function must synchronously return an object. The properties of the
|
||||
* returned object will be added to the logged JSON.
|
||||
*/
|
||||
mixin?: MixinFn<CustomLevels>;
|
||||
|
||||
/**
|
||||
* If provided, the `mixinMergeStrategy` function is called each time one of the active
|
||||
* logging methods is called. The first parameter is the value `mergeObject` or an empty object,
|
||||
* the second parameter is the value resulting from `mixin()` or an empty object.
|
||||
* The function must synchronously return an object.
|
||||
*/
|
||||
mixinMergeStrategy?: MixinMergeStrategyFn
|
||||
|
||||
/**
|
||||
* As an array, the redact option specifies paths that should have their values redacted from any log output.
|
||||
*
|
||||
* Each path must be a string using a syntax which corresponds to JavaScript dot and bracket notation.
|
||||
*
|
||||
* If an object is supplied, three options can be specified:
|
||||
*
|
||||
* paths (String[]): Required. An array of paths
|
||||
* censor (String): Optional. A value to overwrite key which are to be redacted. Default: '[Redacted]'
|
||||
* remove (Boolean): Optional. Instead of censoring the value, remove both the key and the value. Default: false
|
||||
*/
|
||||
redact?: string[] | redactOptions;
|
||||
|
||||
/**
|
||||
* When defining a custom log level via level, set to an integer value to define the new level. Default: `undefined`.
|
||||
*/
|
||||
levelVal?: number;
|
||||
/**
|
||||
* The string key for the 'message' in the JSON object. Default: "msg".
|
||||
*/
|
||||
messageKey?: string;
|
||||
/**
|
||||
* The string key for the 'error' in the JSON object. Default: "err".
|
||||
*/
|
||||
errorKey?: string;
|
||||
/**
|
||||
* The string key to place any logged object under.
|
||||
*/
|
||||
nestedKey?: string;
|
||||
/**
|
||||
* Enables logging. Default: `true`.
|
||||
*/
|
||||
enabled?: boolean;
|
||||
/**
|
||||
* Browser only, see http://getpino.io/#/docs/browser.
|
||||
*/
|
||||
browser?: {
|
||||
/**
|
||||
* The `asObject` option will create a pino-like log object instead of passing all arguments to a console
|
||||
* method. When `write` is set, `asObject` will always be true.
|
||||
*
|
||||
* @example
|
||||
* pino.info('hi') // creates and logs {msg: 'hi', level: 30, time: <ts>}
|
||||
*/
|
||||
asObject?: boolean;
|
||||
/**
|
||||
* The `asObjectBindingsOnly` option is similar to `asObject` but will keep the message and arguments
|
||||
* unformatted. This allows to defer formatting the message to the actual call to `console` methods,
|
||||
* where browsers then have richer formatting in their devtools than when pino will format the message to
|
||||
* a string first.
|
||||
*
|
||||
* @example
|
||||
* pino.info('hello %s', 'world') // creates and logs {level: 30, time: <ts>}, 'hello %s', 'world'
|
||||
*/
|
||||
asObjectBindingsOnly?: boolean;
|
||||
formatters?: {
|
||||
/**
|
||||
* Changes the shape of the log level.
|
||||
* The default shape is { level: number }.
|
||||
*/
|
||||
level?: (label: string, number: number) => object;
|
||||
/**
|
||||
* Changes the shape of the log object.
|
||||
*/
|
||||
log?: (object: Record<string, unknown>) => Record<string, unknown>;
|
||||
}
|
||||
/**
|
||||
* When true, attempts to capture and include the caller location (file:line:column).
|
||||
* In object mode, adds a `caller` string property to the logged object.
|
||||
* Otherwise, appends the caller string as an extra console argument.
|
||||
* This is a browser-only, best-effort feature.
|
||||
*/
|
||||
reportCaller?: boolean;
|
||||
/**
|
||||
* Instead of passing log messages to `console.log` they can be passed to a supplied function. If `write` is
|
||||
* set to a single function, all logging objects are passed to this function. If `write` is an object, it
|
||||
* can have methods that correspond to the levels. When a message is logged at a given level, the
|
||||
* corresponding method is called. If a method isn't present, the logging falls back to using the `console`.
|
||||
*
|
||||
* @example
|
||||
* const pino = require('pino')({
|
||||
* browser: {
|
||||
* write: (o) => {
|
||||
* // do something with o
|
||||
* }
|
||||
* }
|
||||
* })
|
||||
*
|
||||
* @example
|
||||
* const pino = require('pino')({
|
||||
* browser: {
|
||||
* write: {
|
||||
* info: function (o) {
|
||||
* //process info log object
|
||||
* },
|
||||
* error: function (o) {
|
||||
* //process error log object
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* })
|
||||
*/
|
||||
write?:
|
||||
| WriteFn
|
||||
| ({
|
||||
fatal?: WriteFn;
|
||||
error?: WriteFn;
|
||||
warn?: WriteFn;
|
||||
info?: WriteFn;
|
||||
debug?: WriteFn;
|
||||
trace?: WriteFn;
|
||||
} & { [logLevel: string]: WriteFn });
|
||||
|
||||
/**
|
||||
* The serializers provided to `pino` are ignored by default in the browser, including the standard
|
||||
* serializers provided with Pino. Since the default destination for log messages is the console, values
|
||||
* such as `Error` objects are enhanced for inspection, which they otherwise wouldn't be if the Error
|
||||
* serializer was enabled. We can turn all serializers on or we can selectively enable them via an array.
|
||||
*
|
||||
* When `serialize` is `true` the standard error serializer is also enabled (see
|
||||
* {@link https://github.com/pinojs/pino/blob/master/docs/api.md#pino-stdserializers}). This is a global
|
||||
* serializer which will apply to any `Error` objects passed to the logger methods.
|
||||
*
|
||||
* If `serialize` is an array the standard error serializer is also automatically enabled, it can be
|
||||
* explicitly disabled by including a string in the serialize array: `!stdSerializers.err` (see example).
|
||||
*
|
||||
* The `serialize` array also applies to any child logger serializers (see
|
||||
* {@link https://github.com/pinojs/pino/blob/master/docs/api.md#bindingsserializers-object} for how to
|
||||
* set child-bound serializers).
|
||||
*
|
||||
* Unlike server pino the serializers apply to every object passed to the logger method, if the `asObject`
|
||||
* option is `true`, this results in the serializers applying to the first object (as in server pino).
|
||||
*
|
||||
* For more info on serializers see
|
||||
* {@link https://github.com/pinojs/pino/blob/master/docs/api.md#serializers-object}.
|
||||
*
|
||||
* @example
|
||||
* const pino = require('pino')({
|
||||
* browser: {
|
||||
* serialize: true
|
||||
* }
|
||||
* })
|
||||
*
|
||||
* @example
|
||||
* const pino = require('pino')({
|
||||
* serializers: {
|
||||
* custom: myCustomSerializer,
|
||||
* another: anotherSerializer
|
||||
* },
|
||||
* browser: {
|
||||
* serialize: ['custom']
|
||||
* }
|
||||
* })
|
||||
* // following will apply myCustomSerializer to the custom property,
|
||||
* // but will not apply anotherSerializer to another key
|
||||
* pino.info({custom: 'a', another: 'b'})
|
||||
*
|
||||
* @example
|
||||
* const pino = require('pino')({
|
||||
* serializers: {
|
||||
* custom: myCustomSerializer,
|
||||
* another: anotherSerializer
|
||||
* },
|
||||
* browser: {
|
||||
* serialize: ['!stdSerializers.err', 'custom'] //will not serialize Errors, will serialize `custom` keys
|
||||
* }
|
||||
* })
|
||||
*/
|
||||
serialize?: boolean | string[];
|
||||
|
||||
/**
|
||||
* Options for transmission of logs.
|
||||
*
|
||||
* @example
|
||||
* const pino = require('pino')({
|
||||
* browser: {
|
||||
* transmit: {
|
||||
* level: 'warn',
|
||||
* send: function (level, logEvent) {
|
||||
* if (level === 'warn') {
|
||||
* // maybe send the logEvent to a separate endpoint
|
||||
* // or maybe analyse the messages further before sending
|
||||
* }
|
||||
* // we could also use the `logEvent.level.value` property to determine
|
||||
* // numerical value
|
||||
* if (logEvent.level.value >= 50) { // covers error and fatal
|
||||
*
|
||||
* // send the logEvent somewhere
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* })
|
||||
*/
|
||||
transmit?: {
|
||||
/**
|
||||
* Specifies the minimum level (inclusive) of when the `send` function should be called, if not supplied
|
||||
* the `send` function will be called based on the main logging `level` (set via `options.level`,
|
||||
* defaulting to `info`).
|
||||
*/
|
||||
level?: LevelOrString;
|
||||
/**
|
||||
* Remotely record log messages.
|
||||
*
|
||||
* @description Called after writing the log message.
|
||||
*/
|
||||
send: (level: Level, logEvent: LogEvent) => void;
|
||||
};
|
||||
/**
|
||||
* The disabled option will disable logging in browser if set to true, by default it is set to false.
|
||||
*
|
||||
* @example
|
||||
* const pino = require('pino')({browser: {disabled: true}})
|
||||
*/
|
||||
disabled?: boolean;
|
||||
};
|
||||
/**
|
||||
* key-value object added as child logger to each log line. If set to null the base child logger is not added
|
||||
*/
|
||||
base?: { [key: string]: any } | null;
|
||||
|
||||
/**
|
||||
* An object containing functions for formatting the shape of the log lines.
|
||||
* These functions should return a JSONifiable object and should never throw.
|
||||
* These functions allow for full customization of the resulting log lines.
|
||||
* For example, they can be used to change the level key name or to enrich the default metadata.
|
||||
*/
|
||||
formatters?: {
|
||||
/**
|
||||
* Changes the shape of the log level.
|
||||
* The default shape is { level: number }.
|
||||
* The function takes two arguments, the label of the level (e.g. 'info') and the numeric value (e.g. 30).
|
||||
*/
|
||||
level?: (label: string, number: number) => object;
|
||||
/**
|
||||
* Changes the shape of the bindings.
|
||||
* The default shape is { pid, hostname }.
|
||||
* The function takes a single argument, the bindings object.
|
||||
* It will be called every time a child logger is created.
|
||||
*/
|
||||
bindings?: (bindings: Bindings) => object;
|
||||
/**
|
||||
* Changes the shape of the log object.
|
||||
* This function will be called every time one of the log methods (such as .info) is called.
|
||||
* All arguments passed to the log method, except the message, will be pass to this function.
|
||||
* By default it does not change the shape of the log object.
|
||||
*/
|
||||
log?: (object: Record<string, unknown>) => Record<string, unknown>;
|
||||
};
|
||||
|
||||
/**
|
||||
* A string that would be prefixed to every message (and child message)
|
||||
*/
|
||||
msgPrefix?: string
|
||||
|
||||
/**
|
||||
* An object mapping to hook functions. Hook functions allow for customizing internal logger operations.
|
||||
* Hook functions must be synchronous functions.
|
||||
*/
|
||||
hooks?: {
|
||||
/**
|
||||
* Allows for manipulating the parameters passed to logger methods. The signature for this hook is
|
||||
* logMethod (args, method, level) {}, where args is an array of the arguments that were passed to the
|
||||
* log method and method is the log method itself, and level is the log level. This hook must invoke the method function by
|
||||
* using apply, like so: method.apply(this, newArgumentsArray).
|
||||
*/
|
||||
logMethod?: (this: Logger, args: Parameters<LogFn>, method: LogFn, level: number) => void;
|
||||
|
||||
/**
|
||||
* Allows for manipulating the stringified JSON log output just before writing to various transports.
|
||||
* This function must return a string and must be valid JSON.
|
||||
*/
|
||||
streamWrite?: (s: string) => string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Stringification limit at a specific nesting depth when logging circular object. Default: `5`.
|
||||
*/
|
||||
depthLimit?: number
|
||||
|
||||
/**
|
||||
* Stringification limit of properties/elements when logging a specific object/array with circular references. Default: `100`.
|
||||
*/
|
||||
edgeLimit?: number
|
||||
|
||||
/**
|
||||
* Optional child creation callback.
|
||||
*/
|
||||
onChild?: OnChildCallback<CustomLevels>;
|
||||
|
||||
/**
|
||||
* logs newline delimited JSON with `\r\n` instead of `\n`. Default: `false`.
|
||||
*/
|
||||
crlf?: boolean;
|
||||
}
|
||||
|
||||
export interface ChildLoggerOptions<CustomLevels extends string = never> {
|
||||
level?: LevelOrString;
|
||||
serializers?: { [key: string]: SerializerFn };
|
||||
customLevels?: { [level in CustomLevels]: number };
|
||||
formatters?: {
|
||||
level?: (label: string, number: number) => object;
|
||||
bindings?: (bindings: Bindings) => object;
|
||||
log?: (object: object) => object;
|
||||
};
|
||||
redact?: string[] | redactOptions;
|
||||
msgPrefix?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* A data structure representing a log message, it represents the arguments passed to a logger statement, the level
|
||||
* at which they were logged and the hierarchy of child bindings.
|
||||
*
|
||||
* @description By default serializers are not applied to log output in the browser, but they will always be applied
|
||||
* to `messages` and `bindings` in the `logEvent` object. This allows us to ensure a consistent format for all
|
||||
* values between server and client.
|
||||
*/
|
||||
export interface LogEvent {
|
||||
/**
|
||||
* Unix epoch timestamp in milliseconds, the time is taken from the moment the logger method is called.
|
||||
*/
|
||||
ts: number;
|
||||
/**
|
||||
* All arguments passed to logger method, (for instance `logger.info('a', 'b', 'c')` would result in `messages`
|
||||
* array `['a', 'b', 'c']`).
|
||||
*/
|
||||
messages: any[];
|
||||
/**
|
||||
* Represents each child logger (if any), and the relevant bindings.
|
||||
*
|
||||
* @description For instance, given `logger.child({a: 1}).child({b: 2}).info({c: 3})`, the bindings array would
|
||||
* hold `[{a: 1}, {b: 2}]` and the `messages` array would be `[{c: 3}]`. The `bindings` are ordered according to
|
||||
* their position in the child logger hierarchy, with the lowest index being the top of the hierarchy.
|
||||
*/
|
||||
bindings: Bindings[];
|
||||
/**
|
||||
* Holds the `label` (for instance `info`), and the corresponding numerical `value` (for instance `30`).
|
||||
* This could be important in cases where client side level values and labels differ from server side.
|
||||
*/
|
||||
level: {
|
||||
label: string;
|
||||
value: number;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
//// Top level variable (const) exports
|
||||
|
||||
/**
|
||||
* Provides functions for serializing objects common to many projects.
|
||||
*/
|
||||
export const stdSerializers: typeof pinoStdSerializers;
|
||||
|
||||
/**
|
||||
* Holds the current log format version (as output in the v property of each log record).
|
||||
*/
|
||||
export const levels: LevelMapping;
|
||||
export const symbols: {
|
||||
readonly setLevelSym: unique symbol;
|
||||
readonly getLevelSym: unique symbol;
|
||||
readonly levelValSym: unique symbol;
|
||||
readonly useLevelLabelsSym: unique symbol;
|
||||
readonly mixinSym: unique symbol;
|
||||
readonly lsCacheSym: unique symbol;
|
||||
readonly chindingsSym: unique symbol;
|
||||
readonly asJsonSym: unique symbol;
|
||||
readonly writeSym: unique symbol;
|
||||
readonly serializersSym: unique symbol;
|
||||
readonly redactFmtSym: unique symbol;
|
||||
readonly timeSym: unique symbol;
|
||||
readonly timeSliceIndexSym: unique symbol;
|
||||
readonly streamSym: unique symbol;
|
||||
readonly stringifySym: unique symbol;
|
||||
readonly stringifySafeSym: unique symbol;
|
||||
readonly stringifiersSym: unique symbol;
|
||||
readonly endSym: unique symbol;
|
||||
readonly formatOptsSym: unique symbol;
|
||||
readonly messageKeySym: unique symbol;
|
||||
readonly errorKeySym: unique symbol;
|
||||
readonly nestedKeySym: unique symbol;
|
||||
readonly wildcardFirstSym: unique symbol;
|
||||
readonly needsMetadataGsym: unique symbol;
|
||||
readonly useOnlyCustomLevelsSym: unique symbol;
|
||||
readonly formattersSym: unique symbol;
|
||||
readonly hooksSym: unique symbol;
|
||||
};
|
||||
|
||||
/**
|
||||
* Exposes the Pino package version. Also available on the logger instance.
|
||||
*/
|
||||
export const version: string;
|
||||
|
||||
/**
|
||||
* Provides functions for generating the timestamp property in the log output. You can set the `timestamp` option during
|
||||
* initialization to one of these functions to adjust the output format. Alternatively, you can specify your own time function.
|
||||
* A time function must synchronously return a string that would be a valid component of a JSON string. For example,
|
||||
* the default function returns a string like `,"time":1493426328206`.
|
||||
*/
|
||||
export const stdTimeFunctions: {
|
||||
/**
|
||||
* The default time function for Pino. Returns a string like `,"time":1493426328206`.
|
||||
*/
|
||||
epochTime: TimeFn;
|
||||
/*
|
||||
* Returns the seconds since Unix epoch
|
||||
*/
|
||||
unixTime: TimeFn;
|
||||
/**
|
||||
* Returns an empty string. This function is used when the `timestamp` option is set to `false`.
|
||||
*/
|
||||
nullTime: TimeFn;
|
||||
/*
|
||||
* Returns ISO 8601-formatted time in UTC
|
||||
*/
|
||||
isoTime: TimeFn;
|
||||
/*
|
||||
* Returns RFC 3339-formatted time in UTC
|
||||
*/
|
||||
isoTimeNano: TimeFn;
|
||||
};
|
||||
|
||||
//// Exported functions
|
||||
|
||||
/**
|
||||
* Create a Pino Destination instance: a stream-like object with significantly more throughput (over 30%) than a standard Node.js stream.
|
||||
* @param [dest]: The `destination` parameter, can be a file descriptor, a file path, or an object with `dest` property pointing to a fd or path.
|
||||
* An ordinary Node.js `stream` file descriptor can be passed as the destination (such as the result of `fs.createWriteStream`)
|
||||
* but for peak log writing performance, it is strongly recommended to use `pino.destination` to create the destination stream.
|
||||
* @returns A Sonic-Boom stream to be used as destination for the pino function
|
||||
*/
|
||||
export function destination(
|
||||
dest?: number | object | string | DestinationStream | NodeJS.WritableStream | SonicBoomOpts,
|
||||
): SonicBoom;
|
||||
|
||||
export function transport<TransportOptions = Record<string, any>>(
|
||||
options: TransportSingleOptions<TransportOptions> | TransportMultiOptions<TransportOptions> | TransportPipelineOptions<TransportOptions>
|
||||
): ThreadStream
|
||||
|
||||
export function multistream<TLevel = Level>(
|
||||
streamsArray: (DestinationStream | StreamEntry<TLevel>)[] | DestinationStream | StreamEntry<TLevel>,
|
||||
opts?: MultiStreamOptions
|
||||
): MultiStreamRes<TLevel>
|
||||
|
||||
//// Nested version of default export for TypeScript/Babel compatibility
|
||||
|
||||
/**
|
||||
* @param [optionsOrStream]: an options object or a writable stream where the logs will be written. It can also receive some log-line metadata, if the
|
||||
* relative protocol is enabled. Default: process.stdout
|
||||
* @returns a new logger instance.
|
||||
*/
|
||||
function pino<CustomLevels extends string = never, UseOnlyCustomLevels extends boolean = boolean>(optionsOrStream?: LoggerOptions<CustomLevels, UseOnlyCustomLevels> | DestinationStream): Logger<CustomLevels, UseOnlyCustomLevels>;
|
||||
|
||||
/**
|
||||
* @param [options]: an options object
|
||||
* @param [stream]: a writable stream where the logs will be written. It can also receive some log-line metadata, if the
|
||||
* relative protocol is enabled. Default: process.stdout
|
||||
* @returns a new logger instance.
|
||||
*/
|
||||
function pino<CustomLevels extends string = never, UseOnlyCustomLevels extends boolean = boolean>(options: LoggerOptions<CustomLevels, UseOnlyCustomLevels>, stream?: DestinationStream | undefined): Logger<CustomLevels, UseOnlyCustomLevels>;
|
||||
|
||||
/**
|
||||
* Attach selected static members to the nested callable export, so that
|
||||
* `const { pino } = require('pino')` exposes them (e.g. `pino.stdTimeFunctions`).
|
||||
*/
|
||||
namespace pino {
|
||||
const stdTimeFunctions: {
|
||||
epochTime: TimeFn;
|
||||
unixTime: TimeFn;
|
||||
nullTime: TimeFn;
|
||||
isoTime: TimeFn;
|
||||
isoTimeNano: TimeFn;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
//// Callable default export
|
||||
|
||||
/**
|
||||
* @param [optionsOrStream]: an options object or a writable stream where the logs will be written. It can also receive some log-line metadata, if the
|
||||
* relative protocol is enabled. Default: process.stdout
|
||||
* @returns a new logger instance.
|
||||
*/
|
||||
declare function pino<CustomLevels extends string = never, UseOnlyCustomLevels extends boolean = boolean>(optionsOrStream?: pino.LoggerOptions<CustomLevels, UseOnlyCustomLevels> | pino.DestinationStream): pino.Logger<CustomLevels, UseOnlyCustomLevels>;
|
||||
|
||||
/**
|
||||
* @param [options]: an options object
|
||||
* @param [stream]: a writable stream where the logs will be written. It can also receive some log-line metadata, if the
|
||||
* relative protocol is enabled. Default: process.stdout
|
||||
* @returns a new logger instance.
|
||||
*/
|
||||
declare function pino<CustomLevels extends string = never, UseOnlyCustomLevels extends boolean = boolean>(options: pino.LoggerOptions<CustomLevels, UseOnlyCustomLevels>, stream?: pino.DestinationStream | undefined): pino.Logger<CustomLevels, UseOnlyCustomLevels>;
|
||||
|
||||
export = pino;
|
||||
@@ -0,0 +1,189 @@
|
||||
'use strict'
|
||||
|
||||
const { isColorSupported } = require('colorette')
|
||||
const pump = require('pump')
|
||||
const { Transform } = require('node:stream')
|
||||
const abstractTransport = require('pino-abstract-transport')
|
||||
const colors = require('./lib/colors')
|
||||
const {
|
||||
ERROR_LIKE_KEYS,
|
||||
LEVEL_KEY,
|
||||
LEVEL_LABEL,
|
||||
MESSAGE_KEY,
|
||||
TIMESTAMP_KEY
|
||||
} = require('./lib/constants')
|
||||
const {
|
||||
buildSafeSonicBoom,
|
||||
parseFactoryOptions
|
||||
} = require('./lib/utils')
|
||||
const pretty = require('./lib/pretty')
|
||||
|
||||
/**
|
||||
* @typedef {object} PinoPrettyOptions
|
||||
* @property {boolean} [colorize] Indicates if colors should be used when
|
||||
* prettifying. The default will be determined by the terminal capabilities at
|
||||
* run time.
|
||||
* @property {boolean} [colorizeObjects=true] Apply coloring to rendered objects
|
||||
* when coloring is enabled.
|
||||
* @property {boolean} [crlf=false] End lines with `\r\n` instead of `\n`.
|
||||
* @property {string|null} [customColors=null] A comma separated list of colors
|
||||
* to use for specific level labels, e.g. `err:red,info:blue`.
|
||||
* @property {string|null} [customLevels=null] A comma separated list of user
|
||||
* defined level names and numbers, e.g. `err:99,info:1`.
|
||||
* @property {CustomPrettifiers} [customPrettifiers={}] A set of prettifier
|
||||
* functions to apply to keys defined in this object.
|
||||
* @property {K_ERROR_LIKE_KEYS} [errorLikeObjectKeys] A list of string property
|
||||
* names to consider as error objects.
|
||||
* @property {string} [errorProps=''] A comma separated list of properties on
|
||||
* error objects to include in the output.
|
||||
* @property {boolean} [hideObject=false] When `true`, data objects will be
|
||||
* omitted from the output (except for error objects).
|
||||
* @property {string} [ignore='hostname'] A comma separated list of log keys
|
||||
* to omit when outputting the prettified log information.
|
||||
* @property {undefined|string} [include=undefined] A comma separated list of
|
||||
* log keys to include in the prettified log information. Only the keys in this
|
||||
* list will be included in the output.
|
||||
* @property {boolean} [levelFirst=false] When true, the log level will be the
|
||||
* first field in the prettified output.
|
||||
* @property {string} [levelKey='level'] The key name in the log data that
|
||||
* contains the level value for the log.
|
||||
* @property {string} [levelLabel='levelLabel'] Token name to use in
|
||||
* `messageFormat` to represent the name of the logged level.
|
||||
* @property {null|MessageFormatString|MessageFormatFunction} [messageFormat=null]
|
||||
* When a string, defines how the prettified line should be formatted according
|
||||
* to defined tokens. When a function, a synchronous function that returns a
|
||||
* formatted string.
|
||||
* @property {string} [messageKey='msg'] Defines the key in incoming logs that
|
||||
* contains the message of the log, if present.
|
||||
* @property {undefined|string|number} [minimumLevel=undefined] The minimum
|
||||
* level for logs that should be processed. Any logs below this level will
|
||||
* be omitted.
|
||||
* @property {object} [outputStream=process.stdout] The stream to write
|
||||
* prettified log lines to.
|
||||
* @property {boolean} [singleLine=false] When `true` any objects, except error
|
||||
* objects, in the log data will be printed as a single line instead as multiple
|
||||
* lines.
|
||||
* @property {string} [timestampKey='time'] Defines the key in incoming logs
|
||||
* that contains the timestamp of the log, if present.
|
||||
* @property {boolean|string} [translateTime=true] When true, will translate a
|
||||
* JavaScript date integer into a human-readable string. If set to a string,
|
||||
* it must be a format string.
|
||||
* @property {boolean} [useOnlyCustomProps=true] When true, only custom levels
|
||||
* and colors will be used if they have been provided.
|
||||
*/
|
||||
|
||||
/**
|
||||
* The default options that will be used when prettifying log lines.
|
||||
*
|
||||
* @type {PinoPrettyOptions}
|
||||
*/
|
||||
const defaultOptions = {
|
||||
colorize: isColorSupported,
|
||||
colorizeObjects: true,
|
||||
crlf: false,
|
||||
customColors: null,
|
||||
customLevels: null,
|
||||
customPrettifiers: {},
|
||||
errorLikeObjectKeys: ERROR_LIKE_KEYS,
|
||||
errorProps: '',
|
||||
hideObject: false,
|
||||
ignore: 'hostname',
|
||||
include: undefined,
|
||||
levelFirst: false,
|
||||
levelKey: LEVEL_KEY,
|
||||
levelLabel: LEVEL_LABEL,
|
||||
messageFormat: null,
|
||||
messageKey: MESSAGE_KEY,
|
||||
minimumLevel: undefined,
|
||||
outputStream: process.stdout,
|
||||
singleLine: false,
|
||||
timestampKey: TIMESTAMP_KEY,
|
||||
translateTime: true,
|
||||
useOnlyCustomProps: true
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes the supplied options and returns a function that accepts log data
|
||||
* and produces a prettified log string.
|
||||
*
|
||||
* @param {PinoPrettyOptions} options Configuration for the prettifier.
|
||||
* @returns {LogPrettifierFunc}
|
||||
*/
|
||||
function prettyFactory (options) {
|
||||
const context = parseFactoryOptions(Object.assign({}, defaultOptions, options))
|
||||
return pretty.bind({ ...context, context })
|
||||
}
|
||||
|
||||
/**
|
||||
* @typedef {PinoPrettyOptions} BuildStreamOpts
|
||||
* @property {object|number|string} [destination] A destination stream, file
|
||||
* descriptor, or target path to a file.
|
||||
* @property {boolean} [append]
|
||||
* @property {boolean} [mkdir]
|
||||
* @property {boolean} [sync=false]
|
||||
*/
|
||||
|
||||
/**
|
||||
* Constructs a {@link LogPrettifierFunc} and a stream to which the produced
|
||||
* prettified log data will be written.
|
||||
*
|
||||
* @param {BuildStreamOpts} opts
|
||||
* @returns {Transform | (Transform & OnUnknown)}
|
||||
*/
|
||||
function build (opts = {}) {
|
||||
let pretty = prettyFactory(opts)
|
||||
let destination
|
||||
return abstractTransport(function (source) {
|
||||
source.on('message', function pinoConfigListener (message) {
|
||||
if (!message || message.code !== 'PINO_CONFIG') return
|
||||
Object.assign(opts, {
|
||||
messageKey: message.config.messageKey,
|
||||
errorLikeObjectKeys: Array.from(new Set([...(opts.errorLikeObjectKeys || ERROR_LIKE_KEYS), message.config.errorKey])),
|
||||
customLevels: message.config.levels.values
|
||||
})
|
||||
pretty = prettyFactory(opts)
|
||||
source.off('message', pinoConfigListener)
|
||||
})
|
||||
const stream = new Transform({
|
||||
objectMode: true,
|
||||
autoDestroy: true,
|
||||
transform (chunk, enc, cb) {
|
||||
const line = pretty(chunk)
|
||||
cb(null, line)
|
||||
}
|
||||
})
|
||||
|
||||
if (typeof opts.destination === 'object' && typeof opts.destination.write === 'function') {
|
||||
destination = opts.destination
|
||||
} else {
|
||||
destination = buildSafeSonicBoom({
|
||||
dest: opts.destination || 1,
|
||||
append: opts.append,
|
||||
mkdir: opts.mkdir,
|
||||
sync: opts.sync // by default sonic will be async
|
||||
})
|
||||
}
|
||||
|
||||
source.on('unknown', function (line) {
|
||||
destination.write(line + '\n')
|
||||
})
|
||||
|
||||
pump(source, stream, destination)
|
||||
return stream
|
||||
}, {
|
||||
parse: 'lines',
|
||||
close (err, cb) {
|
||||
destination.on('close', () => {
|
||||
cb(err)
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = build
|
||||
module.exports.build = build
|
||||
module.exports.PinoPretty = build
|
||||
module.exports.prettyFactory = prettyFactory
|
||||
module.exports.colorizerFactory = colors
|
||||
module.exports.isColorSupported = isColorSupported
|
||||
module.exports.default = build
|
||||
@@ -0,0 +1,12 @@
|
||||
# `@typescript-eslint/tsconfig-utils`
|
||||
|
||||
> Utilities for collecting TSConfigs for linting scenarios.
|
||||
|
||||
[](https://www.npmjs.com/package/@typescript-eslint/tsconfig-utils)
|
||||
[](https://www.npmjs.com/package/@typescript-eslint/tsconfig-utils)
|
||||
|
||||
The utilities in this package are separated from `@typescript-eslint/utils` so that they do not have a dependency on `eslint` or `@typescript-eslint/typescript-estree`.
|
||||
|
||||
> See https://typescript-eslint.io for general documentation on typescript-eslint, the tooling that allows you to run ESLint and Prettier on TypeScript code.
|
||||
|
||||
<!-- Local path for docs: docs/packages/TSConfig_Utils.mdx -->
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../src/api/options.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,UAAU,MAAM,aAAa,CAAC;AA2BrC,MAAM,UAAU,cAAc,CAAC,OAAsB;IACjD,OAAO,CAAC,CAAC,MAAM,IAAI,OAAO,CAAC,CAAC;AAChC,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,OAA2B;IACtD,OAAO,OAAO,CAAC,YAAY,IAAI,UAAU,EAAE,CAAC;AAChD,CAAC"}
|
||||
@@ -0,0 +1,12 @@
|
||||
"use strict";
|
||||
// THIS CODE WAS AUTOMATICALLY GENERATED
|
||||
// DO NOT EDIT THIS CODE BY HAND
|
||||
// RUN THE FOLLOWING COMMAND FROM THE WORKSPACE ROOT TO REGENERATE:
|
||||
// npx nx generate-lib repo
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.esnext_sharedmemory = void 0;
|
||||
const base_config_1 = require("./base-config");
|
||||
exports.esnext_sharedmemory = {
|
||||
libs: [],
|
||||
variables: [['Atomics', base_config_1.TYPE]],
|
||||
};
|
||||
@@ -0,0 +1,22 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2014-present Sebastian McKenzie and other contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"main": "../../cjs/_assert_this_initialized.cjs",
|
||||
"module": "../../esm/_assert_this_initialized.js"
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright 2024 SWC contributors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@@ -0,0 +1,146 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = default_1;
|
||||
const util = __importStar(require("../core/util.cjs"));
|
||||
const error = () => {
|
||||
const Sizable = {
|
||||
string: { unit: "caractere", verb: "să aibă" },
|
||||
file: { unit: "octeți", verb: "să aibă" },
|
||||
array: { unit: "elemente", verb: "să aibă" },
|
||||
set: { unit: "elemente", verb: "să aibă" },
|
||||
map: { unit: "intrări", verb: "să aibă" },
|
||||
};
|
||||
function getSizing(origin) {
|
||||
return Sizable[origin] ?? null;
|
||||
}
|
||||
const FormatDictionary = {
|
||||
regex: "intrare",
|
||||
email: "adresă de email",
|
||||
url: "URL",
|
||||
emoji: "emoji",
|
||||
uuid: "UUID",
|
||||
uuidv4: "UUIDv4",
|
||||
uuidv6: "UUIDv6",
|
||||
nanoid: "nanoid",
|
||||
guid: "GUID",
|
||||
cuid: "cuid",
|
||||
cuid2: "cuid2",
|
||||
ulid: "ULID",
|
||||
xid: "XID",
|
||||
ksuid: "KSUID",
|
||||
datetime: "dată și oră ISO",
|
||||
date: "dată ISO",
|
||||
time: "oră ISO",
|
||||
duration: "durată ISO",
|
||||
ipv4: "adresă IPv4",
|
||||
ipv6: "adresă IPv6",
|
||||
mac: "adresă MAC",
|
||||
cidrv4: "interval IPv4",
|
||||
cidrv6: "interval IPv6",
|
||||
base64: "șir codat base64",
|
||||
base64url: "șir codat base64url",
|
||||
json_string: "șir JSON",
|
||||
e164: "număr E.164",
|
||||
jwt: "JWT",
|
||||
template_literal: "intrare",
|
||||
};
|
||||
const TypeDictionary = {
|
||||
nan: "NaN",
|
||||
string: "șir",
|
||||
number: "număr",
|
||||
boolean: "boolean",
|
||||
function: "funcție",
|
||||
array: "matrice",
|
||||
object: "obiect",
|
||||
undefined: "nedefinit",
|
||||
symbol: "simbol",
|
||||
bigint: "număr mare",
|
||||
void: "void",
|
||||
never: "never",
|
||||
map: "hartă",
|
||||
set: "set",
|
||||
};
|
||||
return (issue) => {
|
||||
switch (issue.code) {
|
||||
case "invalid_type": {
|
||||
const expected = TypeDictionary[issue.expected] ?? issue.expected;
|
||||
const receivedType = util.parsedType(issue.input);
|
||||
const received = TypeDictionary[receivedType] ?? receivedType;
|
||||
return `Intrare invalidă: așteptat ${expected}, primit ${received}`;
|
||||
}
|
||||
case "invalid_value":
|
||||
if (issue.values.length === 1)
|
||||
return `Intrare invalidă: așteptat ${util.stringifyPrimitive(issue.values[0])}`;
|
||||
return `Opțiune invalidă: așteptat una dintre ${util.joinValues(issue.values, "|")}`;
|
||||
case "too_big": {
|
||||
const adj = issue.inclusive ? "<=" : "<";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing)
|
||||
return `Prea mare: așteptat ca ${issue.origin ?? "valoarea"} ${sizing.verb} ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elemente"}`;
|
||||
return `Prea mare: așteptat ca ${issue.origin ?? "valoarea"} să fie ${adj}${issue.maximum.toString()}`;
|
||||
}
|
||||
case "too_small": {
|
||||
const adj = issue.inclusive ? ">=" : ">";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing) {
|
||||
return `Prea mic: așteptat ca ${issue.origin} ${sizing.verb} ${adj}${issue.minimum.toString()} ${sizing.unit}`;
|
||||
}
|
||||
return `Prea mic: așteptat ca ${issue.origin} să fie ${adj}${issue.minimum.toString()}`;
|
||||
}
|
||||
case "invalid_format": {
|
||||
const _issue = issue;
|
||||
if (_issue.format === "starts_with") {
|
||||
return `Șir invalid: trebuie să înceapă cu "${_issue.prefix}"`;
|
||||
}
|
||||
if (_issue.format === "ends_with")
|
||||
return `Șir invalid: trebuie să se termine cu "${_issue.suffix}"`;
|
||||
if (_issue.format === "includes")
|
||||
return `Șir invalid: trebuie să includă "${_issue.includes}"`;
|
||||
if (_issue.format === "regex")
|
||||
return `Șir invalid: trebuie să se potrivească cu modelul ${_issue.pattern}`;
|
||||
return `Format invalid: ${FormatDictionary[_issue.format] ?? issue.format}`;
|
||||
}
|
||||
case "not_multiple_of":
|
||||
return `Număr invalid: trebuie să fie multiplu de ${issue.divisor}`;
|
||||
case "unrecognized_keys":
|
||||
return `Chei nerecunoscute: ${util.joinValues(issue.keys, ", ")}`;
|
||||
case "invalid_key":
|
||||
return `Cheie invalidă în ${issue.origin}`;
|
||||
case "invalid_union":
|
||||
return "Intrare invalidă";
|
||||
case "invalid_element":
|
||||
return `Valoare invalidă în ${issue.origin}`;
|
||||
default:
|
||||
return `Intrare invalidă`;
|
||||
}
|
||||
};
|
||||
};
|
||||
function default_1() {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
module.exports = exports.default;
|
||||
@@ -0,0 +1 @@
|
||||
export type Lib = 'decorators' | 'decorators.legacy' | 'dom' | 'dom.asynciterable' | 'dom.iterable' | 'es5' | 'es6' | 'es7' | 'es2015' | 'es2015.collection' | 'es2015.core' | 'es2015.generator' | 'es2015.iterable' | 'es2015.promise' | 'es2015.proxy' | 'es2015.reflect' | 'es2015.symbol' | 'es2015.symbol.wellknown' | 'es2016' | 'es2016.array.include' | 'es2016.full' | 'es2016.intl' | 'es2017' | 'es2017.arraybuffer' | 'es2017.date' | 'es2017.full' | 'es2017.intl' | 'es2017.object' | 'es2017.sharedmemory' | 'es2017.string' | 'es2017.typedarrays' | 'es2018' | 'es2018.asyncgenerator' | 'es2018.asynciterable' | 'es2018.full' | 'es2018.intl' | 'es2018.promise' | 'es2018.regexp' | 'es2019' | 'es2019.array' | 'es2019.full' | 'es2019.intl' | 'es2019.object' | 'es2019.string' | 'es2019.symbol' | 'es2020' | 'es2020.bigint' | 'es2020.date' | 'es2020.full' | 'es2020.intl' | 'es2020.number' | 'es2020.promise' | 'es2020.sharedmemory' | 'es2020.string' | 'es2020.symbol.wellknown' | 'es2021' | 'es2021.full' | 'es2021.intl' | 'es2021.promise' | 'es2021.string' | 'es2021.weakref' | 'es2022' | 'es2022.array' | 'es2022.error' | 'es2022.full' | 'es2022.intl' | 'es2022.object' | 'es2022.regexp' | 'es2022.string' | 'es2023' | 'es2023.array' | 'es2023.collection' | 'es2023.full' | 'es2023.intl' | 'es2024' | 'es2024.arraybuffer' | 'es2024.collection' | 'es2024.full' | 'es2024.object' | 'es2024.promise' | 'es2024.regexp' | 'es2024.sharedmemory' | 'es2024.string' | 'es2025' | 'es2025.collection' | 'es2025.float16' | 'es2025.full' | 'es2025.intl' | 'es2025.iterator' | 'es2025.promise' | 'es2025.regexp' | 'esnext' | 'esnext.array' | 'esnext.asynciterable' | 'esnext.bigint' | 'esnext.collection' | 'esnext.date' | 'esnext.decorators' | 'esnext.disposable' | 'esnext.error' | 'esnext.float16' | 'esnext.full' | 'esnext.intl' | 'esnext.iterator' | 'esnext.object' | 'esnext.promise' | 'esnext.regexp' | 'esnext.sharedmemory' | 'esnext.string' | 'esnext.symbol' | 'esnext.temporal' | 'esnext.typedarrays' | 'esnext.weakref' | 'lib' | 'scripthost' | 'webworker' | 'webworker.asynciterable' | 'webworker.importscripts' | 'webworker.iterable';
|
||||
@@ -0,0 +1,23 @@
|
||||
(MIT)
|
||||
|
||||
Original code Copyright Julian Gruber <julian@juliangruber.com>
|
||||
|
||||
Port to TypeScript Copyright Isaac Z. Schlueter <i@izs.me>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"main": "../../cjs/_async_iterator.cjs",
|
||||
"module": "../../esm/_async_iterator.js"
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
function dispose_SuppressedError(r, e) {
|
||||
return "undefined" != typeof SuppressedError ? dispose_SuppressedError = SuppressedError : (dispose_SuppressedError = function dispose_SuppressedError(r, e) {
|
||||
this.suppressed = e, this.error = r, this.stack = Error().stack;
|
||||
}, dispose_SuppressedError.prototype = Object.create(Error.prototype, {
|
||||
constructor: {
|
||||
value: dispose_SuppressedError,
|
||||
writable: !0,
|
||||
configurable: !0
|
||||
}
|
||||
})), new dispose_SuppressedError(r, e);
|
||||
}
|
||||
function _dispose(r, e, s) {
|
||||
function next() {
|
||||
for (; r.length > 0;) try {
|
||||
var o = r.pop(),
|
||||
p = o.d.call(o.v);
|
||||
if (o.a) return Promise.resolve(p).then(next, err);
|
||||
} catch (r) {
|
||||
return err(r);
|
||||
}
|
||||
if (s) throw e;
|
||||
}
|
||||
function err(r) {
|
||||
return e = s ? new dispose_SuppressedError(e, r) : r, s = !0, next();
|
||||
}
|
||||
return next();
|
||||
}
|
||||
module.exports = _dispose, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
||||
Reference in New Issue
Block a user