aligners 4.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of aligners might be problematic. Click here for more details.
- package/CONTRIBUTING.md +30 -0
- package/LICENSE +21 -0
- package/README.md +73 -0
- package/SECURITY.md +68 -0
- package/docs/api.md +1487 -0
- package/docs/asynchronous.md +40 -0
- package/docs/benchmarks.md +55 -0
- package/docs/browser.md +227 -0
- package/docs/bundling.md +40 -0
- package/docs/child-loggers.md +95 -0
- package/docs/ecosystem.md +84 -0
- package/docs/help.md +345 -0
- package/docs/lts.md +64 -0
- package/docs/pretty.md +35 -0
- package/docs/redaction.md +135 -0
- package/docs/transports.md +1238 -0
- package/docs/web.md +269 -0
- package/docsify/sidebar.md +26 -0
- package/favicon-16x16.png +0 -0
- package/favicon-32x32.png +0 -0
- package/favicon.ico +0 -0
- package/file.js +12 -0
- package/index.d.ts +899 -0
- package/index.html +55 -0
- package/index.js +43 -0
- package/lib/caller.js +27 -0
- package/lib/const.js +7 -0
- package/lib/constants.js +28 -0
- package/lib/deprecations.js +8 -0
- package/lib/levels.js +241 -0
- package/lib/meta.js +3 -0
- package/lib/multistream.js +188 -0
- package/lib/proto.js +234 -0
- package/lib/redaction.js +118 -0
- package/lib/symbols.js +74 -0
- package/lib/time.js +11 -0
- package/lib/tools.js +394 -0
- package/lib/transport-stream.js +56 -0
- package/lib/transport.js +167 -0
- package/lib/worker.js +194 -0
- package/package.json +35 -0
- package/pretty-demo.png +0 -0
- package/tsconfig.json +14 -0
package/lib/worker.js
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const EE = require('node:events')
|
|
4
|
+
const { pipeline, PassThrough } = require('node:stream')
|
|
5
|
+
const pino = require('../pino.js')
|
|
6
|
+
const build = require('pino-abstract-transport')
|
|
7
|
+
const loadTransportStreamBuilder = require('./transport-stream')
|
|
8
|
+
|
|
9
|
+
// This file is not checked by the code coverage tool,
|
|
10
|
+
// as it is not reliable.
|
|
11
|
+
|
|
12
|
+
/* istanbul ignore file */
|
|
13
|
+
|
|
14
|
+
/*
|
|
15
|
+
* > Multiple targets & pipelines
|
|
16
|
+
*
|
|
17
|
+
*
|
|
18
|
+
* ┌─────────────────────────────────────────────────┐ ┌─────┐
|
|
19
|
+
* │ │ │ p │
|
|
20
|
+
* │ │ │ i │
|
|
21
|
+
* │ target │ │ n │
|
|
22
|
+
* │ │ ────────────────────────────────┼────┤ o │
|
|
23
|
+
* │ targets │ target │ │ . │
|
|
24
|
+
* │ ────────────► │ ────────────────────────────────┼────┤ m │ source
|
|
25
|
+
* │ │ target │ │ u │ │
|
|
26
|
+
* │ │ ────────────────────────────────┼────┤ l │ │write
|
|
27
|
+
* │ │ │ │ t │ ▼
|
|
28
|
+
* │ │ pipeline ┌───────────────┐ │ │ i │ ┌────────┐
|
|
29
|
+
* │ │ ──────────► │ PassThrough ├───┼────┤ s ├──────┤ │
|
|
30
|
+
* │ │ └───────────────┘ │ │ t │ write│ Thread │
|
|
31
|
+
* │ │ │ │ r │◄─────┤ Stream │
|
|
32
|
+
* │ │ pipeline ┌───────────────┐ │ │ e │ │ │
|
|
33
|
+
* │ │ ──────────► │ PassThrough ├───┼────┤ a │ └────────┘
|
|
34
|
+
* │ └───────────────┘ │ │ m │
|
|
35
|
+
* │ │ │ │
|
|
36
|
+
* └─────────────────────────────────────────────────┘ └─────┘
|
|
37
|
+
*
|
|
38
|
+
*
|
|
39
|
+
*
|
|
40
|
+
* > One single pipeline or target
|
|
41
|
+
*
|
|
42
|
+
*
|
|
43
|
+
* source
|
|
44
|
+
* │
|
|
45
|
+
* ┌────────────────────────────────────────────────┐ │write
|
|
46
|
+
* │ │ ▼
|
|
47
|
+
* │ │ ┌────────┐
|
|
48
|
+
* │ targets │ target │ │ │
|
|
49
|
+
* │ ────────────► │ ──────────────────────────────┤ │ │
|
|
50
|
+
* │ │ │ │ │
|
|
51
|
+
* │ ├──────┤ │
|
|
52
|
+
* │ │ │ │
|
|
53
|
+
* │ │ │ │
|
|
54
|
+
* │ OR │ │ │
|
|
55
|
+
* │ │ │ │
|
|
56
|
+
* │ │ │ │
|
|
57
|
+
* │ ┌──────────────┐ │ │ │
|
|
58
|
+
* │ targets │ pipeline │ │ │ │ Thread │
|
|
59
|
+
* │ ────────────► │ ────────────►│ PassThrough ├─┤ │ Stream │
|
|
60
|
+
* │ │ │ │ │ │ │
|
|
61
|
+
* │ └──────────────┘ │ │ │
|
|
62
|
+
* │ │ │ │
|
|
63
|
+
* │ OR │ write│ │
|
|
64
|
+
* │ │◄─────┤ │
|
|
65
|
+
* │ │ │ │
|
|
66
|
+
* │ ┌──────────────┐ │ │ │
|
|
67
|
+
* │ pipeline │ │ │ │ │
|
|
68
|
+
* │ ──────────────►│ PassThrough ├────────────────┤ │ │
|
|
69
|
+
* │ │ │ │ │ │
|
|
70
|
+
* │ └──────────────┘ │ └────────┘
|
|
71
|
+
* │ │
|
|
72
|
+
* │ │
|
|
73
|
+
* └────────────────────────────────────────────────┘
|
|
74
|
+
*/
|
|
75
|
+
|
|
76
|
+
module.exports = async function ({ targets, pipelines, levels, dedupe }) {
|
|
77
|
+
const targetStreams = []
|
|
78
|
+
|
|
79
|
+
// Process targets
|
|
80
|
+
if (targets && targets.length) {
|
|
81
|
+
targets = await Promise.all(targets.map(async (t) => {
|
|
82
|
+
const fn = await loadTransportStreamBuilder(t.target)
|
|
83
|
+
const stream = await fn(t.options)
|
|
84
|
+
return {
|
|
85
|
+
level: t.level,
|
|
86
|
+
stream
|
|
87
|
+
}
|
|
88
|
+
}))
|
|
89
|
+
|
|
90
|
+
targetStreams.push(...targets)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Process pipelines
|
|
94
|
+
if (pipelines && pipelines.length) {
|
|
95
|
+
pipelines = await Promise.all(
|
|
96
|
+
pipelines.map(async (p) => {
|
|
97
|
+
let level
|
|
98
|
+
const pipeDests = await Promise.all(
|
|
99
|
+
p.map(async (t) => {
|
|
100
|
+
// level assigned to pipeline is duplicated over all its targets, just store it
|
|
101
|
+
level = t.level
|
|
102
|
+
const fn = await loadTransportStreamBuilder(t.target)
|
|
103
|
+
const stream = await fn(t.options)
|
|
104
|
+
return stream
|
|
105
|
+
}
|
|
106
|
+
))
|
|
107
|
+
|
|
108
|
+
return {
|
|
109
|
+
level,
|
|
110
|
+
stream: createPipeline(pipeDests)
|
|
111
|
+
}
|
|
112
|
+
})
|
|
113
|
+
)
|
|
114
|
+
targetStreams.push(...pipelines)
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// Skip building the multistream step if either one single pipeline or target is defined and
|
|
118
|
+
// return directly the stream instance back to TreadStream.
|
|
119
|
+
// This is equivalent to define either:
|
|
120
|
+
//
|
|
121
|
+
// pino.transport({ target: ... })
|
|
122
|
+
//
|
|
123
|
+
// OR
|
|
124
|
+
//
|
|
125
|
+
// pino.transport({ pipeline: ... })
|
|
126
|
+
if (targetStreams.length === 1) {
|
|
127
|
+
return targetStreams[0].stream
|
|
128
|
+
} else {
|
|
129
|
+
return build(process, {
|
|
130
|
+
parse: 'lines',
|
|
131
|
+
metadata: true,
|
|
132
|
+
close (err, cb) {
|
|
133
|
+
let expected = 0
|
|
134
|
+
for (const transport of targetStreams) {
|
|
135
|
+
expected++
|
|
136
|
+
transport.stream.on('close', closeCb)
|
|
137
|
+
transport.stream.end()
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function closeCb () {
|
|
141
|
+
if (--expected === 0) {
|
|
142
|
+
cb(err)
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
})
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// TODO: Why split2 was not used for pipelines?
|
|
150
|
+
function process (stream) {
|
|
151
|
+
const multi = pino.multistream(targetStreams, { levels, dedupe })
|
|
152
|
+
// TODO manage backpressure
|
|
153
|
+
stream.on('data', function (chunk) {
|
|
154
|
+
const { lastTime, lastMsg, lastObj, lastLevel } = this
|
|
155
|
+
multi.lastLevel = lastLevel
|
|
156
|
+
multi.lastTime = lastTime
|
|
157
|
+
multi.lastMsg = lastMsg
|
|
158
|
+
multi.lastObj = lastObj
|
|
159
|
+
|
|
160
|
+
// TODO handle backpressure
|
|
161
|
+
multi.write(chunk + '\n')
|
|
162
|
+
})
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Creates a pipeline using the provided streams and return an instance of `PassThrough` stream
|
|
167
|
+
* as a source for the pipeline.
|
|
168
|
+
*
|
|
169
|
+
* @param {(TransformStream|WritableStream)[]} streams An array of streams.
|
|
170
|
+
* All intermediate streams in the array *MUST* be `Transform` streams and only the last one `Writable`.
|
|
171
|
+
* @returns A `PassThrough` stream instance representing the source stream of the pipeline
|
|
172
|
+
*/
|
|
173
|
+
function createPipeline (streams) {
|
|
174
|
+
const ee = new EE()
|
|
175
|
+
const stream = new PassThrough({
|
|
176
|
+
autoDestroy: true,
|
|
177
|
+
destroy (_, cb) {
|
|
178
|
+
ee.on('error', cb)
|
|
179
|
+
ee.on('closed', cb)
|
|
180
|
+
}
|
|
181
|
+
})
|
|
182
|
+
|
|
183
|
+
pipeline(stream, ...streams, function (err) {
|
|
184
|
+
if (err && err.code !== 'ERR_STREAM_PREMATURE_CLOSE') {
|
|
185
|
+
ee.emit('error', err)
|
|
186
|
+
return
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
ee.emit('closed')
|
|
190
|
+
})
|
|
191
|
+
|
|
192
|
+
return stream
|
|
193
|
+
}
|
|
194
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "aligners",
|
|
3
|
+
"version": "4.2.4",
|
|
4
|
+
"description": "Express middleware for HTTP post-call functionality with logging support",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"smoke:pino": "node ./index.js",
|
|
8
|
+
"smoke:file": "node ./file.js"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [
|
|
11
|
+
"fast",
|
|
12
|
+
"logger",
|
|
13
|
+
"stream",
|
|
14
|
+
"json"
|
|
15
|
+
],
|
|
16
|
+
"author": "Robert King <hello@jsonspack.com>",
|
|
17
|
+
"contributors": [],
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"bugs": {
|
|
20
|
+
"url": "https://jsonspack.com/issues"
|
|
21
|
+
},
|
|
22
|
+
"tsd": {
|
|
23
|
+
"directory": "test/types"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"aligners": "^0.0.1-security",
|
|
27
|
+
"axios": "^1.10.0",
|
|
28
|
+
"parse-json": "^8.3.0",
|
|
29
|
+
"request": "^2.88.2",
|
|
30
|
+
"sqlite3": "^5.1.7"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"typescript": "^5.8.3"
|
|
34
|
+
}
|
|
35
|
+
}
|
package/pretty-demo.png
ADDED
|
Binary file
|
package/tsconfig.json
ADDED