mirror of
https://github.com/x1xhlol/system-prompts-and-models-of-ai-tools.git
synced 2026-02-04 05:50:50 +00:00
KI
KJ
This commit is contained in:
309
unified-ai-platform/node_modules/logform/CHANGELOG.md
generated
vendored
Normal file
309
unified-ai-platform/node_modules/logform/CHANGELOG.md
generated
vendored
Normal file
@@ -0,0 +1,309 @@
|
||||
# CHANGELOG
|
||||
|
||||
### [2.5.1](https://github.com/winstonjs/logform/compare/v2.5.0...v2.5.1)
|
||||
**2023/02/07**
|
||||
## Bugfix
|
||||
The triple-beam types package has been promoted to a full dependency, by first-time contributor @carboneater (Thanks!)
|
||||
in https://github.com/winstonjs/logform/pull/243 to fix https://github.com/winstonjs/logform/issues/242.
|
||||
|
||||
### [2.5.0](https://github.com/winstonjs/logform/compare/v2.4.2...v2.5.0)
|
||||
**2023/02/06**
|
||||
## Most Important:
|
||||
* Now incompatible with TypeScript < 4.4 due to [PR #240](https://github.com/winstonjs/logform/pull/240), as pointed out in [#244](https://github.com/winstonjs/logform/issues/244).
|
||||
|
||||
## Improvements
|
||||
All the improvements in this release are from first-time contributors - thanks for your contributions!
|
||||
* Feature - optionally include Error.cause property by @davidnbooth in https://github.com/winstonjs/logform/pull/226
|
||||
* Add triple beam properties to types by @robinpokorny in https://github.com/winstonjs/logform/pull/194
|
||||
* TransformableInfo should support symbols as keys by @dancrumb in https://github.com/winstonjs/logform/pull/240
|
||||
|
||||
## Dependency updates by @dependabot
|
||||
* Bump @babel/cli from 7.18.6 to 7.19.3 by @dependabot in https://github.com/winstonjs/logform/pull/214
|
||||
* Bump @babel/core from 7.18.6 to 7.20.12 by @dependabot in https://github.com/winstonjs/logform/pull/212
|
||||
and https://github.com/winstonjs/logform/pull/237
|
||||
* Bump @babel/preset-env from 7.18.6 to 7.20.2 by @dependabot in https://github.com/winstonjs/logform/pull/217
|
||||
and https://github.com/winstonjs/logform/pull/225
|
||||
* Bump eslint from 8.19.0 to 8.33.0 by @dependabot in https://github.com/winstonjs/logform/pull/215
|
||||
and https://github.com/winstonjs/logform/pull/241
|
||||
* Bump mocha from 10.0.0 to 10.2.0 by @dependabot in https://github.com/winstonjs/logform/pull/218
|
||||
and https://github.com/winstonjs/logform/pull/232
|
||||
* Bump safe-stable-stringify from 2.3.1 to 2.4.2 by @dependabot in https://github.com/winstonjs/logform/pull/206
|
||||
and https://github.com/winstonjs/logform/pull/235
|
||||
|
||||
### [2.4.2](https://github.com/winstonjs/logform/compare/v2.4.1...v2.4.2)
|
||||
**2022/07/05**
|
||||
## Bugfixes
|
||||
This patch-level release includes a fix for a crash on attempt to uncolorize Symbol.
|
||||
Thanks to @Alexsey for that first contribution in https://github.com/winstonjs/logform/pull/188.
|
||||
|
||||
## Maintainability updates:
|
||||
Line break styles were changed to be LF (instead of CRLF) more consistently so that linter warnings
|
||||
aren't drowned out by notes about that.
|
||||
|
||||
## Dependency updates by @dependabot
|
||||
* @babel/cli from 7.17.10 to 7.18.6 in https://github.com/winstonjs/logform/pull/187
|
||||
* @babel/core from 7.18.5 to 7.18.6 in https://github.com/winstonjs/logform/pull/185
|
||||
* @babel/preset-env from 7.18.2 to 7.18.6 in https://github.com/winstonjs/logform/pull/184
|
||||
* eslint from 8.18.0 to 8.19.0 in https://github.com/winstonjs/logform/pull/186
|
||||
|
||||
### 2.4.1
|
||||
**2022/06/21**
|
||||
|
||||
- [#178] Change TransformableInfo message prop to any: Loosening types to fix #172 (thanks, @gregbair!)
|
||||
- [#149] Adopted issue templates for reporting issues, affects GitHub project management only (thanks, @maverick1872!)
|
||||
- Updated dependencies, from dependabot
|
||||
|
||||
### 2.4.0
|
||||
**2022/02/12**
|
||||
|
||||
- Updated all dependencies
|
||||
- [#135] Use CLI levels (not NPM levels) in `CliFormat` (this was likely a typo originally)
|
||||
- [#134] Expose `safe-stable-stringify` 2.x options as parameters in `JsonOptions`
|
||||
|
||||
### 2.3.2
|
||||
**2022/01/09**
|
||||
|
||||
This update, which also used up version number 2.3.1, pinned the version of the `colors` dependency
|
||||
due to vandalism by a developer of that package, as noted [here](https://www.bleepingcomputer.com/news/security/dev-corrupts-npm-libs-colors-and-faker-breaking-thousands-of-apps/).
|
||||
[As discussed in the `winston` package](https://github.com/winstonjs/winston/issues/2011), all users should update to this (or a later version, should one exist) ASAP.
|
||||
|
||||
### 2.3.0
|
||||
**2021/09/21**
|
||||
|
||||
- Update dependencies
|
||||
- Removing some superfluous semicolons & commas lint
|
||||
- Avoid dynamic requires [#117]
|
||||
- Replace JSON stringify library "fast-safe-stringify" by "safe-stable-stringify" [#98]
|
||||
- More correctly format errors even if the “message” property is enumerable [#101]
|
||||
- Fix errors and ms export for browsers [#106]
|
||||
|
||||
### 2.2.0
|
||||
**2020/06/21**
|
||||
|
||||
- [#90], [#91] Add option for using stable stringify when formatting as JSON.
|
||||
- [#84] Add replacer for BigInt on JSON formatter.
|
||||
- [#79] Timestamp format type definitions can accept functions.
|
||||
- Update dependencies and fix most of the oustanding npm audit notices.
|
||||
|
||||
### 2.1.2
|
||||
**2019/01/31**
|
||||
|
||||
- [#74] Remove all internal symbols before invoking `util.inspect`.
|
||||
- Related to [#31].
|
||||
|
||||
### 2.1.1
|
||||
**2019/01/29**
|
||||
|
||||
- [#71] Bump logform to be consistent with winston.
|
||||
- Fixes https://github.com/winstonjs/winston/issues/1584
|
||||
|
||||
### 2.1.0
|
||||
**2019/01/07**
|
||||
|
||||
- [#59], [#68], [#69] Add error normalizing format.
|
||||
- [#65] When MESSAGE symbol has a value and `{ all: true }` is set, colorize the entire serialized message.
|
||||
|
||||
### 2.0.0
|
||||
**2018/12/23**
|
||||
|
||||
- **BREAKING** [#57] Try better fix for [winston#1485]. See:
|
||||
[New `splat` behavior`](#new-splat-behavior) below.
|
||||
- [#54] Fix typo in `README.md`
|
||||
- [#55] Strip info[LEVEL] in prettyPrint. Fixes [#31].
|
||||
- [#56] Document built-in formats.
|
||||
- [#64] Add TypeScript definitions for all format options.
|
||||
Relates to [#9] and [#48].
|
||||
|
||||
#### New `splat` behavior
|
||||
|
||||
Previously `splat` would have added a `meta` property for any additional
|
||||
`info[SPLAT]` beyond the expected number of tokens.
|
||||
|
||||
**As of `logform@2.0.0`,** `format.splat` assumes additional splat paramters
|
||||
(aka "metas") are objects and merges enumerable properties into the `info`.
|
||||
e.g.
|
||||
|
||||
``` js
|
||||
const { format } = require('logform');
|
||||
const { splat } = format;
|
||||
const { MESSAGE, LEVEL, SPLAT } = require('triple-beam');
|
||||
|
||||
console.log(
|
||||
// Expects two tokens, but three splat parameters provided.
|
||||
splat().transform({
|
||||
level: 'info',
|
||||
message: 'Let us %s for %j',
|
||||
[LEVEL]: 'info',
|
||||
[MESSAGE]: 'Let us %s for %j',
|
||||
[SPLAT]: ['objects', { label: 'sure' }, { thisIsMeta: 'wut' }]
|
||||
})
|
||||
);
|
||||
|
||||
// logform@1.x behavior:
|
||||
// Added "meta" property.
|
||||
//
|
||||
// { level: 'info',
|
||||
// message: 'Let us objects for {"label":"sure"}',
|
||||
// meta: { thisIsMeta: 'wut' },
|
||||
// [Symbol(level)]: 'info',
|
||||
// [Symbol(message)]: 'Let us %s for %j',
|
||||
// [Symbol(splat)]: [ 'objects', { label: 'sure' } ] }
|
||||
|
||||
// logform@2.x behavior:
|
||||
// Enumerable properties assigned into `info`.
|
||||
//
|
||||
// { level: 'info',
|
||||
// message: 'Let us objects for {"label":"sure"}',
|
||||
// thisIsMeta: 'wut',
|
||||
// [Symbol(level)]: 'info',
|
||||
// [Symbol(message)]: 'Let us %s for %j',
|
||||
// [Symbol(splat)]: [ 'objects', { label: 'sure' } ] }
|
||||
```
|
||||
|
||||
The reason for this change is to be consistent with how `winston` itself
|
||||
handles `meta` objects in its variable-arity conventions.
|
||||
|
||||
**BE ADVISED** previous "metas" that _were not objects_ will very likely lead
|
||||
to odd behavior. e.g.
|
||||
|
||||
``` js
|
||||
const { format } = require('logform');
|
||||
const { splat } = format;
|
||||
const { MESSAGE, LEVEL, SPLAT } = require('triple-beam');
|
||||
|
||||
console.log(
|
||||
// Expects two tokens, but three splat parameters provided.
|
||||
splat().transform({
|
||||
level: 'info',
|
||||
message: 'Let us %s for %j',
|
||||
[LEVEL]: 'info',
|
||||
[MESSAGE]: 'Let us %s for %j',
|
||||
// !!NOTICE!! Additional parameters are a string and an Array
|
||||
[SPLAT]: ['objects', { label: 'sure' }, 'lol', ['ok', 'why']]
|
||||
})
|
||||
);
|
||||
|
||||
// logform@1.x behavior:
|
||||
// Added "meta" property.
|
||||
//
|
||||
// { level: 'info',
|
||||
// message: 'Let us objects for {"label":"sure"}',
|
||||
// meta: ['lol', ['ok', 'why']],
|
||||
// [Symbol(level)]: 'info',
|
||||
// [Symbol(message)]: 'Let us %s for %j',
|
||||
// [Symbol(splat)]: [ 'objects', { label: 'sure' } ] }
|
||||
|
||||
// logform@2.x behavior: Enumerable properties assigned into `info`.
|
||||
// **Strings and Arrays only have NUMERIC enumerable properties!**
|
||||
//
|
||||
// { '0': 'ok',
|
||||
// '1': 'why',
|
||||
// '2': 'l',
|
||||
// level: 'info',
|
||||
// message: 'Let us objects for {"label":"sure"}',
|
||||
// [Symbol(level)]: 'info',
|
||||
// [Symbol(message)]: 'Let us %s for %j',
|
||||
// [Symbol(splat)]: [ 'objects', { label: 'sure' } ] }
|
||||
```
|
||||
|
||||
### 1.10.0
|
||||
**2018/09/17**
|
||||
|
||||
- [#52] Add types field in package.json.
|
||||
- [#46], [#49] Changes for splat when there are no tokens present and no splat present.
|
||||
- [#47], [#53] Expose transpiled code for Browser-only scenarios.
|
||||
|
||||
### 1.9.1
|
||||
**2018/06/26**
|
||||
|
||||
- [#39] Don't break when there are % placeholders but no values.
|
||||
- [#42] Only set `meta` when non-zero additional `SPLAT` arguments are
|
||||
provided. (Fixes [winstonjs/winston#1358]).
|
||||
|
||||
### 1.9.0
|
||||
**2018/06/12**
|
||||
|
||||
- [#38] Migrate functionality from winston Logger to splat format.
|
||||
- [#37] Match expectations from `winston@2.x` for padLevels. Create a correct `Cli` format with initial state. (Fixes [#36]).
|
||||
|
||||
### 1.8.0
|
||||
**2018/06/11**
|
||||
|
||||
- [#35] Use `fast-safe-stringify` for perf and to support circular refs.
|
||||
- [#34] Colorize level symbol.
|
||||
|
||||
### 1.7.0
|
||||
**2018/05/24**
|
||||
|
||||
- [#28] Use more es6-features across the board.
|
||||
- [#30] Fix combine return value.
|
||||
- [#29] Add metadata function to format namespace.
|
||||
|
||||
### 1.6.0
|
||||
**2018/04/25**
|
||||
|
||||
- [#25] Implement padLevels format.
|
||||
- [#26] Update `dependencies` and add `node@10` to the travis build of the project.
|
||||
- [#27] Refactor logform to use triple-beam.
|
||||
|
||||
### 1.5.0
|
||||
**2018/04/22**
|
||||
|
||||
- [#23], (@ChrisAlderson) Add ms format to support '+N ms' format. Fixes #20.
|
||||
- [#24], (@aneilbaboo) Fix `webpack` warnings.
|
||||
- Add `.travis.yml`.
|
||||
|
||||
### 1.4.2
|
||||
**2018/04/19**
|
||||
|
||||
- [#22], (@Jasu) Fix compilation on Babel 6.
|
||||
|
||||
### 1.4.1
|
||||
**2018/04/06**
|
||||
|
||||
- [#21], (@dabh) Add tsconfig.json. Fixes #19.
|
||||
|
||||
### 1.4.0
|
||||
**2018/03/23**
|
||||
|
||||
- [#14] @iamkirkbater Added Initial Metadata Support.
|
||||
- Correct JSDoc for printf.js. Fixes #10.
|
||||
|
||||
### 1.3.0
|
||||
**2018/03/16**
|
||||
|
||||
- [#18] Expose browser.js for rollup and the like. Fixes [#5].
|
||||
- [#13] @dabh Use new version of colors.
|
||||
- [#15] @dabh Add Typescript typings (ported from DefinitelyTyped).
|
||||
- [#17], [#16] Fix error messages other typos.
|
||||
|
||||
### 1.2.2
|
||||
**2017/12/05**
|
||||
|
||||
- [#4], [#11] Fix timestamp and replace `date-fns` with `fecha` (with test cases) [`@ChrisAlderson`].
|
||||
|
||||
### 1.2.1
|
||||
**2017/10/01**
|
||||
|
||||
- [#3] Strip `info.splat` in `format.simple` to avoid double inclusion.
|
||||
|
||||
### 1.2.0
|
||||
**2017/09/30**
|
||||
|
||||
- Transition from `info.raw` to `info[Symbol.for('message')]`.
|
||||
- Finish `README.md` except for full list of all built-in formats.
|
||||
- 100% coverage for everything except for `{ align, cli, padLevels }`.
|
||||
|
||||
### 1.1.0
|
||||
**2017/09/29**
|
||||
|
||||
- [#2] Add baseline expected formats that were previously exposed as options to `common.log` in `winston@2.x` and below.
|
||||
- [#2] Introduce `format.combine` to remove inconsistency in behavior between `format(fn0)` and `format(fn0, ...moreFns)`.
|
||||
- [#2] `README.md` now covers all of the basics for `logform`.
|
||||
|
||||
### 1.0.0
|
||||
**2017/09/26**
|
||||
|
||||
- Initial release.
|
||||
|
||||
[winstonjs/winston#1358]: https://github.com/winstonjs/winston/issues/1358
|
||||
653
unified-ai-platform/node_modules/logform/README.md
generated
vendored
Normal file
653
unified-ai-platform/node_modules/logform/README.md
generated
vendored
Normal file
@@ -0,0 +1,653 @@
|
||||
# logform
|
||||
|
||||
A mutable object-based log format designed for chaining & objectMode streams.
|
||||
|
||||
``` js
|
||||
const { format } = require('logform');
|
||||
|
||||
const alignedWithColorsAndTime = format.combine(
|
||||
format.colorize(),
|
||||
format.timestamp(),
|
||||
format.align(),
|
||||
format.printf(info => `${info.timestamp} ${info.level}: ${info.message}`)
|
||||
);
|
||||
```
|
||||
|
||||
- [`info` Objects](#info-objects)
|
||||
- [Understanding formats](#understanding-formats)
|
||||
- [Combining formats](#combining-formats)
|
||||
- [Filtering `info` objects](#filtering-info-objects)
|
||||
- [Formats](#formats)
|
||||
- [Align](#align)
|
||||
- [CLI](#cli)
|
||||
- [Colorize](#colorize)
|
||||
- [Combine](#combine)
|
||||
- [Errors](#errors)
|
||||
- [JSON](#json)
|
||||
- [Label](#label)
|
||||
- [Logstash](#logstash)
|
||||
- [Metadata](#metadata)
|
||||
- [PadLevels](#padlevels)
|
||||
- [PrettyPrint](#prettyprint)
|
||||
- [Printf](#printf)
|
||||
- [Simple](#simple)
|
||||
- [Splat](#splat)
|
||||
- [Timestamp](#timestamp)
|
||||
- [Uncolorize](#uncolorize)
|
||||
|
||||
## `info` Objects
|
||||
|
||||
The `info` parameter provided to a given format represents a single log
|
||||
message. The object itself is mutable. Every `info` must have at least the
|
||||
`level` and `message` properties:
|
||||
|
||||
``` js
|
||||
const info = {
|
||||
level: 'info', // Level of the logging message
|
||||
message: 'Hey! Log something?' // Descriptive message being logged.
|
||||
}
|
||||
```
|
||||
|
||||
Properties **besides level and message** are considered as "`meta`". i.e.:
|
||||
|
||||
``` js
|
||||
const { level, message, ...meta } = info;
|
||||
```
|
||||
|
||||
Several of the formats in `logform` itself add additional properties:
|
||||
|
||||
| Property | Format added by | Description |
|
||||
| ----------- | --------------- | ----------- |
|
||||
| `splat` | `splat()` | String interpolation splat for `%d %s`-style messages. |
|
||||
| `timestamp` | `timestamp()` | timestamp the message was received. |
|
||||
| `label` | `label()` | Custom label associated with each message. |
|
||||
| `ms` | `ms()` | Number of milliseconds since the previous log message. |
|
||||
|
||||
As a consumer you may add whatever properties you wish – _internal state is
|
||||
maintained by `Symbol` properties:_
|
||||
|
||||
- `Symbol.for('level')` _**(READ-ONLY)**:_ equal to `level` property.
|
||||
**Is treated as immutable by all code.**
|
||||
- `Symbol.for('message'):` complete string message set by "finalizing formats":
|
||||
- `json`
|
||||
- `logstash`
|
||||
- `printf`
|
||||
- `prettyPrint`
|
||||
- `simple`
|
||||
- `Symbol.for('splat')`: additional string interpolation arguments. _Used
|
||||
exclusively by `splat()` format._
|
||||
|
||||
These Symbols are stored in another package: `triple-beam` so that all
|
||||
consumers of `logform` can have the same Symbol reference. i.e.:
|
||||
|
||||
``` js
|
||||
const { LEVEL, MESSAGE, SPLAT } = require('triple-beam');
|
||||
|
||||
console.log(LEVEL === Symbol.for('level'));
|
||||
// true
|
||||
|
||||
console.log(MESSAGE === Symbol.for('message'));
|
||||
// true
|
||||
|
||||
console.log(SPLAT === Symbol.for('splat'));
|
||||
// true
|
||||
```
|
||||
|
||||
## Understanding formats
|
||||
|
||||
Formats are prototypal objects (i.e. class instances) that define a single method: `transform(info, opts)` and return the mutated `info`
|
||||
|
||||
- `info`: an object representing the log message.
|
||||
- `opts`: setting specific to the current instance of the format.
|
||||
|
||||
They are expected to return one of two things:
|
||||
|
||||
- **An `info` Object** representing the modified `info` argument. Object references need not be preserved if immutability is preferred. All current built-in formats consider `info` mutable, but [immutablejs] is being considered for future releases.
|
||||
- **A falsey value** indicating that the `info` argument should be ignored by the caller. (See: [Filtering `info` Objects](#filtering-info-objects)) below.
|
||||
|
||||
`logform.format` is designed to be as simple as possible. To define a new format simple pass it a `transform(info, opts)` function to get a new `Format`.
|
||||
|
||||
The named `Format` returned can be used to create as many copies of the given `Format` as desired:
|
||||
|
||||
``` js
|
||||
const { format } = require('logform');
|
||||
|
||||
const volume = format((info, opts) => {
|
||||
if (opts.yell) {
|
||||
info.message = info.message.toUpperCase();
|
||||
} else if (opts.whisper) {
|
||||
info.message = info.message.toLowerCase();
|
||||
}
|
||||
|
||||
return info;
|
||||
});
|
||||
|
||||
// `volume` is now a function that returns instances of the format.
|
||||
const scream = volume({ yell: true });
|
||||
console.dir(scream.transform({
|
||||
level: 'info',
|
||||
message: `sorry for making you YELL in your head!`
|
||||
}, scream.options));
|
||||
// {
|
||||
// level: 'info'
|
||||
// message: 'SORRY FOR MAKING YOU YELL IN YOUR HEAD!'
|
||||
// }
|
||||
|
||||
// `volume` can be used multiple times to create different formats.
|
||||
const whisper = volume({ whisper: true });
|
||||
console.dir(whisper.transform({
|
||||
level: 'info',
|
||||
message: `WHY ARE THEY MAKING US YELL SO MUCH!`
|
||||
}), whisper.options);
|
||||
// {
|
||||
// level: 'info'
|
||||
// message: 'why are they making us yell so much!'
|
||||
// }
|
||||
```
|
||||
|
||||
### Combining formats
|
||||
|
||||
Any number of formats may be combined into a single format using `format.combine`. Since `format.combine` takes no `opts`, as a convenience it returns pre-created instance of the combined format.
|
||||
|
||||
``` js
|
||||
const { format } = require('logform');
|
||||
const { combine, timestamp, label } = format;
|
||||
|
||||
const labelTimestamp = combine(
|
||||
label({ label: 'right meow!' }),
|
||||
timestamp()
|
||||
);
|
||||
|
||||
const info = labelTimestamp.transform({
|
||||
level: 'info',
|
||||
message: 'What time is the testing at?'
|
||||
});
|
||||
|
||||
console.dir(info);
|
||||
// { level: 'info',
|
||||
// message: 'What time is the testing at?',
|
||||
// label: 'right meow!',
|
||||
// timestamp: '2017-09-30T03:57:26.875Z' }
|
||||
```
|
||||
|
||||
### Filtering `info` Objects
|
||||
|
||||
If you wish to filter out a given `info` Object completely then simply return a falsey value.
|
||||
|
||||
``` js
|
||||
const ignorePrivate = format((info, opts) => {
|
||||
if (info.private) { return false; }
|
||||
return info;
|
||||
});
|
||||
|
||||
console.dir(ignorePrivate.transform({
|
||||
level: 'error',
|
||||
message: 'Public error to share'
|
||||
}));
|
||||
// { level: 'error', message: 'Public error to share' }
|
||||
|
||||
console.dir(ignorePrivate.transform({
|
||||
level: 'error',
|
||||
private: true,
|
||||
message: 'This is super secret - hide it.'
|
||||
}));
|
||||
// false
|
||||
```
|
||||
|
||||
Use of `format.combine` will respect any falsey values return and stop evaluation of later formats in the series. For example:
|
||||
|
||||
``` js
|
||||
const { format } = require('logform');
|
||||
const { combine, timestamp, label } = format;
|
||||
|
||||
const willNeverThrow = format.combine(
|
||||
format(info => { return false })(), // Ignores everything
|
||||
format(info => { throw new Error('Never reached') })()
|
||||
);
|
||||
|
||||
console.dir(willNeverThrow.transform({
|
||||
level: 'info',
|
||||
message: 'wow such testing'
|
||||
}))
|
||||
```
|
||||
|
||||
## Formats
|
||||
|
||||
### Align
|
||||
|
||||
The `align` format adds a `\t` delimiter before the message to align it in the same place.
|
||||
|
||||
```js
|
||||
const { format } = require('logform');
|
||||
|
||||
const alignFormat = format.align();
|
||||
|
||||
const info = alignFormat.transform({
|
||||
level: 'info',
|
||||
message: 'my message'
|
||||
});
|
||||
|
||||
console.log(info);
|
||||
// { level: 'info', message: '\tmy message' }
|
||||
```
|
||||
|
||||
This was previously exposed as `{ align: true }` in `winston < 3.0.0`.
|
||||
|
||||
### CLI
|
||||
|
||||
The `cli` format is a combination of the `colorize` and the `padLevels` formats. It turns a log `info` object into the same format previously available in `winston.cli()` in `winston < 3.0.0`.
|
||||
|
||||
```js
|
||||
const { format } = require('logform');
|
||||
const LEVEL = Symbol.for('level');
|
||||
|
||||
const cliFormat = format.cli({ colors: { info: 'blue' }});
|
||||
|
||||
const info = cliFormat.transform({
|
||||
[LEVEL]: 'info',
|
||||
level: 'info',
|
||||
message: 'my message'
|
||||
}, { all: true });
|
||||
|
||||
console.log(info);
|
||||
// { level: '\u001b[34minfo\u001b[39m',
|
||||
// message: '\u001b[34m my message\u001b[39m',
|
||||
// [Symbol(level)]: 'info',
|
||||
// [Symbol(message)]:
|
||||
// '\u001b[34minfo\u001b[39m:\u001b[34m my message\u001b[39m' }
|
||||
```
|
||||
|
||||
### Colorize
|
||||
|
||||
The `colorize` format adds different colors depending on the log level to the message and/or level.
|
||||
It accepts the following options:
|
||||
|
||||
* **level**: If set to `true` the color will be applied to the `level`.
|
||||
* **all**: If set to `true` the color will be applied to the `message` and `level`.
|
||||
* **message**: If set to `true` the color will be applied to the `message`.
|
||||
* **colors**: An object containing the colors for the log levels. For example: `{ info: 'blue', error: 'red' }`
|
||||
|
||||
```js
|
||||
const { format } = require('logform');
|
||||
const LEVEL = Symbol.for('level');
|
||||
|
||||
const colorizeFormat = format.colorize({ colors: { info: 'blue' }});
|
||||
|
||||
const info = colorizeFormat.transform({
|
||||
[LEVEL]: 'info',
|
||||
level: 'info',
|
||||
message: 'my message'
|
||||
}, { all: true });
|
||||
|
||||
console.log(info);
|
||||
// { level: '\u001b[34minfo\u001b[39m',
|
||||
// message: '\u001b[34mmy message\u001b[39m',
|
||||
// [Symbol(level)]: 'info' }
|
||||
```
|
||||
|
||||
This was previously exposed as `{ colorize: true }` to transports in `winston < 3.0.0`.
|
||||
|
||||
### Combine
|
||||
|
||||
The `combine` Format allows to combine multiple formats:
|
||||
|
||||
```js
|
||||
const { format } = require('logform');
|
||||
const { combine, timestamp, json } = format;
|
||||
|
||||
const jsonWithTimestamp = combine(
|
||||
timestamp(),
|
||||
json()
|
||||
);
|
||||
|
||||
const info = jsonWithTimestamp.transform({
|
||||
level: 'info',
|
||||
message: 'my message'
|
||||
});
|
||||
|
||||
console.log(info);
|
||||
// { level: 'info',
|
||||
// message: 'my message',
|
||||
// timestamp: '2018-10-02T15:03:14.230Z',
|
||||
// [Symbol(message)]:
|
||||
// '{"level":"info","message":"my message","timestamp":"2018-10-02T15:03:14.230Z"}' }
|
||||
```
|
||||
|
||||
### Errors
|
||||
|
||||
The `errors` format allows you to pass in an instance of a JavaScript `Error`
|
||||
directly to the logger. It allows you to specify whether not to include the
|
||||
stack-trace.
|
||||
|
||||
```js
|
||||
const { format } = require('logform');
|
||||
const { errors } = format;
|
||||
|
||||
const errorsFormat = errors({ stack: true })
|
||||
|
||||
const info = errorsFormat.transform(new Error('Oh no!'));
|
||||
|
||||
console.log(info);
|
||||
// Error: Oh no!
|
||||
// at repl:1:13
|
||||
// at ContextifyScript.Script.runInThisContext (vm.js:50:33)
|
||||
// at REPLServer.defaultEval (repl.js:240:29)
|
||||
// at bound (domain.js:301:14)
|
||||
// at REPLServer.runBound [as eval] (domain.js:314:12)
|
||||
// at REPLServer.onLine (repl.js:468:10)
|
||||
// at emitOne (events.js:121:20)
|
||||
// at REPLServer.emit (events.js:211:7)
|
||||
// at REPLServer.Interface._onLine (readline.js:282:10)
|
||||
// at REPLServer.Interface._line (readline.js:631:8)
|
||||
```
|
||||
|
||||
It will also handle `{ message }` properties as `Error` instances:
|
||||
|
||||
```js
|
||||
const { format } = require('logform');
|
||||
const { errors } = format;
|
||||
|
||||
const errorsFormat = errors({ stack: true })
|
||||
|
||||
const info = errorsFormat.transform({
|
||||
message: new Error('Oh no!')
|
||||
});
|
||||
|
||||
console.log(info);
|
||||
// Error: Oh no!
|
||||
// at repl:1:13
|
||||
// at ContextifyScript.Script.runInThisContext (vm.js:50:33)
|
||||
// at REPLServer.defaultEval (repl.js:240:29)
|
||||
// at bound (domain.js:301:14)
|
||||
// at REPLServer.runBound [as eval] (domain.js:314:12)
|
||||
// at REPLServer.onLine (repl.js:468:10)
|
||||
// at emitOne (events.js:121:20)
|
||||
// at REPLServer.emit (events.js:211:7)
|
||||
// at REPLServer.Interface._onLine (readline.js:282:10)
|
||||
// at REPLServer.Interface._line (readline.js:631:8)
|
||||
```
|
||||
|
||||
### JSON
|
||||
|
||||
The `json` format uses `safe-stable-stringify` to finalize the message.
|
||||
It accepts the following options:
|
||||
|
||||
* **replacer**: A function that influences how the `info` is stringified.
|
||||
* **space**: The number of white space used to format the json.
|
||||
|
||||
```js
|
||||
const { format } = require('logform');
|
||||
|
||||
const jsonFormat = format.json();
|
||||
|
||||
const info = jsonFormat.transform({
|
||||
level: 'info',
|
||||
message: 'my message',
|
||||
});
|
||||
console.log(info);
|
||||
// { level: 'info',
|
||||
// message: 'my message',
|
||||
// [Symbol(message)]: '{"level":"info","message":"my message"}' }
|
||||
```
|
||||
|
||||
This was previously exposed as `{ json: true }` to transports in `winston < 3.0.0`.
|
||||
|
||||
### Label
|
||||
|
||||
The `label` format adds the specified `label` before the message or adds it to the `info` object.
|
||||
It accepts the following options:
|
||||
|
||||
* **label**: A label to be added before the message.
|
||||
* **message**: If set to `true` the `label` will be added to `info.message`. If set to `false` the `label` will be added as `info.label`.
|
||||
|
||||
```js
|
||||
const { format } = require('logform');
|
||||
|
||||
const labelFormat = format.label();
|
||||
|
||||
const info = labelFormat.transform({
|
||||
level: 'info',
|
||||
message: 'my message'
|
||||
}, { label: 'my label', message: true });
|
||||
|
||||
console.log(info);
|
||||
// { level: 'info', message: '[my label] my message' }
|
||||
```
|
||||
|
||||
This was previously exposed as `{ label: 'my label' }` to transports in `winston < 3.0.0`.
|
||||
|
||||
### Logstash
|
||||
|
||||
The `logstash` Format turns a log `info` object into pure JSON with the appropriate logstash options.
|
||||
|
||||
```js
|
||||
const { format } = require('logform');
|
||||
const { logstash, combine, timestamp } = format;
|
||||
|
||||
const logstashFormat = combine(
|
||||
timestamp(),
|
||||
logstash()
|
||||
);
|
||||
|
||||
const info = logstashFormat.transform({
|
||||
level: 'info',
|
||||
message: 'my message'
|
||||
});
|
||||
|
||||
console.log(info);
|
||||
// { level: 'info',
|
||||
// [Symbol(message)]:
|
||||
// '{"@message":"my message","@timestamp":"2018-10-02T11:04:52.915Z","@fields":{"level":"info"}}' }
|
||||
```
|
||||
|
||||
This was previously exposed as `{ logstash: true }` to transports in `winston < 3.0.0`.
|
||||
|
||||
### Metadata
|
||||
|
||||
The `metadata` format adds a metadata object to collect extraneous data, similar to the metadata object in winston 2.x.
|
||||
It accepts the following options:
|
||||
|
||||
* **key**: The name of the key used for the metadata object. Defaults to `metadata`.
|
||||
* **fillExcept**: An array of keys that should not be added to the metadata object.
|
||||
* **fillWith**: An array of keys that will be added to the metadata object.
|
||||
|
||||
```js
|
||||
const { format } = require('logform');
|
||||
|
||||
const metadataFormat = format.metadata();
|
||||
|
||||
const info = metadataFormat.transform({
|
||||
level: 'info',
|
||||
message: 'my message',
|
||||
meta: 42
|
||||
});
|
||||
|
||||
console.log(info);
|
||||
// { level: 'info', message: 'my message', metadata: { meta: 42 } }
|
||||
```
|
||||
|
||||
### PadLevels
|
||||
|
||||
The `padLevels` format pads levels to be the same length.
|
||||
|
||||
```js
|
||||
const { format } = require('logform');
|
||||
const LEVEL = Symbol.for('level');
|
||||
|
||||
const padLevelsFormat = format.padLevels();
|
||||
|
||||
const info = padLevelsFormat.transform({
|
||||
[LEVEL]: 'info',
|
||||
message: 'my message'
|
||||
});
|
||||
|
||||
console.log(info);
|
||||
// { message: ' my message', [Symbol(level)]: 'info' }
|
||||
```
|
||||
|
||||
This was previously exposed as `{ padLevels: true }` to transports in `winston < 3.0.0`.
|
||||
|
||||
### PrettyPrint
|
||||
|
||||
The `prettyPrint` format finalizes the message using `util.inspect`.
|
||||
It accepts the following options:
|
||||
|
||||
* **depth**: A `number` that specifies the maximum depth of the `info` object being stringified by `util.inspect`. Defaults to `2`.
|
||||
* **colorize**: Colorizes the message if set to `true`. Defaults to `false`.
|
||||
|
||||
The `prettyPrint` format should not be used in production because it may impact performance negatively and block the event loop.
|
||||
|
||||
> **NOTE:** the `LEVEL`, `MESSAGE`, and `SPLAT` symbols are stripped from the
|
||||
> output message _by design._
|
||||
|
||||
This was previously exposed as `{ prettyPrint: true }` to transports in `winston < 3.0.0`.
|
||||
|
||||
```js
|
||||
const { format } = require('logform');
|
||||
|
||||
const prettyPrintFormat = format.prettyPrint();
|
||||
|
||||
const info = prettyPrintFormat.transform({
|
||||
[LEVEL]: 'info',
|
||||
level: 'info',
|
||||
message: 'my message'
|
||||
});
|
||||
|
||||
console.log(info);
|
||||
// { level: 'info',
|
||||
// message: 'my message',
|
||||
// [Symbol(level)]: 'info',
|
||||
// [Symbol(message)]: '{ level: \'info\', message: \'my message\' }' }
|
||||
```
|
||||
|
||||
### Printf
|
||||
|
||||
The `printf` format allows to create a custom logging format:
|
||||
|
||||
```js
|
||||
const { format } = require('logform');
|
||||
|
||||
const myFormat = format.printf((info) => {
|
||||
return `${info.level} ${info.message}`;
|
||||
})
|
||||
|
||||
const info = myFormat.transform({
|
||||
level: 'info',
|
||||
message: 'my message'
|
||||
});
|
||||
|
||||
console.log(info);
|
||||
// { level: 'info',
|
||||
// message: 'my message',
|
||||
// [Symbol(message)]: 'info my message' }
|
||||
```
|
||||
|
||||
### Simple
|
||||
|
||||
The `simple` format finalizes the `info` object using the format: `level: message stringifiedRest`.
|
||||
```js
|
||||
const { format } = require('logform');
|
||||
const MESSAGE = Symbol.for('message');
|
||||
|
||||
const simpleFormat = format.simple();
|
||||
|
||||
const info = simpleFormat.transform({
|
||||
level: 'info',
|
||||
message: 'my message',
|
||||
number: 123
|
||||
});
|
||||
console.log(info[MESSAGE]);
|
||||
// info: my message {number:123}
|
||||
```
|
||||
|
||||
### Splat
|
||||
|
||||
The `splat` format transforms the message by using `util.format` to complete any `info.message` provided it has string interpolation tokens.
|
||||
|
||||
```js
|
||||
const { format } = require('logform');
|
||||
|
||||
const splatFormat = format.splat();
|
||||
|
||||
const info = splatFormat.transform({
|
||||
level: 'info',
|
||||
message: 'my message %s',
|
||||
splat: ['test']
|
||||
});
|
||||
|
||||
console.log(info);
|
||||
// { level: 'info', message: 'my message test', splat: [ 'test' ] }
|
||||
```
|
||||
|
||||
Any additional splat parameters beyond those needed for the `%` tokens
|
||||
(aka "metas") are assumed to be objects. Their enumerable properties are
|
||||
merged into the `info`.
|
||||
|
||||
```js
|
||||
const { format } = require('logform');
|
||||
|
||||
const splatFormat = format.splat();
|
||||
|
||||
const info = splatFormat.transform({
|
||||
level: 'info',
|
||||
message: 'my message %s',
|
||||
splat: ['test', { thisIsMeta: true }]
|
||||
});
|
||||
|
||||
console.log(info);
|
||||
// { level: 'info',
|
||||
// message: 'my message test',
|
||||
// thisIsMeta: true,
|
||||
// splat: [ 'test' ] }
|
||||
```
|
||||
|
||||
This was previously exposed implicitly in `winston < 3.0.0`.
|
||||
|
||||
### Timestamp
|
||||
|
||||
The `timestamp` format adds a timestamp to the info.
|
||||
It accepts the following options:
|
||||
|
||||
* **format**: Either the format as a string accepted by the [fecha](https://github.com/taylorhakes/fecha) module or a function that returns a formatted date. If no format is provided `new Date().toISOString()` will be used.
|
||||
* **alias**: The name of an alias for the timestamp property, that will be added to the `info` object.
|
||||
|
||||
```js
|
||||
const { format } = require('logform');
|
||||
|
||||
const timestampFormat = format.timestamp();
|
||||
|
||||
const info = timestampFormat.transform({
|
||||
level: 'info',
|
||||
message: 'my message'
|
||||
});
|
||||
|
||||
console.log(info);
|
||||
// { level: 'info',
|
||||
// message: 'my message',
|
||||
// timestamp: '2018-10-02T11:47:02.682Z' }
|
||||
```
|
||||
|
||||
It was previously available in `winston < 3.0.0` as `{ timestamp: true }` and `{ timestamp: function:String }`.
|
||||
|
||||
|
||||
### Uncolorize
|
||||
|
||||
The `uncolorize` format strips colors from `info` objects.
|
||||
It accepts the following options:
|
||||
|
||||
* **level**: Disables the uncolorize format for `info.level` if set to `false`.
|
||||
* **message**: Disables the uncolorize format for `info.message` if set to `false`.
|
||||
* **raw**: Disables the uncolorize format for `info[MESSAGE]` if set to `false`.
|
||||
|
||||
This was previously exposed as `{ stripColors: true }` to transports in `winston < 3.0.0`.
|
||||
|
||||
## Tests
|
||||
|
||||
Tests are written with `mocha`, `assume`, and `nyc`. They can be run with `npm`:
|
||||
|
||||
```
|
||||
npm test
|
||||
```
|
||||
|
||||
##### LICENSE: MIT
|
||||
##### AUTHOR: [Charlie Robbins](https://github.com/indexzero)
|
||||
14
unified-ai-platform/node_modules/logform/align.js
generated
vendored
Normal file
14
unified-ai-platform/node_modules/logform/align.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
'use strict';
|
||||
|
||||
const format = require('./format');
|
||||
|
||||
/*
|
||||
* function align (info)
|
||||
* Returns a new instance of the align Format which adds a `\t`
|
||||
* delimiter before the message to properly align it in the same place.
|
||||
* It was previously { align: true } in winston < 3.0.0
|
||||
*/
|
||||
module.exports = format(info => {
|
||||
info.message = `\t${info.message}`;
|
||||
return info;
|
||||
});
|
||||
38
unified-ai-platform/node_modules/logform/browser.js
generated
vendored
Normal file
38
unified-ai-platform/node_modules/logform/browser.js
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
'use strict';
|
||||
|
||||
/*
|
||||
* @api public
|
||||
* @property {function} format
|
||||
* Both the construction method and set of exposed
|
||||
* formats.
|
||||
*/
|
||||
const format = exports.format = require('././format');
|
||||
|
||||
/*
|
||||
* @api public
|
||||
* @method {function} levels
|
||||
* Registers the specified levels with logform.
|
||||
*/
|
||||
exports.levels = require('././levels');
|
||||
|
||||
//
|
||||
// Setup all transports as eager-loaded exports
|
||||
// so that they are static for the bundlers.
|
||||
//
|
||||
Object.defineProperty(format, 'align', { value: require('./align') });
|
||||
Object.defineProperty(format, 'cli', { value: require('./cli') });
|
||||
Object.defineProperty(format, 'colorize', { value: require('./colorize') });
|
||||
Object.defineProperty(format, 'combine', { value: require('./combine') });
|
||||
Object.defineProperty(format, 'errors', { value: require('./errors') });
|
||||
Object.defineProperty(format, 'json', { value: require('./json') });
|
||||
Object.defineProperty(format, 'label', { value: require('./label') });
|
||||
Object.defineProperty(format, 'logstash', { value: require('./logstash') });
|
||||
Object.defineProperty(format, 'metadata', { value: require('./metadata') });
|
||||
Object.defineProperty(format, 'ms', { value: require('./ms') });
|
||||
Object.defineProperty(format, 'padLevels', { value: require('./pad-levels') });
|
||||
Object.defineProperty(format, 'prettyPrint', { value: require('./pretty-print') });
|
||||
Object.defineProperty(format, 'printf', { value: require('./printf') });
|
||||
Object.defineProperty(format, 'simple', { value: require('./simple') });
|
||||
Object.defineProperty(format, 'splat', { value: require('./splat') });
|
||||
Object.defineProperty(format, 'timestamp', { value: require('./timestamp') });
|
||||
Object.defineProperty(format, 'uncolorize', { value: require('./uncolorize') });
|
||||
52
unified-ai-platform/node_modules/logform/cli.js
generated
vendored
Normal file
52
unified-ai-platform/node_modules/logform/cli.js
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
'use strict';
|
||||
|
||||
const { Colorizer } = require('./colorize');
|
||||
const { Padder } = require('./pad-levels');
|
||||
const { configs, MESSAGE } = require('triple-beam');
|
||||
|
||||
|
||||
/**
|
||||
* Cli format class that handles initial state for a a separate
|
||||
* Colorizer and Padder instance.
|
||||
*/
|
||||
class CliFormat {
|
||||
constructor(opts = {}) {
|
||||
if (!opts.levels) {
|
||||
opts.levels = configs.cli.levels;
|
||||
}
|
||||
|
||||
this.colorizer = new Colorizer(opts);
|
||||
this.padder = new Padder(opts);
|
||||
this.options = opts;
|
||||
}
|
||||
|
||||
/*
|
||||
* function transform (info, opts)
|
||||
* Attempts to both:
|
||||
* 1. Pad the { level }
|
||||
* 2. Colorize the { level, message }
|
||||
* of the given `logform` info object depending on the `opts`.
|
||||
*/
|
||||
transform(info, opts) {
|
||||
this.colorizer.transform(
|
||||
this.padder.transform(info, opts),
|
||||
opts
|
||||
);
|
||||
|
||||
info[MESSAGE] = `${info.level}:${info.message}`;
|
||||
return info;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* function cli (opts)
|
||||
* Returns a new instance of the CLI format that turns a log
|
||||
* `info` object into the same format previously available
|
||||
* in `winston.cli()` in `winston < 3.0.0`.
|
||||
*/
|
||||
module.exports = opts => new CliFormat(opts);
|
||||
|
||||
//
|
||||
// Attach the CliFormat for registration purposes
|
||||
//
|
||||
module.exports.Format = CliFormat;
|
||||
122
unified-ai-platform/node_modules/logform/colorize.js
generated
vendored
Normal file
122
unified-ai-platform/node_modules/logform/colorize.js
generated
vendored
Normal file
@@ -0,0 +1,122 @@
|
||||
'use strict';
|
||||
|
||||
const colors = require('@colors/colors/safe');
|
||||
const { LEVEL, MESSAGE } = require('triple-beam');
|
||||
|
||||
//
|
||||
// Fix colors not appearing in non-tty environments
|
||||
//
|
||||
colors.enabled = true;
|
||||
|
||||
/**
|
||||
* @property {RegExp} hasSpace
|
||||
* Simple regex to check for presence of spaces.
|
||||
*/
|
||||
const hasSpace = /\s+/;
|
||||
|
||||
/*
|
||||
* Colorizer format. Wraps the `level` and/or `message` properties
|
||||
* of the `info` objects with ANSI color codes based on a few options.
|
||||
*/
|
||||
class Colorizer {
|
||||
constructor(opts = {}) {
|
||||
if (opts.colors) {
|
||||
this.addColors(opts.colors);
|
||||
}
|
||||
|
||||
this.options = opts;
|
||||
}
|
||||
|
||||
/*
|
||||
* Adds the colors Object to the set of allColors
|
||||
* known by the Colorizer
|
||||
*
|
||||
* @param {Object} colors Set of color mappings to add.
|
||||
*/
|
||||
static addColors(clrs) {
|
||||
const nextColors = Object.keys(clrs).reduce((acc, level) => {
|
||||
acc[level] = hasSpace.test(clrs[level])
|
||||
? clrs[level].split(hasSpace)
|
||||
: clrs[level];
|
||||
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
Colorizer.allColors = Object.assign({}, Colorizer.allColors || {}, nextColors);
|
||||
return Colorizer.allColors;
|
||||
}
|
||||
|
||||
/*
|
||||
* Adds the colors Object to the set of allColors
|
||||
* known by the Colorizer
|
||||
*
|
||||
* @param {Object} colors Set of color mappings to add.
|
||||
*/
|
||||
addColors(clrs) {
|
||||
return Colorizer.addColors(clrs);
|
||||
}
|
||||
|
||||
/*
|
||||
* function colorize (lookup, level, message)
|
||||
* Performs multi-step colorization using @colors/colors/safe
|
||||
*/
|
||||
colorize(lookup, level, message) {
|
||||
if (typeof message === 'undefined') {
|
||||
message = level;
|
||||
}
|
||||
|
||||
//
|
||||
// If the color for the level is just a string
|
||||
// then attempt to colorize the message with it.
|
||||
//
|
||||
if (!Array.isArray(Colorizer.allColors[lookup])) {
|
||||
return colors[Colorizer.allColors[lookup]](message);
|
||||
}
|
||||
|
||||
//
|
||||
// If it is an Array then iterate over that Array, applying
|
||||
// the colors function for each item.
|
||||
//
|
||||
for (let i = 0, len = Colorizer.allColors[lookup].length; i < len; i++) {
|
||||
message = colors[Colorizer.allColors[lookup][i]](message);
|
||||
}
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
/*
|
||||
* function transform (info, opts)
|
||||
* Attempts to colorize the { level, message } of the given
|
||||
* `logform` info object.
|
||||
*/
|
||||
transform(info, opts) {
|
||||
if (opts.all && typeof info[MESSAGE] === 'string') {
|
||||
info[MESSAGE] = this.colorize(info[LEVEL], info.level, info[MESSAGE]);
|
||||
}
|
||||
|
||||
if (opts.level || opts.all || !opts.message) {
|
||||
info.level = this.colorize(info[LEVEL], info.level);
|
||||
}
|
||||
|
||||
if (opts.all || opts.message) {
|
||||
info.message = this.colorize(info[LEVEL], info.level, info.message);
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* function colorize (info)
|
||||
* Returns a new instance of the colorize Format that applies
|
||||
* level colors to `info` objects. This was previously exposed
|
||||
* as { colorize: true } to transports in `winston < 3.0.0`.
|
||||
*/
|
||||
module.exports = opts => new Colorizer(opts);
|
||||
|
||||
//
|
||||
// Attach the Colorizer for registration purposes
|
||||
//
|
||||
module.exports.Colorizer
|
||||
= module.exports.Format
|
||||
= Colorizer;
|
||||
66
unified-ai-platform/node_modules/logform/combine.js
generated
vendored
Normal file
66
unified-ai-platform/node_modules/logform/combine.js
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
'use strict';
|
||||
|
||||
const format = require('./format');
|
||||
|
||||
/*
|
||||
* function cascade(formats)
|
||||
* Returns a function that invokes the `._format` function in-order
|
||||
* for the specified set of `formats`. In this manner we say that Formats
|
||||
* are "pipe-like", but not a pure pumpify implementation. Since there is no back
|
||||
* pressure we can remove all of the "readable" plumbing in Node streams.
|
||||
*/
|
||||
function cascade(formats) {
|
||||
if (!formats.every(isValidFormat)) {
|
||||
return;
|
||||
}
|
||||
|
||||
return info => {
|
||||
let obj = info;
|
||||
for (let i = 0; i < formats.length; i++) {
|
||||
obj = formats[i].transform(obj, formats[i].options);
|
||||
if (!obj) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
};
|
||||
}
|
||||
|
||||
/*
|
||||
* function isValidFormat(format)
|
||||
* If the format does not define a `transform` function throw an error
|
||||
* with more detailed usage.
|
||||
*/
|
||||
function isValidFormat(fmt) {
|
||||
if (typeof fmt.transform !== 'function') {
|
||||
throw new Error([
|
||||
'No transform function found on format. Did you create a format instance?',
|
||||
'const myFormat = format(formatFn);',
|
||||
'const instance = myFormat();'
|
||||
].join('\n'));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* function combine (info)
|
||||
* Returns a new instance of the combine Format which combines the specified
|
||||
* formats into a new format. This is similar to a pipe-chain in transform streams.
|
||||
* We choose to combine the prototypes this way because there is no back pressure in
|
||||
* an in-memory transform chain.
|
||||
*/
|
||||
module.exports = (...formats) => {
|
||||
const combinedFormat = format(cascade(formats));
|
||||
const instance = combinedFormat();
|
||||
instance.Format = combinedFormat.Format;
|
||||
return instance;
|
||||
};
|
||||
|
||||
//
|
||||
// Export the cascade method for use in cli and other
|
||||
// combined formats that should not be assumed to be
|
||||
// singletons.
|
||||
//
|
||||
module.exports.cascade = cascade;
|
||||
14
unified-ai-platform/node_modules/logform/dist/align.js
generated
vendored
Normal file
14
unified-ai-platform/node_modules/logform/dist/align.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
'use strict';
|
||||
|
||||
var format = require('./format');
|
||||
|
||||
/*
|
||||
* function align (info)
|
||||
* Returns a new instance of the align Format which adds a `\t`
|
||||
* delimiter before the message to properly align it in the same place.
|
||||
* It was previously { align: true } in winston < 3.0.0
|
||||
*/
|
||||
module.exports = format(function (info) {
|
||||
info.message = "\t".concat(info.message);
|
||||
return info;
|
||||
});
|
||||
72
unified-ai-platform/node_modules/logform/dist/browser.js
generated
vendored
Normal file
72
unified-ai-platform/node_modules/logform/dist/browser.js
generated
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
'use strict';
|
||||
|
||||
/*
|
||||
* @api public
|
||||
* @property {function} format
|
||||
* Both the construction method and set of exposed
|
||||
* formats.
|
||||
*/
|
||||
var format = exports.format = require('././format');
|
||||
|
||||
/*
|
||||
* @api public
|
||||
* @method {function} levels
|
||||
* Registers the specified levels with logform.
|
||||
*/
|
||||
exports.levels = require('././levels');
|
||||
|
||||
//
|
||||
// Setup all transports as eager-loaded exports
|
||||
// so that they are static for the bundlers.
|
||||
//
|
||||
Object.defineProperty(format, 'align', {
|
||||
value: require('./align')
|
||||
});
|
||||
Object.defineProperty(format, 'cli', {
|
||||
value: require('./cli')
|
||||
});
|
||||
Object.defineProperty(format, 'colorize', {
|
||||
value: require('./colorize')
|
||||
});
|
||||
Object.defineProperty(format, 'combine', {
|
||||
value: require('./combine')
|
||||
});
|
||||
Object.defineProperty(format, 'errors', {
|
||||
value: require('./errors')
|
||||
});
|
||||
Object.defineProperty(format, 'json', {
|
||||
value: require('./json')
|
||||
});
|
||||
Object.defineProperty(format, 'label', {
|
||||
value: require('./label')
|
||||
});
|
||||
Object.defineProperty(format, 'logstash', {
|
||||
value: require('./logstash')
|
||||
});
|
||||
Object.defineProperty(format, 'metadata', {
|
||||
value: require('./metadata')
|
||||
});
|
||||
Object.defineProperty(format, 'ms', {
|
||||
value: require('./ms')
|
||||
});
|
||||
Object.defineProperty(format, 'padLevels', {
|
||||
value: require('./pad-levels')
|
||||
});
|
||||
Object.defineProperty(format, 'prettyPrint', {
|
||||
value: require('./pretty-print')
|
||||
});
|
||||
Object.defineProperty(format, 'printf', {
|
||||
value: require('./printf')
|
||||
});
|
||||
Object.defineProperty(format, 'simple', {
|
||||
value: require('./simple')
|
||||
});
|
||||
Object.defineProperty(format, 'splat', {
|
||||
value: require('./splat')
|
||||
});
|
||||
Object.defineProperty(format, 'timestamp', {
|
||||
value: require('./timestamp')
|
||||
});
|
||||
Object.defineProperty(format, 'uncolorize', {
|
||||
value: require('./uncolorize')
|
||||
});
|
||||
62
unified-ai-platform/node_modules/logform/dist/cli.js
generated
vendored
Normal file
62
unified-ai-platform/node_modules/logform/dist/cli.js
generated
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
'use strict';
|
||||
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
||||
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
||||
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
var _require = require('./colorize'),
|
||||
Colorizer = _require.Colorizer;
|
||||
var _require2 = require('./pad-levels'),
|
||||
Padder = _require2.Padder;
|
||||
var _require3 = require('triple-beam'),
|
||||
configs = _require3.configs,
|
||||
MESSAGE = _require3.MESSAGE;
|
||||
|
||||
/**
|
||||
* Cli format class that handles initial state for a a separate
|
||||
* Colorizer and Padder instance.
|
||||
*/
|
||||
var CliFormat = /*#__PURE__*/function () {
|
||||
function CliFormat() {
|
||||
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
||||
_classCallCheck(this, CliFormat);
|
||||
if (!opts.levels) {
|
||||
opts.levels = configs.cli.levels;
|
||||
}
|
||||
this.colorizer = new Colorizer(opts);
|
||||
this.padder = new Padder(opts);
|
||||
this.options = opts;
|
||||
}
|
||||
|
||||
/*
|
||||
* function transform (info, opts)
|
||||
* Attempts to both:
|
||||
* 1. Pad the { level }
|
||||
* 2. Colorize the { level, message }
|
||||
* of the given `logform` info object depending on the `opts`.
|
||||
*/
|
||||
return _createClass(CliFormat, [{
|
||||
key: "transform",
|
||||
value: function transform(info, opts) {
|
||||
this.colorizer.transform(this.padder.transform(info, opts), opts);
|
||||
info[MESSAGE] = "".concat(info.level, ":").concat(info.message);
|
||||
return info;
|
||||
}
|
||||
}]);
|
||||
}();
|
||||
/*
|
||||
* function cli (opts)
|
||||
* Returns a new instance of the CLI format that turns a log
|
||||
* `info` object into the same format previously available
|
||||
* in `winston.cli()` in `winston < 3.0.0`.
|
||||
*/
|
||||
module.exports = function (opts) {
|
||||
return new CliFormat(opts);
|
||||
};
|
||||
|
||||
//
|
||||
// Attach the CliFormat for registration purposes
|
||||
//
|
||||
module.exports.Format = CliFormat;
|
||||
131
unified-ai-platform/node_modules/logform/dist/colorize.js
generated
vendored
Normal file
131
unified-ai-platform/node_modules/logform/dist/colorize.js
generated
vendored
Normal file
@@ -0,0 +1,131 @@
|
||||
'use strict';
|
||||
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
||||
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
||||
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
var colors = require('@colors/colors/safe');
|
||||
var _require = require('triple-beam'),
|
||||
LEVEL = _require.LEVEL,
|
||||
MESSAGE = _require.MESSAGE;
|
||||
|
||||
//
|
||||
// Fix colors not appearing in non-tty environments
|
||||
//
|
||||
colors.enabled = true;
|
||||
|
||||
/**
|
||||
* @property {RegExp} hasSpace
|
||||
* Simple regex to check for presence of spaces.
|
||||
*/
|
||||
var hasSpace = /\s+/;
|
||||
|
||||
/*
|
||||
* Colorizer format. Wraps the `level` and/or `message` properties
|
||||
* of the `info` objects with ANSI color codes based on a few options.
|
||||
*/
|
||||
var Colorizer = /*#__PURE__*/function () {
|
||||
function Colorizer() {
|
||||
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
||||
_classCallCheck(this, Colorizer);
|
||||
if (opts.colors) {
|
||||
this.addColors(opts.colors);
|
||||
}
|
||||
this.options = opts;
|
||||
}
|
||||
|
||||
/*
|
||||
* Adds the colors Object to the set of allColors
|
||||
* known by the Colorizer
|
||||
*
|
||||
* @param {Object} colors Set of color mappings to add.
|
||||
*/
|
||||
return _createClass(Colorizer, [{
|
||||
key: "addColors",
|
||||
value:
|
||||
/*
|
||||
* Adds the colors Object to the set of allColors
|
||||
* known by the Colorizer
|
||||
*
|
||||
* @param {Object} colors Set of color mappings to add.
|
||||
*/
|
||||
function addColors(clrs) {
|
||||
return Colorizer.addColors(clrs);
|
||||
}
|
||||
|
||||
/*
|
||||
* function colorize (lookup, level, message)
|
||||
* Performs multi-step colorization using @colors/colors/safe
|
||||
*/
|
||||
}, {
|
||||
key: "colorize",
|
||||
value: function colorize(lookup, level, message) {
|
||||
if (typeof message === 'undefined') {
|
||||
message = level;
|
||||
}
|
||||
|
||||
//
|
||||
// If the color for the level is just a string
|
||||
// then attempt to colorize the message with it.
|
||||
//
|
||||
if (!Array.isArray(Colorizer.allColors[lookup])) {
|
||||
return colors[Colorizer.allColors[lookup]](message);
|
||||
}
|
||||
|
||||
//
|
||||
// If it is an Array then iterate over that Array, applying
|
||||
// the colors function for each item.
|
||||
//
|
||||
for (var i = 0, len = Colorizer.allColors[lookup].length; i < len; i++) {
|
||||
message = colors[Colorizer.allColors[lookup][i]](message);
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
/*
|
||||
* function transform (info, opts)
|
||||
* Attempts to colorize the { level, message } of the given
|
||||
* `logform` info object.
|
||||
*/
|
||||
}, {
|
||||
key: "transform",
|
||||
value: function transform(info, opts) {
|
||||
if (opts.all && typeof info[MESSAGE] === 'string') {
|
||||
info[MESSAGE] = this.colorize(info[LEVEL], info.level, info[MESSAGE]);
|
||||
}
|
||||
if (opts.level || opts.all || !opts.message) {
|
||||
info.level = this.colorize(info[LEVEL], info.level);
|
||||
}
|
||||
if (opts.all || opts.message) {
|
||||
info.message = this.colorize(info[LEVEL], info.level, info.message);
|
||||
}
|
||||
return info;
|
||||
}
|
||||
}], [{
|
||||
key: "addColors",
|
||||
value: function addColors(clrs) {
|
||||
var nextColors = Object.keys(clrs).reduce(function (acc, level) {
|
||||
acc[level] = hasSpace.test(clrs[level]) ? clrs[level].split(hasSpace) : clrs[level];
|
||||
return acc;
|
||||
}, {});
|
||||
Colorizer.allColors = Object.assign({}, Colorizer.allColors || {}, nextColors);
|
||||
return Colorizer.allColors;
|
||||
}
|
||||
}]);
|
||||
}();
|
||||
/*
|
||||
* function colorize (info)
|
||||
* Returns a new instance of the colorize Format that applies
|
||||
* level colors to `info` objects. This was previously exposed
|
||||
* as { colorize: true } to transports in `winston < 3.0.0`.
|
||||
*/
|
||||
module.exports = function (opts) {
|
||||
return new Colorizer(opts);
|
||||
};
|
||||
|
||||
//
|
||||
// Attach the Colorizer for registration purposes
|
||||
//
|
||||
module.exports.Colorizer = module.exports.Format = Colorizer;
|
||||
62
unified-ai-platform/node_modules/logform/dist/combine.js
generated
vendored
Normal file
62
unified-ai-platform/node_modules/logform/dist/combine.js
generated
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
'use strict';
|
||||
|
||||
var format = require('./format');
|
||||
|
||||
/*
|
||||
* function cascade(formats)
|
||||
* Returns a function that invokes the `._format` function in-order
|
||||
* for the specified set of `formats`. In this manner we say that Formats
|
||||
* are "pipe-like", but not a pure pumpify implementation. Since there is no back
|
||||
* pressure we can remove all of the "readable" plumbing in Node streams.
|
||||
*/
|
||||
function cascade(formats) {
|
||||
if (!formats.every(isValidFormat)) {
|
||||
return;
|
||||
}
|
||||
return function (info) {
|
||||
var obj = info;
|
||||
for (var i = 0; i < formats.length; i++) {
|
||||
obj = formats[i].transform(obj, formats[i].options);
|
||||
if (!obj) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
};
|
||||
}
|
||||
|
||||
/*
|
||||
* function isValidFormat(format)
|
||||
* If the format does not define a `transform` function throw an error
|
||||
* with more detailed usage.
|
||||
*/
|
||||
function isValidFormat(fmt) {
|
||||
if (typeof fmt.transform !== 'function') {
|
||||
throw new Error(['No transform function found on format. Did you create a format instance?', 'const myFormat = format(formatFn);', 'const instance = myFormat();'].join('\n'));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* function combine (info)
|
||||
* Returns a new instance of the combine Format which combines the specified
|
||||
* formats into a new format. This is similar to a pipe-chain in transform streams.
|
||||
* We choose to combine the prototypes this way because there is no back pressure in
|
||||
* an in-memory transform chain.
|
||||
*/
|
||||
module.exports = function () {
|
||||
for (var _len = arguments.length, formats = new Array(_len), _key = 0; _key < _len; _key++) {
|
||||
formats[_key] = arguments[_key];
|
||||
}
|
||||
var combinedFormat = format(cascade(formats));
|
||||
var instance = combinedFormat();
|
||||
instance.Format = combinedFormat.Format;
|
||||
return instance;
|
||||
};
|
||||
|
||||
//
|
||||
// Export the cascade method for use in cli and other
|
||||
// combined formats that should not be assumed to be
|
||||
// singletons.
|
||||
//
|
||||
module.exports.cascade = cascade;
|
||||
44
unified-ai-platform/node_modules/logform/dist/errors.js
generated
vendored
Normal file
44
unified-ai-platform/node_modules/logform/dist/errors.js
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
/* eslint no-undefined: 0 */
|
||||
'use strict';
|
||||
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
var format = require('./format');
|
||||
var _require = require('triple-beam'),
|
||||
LEVEL = _require.LEVEL,
|
||||
MESSAGE = _require.MESSAGE;
|
||||
|
||||
/*
|
||||
* function errors (info)
|
||||
* If the `message` property of the `info` object is an instance of `Error`,
|
||||
* replace the `Error` object its own `message` property.
|
||||
*
|
||||
* Optionally, the Error's `stack` and/or `cause` properties can also be appended to the `info` object.
|
||||
*/
|
||||
module.exports = format(function (einfo, _ref) {
|
||||
var stack = _ref.stack,
|
||||
cause = _ref.cause;
|
||||
if (einfo instanceof Error) {
|
||||
var info = Object.assign({}, einfo, _defineProperty(_defineProperty(_defineProperty({
|
||||
level: einfo.level
|
||||
}, LEVEL, einfo[LEVEL] || einfo.level), "message", einfo.message), MESSAGE, einfo[MESSAGE] || einfo.message));
|
||||
if (stack) info.stack = einfo.stack;
|
||||
if (cause) info.cause = einfo.cause;
|
||||
return info;
|
||||
}
|
||||
if (!(einfo.message instanceof Error)) return einfo;
|
||||
|
||||
// Assign all enumerable properties and the
|
||||
// message property from the error provided.
|
||||
var err = einfo.message;
|
||||
Object.assign(einfo, err);
|
||||
einfo.message = err.message;
|
||||
einfo[MESSAGE] = err.message;
|
||||
|
||||
// Assign the stack and/or cause if requested.
|
||||
if (stack) einfo.stack = err.stack;
|
||||
if (cause) einfo.cause = err.cause;
|
||||
return einfo;
|
||||
});
|
||||
70
unified-ai-platform/node_modules/logform/dist/format.js
generated
vendored
Normal file
70
unified-ai-platform/node_modules/logform/dist/format.js
generated
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
'use strict';
|
||||
|
||||
/*
|
||||
* Displays a helpful message and the source of
|
||||
* the format when it is invalid.
|
||||
*/
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
||||
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
||||
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
||||
function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
|
||||
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
|
||||
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
|
||||
function _wrapNativeSuper(t) { var r = "function" == typeof Map ? new Map() : void 0; return _wrapNativeSuper = function _wrapNativeSuper(t) { if (null === t || !_isNativeFunction(t)) return t; if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function"); if (void 0 !== r) { if (r.has(t)) return r.get(t); r.set(t, Wrapper); } function Wrapper() { return _construct(t, arguments, _getPrototypeOf(this).constructor); } return Wrapper.prototype = Object.create(t.prototype, { constructor: { value: Wrapper, enumerable: !1, writable: !0, configurable: !0 } }), _setPrototypeOf(Wrapper, t); }, _wrapNativeSuper(t); }
|
||||
function _construct(t, e, r) { if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments); var o = [null]; o.push.apply(o, e); var p = new (t.bind.apply(t, o))(); return r && _setPrototypeOf(p, r.prototype), p; }
|
||||
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
||||
function _isNativeFunction(t) { try { return -1 !== Function.toString.call(t).indexOf("[native code]"); } catch (n) { return "function" == typeof t; } }
|
||||
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
||||
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
||||
var InvalidFormatError = /*#__PURE__*/function (_Error) {
|
||||
function InvalidFormatError(formatFn) {
|
||||
var _this;
|
||||
_classCallCheck(this, InvalidFormatError);
|
||||
_this = _callSuper(this, InvalidFormatError, ["Format functions must be synchronous taking a two arguments: (info, opts)\nFound: ".concat(formatFn.toString().split('\n')[0], "\n")]);
|
||||
Error.captureStackTrace(_this, InvalidFormatError);
|
||||
return _this;
|
||||
}
|
||||
_inherits(InvalidFormatError, _Error);
|
||||
return _createClass(InvalidFormatError);
|
||||
}(/*#__PURE__*/_wrapNativeSuper(Error));
|
||||
/*
|
||||
* function format (formatFn)
|
||||
* Returns a create function for the `formatFn`.
|
||||
*/
|
||||
module.exports = function (formatFn) {
|
||||
if (formatFn.length > 2) {
|
||||
throw new InvalidFormatError(formatFn);
|
||||
}
|
||||
|
||||
/*
|
||||
* function Format (options)
|
||||
* Base prototype which calls a `_format`
|
||||
* function and pushes the result.
|
||||
*/
|
||||
function Format() {
|
||||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
||||
this.options = options;
|
||||
}
|
||||
Format.prototype.transform = formatFn;
|
||||
|
||||
//
|
||||
// Create a function which returns new instances of
|
||||
// FormatWrap for simple syntax like:
|
||||
//
|
||||
// require('winston').formats.json();
|
||||
//
|
||||
function createFormatWrap(opts) {
|
||||
return new Format(opts);
|
||||
}
|
||||
|
||||
//
|
||||
// Expose the FormatWrap through the create function
|
||||
// for testability.
|
||||
//
|
||||
createFormatWrap.Format = Format;
|
||||
return createFormatWrap;
|
||||
};
|
||||
86
unified-ai-platform/node_modules/logform/dist/index.js
generated
vendored
Normal file
86
unified-ai-platform/node_modules/logform/dist/index.js
generated
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
'use strict';
|
||||
|
||||
/*
|
||||
* @api public
|
||||
* @property {function} format
|
||||
* Both the construction method and set of exposed
|
||||
* formats.
|
||||
*/
|
||||
var format = exports.format = require('./format');
|
||||
|
||||
/*
|
||||
* @api public
|
||||
* @method {function} levels
|
||||
* Registers the specified levels with logform.
|
||||
*/
|
||||
exports.levels = require('./levels');
|
||||
|
||||
/*
|
||||
* @api private
|
||||
* method {function} exposeFormat
|
||||
* Exposes a sub-format on the main format object
|
||||
* as a lazy-loaded getter.
|
||||
*/
|
||||
function exposeFormat(name, requireFormat) {
|
||||
Object.defineProperty(format, name, {
|
||||
get: function get() {
|
||||
return requireFormat();
|
||||
},
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
|
||||
//
|
||||
// Setup all transports as lazy-loaded getters.
|
||||
//
|
||||
exposeFormat('align', function () {
|
||||
return require('./align');
|
||||
});
|
||||
exposeFormat('errors', function () {
|
||||
return require('./errors');
|
||||
});
|
||||
exposeFormat('cli', function () {
|
||||
return require('./cli');
|
||||
});
|
||||
exposeFormat('combine', function () {
|
||||
return require('./combine');
|
||||
});
|
||||
exposeFormat('colorize', function () {
|
||||
return require('./colorize');
|
||||
});
|
||||
exposeFormat('json', function () {
|
||||
return require('./json');
|
||||
});
|
||||
exposeFormat('label', function () {
|
||||
return require('./label');
|
||||
});
|
||||
exposeFormat('logstash', function () {
|
||||
return require('./logstash');
|
||||
});
|
||||
exposeFormat('metadata', function () {
|
||||
return require('./metadata');
|
||||
});
|
||||
exposeFormat('ms', function () {
|
||||
return require('./ms');
|
||||
});
|
||||
exposeFormat('padLevels', function () {
|
||||
return require('./pad-levels');
|
||||
});
|
||||
exposeFormat('prettyPrint', function () {
|
||||
return require('./pretty-print');
|
||||
});
|
||||
exposeFormat('printf', function () {
|
||||
return require('./printf');
|
||||
});
|
||||
exposeFormat('simple', function () {
|
||||
return require('./simple');
|
||||
});
|
||||
exposeFormat('splat', function () {
|
||||
return require('./splat');
|
||||
});
|
||||
exposeFormat('timestamp', function () {
|
||||
return require('./timestamp');
|
||||
});
|
||||
exposeFormat('uncolorize', function () {
|
||||
return require('./uncolorize');
|
||||
});
|
||||
30
unified-ai-platform/node_modules/logform/dist/json.js
generated
vendored
Normal file
30
unified-ai-platform/node_modules/logform/dist/json.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
'use strict';
|
||||
|
||||
var format = require('./format');
|
||||
var _require = require('triple-beam'),
|
||||
MESSAGE = _require.MESSAGE;
|
||||
var stringify = require('safe-stable-stringify');
|
||||
|
||||
/*
|
||||
* function replacer (key, value)
|
||||
* Handles proper stringification of Buffer and bigint output.
|
||||
*/
|
||||
function replacer(key, value) {
|
||||
// safe-stable-stringify does support BigInt, however, it doesn't wrap the value in quotes.
|
||||
// Leading to a loss in fidelity if the resulting string is parsed.
|
||||
// It would also be a breaking change for logform.
|
||||
if (typeof value === 'bigint') return value.toString();
|
||||
return value;
|
||||
}
|
||||
|
||||
/*
|
||||
* function json (info)
|
||||
* Returns a new instance of the JSON format that turns a log `info`
|
||||
* object into pure JSON. This was previously exposed as { json: true }
|
||||
* to transports in `winston < 3.0.0`.
|
||||
*/
|
||||
module.exports = format(function (info, opts) {
|
||||
var jsonStringify = stringify.configure(opts);
|
||||
info[MESSAGE] = jsonStringify(info, opts.replacer || replacer, opts.space);
|
||||
return info;
|
||||
});
|
||||
18
unified-ai-platform/node_modules/logform/dist/label.js
generated
vendored
Normal file
18
unified-ai-platform/node_modules/logform/dist/label.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
'use strict';
|
||||
|
||||
var format = require('./format');
|
||||
|
||||
/*
|
||||
* function label (info)
|
||||
* Returns a new instance of the label Format which adds the specified
|
||||
* `opts.label` before the message. This was previously exposed as
|
||||
* { label: 'my label' } to transports in `winston < 3.0.0`.
|
||||
*/
|
||||
module.exports = format(function (info, opts) {
|
||||
if (opts.message) {
|
||||
info.message = "[".concat(opts.label, "] ").concat(info.message);
|
||||
return info;
|
||||
}
|
||||
info.label = opts.label;
|
||||
return info;
|
||||
});
|
||||
13
unified-ai-platform/node_modules/logform/dist/levels.js
generated
vendored
Normal file
13
unified-ai-platform/node_modules/logform/dist/levels.js
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
'use strict';
|
||||
|
||||
var _require = require('./colorize'),
|
||||
Colorizer = _require.Colorizer;
|
||||
|
||||
/*
|
||||
* Simple method to register colors with a simpler require
|
||||
* path within the module.
|
||||
*/
|
||||
module.exports = function (config) {
|
||||
Colorizer.addColors(config.colors || config);
|
||||
return config;
|
||||
};
|
||||
28
unified-ai-platform/node_modules/logform/dist/logstash.js
generated
vendored
Normal file
28
unified-ai-platform/node_modules/logform/dist/logstash.js
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
'use strict';
|
||||
|
||||
var format = require('./format');
|
||||
var _require = require('triple-beam'),
|
||||
MESSAGE = _require.MESSAGE;
|
||||
var jsonStringify = require('safe-stable-stringify');
|
||||
|
||||
/*
|
||||
* function logstash (info)
|
||||
* Returns a new instance of the LogStash Format that turns a
|
||||
* log `info` object into pure JSON with the appropriate logstash
|
||||
* options. This was previously exposed as { logstash: true }
|
||||
* to transports in `winston < 3.0.0`.
|
||||
*/
|
||||
module.exports = format(function (info) {
|
||||
var logstash = {};
|
||||
if (info.message) {
|
||||
logstash['@message'] = info.message;
|
||||
delete info.message;
|
||||
}
|
||||
if (info.timestamp) {
|
||||
logstash['@timestamp'] = info.timestamp;
|
||||
delete info.timestamp;
|
||||
}
|
||||
logstash['@fields'] = info;
|
||||
info[MESSAGE] = jsonStringify(logstash);
|
||||
return info;
|
||||
});
|
||||
56
unified-ai-platform/node_modules/logform/dist/metadata.js
generated
vendored
Normal file
56
unified-ai-platform/node_modules/logform/dist/metadata.js
generated
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
'use strict';
|
||||
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
var format = require('./format');
|
||||
function fillExcept(info, fillExceptKeys, metadataKey) {
|
||||
var savedKeys = fillExceptKeys.reduce(function (acc, key) {
|
||||
acc[key] = info[key];
|
||||
delete info[key];
|
||||
return acc;
|
||||
}, {});
|
||||
var metadata = Object.keys(info).reduce(function (acc, key) {
|
||||
acc[key] = info[key];
|
||||
delete info[key];
|
||||
return acc;
|
||||
}, {});
|
||||
Object.assign(info, savedKeys, _defineProperty({}, metadataKey, metadata));
|
||||
return info;
|
||||
}
|
||||
function fillWith(info, fillWithKeys, metadataKey) {
|
||||
info[metadataKey] = fillWithKeys.reduce(function (acc, key) {
|
||||
acc[key] = info[key];
|
||||
delete info[key];
|
||||
return acc;
|
||||
}, {});
|
||||
return info;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds in a "metadata" object to collect extraneous data, similar to the metadata
|
||||
* object in winston 2.x.
|
||||
*/
|
||||
module.exports = format(function (info) {
|
||||
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||
var metadataKey = 'metadata';
|
||||
if (opts.key) {
|
||||
metadataKey = opts.key;
|
||||
}
|
||||
var fillExceptKeys = [];
|
||||
if (!opts.fillExcept && !opts.fillWith) {
|
||||
fillExceptKeys.push('level');
|
||||
fillExceptKeys.push('message');
|
||||
}
|
||||
if (opts.fillExcept) {
|
||||
fillExceptKeys = opts.fillExcept;
|
||||
}
|
||||
if (fillExceptKeys.length > 0) {
|
||||
return fillExcept(info, fillExceptKeys, metadataKey);
|
||||
}
|
||||
if (opts.fillWith) {
|
||||
return fillWith(info, opts.fillWith, metadataKey);
|
||||
}
|
||||
return info;
|
||||
});
|
||||
18
unified-ai-platform/node_modules/logform/dist/ms.js
generated
vendored
Normal file
18
unified-ai-platform/node_modules/logform/dist/ms.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
'use strict';
|
||||
|
||||
var _this = void 0;
|
||||
var format = require('./format');
|
||||
var ms = require('ms');
|
||||
|
||||
/*
|
||||
* function ms (info)
|
||||
* Returns an `info` with a `ms` property. The `ms` property holds the Value
|
||||
* of the time difference between two calls in milliseconds.
|
||||
*/
|
||||
module.exports = format(function (info) {
|
||||
var curr = +new Date();
|
||||
_this.diff = curr - (_this.prevTime || curr);
|
||||
_this.prevTime = curr;
|
||||
info.ms = "+".concat(ms(_this.diff));
|
||||
return info;
|
||||
});
|
||||
110
unified-ai-platform/node_modules/logform/dist/pad-levels.js
generated
vendored
Normal file
110
unified-ai-platform/node_modules/logform/dist/pad-levels.js
generated
vendored
Normal file
@@ -0,0 +1,110 @@
|
||||
/* eslint no-unused-vars: 0 */
|
||||
'use strict';
|
||||
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
||||
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
||||
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
||||
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
||||
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
||||
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
||||
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
||||
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
||||
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
var _require = require('triple-beam'),
|
||||
configs = _require.configs,
|
||||
LEVEL = _require.LEVEL,
|
||||
MESSAGE = _require.MESSAGE;
|
||||
var Padder = /*#__PURE__*/function () {
|
||||
function Padder() {
|
||||
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
||||
levels: configs.npm.levels
|
||||
};
|
||||
_classCallCheck(this, Padder);
|
||||
this.paddings = Padder.paddingForLevels(opts.levels, opts.filler);
|
||||
this.options = opts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum length of keys in the specified `levels` Object.
|
||||
* @param {Object} levels Set of all levels to calculate longest level against.
|
||||
* @returns {Number} Maximum length of the longest level string.
|
||||
*/
|
||||
return _createClass(Padder, [{
|
||||
key: "transform",
|
||||
value:
|
||||
/**
|
||||
* Prepends the padding onto the `message` based on the `LEVEL` of
|
||||
* the `info`. This is based on the behavior of `winston@2` which also
|
||||
* prepended the level onto the message.
|
||||
*
|
||||
* See: https://github.com/winstonjs/winston/blob/2.x/lib/winston/logger.js#L198-L201
|
||||
*
|
||||
* @param {Info} info Logform info object
|
||||
* @param {Object} opts Options passed along to this instance.
|
||||
* @returns {Info} Modified logform info object.
|
||||
*/
|
||||
function transform(info, opts) {
|
||||
info.message = "".concat(this.paddings[info[LEVEL]]).concat(info.message);
|
||||
if (info[MESSAGE]) {
|
||||
info[MESSAGE] = "".concat(this.paddings[info[LEVEL]]).concat(info[MESSAGE]);
|
||||
}
|
||||
return info;
|
||||
}
|
||||
}], [{
|
||||
key: "getLongestLevel",
|
||||
value: function getLongestLevel(levels) {
|
||||
var lvls = Object.keys(levels).map(function (level) {
|
||||
return level.length;
|
||||
});
|
||||
return Math.max.apply(Math, _toConsumableArray(lvls));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the padding for the specified `level` assuming that the
|
||||
* maximum length of all levels it's associated with is `maxLength`.
|
||||
* @param {String} level Level to calculate padding for.
|
||||
* @param {String} filler Repeatable text to use for padding.
|
||||
* @param {Number} maxLength Length of the longest level
|
||||
* @returns {String} Padding string for the `level`
|
||||
*/
|
||||
}, {
|
||||
key: "paddingForLevel",
|
||||
value: function paddingForLevel(level, filler, maxLength) {
|
||||
var targetLen = maxLength + 1 - level.length;
|
||||
var rep = Math.floor(targetLen / filler.length);
|
||||
var padding = "".concat(filler).concat(filler.repeat(rep));
|
||||
return padding.slice(0, targetLen);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an object with the string paddings for the given `levels`
|
||||
* using the specified `filler`.
|
||||
* @param {Object} levels Set of all levels to calculate padding for.
|
||||
* @param {String} filler Repeatable text to use for padding.
|
||||
* @returns {Object} Mapping of level to desired padding.
|
||||
*/
|
||||
}, {
|
||||
key: "paddingForLevels",
|
||||
value: function paddingForLevels(levels) {
|
||||
var filler = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ' ';
|
||||
var maxLength = Padder.getLongestLevel(levels);
|
||||
return Object.keys(levels).reduce(function (acc, level) {
|
||||
acc[level] = Padder.paddingForLevel(level, filler, maxLength);
|
||||
return acc;
|
||||
}, {});
|
||||
}
|
||||
}]);
|
||||
}();
|
||||
/*
|
||||
* function padLevels (info)
|
||||
* Returns a new instance of the padLevels Format which pads
|
||||
* levels to be the same length. This was previously exposed as
|
||||
* { padLevels: true } to transports in `winston < 3.0.0`.
|
||||
*/
|
||||
module.exports = function (opts) {
|
||||
return new Padder(opts);
|
||||
};
|
||||
module.exports.Padder = module.exports.Format = Padder;
|
||||
32
unified-ai-platform/node_modules/logform/dist/pretty-print.js
generated
vendored
Normal file
32
unified-ai-platform/node_modules/logform/dist/pretty-print.js
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
'use strict';
|
||||
|
||||
var inspect = require('util').inspect;
|
||||
var format = require('./format');
|
||||
var _require = require('triple-beam'),
|
||||
LEVEL = _require.LEVEL,
|
||||
MESSAGE = _require.MESSAGE,
|
||||
SPLAT = _require.SPLAT;
|
||||
|
||||
/*
|
||||
* function prettyPrint (info)
|
||||
* Returns a new instance of the prettyPrint Format that "prettyPrint"
|
||||
* serializes `info` objects. This was previously exposed as
|
||||
* { prettyPrint: true } to transports in `winston < 3.0.0`.
|
||||
*/
|
||||
module.exports = format(function (info) {
|
||||
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||
//
|
||||
// info[{LEVEL, MESSAGE, SPLAT}] are enumerable here. Since they
|
||||
// are internal, we remove them before util.inspect so they
|
||||
// are not printed.
|
||||
//
|
||||
var stripped = Object.assign({}, info);
|
||||
|
||||
// Remark (indexzero): update this technique in April 2019
|
||||
// when node@6 is EOL
|
||||
delete stripped[LEVEL];
|
||||
delete stripped[MESSAGE];
|
||||
delete stripped[SPLAT];
|
||||
info[MESSAGE] = inspect(stripped, false, opts.depth || null, opts.colorize);
|
||||
return info;
|
||||
});
|
||||
33
unified-ai-platform/node_modules/logform/dist/printf.js
generated
vendored
Normal file
33
unified-ai-platform/node_modules/logform/dist/printf.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
'use strict';
|
||||
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
||||
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
||||
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
var _require = require('triple-beam'),
|
||||
MESSAGE = _require.MESSAGE;
|
||||
var Printf = /*#__PURE__*/function () {
|
||||
function Printf(templateFn) {
|
||||
_classCallCheck(this, Printf);
|
||||
this.template = templateFn;
|
||||
}
|
||||
return _createClass(Printf, [{
|
||||
key: "transform",
|
||||
value: function transform(info) {
|
||||
info[MESSAGE] = this.template(info);
|
||||
return info;
|
||||
}
|
||||
}]);
|
||||
}();
|
||||
/*
|
||||
* function printf (templateFn)
|
||||
* Returns a new instance of the printf Format that creates an
|
||||
* intermediate prototype to store the template string-based formatter
|
||||
* function.
|
||||
*/
|
||||
module.exports = function (opts) {
|
||||
return new Printf(opts);
|
||||
};
|
||||
module.exports.Printf = module.exports.Format = Printf;
|
||||
32
unified-ai-platform/node_modules/logform/dist/simple.js
generated
vendored
Normal file
32
unified-ai-platform/node_modules/logform/dist/simple.js
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
/* eslint no-undefined: 0 */
|
||||
'use strict';
|
||||
|
||||
var format = require('./format');
|
||||
var _require = require('triple-beam'),
|
||||
MESSAGE = _require.MESSAGE;
|
||||
var jsonStringify = require('safe-stable-stringify');
|
||||
|
||||
/*
|
||||
* function simple (info)
|
||||
* Returns a new instance of the simple format TransformStream
|
||||
* which writes a simple representation of logs.
|
||||
*
|
||||
* const { level, message, splat, ...rest } = info;
|
||||
*
|
||||
* ${level}: ${message} if rest is empty
|
||||
* ${level}: ${message} ${JSON.stringify(rest)} otherwise
|
||||
*/
|
||||
module.exports = format(function (info) {
|
||||
var stringifiedRest = jsonStringify(Object.assign({}, info, {
|
||||
level: undefined,
|
||||
message: undefined,
|
||||
splat: undefined
|
||||
}));
|
||||
var padding = info.padding && info.padding[info.level] || '';
|
||||
if (stringifiedRest !== '{}') {
|
||||
info[MESSAGE] = "".concat(info.level, ":").concat(padding, " ").concat(info.message, " ").concat(stringifiedRest);
|
||||
} else {
|
||||
info[MESSAGE] = "".concat(info.level, ":").concat(padding, " ").concat(info.message);
|
||||
}
|
||||
return info;
|
||||
});
|
||||
143
unified-ai-platform/node_modules/logform/dist/splat.js
generated
vendored
Normal file
143
unified-ai-platform/node_modules/logform/dist/splat.js
generated
vendored
Normal file
@@ -0,0 +1,143 @@
|
||||
'use strict';
|
||||
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
||||
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
||||
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
||||
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
||||
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
||||
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
||||
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
||||
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
||||
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
var util = require('util');
|
||||
var _require = require('triple-beam'),
|
||||
SPLAT = _require.SPLAT;
|
||||
|
||||
/**
|
||||
* Captures the number of format (i.e. %s strings) in a given string.
|
||||
* Based on `util.format`, see Node.js source:
|
||||
* https://github.com/nodejs/node/blob/b1c8f15c5f169e021f7c46eb7b219de95fe97603/lib/util.js#L201-L230
|
||||
* @type {RegExp}
|
||||
*/
|
||||
var formatRegExp = /%[scdjifoO%]/g;
|
||||
|
||||
/**
|
||||
* Captures the number of escaped % signs in a format string (i.e. %s strings).
|
||||
* @type {RegExp}
|
||||
*/
|
||||
var escapedPercent = /%%/g;
|
||||
var Splatter = /*#__PURE__*/function () {
|
||||
function Splatter(opts) {
|
||||
_classCallCheck(this, Splatter);
|
||||
this.options = opts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if tokens <= splat.length, assign { splat, meta } into the
|
||||
* `info` accordingly, and write to this instance.
|
||||
*
|
||||
* @param {Info} info Logform info message.
|
||||
* @param {String[]} tokens Set of string interpolation tokens.
|
||||
* @returns {Info} Modified info message
|
||||
* @private
|
||||
*/
|
||||
return _createClass(Splatter, [{
|
||||
key: "_splat",
|
||||
value: function _splat(info, tokens) {
|
||||
var msg = info.message;
|
||||
var splat = info[SPLAT] || info.splat || [];
|
||||
var percents = msg.match(escapedPercent);
|
||||
var escapes = percents && percents.length || 0;
|
||||
|
||||
// The expected splat is the number of tokens minus the number of escapes
|
||||
// e.g.
|
||||
// - { expectedSplat: 3 } '%d %s %j'
|
||||
// - { expectedSplat: 5 } '[%s] %d%% %d%% %s %j'
|
||||
//
|
||||
// Any "meta" will be arugments in addition to the expected splat size
|
||||
// regardless of type. e.g.
|
||||
//
|
||||
// logger.log('info', '%d%% %s %j', 100, 'wow', { such: 'js' }, { thisIsMeta: true });
|
||||
// would result in splat of four (4), but only three (3) are expected. Therefore:
|
||||
//
|
||||
// extraSplat = 3 - 4 = -1
|
||||
// metas = [100, 'wow', { such: 'js' }, { thisIsMeta: true }].splice(-1, -1 * -1);
|
||||
// splat = [100, 'wow', { such: 'js' }]
|
||||
var expectedSplat = tokens.length - escapes;
|
||||
var extraSplat = expectedSplat - splat.length;
|
||||
var metas = extraSplat < 0 ? splat.splice(extraSplat, -1 * extraSplat) : [];
|
||||
|
||||
// Now that { splat } has been separated from any potential { meta }. we
|
||||
// can assign this to the `info` object and write it to our format stream.
|
||||
// If the additional metas are **NOT** objects or **LACK** enumerable properties
|
||||
// you are going to have a bad time.
|
||||
var metalen = metas.length;
|
||||
if (metalen) {
|
||||
for (var i = 0; i < metalen; i++) {
|
||||
Object.assign(info, metas[i]);
|
||||
}
|
||||
}
|
||||
info.message = util.format.apply(util, [msg].concat(_toConsumableArray(splat)));
|
||||
return info;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms the `info` message by using `util.format` to complete
|
||||
* any `info.message` provided it has string interpolation tokens.
|
||||
* If no tokens exist then `info` is immutable.
|
||||
*
|
||||
* @param {Info} info Logform info message.
|
||||
* @param {Object} opts Options for this instance.
|
||||
* @returns {Info} Modified info message
|
||||
*/
|
||||
}, {
|
||||
key: "transform",
|
||||
value: function transform(info) {
|
||||
var msg = info.message;
|
||||
var splat = info[SPLAT] || info.splat;
|
||||
|
||||
// No need to process anything if splat is undefined
|
||||
if (!splat || !splat.length) {
|
||||
return info;
|
||||
}
|
||||
|
||||
// Extract tokens, if none available default to empty array to
|
||||
// ensure consistancy in expected results
|
||||
var tokens = msg && msg.match && msg.match(formatRegExp);
|
||||
|
||||
// This condition will take care of inputs with info[SPLAT]
|
||||
// but no tokens present
|
||||
if (!tokens && (splat || splat.length)) {
|
||||
var metas = splat.length > 1 ? splat.splice(0) : splat;
|
||||
|
||||
// Now that { splat } has been separated from any potential { meta }. we
|
||||
// can assign this to the `info` object and write it to our format stream.
|
||||
// If the additional metas are **NOT** objects or **LACK** enumerable properties
|
||||
// you are going to have a bad time.
|
||||
var metalen = metas.length;
|
||||
if (metalen) {
|
||||
for (var i = 0; i < metalen; i++) {
|
||||
Object.assign(info, metas[i]);
|
||||
}
|
||||
}
|
||||
return info;
|
||||
}
|
||||
if (tokens) {
|
||||
return this._splat(info, tokens);
|
||||
}
|
||||
return info;
|
||||
}
|
||||
}]);
|
||||
}();
|
||||
/*
|
||||
* function splat (info)
|
||||
* Returns a new instance of the splat format TransformStream
|
||||
* which performs string interpolation from `info` objects. This was
|
||||
* previously exposed implicitly in `winston < 3.0.0`.
|
||||
*/
|
||||
module.exports = function (opts) {
|
||||
return new Splatter(opts);
|
||||
};
|
||||
26
unified-ai-platform/node_modules/logform/dist/timestamp.js
generated
vendored
Normal file
26
unified-ai-platform/node_modules/logform/dist/timestamp.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
'use strict';
|
||||
|
||||
var fecha = require('fecha');
|
||||
var format = require('./format');
|
||||
|
||||
/*
|
||||
* function timestamp (info)
|
||||
* Returns a new instance of the timestamp Format which adds a timestamp
|
||||
* to the info. It was previously available in winston < 3.0.0 as:
|
||||
*
|
||||
* - { timestamp: true } // `new Date.toISOString()`
|
||||
* - { timestamp: function:String } // Value returned by `timestamp()`
|
||||
*/
|
||||
module.exports = format(function (info) {
|
||||
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||
if (opts.format) {
|
||||
info.timestamp = typeof opts.format === 'function' ? opts.format() : fecha.format(new Date(), opts.format);
|
||||
}
|
||||
if (!info.timestamp) {
|
||||
info.timestamp = new Date().toISOString();
|
||||
}
|
||||
if (opts.alias) {
|
||||
info[opts.alias] = info.timestamp;
|
||||
}
|
||||
return info;
|
||||
});
|
||||
25
unified-ai-platform/node_modules/logform/dist/uncolorize.js
generated
vendored
Normal file
25
unified-ai-platform/node_modules/logform/dist/uncolorize.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
'use strict';
|
||||
|
||||
var colors = require('@colors/colors/safe');
|
||||
var format = require('./format');
|
||||
var _require = require('triple-beam'),
|
||||
MESSAGE = _require.MESSAGE;
|
||||
|
||||
/*
|
||||
* function uncolorize (info)
|
||||
* Returns a new instance of the uncolorize Format that strips colors
|
||||
* from `info` objects. This was previously exposed as { stripColors: true }
|
||||
* to transports in `winston < 3.0.0`.
|
||||
*/
|
||||
module.exports = format(function (info, opts) {
|
||||
if (opts.level !== false) {
|
||||
info.level = colors.strip(info.level);
|
||||
}
|
||||
if (opts.message !== false) {
|
||||
info.message = colors.strip(String(info.message));
|
||||
}
|
||||
if (opts.raw !== false && info[MESSAGE]) {
|
||||
info[MESSAGE] = colors.strip(String(info[MESSAGE]));
|
||||
}
|
||||
return info;
|
||||
});
|
||||
41
unified-ai-platform/node_modules/logform/errors.js
generated
vendored
Normal file
41
unified-ai-platform/node_modules/logform/errors.js
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
/* eslint no-undefined: 0 */
|
||||
'use strict';
|
||||
|
||||
const format = require('./format');
|
||||
const { LEVEL, MESSAGE } = require('triple-beam');
|
||||
|
||||
/*
|
||||
* function errors (info)
|
||||
* If the `message` property of the `info` object is an instance of `Error`,
|
||||
* replace the `Error` object its own `message` property.
|
||||
*
|
||||
* Optionally, the Error's `stack` and/or `cause` properties can also be appended to the `info` object.
|
||||
*/
|
||||
module.exports = format((einfo, { stack, cause }) => {
|
||||
if (einfo instanceof Error) {
|
||||
const info = Object.assign({}, einfo, {
|
||||
level: einfo.level,
|
||||
[LEVEL]: einfo[LEVEL] || einfo.level,
|
||||
message: einfo.message,
|
||||
[MESSAGE]: einfo[MESSAGE] || einfo.message
|
||||
});
|
||||
|
||||
if (stack) info.stack = einfo.stack;
|
||||
if (cause) info.cause = einfo.cause;
|
||||
return info;
|
||||
}
|
||||
|
||||
if (!(einfo.message instanceof Error)) return einfo;
|
||||
|
||||
// Assign all enumerable properties and the
|
||||
// message property from the error provided.
|
||||
const err = einfo.message;
|
||||
Object.assign(einfo, err);
|
||||
einfo.message = err.message;
|
||||
einfo[MESSAGE] = err.message;
|
||||
|
||||
// Assign the stack and/or cause if requested.
|
||||
if (stack) einfo.stack = err.stack;
|
||||
if (cause) einfo.cause = err.cause;
|
||||
return einfo;
|
||||
});
|
||||
52
unified-ai-platform/node_modules/logform/format.js
generated
vendored
Normal file
52
unified-ai-platform/node_modules/logform/format.js
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
'use strict';
|
||||
|
||||
/*
|
||||
* Displays a helpful message and the source of
|
||||
* the format when it is invalid.
|
||||
*/
|
||||
class InvalidFormatError extends Error {
|
||||
constructor(formatFn) {
|
||||
super(`Format functions must be synchronous taking a two arguments: (info, opts)
|
||||
Found: ${formatFn.toString().split('\n')[0]}\n`);
|
||||
|
||||
Error.captureStackTrace(this, InvalidFormatError);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* function format (formatFn)
|
||||
* Returns a create function for the `formatFn`.
|
||||
*/
|
||||
module.exports = formatFn => {
|
||||
if (formatFn.length > 2) {
|
||||
throw new InvalidFormatError(formatFn);
|
||||
}
|
||||
|
||||
/*
|
||||
* function Format (options)
|
||||
* Base prototype which calls a `_format`
|
||||
* function and pushes the result.
|
||||
*/
|
||||
function Format(options = {}) {
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
Format.prototype.transform = formatFn;
|
||||
|
||||
//
|
||||
// Create a function which returns new instances of
|
||||
// FormatWrap for simple syntax like:
|
||||
//
|
||||
// require('winston').formats.json();
|
||||
//
|
||||
function createFormatWrap(opts) {
|
||||
return new Format(opts);
|
||||
}
|
||||
|
||||
//
|
||||
// Expose the FormatWrap through the create function
|
||||
// for testability.
|
||||
//
|
||||
createFormatWrap.Format = Format;
|
||||
return createFormatWrap;
|
||||
};
|
||||
201
unified-ai-platform/node_modules/logform/index.d.ts
generated
vendored
Normal file
201
unified-ai-platform/node_modules/logform/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,201 @@
|
||||
// Type definitions for logform 2.x
|
||||
// Project: https://github.com/winstonjs/logform
|
||||
// Definitions by: DABH <https://github.com/DABH>
|
||||
// Definitions: https://github.com/winstonjs/logform
|
||||
// TypeScript Version: 2.2
|
||||
import {LEVEL, MESSAGE, SPLAT} from 'triple-beam'
|
||||
|
||||
export interface TransformableInfo {
|
||||
level: string;
|
||||
message: unknown;
|
||||
[LEVEL]?: string;
|
||||
[MESSAGE]?: unknown;
|
||||
[SPLAT]?: unknown;
|
||||
[key: string | symbol]: unknown;
|
||||
}
|
||||
|
||||
export type TransformFunction = (info: TransformableInfo, opts?: unknown) => TransformableInfo | boolean;
|
||||
export type Colors = { [key: string]: string | string[] }; // tslint:disable-line interface-over-type-literal
|
||||
export type FormatWrap = (opts?: unknown) => Format;
|
||||
|
||||
export class Format {
|
||||
constructor(opts?: object);
|
||||
|
||||
options?: object;
|
||||
transform: TransformFunction;
|
||||
}
|
||||
|
||||
export class Colorizer extends Format {
|
||||
constructor(opts?: object);
|
||||
|
||||
createColorize: (opts?: object) => Colorizer;
|
||||
addColors: (colors: Colors) => Colors;
|
||||
colorize: (level: string, message: string) => string;
|
||||
}
|
||||
|
||||
export function format(transform: TransformFunction): FormatWrap;
|
||||
|
||||
export function levels(config: object): object;
|
||||
|
||||
export namespace format {
|
||||
function align(): Format;
|
||||
function cli(opts?: CliOptions): Format;
|
||||
function colorize(opts?: ColorizeOptions): Colorizer;
|
||||
function combine(...formats: Format[]): Format;
|
||||
function errors(opts?: object): Format;
|
||||
function json(opts?: JsonOptions): Format;
|
||||
function label(opts?: LabelOptions): Format;
|
||||
function logstash(): Format;
|
||||
function metadata(opts?: MetadataOptions): Format;
|
||||
function ms(): Format;
|
||||
function padLevels(opts?: PadLevelsOptions): Format;
|
||||
function prettyPrint(opts?: PrettyPrintOptions): Format;
|
||||
function printf(templateFunction: (info: TransformableInfo) => string): Format;
|
||||
function simple(): Format;
|
||||
function splat(): Format;
|
||||
function timestamp(opts?: TimestampOptions): Format;
|
||||
function uncolorize(opts?: UncolorizeOptions): Format;
|
||||
}
|
||||
|
||||
export interface CliOptions extends ColorizeOptions, PadLevelsOptions { }
|
||||
|
||||
export interface ColorizeOptions {
|
||||
/**
|
||||
* If set to `true` the color will be applied to the `level`.
|
||||
*/
|
||||
level?: boolean;
|
||||
/**
|
||||
* If set to `true` the color will be applied to the `message` and `level`.
|
||||
*/
|
||||
all?: boolean;
|
||||
/**
|
||||
* If set to `true` the color will be applied to the `message`.
|
||||
*/
|
||||
message?: boolean;
|
||||
/**
|
||||
* An object containing the colors for the log levels. For example: `{ info: 'blue', error: 'red' }`.
|
||||
*/
|
||||
colors?: Record<string, string | string[]>;
|
||||
}
|
||||
|
||||
export interface JsonOptions {
|
||||
/**
|
||||
* A function that influences how the `info` is stringified.
|
||||
*/
|
||||
replacer?: (this: unknown, key: string, value: unknown) => unknown;
|
||||
/**
|
||||
* The number of white space used to format the json.
|
||||
*/
|
||||
space?: number;
|
||||
|
||||
// The following options come from safe-stable-stringify
|
||||
// https://github.com/BridgeAR/safe-stable-stringify/blob/main/index.d.ts
|
||||
|
||||
/**
|
||||
* If `true`, bigint values are converted to a number. Otherwise, they are ignored.
|
||||
* This option is ignored by default as Logform stringifies BigInt in the default replacer.
|
||||
* @default true
|
||||
*/
|
||||
bigint?: boolean,
|
||||
/**
|
||||
* Defines the value for circular references.
|
||||
* Set to `undefined`, circular properties are not serialized (array entries are replaced with null).
|
||||
* Set to `Error`, to throw on circular references.
|
||||
* @default "[Circular]"
|
||||
*/
|
||||
circularValue?: string | null | TypeErrorConstructor | ErrorConstructor,
|
||||
/**
|
||||
* If `true`, guarantee a deterministic key order instead of relying on the insertion order.
|
||||
* @default true
|
||||
*/
|
||||
deterministic?: boolean,
|
||||
/**
|
||||
* Maximum number of entries to serialize per object (at least one).
|
||||
* The serialized output contains information about how many entries have not been serialized.
|
||||
* Ignored properties are counted as well (e.g., properties with symbol values).
|
||||
* Using the array replacer overrules this option.
|
||||
* @default Infinity
|
||||
*/
|
||||
maximumBreadth?: number,
|
||||
/**
|
||||
* Maximum number of object nesting levels (at least 1) that will be serialized.
|
||||
* Objects at the maximum level are serialized as `"[Object]"` and arrays as `"[Array]"`.
|
||||
* @default Infinity
|
||||
*/
|
||||
maximumDepth?: number,
|
||||
}
|
||||
|
||||
export interface LabelOptions {
|
||||
/**
|
||||
* A label to be added before the message.
|
||||
*/
|
||||
label?: string;
|
||||
/**
|
||||
* If set to `true` the `label` will be added to `info.message`. If set to `false` the `label`
|
||||
* will be added as `info.label`.
|
||||
*/
|
||||
message?: boolean;
|
||||
}
|
||||
|
||||
export interface MetadataOptions {
|
||||
/**
|
||||
* The name of the key used for the metadata object. Defaults to `metadata`.
|
||||
*/
|
||||
key?: string;
|
||||
/**
|
||||
* An array of keys that should not be added to the metadata object.
|
||||
*/
|
||||
fillExcept?: string[];
|
||||
/**
|
||||
* An array of keys that will be added to the metadata object.
|
||||
*/
|
||||
fillWith?: string[];
|
||||
}
|
||||
|
||||
export interface PadLevelsOptions {
|
||||
/**
|
||||
* Log levels. Defaults to `configs.npm.levels` from [triple-beam](https://github.com/winstonjs/triple-beam)
|
||||
* module.
|
||||
*/
|
||||
levels?: Record<string, number>;
|
||||
}
|
||||
|
||||
export interface PrettyPrintOptions {
|
||||
/**
|
||||
* A `number` that specifies the maximum depth of the `info` object being stringified by
|
||||
* `util.inspect`. Defaults to `2`.
|
||||
*/
|
||||
depth?: number;
|
||||
/**
|
||||
* Colorizes the message if set to `true`. Defaults to `false`.
|
||||
*/
|
||||
colorize?: boolean;
|
||||
}
|
||||
|
||||
export interface TimestampOptions {
|
||||
/**
|
||||
* Either the format as a string accepted by the [fecha](https://github.com/taylorhakes/fecha)
|
||||
* module or a function that returns a formatted date. If no format is provided `new
|
||||
* Date().toISOString()` will be used.
|
||||
*/
|
||||
format?: string | (() => string);
|
||||
/**
|
||||
* The name of an alias for the timestamp property, that will be added to the `info` object.
|
||||
*/
|
||||
alias?: string;
|
||||
}
|
||||
|
||||
export interface UncolorizeOptions {
|
||||
/**
|
||||
* Disables the uncolorize format for `info.level` if set to `false`.
|
||||
*/
|
||||
level?: boolean;
|
||||
/**
|
||||
* Disables the uncolorize format for `info.message` if set to `false`.
|
||||
*/
|
||||
message?: boolean;
|
||||
/**
|
||||
* Disables the uncolorize format for `info[MESSAGE]` if set to `false`.
|
||||
*/
|
||||
raw?: boolean;
|
||||
}
|
||||
52
unified-ai-platform/node_modules/logform/index.js
generated
vendored
Normal file
52
unified-ai-platform/node_modules/logform/index.js
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
'use strict';
|
||||
|
||||
/*
|
||||
* @api public
|
||||
* @property {function} format
|
||||
* Both the construction method and set of exposed
|
||||
* formats.
|
||||
*/
|
||||
const format = exports.format = require('./format');
|
||||
|
||||
/*
|
||||
* @api public
|
||||
* @method {function} levels
|
||||
* Registers the specified levels with logform.
|
||||
*/
|
||||
exports.levels = require('./levels');
|
||||
|
||||
/*
|
||||
* @api private
|
||||
* method {function} exposeFormat
|
||||
* Exposes a sub-format on the main format object
|
||||
* as a lazy-loaded getter.
|
||||
*/
|
||||
function exposeFormat(name, requireFormat) {
|
||||
Object.defineProperty(format, name, {
|
||||
get() {
|
||||
return requireFormat();
|
||||
},
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
|
||||
//
|
||||
// Setup all transports as lazy-loaded getters.
|
||||
//
|
||||
exposeFormat('align', function () { return require('./align'); });
|
||||
exposeFormat('errors', function () { return require('./errors'); });
|
||||
exposeFormat('cli', function () { return require('./cli'); });
|
||||
exposeFormat('combine', function () { return require('./combine'); });
|
||||
exposeFormat('colorize', function () { return require('./colorize'); });
|
||||
exposeFormat('json', function () { return require('./json'); });
|
||||
exposeFormat('label', function () { return require('./label'); });
|
||||
exposeFormat('logstash', function () { return require('./logstash'); });
|
||||
exposeFormat('metadata', function () { return require('./metadata'); });
|
||||
exposeFormat('ms', function () { return require('./ms'); });
|
||||
exposeFormat('padLevels', function () { return require('./pad-levels'); });
|
||||
exposeFormat('prettyPrint', function () { return require('./pretty-print'); });
|
||||
exposeFormat('printf', function () { return require('./printf'); });
|
||||
exposeFormat('simple', function () { return require('./simple'); });
|
||||
exposeFormat('splat', function () { return require('./splat'); });
|
||||
exposeFormat('timestamp', function () { return require('./timestamp'); });
|
||||
exposeFormat('uncolorize', function () { return require('./uncolorize'); });
|
||||
30
unified-ai-platform/node_modules/logform/json.js
generated
vendored
Normal file
30
unified-ai-platform/node_modules/logform/json.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
'use strict';
|
||||
|
||||
const format = require('./format');
|
||||
const { MESSAGE } = require('triple-beam');
|
||||
const stringify = require('safe-stable-stringify');
|
||||
|
||||
/*
|
||||
* function replacer (key, value)
|
||||
* Handles proper stringification of Buffer and bigint output.
|
||||
*/
|
||||
function replacer(key, value) {
|
||||
// safe-stable-stringify does support BigInt, however, it doesn't wrap the value in quotes.
|
||||
// Leading to a loss in fidelity if the resulting string is parsed.
|
||||
// It would also be a breaking change for logform.
|
||||
if (typeof value === 'bigint')
|
||||
return value.toString();
|
||||
return value;
|
||||
}
|
||||
|
||||
/*
|
||||
* function json (info)
|
||||
* Returns a new instance of the JSON format that turns a log `info`
|
||||
* object into pure JSON. This was previously exposed as { json: true }
|
||||
* to transports in `winston < 3.0.0`.
|
||||
*/
|
||||
module.exports = format((info, opts) => {
|
||||
const jsonStringify = stringify.configure(opts);
|
||||
info[MESSAGE] = jsonStringify(info, opts.replacer || replacer, opts.space);
|
||||
return info;
|
||||
});
|
||||
19
unified-ai-platform/node_modules/logform/label.js
generated
vendored
Normal file
19
unified-ai-platform/node_modules/logform/label.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
'use strict';
|
||||
|
||||
const format = require('./format');
|
||||
|
||||
/*
|
||||
* function label (info)
|
||||
* Returns a new instance of the label Format which adds the specified
|
||||
* `opts.label` before the message. This was previously exposed as
|
||||
* { label: 'my label' } to transports in `winston < 3.0.0`.
|
||||
*/
|
||||
module.exports = format((info, opts) => {
|
||||
if (opts.message) {
|
||||
info.message = `[${opts.label}] ${info.message}`;
|
||||
return info;
|
||||
}
|
||||
|
||||
info.label = opts.label;
|
||||
return info;
|
||||
});
|
||||
12
unified-ai-platform/node_modules/logform/levels.js
generated
vendored
Normal file
12
unified-ai-platform/node_modules/logform/levels.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
'use strict';
|
||||
|
||||
const { Colorizer } = require('./colorize');
|
||||
|
||||
/*
|
||||
* Simple method to register colors with a simpler require
|
||||
* path within the module.
|
||||
*/
|
||||
module.exports = config => {
|
||||
Colorizer.addColors(config.colors || config);
|
||||
return config;
|
||||
};
|
||||
29
unified-ai-platform/node_modules/logform/logstash.js
generated
vendored
Normal file
29
unified-ai-platform/node_modules/logform/logstash.js
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
'use strict';
|
||||
|
||||
const format = require('./format');
|
||||
const { MESSAGE } = require('triple-beam');
|
||||
const jsonStringify = require('safe-stable-stringify');
|
||||
|
||||
/*
|
||||
* function logstash (info)
|
||||
* Returns a new instance of the LogStash Format that turns a
|
||||
* log `info` object into pure JSON with the appropriate logstash
|
||||
* options. This was previously exposed as { logstash: true }
|
||||
* to transports in `winston < 3.0.0`.
|
||||
*/
|
||||
module.exports = format(info => {
|
||||
const logstash = {};
|
||||
if (info.message) {
|
||||
logstash['@message'] = info.message;
|
||||
delete info.message;
|
||||
}
|
||||
|
||||
if (info.timestamp) {
|
||||
logstash['@timestamp'] = info.timestamp;
|
||||
delete info.timestamp;
|
||||
}
|
||||
|
||||
logstash['@fields'] = info;
|
||||
info[MESSAGE] = jsonStringify(logstash);
|
||||
return info;
|
||||
});
|
||||
61
unified-ai-platform/node_modules/logform/metadata.js
generated
vendored
Normal file
61
unified-ai-platform/node_modules/logform/metadata.js
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
'use strict';
|
||||
|
||||
const format = require('./format');
|
||||
|
||||
function fillExcept(info, fillExceptKeys, metadataKey) {
|
||||
const savedKeys = fillExceptKeys.reduce((acc, key) => {
|
||||
acc[key] = info[key];
|
||||
delete info[key];
|
||||
return acc;
|
||||
}, {});
|
||||
const metadata = Object.keys(info).reduce((acc, key) => {
|
||||
acc[key] = info[key];
|
||||
delete info[key];
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
Object.assign(info, savedKeys, {
|
||||
[metadataKey]: metadata
|
||||
});
|
||||
return info;
|
||||
}
|
||||
|
||||
function fillWith(info, fillWithKeys, metadataKey) {
|
||||
info[metadataKey] = fillWithKeys.reduce((acc, key) => {
|
||||
acc[key] = info[key];
|
||||
delete info[key];
|
||||
return acc;
|
||||
}, {});
|
||||
return info;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds in a "metadata" object to collect extraneous data, similar to the metadata
|
||||
* object in winston 2.x.
|
||||
*/
|
||||
module.exports = format((info, opts = {}) => {
|
||||
let metadataKey = 'metadata';
|
||||
if (opts.key) {
|
||||
metadataKey = opts.key;
|
||||
}
|
||||
|
||||
let fillExceptKeys = [];
|
||||
if (!opts.fillExcept && !opts.fillWith) {
|
||||
fillExceptKeys.push('level');
|
||||
fillExceptKeys.push('message');
|
||||
}
|
||||
|
||||
if (opts.fillExcept) {
|
||||
fillExceptKeys = opts.fillExcept;
|
||||
}
|
||||
|
||||
if (fillExceptKeys.length > 0) {
|
||||
return fillExcept(info, fillExceptKeys, metadataKey);
|
||||
}
|
||||
|
||||
if (opts.fillWith) {
|
||||
return fillWith(info, opts.fillWith, metadataKey);
|
||||
}
|
||||
|
||||
return info;
|
||||
});
|
||||
18
unified-ai-platform/node_modules/logform/ms.js
generated
vendored
Normal file
18
unified-ai-platform/node_modules/logform/ms.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
'use strict';
|
||||
|
||||
const format = require('./format');
|
||||
const ms = require('ms');
|
||||
|
||||
/*
|
||||
* function ms (info)
|
||||
* Returns an `info` with a `ms` property. The `ms` property holds the Value
|
||||
* of the time difference between two calls in milliseconds.
|
||||
*/
|
||||
module.exports = format(info => {
|
||||
const curr = +new Date();
|
||||
this.diff = curr - (this.prevTime || curr);
|
||||
this.prevTime = curr;
|
||||
info.ms = `+${ms(this.diff)}`;
|
||||
|
||||
return info;
|
||||
});
|
||||
22
unified-ai-platform/node_modules/logform/node_modules/fecha/LICENSE
generated
vendored
Normal file
22
unified-ai-platform/node_modules/logform/node_modules/fecha/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 Taylor Hakes
|
||||
|
||||
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.
|
||||
|
||||
320
unified-ai-platform/node_modules/logform/node_modules/fecha/README.md
generated
vendored
Normal file
320
unified-ai-platform/node_modules/logform/node_modules/fecha/README.md
generated
vendored
Normal file
@@ -0,0 +1,320 @@
|
||||
# fecha [](https://travis-ci.org/taylorhakes/fecha)
|
||||
|
||||
Lightweight date formatting and parsing (~2KB). Meant to replace parsing and formatting functionality of moment.js.
|
||||
|
||||
### NPM
|
||||
```
|
||||
npm install fecha --save
|
||||
```
|
||||
### Yarn
|
||||
```
|
||||
yarn add fecha
|
||||
```
|
||||
|
||||
### Fecha vs Moment
|
||||
<table class="table table-striped table-bordered">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th>Fecha</th>
|
||||
<th>Moment</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>Size (Min. and Gzipped)</b></td>
|
||||
<td>2.1KBs</td>
|
||||
<td>13.1KBs</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>Date Parsing</b></td>
|
||||
<td>✓</td>
|
||||
<td>✓</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>Date Formatting</b></td>
|
||||
<td>✓</td>
|
||||
<td>✓</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>Date Manipulation</b></td>
|
||||
<td></td>
|
||||
<td>✓</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>I18n Support</b></td>
|
||||
<td>✓</td>
|
||||
<td>✓</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
## Use it
|
||||
|
||||
#### Formatting
|
||||
`format` accepts a Date object (or timestamp) and a string format and returns a formatted string. See below for
|
||||
available format tokens.
|
||||
|
||||
Note: `format` will throw an error when passed invalid parameters
|
||||
```js
|
||||
import { format } from 'fecha';
|
||||
|
||||
type format = (date: Date, format?: string, i18n?: I18nSettings) => str;
|
||||
|
||||
// Custom formats
|
||||
format(new Date(2015, 10, 20), 'dddd MMMM Do, YYYY'); // 'Friday November 20th, 2015'
|
||||
format(new Date(1998, 5, 3, 15, 23, 10, 350), 'YYYY-MM-DD hh:mm:ss.SSS A'); // '1998-06-03 03:23:10.350 PM'
|
||||
|
||||
// Named masks
|
||||
format(new Date(2015, 10, 20), 'isoDate'); // '2015-11-20'
|
||||
format(new Date(2015, 10, 20), 'mediumDate'); // 'Nov 20, 2015'
|
||||
format(new Date(2015, 10, 20, 3, 2, 1), 'isoDateTime'); // '2015-11-20T03:02:01-05:00'
|
||||
format(new Date(2015, 2, 10, 5, 30, 20), 'shortTime'); // '05:30'
|
||||
|
||||
// Literals
|
||||
format(new Date(2001, 2, 5, 6, 7, 2, 5), '[on] MM-DD-YYYY [at] HH:mm'); // 'on 03-05-2001 at 06:07'
|
||||
```
|
||||
|
||||
#### Parsing
|
||||
`parse` accepts a Date string and a string format and returns a Date object. See below for available format tokens.
|
||||
|
||||
*NOTE*: `parse` will throw an error when passed invalid string format or missing format. You MUST specify a format.
|
||||
```js
|
||||
import { parse } from 'fecha';
|
||||
|
||||
type parse = (dateStr: string, format: string, i18n?: I18nSettingsOptional) => Date|null;
|
||||
|
||||
// Custom formats
|
||||
parse('February 3rd, 2014', 'MMMM Do, YYYY'); // new Date(2014, 1, 3)
|
||||
parse('10-12-10 14:11:12', 'YY-MM-DD HH:mm:ss'); // new Date(2010, 11, 10, 14, 11, 12)
|
||||
|
||||
// Named masks
|
||||
parse('5/3/98', 'shortDate'); // new Date(1998, 4, 3)
|
||||
parse('November 4, 2005', 'longDate'); // new Date(2005, 10, 4)
|
||||
parse('2015-11-20T03:02:01-05:00', 'isoDateTime'); // new Date(2015, 10, 20, 3, 2, 1)
|
||||
|
||||
// Override i18n
|
||||
parse('4 de octubre de 1983', 'M de MMMM de YYYY', {
|
||||
monthNames: [
|
||||
'enero',
|
||||
'febrero',
|
||||
'marzo',
|
||||
'abril',
|
||||
'mayo',
|
||||
'junio',
|
||||
'julio',
|
||||
'agosto',
|
||||
'septiembre',
|
||||
'octubre',
|
||||
'noviembre',
|
||||
'diciembre'
|
||||
]
|
||||
}); // new Date(1983, 9, 4)
|
||||
```
|
||||
|
||||
#### i18n Support
|
||||
```js
|
||||
import {setGlobalDateI18n} from 'fecha';
|
||||
|
||||
/*
|
||||
Default I18n Settings
|
||||
{
|
||||
dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thur', 'Fri', 'Sat'],
|
||||
dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
|
||||
monthNamesShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
|
||||
monthNames: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
|
||||
amPm: ['am', 'pm'],
|
||||
// D is the day of the month, function returns something like... 3rd or 11th
|
||||
DoFn(dayOfMonth) {
|
||||
return dayOfMonth + [ 'th', 'st', 'nd', 'rd' ][ dayOfMonth % 10 > 3 ? 0 : (dayOfMonth - dayOfMonth % 10 !== 10) * dayOfMonth % 10 ];
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
setGlobalDateI18n({
|
||||
dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thur', 'Fri', 'Sat'],
|
||||
dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
|
||||
monthNamesShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
|
||||
monthNames: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
|
||||
amPm: ['am', 'pm'],
|
||||
// D is the day of the month, function returns something like... 3rd or 11th
|
||||
DoFn: function (D) {
|
||||
return D + [ 'th', 'st', 'nd', 'rd' ][ D % 10 > 3 ? 0 : (D - D % 10 !== 10) * D % 10 ];
|
||||
}
|
||||
});
|
||||
|
||||
```
|
||||
|
||||
#### Custom Named Masks
|
||||
```js
|
||||
import { format, setGlobalDateMasks } from 'fecha';
|
||||
/*
|
||||
Default global masks
|
||||
{
|
||||
default: 'ddd MMM DD YYYY HH:mm:ss',
|
||||
shortDate: 'M/D/YY',
|
||||
mediumDate: 'MMM D, YYYY',
|
||||
longDate: 'MMMM D, YYYY',
|
||||
fullDate: 'dddd, MMMM D, YYYY',
|
||||
shortTime: 'HH:mm',
|
||||
mediumTime: 'HH:mm:ss',
|
||||
longTime: 'HH:mm:ss.SSS'
|
||||
}
|
||||
*/
|
||||
|
||||
// Create a new mask
|
||||
setGlobalDateMasks({
|
||||
myMask: 'HH:mm:ss YY/MM/DD';
|
||||
});
|
||||
|
||||
// Use it
|
||||
format(new Date(2014, 5, 6, 14, 10, 45), 'myMask'); // '14:10:45 14/06/06'
|
||||
```
|
||||
|
||||
### Formatting Tokens
|
||||
<table class="table table-striped table-bordered">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th>Token</th>
|
||||
<th>Output</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>Month</b></td>
|
||||
<td>M</td>
|
||||
<td>1 2 ... 11 12</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>MM</td>
|
||||
<td>01 02 ... 11 12</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>MMM</td>
|
||||
<td>Jan Feb ... Nov Dec</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>MMMM</td>
|
||||
<td>January February ... November December</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>Day of Month</b></td>
|
||||
<td>D</td>
|
||||
<td>1 2 ... 30 31</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>Do</td>
|
||||
<td>1st 2nd ... 30th 31st</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>DD</td>
|
||||
<td>01 02 ... 30 31</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>Day of Week</b></td>
|
||||
<td>d</td>
|
||||
<td>0 1 ... 5 6</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>ddd</td>
|
||||
<td>Sun Mon ... Fri Sat</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>dddd</td>
|
||||
<td>Sunday Monday ... Friday Saturday</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>Year</b></td>
|
||||
<td>YY</td>
|
||||
<td>70 71 ... 29 30</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>YYYY</td>
|
||||
<td>1970 1971 ... 2029 2030</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>AM/PM</b></td>
|
||||
<td>A</td>
|
||||
<td>AM PM</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>a</td>
|
||||
<td>am pm</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>Hour</b></td>
|
||||
<td>H</td>
|
||||
<td>0 1 ... 22 23</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>HH</td>
|
||||
<td>00 01 ... 22 23</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>h</td>
|
||||
<td>1 2 ... 11 12</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>hh</td>
|
||||
<td>01 02 ... 11 12</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>Minute</b></td>
|
||||
<td>m</td>
|
||||
<td>0 1 ... 58 59</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>mm</td>
|
||||
<td>00 01 ... 58 59</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>Second</b></td>
|
||||
<td>s</td>
|
||||
<td>0 1 ... 58 59</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>ss</td>
|
||||
<td>00 01 ... 58 59</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>Fractional Second</b></td>
|
||||
<td>S</td>
|
||||
<td>0 1 ... 8 9</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>SS</td>
|
||||
<td>0 1 ... 98 99</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>SSS</td>
|
||||
<td>0 1 ... 998 999</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>Timezone</b></td>
|
||||
<td>Z</td>
|
||||
<td>
|
||||
-07:00 -06:00 ... +06:00 +07:00
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b></b></td>
|
||||
<td>ZZ</td>
|
||||
<td>
|
||||
-0700 -0600 ... +0600 +0700
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
2
unified-ai-platform/node_modules/logform/node_modules/fecha/dist/fecha.min.js
generated
vendored
Normal file
2
unified-ai-platform/node_modules/logform/node_modules/fecha/dist/fecha.min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
unified-ai-platform/node_modules/logform/node_modules/fecha/dist/fecha.min.js.map
generated
vendored
Normal file
1
unified-ai-platform/node_modules/logform/node_modules/fecha/dist/fecha.min.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
52
unified-ai-platform/node_modules/logform/node_modules/fecha/lib/fecha.d.ts
generated
vendored
Normal file
52
unified-ai-platform/node_modules/logform/node_modules/fecha/lib/fecha.d.ts
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
export declare type I18nSettings = {
|
||||
amPm: [string, string];
|
||||
dayNames: Days;
|
||||
dayNamesShort: Days;
|
||||
monthNames: Months;
|
||||
monthNamesShort: Months;
|
||||
DoFn(dayOfMonth: number): string;
|
||||
};
|
||||
export declare type I18nSettingsOptional = Partial<I18nSettings>;
|
||||
export declare type Days = [string, string, string, string, string, string, string];
|
||||
export declare type Months = [string, string, string, string, string, string, string, string, string, string, string, string];
|
||||
export declare function assign<A>(a: A): A;
|
||||
export declare function assign<A, B>(a: A, b: B): A & B;
|
||||
export declare function assign<A, B, C>(a: A, b: B, c: C): A & B & C;
|
||||
export declare function assign<A, B, C, D>(a: A, b: B, c: C, d: D): A & B & C & D;
|
||||
declare const defaultI18n: I18nSettings;
|
||||
declare const setGlobalDateI18n: (i18n: I18nSettingsOptional) => I18nSettings;
|
||||
declare const setGlobalDateMasks: (masks: {
|
||||
[key: string]: string;
|
||||
}) => {
|
||||
[key: string]: string;
|
||||
};
|
||||
/***
|
||||
* Format a date
|
||||
* @method format
|
||||
* @param {Date|number} dateObj
|
||||
* @param {string} mask Format of the date, i.e. 'mm-dd-yy' or 'shortDate'
|
||||
* @returns {string} Formatted date string
|
||||
*/
|
||||
declare const format: (dateObj: Date, mask?: string, i18n?: I18nSettingsOptional) => string;
|
||||
/**
|
||||
* Parse a date string into a Javascript Date object /
|
||||
* @method parse
|
||||
* @param {string} dateStr Date string
|
||||
* @param {string} format Date parse format
|
||||
* @param {i18n} I18nSettingsOptional Full or subset of I18N settings
|
||||
* @returns {Date|null} Returns Date object. Returns null what date string is invalid or doesn't match format
|
||||
*/
|
||||
declare function parse(dateStr: string, format: string, i18n?: I18nSettingsOptional): Date | null;
|
||||
declare const _default: {
|
||||
format: (dateObj: Date, mask?: string, i18n?: Partial<I18nSettings>) => string;
|
||||
parse: typeof parse;
|
||||
defaultI18n: I18nSettings;
|
||||
setGlobalDateI18n: (i18n: Partial<I18nSettings>) => I18nSettings;
|
||||
setGlobalDateMasks: (masks: {
|
||||
[key: string]: string;
|
||||
}) => {
|
||||
[key: string]: string;
|
||||
};
|
||||
};
|
||||
export default _default;
|
||||
export { format, parse, defaultI18n, setGlobalDateI18n, setGlobalDateMasks };
|
||||
403
unified-ai-platform/node_modules/logform/node_modules/fecha/lib/fecha.js
generated
vendored
Normal file
403
unified-ai-platform/node_modules/logform/node_modules/fecha/lib/fecha.js
generated
vendored
Normal file
@@ -0,0 +1,403 @@
|
||||
var token = /d{1,4}|M{1,4}|YY(?:YY)?|S{1,3}|Do|ZZ|Z|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
|
||||
var twoDigitsOptional = "\\d\\d?";
|
||||
var twoDigits = "\\d\\d";
|
||||
var threeDigits = "\\d{3}";
|
||||
var fourDigits = "\\d{4}";
|
||||
var word = "[^\\s]+";
|
||||
var literal = /\[([^]*?)\]/gm;
|
||||
function shorten(arr, sLen) {
|
||||
var newArr = [];
|
||||
for (var i = 0, len = arr.length; i < len; i++) {
|
||||
newArr.push(arr[i].substr(0, sLen));
|
||||
}
|
||||
return newArr;
|
||||
}
|
||||
var monthUpdate = function (arrName) { return function (v, i18n) {
|
||||
var lowerCaseArr = i18n[arrName].map(function (v) { return v.toLowerCase(); });
|
||||
var index = lowerCaseArr.indexOf(v.toLowerCase());
|
||||
if (index > -1) {
|
||||
return index;
|
||||
}
|
||||
return null;
|
||||
}; };
|
||||
function assign(origObj) {
|
||||
var args = [];
|
||||
for (var _i = 1; _i < arguments.length; _i++) {
|
||||
args[_i - 1] = arguments[_i];
|
||||
}
|
||||
for (var _a = 0, args_1 = args; _a < args_1.length; _a++) {
|
||||
var obj = args_1[_a];
|
||||
for (var key in obj) {
|
||||
// @ts-ignore ex
|
||||
origObj[key] = obj[key];
|
||||
}
|
||||
}
|
||||
return origObj;
|
||||
}
|
||||
var dayNames = [
|
||||
"Sunday",
|
||||
"Monday",
|
||||
"Tuesday",
|
||||
"Wednesday",
|
||||
"Thursday",
|
||||
"Friday",
|
||||
"Saturday"
|
||||
];
|
||||
var monthNames = [
|
||||
"January",
|
||||
"February",
|
||||
"March",
|
||||
"April",
|
||||
"May",
|
||||
"June",
|
||||
"July",
|
||||
"August",
|
||||
"September",
|
||||
"October",
|
||||
"November",
|
||||
"December"
|
||||
];
|
||||
var monthNamesShort = shorten(monthNames, 3);
|
||||
var dayNamesShort = shorten(dayNames, 3);
|
||||
var defaultI18n = {
|
||||
dayNamesShort: dayNamesShort,
|
||||
dayNames: dayNames,
|
||||
monthNamesShort: monthNamesShort,
|
||||
monthNames: monthNames,
|
||||
amPm: ["am", "pm"],
|
||||
DoFn: function (dayOfMonth) {
|
||||
return (dayOfMonth +
|
||||
["th", "st", "nd", "rd"][dayOfMonth % 10 > 3
|
||||
? 0
|
||||
: ((dayOfMonth - (dayOfMonth % 10) !== 10 ? 1 : 0) * dayOfMonth) % 10]);
|
||||
}
|
||||
};
|
||||
var globalI18n = assign({}, defaultI18n);
|
||||
var setGlobalDateI18n = function (i18n) {
|
||||
return (globalI18n = assign(globalI18n, i18n));
|
||||
};
|
||||
var regexEscape = function (str) {
|
||||
return str.replace(/[|\\{()[^$+*?.-]/g, "\\$&");
|
||||
};
|
||||
var pad = function (val, len) {
|
||||
if (len === void 0) { len = 2; }
|
||||
val = String(val);
|
||||
while (val.length < len) {
|
||||
val = "0" + val;
|
||||
}
|
||||
return val;
|
||||
};
|
||||
var formatFlags = {
|
||||
D: function (dateObj) { return String(dateObj.getDate()); },
|
||||
DD: function (dateObj) { return pad(dateObj.getDate()); },
|
||||
Do: function (dateObj, i18n) {
|
||||
return i18n.DoFn(dateObj.getDate());
|
||||
},
|
||||
d: function (dateObj) { return String(dateObj.getDay()); },
|
||||
dd: function (dateObj) { return pad(dateObj.getDay()); },
|
||||
ddd: function (dateObj, i18n) {
|
||||
return i18n.dayNamesShort[dateObj.getDay()];
|
||||
},
|
||||
dddd: function (dateObj, i18n) {
|
||||
return i18n.dayNames[dateObj.getDay()];
|
||||
},
|
||||
M: function (dateObj) { return String(dateObj.getMonth() + 1); },
|
||||
MM: function (dateObj) { return pad(dateObj.getMonth() + 1); },
|
||||
MMM: function (dateObj, i18n) {
|
||||
return i18n.monthNamesShort[dateObj.getMonth()];
|
||||
},
|
||||
MMMM: function (dateObj, i18n) {
|
||||
return i18n.monthNames[dateObj.getMonth()];
|
||||
},
|
||||
YY: function (dateObj) {
|
||||
return pad(String(dateObj.getFullYear()), 4).substr(2);
|
||||
},
|
||||
YYYY: function (dateObj) { return pad(dateObj.getFullYear(), 4); },
|
||||
h: function (dateObj) { return String(dateObj.getHours() % 12 || 12); },
|
||||
hh: function (dateObj) { return pad(dateObj.getHours() % 12 || 12); },
|
||||
H: function (dateObj) { return String(dateObj.getHours()); },
|
||||
HH: function (dateObj) { return pad(dateObj.getHours()); },
|
||||
m: function (dateObj) { return String(dateObj.getMinutes()); },
|
||||
mm: function (dateObj) { return pad(dateObj.getMinutes()); },
|
||||
s: function (dateObj) { return String(dateObj.getSeconds()); },
|
||||
ss: function (dateObj) { return pad(dateObj.getSeconds()); },
|
||||
S: function (dateObj) {
|
||||
return String(Math.round(dateObj.getMilliseconds() / 100));
|
||||
},
|
||||
SS: function (dateObj) {
|
||||
return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
|
||||
},
|
||||
SSS: function (dateObj) { return pad(dateObj.getMilliseconds(), 3); },
|
||||
a: function (dateObj, i18n) {
|
||||
return dateObj.getHours() < 12 ? i18n.amPm[0] : i18n.amPm[1];
|
||||
},
|
||||
A: function (dateObj, i18n) {
|
||||
return dateObj.getHours() < 12
|
||||
? i18n.amPm[0].toUpperCase()
|
||||
: i18n.amPm[1].toUpperCase();
|
||||
},
|
||||
ZZ: function (dateObj) {
|
||||
var offset = dateObj.getTimezoneOffset();
|
||||
return ((offset > 0 ? "-" : "+") +
|
||||
pad(Math.floor(Math.abs(offset) / 60) * 100 + (Math.abs(offset) % 60), 4));
|
||||
},
|
||||
Z: function (dateObj) {
|
||||
var offset = dateObj.getTimezoneOffset();
|
||||
return ((offset > 0 ? "-" : "+") +
|
||||
pad(Math.floor(Math.abs(offset) / 60), 2) +
|
||||
":" +
|
||||
pad(Math.abs(offset) % 60, 2));
|
||||
}
|
||||
};
|
||||
var monthParse = function (v) { return +v - 1; };
|
||||
var emptyDigits = [null, twoDigitsOptional];
|
||||
var emptyWord = [null, word];
|
||||
var amPm = [
|
||||
"isPm",
|
||||
word,
|
||||
function (v, i18n) {
|
||||
var val = v.toLowerCase();
|
||||
if (val === i18n.amPm[0]) {
|
||||
return 0;
|
||||
}
|
||||
else if (val === i18n.amPm[1]) {
|
||||
return 1;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
];
|
||||
var timezoneOffset = [
|
||||
"timezoneOffset",
|
||||
"[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z?",
|
||||
function (v) {
|
||||
var parts = (v + "").match(/([+-]|\d\d)/gi);
|
||||
if (parts) {
|
||||
var minutes = +parts[1] * 60 + parseInt(parts[2], 10);
|
||||
return parts[0] === "+" ? minutes : -minutes;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
];
|
||||
var parseFlags = {
|
||||
D: ["day", twoDigitsOptional],
|
||||
DD: ["day", twoDigits],
|
||||
Do: ["day", twoDigitsOptional + word, function (v) { return parseInt(v, 10); }],
|
||||
M: ["month", twoDigitsOptional, monthParse],
|
||||
MM: ["month", twoDigits, monthParse],
|
||||
YY: [
|
||||
"year",
|
||||
twoDigits,
|
||||
function (v) {
|
||||
var now = new Date();
|
||||
var cent = +("" + now.getFullYear()).substr(0, 2);
|
||||
return +("" + (+v > 68 ? cent - 1 : cent) + v);
|
||||
}
|
||||
],
|
||||
h: ["hour", twoDigitsOptional, undefined, "isPm"],
|
||||
hh: ["hour", twoDigits, undefined, "isPm"],
|
||||
H: ["hour", twoDigitsOptional],
|
||||
HH: ["hour", twoDigits],
|
||||
m: ["minute", twoDigitsOptional],
|
||||
mm: ["minute", twoDigits],
|
||||
s: ["second", twoDigitsOptional],
|
||||
ss: ["second", twoDigits],
|
||||
YYYY: ["year", fourDigits],
|
||||
S: ["millisecond", "\\d", function (v) { return +v * 100; }],
|
||||
SS: ["millisecond", twoDigits, function (v) { return +v * 10; }],
|
||||
SSS: ["millisecond", threeDigits],
|
||||
d: emptyDigits,
|
||||
dd: emptyDigits,
|
||||
ddd: emptyWord,
|
||||
dddd: emptyWord,
|
||||
MMM: ["month", word, monthUpdate("monthNamesShort")],
|
||||
MMMM: ["month", word, monthUpdate("monthNames")],
|
||||
a: amPm,
|
||||
A: amPm,
|
||||
ZZ: timezoneOffset,
|
||||
Z: timezoneOffset
|
||||
};
|
||||
// Some common format strings
|
||||
var globalMasks = {
|
||||
default: "ddd MMM DD YYYY HH:mm:ss",
|
||||
shortDate: "M/D/YY",
|
||||
mediumDate: "MMM D, YYYY",
|
||||
longDate: "MMMM D, YYYY",
|
||||
fullDate: "dddd, MMMM D, YYYY",
|
||||
isoDate: "YYYY-MM-DD",
|
||||
isoDateTime: "YYYY-MM-DDTHH:mm:ssZ",
|
||||
shortTime: "HH:mm",
|
||||
mediumTime: "HH:mm:ss",
|
||||
longTime: "HH:mm:ss.SSS"
|
||||
};
|
||||
var setGlobalDateMasks = function (masks) { return assign(globalMasks, masks); };
|
||||
/***
|
||||
* Format a date
|
||||
* @method format
|
||||
* @param {Date|number} dateObj
|
||||
* @param {string} mask Format of the date, i.e. 'mm-dd-yy' or 'shortDate'
|
||||
* @returns {string} Formatted date string
|
||||
*/
|
||||
var format = function (dateObj, mask, i18n) {
|
||||
if (mask === void 0) { mask = globalMasks["default"]; }
|
||||
if (i18n === void 0) { i18n = {}; }
|
||||
if (typeof dateObj === "number") {
|
||||
dateObj = new Date(dateObj);
|
||||
}
|
||||
if (Object.prototype.toString.call(dateObj) !== "[object Date]" ||
|
||||
isNaN(dateObj.getTime())) {
|
||||
throw new Error("Invalid Date pass to format");
|
||||
}
|
||||
mask = globalMasks[mask] || mask;
|
||||
var literals = [];
|
||||
// Make literals inactive by replacing them with @@@
|
||||
mask = mask.replace(literal, function ($0, $1) {
|
||||
literals.push($1);
|
||||
return "@@@";
|
||||
});
|
||||
var combinedI18nSettings = assign(assign({}, globalI18n), i18n);
|
||||
// Apply formatting rules
|
||||
mask = mask.replace(token, function ($0) {
|
||||
return formatFlags[$0](dateObj, combinedI18nSettings);
|
||||
});
|
||||
// Inline literal values back into the formatted value
|
||||
return mask.replace(/@@@/g, function () { return literals.shift(); });
|
||||
};
|
||||
/**
|
||||
* Parse a date string into a Javascript Date object /
|
||||
* @method parse
|
||||
* @param {string} dateStr Date string
|
||||
* @param {string} format Date parse format
|
||||
* @param {i18n} I18nSettingsOptional Full or subset of I18N settings
|
||||
* @returns {Date|null} Returns Date object. Returns null what date string is invalid or doesn't match format
|
||||
*/
|
||||
function parse(dateStr, format, i18n) {
|
||||
if (i18n === void 0) { i18n = {}; }
|
||||
if (typeof format !== "string") {
|
||||
throw new Error("Invalid format in fecha parse");
|
||||
}
|
||||
// Check to see if the format is actually a mask
|
||||
format = globalMasks[format] || format;
|
||||
// Avoid regular expression denial of service, fail early for really long strings
|
||||
// https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
|
||||
if (dateStr.length > 1000) {
|
||||
return null;
|
||||
}
|
||||
// Default to the beginning of the year.
|
||||
var today = new Date();
|
||||
var dateInfo = {
|
||||
year: today.getFullYear(),
|
||||
month: 0,
|
||||
day: 1,
|
||||
hour: 0,
|
||||
minute: 0,
|
||||
second: 0,
|
||||
millisecond: 0,
|
||||
isPm: null,
|
||||
timezoneOffset: null
|
||||
};
|
||||
var parseInfo = [];
|
||||
var literals = [];
|
||||
// Replace all the literals with @@@. Hopefully a string that won't exist in the format
|
||||
var newFormat = format.replace(literal, function ($0, $1) {
|
||||
literals.push(regexEscape($1));
|
||||
return "@@@";
|
||||
});
|
||||
var specifiedFields = {};
|
||||
var requiredFields = {};
|
||||
// Change every token that we find into the correct regex
|
||||
newFormat = regexEscape(newFormat).replace(token, function ($0) {
|
||||
var info = parseFlags[$0];
|
||||
var field = info[0], regex = info[1], requiredField = info[3];
|
||||
// Check if the person has specified the same field twice. This will lead to confusing results.
|
||||
if (specifiedFields[field]) {
|
||||
throw new Error("Invalid format. " + field + " specified twice in format");
|
||||
}
|
||||
specifiedFields[field] = true;
|
||||
// Check if there are any required fields. For instance, 12 hour time requires AM/PM specified
|
||||
if (requiredField) {
|
||||
requiredFields[requiredField] = true;
|
||||
}
|
||||
parseInfo.push(info);
|
||||
return "(" + regex + ")";
|
||||
});
|
||||
// Check all the required fields are present
|
||||
Object.keys(requiredFields).forEach(function (field) {
|
||||
if (!specifiedFields[field]) {
|
||||
throw new Error("Invalid format. " + field + " is required in specified format");
|
||||
}
|
||||
});
|
||||
// Add back all the literals after
|
||||
newFormat = newFormat.replace(/@@@/g, function () { return literals.shift(); });
|
||||
// Check if the date string matches the format. If it doesn't return null
|
||||
var matches = dateStr.match(new RegExp(newFormat, "i"));
|
||||
if (!matches) {
|
||||
return null;
|
||||
}
|
||||
var combinedI18nSettings = assign(assign({}, globalI18n), i18n);
|
||||
// For each match, call the parser function for that date part
|
||||
for (var i = 1; i < matches.length; i++) {
|
||||
var _a = parseInfo[i - 1], field = _a[0], parser = _a[2];
|
||||
var value = parser
|
||||
? parser(matches[i], combinedI18nSettings)
|
||||
: +matches[i];
|
||||
// If the parser can't make sense of the value, return null
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
dateInfo[field] = value;
|
||||
}
|
||||
if (dateInfo.isPm === 1 && dateInfo.hour != null && +dateInfo.hour !== 12) {
|
||||
dateInfo.hour = +dateInfo.hour + 12;
|
||||
}
|
||||
else if (dateInfo.isPm === 0 && +dateInfo.hour === 12) {
|
||||
dateInfo.hour = 0;
|
||||
}
|
||||
var dateTZ;
|
||||
if (dateInfo.timezoneOffset == null) {
|
||||
dateTZ = new Date(dateInfo.year, dateInfo.month, dateInfo.day, dateInfo.hour, dateInfo.minute, dateInfo.second, dateInfo.millisecond);
|
||||
var validateFields = [
|
||||
["month", "getMonth"],
|
||||
["day", "getDate"],
|
||||
["hour", "getHours"],
|
||||
["minute", "getMinutes"],
|
||||
["second", "getSeconds"]
|
||||
];
|
||||
for (var i = 0, len = validateFields.length; i < len; i++) {
|
||||
// Check to make sure the date field is within the allowed range. Javascript dates allows values
|
||||
// outside the allowed range. If the values don't match the value was invalid
|
||||
if (specifiedFields[validateFields[i][0]] &&
|
||||
dateInfo[validateFields[i][0]] !== dateTZ[validateFields[i][1]]()) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
dateTZ = new Date(Date.UTC(dateInfo.year, dateInfo.month, dateInfo.day, dateInfo.hour, dateInfo.minute - dateInfo.timezoneOffset, dateInfo.second, dateInfo.millisecond));
|
||||
// We can't validate dates in another timezone unfortunately. Do a basic check instead
|
||||
if (dateInfo.month > 11 ||
|
||||
dateInfo.month < 0 ||
|
||||
dateInfo.day > 31 ||
|
||||
dateInfo.day < 1 ||
|
||||
dateInfo.hour > 23 ||
|
||||
dateInfo.hour < 0 ||
|
||||
dateInfo.minute > 59 ||
|
||||
dateInfo.minute < 0 ||
|
||||
dateInfo.second > 59 ||
|
||||
dateInfo.second < 0) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
// Don't allow invalid dates
|
||||
return dateTZ;
|
||||
}
|
||||
var fecha = {
|
||||
format: format,
|
||||
parse: parse,
|
||||
defaultI18n: defaultI18n,
|
||||
setGlobalDateI18n: setGlobalDateI18n,
|
||||
setGlobalDateMasks: setGlobalDateMasks
|
||||
};
|
||||
|
||||
export default fecha;
|
||||
export { assign, format, parse, defaultI18n, setGlobalDateI18n, setGlobalDateMasks };
|
||||
//# sourceMappingURL=fecha.js.map
|
||||
1
unified-ai-platform/node_modules/logform/node_modules/fecha/lib/fecha.js.map
generated
vendored
Normal file
1
unified-ai-platform/node_modules/logform/node_modules/fecha/lib/fecha.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
418
unified-ai-platform/node_modules/logform/node_modules/fecha/lib/fecha.umd.js
generated
vendored
Normal file
418
unified-ai-platform/node_modules/logform/node_modules/fecha/lib/fecha.umd.js
generated
vendored
Normal file
@@ -0,0 +1,418 @@
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
||||
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
||||
(factory((global.fecha = {})));
|
||||
}(this, (function (exports) { 'use strict';
|
||||
|
||||
var token = /d{1,4}|M{1,4}|YY(?:YY)?|S{1,3}|Do|ZZ|Z|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
|
||||
var twoDigitsOptional = "\\d\\d?";
|
||||
var twoDigits = "\\d\\d";
|
||||
var threeDigits = "\\d{3}";
|
||||
var fourDigits = "\\d{4}";
|
||||
var word = "[^\\s]+";
|
||||
var literal = /\[([^]*?)\]/gm;
|
||||
function shorten(arr, sLen) {
|
||||
var newArr = [];
|
||||
for (var i = 0, len = arr.length; i < len; i++) {
|
||||
newArr.push(arr[i].substr(0, sLen));
|
||||
}
|
||||
return newArr;
|
||||
}
|
||||
var monthUpdate = function (arrName) { return function (v, i18n) {
|
||||
var lowerCaseArr = i18n[arrName].map(function (v) { return v.toLowerCase(); });
|
||||
var index = lowerCaseArr.indexOf(v.toLowerCase());
|
||||
if (index > -1) {
|
||||
return index;
|
||||
}
|
||||
return null;
|
||||
}; };
|
||||
function assign(origObj) {
|
||||
var args = [];
|
||||
for (var _i = 1; _i < arguments.length; _i++) {
|
||||
args[_i - 1] = arguments[_i];
|
||||
}
|
||||
for (var _a = 0, args_1 = args; _a < args_1.length; _a++) {
|
||||
var obj = args_1[_a];
|
||||
for (var key in obj) {
|
||||
// @ts-ignore ex
|
||||
origObj[key] = obj[key];
|
||||
}
|
||||
}
|
||||
return origObj;
|
||||
}
|
||||
var dayNames = [
|
||||
"Sunday",
|
||||
"Monday",
|
||||
"Tuesday",
|
||||
"Wednesday",
|
||||
"Thursday",
|
||||
"Friday",
|
||||
"Saturday"
|
||||
];
|
||||
var monthNames = [
|
||||
"January",
|
||||
"February",
|
||||
"March",
|
||||
"April",
|
||||
"May",
|
||||
"June",
|
||||
"July",
|
||||
"August",
|
||||
"September",
|
||||
"October",
|
||||
"November",
|
||||
"December"
|
||||
];
|
||||
var monthNamesShort = shorten(monthNames, 3);
|
||||
var dayNamesShort = shorten(dayNames, 3);
|
||||
var defaultI18n = {
|
||||
dayNamesShort: dayNamesShort,
|
||||
dayNames: dayNames,
|
||||
monthNamesShort: monthNamesShort,
|
||||
monthNames: monthNames,
|
||||
amPm: ["am", "pm"],
|
||||
DoFn: function (dayOfMonth) {
|
||||
return (dayOfMonth +
|
||||
["th", "st", "nd", "rd"][dayOfMonth % 10 > 3
|
||||
? 0
|
||||
: ((dayOfMonth - (dayOfMonth % 10) !== 10 ? 1 : 0) * dayOfMonth) % 10]);
|
||||
}
|
||||
};
|
||||
var globalI18n = assign({}, defaultI18n);
|
||||
var setGlobalDateI18n = function (i18n) {
|
||||
return (globalI18n = assign(globalI18n, i18n));
|
||||
};
|
||||
var regexEscape = function (str) {
|
||||
return str.replace(/[|\\{()[^$+*?.-]/g, "\\$&");
|
||||
};
|
||||
var pad = function (val, len) {
|
||||
if (len === void 0) { len = 2; }
|
||||
val = String(val);
|
||||
while (val.length < len) {
|
||||
val = "0" + val;
|
||||
}
|
||||
return val;
|
||||
};
|
||||
var formatFlags = {
|
||||
D: function (dateObj) { return String(dateObj.getDate()); },
|
||||
DD: function (dateObj) { return pad(dateObj.getDate()); },
|
||||
Do: function (dateObj, i18n) {
|
||||
return i18n.DoFn(dateObj.getDate());
|
||||
},
|
||||
d: function (dateObj) { return String(dateObj.getDay()); },
|
||||
dd: function (dateObj) { return pad(dateObj.getDay()); },
|
||||
ddd: function (dateObj, i18n) {
|
||||
return i18n.dayNamesShort[dateObj.getDay()];
|
||||
},
|
||||
dddd: function (dateObj, i18n) {
|
||||
return i18n.dayNames[dateObj.getDay()];
|
||||
},
|
||||
M: function (dateObj) { return String(dateObj.getMonth() + 1); },
|
||||
MM: function (dateObj) { return pad(dateObj.getMonth() + 1); },
|
||||
MMM: function (dateObj, i18n) {
|
||||
return i18n.monthNamesShort[dateObj.getMonth()];
|
||||
},
|
||||
MMMM: function (dateObj, i18n) {
|
||||
return i18n.monthNames[dateObj.getMonth()];
|
||||
},
|
||||
YY: function (dateObj) {
|
||||
return pad(String(dateObj.getFullYear()), 4).substr(2);
|
||||
},
|
||||
YYYY: function (dateObj) { return pad(dateObj.getFullYear(), 4); },
|
||||
h: function (dateObj) { return String(dateObj.getHours() % 12 || 12); },
|
||||
hh: function (dateObj) { return pad(dateObj.getHours() % 12 || 12); },
|
||||
H: function (dateObj) { return String(dateObj.getHours()); },
|
||||
HH: function (dateObj) { return pad(dateObj.getHours()); },
|
||||
m: function (dateObj) { return String(dateObj.getMinutes()); },
|
||||
mm: function (dateObj) { return pad(dateObj.getMinutes()); },
|
||||
s: function (dateObj) { return String(dateObj.getSeconds()); },
|
||||
ss: function (dateObj) { return pad(dateObj.getSeconds()); },
|
||||
S: function (dateObj) {
|
||||
return String(Math.round(dateObj.getMilliseconds() / 100));
|
||||
},
|
||||
SS: function (dateObj) {
|
||||
return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
|
||||
},
|
||||
SSS: function (dateObj) { return pad(dateObj.getMilliseconds(), 3); },
|
||||
a: function (dateObj, i18n) {
|
||||
return dateObj.getHours() < 12 ? i18n.amPm[0] : i18n.amPm[1];
|
||||
},
|
||||
A: function (dateObj, i18n) {
|
||||
return dateObj.getHours() < 12
|
||||
? i18n.amPm[0].toUpperCase()
|
||||
: i18n.amPm[1].toUpperCase();
|
||||
},
|
||||
ZZ: function (dateObj) {
|
||||
var offset = dateObj.getTimezoneOffset();
|
||||
return ((offset > 0 ? "-" : "+") +
|
||||
pad(Math.floor(Math.abs(offset) / 60) * 100 + (Math.abs(offset) % 60), 4));
|
||||
},
|
||||
Z: function (dateObj) {
|
||||
var offset = dateObj.getTimezoneOffset();
|
||||
return ((offset > 0 ? "-" : "+") +
|
||||
pad(Math.floor(Math.abs(offset) / 60), 2) +
|
||||
":" +
|
||||
pad(Math.abs(offset) % 60, 2));
|
||||
}
|
||||
};
|
||||
var monthParse = function (v) { return +v - 1; };
|
||||
var emptyDigits = [null, twoDigitsOptional];
|
||||
var emptyWord = [null, word];
|
||||
var amPm = [
|
||||
"isPm",
|
||||
word,
|
||||
function (v, i18n) {
|
||||
var val = v.toLowerCase();
|
||||
if (val === i18n.amPm[0]) {
|
||||
return 0;
|
||||
}
|
||||
else if (val === i18n.amPm[1]) {
|
||||
return 1;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
];
|
||||
var timezoneOffset = [
|
||||
"timezoneOffset",
|
||||
"[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z?",
|
||||
function (v) {
|
||||
var parts = (v + "").match(/([+-]|\d\d)/gi);
|
||||
if (parts) {
|
||||
var minutes = +parts[1] * 60 + parseInt(parts[2], 10);
|
||||
return parts[0] === "+" ? minutes : -minutes;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
];
|
||||
var parseFlags = {
|
||||
D: ["day", twoDigitsOptional],
|
||||
DD: ["day", twoDigits],
|
||||
Do: ["day", twoDigitsOptional + word, function (v) { return parseInt(v, 10); }],
|
||||
M: ["month", twoDigitsOptional, monthParse],
|
||||
MM: ["month", twoDigits, monthParse],
|
||||
YY: [
|
||||
"year",
|
||||
twoDigits,
|
||||
function (v) {
|
||||
var now = new Date();
|
||||
var cent = +("" + now.getFullYear()).substr(0, 2);
|
||||
return +("" + (+v > 68 ? cent - 1 : cent) + v);
|
||||
}
|
||||
],
|
||||
h: ["hour", twoDigitsOptional, undefined, "isPm"],
|
||||
hh: ["hour", twoDigits, undefined, "isPm"],
|
||||
H: ["hour", twoDigitsOptional],
|
||||
HH: ["hour", twoDigits],
|
||||
m: ["minute", twoDigitsOptional],
|
||||
mm: ["minute", twoDigits],
|
||||
s: ["second", twoDigitsOptional],
|
||||
ss: ["second", twoDigits],
|
||||
YYYY: ["year", fourDigits],
|
||||
S: ["millisecond", "\\d", function (v) { return +v * 100; }],
|
||||
SS: ["millisecond", twoDigits, function (v) { return +v * 10; }],
|
||||
SSS: ["millisecond", threeDigits],
|
||||
d: emptyDigits,
|
||||
dd: emptyDigits,
|
||||
ddd: emptyWord,
|
||||
dddd: emptyWord,
|
||||
MMM: ["month", word, monthUpdate("monthNamesShort")],
|
||||
MMMM: ["month", word, monthUpdate("monthNames")],
|
||||
a: amPm,
|
||||
A: amPm,
|
||||
ZZ: timezoneOffset,
|
||||
Z: timezoneOffset
|
||||
};
|
||||
// Some common format strings
|
||||
var globalMasks = {
|
||||
default: "ddd MMM DD YYYY HH:mm:ss",
|
||||
shortDate: "M/D/YY",
|
||||
mediumDate: "MMM D, YYYY",
|
||||
longDate: "MMMM D, YYYY",
|
||||
fullDate: "dddd, MMMM D, YYYY",
|
||||
isoDate: "YYYY-MM-DD",
|
||||
isoDateTime: "YYYY-MM-DDTHH:mm:ssZ",
|
||||
shortTime: "HH:mm",
|
||||
mediumTime: "HH:mm:ss",
|
||||
longTime: "HH:mm:ss.SSS"
|
||||
};
|
||||
var setGlobalDateMasks = function (masks) { return assign(globalMasks, masks); };
|
||||
/***
|
||||
* Format a date
|
||||
* @method format
|
||||
* @param {Date|number} dateObj
|
||||
* @param {string} mask Format of the date, i.e. 'mm-dd-yy' or 'shortDate'
|
||||
* @returns {string} Formatted date string
|
||||
*/
|
||||
var format = function (dateObj, mask, i18n) {
|
||||
if (mask === void 0) { mask = globalMasks["default"]; }
|
||||
if (i18n === void 0) { i18n = {}; }
|
||||
if (typeof dateObj === "number") {
|
||||
dateObj = new Date(dateObj);
|
||||
}
|
||||
if (Object.prototype.toString.call(dateObj) !== "[object Date]" ||
|
||||
isNaN(dateObj.getTime())) {
|
||||
throw new Error("Invalid Date pass to format");
|
||||
}
|
||||
mask = globalMasks[mask] || mask;
|
||||
var literals = [];
|
||||
// Make literals inactive by replacing them with @@@
|
||||
mask = mask.replace(literal, function ($0, $1) {
|
||||
literals.push($1);
|
||||
return "@@@";
|
||||
});
|
||||
var combinedI18nSettings = assign(assign({}, globalI18n), i18n);
|
||||
// Apply formatting rules
|
||||
mask = mask.replace(token, function ($0) {
|
||||
return formatFlags[$0](dateObj, combinedI18nSettings);
|
||||
});
|
||||
// Inline literal values back into the formatted value
|
||||
return mask.replace(/@@@/g, function () { return literals.shift(); });
|
||||
};
|
||||
/**
|
||||
* Parse a date string into a Javascript Date object /
|
||||
* @method parse
|
||||
* @param {string} dateStr Date string
|
||||
* @param {string} format Date parse format
|
||||
* @param {i18n} I18nSettingsOptional Full or subset of I18N settings
|
||||
* @returns {Date|null} Returns Date object. Returns null what date string is invalid or doesn't match format
|
||||
*/
|
||||
function parse(dateStr, format, i18n) {
|
||||
if (i18n === void 0) { i18n = {}; }
|
||||
if (typeof format !== "string") {
|
||||
throw new Error("Invalid format in fecha parse");
|
||||
}
|
||||
// Check to see if the format is actually a mask
|
||||
format = globalMasks[format] || format;
|
||||
// Avoid regular expression denial of service, fail early for really long strings
|
||||
// https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
|
||||
if (dateStr.length > 1000) {
|
||||
return null;
|
||||
}
|
||||
// Default to the beginning of the year.
|
||||
var today = new Date();
|
||||
var dateInfo = {
|
||||
year: today.getFullYear(),
|
||||
month: 0,
|
||||
day: 1,
|
||||
hour: 0,
|
||||
minute: 0,
|
||||
second: 0,
|
||||
millisecond: 0,
|
||||
isPm: null,
|
||||
timezoneOffset: null
|
||||
};
|
||||
var parseInfo = [];
|
||||
var literals = [];
|
||||
// Replace all the literals with @@@. Hopefully a string that won't exist in the format
|
||||
var newFormat = format.replace(literal, function ($0, $1) {
|
||||
literals.push(regexEscape($1));
|
||||
return "@@@";
|
||||
});
|
||||
var specifiedFields = {};
|
||||
var requiredFields = {};
|
||||
// Change every token that we find into the correct regex
|
||||
newFormat = regexEscape(newFormat).replace(token, function ($0) {
|
||||
var info = parseFlags[$0];
|
||||
var field = info[0], regex = info[1], requiredField = info[3];
|
||||
// Check if the person has specified the same field twice. This will lead to confusing results.
|
||||
if (specifiedFields[field]) {
|
||||
throw new Error("Invalid format. " + field + " specified twice in format");
|
||||
}
|
||||
specifiedFields[field] = true;
|
||||
// Check if there are any required fields. For instance, 12 hour time requires AM/PM specified
|
||||
if (requiredField) {
|
||||
requiredFields[requiredField] = true;
|
||||
}
|
||||
parseInfo.push(info);
|
||||
return "(" + regex + ")";
|
||||
});
|
||||
// Check all the required fields are present
|
||||
Object.keys(requiredFields).forEach(function (field) {
|
||||
if (!specifiedFields[field]) {
|
||||
throw new Error("Invalid format. " + field + " is required in specified format");
|
||||
}
|
||||
});
|
||||
// Add back all the literals after
|
||||
newFormat = newFormat.replace(/@@@/g, function () { return literals.shift(); });
|
||||
// Check if the date string matches the format. If it doesn't return null
|
||||
var matches = dateStr.match(new RegExp(newFormat, "i"));
|
||||
if (!matches) {
|
||||
return null;
|
||||
}
|
||||
var combinedI18nSettings = assign(assign({}, globalI18n), i18n);
|
||||
// For each match, call the parser function for that date part
|
||||
for (var i = 1; i < matches.length; i++) {
|
||||
var _a = parseInfo[i - 1], field = _a[0], parser = _a[2];
|
||||
var value = parser
|
||||
? parser(matches[i], combinedI18nSettings)
|
||||
: +matches[i];
|
||||
// If the parser can't make sense of the value, return null
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
dateInfo[field] = value;
|
||||
}
|
||||
if (dateInfo.isPm === 1 && dateInfo.hour != null && +dateInfo.hour !== 12) {
|
||||
dateInfo.hour = +dateInfo.hour + 12;
|
||||
}
|
||||
else if (dateInfo.isPm === 0 && +dateInfo.hour === 12) {
|
||||
dateInfo.hour = 0;
|
||||
}
|
||||
var dateTZ;
|
||||
if (dateInfo.timezoneOffset == null) {
|
||||
dateTZ = new Date(dateInfo.year, dateInfo.month, dateInfo.day, dateInfo.hour, dateInfo.minute, dateInfo.second, dateInfo.millisecond);
|
||||
var validateFields = [
|
||||
["month", "getMonth"],
|
||||
["day", "getDate"],
|
||||
["hour", "getHours"],
|
||||
["minute", "getMinutes"],
|
||||
["second", "getSeconds"]
|
||||
];
|
||||
for (var i = 0, len = validateFields.length; i < len; i++) {
|
||||
// Check to make sure the date field is within the allowed range. Javascript dates allows values
|
||||
// outside the allowed range. If the values don't match the value was invalid
|
||||
if (specifiedFields[validateFields[i][0]] &&
|
||||
dateInfo[validateFields[i][0]] !== dateTZ[validateFields[i][1]]()) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
dateTZ = new Date(Date.UTC(dateInfo.year, dateInfo.month, dateInfo.day, dateInfo.hour, dateInfo.minute - dateInfo.timezoneOffset, dateInfo.second, dateInfo.millisecond));
|
||||
// We can't validate dates in another timezone unfortunately. Do a basic check instead
|
||||
if (dateInfo.month > 11 ||
|
||||
dateInfo.month < 0 ||
|
||||
dateInfo.day > 31 ||
|
||||
dateInfo.day < 1 ||
|
||||
dateInfo.hour > 23 ||
|
||||
dateInfo.hour < 0 ||
|
||||
dateInfo.minute > 59 ||
|
||||
dateInfo.minute < 0 ||
|
||||
dateInfo.second > 59 ||
|
||||
dateInfo.second < 0) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
// Don't allow invalid dates
|
||||
return dateTZ;
|
||||
}
|
||||
var fecha = {
|
||||
format: format,
|
||||
parse: parse,
|
||||
defaultI18n: defaultI18n,
|
||||
setGlobalDateI18n: setGlobalDateI18n,
|
||||
setGlobalDateMasks: setGlobalDateMasks
|
||||
};
|
||||
|
||||
exports.assign = assign;
|
||||
exports.default = fecha;
|
||||
exports.format = format;
|
||||
exports.parse = parse;
|
||||
exports.defaultI18n = defaultI18n;
|
||||
exports.setGlobalDateI18n = setGlobalDateI18n;
|
||||
exports.setGlobalDateMasks = setGlobalDateMasks;
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
})));
|
||||
//# sourceMappingURL=fecha.umd.js.map
|
||||
1
unified-ai-platform/node_modules/logform/node_modules/fecha/lib/fecha.umd.js.map
generated
vendored
Normal file
1
unified-ai-platform/node_modules/logform/node_modules/fecha/lib/fecha.umd.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
55
unified-ai-platform/node_modules/logform/node_modules/fecha/package.json
generated
vendored
Normal file
55
unified-ai-platform/node_modules/logform/node_modules/fecha/package.json
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
{
|
||||
"name": "fecha",
|
||||
"version": "4.2.3",
|
||||
"description": "Date formatting and parsing",
|
||||
"main": "lib/fecha.umd.js",
|
||||
"module": "lib/fecha.js",
|
||||
"scripts": {
|
||||
"test-only": "ts-node test.js",
|
||||
"test": "prettier --check *.js src/*.ts && eslint --ext .ts src && npm run build && nyc --cache --reporter=text ts-node test.js",
|
||||
"build": "NODE_ENV=production rollup -c --sourcemap && tsc",
|
||||
"format": "prettier --write *.js src/*.ts"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://taylorhakes@github.com/taylorhakes/fecha.git"
|
||||
},
|
||||
"keywords": [
|
||||
"date",
|
||||
"parse",
|
||||
"moment",
|
||||
"format",
|
||||
"fecha",
|
||||
"formatting"
|
||||
],
|
||||
"author": "Taylor Hakes",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/taylorhakes/fecha/issues"
|
||||
},
|
||||
"homepage": "https://github.com/taylorhakes/fecha",
|
||||
"devDependencies": {
|
||||
"@istanbuljs/nyc-config-typescript": "^1.0.1",
|
||||
"@typescript-eslint/eslint-plugin": "^2.14.0",
|
||||
"@typescript-eslint/parser": "^2.14.0",
|
||||
"eslint": "^7.23.0",
|
||||
"eslint-config-prettier": "^8.1.0",
|
||||
"nyc": "^15.0.0",
|
||||
"painless": "^0.9.7",
|
||||
"prettier": "1.19.1",
|
||||
"rollup": "^0.59.0",
|
||||
"rollup-plugin-sourcemaps": "^0.5.0",
|
||||
"rollup-plugin-typescript": "^1.0.1",
|
||||
"rollup-plugin-uglify": "^3.0.0",
|
||||
"source-map-support": "^0.5.16",
|
||||
"ts-node": "^8.5.4",
|
||||
"tslib": "^1.10.0",
|
||||
"typescript": "^3.7.4"
|
||||
},
|
||||
"files": [
|
||||
"lib",
|
||||
"dist",
|
||||
"src"
|
||||
],
|
||||
"types": "lib/fecha.d.ts"
|
||||
}
|
||||
524
unified-ai-platform/node_modules/logform/node_modules/fecha/src/fecha.ts
generated
vendored
Normal file
524
unified-ai-platform/node_modules/logform/node_modules/fecha/src/fecha.ts
generated
vendored
Normal file
@@ -0,0 +1,524 @@
|
||||
const token = /d{1,4}|M{1,4}|YY(?:YY)?|S{1,3}|Do|ZZ|Z|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
|
||||
const twoDigitsOptional = "\\d\\d?";
|
||||
const twoDigits = "\\d\\d";
|
||||
const threeDigits = "\\d{3}";
|
||||
const fourDigits = "\\d{4}";
|
||||
const word = "[^\\s]+";
|
||||
const literal = /\[([^]*?)\]/gm;
|
||||
|
||||
type DateInfo = {
|
||||
year: number;
|
||||
month: number;
|
||||
day: number;
|
||||
hour: number;
|
||||
minute: number;
|
||||
second: number;
|
||||
millisecond: number;
|
||||
isPm: number | null;
|
||||
timezoneOffset: number | null;
|
||||
};
|
||||
|
||||
export type I18nSettings = {
|
||||
amPm: [string, string];
|
||||
dayNames: Days;
|
||||
dayNamesShort: Days;
|
||||
monthNames: Months;
|
||||
monthNamesShort: Months;
|
||||
DoFn(dayOfMonth: number): string;
|
||||
};
|
||||
|
||||
export type I18nSettingsOptional = Partial<I18nSettings>;
|
||||
|
||||
export type Days = [string, string, string, string, string, string, string];
|
||||
export type Months = [
|
||||
string,
|
||||
string,
|
||||
string,
|
||||
string,
|
||||
string,
|
||||
string,
|
||||
string,
|
||||
string,
|
||||
string,
|
||||
string,
|
||||
string,
|
||||
string
|
||||
];
|
||||
|
||||
function shorten<T extends string[]>(arr: T, sLen: number): string[] {
|
||||
const newArr: string[] = [];
|
||||
for (let i = 0, len = arr.length; i < len; i++) {
|
||||
newArr.push(arr[i].substr(0, sLen));
|
||||
}
|
||||
return newArr;
|
||||
}
|
||||
|
||||
const monthUpdate = (
|
||||
arrName: "monthNames" | "monthNamesShort" | "dayNames" | "dayNamesShort"
|
||||
) => (v: string, i18n: I18nSettings): number | null => {
|
||||
const lowerCaseArr = i18n[arrName].map(v => v.toLowerCase());
|
||||
const index = lowerCaseArr.indexOf(v.toLowerCase());
|
||||
if (index > -1) {
|
||||
return index;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
export function assign<A>(a: A): A;
|
||||
export function assign<A, B>(a: A, b: B): A & B;
|
||||
export function assign<A, B, C>(a: A, b: B, c: C): A & B & C;
|
||||
export function assign<A, B, C, D>(a: A, b: B, c: C, d: D): A & B & C & D;
|
||||
export function assign(origObj: any, ...args: any[]): any {
|
||||
for (const obj of args) {
|
||||
for (const key in obj) {
|
||||
// @ts-ignore ex
|
||||
origObj[key] = obj[key];
|
||||
}
|
||||
}
|
||||
return origObj;
|
||||
}
|
||||
|
||||
const dayNames: Days = [
|
||||
"Sunday",
|
||||
"Monday",
|
||||
"Tuesday",
|
||||
"Wednesday",
|
||||
"Thursday",
|
||||
"Friday",
|
||||
"Saturday"
|
||||
];
|
||||
const monthNames: Months = [
|
||||
"January",
|
||||
"February",
|
||||
"March",
|
||||
"April",
|
||||
"May",
|
||||
"June",
|
||||
"July",
|
||||
"August",
|
||||
"September",
|
||||
"October",
|
||||
"November",
|
||||
"December"
|
||||
];
|
||||
|
||||
const monthNamesShort: Months = shorten(monthNames, 3) as Months;
|
||||
const dayNamesShort: Days = shorten(dayNames, 3) as Days;
|
||||
|
||||
const defaultI18n: I18nSettings = {
|
||||
dayNamesShort,
|
||||
dayNames,
|
||||
monthNamesShort,
|
||||
monthNames,
|
||||
amPm: ["am", "pm"],
|
||||
DoFn(dayOfMonth: number) {
|
||||
return (
|
||||
dayOfMonth +
|
||||
["th", "st", "nd", "rd"][
|
||||
dayOfMonth % 10 > 3
|
||||
? 0
|
||||
: ((dayOfMonth - (dayOfMonth % 10) !== 10 ? 1 : 0) * dayOfMonth) % 10
|
||||
]
|
||||
);
|
||||
}
|
||||
};
|
||||
let globalI18n = assign({}, defaultI18n);
|
||||
const setGlobalDateI18n = (i18n: I18nSettingsOptional): I18nSettings =>
|
||||
(globalI18n = assign(globalI18n, i18n));
|
||||
|
||||
const regexEscape = (str: string): string =>
|
||||
str.replace(/[|\\{()[^$+*?.-]/g, "\\$&");
|
||||
|
||||
const pad = (val: string | number, len = 2): string => {
|
||||
val = String(val);
|
||||
while (val.length < len) {
|
||||
val = "0" + val;
|
||||
}
|
||||
return val;
|
||||
};
|
||||
|
||||
const formatFlags: Record<
|
||||
string,
|
||||
(dateObj: Date, i18n: I18nSettings) => string
|
||||
> = {
|
||||
D: (dateObj: Date): string => String(dateObj.getDate()),
|
||||
DD: (dateObj: Date): string => pad(dateObj.getDate()),
|
||||
Do: (dateObj: Date, i18n: I18nSettings): string =>
|
||||
i18n.DoFn(dateObj.getDate()),
|
||||
d: (dateObj: Date): string => String(dateObj.getDay()),
|
||||
dd: (dateObj: Date): string => pad(dateObj.getDay()),
|
||||
ddd: (dateObj: Date, i18n: I18nSettings): string =>
|
||||
i18n.dayNamesShort[dateObj.getDay()],
|
||||
dddd: (dateObj: Date, i18n: I18nSettings): string =>
|
||||
i18n.dayNames[dateObj.getDay()],
|
||||
M: (dateObj: Date): string => String(dateObj.getMonth() + 1),
|
||||
MM: (dateObj: Date): string => pad(dateObj.getMonth() + 1),
|
||||
MMM: (dateObj: Date, i18n: I18nSettings): string =>
|
||||
i18n.monthNamesShort[dateObj.getMonth()],
|
||||
MMMM: (dateObj: Date, i18n: I18nSettings): string =>
|
||||
i18n.monthNames[dateObj.getMonth()],
|
||||
YY: (dateObj: Date): string =>
|
||||
pad(String(dateObj.getFullYear()), 4).substr(2),
|
||||
YYYY: (dateObj: Date): string => pad(dateObj.getFullYear(), 4),
|
||||
h: (dateObj: Date): string => String(dateObj.getHours() % 12 || 12),
|
||||
hh: (dateObj: Date): string => pad(dateObj.getHours() % 12 || 12),
|
||||
H: (dateObj: Date): string => String(dateObj.getHours()),
|
||||
HH: (dateObj: Date): string => pad(dateObj.getHours()),
|
||||
m: (dateObj: Date): string => String(dateObj.getMinutes()),
|
||||
mm: (dateObj: Date): string => pad(dateObj.getMinutes()),
|
||||
s: (dateObj: Date): string => String(dateObj.getSeconds()),
|
||||
ss: (dateObj: Date): string => pad(dateObj.getSeconds()),
|
||||
S: (dateObj: Date): string =>
|
||||
String(Math.round(dateObj.getMilliseconds() / 100)),
|
||||
SS: (dateObj: Date): string =>
|
||||
pad(Math.round(dateObj.getMilliseconds() / 10), 2),
|
||||
SSS: (dateObj: Date): string => pad(dateObj.getMilliseconds(), 3),
|
||||
a: (dateObj: Date, i18n: I18nSettings): string =>
|
||||
dateObj.getHours() < 12 ? i18n.amPm[0] : i18n.amPm[1],
|
||||
A: (dateObj: Date, i18n: I18nSettings): string =>
|
||||
dateObj.getHours() < 12
|
||||
? i18n.amPm[0].toUpperCase()
|
||||
: i18n.amPm[1].toUpperCase(),
|
||||
ZZ(dateObj: Date): string {
|
||||
const offset = dateObj.getTimezoneOffset();
|
||||
return (
|
||||
(offset > 0 ? "-" : "+") +
|
||||
pad(Math.floor(Math.abs(offset) / 60) * 100 + (Math.abs(offset) % 60), 4)
|
||||
);
|
||||
},
|
||||
Z(dateObj: Date): string {
|
||||
const offset = dateObj.getTimezoneOffset();
|
||||
return (
|
||||
(offset > 0 ? "-" : "+") +
|
||||
pad(Math.floor(Math.abs(offset) / 60), 2) +
|
||||
":" +
|
||||
pad(Math.abs(offset) % 60, 2)
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
type ParseInfo = [
|
||||
keyof DateInfo,
|
||||
string,
|
||||
((v: string, i18n: I18nSettings) => number | null)?,
|
||||
string?
|
||||
];
|
||||
const monthParse = (v: string): number => +v - 1;
|
||||
const emptyDigits: ParseInfo = [null, twoDigitsOptional];
|
||||
const emptyWord: ParseInfo = [null, word];
|
||||
const amPm: ParseInfo = [
|
||||
"isPm",
|
||||
word,
|
||||
(v: string, i18n: I18nSettings): number | null => {
|
||||
const val = v.toLowerCase();
|
||||
if (val === i18n.amPm[0]) {
|
||||
return 0;
|
||||
} else if (val === i18n.amPm[1]) {
|
||||
return 1;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
];
|
||||
const timezoneOffset: ParseInfo = [
|
||||
"timezoneOffset",
|
||||
"[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z?",
|
||||
(v: string): number | null => {
|
||||
const parts = (v + "").match(/([+-]|\d\d)/gi);
|
||||
|
||||
if (parts) {
|
||||
const minutes = +parts[1] * 60 + parseInt(parts[2], 10);
|
||||
return parts[0] === "+" ? minutes : -minutes;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
];
|
||||
const parseFlags: Record<string, ParseInfo> = {
|
||||
D: ["day", twoDigitsOptional],
|
||||
DD: ["day", twoDigits],
|
||||
Do: ["day", twoDigitsOptional + word, (v: string): number => parseInt(v, 10)],
|
||||
M: ["month", twoDigitsOptional, monthParse],
|
||||
MM: ["month", twoDigits, monthParse],
|
||||
YY: [
|
||||
"year",
|
||||
twoDigits,
|
||||
(v: string): number => {
|
||||
const now = new Date();
|
||||
const cent = +("" + now.getFullYear()).substr(0, 2);
|
||||
return +("" + (+v > 68 ? cent - 1 : cent) + v);
|
||||
}
|
||||
],
|
||||
h: ["hour", twoDigitsOptional, undefined, "isPm"],
|
||||
hh: ["hour", twoDigits, undefined, "isPm"],
|
||||
H: ["hour", twoDigitsOptional],
|
||||
HH: ["hour", twoDigits],
|
||||
m: ["minute", twoDigitsOptional],
|
||||
mm: ["minute", twoDigits],
|
||||
s: ["second", twoDigitsOptional],
|
||||
ss: ["second", twoDigits],
|
||||
YYYY: ["year", fourDigits],
|
||||
S: ["millisecond", "\\d", (v: string): number => +v * 100],
|
||||
SS: ["millisecond", twoDigits, (v: string): number => +v * 10],
|
||||
SSS: ["millisecond", threeDigits],
|
||||
d: emptyDigits,
|
||||
dd: emptyDigits,
|
||||
ddd: emptyWord,
|
||||
dddd: emptyWord,
|
||||
MMM: ["month", word, monthUpdate("monthNamesShort")],
|
||||
MMMM: ["month", word, monthUpdate("monthNames")],
|
||||
a: amPm,
|
||||
A: amPm,
|
||||
ZZ: timezoneOffset,
|
||||
Z: timezoneOffset
|
||||
};
|
||||
|
||||
// Some common format strings
|
||||
const globalMasks: { [key: string]: string } = {
|
||||
default: "ddd MMM DD YYYY HH:mm:ss",
|
||||
shortDate: "M/D/YY",
|
||||
mediumDate: "MMM D, YYYY",
|
||||
longDate: "MMMM D, YYYY",
|
||||
fullDate: "dddd, MMMM D, YYYY",
|
||||
isoDate: "YYYY-MM-DD",
|
||||
isoDateTime: "YYYY-MM-DDTHH:mm:ssZ",
|
||||
shortTime: "HH:mm",
|
||||
mediumTime: "HH:mm:ss",
|
||||
longTime: "HH:mm:ss.SSS"
|
||||
};
|
||||
const setGlobalDateMasks = (masks: {
|
||||
[key: string]: string;
|
||||
}): { [key: string]: string } => assign(globalMasks, masks);
|
||||
|
||||
/***
|
||||
* Format a date
|
||||
* @method format
|
||||
* @param {Date|number} dateObj
|
||||
* @param {string} mask Format of the date, i.e. 'mm-dd-yy' or 'shortDate'
|
||||
* @returns {string} Formatted date string
|
||||
*/
|
||||
const format = (
|
||||
dateObj: Date,
|
||||
mask: string = globalMasks["default"],
|
||||
i18n: I18nSettingsOptional = {}
|
||||
): string => {
|
||||
if (typeof dateObj === "number") {
|
||||
dateObj = new Date(dateObj);
|
||||
}
|
||||
|
||||
if (
|
||||
Object.prototype.toString.call(dateObj) !== "[object Date]" ||
|
||||
isNaN(dateObj.getTime())
|
||||
) {
|
||||
throw new Error("Invalid Date pass to format");
|
||||
}
|
||||
|
||||
mask = globalMasks[mask] || mask;
|
||||
|
||||
const literals: string[] = [];
|
||||
|
||||
// Make literals inactive by replacing them with @@@
|
||||
mask = mask.replace(literal, function($0, $1) {
|
||||
literals.push($1);
|
||||
return "@@@";
|
||||
});
|
||||
|
||||
const combinedI18nSettings: I18nSettings = assign(
|
||||
assign({}, globalI18n),
|
||||
i18n
|
||||
);
|
||||
// Apply formatting rules
|
||||
mask = mask.replace(token, $0 =>
|
||||
formatFlags[$0](dateObj, combinedI18nSettings)
|
||||
);
|
||||
// Inline literal values back into the formatted value
|
||||
return mask.replace(/@@@/g, () => literals.shift());
|
||||
};
|
||||
|
||||
/**
|
||||
* Parse a date string into a Javascript Date object /
|
||||
* @method parse
|
||||
* @param {string} dateStr Date string
|
||||
* @param {string} format Date parse format
|
||||
* @param {i18n} I18nSettingsOptional Full or subset of I18N settings
|
||||
* @returns {Date|null} Returns Date object. Returns null what date string is invalid or doesn't match format
|
||||
*/
|
||||
function parse(
|
||||
dateStr: string,
|
||||
format: string,
|
||||
i18n: I18nSettingsOptional = {}
|
||||
): Date | null {
|
||||
if (typeof format !== "string") {
|
||||
throw new Error("Invalid format in fecha parse");
|
||||
}
|
||||
|
||||
// Check to see if the format is actually a mask
|
||||
format = globalMasks[format] || format;
|
||||
|
||||
// Avoid regular expression denial of service, fail early for really long strings
|
||||
// https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
|
||||
if (dateStr.length > 1000) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Default to the beginning of the year.
|
||||
const today = new Date();
|
||||
const dateInfo: DateInfo = {
|
||||
year: today.getFullYear(),
|
||||
month: 0,
|
||||
day: 1,
|
||||
hour: 0,
|
||||
minute: 0,
|
||||
second: 0,
|
||||
millisecond: 0,
|
||||
isPm: null,
|
||||
timezoneOffset: null
|
||||
};
|
||||
const parseInfo: ParseInfo[] = [];
|
||||
const literals: string[] = [];
|
||||
|
||||
// Replace all the literals with @@@. Hopefully a string that won't exist in the format
|
||||
let newFormat = format.replace(literal, ($0, $1) => {
|
||||
literals.push(regexEscape($1));
|
||||
return "@@@";
|
||||
});
|
||||
const specifiedFields: { [field: string]: boolean } = {};
|
||||
const requiredFields: { [field: string]: boolean } = {};
|
||||
|
||||
// Change every token that we find into the correct regex
|
||||
newFormat = regexEscape(newFormat).replace(token, $0 => {
|
||||
const info = parseFlags[$0];
|
||||
const [field, regex, , requiredField] = info;
|
||||
|
||||
// Check if the person has specified the same field twice. This will lead to confusing results.
|
||||
if (specifiedFields[field]) {
|
||||
throw new Error(`Invalid format. ${field} specified twice in format`);
|
||||
}
|
||||
|
||||
specifiedFields[field] = true;
|
||||
|
||||
// Check if there are any required fields. For instance, 12 hour time requires AM/PM specified
|
||||
if (requiredField) {
|
||||
requiredFields[requiredField] = true;
|
||||
}
|
||||
|
||||
parseInfo.push(info);
|
||||
return "(" + regex + ")";
|
||||
});
|
||||
|
||||
// Check all the required fields are present
|
||||
Object.keys(requiredFields).forEach(field => {
|
||||
if (!specifiedFields[field]) {
|
||||
throw new Error(
|
||||
`Invalid format. ${field} is required in specified format`
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
// Add back all the literals after
|
||||
newFormat = newFormat.replace(/@@@/g, () => literals.shift());
|
||||
|
||||
// Check if the date string matches the format. If it doesn't return null
|
||||
const matches = dateStr.match(new RegExp(newFormat, "i"));
|
||||
if (!matches) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const combinedI18nSettings: I18nSettings = assign(
|
||||
assign({}, globalI18n),
|
||||
i18n
|
||||
);
|
||||
|
||||
// For each match, call the parser function for that date part
|
||||
for (let i = 1; i < matches.length; i++) {
|
||||
const [field, , parser] = parseInfo[i - 1];
|
||||
const value = parser
|
||||
? parser(matches[i], combinedI18nSettings)
|
||||
: +matches[i];
|
||||
|
||||
// If the parser can't make sense of the value, return null
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
dateInfo[field] = value;
|
||||
}
|
||||
|
||||
if (dateInfo.isPm === 1 && dateInfo.hour != null && +dateInfo.hour !== 12) {
|
||||
dateInfo.hour = +dateInfo.hour + 12;
|
||||
} else if (dateInfo.isPm === 0 && +dateInfo.hour === 12) {
|
||||
dateInfo.hour = 0;
|
||||
}
|
||||
|
||||
let dateTZ: Date;
|
||||
if (dateInfo.timezoneOffset == null) {
|
||||
dateTZ = new Date(
|
||||
dateInfo.year,
|
||||
dateInfo.month,
|
||||
dateInfo.day,
|
||||
dateInfo.hour,
|
||||
dateInfo.minute,
|
||||
dateInfo.second,
|
||||
dateInfo.millisecond
|
||||
);
|
||||
const validateFields: [
|
||||
"month" | "day" | "hour" | "minute" | "second",
|
||||
"getMonth" | "getDate" | "getHours" | "getMinutes" | "getSeconds"
|
||||
][] = [
|
||||
["month", "getMonth"],
|
||||
["day", "getDate"],
|
||||
["hour", "getHours"],
|
||||
["minute", "getMinutes"],
|
||||
["second", "getSeconds"]
|
||||
];
|
||||
for (let i = 0, len = validateFields.length; i < len; i++) {
|
||||
// Check to make sure the date field is within the allowed range. Javascript dates allows values
|
||||
// outside the allowed range. If the values don't match the value was invalid
|
||||
if (
|
||||
specifiedFields[validateFields[i][0]] &&
|
||||
dateInfo[validateFields[i][0]] !== dateTZ[validateFields[i][1]]()
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
dateTZ = new Date(
|
||||
Date.UTC(
|
||||
dateInfo.year,
|
||||
dateInfo.month,
|
||||
dateInfo.day,
|
||||
dateInfo.hour,
|
||||
dateInfo.minute - dateInfo.timezoneOffset,
|
||||
dateInfo.second,
|
||||
dateInfo.millisecond
|
||||
)
|
||||
);
|
||||
|
||||
// We can't validate dates in another timezone unfortunately. Do a basic check instead
|
||||
if (
|
||||
dateInfo.month > 11 ||
|
||||
dateInfo.month < 0 ||
|
||||
dateInfo.day > 31 ||
|
||||
dateInfo.day < 1 ||
|
||||
dateInfo.hour > 23 ||
|
||||
dateInfo.hour < 0 ||
|
||||
dateInfo.minute > 59 ||
|
||||
dateInfo.minute < 0 ||
|
||||
dateInfo.second > 59 ||
|
||||
dateInfo.second < 0
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Don't allow invalid dates
|
||||
|
||||
return dateTZ;
|
||||
}
|
||||
export default {
|
||||
format,
|
||||
parse,
|
||||
defaultI18n,
|
||||
setGlobalDateI18n,
|
||||
setGlobalDateMasks
|
||||
};
|
||||
export { format, parse, defaultI18n, setGlobalDateI18n, setGlobalDateMasks };
|
||||
53
unified-ai-platform/node_modules/logform/package.json
generated
vendored
Normal file
53
unified-ai-platform/node_modules/logform/package.json
generated
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
{
|
||||
"name": "logform",
|
||||
"version": "2.7.0",
|
||||
"description": "An mutable object-based log format designed for chaining & objectMode streams.",
|
||||
"main": "index.js",
|
||||
"browser": "dist/browser.js",
|
||||
"scripts": {
|
||||
"lint": "eslint *.js test/*.js examples/*.js --resolve-plugins-relative-to ./node_modules/@dabh/eslint-config-populist",
|
||||
"pretest": "npm run lint && npm run build",
|
||||
"test": "nyc mocha test/*.test.js",
|
||||
"build": "rimraf dist && babel *.js -d ./dist",
|
||||
"prepublishOnly": "npm run build"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/winstonjs/logform.git"
|
||||
},
|
||||
"keywords": [
|
||||
"winston",
|
||||
"logging",
|
||||
"format",
|
||||
"winstonjs"
|
||||
],
|
||||
"author": "Charlie Robbins <charlie.robbins@gmail.com>",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/winstonjs/logform/issues"
|
||||
},
|
||||
"homepage": "https://github.com/winstonjs/logform#readme",
|
||||
"dependencies": {
|
||||
"@colors/colors": "1.6.0",
|
||||
"@types/triple-beam": "^1.3.2",
|
||||
"fecha": "^4.2.0",
|
||||
"ms": "^2.1.1",
|
||||
"safe-stable-stringify": "^2.3.1",
|
||||
"triple-beam": "^1.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.10.3",
|
||||
"@babel/core": "^7.10.3",
|
||||
"@babel/preset-env": "^7.10.3",
|
||||
"@dabh/eslint-config-populist": "^5.0.0",
|
||||
"assume": "^2.2.0",
|
||||
"eslint": "^8.8.0",
|
||||
"mocha": "^10.0.0",
|
||||
"nyc": "^17.1.0",
|
||||
"rimraf": "^5.0.5"
|
||||
},
|
||||
"types": "./index.d.ts",
|
||||
"engines": {
|
||||
"node": ">= 12.0.0"
|
||||
}
|
||||
}
|
||||
83
unified-ai-platform/node_modules/logform/pad-levels.js
generated
vendored
Normal file
83
unified-ai-platform/node_modules/logform/pad-levels.js
generated
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
/* eslint no-unused-vars: 0 */
|
||||
'use strict';
|
||||
|
||||
const { configs, LEVEL, MESSAGE } = require('triple-beam');
|
||||
|
||||
class Padder {
|
||||
constructor(opts = { levels: configs.npm.levels }) {
|
||||
this.paddings = Padder.paddingForLevels(opts.levels, opts.filler);
|
||||
this.options = opts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum length of keys in the specified `levels` Object.
|
||||
* @param {Object} levels Set of all levels to calculate longest level against.
|
||||
* @returns {Number} Maximum length of the longest level string.
|
||||
*/
|
||||
static getLongestLevel(levels) {
|
||||
const lvls = Object.keys(levels).map(level => level.length);
|
||||
return Math.max(...lvls);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the padding for the specified `level` assuming that the
|
||||
* maximum length of all levels it's associated with is `maxLength`.
|
||||
* @param {String} level Level to calculate padding for.
|
||||
* @param {String} filler Repeatable text to use for padding.
|
||||
* @param {Number} maxLength Length of the longest level
|
||||
* @returns {String} Padding string for the `level`
|
||||
*/
|
||||
static paddingForLevel(level, filler, maxLength) {
|
||||
const targetLen = maxLength + 1 - level.length;
|
||||
const rep = Math.floor(targetLen / filler.length);
|
||||
const padding = `${filler}${filler.repeat(rep)}`;
|
||||
return padding.slice(0, targetLen);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an object with the string paddings for the given `levels`
|
||||
* using the specified `filler`.
|
||||
* @param {Object} levels Set of all levels to calculate padding for.
|
||||
* @param {String} filler Repeatable text to use for padding.
|
||||
* @returns {Object} Mapping of level to desired padding.
|
||||
*/
|
||||
static paddingForLevels(levels, filler = ' ') {
|
||||
const maxLength = Padder.getLongestLevel(levels);
|
||||
return Object.keys(levels).reduce((acc, level) => {
|
||||
acc[level] = Padder.paddingForLevel(level, filler, maxLength);
|
||||
return acc;
|
||||
}, {});
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepends the padding onto the `message` based on the `LEVEL` of
|
||||
* the `info`. This is based on the behavior of `winston@2` which also
|
||||
* prepended the level onto the message.
|
||||
*
|
||||
* See: https://github.com/winstonjs/winston/blob/2.x/lib/winston/logger.js#L198-L201
|
||||
*
|
||||
* @param {Info} info Logform info object
|
||||
* @param {Object} opts Options passed along to this instance.
|
||||
* @returns {Info} Modified logform info object.
|
||||
*/
|
||||
transform(info, opts) {
|
||||
info.message = `${this.paddings[info[LEVEL]]}${info.message}`;
|
||||
if (info[MESSAGE]) {
|
||||
info[MESSAGE] = `${this.paddings[info[LEVEL]]}${info[MESSAGE]}`;
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* function padLevels (info)
|
||||
* Returns a new instance of the padLevels Format which pads
|
||||
* levels to be the same length. This was previously exposed as
|
||||
* { padLevels: true } to transports in `winston < 3.0.0`.
|
||||
*/
|
||||
module.exports = opts => new Padder(opts);
|
||||
|
||||
module.exports.Padder
|
||||
= module.exports.Format
|
||||
= Padder;
|
||||
29
unified-ai-platform/node_modules/logform/pretty-print.js
generated
vendored
Normal file
29
unified-ai-platform/node_modules/logform/pretty-print.js
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
'use strict';
|
||||
|
||||
const inspect = require('util').inspect;
|
||||
const format = require('./format');
|
||||
const { LEVEL, MESSAGE, SPLAT } = require('triple-beam');
|
||||
|
||||
/*
|
||||
* function prettyPrint (info)
|
||||
* Returns a new instance of the prettyPrint Format that "prettyPrint"
|
||||
* serializes `info` objects. This was previously exposed as
|
||||
* { prettyPrint: true } to transports in `winston < 3.0.0`.
|
||||
*/
|
||||
module.exports = format((info, opts = {}) => {
|
||||
//
|
||||
// info[{LEVEL, MESSAGE, SPLAT}] are enumerable here. Since they
|
||||
// are internal, we remove them before util.inspect so they
|
||||
// are not printed.
|
||||
//
|
||||
const stripped = Object.assign({}, info);
|
||||
|
||||
// Remark (indexzero): update this technique in April 2019
|
||||
// when node@6 is EOL
|
||||
delete stripped[LEVEL];
|
||||
delete stripped[MESSAGE];
|
||||
delete stripped[SPLAT];
|
||||
|
||||
info[MESSAGE] = inspect(stripped, false, opts.depth || null, opts.colorize);
|
||||
return info;
|
||||
});
|
||||
26
unified-ai-platform/node_modules/logform/printf.js
generated
vendored
Normal file
26
unified-ai-platform/node_modules/logform/printf.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
'use strict';
|
||||
|
||||
const { MESSAGE } = require('triple-beam');
|
||||
|
||||
class Printf {
|
||||
constructor(templateFn) {
|
||||
this.template = templateFn;
|
||||
}
|
||||
|
||||
transform(info) {
|
||||
info[MESSAGE] = this.template(info);
|
||||
return info;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* function printf (templateFn)
|
||||
* Returns a new instance of the printf Format that creates an
|
||||
* intermediate prototype to store the template string-based formatter
|
||||
* function.
|
||||
*/
|
||||
module.exports = opts => new Printf(opts);
|
||||
|
||||
module.exports.Printf
|
||||
= module.exports.Format
|
||||
= Printf;
|
||||
33
unified-ai-platform/node_modules/logform/simple.js
generated
vendored
Normal file
33
unified-ai-platform/node_modules/logform/simple.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
/* eslint no-undefined: 0 */
|
||||
'use strict';
|
||||
|
||||
const format = require('./format');
|
||||
const { MESSAGE } = require('triple-beam');
|
||||
const jsonStringify = require('safe-stable-stringify');
|
||||
|
||||
/*
|
||||
* function simple (info)
|
||||
* Returns a new instance of the simple format TransformStream
|
||||
* which writes a simple representation of logs.
|
||||
*
|
||||
* const { level, message, splat, ...rest } = info;
|
||||
*
|
||||
* ${level}: ${message} if rest is empty
|
||||
* ${level}: ${message} ${JSON.stringify(rest)} otherwise
|
||||
*/
|
||||
module.exports = format(info => {
|
||||
const stringifiedRest = jsonStringify(Object.assign({}, info, {
|
||||
level: undefined,
|
||||
message: undefined,
|
||||
splat: undefined
|
||||
}));
|
||||
|
||||
const padding = info.padding && info.padding[info.level] || '';
|
||||
if (stringifiedRest !== '{}') {
|
||||
info[MESSAGE] = `${info.level}:${padding} ${info.message} ${stringifiedRest}`;
|
||||
} else {
|
||||
info[MESSAGE] = `${info.level}:${padding} ${info.message}`;
|
||||
}
|
||||
|
||||
return info;
|
||||
});
|
||||
132
unified-ai-platform/node_modules/logform/splat.js
generated
vendored
Normal file
132
unified-ai-platform/node_modules/logform/splat.js
generated
vendored
Normal file
@@ -0,0 +1,132 @@
|
||||
'use strict';
|
||||
|
||||
const util = require('util');
|
||||
const { SPLAT } = require('triple-beam');
|
||||
|
||||
/**
|
||||
* Captures the number of format (i.e. %s strings) in a given string.
|
||||
* Based on `util.format`, see Node.js source:
|
||||
* https://github.com/nodejs/node/blob/b1c8f15c5f169e021f7c46eb7b219de95fe97603/lib/util.js#L201-L230
|
||||
* @type {RegExp}
|
||||
*/
|
||||
const formatRegExp = /%[scdjifoO%]/g;
|
||||
|
||||
/**
|
||||
* Captures the number of escaped % signs in a format string (i.e. %s strings).
|
||||
* @type {RegExp}
|
||||
*/
|
||||
const escapedPercent = /%%/g;
|
||||
|
||||
class Splatter {
|
||||
constructor(opts) {
|
||||
this.options = opts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if tokens <= splat.length, assign { splat, meta } into the
|
||||
* `info` accordingly, and write to this instance.
|
||||
*
|
||||
* @param {Info} info Logform info message.
|
||||
* @param {String[]} tokens Set of string interpolation tokens.
|
||||
* @returns {Info} Modified info message
|
||||
* @private
|
||||
*/
|
||||
_splat(info, tokens) {
|
||||
const msg = info.message;
|
||||
const splat = info[SPLAT] || info.splat || [];
|
||||
const percents = msg.match(escapedPercent);
|
||||
const escapes = percents && percents.length || 0;
|
||||
|
||||
// The expected splat is the number of tokens minus the number of escapes
|
||||
// e.g.
|
||||
// - { expectedSplat: 3 } '%d %s %j'
|
||||
// - { expectedSplat: 5 } '[%s] %d%% %d%% %s %j'
|
||||
//
|
||||
// Any "meta" will be arugments in addition to the expected splat size
|
||||
// regardless of type. e.g.
|
||||
//
|
||||
// logger.log('info', '%d%% %s %j', 100, 'wow', { such: 'js' }, { thisIsMeta: true });
|
||||
// would result in splat of four (4), but only three (3) are expected. Therefore:
|
||||
//
|
||||
// extraSplat = 3 - 4 = -1
|
||||
// metas = [100, 'wow', { such: 'js' }, { thisIsMeta: true }].splice(-1, -1 * -1);
|
||||
// splat = [100, 'wow', { such: 'js' }]
|
||||
const expectedSplat = tokens.length - escapes;
|
||||
const extraSplat = expectedSplat - splat.length;
|
||||
const metas = extraSplat < 0
|
||||
? splat.splice(extraSplat, -1 * extraSplat)
|
||||
: [];
|
||||
|
||||
// Now that { splat } has been separated from any potential { meta }. we
|
||||
// can assign this to the `info` object and write it to our format stream.
|
||||
// If the additional metas are **NOT** objects or **LACK** enumerable properties
|
||||
// you are going to have a bad time.
|
||||
const metalen = metas.length;
|
||||
if (metalen) {
|
||||
for (let i = 0; i < metalen; i++) {
|
||||
Object.assign(info, metas[i]);
|
||||
}
|
||||
}
|
||||
|
||||
info.message = util.format(msg, ...splat);
|
||||
return info;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms the `info` message by using `util.format` to complete
|
||||
* any `info.message` provided it has string interpolation tokens.
|
||||
* If no tokens exist then `info` is immutable.
|
||||
*
|
||||
* @param {Info} info Logform info message.
|
||||
* @param {Object} opts Options for this instance.
|
||||
* @returns {Info} Modified info message
|
||||
*/
|
||||
transform(info) {
|
||||
const msg = info.message;
|
||||
const splat = info[SPLAT] || info.splat;
|
||||
|
||||
// No need to process anything if splat is undefined
|
||||
if (!splat || !splat.length) {
|
||||
return info;
|
||||
}
|
||||
|
||||
// Extract tokens, if none available default to empty array to
|
||||
// ensure consistancy in expected results
|
||||
const tokens = msg && msg.match && msg.match(formatRegExp);
|
||||
|
||||
// This condition will take care of inputs with info[SPLAT]
|
||||
// but no tokens present
|
||||
if (!tokens && (splat || splat.length)) {
|
||||
const metas = splat.length > 1
|
||||
? splat.splice(0)
|
||||
: splat;
|
||||
|
||||
// Now that { splat } has been separated from any potential { meta }. we
|
||||
// can assign this to the `info` object and write it to our format stream.
|
||||
// If the additional metas are **NOT** objects or **LACK** enumerable properties
|
||||
// you are going to have a bad time.
|
||||
const metalen = metas.length;
|
||||
if (metalen) {
|
||||
for (let i = 0; i < metalen; i++) {
|
||||
Object.assign(info, metas[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
if (tokens) {
|
||||
return this._splat(info, tokens);
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* function splat (info)
|
||||
* Returns a new instance of the splat format TransformStream
|
||||
* which performs string interpolation from `info` objects. This was
|
||||
* previously exposed implicitly in `winston < 3.0.0`.
|
||||
*/
|
||||
module.exports = opts => new Splatter(opts);
|
||||
30
unified-ai-platform/node_modules/logform/timestamp.js
generated
vendored
Normal file
30
unified-ai-platform/node_modules/logform/timestamp.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
'use strict';
|
||||
|
||||
const fecha = require('fecha');
|
||||
const format = require('./format');
|
||||
|
||||
/*
|
||||
* function timestamp (info)
|
||||
* Returns a new instance of the timestamp Format which adds a timestamp
|
||||
* to the info. It was previously available in winston < 3.0.0 as:
|
||||
*
|
||||
* - { timestamp: true } // `new Date.toISOString()`
|
||||
* - { timestamp: function:String } // Value returned by `timestamp()`
|
||||
*/
|
||||
module.exports = format((info, opts = {}) => {
|
||||
if (opts.format) {
|
||||
info.timestamp = typeof opts.format === 'function'
|
||||
? opts.format()
|
||||
: fecha.format(new Date(), opts.format);
|
||||
}
|
||||
|
||||
if (!info.timestamp) {
|
||||
info.timestamp = new Date().toISOString();
|
||||
}
|
||||
|
||||
if (opts.alias) {
|
||||
info[opts.alias] = info.timestamp;
|
||||
}
|
||||
|
||||
return info;
|
||||
});
|
||||
22
unified-ai-platform/node_modules/logform/tsconfig.json
generated
vendored
Normal file
22
unified-ai-platform/node_modules/logform/tsconfig.json
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts"
|
||||
]
|
||||
}
|
||||
27
unified-ai-platform/node_modules/logform/uncolorize.js
generated
vendored
Normal file
27
unified-ai-platform/node_modules/logform/uncolorize.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
'use strict';
|
||||
|
||||
const colors = require('@colors/colors/safe');
|
||||
const format = require('./format');
|
||||
const { MESSAGE } = require('triple-beam');
|
||||
|
||||
/*
|
||||
* function uncolorize (info)
|
||||
* Returns a new instance of the uncolorize Format that strips colors
|
||||
* from `info` objects. This was previously exposed as { stripColors: true }
|
||||
* to transports in `winston < 3.0.0`.
|
||||
*/
|
||||
module.exports = format((info, opts) => {
|
||||
if (opts.level !== false) {
|
||||
info.level = colors.strip(info.level);
|
||||
}
|
||||
|
||||
if (opts.message !== false) {
|
||||
info.message = colors.strip(String(info.message));
|
||||
}
|
||||
|
||||
if (opts.raw !== false && info[MESSAGE]) {
|
||||
info[MESSAGE] = colors.strip(String(info[MESSAGE]));
|
||||
}
|
||||
|
||||
return info;
|
||||
});
|
||||
Reference in New Issue
Block a user