navi-hey 1.10.0 → 1.11.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.
- package/README.md +3 -106
- package/bin/navi.js +2 -2
- package/config/menu.yml +36 -0
- package/lib/README.md +20 -0
- package/lib/common/utils/logging/{BufferedLogger.js → buffer/BufferedLogger.js} +5 -5
- package/lib/common/utils/logging/{LogBuffer.js → buffer/LogBuffer.js} +4 -4
- package/lib/common/utils/logging/{LogBufferCollection.js → buffer/LogBufferCollection.js} +2 -2
- package/lib/exceptions/config/ExtensionsDirectoryMissing.js +21 -0
- package/lib/exceptions/config/MenuConfigurationInvalid.js +23 -0
- package/lib/exceptions/config/{InvalidEmitBodyTemplate.js → emit/InvalidEmitBodyTemplate.js} +1 -1
- package/lib/exceptions/config/{InvalidEmitCooldown.js → emit/InvalidEmitCooldown.js} +1 -1
- package/lib/exceptions/config/{InvalidEmitHeaders.js → emit/InvalidEmitHeaders.js} +1 -1
- package/lib/exceptions/config/{InvalidEmitMethod.js → emit/InvalidEmitMethod.js} +1 -1
- package/lib/exceptions/config/{InvalidEmitRetries.js → emit/InvalidEmitRetries.js} +1 -1
- package/lib/exceptions/config/{MissingEmitUrl.js → emit/MissingEmitUrl.js} +1 -1
- package/lib/exceptions/config/{ConfigurationFileNotFound.js → file/ConfigurationFileNotFound.js} +1 -1
- package/lib/exceptions/config/{ConfigurationFileNotProvided.js → file/ConfigurationFileNotProvided.js} +1 -1
- package/lib/exceptions/config/{InvalidMemoryDataStore.js → memory/InvalidMemoryDataStore.js} +1 -1
- package/lib/exceptions/config/{InvalidMemoryThresholds.js → memory/InvalidMemoryThresholds.js} +1 -1
- package/lib/exceptions/config/{InvalidParserMatch.js → parser/InvalidParserMatch.js} +1 -1
- package/lib/exceptions/config/{InvalidParserType.js → parser/InvalidParserType.js} +1 -1
- package/lib/exceptions/config/{MissingParserField.js → parser/MissingParserField.js} +1 -1
- package/lib/exceptions/config/{MissingParserFields.js → parser/MissingParserFields.js} +1 -1
- package/lib/exceptions/config/{MissingParserMatch.js → parser/MissingParserMatch.js} +1 -1
- package/lib/models/configs/Config.js +1 -1
- package/lib/models/configs/MemoryConfig.js +2 -2
- package/lib/models/configs/MenuConfig.js +248 -0
- package/lib/models/configs/MenuEntry.js +127 -0
- package/lib/models/request/Resource.js +1 -1
- package/lib/models/request/{TemplateStringRenderer.js → renderers/TemplateStringRenderer.js} +1 -1
- package/lib/models/request/{ResourceRequest.js → resource_request/ResourceRequest.js} +27 -7
- package/lib/models/request/{ResourceRequestAction.js → resource_request/ResourceRequestAction.js} +5 -5
- package/lib/models/request/{ResourceRequestEmit.js → resource_request/ResourceRequestEmit.js} +9 -9
- package/lib/models/request/{ResourceRequestPaginatedAction.js → resource_request/ResourceRequestPaginatedAction.js} +7 -7
- package/lib/models/request/{ResourceRequestParser.js → resource_request/ResourceRequestParser.js} +1 -1
- package/lib/parsers/CssSelectorParser.js +2 -2
- package/lib/parsers/JsonPathParser.js +1 -1
- package/lib/parsers/css_selector_parser/FilterMatcher.js +1 -1
- package/lib/parsers/json_path/MatchResolver.js +1 -1
- package/lib/parsers/regex_parser/AttributesValidator.js +2 -2
- package/lib/registry/ClientRegistry.js +1 -1
- package/lib/registry/EmissionRegistry.js +1 -1
- package/lib/registry/ExtractionRegistry.js +1 -1
- package/lib/registry/LogRegistry.js +6 -6
- package/lib/registry/MemoryRegistry.js +1 -1
- package/lib/registry/ParserRegistry.js +1 -1
- package/lib/registry/ResourceRegistry.js +1 -1
- package/lib/registry/{EmissionRegistryInstance.js → instances/EmissionRegistryInstance.js} +5 -5
- package/lib/registry/{ExtractionRegistryInstance.js → instances/ExtractionRegistryInstance.js} +5 -5
- package/lib/registry/{LogRegistryInstance.js → instances/LogRegistryInstance.js} +10 -10
- package/lib/registry/{MemoryRegistryInstance.js → instances/MemoryRegistryInstance.js} +4 -4
- package/lib/registry/{NamedRegistry.js → namespace/NamedRegistry.js} +1 -1
- package/lib/registry/{Namespace.js → namespace/Namespace.js} +2 -2
- package/lib/registry/{NamespaceMap.js → namespace/NamespaceMap.js} +4 -4
- package/lib/serializers/LogSerializer.js +1 -1
- package/lib/serializers/MenuSerializer.js +19 -0
- package/lib/server/RouteRegister.js +1 -1
- package/lib/server/Router.js +73 -2
- package/lib/server/SecuredRequestHandler.js +1 -1
- package/lib/server/WebServer.js +9 -5
- package/lib/server/extensions/ExtensionModuleValidator.js +112 -0
- package/lib/server/extensions/ExtensionRoutesLoader.js +196 -0
- package/lib/server/extensions/ExtensionsEnv.js +52 -0
- package/lib/server/handlers/FrontendAssetsHandler.js +50 -0
- package/lib/server/handlers/FrontendManifestHandler.js +83 -0
- package/lib/server/handlers/LinksHandler.js +1 -1
- package/lib/server/handlers/MenuHandler.js +36 -0
- package/lib/server/handlers/api/ApiConfigHandler.js +1 -1
- package/lib/server/handlers/api/ApiEngineStartHandler.js +39 -4
- package/lib/services/application/Application.js +3 -2
- package/lib/services/application/ApplicationConfigurator.js +8 -3
- package/lib/services/application/ApplicationInstance.js +21 -3
- package/lib/services/application/ArgumentsParser.js +9 -3
- package/lib/services/application/ConfigStore.js +12 -1
- package/lib/services/builders/NamespaceMapBuilder.js +2 -2
- package/lib/services/builders/RegistriesBuilder.js +1 -1
- package/lib/services/config/ConfigIncluder.js +3 -3
- package/lib/services/engine/EngineController.js +1 -1
- package/lib/services/engine/ServerController.js +8 -4
- package/lib/utils/ResourceEnqueuer.js +34 -9
- package/package.json +7 -1
- package/static/assets/{index-FbZXTjVy.css → index-CKnpQp0V.css} +1 -1
- package/static/assets/index-D9DOeCyI.js +49 -0
- package/static/assets/react-vendor.js +11 -0
- package/static/index.html +16 -2
- package/lib/utils/index.js +0 -2
- package/lib/utils/logging/BaseLogger.js +0 -1
- package/lib/utils/logging/BufferedLogger.js +0 -1
- package/lib/utils/logging/ConsoleLogger.js +0 -1
- package/lib/utils/logging/Log.js +0 -1
- package/lib/utils/logging/LogBuffer.js +0 -1
- package/lib/utils/logging/LogBufferCollection.js +0 -1
- package/lib/utils/logging/LogContext.js +0 -1
- package/lib/utils/logging/LogFactory.js +0 -1
- package/lib/utils/logging/LogFilter.js +0 -1
- package/lib/utils/logging/Logger.js +0 -1
- package/lib/utils/logging/LoggerGroup.js +0 -1
- package/static/assets/index-C7P-w9r_.js +0 -59
- /package/lib/exceptions/config/{ConfigurationIncludeNotFound.js → file/ConfigurationIncludeNotFound.js} +0 -0
- /package/lib/models/request/{BodyTemplateRenderer.js → renderers/BodyTemplateRenderer.js} +0 -0
- /package/lib/models/request/{TokenResolver.js → tokens/TokenResolver.js} +0 -0
- /package/lib/models/request/{UrlTokenResolver.js → tokens/UrlTokenResolver.js} +0 -0
package/README.md
CHANGED
|
@@ -49,112 +49,9 @@ navi-hey --config /path/to/your/config.yml
|
|
|
49
49
|
|
|
50
50
|
## Configuration File
|
|
51
51
|
|
|
52
|
-
Navi is configured via a YAML file that defines HTTP clients, resources, and the worker
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
```yaml
|
|
57
|
-
workers:
|
|
58
|
-
quantity: 5 # number of concurrent workers (default: 1)
|
|
59
|
-
retry_cooldown: 2000 # ms before a failed job is retried (default: 2000)
|
|
60
|
-
sleep: 500 # ms the engine waits between allocation ticks (default: 500)
|
|
61
|
-
max-retries: 3 # max number of retries before a job is marked dead (default: 3)
|
|
62
|
-
|
|
63
|
-
log:
|
|
64
|
-
size: 100 # max number of log entries kept in memory (default: 100)
|
|
65
|
-
|
|
66
|
-
failure:
|
|
67
|
-
threshold: 10.0 # optional: exit with failure if > 10% of jobs are dead
|
|
68
|
-
|
|
69
|
-
web:
|
|
70
|
-
port: 3000 # port for the monitoring web UI (omit to disable)
|
|
71
|
-
|
|
72
|
-
clients:
|
|
73
|
-
default:
|
|
74
|
-
base_url: https://example.com
|
|
75
|
-
auth_api:
|
|
76
|
-
base_url: https://api.example.com
|
|
77
|
-
headers:
|
|
78
|
-
Authorization: Bearer $API_TOKEN
|
|
79
|
-
|
|
80
|
-
resources:
|
|
81
|
-
home:
|
|
82
|
-
- url: /
|
|
83
|
-
status: 200
|
|
84
|
-
assets:
|
|
85
|
-
- selector: script[src]
|
|
86
|
-
attribute: src
|
|
87
|
-
- selector: link[rel="stylesheet"]
|
|
88
|
-
attribute: href
|
|
89
|
-
categories:
|
|
90
|
-
- url: /categories.json
|
|
91
|
-
status: 200
|
|
92
|
-
actions:
|
|
93
|
-
- resource: category_information
|
|
94
|
-
- resource: products
|
|
95
|
-
parameters:
|
|
96
|
-
category_id: parsedBody.id
|
|
97
|
-
paginated_actions:
|
|
98
|
-
- resource: products_page
|
|
99
|
-
pagination:
|
|
100
|
-
- pages: parsedBody.pagination.pages
|
|
101
|
-
- page_key: page
|
|
102
|
-
- zero_indexed: false
|
|
103
|
-
parameters:
|
|
104
|
-
per_page: headers['x-per-page']
|
|
105
|
-
- url: /categories
|
|
106
|
-
status: 302
|
|
107
|
-
- url: /#/categories
|
|
108
|
-
status: 200
|
|
109
|
-
category_information:
|
|
110
|
-
- url: /categories/{:id}.json
|
|
111
|
-
status: 200
|
|
112
|
-
client: auth_api
|
|
113
|
-
products:
|
|
114
|
-
- url: /categories/{:category_id}/products/{:page}.json
|
|
115
|
-
status: 200
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
### Fields
|
|
119
|
-
|
|
120
|
-
| Field | Description |
|
|
121
|
-
|-------|-------------|
|
|
122
|
-
| `workers.quantity` | Number of concurrent workers. Defaults to `1`. |
|
|
123
|
-
| `workers.retry_cooldown` | Milliseconds a failed job waits before being re-queued for retry. Defaults to `2000`. |
|
|
124
|
-
| `workers.sleep` | Milliseconds the engine waits between allocation ticks. Defaults to `500`. |
|
|
125
|
-
| `workers.max-retries` | Maximum number of times a job is retried before being moved to the dead queue. Defaults to `3`. |
|
|
126
|
-
| `log.size` | Maximum number of log entries kept in the in-memory log buffer. Defaults to `100`. |
|
|
127
|
-
| `failure.threshold` | Optional. Percentage (0–100) of dead jobs that triggers a non-zero exit code. When absent, Navi always exits successfully. |
|
|
128
|
-
| `web.port` | Port for the local monitoring web UI. Omit the `web` key entirely to run Navi without the web server. The web UI frontend is bundled with the package and served from `source/static/`. After frontend code changes, run `yarn build` in the `navi_frontend` service to update the bundled assets. |
|
|
129
|
-
|
|
130
|
-
When the web server is enabled, the following screens are available:
|
|
131
|
-
|
|
132
|
-
| Screen | URL | Description |
|
|
133
|
-
|--------|-----|-------------|
|
|
134
|
-
| Dashboard | `/#/` | Real-time job queue stats (counts per status). |
|
|
135
|
-
| Jobs list | `/#/jobs` | Table of all jobs across every status, with links to individual job pages. |
|
|
136
|
-
| Job detail | `/#/job/:id` | Full details for a specific job (ID, status, attempt count). |
|
|
137
|
-
| `clients.<name>.base_url` | Base URL for the named HTTP client. Supports environment variable references (`$VAR` or `${VAR}`), resolved at configuration load time. |
|
|
138
|
-
| `clients.<name>.headers` | Optional HTTP headers sent with every request of this client. Header values support environment variable references (`$VAR` or `${VAR}`), resolved at configuration load time. |
|
|
139
|
-
| `resources.<name>` | A named group of URL requests to warm. |
|
|
140
|
-
| `url` | URL path (appended to the client's `base_url`). Supports `{:placeholder}` tokens. |
|
|
141
|
-
| `status` | Expected HTTP response status code. Navi marks a request as failed if the actual status differs. |
|
|
142
|
-
| `client` | Name of the client to use for this request. Defaults to `default`. |
|
|
143
|
-
| `actions` | Optional list of actions to execute after a successful response. |
|
|
144
|
-
| `actions[].resource` | Name of the resource to act upon. Required. |
|
|
145
|
-
| `actions[].parameters` | Optional key-value map. Each key is the destination variable name and each value is a path expression resolved against the response (e.g. `parsedBody.id`, `headers['page']`). When absent, the parsed body item is passed through unchanged. |
|
|
146
|
-
| `paginated_actions` | Optional list of paginated actions. Each entry fans out one `ResourceRequestJob` per page. |
|
|
147
|
-
| `paginated_actions[].resource` | Name of the resource to enqueue per page. Required. |
|
|
148
|
-
| `paginated_actions[].pagination` | List of pagination config entries. Required. |
|
|
149
|
-
| `paginated_actions[].pagination[].pages` | Path expression (e.g. `parsedBody.pagination.pages`) resolving to the total page count. |
|
|
150
|
-
| `paginated_actions[].pagination[].page_key` | Parameter name injected as the current page number into each downstream request. |
|
|
151
|
-
| `paginated_actions[].pagination[].zero_indexed` | Boolean. Pages start at `0` when `true`, at `1` when `false` (default). |
|
|
152
|
-
| `paginated_actions[].parameters` | Optional. Path expressions (same syntax as `actions[].parameters`) resolved against the response and merged into each page's request parameters. `page_key`'s value always takes precedence on key collision. |
|
|
153
|
-
| `assets` | Optional list of asset extraction rules. When present on an HTML resource, Navi parses the response body and enqueues a download job for each matched URL. |
|
|
154
|
-
| `assets[].selector` | CSS selector used to find asset elements in the HTML response (e.g. `script[src]`, `link[rel="stylesheet"]`). |
|
|
155
|
-
| `assets[].attribute` | Attribute on the matched element that holds the asset URL (e.g. `src`, `href`). |
|
|
156
|
-
| `assets[].client` | Named client to use when fetching the asset. Defaults to `default`. |
|
|
157
|
-
| `assets[].status` | Expected HTTP status code for asset fetches. Defaults to `200`. |
|
|
52
|
+
Navi is configured via a YAML file that defines HTTP clients, resources, and the worker
|
|
53
|
+
pool size. See the [configuration schema](https://github.com/darthjee/navi/blob/main/docs/guides/navi/configuration-schema.md)
|
|
54
|
+
for the full field-by-field reference.
|
|
158
55
|
|
|
159
56
|
---
|
|
160
57
|
|
package/bin/navi.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { Application } from '../lib/services/application/Application.js';
|
|
4
4
|
import { ArgumentsParser } from '../lib/services/application/ArgumentsParser.js';
|
|
5
5
|
|
|
6
|
-
const { config } = ArgumentsParser.parse(process.argv.slice(2));
|
|
6
|
+
const { config, menu } = ArgumentsParser.parse(process.argv.slice(2));
|
|
7
7
|
Application.build();
|
|
8
|
-
Application.loadConfig(config);
|
|
8
|
+
Application.loadConfig(config, menu);
|
|
9
9
|
Application.run();
|
package/config/menu.yml
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Navi internal navigation menu — stock template.
|
|
2
|
+
#
|
|
3
|
+
# This file ships fully commented out. With no active `entries` key Navi falls
|
|
4
|
+
# back to its built-in defaults (Logs + Memory), so the menu below is unchanged
|
|
5
|
+
# until you uncomment something.
|
|
6
|
+
#
|
|
7
|
+
# Operator entries are MERGED after the built-in defaults: defaults first (in
|
|
8
|
+
# their shipped order), then your entries in file order. Copy this file, edit it,
|
|
9
|
+
# and point Navi at it with `-m` / `--menu` / `NAVI_MENU`.
|
|
10
|
+
#
|
|
11
|
+
# ----------------------------------------------------------------------------
|
|
12
|
+
# entries:
|
|
13
|
+
# # A plain added entry — internal SPA path plus the text shown in the menu.
|
|
14
|
+
# - route: /dashboard
|
|
15
|
+
# text: Dashboard
|
|
16
|
+
#
|
|
17
|
+
# # An external link — any absolute http(s) URL is allowed as a route.
|
|
18
|
+
# - route: https://status.example.com
|
|
19
|
+
# text: Status page
|
|
20
|
+
#
|
|
21
|
+
# # Re-listing a default route (/logs or /memory/status) repositions that
|
|
22
|
+
# # default here instead of duplicating it. Omit `text` to keep the shipped
|
|
23
|
+
# # label ("Logs" / "Memory"); supply `text` to override it.
|
|
24
|
+
# - route: /logs
|
|
25
|
+
# text: Application logs
|
|
26
|
+
#
|
|
27
|
+
# # `hidden: true` on a default route removes just that default. The hidden
|
|
28
|
+
# # entry itself never renders. It is only valid on a default route.
|
|
29
|
+
# - route: /memory/status
|
|
30
|
+
# hidden: true
|
|
31
|
+
#
|
|
32
|
+
# # Top-level sibling of `entries`. `defaults: false` drops BOTH built-in
|
|
33
|
+
# # defaults, so only your entries render — the only way to empty the menu.
|
|
34
|
+
# # A non-boolean value is ignored (treated as true) with a warning.
|
|
35
|
+
# defaults: false
|
|
36
|
+
# ----------------------------------------------------------------------------
|
package/lib/README.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# `source/lib/` index
|
|
2
|
+
|
|
3
|
+
One line per immediate child. For the full narrative breakdown, follow the "See also" link.
|
|
4
|
+
|
|
5
|
+
- `client/` — `Client.js`: Axios-based HTTP executor for URL-template and absolute-URL requests.
|
|
6
|
+
- `common/` — utilities/base classes shared with `dev/app/` (`exceptions/`, `server/`, `utils/` incl. `logging/`, `EnvResolver`).
|
|
7
|
+
- `enqueuers/` — push jobs into `deku-swarm`'s `JobRegistry` (`ActionsEnqueuer`, `PaginatedActionsEnqueuer`, `AssetRequestEnqueuer`).
|
|
8
|
+
- `exceptions/` — custom error hierarchy under `AppError`; sub-domains `config/`, `request/`, `registry/`, `http/`.
|
|
9
|
+
- `jobs/` — concrete `Job` subclasses (`ResourceRequestJob`, `ActionProcessingJob`, `PaginatedActionProcessingJob`, `HtmlParseJob`, `AssetDownloadJob`).
|
|
10
|
+
- `models/` — YAML-config → typed instances (`configs/`, `request/`, `response/`); entry point `Config.fromFile()`.
|
|
11
|
+
- `parsers/` — response extraction strategies: `RegexParser`, `JsonPathParser`, `CssSelectorParser` (+ their sub-implementation folders).
|
|
12
|
+
- `registry/` — named-lookup collections (`ResourceRegistry`, `ClientRegistry`, `LogRegistry`, …); `instances/` singletons, `namespace/` primitives.
|
|
13
|
+
- `serializers/` — plain-object views of domain models for the web server's JSON responses.
|
|
14
|
+
- `server/` — Express web server: `Router`, `RouteRegister`, `HandlerConfig`, `handlers/` (+ `handlers/engine/`, `handlers/jobs/`).
|
|
15
|
+
- `services/` — business logic / I/O: `Application`, `ApplicationInstance`, `Client`, `ConfigLoader`, `ConfigParser`, `ArgumentsParser`.
|
|
16
|
+
- `utils/` — low-level helpers with no domain knowledge: `HtmlParser`, `ResourceRequestCollector`, `ResourceEnqueuer`, `generators/`.
|
|
17
|
+
|
|
18
|
+
## See also
|
|
19
|
+
|
|
20
|
+
[`docs/agents/architecture/source-layout.md`](../../docs/agents/architecture/source-layout.md) — the full narrative breakdown of `source/lib/`.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseLogger } from '
|
|
1
|
+
import { BaseLogger } from '../BaseLogger.js';
|
|
2
2
|
import { LogBuffer } from './LogBuffer.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -32,7 +32,7 @@ class BufferedLogger extends BaseLogger {
|
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
34
|
* Returns the most recently added log, or undefined if the buffer is empty.
|
|
35
|
-
* @returns {import('
|
|
35
|
+
* @returns {import('../Log.js').Log|undefined} The most recently added log entry, or undefined.
|
|
36
36
|
*/
|
|
37
37
|
get latestLog() {
|
|
38
38
|
return this.#buffer.latestLog;
|
|
@@ -40,7 +40,7 @@ class BufferedLogger extends BaseLogger {
|
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
42
|
* Gets all logs from the buffer.
|
|
43
|
-
* @returns {Array<import('
|
|
43
|
+
* @returns {Array<import('../Log.js').Log>} Array of log entries.
|
|
44
44
|
*/
|
|
45
45
|
getLogs() {
|
|
46
46
|
return this.#buffer.getLogs();
|
|
@@ -49,7 +49,7 @@ class BufferedLogger extends BaseLogger {
|
|
|
49
49
|
/**
|
|
50
50
|
* Gets a specific log by ID.
|
|
51
51
|
* @param {number} id - The log ID to find.
|
|
52
|
-
* @returns {import('
|
|
52
|
+
* @returns {import('../Log.js').Log|undefined} The log entry or undefined if not found.
|
|
53
53
|
*/
|
|
54
54
|
getLogById(id) {
|
|
55
55
|
return this.#buffer.getLogById(id);
|
|
@@ -58,7 +58,7 @@ class BufferedLogger extends BaseLogger {
|
|
|
58
58
|
/**
|
|
59
59
|
* Gets logs filtered by level.
|
|
60
60
|
* @param {string} level - The log level to filter by.
|
|
61
|
-
* @returns {Array<import('
|
|
61
|
+
* @returns {Array<import('../Log.js').Log>} Array of log entries matching the level.
|
|
62
62
|
*/
|
|
63
63
|
getLogsByLevel(level) {
|
|
64
64
|
return this.#buffer.getLogsByLevel(level);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LogFactory } from '
|
|
1
|
+
import { LogFactory } from '../LogFactory.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* LogBuffer manages a limited collection of log entries with automatic retention.
|
|
@@ -26,7 +26,7 @@ class LogBuffer {
|
|
|
26
26
|
* @param {string} level - The log level.
|
|
27
27
|
* @param {string} message - The log message.
|
|
28
28
|
* @param {object} [attributes={}] - Optional structured metadata for the log entry.
|
|
29
|
-
* @returns {import('
|
|
29
|
+
* @returns {import('../Log.js').Log} The created log entry.
|
|
30
30
|
*/
|
|
31
31
|
add(level, message, attributes = {}) {
|
|
32
32
|
const log = this.#factory.build(level, message, attributes);
|
|
@@ -68,7 +68,7 @@ class LogBuffer {
|
|
|
68
68
|
|
|
69
69
|
/**
|
|
70
70
|
* Appends an existing Log instance to the buffer, respecting the retention limit.
|
|
71
|
-
* @param {import('
|
|
71
|
+
* @param {import('../Log.js').Log} log - The Log instance to append.
|
|
72
72
|
* @returns {void}
|
|
73
73
|
*/
|
|
74
74
|
push(log) {
|
|
@@ -80,7 +80,7 @@ class LogBuffer {
|
|
|
80
80
|
|
|
81
81
|
/**
|
|
82
82
|
* Returns the most recently added log, or undefined if the buffer is empty.
|
|
83
|
-
* @returns {import('
|
|
83
|
+
* @returns {import('../Log.js').Log|undefined} The most recently added log entry, or undefined.
|
|
84
84
|
*/
|
|
85
85
|
get latestLog() {
|
|
86
86
|
return this.#logs[0];
|
|
@@ -22,7 +22,7 @@ class LogBufferCollection {
|
|
|
22
22
|
* Appends an existing Log instance to the buffer for the given key.
|
|
23
23
|
* Lazily creates the buffer on first use.
|
|
24
24
|
* @param {string|number} key - The key identifying the buffer (e.g. jobId or workerId).
|
|
25
|
-
* @param {import('
|
|
25
|
+
* @param {import('../Log.js').Log} log - The Log instance to append.
|
|
26
26
|
* @returns {void}
|
|
27
27
|
*/
|
|
28
28
|
push(key, log) {
|
|
@@ -36,7 +36,7 @@ class LogBufferCollection {
|
|
|
36
36
|
* Returns all logs for the given key in chronological order (oldest first).
|
|
37
37
|
* Returns an empty array if no buffer exists for that key.
|
|
38
38
|
* @param {string|number} key - The key to look up.
|
|
39
|
-
* @returns {Array<import('
|
|
39
|
+
* @returns {Array<import('../Log.js').Log>} Array of log entries for the given key, oldest first.
|
|
40
40
|
*/
|
|
41
41
|
getLogs(key) {
|
|
42
42
|
if (!this.#buffers.has(key)) return [];
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { AppError } from '../../common/exceptions/AppError.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* ExtensionsDirectoryMissing is thrown when extensions are enabled but
|
|
5
|
+
* `NAVI_EXTENSIONS_DIR` is unset, does not exist, or is not a directory.
|
|
6
|
+
* Startup is aborted fail-fast, mirroring `MenuConfigurationInvalid`'s posture
|
|
7
|
+
* on a broken configuration root.
|
|
8
|
+
* @author darthjee
|
|
9
|
+
*/
|
|
10
|
+
class ExtensionsDirectoryMissing extends AppError {
|
|
11
|
+
/**
|
|
12
|
+
* @param {string} dir - The offending extensions directory path.
|
|
13
|
+
*/
|
|
14
|
+
constructor(dir) {
|
|
15
|
+
super(`Extensions are enabled but the extensions directory is missing: ${dir}`);
|
|
16
|
+
this.name = 'ExtensionsDirectoryMissing';
|
|
17
|
+
this.dir = dir;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { ExtensionsDirectoryMissing };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { AppError } from '../../common/exceptions/AppError.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* MenuConfigurationInvalid is thrown when the menu configuration file cannot be
|
|
5
|
+
* parsed, or parses to a document whose `entries` key is present but is not a
|
|
6
|
+
* list. Startup is aborted fail-fast, matching the `ConfigIncluder` posture on a
|
|
7
|
+
* broken main configuration file.
|
|
8
|
+
* @author darthjee
|
|
9
|
+
*/
|
|
10
|
+
class MenuConfigurationInvalid extends AppError {
|
|
11
|
+
/**
|
|
12
|
+
* @param {string} file - Path to the offending menu configuration file.
|
|
13
|
+
* @param {string} [reason] - Optional detail about why the file is invalid.
|
|
14
|
+
*/
|
|
15
|
+
constructor(file, reason) {
|
|
16
|
+
super(`Invalid menu configuration file: ${file}${reason ? ` (${reason})` : ''}`);
|
|
17
|
+
this.name = 'MenuConfigurationInvalid';
|
|
18
|
+
this.file = file;
|
|
19
|
+
this.reason = reason;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { MenuConfigurationInvalid };
|
|
@@ -2,7 +2,7 @@ import { EmitConfig } from './EmitConfig.js';
|
|
|
2
2
|
import { ExtractionConfig } from './ExtractionConfig.js';
|
|
3
3
|
import { LogConfig } from './LogConfig.js';
|
|
4
4
|
import { NamespaceNotFound } from '../../exceptions/registry/NamespaceNotFound.js';
|
|
5
|
-
import { NamespaceMap } from '../../registry/NamespaceMap.js';
|
|
5
|
+
import { NamespaceMap } from '../../registry/namespace/NamespaceMap.js';
|
|
6
6
|
import { ResourceRegistry } from '../../registry/ResourceRegistry.js';
|
|
7
7
|
import { ConfigLoader } from '../../services/config/ConfigLoader.js';
|
|
8
8
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { InvalidMemoryDataStore } from '../../exceptions/config/InvalidMemoryDataStore.js';
|
|
2
|
-
import { InvalidMemoryThresholds } from '../../exceptions/config/InvalidMemoryThresholds.js';
|
|
1
|
+
import { InvalidMemoryDataStore } from '../../exceptions/config/memory/InvalidMemoryDataStore.js';
|
|
2
|
+
import { InvalidMemoryThresholds } from '../../exceptions/config/memory/InvalidMemoryThresholds.js';
|
|
3
3
|
import { MemoryMaximumResolver } from '../../utils/memory/MemoryMaximumResolver.js';
|
|
4
4
|
|
|
5
5
|
const DEFAULT_THRESHOLDS = { low: 25.0, medium: 50.0, high: 75.0, over: 100.0 };
|