From 1c676c5fb0c6e4f616454498b34097e579d8d213 Mon Sep 17 00:00:00 2001 From: Tobias Gurtzick Date: Sat, 13 Jun 2020 11:29:12 +0200 Subject: [PATCH] add failing test Signed-off-by: Tobias Gurtzick --- test/coverage.html | 4451 ++++++++++++++++++++++-------------------- test/history.test.js | 44 + 2 files changed, 2378 insertions(+), 2117 deletions(-) create mode 100644 test/history.test.js diff --git a/test/coverage.html b/test/coverage.html index a7ef4119..ade5b9a6 100644 --- a/test/coverage.html +++ b/test/coverage.html @@ -552,11 +552,11 @@ lib/add.js
  • - 92.15 + 92.34 lib/api.js
  • - 87.52 + 87.69 lib/common.js
  • @@ -610,8 +610,8 @@

    Test Report

    0
    0
    -
    347
    -
    36778
    +
    352
    +
    45463
    @@ -627,6 +627,20 @@

    Test Report

    + + + + + + + + + + + + + + @@ -714,35 +728,35 @@

    Test Report

    act make_actmsg - 10 + 8 2 act process_outward - 115 + 74 3 actions cmd_ping - 309 + 267 4 actions cmd_stats - 50 + 32 5 actions cmd_close - 132 + 144 6 @@ -756,2387 +770,2422 @@

    Test Report

    actions get_options - 77 + 59 8 add name - 17 + 41 9 add action_modifier - 130 + 140 10 api error - 8 + 9 11 - api fail + api list - 18 + 26 12 - api list + api translate - 25 + 146 13 - api translate + api test-mode - 131 + 81 14 - api test-mode + api find_plugin - 72 + 142 15 - api find_plugin + api has_plugin - 146 + 247 16 - api has_plugin + api ignore_plugin - 252 + 403 17 - api ignore_plugin + api has - 365 + 13 18 - api has + api find - 4 + 59 19 - api find + api status - 18 + 162 20 - api status + api reply - 131 + 38 21 - api reply + api delegate - 14 + 46 - + 22 - api delegate + api fail invoked with a code and details - 14 + 5 - + 23 + api fail invoked with a condition, code and details when the condition is true throws + + + 4 + + + 24 + api fail invoked with a condition, code and details when the condition is false does not throw + + + 1 + + + 25 + api fail invoked with a condition, code and details when the condition is not a boolean throws informing the client of the wrong type + + + 2 + + + 26 + api fail when given no arguments throws a seneca error + + + 2 + + + 27 + api fail when given too many arguments throws a seneca error + + + 2 + + + 28 close happy - 122 + 135 - 24 + 29 close add - 128 + 148 - 25 + 30 close graceful - 239 + 257 - 26 + 31 close timeout - 126 + 148 - 27 + 32 close handle-signal - 126 + 155 - 28 + 33 close error - 128 + 148 - 29 + 34 close no-promise - 125 + 151 - 30 + 35 close with-promise - 129 + 151 - 31 + 36 close with-async-await - 125 + 144 - 32 + 37 common misc - 7 + 38 - 33 + 38 common deepextend-empty - 1 + 2 - 34 + 39 common deepextend-dups - 0 + 1 - 35 + 40 common deepextend-objs - 5 + 16 - 36 + 41 common deepextend-objs with functions - 0 + 1 - 37 + 42 common pattern - 0 + 1 - 38 + 43 common nil - 1 + 0 - 39 + 44 common recurse - 0 + 1 - 40 + 45 common pincanon 1 - 41 + 46 common history - 7 + 21 - 42 + 47 common clean - 2 + 7 - 43 + 48 common parse_jsonic - 2 + 10 - 44 + 49 common make_plugin_key - 5 + 24 - 45 + 50 custom custom-basic - 23 + 42 - 46 + 51 custom custom-deep - 134 + 169 - 47 + 52 custom custom-reply - 134 + 163 - 48 + 53 custom custom-entity - 164 + 244 - 49 + 54 custom custom-prior - 48 + 74 - 50 + 55 custom custom-simple-transport - 157 + 217 - 51 + 56 custom custom-bells-transport - 279 + 407 - 52 + 57 custom custom-add-basic - 134 + 182 - 53 + 58 custom custom-add-fix - 19 + 73 - 54 + 59 debug logroute - 10 + 27 - 55 + 60 delegation happy - 143 + 173 - 56 + 61 delegation dynamic - 137 + 210 - 57 + 62 delegation prior.basic - 133 + 177 - 58 + 63 delegation parent.plugin - 159 + 253 - 59 + 64 entity happy - 29 + 123 - 60 + 65 entity entity-msg - 133 + 146 - 61 + 66 entity mem-ops - 233 + 296 - 62 + 67 error fail - 13 + 33 - 63 + 68 error response_is_error - 25 + 92 - 64 + 69 error action_callback - 22 + 42 - 65 + 70 error plugin_load - 18 + 30 - 66 + 71 error act_not_found - 52 + 104 - 67 + 72 error exec_action_throw_basic - 15 + 37 - 68 + 73 error exec_action_throw_basic_legacy - 33 + 62 - 69 + 74 error exec_action_throw_nolog - 21 + 32 - 70 + 75 error exec_action_errhandler_throw - 62 + 111 - 71 + 76 error exec_action_result - 22 + 46 - 72 + 77 error exec_deep_action_result - 27 + 68 - 73 + 78 error exec_remote_action_result - 167 + 232 - 74 + 79 error exec_action_result_legacy - 34 + 121 - 75 + 80 error exec_action_result_nolog - 32 + 66 - 76 + 81 error exec_action_errhandler_result - 63 + 124 - 77 + 82 error action_callback - 171 + 186 - 78 + 83 error legacy_fail - 11 + 35 - 79 + 84 error types - 22 + 78 - 80 + 85 explain explain-basic - 47 + 86 - 81 + 86 explain explain-data - 32 + 71 - 82 + 87 explain explain-deep - 64 + 79 - 83 + 88 explain explain-toplevel - 136 + 142 - 84 + 89 explain explain-transport - 334 + 385 - 85 + 90 exports happy - 123 + 149 - 86 + 91 exports with-init - 129 + 143 - 87 + 92 exports with-preload - 124 + 152 - 88 + 93 exports with-preload-and-init - 139 + 155 - 89 + 94 outward act_error 1 - 90 + 95 inward announce - 123 + 147 - 91 + 96 inward arg-check - 2 + 4 - 92 + 97 legacy fail - 1 + 2 - 93 + 98 legacy argprops - 1 + 2 - 94 + 99 legacy router - 0 + 1 - 95 + 100 legacy no-default-transport - 120 + 133 - 96 + 101 legacy actdef - 14 + 31 - 97 + 102 logging happy - 122 + 142 - 98 + 103 logging happy-ng - 122 + 143 - 99 + 104 logging level-text-values - 10 + 34 - 100 + 105 logging build_log_spec - 2 + 12 - 101 + 106 logging event - 135 + 178 - 102 + 107 logging quiet - 120 + 144 - 103 + 108 logging bad_logspec - 7 + 13 - 104 + 109 logging basic - 120 + 143 - 105 + 110 logging logger-output - 755 + 898 - 106 + 111 logging shortcuts - 1362 + 1567 - 107 + 112 logging test-mode-basic - 122 + 142 - 108 + 113 logging test-mode-option - 125 + 150 - 109 + 114 logging test-mode-argv - 122 + 150 - 110 + 115 logging test-mode-argv-opts - 127 + 145 - 111 + 116 logging test-mode-env - 122 + 155 - 112 + 117 logging quiet-mode-basic - 123 + 140 - 113 + 118 logging quiet-mode-option - 122 + 141 - 114 + 119 logging quiet-mode-argv - 127 + 141 - 115 + 120 logging quiet-mode-argv-opts - 123 + 152 - 116 + 121 logging quiet-mode-env - 123 + 146 - 117 + 122 logging test-quiet-mode-basic - 124 + 145 - 118 + 123 logging quiet-test-mode-basic - 125 + 150 - 119 + 124 logging test-ready-quiet-mode-basic - 255 + 264 - 120 + 125 logging quiet-ready-test-mode-basic - 237 + 257 - 121 + 126 logging quiet-argv-override - 127 + 149 - 122 + 127 logging test-argv-override - 126 + 152 - 123 + 128 logging quiet-env-override - 125 + 148 - 124 + 129 logging test-env-override - 123 + 133 - 125 + 130 logging intern.build_act_entry - 1 + 2 - 126 + 131 message happy-vanilla - 26 + 78 - 127 + 132 message happy-msg - 26 + 50 - 128 + 133 message loop - 29 + 31 - 129 + 134 message branch - 38 + 56 - 130 + 135 message empty-response - 123 + 131 - 131 + 136 message reply - 124 + 156 - 132 + 137 message prior - 124 + 144 - 133 + 138 message entity - 32 + 122 - 134 + 139 message single-simple-transport - 143 + 170 - 135 + 140 message simple-transport - 591 + 677 - 136 + 141 message partial-patterns - 127 + 155 - 137 + 142 meta custom-parents - 26 + 91 - 138 + 143 meta custom-priors - 46 + 77 - 139 + 144 meta custom-fixed - 28 + 37 - 140 + 145 options strict.find - 11 + 15 - 141 + 146 options internal.routers - 14 + 17 - 142 + 147 order happy - 256 + 276 - 143 + 148 outward make_error - 2 + 3 - 144 + 149 outward act_stats - 0 + 2 - 145 + 150 outward arg-check - 1 + 3 - 146 + 151 plugin use.intern - 10 + 38 - 147 + 152 plugin plugin-edges - 8 + 31 - 148 + 153 plugin plugin-internal-ordu - 8 + 43 - 149 + 154 plugin standard-test-plugin - 151 + 215 - 150 + 155 plugin standard-test-plugin-full-ignore - 238 + 263 - 151 + 156 plugin plugin-ignore-via-options - 121 + 142 - 152 + 157 plugin plugin-ignore-null - 125 + 144 - 153 + 158 plugin plugin-delegate-init - 127 + 146 - 154 + 159 plugin load-defaults - 125 + 158 - 155 + 160 plugin load-relative-to-root - 131 + 161 - 156 + 161 plugin good-default-options - 126 + 153 - 157 + 162 plugin bad-default-options - 26 + 72 - 158 + 163 plugin legacy-options - 13 + 32 - 159 + 164 plugin should return "no errors created." when passing test false - 396 + 504 - 160 + 165 plugin should return "error caught!" when passing test true - 380 + 422 - 161 + 166 plugin works with exportmap - 127 + 172 - 162 + 167 plugin bad - 133 + 140 - 163 + 168 plugin plugin-error-def - 20 + 74 - 164 + 169 plugin plugin-error-deprecated - 21 + 72 - 165 + 170 plugin plugin-error-add - 12 + 59 - 166 + 171 plugin plugin-error-act - 28 + 68 - 167 + 172 plugin depends - 140 + 158 - 168 + 173 plugin plugin-fix - 151 + 241 - 169 + 174 plugin export - 14 + 33 - 170 + 175 plugin handles plugin with action that timesout - 243 + 273 - 171 + 176 plugin handles plugin action that throws an error - 138 + 160 - 172 + 177 plugin calling act from init actor is deprecated - 20 + 36 - 173 + 178 plugin plugin actions receive errors in callback function - 135 + 150 - 174 + 179 plugin dynamic-load-sequence - 354 + 383 - 175 + 180 plugin serial-load-sequence - 128 + 150 - 176 + 181 plugin plugin options can be modified by plugins during load sequence - 128 + 146 - 177 + 182 plugin plugin options can be modified by plugins during init sequence - 125 + 150 - 178 + 183 plugin plugin init can add actions for future init actions to call - 129 + 159 - 179 + 184 plugin plugin-init-error - 18 + 62 - 180 + 185 plugin plugin-extend-action-modifier - 135 + 159 - 181 + 186 plugin plugin-extend-logger - 120 + 124 - 182 + 187 plugin plugins-from-options - 128 + 153 - 183 + 188 plugin plugins-from-bad-options - 19 + 41 - 184 + 189 plugin plugins-options-precedence - 129 + 158 - 185 + 190 plugin error-plugin-define - 19 + 46 - 186 + 191 plugin error-plugin-init - 45 + 62 - 187 + 192 plugin error-plugin-action - 18 + 23 - 188 + 193 plugin no-name - 139 + 150 - 189 + 194 plugin seneca-prefix-wins - 126 + 157 - 190 + 195 plugin plugin-defaults-top-level-joi - 128 + 170 - 191 + 196 plugin plugin-order-task-args - 12 + 39 - 192 + 197 plugin plugin-defaults-function - 125 + 156 - 193 + 198 print init - 11 + 18 - 194 + 199 print options - 12 + 16 - 195 + 200 print print - 6 + 13 - 196 + 201 print custom-print - 20 + 35 - 197 + 202 prior happy - 28 + 56 - 198 + 203 prior top-level - 9 + 17 - 199 + 204 prior add-general-to-specific - 32 + 39 - 200 + 205 prior add-strict-general-to-specific - 24 + 22 - 201 + 206 prior add-specific-to-general - 21 + 22 - 202 + 207 prior add-strict-specific-to-general 18 - 203 + 208 prior add-general-to-specific-alpha 19 - 204 + 209 prior add-general-to-specific-reverse-alpha - 24 + 27 - 205 + 210 prior add-strict-default - 21 + 24 - 206 + 211 prior add-strict-true - 28 + 26 - 207 + 212 private exit_close - 369 + 424 - 208 + 213 ready ready_die - 120 + 150 - 209 + 214 ready ready_die_no_errhandler - 126 + 139 - 210 + 215 ready ready_null_name - 120 + 140 - 211 + 216 ready ready-complex - 271 + 310 - 212 + 217 ready ready-always-called - 234 + 255 - 213 + 218 ready ready-error-test - 128 + 150 - 214 + 219 ready ready-event - 17 + 51 - 215 + 220 ready ready-both - 118 + 143 - 216 + 221 seneca --seneca.log arguments tests: --seneca.log=level:warn - 10 + 26 - 217 + 222 seneca --seneca.log arguments tests: --seneca.log=level:warn+ - 11 + 26 - 218 + 223 seneca --seneca.log arguments tests: --seneca.log.level.warn - 22 + 70 - 219 + 224 seneca --seneca.log arguments tests: --seneca.log.level.warn+ - 28 + 69 - 220 + 225 seneca --seneca.log arguments tests: duplicate param --seneca.log - 18 + 62 - 221 + 226 seneca --seneca.log arguments tests: incorrect arg --seneca.log=level: - 26 + 58 - 222 + 227 seneca --seneca.log arguments tests: incorrect arg --seneca.log.level.abc - 18 + 60 - 223 + 228 seneca --seneca.log arguments tests: incorrect arg --seneca.log.abc - 18 + 23 - 224 + 229 seneca --seneca.log aliases tests: --seneca.log.quiet - 17 + 19 - 225 + 230 seneca --seneca.log aliases tests: --seneca.log.silent - 31 + 20 - 226 + 231 seneca --seneca.log aliases tests: --seneca.log.all - 27 + 19 - 227 + 232 seneca --seneca.log aliases tests: --seneca.log.any - 23 + 22 - 228 + 233 seneca --seneca.log aliases tests: --seneca.log.print - 21 + 18 - 229 + 234 seneca --seneca.log aliases tests: --seneca.log.test - 17 + 15 - 230 + 235 seneca --seneca.log aliases tests: --seneca.log.standard - 27 + 14 - 231 + 236 seneca --seneca.log aliases tests: --seneca.log.level.quiet - 17 + 16 - 232 + 237 seneca --seneca.log aliases tests: --seneca.log.level.silent - 28 + 17 - 233 + 238 seneca --seneca.log aliases tests: --seneca.log.level.all - 20 + 15 - 234 + 239 seneca --seneca.log aliases tests: --seneca.log.level.any - 15 + 13 - 235 + 240 seneca --seneca.log aliases tests: --seneca.log.level.print - 28 + 17 - 236 + 241 seneca --seneca.log aliases tests: --seneca.log.level.test - 21 + 14 - 237 + 242 seneca --seneca.log aliases tests: --seneca.log.level.standard - 17 + 15 - 238 + 243 seneca happy - 36 + 40 - 239 + 244 seneca require-abbrev - 254 + 247 - 240 + 245 seneca version - 11 + 25 - 241 + 246 seneca tag - 8 + 29 - 242 + 247 seneca json-inspect - 15 + 53 - 243 + 248 seneca quick - 36 + 48 - 244 + 249 seneca happy-error - 19 + 15 - 245 + 250 seneca errhandler - 112 + 113 - 246 + 251 seneca action-basic - 15 + 51 - 247 + 252 seneca action-callback-instance - 15 + 68 - 248 + 253 seneca action-act-invalid-args - 18 + 32 - 249 + 254 seneca action-default - 29 + 34 - 250 + 255 seneca action-override - 148 + 147 - 251 + 256 seneca action-callback-args - 22 + 60 - 252 + 257 seneca action-extend - 127 + 172 - 253 + 258 seneca prior-nocache - 351 + 375 - 254 + 259 seneca gating - 124 + 144 - 255 + 260 seneca act_if - 29 + 128 - 256 + 261 seneca loading-plugins - 153 + 168 - 257 + 262 seneca fire-and-forget - 13 + 23 - 258 + 263 seneca strargs - 39 + 92 - 259 + 264 seneca string-add - 25 + 24 - 260 + 265 seneca fix-basic - 9 + 13 - 261 + 266 seneca act-history - 58 + 43 - 262 + 267 seneca wrap - 49 + 48 - 263 + 268 seneca meta - 33 + 19 - 264 + 269 seneca strict-result - 15 + 10 - 265 + 270 seneca add-noop - 16 + 14 - 266 + 271 seneca supports jsonic params to has - 10 + 11 - 267 + 272 seneca supports a function to trace actions - 30 + 23 - 268 + 273 seneca supports true to be passed as trace action option - 30 + 15 - 269 + 274 seneca strict-find-false - 19 + 17 - 270 + 275 seneca strict-find-true - 20 + 16 - 271 + 276 seneca strict-find-default 18 - 272 + 277 seneca catchall-pattern - 121 + 124 - 273 + 278 seneca memory - 385 + 439 - 274 + 279 seneca use-shortcut - 53 + 21 - 275 + 280 seneca status-log - 40 + 17 - 276 + 281 seneca reply-seneca - 152 + 121 - 277 + 282 seneca pattern-types - 125 + 152 - 278 + 283 seneca order - 11 + 28 - 279 + 284 seneca #decorate can add a property to seneca - 6 + 32 - 280 + 285 seneca #decorate cannot override core property - 14 + 46 - 281 + 286 seneca #decorate cannot overwrite a decorated property - 15 + 25 - 282 + 287 seneca #decorate cannot prefix a property with an underscore - 22 + 16 - 283 + 288 seneca #intercept intercept - 41 + 31 - 284 + 289 sequence single-add-act - 19 + 18 - 285 + 290 sequence double-add-act - 24 + 20 - 286 + 291 sequence single-add-act-ready - 127 + 125 - 287 + 292 sequence single-add-act-gate-action - 17 + 55 - 288 + 293 sequence single-add-act-gate-instance - 22 + 49 - 289 + 294 smoke seneca-smoke - 25 + 28 - 290 + 295 options options-happy - 123 + 136 - 291 + 296 options options-getset - 124 + 142 - 292 + 297 options options-legacy - 123 + 146 - 293 + 298 options options-file-js - 127 + 145 - 294 + 299 options legacy-options-file-js - 121 + 142 - 295 + 300 options options-file-json - 124 + 152 - 296 + 301 options options-file-json-nomore - 125 + 147 - 297 + 302 options options-env - 121 + 144 - 298 + 303 options options-cmdline - 127 + 136 - 299 + 304 sub happy-sub - 25 + 72 - 300 + 305 sub inwards-outwards-sub - 34 + 68 - 301 + 306 sub specific-sub - 30 + 31 - 302 + 307 sub error-sub - 37 + 24 - 303 + 308 sub mixed-sub - 29 + 32 - 304 + 309 sub sub-prior - 125 + 124 - 305 + 310 sub sub-close - 127 + 125 - 306 + 311 sub sub-fix - 17 + 31 - 307 + 312 timeout happy - 124 + 132 - 308 + 313 timeout error-handler - 234 + 256 - 309 + 314 timeout should accept a timeout value from options - 239 + 259 - 310 + 315 transport happy-nextgen - 393 + 447 - 311 + 316 transport config-legacy-nextgen - 480 + 536 - 312 + 317 transport error-nextgen - 366 + 414 - 313 + 318 transport interop-nextgen - 270 + 440 - 314 + 319 transport config-nextgen - 501 + 654 - 315 + 320 transport nextgen-transport-local-override - 371 + 437 - 316 + 321 transport nextgen-meta - 379 + 456 - 317 + 322 transport nextgen-ordering - 484 + 565 - 318 + 323 transport transport-exact-single - 167 + 271 - 319 + 324 transport transport-local-override - 161 + 256 - 320 + 325 transport transport-star - 281 + 316 - 321 + 326 transport transport-star-pin-object - 277 + 321 - 322 + 327 transport transport-single-notdef - 162 + 238 - 323 + 328 transport transport-pins-notdef - 185 + 260 - 324 + 329 transport transport-single-wrap-and-star - 300 + 407 - 325 + 330 transport transport-local-single-and-star - 282 + 327 - 326 + 331 transport transport-local-over-wrap - 246 + 292 - 327 + 332 transport transport-local-prior-wrap - 172 + 252 - 328 + 333 transport transport-init-ordering - 246 + 282 - 329 + 334 transport transport-no-plugin-init - 288 + 310 - 330 + 335 transport transport-balance-exact - 905 + 1065 - 331 + 336 transport multi-layer-error - 720 + 792 - 332 + 337 transport server can be restarted without issues to clients - 625 + 749 - 333 + 338 transport transport-listen supports-null-options - 124 + 155 - 334 + 339 transport transport-listen supports type as tcp option - 128 + 154 - 335 + 340 transport transport-listen supports type as http option - 125 + 151 - 336 + 341 transport transport-listen supports the port number as an argument - 127 + 156 - 337 + 342 transport transport-listen supports the port number and host as an argument - 125 + 156 - 338 + 343 transport transport-listen supports the port number, host, and path as an argument - 128 + 149 - 339 + 344 transport transport-listen action-error - 124 + 144 - 340 + 345 transport client() supports null options - 124 + 150 - 341 + 346 util seneca.util.deepextend.happy - 2 + 3 - 342 + 347 util seneca.util.deepextend.types with new - 2 + 6 - 343 + 348 util seneca.util.deepextend.types - 1 + 4 - 344 + 349 util seneca.util.deepextend.mixed - 2 + 4 - 345 + 350 util seneca.util.deepextend.entity 1 - 346 + 351 xward happy-inward - 14 + 56 - 347 + 352 xward happy-outward - 23 + 56 @@ -3144,10 +3193,10 @@

    Test Report

    Code Coverage Report

    -
    91.22%
    -
    4817
    -
    4394
    -
    423
    +
    91.28%
    +
    4837
    +
    4415
    +
    422
    @@ -7724,7 +7773,7 @@

    seneca.js

    759 - 10362 + 10366 return void 0 @@ -8286,7 +8335,7 @@

    lib/act.js

    86 - 5 + 10 var timeout_err = Common.error('action_timeout', { @@ -8352,7 +8401,7 @@

    lib/act.js

    97 - 5 + 10 intern.handle_reply(meta, actctxt, actmsg, timeout_err) @@ -9090,13 +9139,13 @@

    lib/act.js

    220 - 2820 + 2825 var delegate = actctxt.seneca 221 - 2820 + 2825 var reply = actctxt.reply @@ -9108,7 +9157,7 @@

    lib/act.js

    223 - 2820 + 2825 var data = { @@ -9168,25 +9217,25 @@

    lib/act.js

    233 - 2820 + 2825 actctxt.duration = meta.end - meta.start 234 - 2820 + 2825 actctxt.actlog = intern.actlog 235 - 2820 + 2825 actctxt.errlog = intern.errlog 236 - 2820 + 2825 actctxt.error = Common.error @@ -9198,7 +9247,7 @@

    lib/act.js

    238 - 2820 + 2825 meta.error = Util.isError(data.res) @@ -9216,7 +9265,7 @@

    lib/act.js

    241 - 2820 + 2825 if (!meta.error && data.res === data.err) { @@ -9246,7 +9295,7 @@

    lib/act.js

    246 - 2820 + 2825 if ( @@ -9312,7 +9361,7 @@

    lib/act.js

    257 - 2820 + 2825 intern.process_outward(actctxt, data, delegate) @@ -9324,19 +9373,19 @@

    lib/act.js

    259 - 2820 + 2825 if (data.has_callback) { 260 - 2815 + 2820 try { 261 - 2815 + 2820 reply.call(delegate, data.err, data.res, data.meta) @@ -9414,7 +9463,7 @@

    lib/act.js

    274 - 2825 + 2830 if (outward) { @@ -12365,9 +12414,9 @@

    lib/add.js

    lib/api.js

    -
    92.15%
    -
    650
    -
    599
    +
    92.34%
    +
    666
    +
    615
    51
    @@ -12726,7 +12775,7 @@

    lib/api.js

    - + @@ -12738,13 +12787,13 @@

    lib/api.js

    - + - + @@ -13260,7 +13309,7 @@

    lib/api.js

    - + @@ -13284,7 +13333,7 @@

    lib/api.js

    - + @@ -13302,7 +13351,7 @@

    lib/api.js

    - + @@ -13332,13 +13381,13 @@

    lib/api.js

    - + - + @@ -13356,7 +13405,7 @@

    lib/api.js

    - + @@ -13374,7 +13423,7 @@

    lib/api.js

    - + @@ -13405,43 +13454,43 @@

    lib/api.js

    - + - + - - + + - + - + - + - + - - + + - - + + @@ -13453,139 +13502,139 @@

    lib/api.js

    - + - - + + - - + + - + - + - - + + - - + + - - + + - + - - + + - - + + - + - - + + - + - - + + - - + + - + - + - + - + - - + + - - + + - + - + - - + + @@ -13596,164 +13645,164 @@

    lib/api.js

    - - + + - + - + - - + + - - + + - + - - + + - - + + - - + + - - + + - + - - + + - + - + - - + + - - + + - + - + - - + + - + - - + + - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + @@ -13764,158 +13813,158 @@

    lib/api.js

    - - + + - - + + - - + + - + - + - + - + - + - - + + - - + + - + - - + + - - + + - + - - + + - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - + - - + + - - + + - - + + - + @@ -13926,38 +13975,38 @@

    lib/api.js

    - - + + - - + + - + - + - + - - + + - + - - + + @@ -13965,551 +14014,551 @@

    lib/api.js

    - + - - + + - + - + - + - - + + - - + + - - + + - - + + - - + + - - + + - + - + - - + + - - + + - + - + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - + - + - - + + - - + + - - + + - - + + - - + + - + - - + + - - + + - - + + - - + + - - + + - - + + - + - + - + - + - - + + - + - + - + - - + + - + - - + + - - + + - + - - + + - - + + - - + + - + - - + + - - + + - - + + - - + + - + - + - - + + - + - + - + - + - + - - + + - + - + - + - - + + - + - + - - + + - + - + - - + + - + - - + + - - + + - - + + - - + + - - + + - + - + - + - + - + - - + + - + - + - - + + - + - + - + - - + + - - + + - - + + @@ -14520,170 +14569,170 @@

    lib/api.js

    - - + + - + - + - - + + - - + + - + - - + + - - + + - - + + - + - + - + - + - - + + - - + + - - + + - - + + - + - + - - + + - + - + - - + + - - + + - - + + - + - + - + - - + + - + @@ -14695,79 +14744,79 @@

    lib/api.js

    - + - - + + - + - - + + - - + + - + - - + + - - + + - - + + - - + + - - + + - - + + - + - + @@ -14778,404 +14827,404 @@

    lib/api.js

    - - + + - + - + - + - - + + - + - - + + - + - - + + - + - + - - + + - - + + - + - - + + - + - + - + - - + + - - + + - + - - + + - - + + - - + + - + - - + + - - + + - + - - + + - - + + - - + + - + - - + + - + - - + + - + - + - + - + - - + + - + - - + + - - + + - + - + - + - - + + - - + + - - + + - - + + - + - - + + - - + + - - + + - + - - + + - + - - + + - - + + - - + + - + - + - - + + - - + + - - + + - + - - + + - - + + - + @@ -15186,86 +15235,86 @@

    lib/api.js

    - - + + - - + + - - + + - + - - + + - + - - + + - + - - + + - + - - + + - - + + - - + + - + @@ -15276,266 +15325,266 @@

    lib/api.js

    - - + + - + - - + + - - + + - + - - + + - + - - + + - - + + - - + + - - + + - - + + - + - - + + - - + + - + - + - - + + - + - - + + - + - - + + - - + + - + - - + + - - + + - + - - + + - - + + - - + + - - + + - + - - + + - - + + - - + + - - + + - - + + - + - - + + - + - + - + - - + + - - + + @@ -15553,79 +15602,79 @@

    lib/api.js

    - + - + - + - + - - + + - - + + - - + + - + - - + + - + - - + + - - + + - + @@ -15636,128 +15685,128 @@

    lib/api.js

    - - + + - - + + - + - + - - + + - - + + - + - - + + - + - - + + - + - + - + - - + + - + - + - + - + - - + + - + - - + + @@ -15768,38 +15817,38 @@

    lib/api.js

    - - + + - - + + - - + + - - + + - - + + - - + + @@ -15810,50 +15859,50 @@

    lib/api.js

    - - + + - + - + - + - - + + - + - - + + - - + + @@ -15864,333 +15913,333 @@

    lib/api.js

    - - + + - - + + - + - + - - + + - + - - + + - - + + - - + + - - + + - + - + - + - - + + - + - + - - + + - + - - + + - + - + - - + + - + - + - + - - + + - - + + - - + + - - + + - - + + - + - + - - + + - - + + - + - + - + - + - - + + - + - + - - + + - - + + - - + + - + - - + + - + - + - + - + - + - + - + - - + + - + - - + + - + - + - + - - + + - - + + - + - - - + + + @@ -16200,314 +16249,314 @@

    lib/api.js

    - - + + - - + + - - + + - + - + - - + + - + - + - - + + - - + + - + - + - + - + - + - + - + - + - + - - + + - - + + - + - + - - + + - + - - + + - + - - + + - + - - + + - + - + - + - - + + - - + + - - + + - + - - + + - + - + - + - + - + - + - - + + - + - - + + - - + + - + - + - + - + - + - + - + - + - - + + - + - + - + - + - - + + @@ -16519,7 +16568,7 @@

    lib/api.js

    - + @@ -16531,115 +16580,115 @@

    lib/api.js

    - + - + - - + + - + - + - + - - + + - + - + - - + + - - + + - + - + - + - + - + - + - + - - + + - + - + - + - - + + - - + + @@ -16650,128 +16699,128 @@

    lib/api.js

    - - + + - + - - + + - - + + - - + + - + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - - + + - - + + @@ -16782,152 +16831,152 @@

    lib/api.js

    - - + + - + - + - + - - + + - + - - + + - + - + - + - + - - + + - - + + - - + + - + - + - + - + - + - - + + - + - + - - + + - + - - + + - + - - + + - - + + - + @@ -16938,140 +16987,140 @@

    lib/api.js

    - - + + - + - - + + - + - + - - + + - - + + - + - - + + - - + + - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - + - - + + - - + + @@ -17082,104 +17131,104 @@

    lib/api.js

    - - + + - + - + - - + + - - + + - + - - + + - + - - + + - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + @@ -17197,550 +17246,682 @@

    lib/api.js

    - + - + - - + + - - + + - - + + - + - + - - + + - - + + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + @@ -17751,10 +17932,10 @@

    lib/api.js

    lib/common.js

    -
    87.52%
    +
    87.69%
    585
    -
    512
    -
    73
    +
    513
    +
    72
    58 2210822122 var private$ = self.private$
    60 2210822122 if (null == options) {
    61 2083620850 return private$.optioner.get()
    147 1617 if (null == first) {
    151 1415 var plugin_fullname =
    154 1415 var plugin =
    159 1415 var error = null
    160 1415 if (plugin && plugin.eraro && plugin.eraro.has(first)) {
    163 1112 error = Common.eraro.apply(this, arguments)
    166 1415 return error
    171 1exports.fail = function (code, args) {exports.fail = function (...args) {
    172 var error = this.error(code, args) if (args.length === 2) {
    173 5 return failIf(this, true, ...args)
    174
    if (
    args
    &&
    false === args.throw$
    ) {
    }
    175 return error
    176 } else {5 if (args.length === 3) {
    177 5 throw error3 return failIf(this, ...args)
    178 179 }
    180 2 throw this.util.error('fail_wrong_number_of_args',
    181 1exports.inward = function () { { num_args: args.length })
    182 // TODO: norma should support f/x where x = # args
    183 var args = Norma('inward:f', arguments)
    184 1 this.private$.inward.add(args.inward) function failIf(self, cond, code, args) {
    185 1 return this8 if (typeof cond !== 'boolean') {
    186 }1 throw self.util.error('fail_cond_must_be_bool')
    187 }
    188 1exports.outward = function () {
    189 var args = Norma('outward:f', arguments)7 if (!cond) {
    190 1 this.private$.outward.add(args.outward) return
    191 1 return this }
    192 }
    193 6 const error = self.error(code, args)
    194 1exports.prior = function () {
    195 if (null == this.private$.act) {
    if (
    args
    &&
    false === args.throw$
    ) {
    196 // TODO: should be a top level api method: seneca.fail return error
    197 1 throw this.util.error('no_prior_action', { args: arguments }) } else {
    198 }6 throw error
    199 }
    200 // Get definition of prior action }
    201 128 var priordef = this.private$.act.def.priordef}
    202
    203 128 var spec = Common.build_message(this, arguments, 'reply:f?', this.fixedargs)1exports.inward = function () {
    204 // TODO: norma should support f/x where x = # args
    205 // TODO: clean sufficiently so that seneca.util.clean not needed var args = Norma('inward:f', arguments)
    206 128 var msg = spec.msg1 this.private$.inward.add(args.inward)
    207 128 var reply = spec.reply1 return this
    208 }
    209 128 if (priordef) {
    210 103 msg.prior$ = priordef.id1exports.outward = function () {
    211 103 this.act(msg, reply) var args = Norma('outward:f', arguments)
    212 } else {1 this.private$.outward.add(args.outward)
    213
    var meta =
    msg.meta$
    || {}
    1 return this
    214
    var out = msg.default$ ||
    meta.dflt
    || null
    }
    215 25 out = null == out ? out : Object.assign({}, out)
    216 25 return reply.call(this, null, out, meta)1exports.prior = function () {
    217 } if (null == this.private$.act) {
    218 } // TODO: should be a top level api method: seneca.fail
    219 1 throw this.util.error('no_prior_action', { args: arguments })
    220 // TODO: rename fixedargs }
    221 1exports.delegate = function (fixedargs, fixedmeta) {
    222 var self = this // Get definition of prior action
    223 3611 var root = this.root128 var priordef = this.private$.act.def.priordef
    224 3611 var opts = this.options()
    225 128 var spec = Common.build_message(this, arguments, 'reply:f?', this.fixedargs)
    226 3611 fixedargs = fixedargs || {}
    227 3611 fixedmeta = fixedmeta || {} // TODO: clean sufficiently so that seneca.util.clean not needed
    228 128 var msg = spec.msg
    229 3611 var delegate = Object.create(self)128 var reply = spec.reply
    230
    231 3611 delegate.private$ = Object.create(self.private$)128 if (priordef) {
    232 103 msg.prior$ = priordef.id
    233 3611 delegate.did =103 this.act(msg, reply)
    234 (delegate.did ? delegate.did + '/' : '') + self.private$.didnid() } else {
    235
    var meta =
    msg.meta$
    || {}
    236 function delegate_log() {
    var out = msg.default$ ||
    meta.dflt
    || null
    237 11951 return root.log.apply(delegate, arguments)25 out = null == out ? out : Object.assign({}, out)
    238 }25 return reply.call(this, null, out, meta)
    239 }
    240 3611 Object.assign(delegate_log, root.log)}
    241 3611 delegate_log.self = () => delegate
    242 // TODO: rename fixedargs
    243 3611 var strdesc1exports.delegate = function (fixedargs, fixedmeta) {
    244 var self = this
    245 function delegate_toString() {3611 var root = this.root
    246 94 if (strdesc) return strdesc3611 var opts = this.options()
    247 78 var vfa = {}
    248 78 Object.keys(fixedargs).forEach((k) => {3611 fixedargs = fixedargs || {}
    249 var v = fixedargs[k]3611 fixedmeta = fixedmeta || {}
    250 193 if (~k.indexOf('$')) return
    251 1 vfa[k] = v3611 var delegate = Object.create(self)
    252 })
    253 3611 delegate.private$ = Object.create(self.private$)
    254 78 strdesc =
    255 self.toString() +3611 delegate.did =
    256 (Object.keys(vfa).length ? '/' + Jsonic.stringify(vfa) : '') (delegate.did ? delegate.did + '/' : '') + self.private$.didnid()
    257
    258 78 return strdesc function delegate_log() {
    259 }11964 return root.log.apply(delegate, arguments)
    260 }
    261
    var delegate_fixedargs =
    opts.strict.fixedargs
    262 ? Object.assign({}, fixedargs, self.fixedargs)3611 Object.assign(delegate_log, root.log)
    263
    :
    Object.assign({}, self.fixedargs, fixedargs)
    3611 delegate_log.self = () => delegate
    264
    265
    var delegate_fixedmeta =
    opts.strict.fixedmeta
    3611 var strdesc
    266
    ?
    Object.assign({}, fixedmeta, self.fixedmeta)
    267 : Object.assign({}, self.fixedmeta, fixedmeta) function delegate_toString() {
    268 98 if (strdesc) return strdesc
    269 function delegate_delegate(further_fixedargs, further_fixedmeta) {82 var vfa = {}
    270 2131 var args = Object.assign({}, delegate.fixedargs, further_fixedargs || {})82 Object.keys(fixedargs).forEach((k) => {
    271 2131 var meta = Object.assign({}, delegate.fixedmeta, further_fixedmeta || {}) var v = fixedargs[k]
    272 2131 return self.delegate.call(this, args, meta)209 if (~k.indexOf('$')) return
    273 }1 vfa[k] = v
    274 })
    275 // Somewhere to put contextual data for this delegate.
    276 // For example, data for individual web requests.82 strdesc =
    277 3611 var delegate_context = Object.assign({}, self.context) self.toString() +
    278 (Object.keys(vfa).length ? '/' + Jsonic.stringify(vfa) : '')
    279 // Prevents incorrect prototype properties in mocha test contexts
    280 3611 Object.defineProperties(delegate, {82 return strdesc
    281 log: { value: delegate_log, writable: true }, }
    282 toString: { value: delegate_toString, writable: true },
    283 fixedargs: { value: delegate_fixedargs, writable: true },
    var delegate_fixedargs =
    opts.strict.fixedargs
    284 fixedmeta: { value: delegate_fixedmeta, writable: true }, ? Object.assign({}, fixedargs, self.fixedargs)
    285 delegate: { value: delegate_delegate, writable: true },
    :
    Object.assign({}, self.fixedargs, fixedargs)
    286 context: { value: delegate_context, writable: true },
    287 })
    var delegate_fixedmeta =
    opts.strict.fixedmeta
    288
    ?
    Object.assign({}, fixedmeta, self.fixedmeta)
    289 3611 return delegate : Object.assign({}, self.fixedmeta, fixedmeta)
    290 }
    291 function delegate_delegate(further_fixedargs, further_fixedmeta) {
    292 1exports.depends = function () {2131 var args = Object.assign({}, delegate.fixedargs, further_fixedargs || {})
    293 var self = this2131 var meta = Object.assign({}, delegate.fixedmeta, further_fixedmeta || {})
    294 7 var private$ = this.private$2131 return self.delegate.call(this, args, meta)
    295 7 var error = this.util.error }
    296 7 var args = Norma('{pluginname:s deps:a? moredeps:s*}', arguments)
    297 // Somewhere to put contextual data for this delegate.
    298 7 var deps = args.deps || args.moredeps || [] // For example, data for individual web requests.
    299 3611 var delegate_context = Object.assign({}, self.context)
    300 7 for (var i = 0; i < deps.length; i++) {
    301 9 var depname = deps[i] // Prevents incorrect prototype properties in mocha test contexts
    302 3611 Object.defineProperties(delegate, {
    303 9 if ( log: { value: delegate_log, writable: true },
    304 !private$.plugin_order.byname.includes(depname) && toString: { value: delegate_toString, writable: true },
    305
    !private$.plugin_order.byname.includes('seneca-' + depname)
    fixedargs: { value: delegate_fixedargs, writable: true },
    306 ) { fixedmeta: { value: delegate_fixedmeta, writable: true },
    307 2 self.die( delegate: { value: delegate_delegate, writable: true },
    308 error('plugin_required', { context: { value: delegate_context, writable: true },
    309 name: args.pluginname, })
    310 dependency: depname,
    311 })3611 return delegate
    312 )}
    313 2 break
    314 }1exports.depends = function () {
    315 } var self = this
    316 }7 var private$ = this.private$
    317 7 var error = this.util.error
    318 1exports.export = function (key) {7 var args = Norma('{pluginname:s deps:a? moredeps:s*}', arguments)
    319 var self = this
    320 76 var private$ = this.private$7 var deps = args.deps || args.moredeps || []
    321 76 var error = this.util.error
    322 76 var opts = this.options()7 for (var i = 0; i < deps.length; i++) {
    323 9 var depname = deps[i]
    324 // Legacy aliases
    325
    if (
    key === 'util'
    ) {
    9 if (
    326 key = 'basic' !private$.plugin_order.byname.includes(depname) &&
    327 }
    !private$.plugin_order.byname.includes('seneca-' + depname)
    328 ) {
    329 76 var exportval = private$.exports[key]2 self.die(
    330 error('plugin_required', {
    331
    if (!exportval &&
    opts.strict.exports
    ) {
    name: args.pluginname,
    332 1 return self.die(error('export_not_found', { key: key })) dependency: depname,
    333 } })
    334 )
    335 75 return exportval2 break
    336 } }
    337 }
    338 1exports.quiet = function (flags) {}
    339 flags = flags || {}
    340 1exports.export = function (key) {
    341 39 var quiet_opts = { var self = this
    342 test: false,76 var private$ = this.private$
    343 quiet: true,76 var error = this.util.error
    344 log: 'none',76 var opts = this.options()
    345 reload$: true,
    346 } // Legacy aliases
    347
    if (
    key === 'util'
    ) {
    348 39 var opts = this.options(quiet_opts) key = 'basic'
    349 }
    350 // An override from env or args is possible.
    351 // Only flip to test mode if called from test() method76 var exportval = private$.exports[key]
    352
    if (opts.test &&
    'test' !== flags.from
    ) {
    353 2 return this.test()
    if (!exportval &&
    opts.strict.exports
    ) {
    354 } else {1 return self.die(error('export_not_found', { key: key }))
    355 37 this.private$.logging.build_log(this) }
    356
    357 37 return this75 return exportval
    358 }}
    359 }
    360 1exports.quiet = function (flags) {
    361 1exports.test = function (errhandler, logspec) { flags = flags || {}
    362 var opts = this.options()
    363 39 var quiet_opts = {
    364 204 if ('-' != opts.tag) { test: false,
    365 21 this.root.id = quiet: true,
    366 null == opts.id$ log: 'none',
    367 ? this.private$.actnid().substring(0, 4) + '/' + opts.tag reload$: true,
    368 : '' + opts.id$ }
    369 }
    370 39 var opts = this.options(quiet_opts)
    371 204 if ('function' !== typeof errhandler && null !== errhandler) {
    372 55 logspec = errhandler // An override from env or args is possible.
    373 55 errhandler = null // Only flip to test mode if called from test() method
    374 }
    if (opts.test &&
    'test' !== flags.from
    ) {
    375 2 return this.test()
    376
    logspec =
    true === logspec
    || 'true' === logspec ? 'test' : logspec
    } else {
    377 37 this.private$.logging.build_log(this)
    378 204 var test_opts = {
    379 errhandler: null == errhandler ? null : errhandler,37 return this
    380 test: true, }
    381 quiet: false,}
    382 reload$: true,
    383 log: logspec || 'test',1exports.test = function (errhandler, logspec) {
    384 } var opts = this.options()
    385 386 204 var set_opts = this.options(test_opts) if ('-' != opts.tag) {
    387 21 this.root.id =
    388 // An override from env or args is possible. null == opts.id$
    389 204 if (set_opts.quiet) { ? this.private$.actnid().substring(0, 4) + '/' + opts.tag
    390 2 return this.quiet({ from: 'test' }) : '' + opts.id$
    391 } else { }
    392 202 this.private$.logging.build_log(this)
    393 204 if ('function' !== typeof errhandler && null !== errhandler) {
    394 // Manually set logger to test_logger (avoids infecting options structure),55 logspec = errhandler
    395 // unless there was an external logger defined by the options55 errhandler = null
    396 202 if (!this.private$.logger.from_options$) { }
    397 189 this.root.private$.logger = this.private$.logging.test_logger
    398 }
    logspec =
    true === logspec
    || 'true' === logspec ? 'test' : logspec
    399
    400 202 return this204 var test_opts = {
    401 } errhandler: null == errhandler ? null : errhandler,
    402 } test: true,
    403 quiet: false,
    404 1exports.ping = function () { reload$: true,
    405 var now = Date.now() log: logspec || 'test',
    406 2 return { }
    407 now: now,
    408 uptime: now - this.private$.stats.start,204 var set_opts = this.options(test_opts)
    409 id: this.id,
    410 cpu: process.cpuUsage(), // An override from env or args is possible.
    411 mem: process.memoryUsage(),204 if (set_opts.quiet) {
    412 act: this.private$.stats.act,2 return this.quiet({ from: 'test' })
    413 tr: this.private$.transport.register.map(function (x) { } else {
    414 return Object.assign({ when: x.when, err: x.err }, x.config)202 this.private$.logging.build_log(this)
    415 }),
    416 } // Manually set logger to test_logger (avoids infecting options structure),
    417 } // unless there was an external logger defined by the options
    418 202 if (!this.private$.logger.from_options$) {
    419 1exports.translate = function (from_in, to_in, pick_in) {189 this.root.private$.logger = this.private$.logging.test_logger
    420 var from = 'string' === typeof from_in ? Jsonic(from_in) : from_in }
    421 11 var to = 'string' === typeof to_in ? Jsonic(to_in) : to_in
    422 202 return this
    423 11 var pick = {} }
    424 }
    425 11 if ('string' === typeof pick_in) {
    426 4 pick_in = pick_in.split(/\s*,\s*/)1exports.ping = function () {
    427 } var now = Date.now()
    428 2 return {
    429 11 if (Array.isArray(pick_in)) { now: now,
    430 6 pick_in.forEach(function (prop) { uptime: now - this.private$.stats.start,
    431 if (prop.startsWith('-')) { id: this.id,
    432 2 pick[prop.substring(1)] = false cpu: process.cpuUsage(),
    433 } else { mem: process.memoryUsage(),
    434 7 pick[prop] = true act: this.private$.stats.act,
    435 } tr: this.private$.transport.register.map(function (x) {
    436 }) return Object.assign({ when: x.when, err: x.err }, x.config)
    437
    } else if (pick_in &&
    'object' === typeof pick_in
    ) {
    }),
    438 2 pick = Object.assign({}, pick_in) }
    439 } else {}
    440 3 pick = null
    441 }1exports.translate = function (from_in, to_in, pick_in) {
    442 var from = 'string' === typeof from_in ? Jsonic(from_in) : from_in
    443 11 this.add(from, function (msg, reply) { var to = 'string' === typeof to_in ? Jsonic(to_in) : to_in
    444 var pick_msg
    445 11 var pick = {}
    446 11 if (pick) {
    447 8 pick_msg = {}11 if ('string' === typeof pick_in) {
    448 8 Object.keys(pick).forEach(function (prop) {4 pick_in = pick_in.split(/\s*,\s*/)
    449 if (pick[prop]) { }
    450 9 pick_msg[prop] = msg[prop]
    451 }11 if (Array.isArray(pick_in)) {
    452 })6 pick_in.forEach(function (prop) {
    453 } else { if (prop.startsWith('-')) {
    454 3 pick_msg = this.util.clean(msg)2 pick[prop.substring(1)] = false
    455 } } else {
    456 7 pick[prop] = true
    457 11 var transmsg = Object.assign(pick_msg, to) }
    458 11 this.act(transmsg, reply) })
    459 })
    } else if (pick_in &&
    'object' === typeof pick_in
    ) {
    460 2 pick = Object.assign({}, pick_in)
    461 11 return this } else {
    462 }3 pick = null
    463 }
    464 1exports.gate = function () {
    465 return this.delegate({ gate$: true })11 this.add(from, function (msg, reply) {
    466 } var pick_msg
    467
    468 1exports.ungate = function () {11 if (pick) {
    469 this.fixedargs.gate$ = false8 pick_msg = {}
    470 1 return this8 Object.keys(pick).forEach(function (prop) {
    471 } if (pick[prop]) {
    472 9 pick_msg[prop] = msg[prop]
    473 // TODO this needs a better name }
    474 1exports.list_plugins = function () { })
    475 return Object.assign({}, this.private$.plugins) } else {
    476 }3 pick_msg = this.util.clean(msg)
    477 }
    478 1exports.find_plugin = function (plugindesc, tag) {
    479 var plugin_key = Common.make_plugin_key(plugindesc, tag)11 var transmsg = Object.assign(pick_msg, to)
    480 4 return this.private$.plugins[plugin_key]11 this.act(transmsg, reply)
    481 } })
    482
    483 1exports.has_plugin = function (plugindesc, tag) {11 return this
    484 var plugin_key = Common.make_plugin_key(plugindesc, tag)}
    485 13 return !!this.private$.plugins[plugin_key]
    486 }1exports.gate = function () {
    487 return this.delegate({ gate$: true })
    488 1exports.ignore_plugin = function (plugindesc, tag, ignore) {}
    489 if ('boolean' === typeof tag) {
    490 5 ignore = tag1exports.ungate = function () {
    491 5 tag = null this.fixedargs.gate$ = false
    492 }1 return this
    493 8 var plugin_key = Common.make_plugin_key(plugindesc, tag)}
    494 8 var resolved_ignore = (this.private$.ignore_plugins[plugin_key] =
    495 null == ignore ? true : !!ignore)// TODO this needs a better name
    496 1exports.list_plugins = function () {
    497 8 this.log.info({ return Object.assign({}, this.private$.plugins)
    498 kind: 'plugin',}
    499 case: 'ignore',
    500 full: plugin_key,1exports.find_plugin = function (plugindesc, tag) {
    501 ignore: resolved_ignore, var plugin_key = Common.make_plugin_key(plugindesc, tag)
    502 })4 return this.private$.plugins[plugin_key]
    503 }
    504 8 return this
    505 }1exports.has_plugin = function (plugindesc, tag) {
    506 var plugin_key = Common.make_plugin_key(plugindesc, tag)
    507 // Find the action metadata for a given pattern, if it exists.13 return !!this.private$.plugins[plugin_key]
    508 1exports.find = function (pattern, flags) {}
    509 var seneca = this
    510 1exports.ignore_plugin = function (plugindesc, tag, ignore) {
    511 10278 var pat = 'string' === typeof pattern ? Jsonic(pattern) : pattern if ('boolean' === typeof tag) {
    512 10278 pat = seneca.util.clean(pat)5 ignore = tag
    513 10278 pat = pat || {}5 tag = null
    514 }
    515 10278 var actdef = seneca.private$.actrouter.find(pat, flags && flags.exact)8 var plugin_key = Common.make_plugin_key(plugindesc, tag)
    516 8 var resolved_ignore = (this.private$.ignore_plugins[plugin_key] =
    517 10278 if (!actdef) { null == ignore ? true : !!ignore)
    518 7696 actdef = seneca.private$.actrouter.find({})
    519 }8 this.log.info({
    520 kind: 'plugin',
    521 10278 return actdef case: 'ignore',
    522 } full: plugin_key,
    523 ignore: resolved_ignore,
    524 // True if an action matching the pattern exists. })
    525 1exports.has = function (pattern) {
    526 return !!this.find(pattern, { exact: true })8 return this
    527 529 // List all actions that match the pattern.// Find the action metadata for a given pattern, if it exists.
    530 1exports.list = function (pattern) {exports.find = function (pattern, flags) {
    531 return this.private$.actrouter var seneca = this
    532 .list(null == pattern ? {} : Jsonic(pattern))
    533 .map((x) => x.match)10278 var pat = 'string' === typeof pattern ? Jsonic(pattern) : pattern
    534 10278 pat = seneca.util.clean(pat)
    535 /*10278 pat = pat || {}
    536 return _.map(
    537 this.private$.actrouter.list(null == pattern ? {} : Jsonic(pattern)),10278 var actdef = seneca.private$.actrouter.find(pat, flags && flags.exact)
    538 'match'
    539 )10278 if (!actdef) {
    540 */7696 actdef = seneca.private$.actrouter.find({})
    541 } }
    542
    543 // Get the current status of the instance.10278 return actdef
    544 1exports.status = function (flags) {}
    545 flags = flags || {}
    546 // True if an action matching the pattern exists.
    547 6 var hist = this.private$.history.stats()1exports.has = function (pattern) {
    548 6 hist.log = this.private$.history.list() return !!this.find(pattern, { exact: true })
    549 }
    550 6 var status = {
    551 stats: this.stats(flags.stats),// List all actions that match the pattern.
    552 history: hist,1exports.list = function (pattern) {
    553 transport: this.private$.transport, return this.private$.actrouter
    554 } .list(null == pattern ? {} : Jsonic(pattern))
    555 .map((x) => x.match)
    556 6 return status
    557 } /*
    558 return _.map(
    559 // Reply to an action that is waiting for a result. this.private$.actrouter.list(null == pattern ? {} : Jsonic(pattern)),
    560 // Used by transports to decouple sending messages from receiving responses. 'match'
    561 1exports.reply = function (spec) { )
    562 var instance = this */
    563 34 var actctxt = null}
    564
    565 34 if (spec && spec.meta) {// Get the current status of the instance.
    566 32 actctxt = instance.private$.history.get(spec.meta.id)1exports.status = function (flags) {
    567 32 if (actctxt) { flags = flags || {}
    568 31 actctxt.reply(spec.err, spec.out, spec.meta)
    569 }6 var hist = this.private$.history.stats()
    570 }6 hist.log = this.private$.history.list()
    571
    572 34 return !!actctxt6 var status = {
    573 } stats: this.stats(flags.stats),
    574 history: hist,
    575 // Listen for inbound messages. transport: this.private$.transport,
    576 1exports.listen = function (callpoint) { }
    577 return function api_listen(...argsarr) {
    578 var private$ = this.private$6 return status
    579 47 var self = this}
    580
    581 47 var done = argsarr[argsarr.length - 1]// Reply to an action that is waiting for a result.
    582 47 if (typeof done === 'function') {// Used by transports to decouple sending messages from receiving responses.
    583 1 argsarr.pop()exports.reply = function (spec) {
    584 } else { var instance = this
    585 46 done = () => {}34 var actctxt = null
    586 }
    587 34 if (spec && spec.meta) {
    588 47 self.log.info({32 actctxt = instance.private$.history.get(spec.meta.id)
    589 kind: 'listen',32 if (actctxt) {
    590 case: 'INIT',31 actctxt.reply(spec.err, spec.out, spec.meta)
    591 data: argsarr, }
    592 callpoint: callpoint(true), }
    593 })
    594 34 return !!actctxt
    595
    var opts =
    self.options().transport
    ||
    {}
    }
    596 47 var config = intern.resolve_config(intern.parse_config(argsarr), opts)
    597 // Listen for inbound messages.
    598 47 self.act(1exports.listen = function (callpoint) {
    599 'role:transport,cmd:listen', return function api_listen(...argsarr) {
    600 { config: config, gate$: true }, var private$ = this.private$
    601 function (err, result) {47 var self = this
    602
    if (
    err
    ) {
    603 return self.die(private$.error(err, 'transport_listen', config))47 var done = argsarr[argsarr.length - 1]
    604 }47 if (typeof done === 'function') {
    605 1 argsarr.pop()
    606 47 done(null, result) } else {
    607 47 done = () => {}46 done = () => {}
    608 } }
    609 )
    610 47 self.log.info({
    611 47 return self kind: 'listen',
    612 } case: 'INIT',
    613 } data: argsarr,
    614 callpoint: callpoint(true),
    615 // Send outbound messages. })
    616 1exports.client = function (callpoint) {
    617 return function api_client() {
    var opts =
    self.options().transport
    ||
    {}
    618 var private$ = this.private$47 var config = intern.resolve_config(intern.parse_config(argsarr), opts)
    619 43 var argsarr = Array.prototype.slice.call(arguments)
    620 43 var self = this47 self.act(
    621 'role:transport,cmd:listen',
    622 43 self.log.info({ { config: config, gate$: true },
    623 kind: 'client', function (err, result) {
    624 case: 'INIT',
    if (
    err
    ) {
    625 data: argsarr, return self.die(private$.error(err, 'transport_listen', config))
    626 callpoint: callpoint(true), }
    627 })
    628 47 done(null, result)
    629
    var legacy =
    self.options().legacy
    ||
    {}
    47 done = () => {}
    630
    var opts =
    self.options().transport
    ||
    {}
    }
    631 )
    632 43 var raw_config = intern.parse_config(argsarr)
    633 47 return self
    634 // pg: pin group }
    635 43 raw_config.pg = Common.pincanon(raw_config.pin || raw_config.pins)}
    636
    637 43 var config = intern.resolve_config(raw_config, opts)// Send outbound messages.
    638 1exports.client = function (callpoint) {
    639 43 config.id = config.id || Common.pattern(raw_config) return function api_client() {
    640 var private$ = this.private$
    641 43 var pins = var argsarr = Array.prototype.slice.call(arguments)
    642 config.pins ||43 var self = this
    643
    (
    Array.isArray(config.pin)
    ?
    config.pin
    : [config.pin || ''])
    644 43 self.log.info({
    645 43 pins = pins.map((pin) => { kind: 'client',
    646 return 'string' === typeof pin ? Jsonic(pin) : pin case: 'INIT',
    647 }) data: argsarr,
    648 callpoint: callpoint(true),
    649 //var sd = Plugins.make_delegate(self, { })
    650 // TODO: review - this feels like a hack
    651 // perhaps we should instantiate a virtual plugin to represent the client?
    var legacy =
    self.options().legacy
    ||
    {}
    652 // ... but is this necessary at all?
    var opts =
    self.options().transport
    ||
    {}
    653 43 var task_res = self.order.plugin.task.delegate.exec({
    654 ctx: {43 var raw_config = intern.parse_config(argsarr)
    655 seneca: self,
    656 }, // pg: pin group
    657 data: {43 raw_config.pg = Common.pincanon(raw_config.pin || raw_config.pins)
    658 plugin: {
    659 // TODO: make this unique with a counter43 var config = intern.resolve_config(raw_config, opts)
    660 name: 'seneca_internal_client',
    661 tag: void 0,43 config.id = config.id || Common.pattern(raw_config)
    662 },
    663 },43 var pins =
    664 }) config.pins ||
    665
    (
    Array.isArray(config.pin)
    ?
    config.pin
    : [config.pin || ''])
    666 43 var sd = task_res.out.delegate
    667 43 pins = pins.map((pin) => {
    668 43 var sendclient return 'string' === typeof pin ? Jsonic(pin) : pin
    669 })
    670 43 var transport_client = function transport_client(msg, reply, meta) {
    671
    if (
    legacy.meta
    ) {
    //var sd = Plugins.make_delegate(self, {
    672 meta = meta || msg.meta$ // TODO: review - this feels like a hack
    673 } // perhaps we should instantiate a virtual plugin to represent the client?
    674 // ... but is this necessary at all?
    675 // Undefined plugin init actions pass through here when43 var task_res = self.order.plugin.task.delegate.exec({
    676 // there's a catchall client, as they have local$:true ctx: {
    677 69 if (meta.local) { seneca: self,
    678 11 this.prior(msg, reply) },
    679
    } else if (
    sendclient
    &&
    sendclient.send
    ) {
    data: {
    680
    if (
    legacy.meta
    ) {
    plugin: {
    681 msg.meta$ = meta // TODO: make this unique with a counter
    682 } name: 'seneca_internal_client',
    683 tag: void 0,
    684 58 sendclient.send.call(this, msg, reply, meta) },
    685 } else { },
    686 this.log.error('no-transport-client', { config: config, msg: msg }) })
    687 }
    688 }43 var sd = task_res.out.delegate
    689 690 43 transport_client.id = config.id var sendclient
    691 692 43 if (config.makehandle) { var transport_client = function transport_client(msg, reply, meta) {
    693 1 transport_client.handle = config.makehandle(config)
    if (
    legacy.meta
    ) {
    694 } meta = meta || msg.meta$
    695 }
    696 43 pins.forEach((pin) => {
    697 pin = Object.assign({}, pin) // Undefined plugin init actions pass through here when
    698 // there's a catchall client, as they have local$:true
    699 // Override local actions, including those more specific than69 if (meta.local) {
    700 // the client pattern11 this.prior(msg, reply)
    701
    if (
    config.override
    ) {
    } else if (
    sendclient
    &&
    sendclient.send
    ) {
    702 sd.wrap(
    if (
    legacy.meta
    ) {
    703 sd.util.clean(pin), msg.meta$ = meta
    704 { client_pattern: sd.util.pattern(pin) }, }
    705 transport_client
    706 )58 sendclient.send.call(this, msg, reply, meta)
    707 } } else {
    708 this.log.error('no-transport-client', { config: config, msg: msg })
    709 44 pin.client$ = true }
    710 44 pin.strict$ = { add: true } }
    711
    712 44 sd.add(pin, transport_client)43 transport_client.id = config.id
    713 })
    714 43 if (config.makehandle) {
    715 // Create client.1 transport_client.handle = config.makehandle(config)
    716 43 sd.act( }
    717 'role:transport,cmd:client',
    718 { config: config, gate$: true },43 pins.forEach((pin) => {
    719 function (err, liveclient) { pin = Object.assign({}, pin)
    720
    if (
    err
    ) {
    721 return sd.die(private$.error(err, 'transport_client', config)) // Override local actions, including those more specific than
    722 } // the client pattern
    723
    if (
    config.override
    ) {
    724
    if (
    null == liveclient
    ) {
    sd.wrap(
    725 return sd.die( sd.util.clean(pin),
    726 private$.error('transport_client_null', Common.clean(config)) { client_pattern: sd.util.pattern(pin) },
    727 ) transport_client
    728 } )
    729 }
    730 43 sendclient = liveclient
    731 }44 pin.client$ = true
    732 )44 pin.strict$ = { add: true }
    733
    734 43 return self44 sd.add(pin, transport_client)
    735 } })
    736 }
    737 // Create client.
    738 // Inspired by https://github.com/hapijs/hapi/blob/master/lib/plugin.js decorate43 sd.act(
    739 // TODO: convert to plugin configuration, with standard errors 'role:transport,cmd:client',
    740 1exports.decorate = function () { { config: config, gate$: true },
    741 var args = Norma('property:s value:.', arguments) function (err, liveclient) {
    742
    if (
    err
    ) {
    743 32 var property = args.property return sd.die(private$.error(err, 'transport_client', config))
    744 32 Assert(property[0] !== '_', 'property cannot start with _') }
    745 31 Assert(
    746 this.private$.decorations[property] === undefined,
    if (
    null == liveclient
    ) {
    747 'seneca is already decorated with the property: ' + property return sd.die(
    748 ) private$.error('transport_client_null', Common.clean(config))
    749 30 Assert( )
    750 this.root[property] === undefined, }
    751 'cannot override a core seneca property: ' + property
    752 )43 sendclient = liveclient
    753 }
    754 29 this.root[property] = this.private$.decorations[property] = args.value )
    755 }
    756 43 return self
    757 1intern.parse_config = function (args) { }
    758 var out = {}}
    759
    760 90 var config = args.filter((x) => null != x)// Inspired by https://github.com/hapijs/hapi/blob/master/lib/plugin.js decorate
    761 // TODO: convert to plugin configuration, with standard errors
    762 90 var arglen = config.length1exports.decorate = function () {
    763 var args = Norma('property:s value:.', arguments)
    764 // TODO: use Joi for better error msgs
    765 32 var property = args.property
    766 90 if (arglen === 1) {32 Assert(property[0] !== '_', 'property cannot start with _')
    767
    if (
    config[0]
    && 'object' === typeof config[0]) {
    31 Assert(
    768 63 out = Object.assign({}, config[0]) this.private$.decorations[property] === undefined,
    769 } else { 'seneca is already decorated with the property: ' + property
    770 17 out.port = parseInt(config[0], 10) )
    771 }30 Assert(
    772 10 } else if (arglen === 2) { this.root[property] === undefined,
    773 1 out.port = parseInt(config[0], 10) 'cannot override a core seneca property: ' + property
    774 1 out.host = config[1] )
    775 9 } else if (arglen === 3) {
    776 3 out.port = parseInt(config[0], 10)29 this.root[property] = this.private$.decorations[property] = args.value
    777 3 out.host = config[1]}
    778 3 out.path = config[2]
    779 }1intern.parse_config = function (args) {
    780 var out = {}
    781 90 return out
    782 }90 var config = args.filter((x) => null != x)
    783
    784 1intern.resolve_config = function (config, options) {90 var arglen = config.length
    785 var out = Object.assign({}, config)
    786 // TODO: use Joi for better error msgs
    787 90 Object.keys(options).forEach((key) => {
    788 var value = options[key]90 if (arglen === 1) {
    789
    if (
    value
    && 'object' === typeof value) {
    if (
    config[0]
    && 'object' === typeof config[0]) {
    790 13 return63 out = Object.assign({}, config[0])
    791 } } else {
    792 228 out[key] = out[key] === void 0 ? value : out[key]17 out.port = parseInt(config[0], 10)
    793 }) }
    794 10 } else if (arglen === 2) {
    795 // Default transport is web1 out.port = parseInt(config[0], 10)
    796 90 out.type = out.type || 'web'1 out.host = config[1]
    797 9 } else if (arglen === 3) {
    798 // DEPRECATED: Remove in 4.03 out.port = parseInt(config[0], 10)
    799 90 if (out.type === 'direct' || out.type === 'http') {3 out.host = config[1]
    800 2 out.type = 'web'3 out.path = config[2]
    801 803 90 var base = options[out.type] || {} return out
    804 }
    805 90 out = Object.assign({}, base, out)
    806 1intern.resolve_config = function (config, options) {
    807 90 if (out.type === 'web' || out.type === 'tcp') { var out = Object.assign({}, config)
    808
    out.port =
    out.port == null
    ?
    base.port
    : out.port
    809 53 out.host = out.host == null ? base.host : out.host90 Object.keys(options).forEach((key) => {
    810 53 out.path = out.path == null ? base.path : out.path var value = options[key]
    811 }
    if (
    value
    && 'object' === typeof value) {
    812 13 return
    813 }
    814228 out[key] = out[key] === void 0 ? value : out[key]
    815 })
    816
    817 // Default transport is web
    81890 out.type = out.type || 'web'
    819
    820 // DEPRECATED: Remove in 4.0
    82190 if (out.type === 'direct' || out.type === 'http') {
    8222 out.type = 'web'
    823 }
    824
    82590 var base = options[out.type] || {}
    826
    82790 out = Object.assign({}, base, out)
    828
    82990 if (out.type === 'web' || out.type === 'tcp') {
    830
    out.port =
    out.port == null
    ?
    base.port
    : out.port
    83153 out.host = out.host == null ? base.host : out.host
    83253 out.path = out.path == null ? base.path : out.path
    833 }
    834
    813
    835 90 return out
    814
    836 }
    815
    837
    816
    838 1 intern.close = function (callpoint, done) {
    817
    839 var seneca = this
    818
    840 78 var options = seneca.options()
    819
    841
    820
    842 78 var done_called = false
    821
    843 78 var safe_done = function safe_done(err) {
    822
    844 if (!done_called && 'function' === typeof done) {
    823
    845 77 done_called = true
    824
    846 77 return done.call(seneca, err)
    825
    847 }
    826
    848 }
    827
    849
    828
    850 // don't try to close twice
    829
    851 78 if (seneca.flags.closed) {
    830
    852 1 return safe_done()
    831
    853 }
    832
    854
    833
    855 77 seneca.ready(do_close)
    834
    856 77 var close_timeout = setTimeout(do_close, options.close_delay)
    835
    857
    836
    858 function do_close() {
    837
    859 78 clearTimeout(close_timeout)
    838
    860
    839
    861 78 if (seneca.flags.closed) {
    840
    862 1 return safe_done()
    841
    863 }
    842
    864
    843
    865 // TODO: remove in 4.x
    844
    866 77 seneca.closed = true
    845
    867
    846
    868 77 seneca.flags.closed = true
    847
    869
    848
    870 // cleanup process event listeners
    849
    871 77 Common.each(options.system.close_signals, function (active, signal) {
    850
    872
    if (
    active
    ) {
    851
    873 process.removeListener(signal, seneca.private$.exit_close)
    852
    874 }
    853
    875 })
    854
    876
    855
    877 77 seneca.log.debug({
    856
    878 kind: 'close',
    857
    879 notice: 'start',
    858
    880 callpoint: callpoint(true),
    859
    881 })
    860
    882
    861
    883 77 seneca.act('role:seneca,cmd:close,closing$:true', function (err) {
    862
    884 seneca.log.debug(errlog(err, { kind: 'close', notice: 'end' }))
    863
    885
    864
    886 77 seneca.removeAllListeners('act-in')
    865
    887 77 seneca.removeAllListeners('act-out')
    866
    888 77 seneca.removeAllListeners('act-err')
    867
    889 77 seneca.removeAllListeners('pin')
    868
    890 77 seneca.removeAllListeners('after-pin')
    869
    891 77 seneca.removeAllListeners('ready')
    870
    892
    871
    893 77 seneca.private$.history.close()
    872
    894
    873
    895
    if (
    seneca.private$.status_interval
    ) {
    874
    896 clearInterval(seneca.private$.status_interval)
    875
    897 }
    876
    898
    877
    899 77 return safe_done(err)
    878
    900 })
    879
    901 }
    880
    902
    881
    903 77 return seneca
    882
    904 }
    883
    905
    884
    906 1 intern.fix_args = function (origargs, patargs, msgargs, custom) {
    885
    907 var args = Common.parsePattern(this, origargs, 'rest:.*', patargs)
    886
    908 6 var fixargs = [args.pattern]
    887
    909 .concat({
    888
    910 fixed$: Object.assign({}, msgargs, args.pattern.fixed$),
    889
    911 custom$: Object.assign({}, custom, args.pattern.custom$),
    890
    912 })
    891
    913 .concat(args.rest)
    892
    914 6 return fixargs
    893
    915 }
    894
    916
    @@ -19276,7 +19457,7 @@

    lib/common.js

    - + @@ -19288,7 +19469,7 @@

    lib/common.js

    - + @@ -19300,19 +19481,19 @@

    lib/common.js

    - + - + - + @@ -19324,13 +19505,13 @@

    lib/common.js

    - + - + @@ -19378,7 +19559,7 @@

    lib/common.js

    - + @@ -19786,7 +19967,7 @@

    lib/common.js

    - + @@ -19810,7 +19991,7 @@

    lib/common.js

    - + @@ -19834,7 +20015,7 @@

    lib/common.js

    - + @@ -19870,7 +20051,7 @@

    lib/common.js

    - + @@ -19888,7 +20069,7 @@

    lib/common.js

    - + @@ -19930,7 +20111,7 @@

    lib/common.js

    - + @@ -19942,7 +20123,7 @@

    lib/common.js

    - + @@ -20014,7 +20195,7 @@

    lib/common.js

    - + @@ -20032,7 +20213,7 @@

    lib/common.js

    - + @@ -20056,7 +20237,7 @@

    lib/common.js

    - + @@ -20152,7 +20333,7 @@

    lib/common.js

    - + @@ -20164,7 +20345,7 @@

    lib/common.js

    - + @@ -20176,7 +20357,7 @@

    lib/common.js

    - + @@ -20434,13 +20615,13 @@

    lib/common.js

    - + - + @@ -20821,11 +21002,11 @@

    lib/common.js

    - + - - + + @@ -20857,11 +21038,11 @@

    lib/common.js

    - + - + @@ -21034,13 +21215,13 @@

    lib/common.js

    - + - + @@ -21052,7 +21233,7 @@

    lib/common.js

    - + @@ -21196,13 +21377,13 @@

    lib/common.js

    - + - + @@ -21220,7 +21401,7 @@

    lib/common.js

    - + @@ -21814,13 +21995,13 @@

    lib/common.js

    - + - + @@ -21832,13 +22013,13 @@

    lib/common.js

    - + - + @@ -21856,13 +22037,13 @@

    lib/common.js

    - + - + @@ -21874,31 +22055,31 @@

    lib/common.js

    - + - + - + - + - + @@ -21910,13 +22091,13 @@

    lib/common.js

    - + - + @@ -21940,7 +22121,7 @@

    lib/common.js

    - + @@ -21976,13 +22157,13 @@

    lib/common.js

    - + - + @@ -21994,7 +22175,7 @@

    lib/common.js

    - + @@ -22166,8 +22347,8 @@

    lib/common.js

    lib/errors.js

    100%
    -
    112
    -
    112
    +
    116
    +
    116
    0
    252 2364523655 if (null == obj) return obj
    254 2364123651 var out = Array.isArray(obj) ? [] : {}
    256 2364123651 var pn = Object.getOwnPropertyNames(obj)
    257 2364123651 for (var i = 0; i < pn.length; i++) {
    258 7772177786 var p = pn[i]
    260 7772177786 if ('$' != p[p.length - 1]) {
    261 6381263861 out[p] = obj[p]
    269 2364123651 return out
    337 2125 var test = so.test
    341 2125 var full =
    345 2125 if (0 < diecount) {
    351 1721 diecount++
    354 1721 try {
    361 1721 err.fatal$ = true
    363 1721 var logdesc = {
    375 1721 instance.log.fatal(logdesc)
    378 1721 stack = stack
    382 1721 var procdesc =
    398 1721 var when = new Date()
    400 1721 var clean_details = null
    402 1721 var stderrmsg =
    445 1721 if (so.errhandler) {
    446 1418 so.errhandler.call(instance, err)
    } catch (panic) {
    510 this.log.fatal({4 this.log.fatal({
    511
    516 if (so.test) {
    if (
    so.test
    ) {
    517
    545 56405645 var prior = callmeta.prior || {}
    546 56405645 actdef = actdef || {}
    548 56405645 return Object.assign(
    572 113118 if (err.details && ctxt && ctxt.caller) {
    573 45 err.details.caller = ctxt.caller
    576 113118 return Object.assign(
    675 5937868817 var s = 0
    676 5937868817 var e = i
    678 5937868817 if (0 === this._list.length) {
    679 970117607 return 0
    682 4967751210 do {
    683 102967105764 i = Math.floor((s + e) / 2)
    685 102967105764 if (timelimit > this._list[i].timelimit) {
    686 218274 s = i + 1
    687 218274 i = s
    688 102749105490 } else if (timelimit < this._list[i].timelimit) {
    689 102738105478 e = i
    691 1112 i++
    692 1112 break
    696 4967751210 return i
    702 5936868807 for (var j = 0; j < i; j++) {
    703 421517 delete this._map[this._list[j].id]
    705 5936868807 this._list = this._list.slice(i)
    @@ -23049,13 +23230,13 @@

    lib/errors.js

    - + - + @@ -23067,13 +23248,13 @@

    lib/errors.js

    - + - + @@ -23085,83 +23266,119 @@

    lib/errors.js

    - + - + - + - + - + - + - + - - + + - + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -27398,19 +27615,19 @@

    lib/logging.js

    - + - + - + @@ -28214,7 +28431,7 @@

    lib/logging.js

    - + @@ -28238,13 +28455,13 @@

    lib/logging.js

    - + - + @@ -28256,7 +28473,7 @@

    lib/logging.js

    - + @@ -28292,7 +28509,7 @@

    lib/logging.js

    - + @@ -28316,25 +28533,25 @@

    lib/logging.js

    - + - + - + - + @@ -28346,13 +28563,13 @@

    lib/logging.js

    - + - + @@ -28370,13 +28587,13 @@

    lib/logging.js

    - + - + @@ -28400,13 +28617,13 @@

    lib/logging.js

    - + - + @@ -28430,7 +28647,7 @@

    lib/logging.js

    - + @@ -28442,7 +28659,7 @@

    lib/logging.js

    - + @@ -28454,13 +28671,13 @@

    lib/logging.js

    - + - + @@ -28478,7 +28695,7 @@

    lib/logging.js

    - + @@ -28616,13 +28833,13 @@

    lib/logging.js

    - + - + @@ -28676,19 +28893,19 @@

    lib/logging.js

    - + - + - + @@ -28712,7 +28929,7 @@

    lib/logging.js

    - + @@ -28790,19 +29007,19 @@

    lib/logging.js

    - + - + - + @@ -28856,7 +29073,7 @@

    lib/logging.js

    - + @@ -28880,7 +29097,7 @@

    lib/logging.js

    - + @@ -28922,13 +29139,13 @@

    lib/logging.js

    - + - + @@ -28946,13 +29163,13 @@

    lib/logging.js

    - + - + @@ -28970,7 +29187,7 @@

    lib/logging.js

    - + @@ -28994,13 +29211,13 @@

    lib/logging.js

    - + - + @@ -29228,7 +29445,7 @@

    lib/logging.js

    - + @@ -29252,7 +29469,7 @@

    lib/logging.js

    - + @@ -29264,7 +29481,7 @@

    lib/logging.js

    - + @@ -29300,19 +29517,19 @@

    lib/logging.js

    - + - + - + @@ -29324,19 +29541,19 @@

    lib/logging.js

    - + - + - + @@ -29372,7 +29589,7 @@

    lib/logging.js

    - + @@ -30744,7 +30961,7 @@

    lib/options.js

    - + @@ -31324,7 +31541,7 @@

    lib/outward.js

    - + @@ -31408,7 +31625,7 @@

    lib/outward.js

    - + @@ -31420,19 +31637,19 @@

    lib/outward.js

    - + - + - + @@ -31444,13 +31661,13 @@

    lib/outward.js

    - + - + @@ -31468,7 +31685,7 @@

    lib/outward.js

    - + @@ -31480,13 +31697,13 @@

    lib/outward.js

    - + - + @@ -31522,7 +31739,7 @@

    lib/outward.js

    - + @@ -31546,19 +31763,19 @@

    lib/outward.js

    - + - + - + @@ -31570,7 +31787,7 @@

    lib/outward.js

    - + @@ -31594,7 +31811,7 @@

    lib/outward.js

    - + @@ -31612,7 +31829,7 @@

    lib/outward.js

    - + @@ -31624,7 +31841,7 @@

    lib/outward.js

    - + @@ -31648,13 +31865,13 @@

    lib/outward.js

    - + - + @@ -31696,7 +31913,7 @@

    lib/outward.js

    - + @@ -31708,19 +31925,19 @@

    lib/outward.js

    - + - + - + @@ -31732,7 +31949,7 @@

    lib/outward.js

    - + @@ -31756,7 +31973,7 @@

    lib/outward.js

    - + @@ -31828,7 +32045,7 @@

    lib/outward.js

    - + @@ -31852,7 +32069,7 @@

    lib/outward.js

    - + @@ -31978,7 +32195,7 @@

    lib/outward.js

    - + @@ -31990,13 +32207,13 @@

    lib/outward.js

    - + - + @@ -32122,7 +32339,7 @@

    lib/outward.js

    - + @@ -32134,13 +32351,13 @@

    lib/outward.js

    - + - + @@ -32206,7 +32423,7 @@

    lib/outward.js

    - + @@ -32266,13 +32483,13 @@

    lib/outward.js

    - + - + @@ -32320,19 +32537,19 @@

    lib/outward.js

    - + - + - + @@ -32344,13 +32561,13 @@

    lib/outward.js

    - + - + @@ -32362,7 +32579,7 @@

    lib/outward.js

    - + @@ -32374,7 +32591,7 @@

    lib/outward.js

    - + @@ -32392,7 +32609,7 @@

    lib/outward.js

    - + @@ -32434,13 +32651,13 @@

    lib/outward.js

    - + - + @@ -32452,7 +32669,7 @@

    lib/outward.js

    - + @@ -32506,7 +32723,7 @@

    lib/outward.js

    - + @@ -32548,13 +32765,13 @@

    lib/outward.js

    - + - + @@ -32572,7 +32789,7 @@

    lib/outward.js

    - + @@ -32596,7 +32813,7 @@

    lib/outward.js

    - + @@ -32620,7 +32837,7 @@

    lib/outward.js

    - + @@ -32632,7 +32849,7 @@

    lib/outward.js

    - + @@ -32662,7 +32879,7 @@

    lib/outward.js

    - + @@ -32788,25 +33005,25 @@

    lib/outward.js

    - + - + - + - + @@ -32818,13 +33035,13 @@

    lib/outward.js

    - + - + @@ -32836,7 +33053,7 @@

    lib/outward.js

    - + @@ -32848,7 +33065,7 @@

    lib/outward.js

    - + @@ -32872,7 +33089,7 @@

    lib/outward.js

    - + @@ -33064,7 +33281,7 @@

    lib/outward.js

    - + @@ -33118,7 +33335,7 @@

    lib/outward.js

    - + @@ -33130,7 +33347,7 @@

    lib/outward.js

    - + @@ -33148,7 +33365,7 @@

    lib/outward.js

    - + @@ -33184,7 +33401,7 @@

    lib/outward.js

    - + @@ -33196,13 +33413,13 @@

    lib/outward.js

    - + - + @@ -33226,7 +33443,7 @@

    lib/outward.js

    - + @@ -33244,7 +33461,7 @@

    lib/outward.js

    - + @@ -37764,7 +37981,7 @@

    lib/print.js

    - + @@ -38212,7 +38429,7 @@

    lib/ready.js

    - + @@ -38224,7 +38441,7 @@

    lib/ready.js

    - + @@ -38278,13 +38495,13 @@

    lib/ready.js

    - + - + @@ -38296,13 +38513,13 @@

    lib/ready.js

    - + - + @@ -38314,13 +38531,13 @@

    lib/ready.js

    - + - + @@ -38362,13 +38579,13 @@

    lib/ready.js

    - + - + @@ -38380,19 +38597,19 @@

    lib/ready.js

    - + - + - + diff --git a/test/history.test.js b/test/history.test.js new file mode 100644 index 00000000..0520b817 --- /dev/null +++ b/test/history.test.js @@ -0,0 +1,44 @@ +'use strict' + +const Lab = require('@hapi/lab') +const Code = require('@hapi/code') + +var lab = (exports.lab = Lab.script()) +var describe = lab.describe +var expect = Code.expect + +var Shared = require('./shared') +var it = Shared.make_it(lab) +var Seneca = require('..') + +describe('history', function () { + it('to cleanup after successful execution', function (fin) { + const clearing = 10 + const n = 2 + const seneca = Seneca({ + history: { interval: 1 }, + timeout: 60 * 1000, + legacy: { transport: false }, + }) + .test() + .quiet() + .add('a:1', function (msg, done) { + done() + }) + .add('a:2', function (msg, done) { + setTimeout(() => { + done() + }, clearing + 101) + }) + + for (let i = 0; i < n; ++i) { + seneca.act('a:1', function () {}) + seneca.act('a:2', function () {}) + } + + setTimeout(() => { + expect(seneca.private$.history.list().length).equal(n) + fin() + }, clearing + 10) + }) +})
    145 action_timeout: fail_wrong_number_of_args:
    146 '<%=legacy_string%>Action <%=pattern%> timed out. Timeout was: <%=timeout%> (start: <%=start%>, end: <%=end%>. Message was: <%=message%>.', 'The Seneca.fail method was called with the wrong number of arguments: <%=num_args%>',
    147 148 use_no_args: fail_cond_must_be_bool:
    149 'The seneca.use method needs at least one argument to define a plugin.', 'The Seneca.fail method expected the `cond` param to be a boolean.',
    150 151 // Legacy error message codes action_timeout:
    152 '<%=legacy_string%>Action <%=pattern%> timed out. Timeout was: <%=timeout%> (start: <%=start%>, end: <%=end%>. Message was: <%=message%>.',
    153 act_invalid_args:
    154 'Action <%=pattern%> has invalid arguments; <%=message%>; ' + use_no_args:
    155 'arguments were: <%=msg%>.', 'The seneca.use method needs at least one argument to define a plugin.',
    156 }
    157 // Legacy error message codes
    158 1module.exports.deprecation = {
    159 seneca_parent: act_invalid_args:
    160 'Seneca.parent has been renamed to Seneca.prior. Seneca.parent will be removed in Seneca 4.x.', 'Action <%=pattern%> has invalid arguments; <%=message%>; ' +
    161 'arguments were: <%=msg%>.',
    162 seneca_next_act: 'Seneca.next_act will be removed in Seneca 3.x',}
    163 }
    164 1module.exports.deprecation = {
    165 seneca_parent:
    166 'Seneca.parent has been renamed to Seneca.prior. Seneca.parent will be removed in Seneca 4.x.',
    167
    168 seneca_next_act: 'Seneca.next_act will be removed in Seneca 3.x',
    169}
    170
    132 9091 try {
    133 9091 var logstr = build_test_log(this, entry)
    134 9091 this.private$.print.log(logstr)
    268 1782417863 } else if ('string' === typeof entry) {
    272 1782417863 var logspec = instance.private$.logspec
    273 1782417863 entry.level = entry.level || logspec.default_level
    275 1782417863 if ('number' !== typeof entry.level) {
    281 1782417863 var now = new Date()
    285 1782417863 entry.isot = entry.isot || now.toISOString()
    286 1782417863 entry.when = entry.when || now.getTime()
    287 1782417863 entry.level_name = entry.level_name || logspec.level_text[entry.level]
    288 1782417863 entry.seneca_id = entry.seneca_id || instance.id
    290 1782417863 if (instance.did) {
    291 1195111964 entry.seneca_did = entry.seneca_did || instance.did
    294 1782417863 if (instance.fixedargs.plugin$) {
    295 1181211825 entry.plugin_name = entry.plugin_name || instance.fixedargs.plugin$.name
    299 1782417863 if (instance.private$.act) {
    300 53745383 intern.build_act_entry(instance.private$.act, entry)
    304 1782417863 instance.emit('log', entry)
    306 1782417863 var level_match = logspec.live_level <= entry.level
    308 1782417863 if (level_match) {
    309 612629 instance.private$.logger.call(this, entry)
    312 1782417863 return this
    335 1778117820 entry.level = level
    336 1778117820 return self.log(entry)
    345 9091 var logstr
    346 9091 var time = data.when - seneca.start_time
    347 9091 var exports = seneca.private$.exports
    351 9091 var logb = [
    364 9091 if ('act' === data.kind) {
    365 2223 if (data.meta) {
    366 1920 logb.push(
    375 1920 logb.push(data.meta.pattern)
    379 1920 logb.push(
    386 2223 if (data.actdef) {
    387 1920 logb.push(data.actdef.id)
    390 2223 if (data.notice) {
    391 23 logb.push(data.notice)
    394 2223 if (data.data) {
    398 2223 if ('ERR' === data.case) {
    399 23 logb.push(
    437 9091 if (data.did) {
    441 9091 logstr = logb.join('\t')
    443 9091 return logstr
    449 53765385 entry.actid = entry.actid || act.meta.id
    450 53765385 entry.pattern = entry.pattern || act.meta.pattern
    451 53765385 entry.action = entry.action || act.def.id
    453 53765385 entry.idpath = ('' + act.meta.tx).substring(0, 5)
    454 53765385 if (act.meta.parents) {
    455 49364945 for (var i = 0; i < act.meta.parents.length; i++) {
    461 53765385 entry.idpath += ('.' + act.meta.mi).substring(0, 6)
    222 2121821233 return options
    29 28222827 if (!ctxt.options.legacy.error) {
    43 28202825 Assert(ctxt.options)
    45 28202825 var so = ctxt.options
    46 28202825 var res = data.res
    47 28202825 var meta = data.meta
    49 28202825 var actid = meta.id
    50 28202825 var private$ = ctxt.seneca.private$
    53 28202825 var actdetails = private$.history.get(actid)
    55 28202825 if (actdetails) {
    56 23782381 actdetails.result.push({ when: Date.now(), res: res })
    62 28212826 if (!ctxt.actdef || ctxt.cached$) {
    66 23852390 var private$ = ctxt.seneca.private$
    67 23852390 var stats = private$.stats.act
    68 23852390 var meta = data.meta
    70 23852390 ++stats.done
    74 22822287 private$.timestats.point(ctxt.duration, ctxt.actdef.pattern)
    77 23852390 var pattern = ctxt.actdef.pattern
    79 23852390 var actstats = (private$.stats.actmap[pattern] =
    83 6267 ++stats.fails
    84 6267 ++actstats.fails
    91 28202825 Assert(ctxt.options)
    93 28202825 var so = ctxt.options
    94 28202825 var msg = data.msg
    95 28202825 var res = data.res
    97 28202825 if (void 0 === data.res) {
    101 28202825 var not_object =
    113 28202825 if (data.out instanceof Error) {
    117 28202825 var not_legacy = !(
    138 28202825 var meta = data.meta
    140 28202825 if (meta.error) {
    141 8691 return
    162 28202825 var private$ = ctxt.seneca.private$
    164 28202825 var meta = data.meta
    165 28202825 var reply_meta = data.reply_meta
    176 28202825 if (parent_meta) {
    186 28202825 var meta = data.meta
    187 28202825 var reply_meta = data.reply_meta
    195 28202825 var delegate = ctxt.seneca
    196 28202825 var actdef = ctxt.actdef
    197 28202825 var meta = data.meta
    199 28202825 if (meta.error) {
    200 8691 data.error_desc = intern.act_error(delegate, ctxt, data)
    202 8691 if (meta.fatal) {
    204 59 return delegate.die(data.error_desc.err)
    207 8182 data.has_callback = data.error_desc.call_cb
    214 8182 data.err = data.error_desc.err
    215 8182 delete data.err.meta$
    217 8182 data.res = null
    226 28202825 var delegate = ctxt.seneca
    233 28202825 var meta = data.meta
    234 28202825 var private$ = ctxt.seneca.private$
    237 28202825 if (meta.prior) {
    241 27172722 var submsg = ctxt.seneca.util.clean(data.msg)
    245 27172722 var sub_actions_list = private$.subrouter.outward.find(submsg, false, true)
    247 27172722 submsg.out$ = true
    252 27172722 for (var alI = 0; alI < sub_actions_list.length; alI++) {
    273 8691 var act_callpoint = ctxt.callpoint
    274 8691 var actdef = ctxt.actdef || {}
    275 8691 var origmsg = ctxt.origmsg
    276 8691 var reply = ctxt.reply
    278 8691 var meta = data.meta
    279 8691 var msg = data.msg
    281 8691 var opts = instance.options()
    283 8691 var call_cb = true
    287 8691 if (!err.seneca) {
    319 4348 } else if (
    328 8691 if (opts.legacy.error) {
    330 5862 err.details.plugin = err.details.plugin || {}
    333 8691 var entry = ctxt.actlog(actdef, msg, meta, origmsg, {
    339 8691 entry = ctxt.errlog(err, entry)
    341 8691 instance.log.error(entry)
    342 8691 instance.emit('act-err', msg, err)
    346 2930 call_cb = !opts.errhandler.call(instance, err, err.meta$ || meta)
    349 8691 return {
    49 369370 konsole_log.apply(konsole_log, arguments)
    48 610601 execute_ready(self, ready_call)
    50 2534 private$.ready_list.push(ready_call)
    59 543548 const root = this
    60 543548 var private$ = root.private$
    62 543548 root.emit('ready')
    63 543548 execute_ready(root, private$.ready_list.shift())
    65 543548 if (private$.ge.isclear()) {
    66 542547 while (0 < private$.ready_list.length) {
    73 16831670 if (null == ready_func) return
    74 627632 var opts = instance.options()
    76 627632 try {
    77 627632 instance.log.debug({ kind: 'ready', case: 'call', name: ready_func.name })
    78 627632 ready_func()