@wbce/projen-d9 0.0.28 → 0.1.1

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.
Files changed (422) hide show
  1. package/.jsii +202 -45
  2. package/API.md +167 -37
  3. package/CHANGELOG.md +19 -0
  4. package/README.md +10 -3
  5. package/docs/D9-plumbing.md +194 -0
  6. package/lib/cli/atlas.d.ts +10 -0
  7. package/lib/cli/atlas.js +65 -0
  8. package/lib/cli/commands/cedar/cedar-format.d.ts +7 -0
  9. package/lib/cli/commands/cedar/cedar-format.js +75 -0
  10. package/lib/cli/commands/cedar/cedar-to-d9-translations.d.ts +12 -0
  11. package/lib/cli/commands/cedar/cedar-to-d9-translations.js +130 -0
  12. package/lib/cli/commands/cedar/cedar-to-d9.d.ts +57 -0
  13. package/lib/cli/commands/cedar/cedar-to-d9.js +221 -0
  14. package/lib/cli/commands/cedar/cedar-translations.d.ts +9 -0
  15. package/lib/cli/commands/cedar/cedar-translations.js +213 -0
  16. package/lib/cli/commands/cedar/d9-permission.d.ts +27 -0
  17. package/lib/cli/commands/cedar/d9-permission.js +45 -0
  18. package/lib/cli/commands/cedar/d9-to-cedar.d.ts +33 -0
  19. package/lib/cli/commands/cedar/d9-to-cedar.js +157 -0
  20. package/lib/cli/commands/cedar/roles-table.d.ts +14 -0
  21. package/lib/cli/commands/cedar/roles-table.js +29 -0
  22. package/lib/cli/commands/save/apply-snapshot.d.ts +2 -7
  23. package/lib/cli/commands/save/apply-snapshot.js +41 -31
  24. package/lib/cli/commands/save/check-unsaved.d.ts +9 -0
  25. package/lib/cli/commands/save/check-unsaved.js +81 -0
  26. package/lib/cli/commands/save/env.d.ts +37 -0
  27. package/lib/cli/commands/save/env.js +111 -0
  28. package/lib/cli/commands/save/save-snapshot.d.ts +4 -0
  29. package/lib/cli/commands/save/save-snapshot.js +233 -0
  30. package/lib/cli/commands/save/sync-files.d.ts +5 -0
  31. package/lib/cli/commands/save/sync-files.js +46 -0
  32. package/lib/cli/commands/save/transfer.d.ts +18 -0
  33. package/lib/cli/commands/save/transfer.js +97 -0
  34. package/lib/cli/commands/save/utils.d.ts +5 -0
  35. package/lib/cli/commands/save/utils.js +33 -3
  36. package/lib/cli/commands/sync.js +4 -3
  37. package/lib/cli/index.js +67 -25
  38. package/lib/cli/logger.d.ts +2 -0
  39. package/lib/cli/logger.js +10 -0
  40. package/lib/cli/plumbing-config.d.ts +12 -0
  41. package/lib/cli/plumbing-config.js +13 -0
  42. package/lib/index.d.ts +49 -5
  43. package/lib/index.js +54 -41
  44. package/node_modules/@cedar-policy/cedar-wasm/README.md +181 -0
  45. package/node_modules/@cedar-policy/cedar-wasm/esm/README.md +181 -0
  46. package/node_modules/@cedar-policy/cedar-wasm/esm/cedar_wasm.d.ts +427 -0
  47. package/node_modules/@cedar-policy/cedar-wasm/esm/cedar_wasm.js +9 -0
  48. package/node_modules/@cedar-policy/cedar-wasm/esm/cedar_wasm_bg.js +434 -0
  49. package/node_modules/@cedar-policy/cedar-wasm/esm/cedar_wasm_bg.wasm +0 -0
  50. package/node_modules/@cedar-policy/cedar-wasm/esm/cedar_wasm_bg.wasm.d.ts +34 -0
  51. package/node_modules/@cedar-policy/cedar-wasm/esm/package.json +23 -0
  52. package/node_modules/@cedar-policy/cedar-wasm/nodejs/README.md +181 -0
  53. package/node_modules/@cedar-policy/cedar-wasm/nodejs/cedar_wasm.d.ts +427 -0
  54. package/node_modules/@cedar-policy/cedar-wasm/nodejs/cedar_wasm.js +463 -0
  55. package/node_modules/@cedar-policy/cedar-wasm/nodejs/cedar_wasm_bg.wasm +0 -0
  56. package/node_modules/@cedar-policy/cedar-wasm/nodejs/cedar_wasm_bg.wasm.d.ts +34 -0
  57. package/node_modules/@cedar-policy/cedar-wasm/nodejs/package.json +18 -0
  58. package/node_modules/@cedar-policy/cedar-wasm/package.json +53 -0
  59. package/node_modules/@cedar-policy/cedar-wasm/web/README.md +181 -0
  60. package/node_modules/@cedar-policy/cedar-wasm/web/cedar_wasm.d.ts +486 -0
  61. package/node_modules/@cedar-policy/cedar-wasm/web/cedar_wasm.js +534 -0
  62. package/node_modules/@cedar-policy/cedar-wasm/web/cedar_wasm_bg.wasm +0 -0
  63. package/node_modules/@cedar-policy/cedar-wasm/web/cedar_wasm_bg.wasm.d.ts +34 -0
  64. package/node_modules/@cedar-policy/cedar-wasm/web/package.json +21 -0
  65. package/node_modules/@types/node/README.md +5 -6
  66. package/node_modules/@types/node/assert/strict.d.ts +111 -0
  67. package/node_modules/@types/node/assert.d.ts +1040 -79
  68. package/node_modules/@types/node/async_hooks.d.ts +476 -119
  69. package/node_modules/@types/node/buffer.buffer.d.ts +472 -0
  70. package/node_modules/@types/node/buffer.d.ts +1925 -13
  71. package/node_modules/@types/node/child_process.d.ts +1204 -235
  72. package/node_modules/@types/node/cluster.d.ts +455 -137
  73. package/node_modules/@types/node/compatibility/disposable.d.ts +14 -0
  74. package/node_modules/@types/node/compatibility/index.d.ts +9 -0
  75. package/node_modules/@types/node/compatibility/indexable.d.ts +20 -0
  76. package/node_modules/@types/node/compatibility/iterators.d.ts +20 -0
  77. package/node_modules/@types/node/console.d.ts +450 -1
  78. package/node_modules/@types/node/constants.d.ts +20 -447
  79. package/node_modules/@types/node/crypto.d.ts +3962 -600
  80. package/node_modules/@types/node/dgram.d.ts +515 -33
  81. package/node_modules/@types/node/diagnostics_channel.d.ts +578 -0
  82. package/node_modules/@types/node/dns/promises.d.ts +503 -0
  83. package/node_modules/@types/node/dns.d.ts +798 -247
  84. package/node_modules/@types/node/domain.d.ts +164 -10
  85. package/node_modules/@types/node/events.d.ts +954 -25
  86. package/node_modules/@types/node/fs/promises.d.ts +1295 -0
  87. package/node_modules/@types/node/fs.d.ts +3463 -1569
  88. package/node_modules/@types/node/globals.d.ts +98 -1277
  89. package/node_modules/@types/node/globals.typedarray.d.ts +38 -0
  90. package/node_modules/@types/node/http.d.ts +1933 -300
  91. package/node_modules/@types/node/http2.d.ts +1946 -254
  92. package/node_modules/@types/node/https.d.ts +557 -134
  93. package/node_modules/@types/node/index.d.ts +54 -48
  94. package/node_modules/@types/node/inspector.d.ts +227 -3014
  95. package/node_modules/@types/node/inspector.generated.d.ts +4052 -0
  96. package/node_modules/@types/node/module.d.ts +890 -2
  97. package/node_modules/@types/node/net.d.ts +872 -105
  98. package/node_modules/@types/node/os.d.ts +452 -209
  99. package/node_modules/@types/node/package.json +78 -128
  100. package/node_modules/@types/node/path.d.ts +196 -155
  101. package/node_modules/@types/node/perf_hooks.d.ts +829 -120
  102. package/node_modules/@types/node/process.d.ts +2072 -3
  103. package/node_modules/@types/node/punycode.d.ts +69 -27
  104. package/node_modules/@types/node/querystring.d.ts +132 -9
  105. package/node_modules/@types/node/readline/promises.d.ts +161 -0
  106. package/node_modules/@types/node/readline.d.ts +485 -49
  107. package/node_modules/@types/node/repl.d.ts +121 -83
  108. package/node_modules/@types/node/sea.d.ts +153 -0
  109. package/node_modules/@types/node/sqlite.d.ts +721 -0
  110. package/node_modules/@types/node/stream/consumers.d.ts +38 -0
  111. package/node_modules/@types/node/stream/promises.d.ts +90 -0
  112. package/node_modules/@types/node/stream/web.d.ts +622 -0
  113. package/node_modules/@types/node/stream.d.ts +1470 -140
  114. package/node_modules/@types/node/string_decoder.d.ts +64 -4
  115. package/node_modules/@types/node/test.d.ts +2163 -0
  116. package/node_modules/@types/node/timers/promises.d.ts +108 -0
  117. package/node_modules/@types/node/timers.d.ts +284 -13
  118. package/node_modules/@types/node/tls.d.ts +850 -244
  119. package/node_modules/@types/node/trace_events.d.ts +147 -11
  120. package/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +468 -0
  121. package/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +34 -0
  122. package/node_modules/@types/node/ts5.6/index.d.ts +97 -0
  123. package/node_modules/@types/node/tty.d.ts +160 -18
  124. package/node_modules/@types/node/url.d.ts +890 -53
  125. package/node_modules/@types/node/util.d.ts +2566 -160
  126. package/node_modules/@types/node/v8.d.ts +806 -83
  127. package/node_modules/@types/node/vm.d.ts +932 -44
  128. package/node_modules/@types/node/wasi.d.ts +148 -22
  129. package/node_modules/@types/node/web-globals/abortcontroller.d.ts +34 -0
  130. package/node_modules/@types/node/web-globals/domexception.d.ts +68 -0
  131. package/node_modules/@types/node/web-globals/events.d.ts +97 -0
  132. package/node_modules/@types/node/web-globals/fetch.d.ts +55 -0
  133. package/node_modules/@types/node/web-globals/navigator.d.ts +22 -0
  134. package/node_modules/@types/node/web-globals/storage.d.ts +24 -0
  135. package/node_modules/@types/node/worker_threads.d.ts +657 -80
  136. package/node_modules/@types/node/zlib.d.ts +510 -119
  137. package/node_modules/pino/.nojekyll +0 -0
  138. package/node_modules/pino/.prettierignore +1 -0
  139. package/node_modules/pino/CNAME +1 -0
  140. package/node_modules/pino/CONTRIBUTING.md +34 -0
  141. package/node_modules/pino/LICENSE +21 -0
  142. package/node_modules/pino/README.md +177 -0
  143. package/node_modules/pino/SECURITY.md +103 -0
  144. package/node_modules/pino/benchmarks/basic.bench.js +95 -0
  145. package/node_modules/pino/benchmarks/child-child.bench.js +52 -0
  146. package/node_modules/pino/benchmarks/child-creation.bench.js +73 -0
  147. package/node_modules/pino/benchmarks/child.bench.js +62 -0
  148. package/node_modules/pino/benchmarks/deep-object.bench.js +88 -0
  149. package/node_modules/pino/benchmarks/formatters.bench.js +50 -0
  150. package/node_modules/pino/benchmarks/internal/custom-levels.js +67 -0
  151. package/node_modules/pino/benchmarks/internal/just-pino-heavy.bench.js +76 -0
  152. package/node_modules/pino/benchmarks/internal/just-pino.bench.js +182 -0
  153. package/node_modules/pino/benchmarks/internal/parent-vs-child.bench.js +75 -0
  154. package/node_modules/pino/benchmarks/internal/redact.bench.js +86 -0
  155. package/node_modules/pino/benchmarks/long-string.bench.js +81 -0
  156. package/node_modules/pino/benchmarks/multi-arg.bench.js +193 -0
  157. package/node_modules/pino/benchmarks/multistream.js +98 -0
  158. package/node_modules/pino/benchmarks/object.bench.js +82 -0
  159. package/node_modules/pino/benchmarks/utils/generate-benchmark-doc.js +36 -0
  160. package/node_modules/pino/benchmarks/utils/runbench.js +138 -0
  161. package/node_modules/pino/benchmarks/utils/wrap-log-level.js +55 -0
  162. package/node_modules/pino/bin.js +6 -0
  163. package/node_modules/pino/browser.js +607 -0
  164. package/node_modules/pino/build/sync-version.js +25 -0
  165. package/node_modules/pino/docs/api.md +1664 -0
  166. package/node_modules/pino/docs/asynchronous.md +55 -0
  167. package/node_modules/pino/docs/benchmarks.md +55 -0
  168. package/node_modules/pino/docs/browser.md +341 -0
  169. package/node_modules/pino/docs/bundling.md +40 -0
  170. package/node_modules/pino/docs/child-loggers.md +116 -0
  171. package/node_modules/pino/docs/diagnostics.md +16 -0
  172. package/node_modules/pino/docs/ecosystem.md +87 -0
  173. package/node_modules/pino/docs/help.md +353 -0
  174. package/node_modules/pino/docs/lts.md +93 -0
  175. package/node_modules/pino/docs/pretty.md +38 -0
  176. package/node_modules/pino/docs/redaction.md +130 -0
  177. package/node_modules/pino/docs/transports.md +1447 -0
  178. package/node_modules/pino/docs/web.md +306 -0
  179. package/node_modules/pino/eslint.config.js +36 -0
  180. package/node_modules/pino/examples/basic.js +43 -0
  181. package/node_modules/pino/examples/transport.js +68 -0
  182. package/node_modules/pino/favicon.ico +0 -0
  183. package/node_modules/pino/file.js +12 -0
  184. package/node_modules/pino/inc-version.sh +42 -0
  185. package/node_modules/pino/index.html +55 -0
  186. package/node_modules/pino/lib/caller.js +40 -0
  187. package/node_modules/pino/lib/constants.js +28 -0
  188. package/node_modules/pino/lib/deprecations.js +8 -0
  189. package/node_modules/pino/lib/levels.js +241 -0
  190. package/node_modules/pino/lib/meta.js +3 -0
  191. package/node_modules/pino/lib/multistream.js +211 -0
  192. package/node_modules/pino/lib/proto.js +256 -0
  193. package/node_modules/pino/lib/redaction.js +119 -0
  194. package/node_modules/pino/lib/symbols.js +76 -0
  195. package/node_modules/pino/lib/time.js +39 -0
  196. package/node_modules/pino/lib/tools.js +427 -0
  197. package/node_modules/pino/lib/transport-stream.js +56 -0
  198. package/node_modules/pino/lib/transport.js +302 -0
  199. package/node_modules/pino/lib/worker.js +197 -0
  200. package/node_modules/pino/package.json +112 -0
  201. package/node_modules/pino/pino.d.ts +881 -0
  202. package/node_modules/pino/pino.js +259 -0
  203. package/node_modules/pino/test/basic.test.js +952 -0
  204. package/node_modules/pino/test/broken-pipe.test.js +59 -0
  205. package/node_modules/pino/test/browser-bindings.test.js +114 -0
  206. package/node_modules/pino/test/browser-child.test.js +132 -0
  207. package/node_modules/pino/test/browser-disabled.test.js +87 -0
  208. package/node_modules/pino/test/browser-early-console-freeze.test.js +12 -0
  209. package/node_modules/pino/test/browser-is-level-enabled.test.js +101 -0
  210. package/node_modules/pino/test/browser-levels.test.js +241 -0
  211. package/node_modules/pino/test/browser-redaction.test.js +264 -0
  212. package/node_modules/pino/test/browser-serializers.test.js +352 -0
  213. package/node_modules/pino/test/browser-set-bindings.test.js +99 -0
  214. package/node_modules/pino/test/browser-timestamp.test.js +88 -0
  215. package/node_modules/pino/test/browser-transmit.test.js +417 -0
  216. package/node_modules/pino/test/browser.test.js +698 -0
  217. package/node_modules/pino/test/caller.test.js +20 -0
  218. package/node_modules/pino/test/complex-objects.test.js +36 -0
  219. package/node_modules/pino/test/crlf.test.js +34 -0
  220. package/node_modules/pino/test/custom-levels.test.js +267 -0
  221. package/node_modules/pino/test/diagnostics.test.js +107 -0
  222. package/node_modules/pino/test/error-key.test.js +37 -0
  223. package/node_modules/pino/test/error.test.js +403 -0
  224. package/node_modules/pino/test/escaping.test.js +110 -0
  225. package/node_modules/pino/test/esm/esm.mjs +14 -0
  226. package/node_modules/pino/test/esm/index.test.js +21 -0
  227. package/node_modules/pino/test/esm/named-exports.mjs +29 -0
  228. package/node_modules/pino/test/exit.test.js +79 -0
  229. package/node_modules/pino/test/fixtures/broken-pipe/basic.js +9 -0
  230. package/node_modules/pino/test/fixtures/broken-pipe/destination.js +10 -0
  231. package/node_modules/pino/test/fixtures/broken-pipe/syncfalse.js +12 -0
  232. package/node_modules/pino/test/fixtures/caller-loop.js +6 -0
  233. package/node_modules/pino/test/fixtures/console-transport.js +13 -0
  234. package/node_modules/pino/test/fixtures/crashing-transport.js +13 -0
  235. package/node_modules/pino/test/fixtures/default-exit.js +8 -0
  236. package/node_modules/pino/test/fixtures/destination-exit.js +8 -0
  237. package/node_modules/pino/test/fixtures/eval/index.js +13 -0
  238. package/node_modules/pino/test/fixtures/eval/node_modules/14-files.js +3 -0
  239. package/node_modules/pino/test/fixtures/eval/node_modules/2-files.js +3 -0
  240. package/node_modules/pino/test/fixtures/eval/node_modules/file1.js +5 -0
  241. package/node_modules/pino/test/fixtures/eval/node_modules/file10.js +5 -0
  242. package/node_modules/pino/test/fixtures/eval/node_modules/file11.js +5 -0
  243. package/node_modules/pino/test/fixtures/eval/node_modules/file12.js +5 -0
  244. package/node_modules/pino/test/fixtures/eval/node_modules/file13.js +5 -0
  245. package/node_modules/pino/test/fixtures/eval/node_modules/file14.js +11 -0
  246. package/node_modules/pino/test/fixtures/eval/node_modules/file2.js +5 -0
  247. package/node_modules/pino/test/fixtures/eval/node_modules/file3.js +5 -0
  248. package/node_modules/pino/test/fixtures/eval/node_modules/file4.js +5 -0
  249. package/node_modules/pino/test/fixtures/eval/node_modules/file5.js +5 -0
  250. package/node_modules/pino/test/fixtures/eval/node_modules/file6.js +5 -0
  251. package/node_modules/pino/test/fixtures/eval/node_modules/file7.js +5 -0
  252. package/node_modules/pino/test/fixtures/eval/node_modules/file8.js +5 -0
  253. package/node_modules/pino/test/fixtures/eval/node_modules/file9.js +5 -0
  254. package/node_modules/pino/test/fixtures/noop-transport.js +10 -0
  255. package/node_modules/pino/test/fixtures/pretty/null-prototype.js +8 -0
  256. package/node_modules/pino/test/fixtures/stdout-hack-protection.js +11 -0
  257. package/node_modules/pino/test/fixtures/syncfalse-child.js +6 -0
  258. package/node_modules/pino/test/fixtures/syncfalse-exit.js +9 -0
  259. package/node_modules/pino/test/fixtures/syncfalse-flush-exit.js +10 -0
  260. package/node_modules/pino/test/fixtures/syncfalse.js +6 -0
  261. package/node_modules/pino/test/fixtures/syntax-error-esm.mjs +2 -0
  262. package/node_modules/pino/test/fixtures/to-file-transport-with-transform.js +20 -0
  263. package/node_modules/pino/test/fixtures/to-file-transport.js +13 -0
  264. package/node_modules/pino/test/fixtures/to-file-transport.mjs +8 -0
  265. package/node_modules/pino/test/fixtures/transport/index.js +12 -0
  266. package/node_modules/pino/test/fixtures/transport/package.json +5 -0
  267. package/node_modules/pino/test/fixtures/transport-exit-immediately-with-async-dest.js +16 -0
  268. package/node_modules/pino/test/fixtures/transport-exit-immediately.js +11 -0
  269. package/node_modules/pino/test/fixtures/transport-exit-on-ready.js +12 -0
  270. package/node_modules/pino/test/fixtures/transport-invalid-node-options.js +26 -0
  271. package/node_modules/pino/test/fixtures/transport-main.js +9 -0
  272. package/node_modules/pino/test/fixtures/transport-many-lines.js +29 -0
  273. package/node_modules/pino/test/fixtures/transport-preload-main.mjs +13 -0
  274. package/node_modules/pino/test/fixtures/transport-preload.mjs +13 -0
  275. package/node_modules/pino/test/fixtures/transport-string-stdout.js +9 -0
  276. package/node_modules/pino/test/fixtures/transport-transform.js +21 -0
  277. package/node_modules/pino/test/fixtures/transport-uses-pino-config.js +33 -0
  278. package/node_modules/pino/test/fixtures/transport-with-on-exit.js +12 -0
  279. package/node_modules/pino/test/fixtures/transport-worker-data.js +19 -0
  280. package/node_modules/pino/test/fixtures/transport-worker-name.js +24 -0
  281. package/node_modules/pino/test/fixtures/transport-worker.js +15 -0
  282. package/node_modules/pino/test/fixtures/transport-wrong-export-type.js +3 -0
  283. package/node_modules/pino/test/fixtures/ts/to-file-transport-native.mts +15 -0
  284. package/node_modules/pino/test/fixtures/ts/to-file-transport-with-transform.ts +18 -0
  285. package/node_modules/pino/test/fixtures/ts/to-file-transport.ts +11 -0
  286. package/node_modules/pino/test/fixtures/ts/transpile.cjs +36 -0
  287. package/node_modules/pino/test/fixtures/ts/transport-exit-immediately-with-async-dest.ts +15 -0
  288. package/node_modules/pino/test/fixtures/ts/transport-exit-immediately.ts +10 -0
  289. package/node_modules/pino/test/fixtures/ts/transport-exit-on-ready.ts +11 -0
  290. package/node_modules/pino/test/fixtures/ts/transport-main.ts +8 -0
  291. package/node_modules/pino/test/fixtures/ts/transport-string-stdout.ts +8 -0
  292. package/node_modules/pino/test/fixtures/ts/transport-worker.ts +14 -0
  293. package/node_modules/pino/test/formatters.test.js +364 -0
  294. package/node_modules/pino/test/helper.d.ts +4 -0
  295. package/node_modules/pino/test/helper.js +159 -0
  296. package/node_modules/pino/test/hooks.test.js +114 -0
  297. package/node_modules/pino/test/http.test.js +214 -0
  298. package/node_modules/pino/test/internals/version.test.js +17 -0
  299. package/node_modules/pino/test/is-level-enabled.test.js +179 -0
  300. package/node_modules/pino/test/jest/basic.spec.js +10 -0
  301. package/node_modules/pino/test/levels.test.js +810 -0
  302. package/node_modules/pino/test/metadata.test.js +120 -0
  303. package/node_modules/pino/test/mixin-merge-strategy.test.js +57 -0
  304. package/node_modules/pino/test/mixin.test.js +241 -0
  305. package/node_modules/pino/test/multistream.test.js +793 -0
  306. package/node_modules/pino/test/redact.test.js +923 -0
  307. package/node_modules/pino/test/serializers.test.js +257 -0
  308. package/node_modules/pino/test/smoke.js +59 -0
  309. package/node_modules/pino/test/stdout-protection.test.js +41 -0
  310. package/node_modules/pino/test/syncfalse.test.js +186 -0
  311. package/node_modules/pino/test/timestamp-nano.test.js +37 -0
  312. package/node_modules/pino/test/timestamp.test.js +124 -0
  313. package/node_modules/pino/test/transport/big.test.js +42 -0
  314. package/node_modules/pino/test/transport/bundlers-support.test.js +99 -0
  315. package/node_modules/pino/test/transport/caller.test.js +24 -0
  316. package/node_modules/pino/test/transport/core.test.js +818 -0
  317. package/node_modules/pino/test/transport/core.transpiled.test.ts +114 -0
  318. package/node_modules/pino/test/transport/crash.test.js +36 -0
  319. package/node_modules/pino/test/transport/module-link.test.js +241 -0
  320. package/node_modules/pino/test/transport/native-type-stripping.test.mjs +151 -0
  321. package/node_modules/pino/test/transport/node-options.test.js +116 -0
  322. package/node_modules/pino/test/transport/pipeline.test.js +137 -0
  323. package/node_modules/pino/test/transport/preload.test.js +54 -0
  324. package/node_modules/pino/test/transport/repl.test.js +15 -0
  325. package/node_modules/pino/test/transport/sync-false.test.js +79 -0
  326. package/node_modules/pino/test/transport/sync-true.test.js +57 -0
  327. package/node_modules/pino/test/transport/targets.test.js +48 -0
  328. package/node_modules/pino/test/transport/uses-pino-config.test.js +166 -0
  329. package/node_modules/pino/test/transport-stream.test.js +40 -0
  330. package/node_modules/pino/test/types/pino-import.tst.cts +30 -0
  331. package/node_modules/pino/test/types/pino-import.tst.js +73 -0
  332. package/node_modules/pino/test/types/pino-multistream.tst.ts +49 -0
  333. package/node_modules/pino/test/types/pino-top-export.tst.ts +32 -0
  334. package/node_modules/pino/test/types/pino-transport.tst.ts +171 -0
  335. package/node_modules/pino/test/types/pino-type-only.tst.ts +77 -0
  336. package/node_modules/pino/test/types/pino.ts +98 -0
  337. package/node_modules/pino/test/types/pino.tst.ts +681 -0
  338. package/node_modules/pino/test/types/tsconfig.json +10 -0
  339. package/node_modules/pino/tsconfig.json +14 -0
  340. package/node_modules/pino-pretty/.borp.yaml +6 -0
  341. package/node_modules/pino-pretty/.editorconfig +13 -0
  342. package/node_modules/pino-pretty/.github/dependabot.yml +13 -0
  343. package/node_modules/pino-pretty/.github/workflows/ci.yml +83 -0
  344. package/node_modules/pino-pretty/LICENSE +21 -0
  345. package/node_modules/pino-pretty/Readme.md +425 -0
  346. package/node_modules/pino-pretty/SECURITY.md +146 -0
  347. package/node_modules/pino-pretty/benchmark.js +105 -0
  348. package/node_modules/pino-pretty/bin.js +113 -0
  349. package/node_modules/pino-pretty/demo.png +0 -0
  350. package/node_modules/pino-pretty/docs/help.md +24 -0
  351. package/node_modules/pino-pretty/eslint.config.js +5 -0
  352. package/node_modules/pino-pretty/help/help.txt +68 -0
  353. package/node_modules/pino-pretty/index.d.ts +227 -0
  354. package/node_modules/pino-pretty/index.js +234 -0
  355. package/node_modules/pino-pretty/lib/colors.js +134 -0
  356. package/node_modules/pino-pretty/lib/colors.test.js +132 -0
  357. package/node_modules/pino-pretty/lib/constants.js +55 -0
  358. package/node_modules/pino-pretty/lib/pretty.js +171 -0
  359. package/node_modules/pino-pretty/lib/utils/build-safe-sonic-boom.js +69 -0
  360. package/node_modules/pino-pretty/lib/utils/build-safe-sonic-boom.test.js +84 -0
  361. package/node_modules/pino-pretty/lib/utils/create-date.js +26 -0
  362. package/node_modules/pino-pretty/lib/utils/create-date.test.js +20 -0
  363. package/node_modules/pino-pretty/lib/utils/delete-log-property.js +28 -0
  364. package/node_modules/pino-pretty/lib/utils/delete-log-property.test.js +31 -0
  365. package/node_modules/pino-pretty/lib/utils/filter-log.js +99 -0
  366. package/node_modules/pino-pretty/lib/utils/filter-log.test.js +265 -0
  367. package/node_modules/pino-pretty/lib/utils/format-time.js +66 -0
  368. package/node_modules/pino-pretty/lib/utils/format-time.test.js +71 -0
  369. package/node_modules/pino-pretty/lib/utils/get-level-label-data.js +29 -0
  370. package/node_modules/pino-pretty/lib/utils/get-property-value.js +30 -0
  371. package/node_modules/pino-pretty/lib/utils/get-property-value.test.js +31 -0
  372. package/node_modules/pino-pretty/lib/utils/handle-custom-levels-names-opts.js +38 -0
  373. package/node_modules/pino-pretty/lib/utils/handle-custom-levels-names-opts.test.js +45 -0
  374. package/node_modules/pino-pretty/lib/utils/handle-custom-levels-opts.js +39 -0
  375. package/node_modules/pino-pretty/lib/utils/handle-custom-levels-opts.test.js +47 -0
  376. package/node_modules/pino-pretty/lib/utils/index.js +108 -0
  377. package/node_modules/pino-pretty/lib/utils/index.test.js +37 -0
  378. package/node_modules/pino-pretty/lib/utils/interpret-conditionals.js +41 -0
  379. package/node_modules/pino-pretty/lib/utils/interpret-conditionals.test.js +84 -0
  380. package/node_modules/pino-pretty/lib/utils/is-object.js +7 -0
  381. package/node_modules/pino-pretty/lib/utils/is-object.test.js +10 -0
  382. package/node_modules/pino-pretty/lib/utils/is-valid-date.js +14 -0
  383. package/node_modules/pino-pretty/lib/utils/is-valid-date.test.js +16 -0
  384. package/node_modules/pino-pretty/lib/utils/join-lines-with-indentation.js +29 -0
  385. package/node_modules/pino-pretty/lib/utils/join-lines-with-indentation.test.js +16 -0
  386. package/node_modules/pino-pretty/lib/utils/noop.js +3 -0
  387. package/node_modules/pino-pretty/lib/utils/noop.test.js +12 -0
  388. package/node_modules/pino-pretty/lib/utils/parse-factory-options.js +171 -0
  389. package/node_modules/pino-pretty/lib/utils/prettify-error-log.js +76 -0
  390. package/node_modules/pino-pretty/lib/utils/prettify-error-log.test.js +143 -0
  391. package/node_modules/pino-pretty/lib/utils/prettify-error.js +54 -0
  392. package/node_modules/pino-pretty/lib/utils/prettify-error.test.js +25 -0
  393. package/node_modules/pino-pretty/lib/utils/prettify-level.js +41 -0
  394. package/node_modules/pino-pretty/lib/utils/prettify-level.test.js +70 -0
  395. package/node_modules/pino-pretty/lib/utils/prettify-message.js +65 -0
  396. package/node_modules/pino-pretty/lib/utils/prettify-message.test.js +287 -0
  397. package/node_modules/pino-pretty/lib/utils/prettify-metadata.js +75 -0
  398. package/node_modules/pino-pretty/lib/utils/prettify-metadata.test.js +170 -0
  399. package/node_modules/pino-pretty/lib/utils/prettify-object.js +115 -0
  400. package/node_modules/pino-pretty/lib/utils/prettify-object.test.js +217 -0
  401. package/node_modules/pino-pretty/lib/utils/prettify-time.js +43 -0
  402. package/node_modules/pino-pretty/lib/utils/prettify-time.test.js +264 -0
  403. package/node_modules/pino-pretty/lib/utils/split-property-key.js +49 -0
  404. package/node_modules/pino-pretty/lib/utils/split-property-key.test.js +29 -0
  405. package/node_modules/pino-pretty/lib/utils/strip-unsafe-control-chars.js +18 -0
  406. package/node_modules/pino-pretty/lib/utils/strip-unsafe-control-chars.test.js +9 -0
  407. package/node_modules/pino-pretty/package.json +64 -0
  408. package/node_modules/pino-pretty/test/basic.test.js +1305 -0
  409. package/node_modules/pino-pretty/test/boolean-options.test.js +228 -0
  410. package/node_modules/pino-pretty/test/cli-rc.test.js +275 -0
  411. package/node_modules/pino-pretty/test/cli.test.js +360 -0
  412. package/node_modules/pino-pretty/test/crlf.test.js +33 -0
  413. package/node_modules/pino-pretty/test/error-objects.test.js +494 -0
  414. package/node_modules/pino-pretty/test/example/example.js +33 -0
  415. package/node_modules/pino-pretty/test/helper.js +19 -0
  416. package/node_modules/pino-pretty/test/types/exports.tst.ts +15 -0
  417. package/node_modules/pino-pretty/test/types/pino-pretty.tst.ts +140 -0
  418. package/node_modules/pino-pretty/test/types/tsconfig.json +9 -0
  419. package/package.json +12 -5
  420. package/lib/cli/commands/init.d.ts +0 -1
  421. package/lib/cli/commands/init.js +0 -8
  422. package/node_modules/@types/node/globals.global.d.ts +0 -1
@@ -0,0 +1,818 @@
1
+ 'use strict'
2
+
3
+ const test = require('node:test')
4
+ const assert = require('node:assert')
5
+ const os = require('node:os')
6
+ const { join } = require('node:path')
7
+ const { once } = require('node:events')
8
+ const { setImmediate: immediate } = require('node:timers/promises')
9
+ const { readFile, writeFile } = require('node:fs').promises
10
+ const url = require('url')
11
+ const strip = require('strip-ansi')
12
+ const execa = require('execa')
13
+ const writer = require('flush-write-stream')
14
+ const rimraf = require('rimraf')
15
+ const tspl = require('@matteo.collina/tspl')
16
+
17
+ const { match, watchFileCreated, watchForWrite, file } = require('../helper')
18
+ const pino = require('../../')
19
+
20
+ const { tmpdir } = os
21
+ const pid = process.pid
22
+ const hostname = os.hostname()
23
+
24
+ test('pino.transport with file', async (t) => {
25
+ const destination = file()
26
+ const transport = pino.transport({
27
+ target: join(__dirname, '..', 'fixtures', 'to-file-transport.js'),
28
+ options: { destination }
29
+ })
30
+ t.after(transport.end.bind(transport))
31
+ const instance = pino(transport)
32
+ instance.info('hello')
33
+ await watchFileCreated(destination)
34
+ const result = JSON.parse(await readFile(destination))
35
+ delete result.time
36
+ assert.deepEqual(result, {
37
+ pid,
38
+ hostname,
39
+ level: 30,
40
+ msg: 'hello'
41
+ })
42
+ })
43
+
44
+ test('pino.transport with file (no options + error handling)', async () => {
45
+ const transport = pino.transport({
46
+ target: join(__dirname, '..', 'fixtures', 'to-file-transport.js')
47
+ })
48
+ const [err] = await once(transport, 'error')
49
+ assert.equal(err.message, 'kaboom')
50
+ })
51
+
52
+ test('pino.transport with file URL', async (t) => {
53
+ const destination = file()
54
+ const transport = pino.transport({
55
+ target: url.pathToFileURL(join(__dirname, '..', 'fixtures', 'to-file-transport.js')).href,
56
+ options: { destination }
57
+ })
58
+ t.after(transport.end.bind(transport))
59
+ const instance = pino(transport)
60
+ instance.info('hello')
61
+ await watchFileCreated(destination)
62
+ const result = JSON.parse(await readFile(destination))
63
+ delete result.time
64
+ assert.deepEqual(result, {
65
+ pid,
66
+ hostname,
67
+ level: 30,
68
+ msg: 'hello'
69
+ })
70
+ })
71
+
72
+ test('pino.transport errors if file does not exists', (t, end) => {
73
+ const instance = pino.transport({
74
+ target: join(__dirname, '..', 'fixtures', 'non-existent-file'),
75
+ worker: {
76
+ stdin: true,
77
+ stdout: true,
78
+ stderr: true
79
+ }
80
+ })
81
+ instance.on('error', function () {
82
+ assert.ok('error received')
83
+ end()
84
+ })
85
+ })
86
+
87
+ test('pino.transport errors if transport worker module does not export a function', async (t) => {
88
+ // TODO: add case for non-pipelined single target (needs changes in thread-stream)
89
+ const plan = tspl(t, { plan: 2 })
90
+ const manyTargetsInstance = pino.transport({
91
+ targets: [{
92
+ level: 'info',
93
+ target: join(__dirname, '..', 'fixtures', 'transport-wrong-export-type.js')
94
+ }, {
95
+ level: 'info',
96
+ target: join(__dirname, '..', 'fixtures', 'transport-wrong-export-type.js')
97
+ }]
98
+ })
99
+ manyTargetsInstance.on('error', function (e) {
100
+ plan.equal(e.message, 'exported worker is not a function')
101
+ })
102
+
103
+ const pipelinedInstance = pino.transport({
104
+ pipeline: [{
105
+ target: join(__dirname, '..', 'fixtures', 'transport-wrong-export-type.js')
106
+ }]
107
+ })
108
+ pipelinedInstance.on('error', function (e) {
109
+ plan.equal(e.message, 'exported worker is not a function')
110
+ })
111
+
112
+ await plan
113
+ })
114
+
115
+ test('pino.transport with esm', async (t) => {
116
+ const destination = file()
117
+ const transport = pino.transport({
118
+ target: join(__dirname, '..', 'fixtures', 'to-file-transport.mjs'),
119
+ options: { destination }
120
+ })
121
+ const instance = pino(transport)
122
+ t.after(transport.end.bind(transport))
123
+ instance.info('hello')
124
+ await watchFileCreated(destination)
125
+ const result = JSON.parse(await readFile(destination))
126
+ delete result.time
127
+ assert.deepEqual(result, {
128
+ pid,
129
+ hostname,
130
+ level: 30,
131
+ msg: 'hello'
132
+ })
133
+ })
134
+
135
+ test('pino.transport with two files', async (t) => {
136
+ const dest1 = file()
137
+ const dest2 = file()
138
+ const transport = pino.transport({
139
+ targets: [{
140
+ level: 'info',
141
+ target: 'file://' + join(__dirname, '..', 'fixtures', 'to-file-transport.js'),
142
+ options: { destination: dest1 }
143
+ }, {
144
+ level: 'info',
145
+ target: join(__dirname, '..', 'fixtures', 'to-file-transport.js'),
146
+ options: { destination: dest2 }
147
+ }]
148
+ })
149
+ t.after(transport.end.bind(transport))
150
+ const instance = pino(transport)
151
+ instance.info('hello')
152
+ await Promise.all([watchFileCreated(dest1), watchFileCreated(dest2)])
153
+ const result1 = JSON.parse(await readFile(dest1))
154
+ delete result1.time
155
+ assert.deepEqual(result1, {
156
+ pid,
157
+ hostname,
158
+ level: 30,
159
+ msg: 'hello'
160
+ })
161
+ const result2 = JSON.parse(await readFile(dest2))
162
+ delete result2.time
163
+ assert.deepEqual(result2, {
164
+ pid,
165
+ hostname,
166
+ level: 30,
167
+ msg: 'hello'
168
+ })
169
+ })
170
+
171
+ test('pino.transport with two files and custom levels', async (t) => {
172
+ const dest1 = file()
173
+ const dest2 = file()
174
+ const transport = pino.transport({
175
+ targets: [{
176
+ level: 'info',
177
+ target: join(__dirname, '..', 'fixtures', 'to-file-transport.js'),
178
+ options: { destination: dest1 }
179
+ }, {
180
+ level: 'foo',
181
+ target: join(__dirname, '..', 'fixtures', 'to-file-transport.js'),
182
+ options: { destination: dest2 }
183
+ }],
184
+ levels: { trace: 10, debug: 20, info: 30, warn: 40, error: 50, fatal: 60, foo: 25 }
185
+ })
186
+ t.after(transport.end.bind(transport))
187
+ const instance = pino(transport)
188
+ instance.info('hello')
189
+ await Promise.all([watchFileCreated(dest1), watchFileCreated(dest2)])
190
+ const result1 = JSON.parse(await readFile(dest1))
191
+ delete result1.time
192
+ assert.deepEqual(result1, {
193
+ pid,
194
+ hostname,
195
+ level: 30,
196
+ msg: 'hello'
197
+ })
198
+ const result2 = JSON.parse(await readFile(dest2))
199
+ delete result2.time
200
+ assert.deepEqual(result2, {
201
+ pid,
202
+ hostname,
203
+ level: 30,
204
+ msg: 'hello'
205
+ })
206
+ })
207
+
208
+ test('pino.transport without specifying default levels', async (t) => {
209
+ const dest = file()
210
+ const transport = pino.transport({
211
+ targets: [{
212
+ level: 'foo',
213
+ target: join(__dirname, '..', 'fixtures', 'to-file-transport.js'),
214
+ options: { destination: dest }
215
+ }],
216
+ levels: { foo: 25 }
217
+ })
218
+ t.after(transport.end.bind(transport))
219
+ const instance = pino(transport)
220
+ instance.info('hello')
221
+ await Promise.all([watchFileCreated(dest)])
222
+ const result1 = JSON.parse(await readFile(dest))
223
+ delete result1.time
224
+ assert.deepEqual(result1, {
225
+ pid,
226
+ hostname,
227
+ level: 30,
228
+ msg: 'hello'
229
+ })
230
+ })
231
+
232
+ test('pino.transport with two files and dedupe', async (t) => {
233
+ const dest1 = file()
234
+ const dest2 = file()
235
+ const transport = pino.transport({
236
+ dedupe: true,
237
+ targets: [{
238
+ level: 'info',
239
+ target: join(__dirname, '..', 'fixtures', 'to-file-transport.js'),
240
+ options: { destination: dest1 }
241
+ }, {
242
+ level: 'error',
243
+ target: join(__dirname, '..', 'fixtures', 'to-file-transport.js'),
244
+ options: { destination: dest2 }
245
+ }]
246
+ })
247
+ t.after(transport.end.bind(transport))
248
+ const instance = pino(transport)
249
+ instance.info('hello')
250
+ instance.error('world')
251
+ await Promise.all([watchFileCreated(dest1), watchFileCreated(dest2)])
252
+ const result1 = JSON.parse(await readFile(dest1))
253
+ delete result1.time
254
+ assert.deepEqual(result1, {
255
+ pid,
256
+ hostname,
257
+ level: 30,
258
+ msg: 'hello'
259
+ })
260
+ const result2 = JSON.parse(await readFile(dest2))
261
+ delete result2.time
262
+ assert.deepEqual(result2, {
263
+ pid,
264
+ hostname,
265
+ level: 50,
266
+ msg: 'world'
267
+ })
268
+ })
269
+
270
+ test('pino.transport with single target in targets array honors level filter (#1996)', async (t) => {
271
+ const destination = file()
272
+ const transport = pino.transport({
273
+ targets: [{
274
+ level: 'error',
275
+ target: join(__dirname, '..', 'fixtures', 'to-file-transport.js'),
276
+ options: { destination }
277
+ }]
278
+ })
279
+ t.after(transport.end.bind(transport))
280
+ const instance = pino({ level: 'debug' }, transport)
281
+ instance.debug('debug-msg')
282
+ instance.info('info-msg')
283
+ instance.warn('warn-msg')
284
+ instance.error('error-msg')
285
+ await watchForWrite(destination, 'error-msg')
286
+ const lines = (await readFile(destination, 'utf8')).trim().split('\n').filter(Boolean)
287
+ assert.equal(lines.length, 1, 'only error should be written to destination')
288
+ const result = JSON.parse(lines[0])
289
+ delete result.time
290
+ assert.deepEqual(result, {
291
+ pid,
292
+ hostname,
293
+ level: 50,
294
+ msg: 'error-msg'
295
+ })
296
+ })
297
+
298
+ test('pino.transport with single target in targets array without level keeps logger.level gating', async (t) => {
299
+ const destination = file()
300
+ const transport = pino.transport({
301
+ targets: [{
302
+ target: join(__dirname, '..', 'fixtures', 'to-file-transport.js'),
303
+ options: { destination }
304
+ }]
305
+ })
306
+ t.after(transport.end.bind(transport))
307
+ const instance = pino({ level: 'debug' }, transport)
308
+ instance.debug('debug-msg')
309
+ instance.info('info-msg')
310
+ await watchForWrite(destination, 'info-msg')
311
+ const lines = (await readFile(destination, 'utf8')).trim().split('\n').filter(Boolean)
312
+ assert.equal(lines.length, 2, 'both debug and info reach the single target when no per-target level is set')
313
+ const first = JSON.parse(lines[0])
314
+ delete first.time
315
+ assert.deepEqual(first, {
316
+ pid,
317
+ hostname,
318
+ level: 20,
319
+ msg: 'debug-msg'
320
+ })
321
+ })
322
+
323
+ test('pino.transport with an array including a pino-pretty destination', async (t) => {
324
+ const dest1 = file()
325
+ const dest2 = file()
326
+ const transport = pino.transport({
327
+ targets: [{
328
+ level: 'info',
329
+ target: 'pino/file',
330
+ options: {
331
+ destination: dest1
332
+ }
333
+ }, {
334
+ level: 'info',
335
+ target: 'pino-pretty',
336
+ options: {
337
+ destination: dest2
338
+ }
339
+ }]
340
+ })
341
+ t.after(transport.end.bind(transport))
342
+ const instance = pino(transport)
343
+ instance.info('hello')
344
+ await Promise.all([watchFileCreated(dest1), watchFileCreated(dest2)])
345
+ const result1 = JSON.parse(await readFile(dest1))
346
+ delete result1.time
347
+ assert.deepEqual(result1, {
348
+ pid,
349
+ hostname,
350
+ level: 30,
351
+ msg: 'hello'
352
+ })
353
+ const actual = (await readFile(dest2)).toString()
354
+ assert.match(strip(actual), /\[.*\] INFO.*hello/)
355
+ })
356
+
357
+ test('no transport.end()', async (t) => {
358
+ const destination = file()
359
+ const transport = pino.transport({
360
+ target: join(__dirname, '..', 'fixtures', 'to-file-transport.js'),
361
+ options: { destination }
362
+ })
363
+ const instance = pino(transport)
364
+ instance.info('hello')
365
+ await watchFileCreated(destination)
366
+ const result = JSON.parse(await readFile(destination))
367
+ delete result.time
368
+ assert.deepEqual(result, {
369
+ pid,
370
+ hostname,
371
+ level: 30,
372
+ msg: 'hello'
373
+ })
374
+ })
375
+
376
+ test('autoEnd = false', async (t) => {
377
+ const destination = file()
378
+ const count = process.listenerCount('exit')
379
+ const transport = pino.transport({
380
+ target: join(__dirname, '..', 'fixtures', 'to-file-transport.js'),
381
+ options: { destination },
382
+ worker: { autoEnd: false }
383
+ })
384
+ t.after(transport.end.bind(transport))
385
+ await once(transport, 'ready')
386
+
387
+ const instance = pino(transport)
388
+ instance.info('hello')
389
+
390
+ await watchFileCreated(destination)
391
+
392
+ assert.equal(count, process.listenerCount('exit'))
393
+
394
+ const result = JSON.parse(await readFile(destination))
395
+ delete result.time
396
+ assert.deepEqual(result, {
397
+ pid,
398
+ hostname,
399
+ level: 30,
400
+ msg: 'hello'
401
+ })
402
+ })
403
+
404
+ test('pino.transport with target and targets', async () => {
405
+ assert.throws(
406
+ () => {
407
+ pino.transport({
408
+ target: '/a/file',
409
+ targets: [{
410
+ target: '/a/file'
411
+ }]
412
+ })
413
+ },
414
+ /only one of target or targets can be specified/
415
+ )
416
+ })
417
+
418
+ test('pino.transport with target pino/file', async (t) => {
419
+ const destination = file()
420
+ const transport = pino.transport({
421
+ target: 'pino/file',
422
+ options: { destination }
423
+ })
424
+ t.after(transport.end.bind(transport))
425
+ const instance = pino(transport)
426
+ instance.info('hello')
427
+ await watchFileCreated(destination)
428
+ const result = JSON.parse(await readFile(destination))
429
+ delete result.time
430
+ assert.deepEqual(result, {
431
+ pid,
432
+ hostname,
433
+ level: 30,
434
+ msg: 'hello'
435
+ })
436
+ })
437
+
438
+ test('pino.transport with target pino/file and mkdir option', async (t) => {
439
+ const folder = join(tmpdir(), `pino-${process.pid}-mkdir-transport-file`)
440
+ const destination = join(folder, 'log.txt')
441
+ t.after(() => {
442
+ try {
443
+ rimraf.sync(folder)
444
+ } catch (err) {
445
+ // ignore
446
+ }
447
+ })
448
+ const transport = pino.transport({
449
+ target: 'pino/file',
450
+ options: { destination, mkdir: true }
451
+ })
452
+ t.after(transport.end.bind(transport))
453
+ const instance = pino(transport)
454
+ instance.info('hello')
455
+ await watchFileCreated(destination)
456
+ const result = JSON.parse(await readFile(destination))
457
+ delete result.time
458
+ assert.deepEqual(result, {
459
+ pid,
460
+ hostname,
461
+ level: 30,
462
+ msg: 'hello'
463
+ })
464
+ })
465
+
466
+ test('pino.transport with target pino/file and append option', async (t) => {
467
+ const destination = file()
468
+ await writeFile(destination, JSON.stringify({ pid, hostname, time: Date.now(), level: 30, msg: 'hello' }))
469
+ const transport = pino.transport({
470
+ target: 'pino/file',
471
+ options: { destination, append: false }
472
+ })
473
+ t.after(transport.end.bind(transport))
474
+ const instance = pino(transport)
475
+ instance.info('goodbye')
476
+ await watchForWrite(destination, '"goodbye"')
477
+ const result = JSON.parse(await readFile(destination))
478
+ delete result.time
479
+ assert.deepEqual(result, {
480
+ pid,
481
+ hostname,
482
+ level: 30,
483
+ msg: 'goodbye'
484
+ })
485
+ })
486
+
487
+ test('pino.transport should error with unknown target', async () => {
488
+ assert.throws(
489
+ () => {
490
+ pino.transport({
491
+ target: 'origin',
492
+ caller: 'unknown-file.js'
493
+ })
494
+ },
495
+ /unable to determine transport target for "origin"/
496
+ )
497
+ })
498
+
499
+ test('pino.transport with target pino-pretty', async (t) => {
500
+ const destination = file()
501
+ const transport = pino.transport({
502
+ target: 'pino-pretty',
503
+ options: { destination }
504
+ })
505
+ t.after(transport.end.bind(transport))
506
+ const instance = pino(transport)
507
+ instance.info('hello')
508
+ await watchFileCreated(destination)
509
+ const actual = await readFile(destination, 'utf8')
510
+ assert.match(strip(actual), /\[.*\] INFO.*hello/)
511
+ })
512
+
513
+ test('sets worker data informing the transport that pino will send its config', async (t) => {
514
+ const plan = tspl(t, { plan: 1 })
515
+ const transport = pino.transport({
516
+ target: join(__dirname, '..', 'fixtures', 'transport-worker-data.js')
517
+ })
518
+ t.after(transport.end.bind(transport))
519
+ const instance = pino(transport)
520
+ transport.once('workerData', (workerData) => {
521
+ match(workerData.workerData, { pinoWillSendConfig: true })
522
+ plan.ok('passed')
523
+ })
524
+ instance.info('hello')
525
+
526
+ await plan
527
+ })
528
+
529
+ test('sets worker data informing the transport that pino will send its config (frozen file)', async (t) => {
530
+ const plan = tspl(t, { plan: 1 })
531
+ const config = {
532
+ transport: {
533
+ target: join(__dirname, '..', 'fixtures', 'transport-worker-data.js'),
534
+ options: {}
535
+ }
536
+ }
537
+ Object.freeze(config)
538
+ Object.freeze(config.transport)
539
+ Object.freeze(config.transport.options)
540
+ const instance = pino(config)
541
+ const transport = instance[pino.symbols.streamSym]
542
+ t.after(transport.end.bind(transport))
543
+ transport.once('workerData', (workerData) => {
544
+ match(workerData.workerData, { pinoWillSendConfig: true })
545
+ plan.ok('passed')
546
+ })
547
+ instance.info('hello')
548
+
549
+ await plan
550
+ })
551
+
552
+ test('warns when custom formatters.level is incompatible with multi-target transport routing', async (t) => {
553
+ const warnings = []
554
+ const originalEmitWarning = process.emitWarning
555
+ process.emitWarning = function (warning, options) {
556
+ warnings.push({ warning, options })
557
+ }
558
+ t.after(() => {
559
+ process.emitWarning = originalEmitWarning
560
+ })
561
+
562
+ const transport = pino.transport({
563
+ targets: [
564
+ { target: join(__dirname, '..', 'fixtures', 'noop-transport.js') },
565
+ { target: join(__dirname, '..', 'fixtures', 'noop-transport.js') }
566
+ ]
567
+ })
568
+ t.after(transport.end.bind(transport))
569
+
570
+ const instance = pino({
571
+ formatters: {
572
+ level (label) {
573
+ return { severity: label }
574
+ }
575
+ }
576
+ }, transport)
577
+
578
+ instance.info('hello')
579
+
580
+ assert.equal(warnings.length, 1)
581
+ assert.equal(warnings[0].options.code, 'PINO_TRANSPORT_MULTI_TARGETS_LEVEL_FORMATTER')
582
+ })
583
+
584
+ test('stdout in worker', async () => {
585
+ let actual = ''
586
+ const child = execa(process.argv[0], [join(__dirname, '..', 'fixtures', 'transport-main.js')])
587
+
588
+ for await (const chunk of child.stdout) {
589
+ actual += chunk
590
+ }
591
+ assert.equal(strip(actual).match(/Hello/) != null, true)
592
+ })
593
+
594
+ test('log and exit on ready', async () => {
595
+ let actual = ''
596
+ const child = execa(process.argv[0], [join(__dirname, '..', 'fixtures', 'transport-exit-on-ready.js')])
597
+
598
+ child.stdout.pipe(writer((s, enc, cb) => {
599
+ actual += s
600
+ cb()
601
+ }))
602
+ await once(child, 'close')
603
+ await immediate()
604
+ assert.equal(strip(actual).match(/Hello/) != null, true)
605
+ })
606
+
607
+ test('log and exit before ready', async () => {
608
+ let actual = ''
609
+ const child = execa(process.argv[0], [join(__dirname, '..', 'fixtures', 'transport-exit-immediately.js')])
610
+
611
+ child.stdout.pipe(writer((s, enc, cb) => {
612
+ actual += s
613
+ cb()
614
+ }))
615
+ await once(child, 'close')
616
+ await immediate()
617
+ assert.equal(strip(actual).match(/Hello/) != null, true)
618
+ })
619
+
620
+ test('log and exit before ready with async dest', async () => {
621
+ const destination = file()
622
+ const child = execa(process.argv[0], [join(__dirname, '..', 'fixtures', 'transport-exit-immediately-with-async-dest.js'), destination])
623
+
624
+ await once(child, 'exit')
625
+
626
+ const actual = await readFile(destination, 'utf8')
627
+ assert.equal(strip(actual).match(/HELLO/) != null, true)
628
+ assert.equal(strip(actual).match(/WORLD/) != null, true)
629
+ })
630
+
631
+ test('string integer destination', async () => {
632
+ let actual = ''
633
+ const child = execa(process.argv[0], [join(__dirname, '..', 'fixtures', 'transport-string-stdout.js')])
634
+
635
+ child.stdout.pipe(writer((s, enc, cb) => {
636
+ actual += s
637
+ cb()
638
+ }))
639
+ await once(child, 'close')
640
+ await immediate()
641
+ assert.equal(strip(actual).match(/Hello/) != null, true)
642
+ })
643
+
644
+ test('pino transport options with target', async (t) => {
645
+ const destination = file()
646
+ const instance = pino({
647
+ transport: {
648
+ target: 'pino/file',
649
+ options: { destination }
650
+ }
651
+ })
652
+ const transportStream = instance[pino.symbols.streamSym]
653
+ t.after(transportStream.end.bind(transportStream))
654
+ instance.info('transport option test')
655
+ await watchFileCreated(destination)
656
+ const result = JSON.parse(await readFile(destination))
657
+ delete result.time
658
+ assert.deepEqual(result, {
659
+ pid,
660
+ hostname,
661
+ level: 30,
662
+ msg: 'transport option test'
663
+ })
664
+ })
665
+
666
+ test('pino transport options with targets', async (t) => {
667
+ const dest1 = file()
668
+ const dest2 = file()
669
+ const instance = pino({
670
+ transport: {
671
+ targets: [
672
+ { target: 'pino/file', options: { destination: dest1 } },
673
+ { target: 'pino/file', options: { destination: dest2 } }
674
+ ]
675
+ }
676
+ })
677
+ const transportStream = instance[pino.symbols.streamSym]
678
+ t.after(transportStream.end.bind(transportStream))
679
+ instance.info('transport option test')
680
+
681
+ await Promise.all([watchFileCreated(dest1), watchFileCreated(dest2)])
682
+ const result1 = JSON.parse(await readFile(dest1))
683
+ delete result1.time
684
+ assert.deepEqual(result1, {
685
+ pid,
686
+ hostname,
687
+ level: 30,
688
+ msg: 'transport option test'
689
+ })
690
+ const result2 = JSON.parse(await readFile(dest2))
691
+ delete result2.time
692
+ assert.deepEqual(result2, {
693
+ pid,
694
+ hostname,
695
+ level: 30,
696
+ msg: 'transport option test'
697
+ })
698
+ })
699
+
700
+ test('transport options with target and targets', async () => {
701
+ assert.throws(
702
+ () => {
703
+ pino({
704
+ transport: {
705
+ target: {},
706
+ targets: {}
707
+ }
708
+ })
709
+ },
710
+ /only one of target or targets can be specified/
711
+ )
712
+ })
713
+
714
+ test('transport options with target and stream', async () => {
715
+ assert.throws(
716
+ () => {
717
+ pino({
718
+ transport: {
719
+ target: {}
720
+ }
721
+ }, '/log/null')
722
+ },
723
+ /only one of option.transport or stream can be specified/
724
+ )
725
+ })
726
+
727
+ test('transport options with stream', async (t) => {
728
+ const dest1 = file()
729
+ const transportStream = pino.transport({ target: 'pino/file', options: { destination: dest1 } })
730
+ t.after(transportStream.end.bind(transportStream))
731
+ assert.throws(
732
+ () => {
733
+ pino({
734
+ transport: transportStream
735
+ })
736
+ },
737
+ Error('option.transport do not allow stream, please pass to option directly. e.g. pino(transport)')
738
+ )
739
+ })
740
+
741
+ test('pino.transport handles prototype pollution of __bundlerPathsOverrides', async (t) => {
742
+ // eslint-disable-next-line no-extend-native
743
+ Object.prototype.__bundlerPathsOverrides = { 'pino/file': '/malicious/path' }
744
+ t.after(() => {
745
+ delete Object.prototype.__bundlerPathsOverrides
746
+ })
747
+
748
+ const destination = file()
749
+ const transport = pino.transport({
750
+ target: 'pino/file',
751
+ options: { destination }
752
+ })
753
+ t.after(transport.end.bind(transport))
754
+
755
+ const instance = pino(transport)
756
+ instance.info('hello')
757
+ await watchFileCreated(destination)
758
+ const result = JSON.parse(await readFile(destination))
759
+ delete result.time
760
+ assert.deepEqual(result, {
761
+ pid,
762
+ hostname,
763
+ level: 30,
764
+ msg: 'hello'
765
+ })
766
+ })
767
+
768
+ const hasThreadName = 'threadName' in require('worker_threads')
769
+
770
+ test('pino.transport with single target sets worker thread name to target', { skip: !hasThreadName }, async (t) => {
771
+ const plan = tspl(t, { plan: 1 })
772
+ const transport = pino.transport({
773
+ target: join(__dirname, '..', 'fixtures', 'transport-worker-name.js')
774
+ })
775
+ t.after(transport.end.bind(transport))
776
+ const instance = pino(transport)
777
+ transport.once('workerThreadName', (name) => {
778
+ plan.equal(name, join(__dirname, '..', 'fixtures', 'transport-worker-name.js'))
779
+ })
780
+ instance.info('hello')
781
+
782
+ await plan
783
+ })
784
+
785
+ test('pino.transport with targets sets worker thread name to pino.transport', { skip: !hasThreadName }, async (t) => {
786
+ const plan = tspl(t, { plan: 1 })
787
+ const transport = pino.transport({
788
+ targets: [{
789
+ level: 'info',
790
+ target: join(__dirname, '..', 'fixtures', 'transport-worker-name.js')
791
+ }]
792
+ })
793
+ t.after(transport.end.bind(transport))
794
+ const instance = pino(transport)
795
+ transport.once('workerThreadName', (name) => {
796
+ plan.equal(name, 'pino.transport')
797
+ })
798
+ instance.info('hello')
799
+
800
+ await plan
801
+ })
802
+
803
+ test('pino.transport with pipeline sets worker thread name to pino.transport', { skip: !hasThreadName }, async (t) => {
804
+ const plan = tspl(t, { plan: 1 })
805
+ const transport = pino.transport({
806
+ pipeline: [{
807
+ target: join(__dirname, '..', 'fixtures', 'transport-worker-name.js')
808
+ }]
809
+ })
810
+ t.after(transport.end.bind(transport))
811
+ const instance = pino(transport)
812
+ transport.once('workerThreadName', (name) => {
813
+ plan.equal(name, 'pino.transport')
814
+ })
815
+ instance.info('hello')
816
+
817
+ await plan
818
+ })