@vidavidorra/bunyan-pretty-stream 5.0.0 → 6.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/README.md CHANGED
@@ -58,7 +58,7 @@ Please refer to the [Security Policy on GitHub](https://github.com/vidavidorra/b
58
58
 
59
59
  This project is licensed under the [GPLv3 license](https://www.gnu.org/licenses/gpl.html).
60
60
 
61
- Copyright © 2021 Jeroen de Bruijn
61
+ Copyright © 2021-2023 Jeroen de Bruijn
62
62
 
63
63
  <details><summary>License details.</summary>
64
64
  <p>
@@ -1,3 +1,3 @@
1
- import type BunyanRecord from './record.js';
1
+ import { type BunyanRecord } from './record.js';
2
2
  declare function fromJsonString(json: string): BunyanRecord;
3
3
  export default fromJsonString;
@@ -1,5 +1,6 @@
1
+ export { default as isSource } from './is-source.js';
1
2
  export { default as isBunyanRecord } from './is-record.js';
2
- export { type default as BunyanRecord } from './record.js';
3
+ export type { BunyanRecord, Source } from './record.js';
3
4
  export { default as coreFields } from './core-fields.js';
4
5
  export { default as fromJsonString } from './from-json-string.js';
5
6
  export { default as levels } from './levels.js';
@@ -1,3 +1,4 @@
1
+ export { default as isSource } from './is-source.js';
1
2
  export { default as isBunyanRecord } from './is-record.js';
2
3
  export { default as coreFields } from './core-fields.js';
3
4
  export { default as fromJsonString } from './from-json-string.js';
@@ -1,3 +1,3 @@
1
- import type BunyanRecord from './record.js';
1
+ import { type BunyanRecord } from './record.js';
2
2
  declare function isBunyanRecord(value: unknown): value is BunyanRecord;
3
3
  export default isBunyanRecord;
@@ -1,4 +1,5 @@
1
1
  import is from '@sindresorhus/is';
2
+ import isSource from './is-source.js';
2
3
  function isBunyanRecord(value) {
3
4
  return (is.plainObject(value) &&
4
5
  is.number(value.v) &&
@@ -9,9 +10,8 @@ function isBunyanRecord(value) {
9
10
  is.date(value.time) &&
10
11
  is.string(value.msg) &&
11
12
  (is.undefined(value.src) ||
12
- (is.plainObject(value.src) &&
13
- is.number(value.src.line) &&
14
- (is.undefined(value.src.func) || is.string(value.src.func)))));
13
+ is.emptyObject(value.src) ||
14
+ isSource(value.src)));
15
15
  }
16
16
  export default isBunyanRecord;
17
17
  //# sourceMappingURL=is-record.js.map
@@ -0,0 +1,3 @@
1
+ import { type Source } from './record.js';
2
+ declare function isSource(value: unknown): value is Source;
3
+ export default isSource;
@@ -0,0 +1,9 @@
1
+ import is from '@sindresorhus/is';
2
+ function isSource(value) {
3
+ return (is.plainObject(value) &&
4
+ is.string(value.file) &&
5
+ is.number(value.line) &&
6
+ (is.undefined(value.func) || is.string(value.func)));
7
+ }
8
+ export default isSource;
9
+ //# sourceMappingURL=is-source.js.map
@@ -1,3 +1,8 @@
1
+ type Source = {
2
+ file: string;
3
+ line: number;
4
+ func?: string;
5
+ };
1
6
  type BunyanRecord = {
2
7
  [key: string]: unknown;
3
8
  v: number;
@@ -7,10 +12,6 @@ type BunyanRecord = {
7
12
  pid: number;
8
13
  time: Date;
9
14
  msg: string;
10
- src?: {
11
- file: string;
12
- line: number;
13
- func?: string;
14
- };
15
+ src?: Source | Record<string, never>;
15
16
  };
16
- export default BunyanRecord;
17
+ export type { Source, BunyanRecord };
@@ -1,8 +1,7 @@
1
1
  /// <reference types="node" resolution-mode="require"/>
2
2
  /// <reference types="node" resolution-mode="require"/>
3
- import type { TransformCallback } from 'node:stream';
4
- import { Transform } from 'node:stream';
5
- import type { PublicOptions as Options } from './options.js';
3
+ import { type TransformCallback, Transform } from 'node:stream';
4
+ import { type PublicOptions as Options } from './options.js';
6
5
  declare class PrettyStream extends Transform {
7
6
  private readonly _formatter;
8
7
  constructor(options?: Options);
@@ -1,4 +1,4 @@
1
- import type { Options } from '../options.js';
1
+ import { type Options } from '../options.js';
2
2
  declare class Extras {
3
3
  private readonly _formatCharacters;
4
4
  constructor(formatCharacters: Options['extras']['formatCharacters']);
@@ -1,7 +1,7 @@
1
- import type { ChalkInstance as Chalk } from 'chalk';
2
- import type BunyanRecord from '../bunyan/record.js';
3
- import type { PublicOptions } from '../options.js';
4
- import type { ParsedRecord } from '../parser/parser.js';
1
+ import { type ChalkInstance as Chalk } from 'chalk';
2
+ import { type BunyanRecord } from '../bunyan/index.js';
3
+ import { type PublicOptions } from '../options.js';
4
+ import { type ParsedRecord } from '../parser/parser.js';
5
5
  declare class Formatter {
6
6
  private readonly _options;
7
7
  private readonly _parser;
@@ -1,4 +1,4 @@
1
- import type { Options } from '../options.js';
1
+ import { type Options } from '../options.js';
2
2
  declare class Formatter {
3
3
  private readonly _options;
4
4
  private readonly _iso8601Presets;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { type Logger } from './logger.js';
1
+ export type { Logger } from './logger.js';
2
2
  export { PrettyStream } from './bunyan-pretty-stream.js';
3
3
  export type { PublicOptions as Options } from './options.js';
4
4
  export { levels } from './bunyan/index.js';
package/dist/options.js CHANGED
@@ -1,12 +1,12 @@
1
1
  import { z } from 'zod';
2
- import bunyanCoreFields from './bunyan/core-fields.js';
2
+ import { coreFields } from './bunyan/index.js';
3
3
  import normalisePath from './helpers/normalise-path.js';
4
4
  const extras = z
5
5
  .object({
6
6
  key: z
7
7
  .string()
8
8
  .min(1)
9
- .regex(new RegExp(`^((?!(${bunyanCoreFields.join('|')})).)*$`))
9
+ .regex(new RegExp(`^((?!(${coreFields.join('|')})).)*$`))
10
10
  .optional(),
11
11
  maxLength: z
12
12
  .object({
@@ -1,4 +1,4 @@
1
- import type { Options } from '../options.js';
1
+ import { type Options } from '../options.js';
2
2
  declare class Extras {
3
3
  private readonly _options;
4
4
  private readonly _extra;
@@ -1,9 +1,9 @@
1
- import type BunyanRecord from '../bunyan/record.js';
2
- import type { Options } from '../options.js';
1
+ import { type BunyanRecord, type Source } from '../bunyan/index.js';
2
+ import { type Options } from '../options.js';
3
3
  type ParsedRecord = {
4
4
  version: BunyanRecord['v'];
5
5
  message: BunyanRecord['msg'];
6
- source: BunyanRecord['src'];
6
+ source?: Source;
7
7
  extras: string[];
8
8
  details: Record<string, unknown>;
9
9
  } & Pick<BunyanRecord, 'level' | 'name' | 'hostname' | 'pid' | 'time'>;
@@ -1,4 +1,5 @@
1
1
  import is from '@sindresorhus/is';
2
+ import { isSource } from '../bunyan/index.js';
2
3
  import Extras from './extras.js';
3
4
  class Parser {
4
5
  _extras;
@@ -34,7 +35,7 @@ class Parser {
34
35
  return record;
35
36
  }
36
37
  toRecord(bunyanRecord) {
37
- const { v: version, level, name, hostname, pid, time, msg: message, src: source, ...leftOvers } = bunyanRecord;
38
+ const { v: version, level, name, hostname, pid, time, msg: message, src, ...leftOvers } = bunyanRecord;
38
39
  return {
39
40
  version,
40
41
  level,
@@ -43,7 +44,7 @@ class Parser {
43
44
  pid,
44
45
  time,
45
46
  message,
46
- source,
47
+ source: isSource(src) ? src : undefined,
47
48
  extras: [],
48
49
  details: leftOvers,
49
50
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vidavidorra/bunyan-pretty-stream",
3
- "version": "5.0.0",
3
+ "version": "6.0.0",
4
4
  "description": "Highly configurable Bunyan stream with pretty output",
5
5
  "type": "module",
6
6
  "exports": "./dist/index.js",
@@ -52,7 +52,7 @@
52
52
  "@types/bunyan": "1.8.8",
53
53
  "@types/luxon": "3.2.0",
54
54
  "@types/node": "18.15.0",
55
- "@vidavidorra/commitlint-config": "4.0.12",
55
+ "@vidavidorra/commitlint-config": "4.0.17",
56
56
  "ava": "5.2.0",
57
57
  "bunyan": "*",
58
58
  "bunyan-1.x": "npm:bunyan@1.8.15",
@@ -64,7 +64,7 @@
64
64
  "lint-staged": "13.2.0",
65
65
  "npm-run-all": "4.1.5",
66
66
  "prettier": "2.8.4",
67
- "semantic-release": "20.1.3",
67
+ "semantic-release": "21.0.1",
68
68
  "strip-ansi": "7.0.1",
69
69
  "typescript": "5.0.3",
70
70
  "xo": "0.53.1"