navi-hey 0.4.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/README.md +167 -0
  2. package/lib/exceptions/ForbiddenError.js +14 -0
  3. package/lib/exceptions/InvalidHtmlResponseBody.js +19 -0
  4. package/lib/exceptions/NotFoundError.js +13 -0
  5. package/lib/models/ActionProcessingJob.js +18 -9
  6. package/lib/models/AssetDownloadJob.js +58 -0
  7. package/lib/models/AssetRequest.js +39 -0
  8. package/lib/models/AssetRequestEnqueuer.js +68 -0
  9. package/lib/models/Config.js +4 -1
  10. package/lib/models/HtmlParseJob.js +71 -0
  11. package/lib/models/Job.js +12 -2
  12. package/lib/models/LogConfig.js +35 -0
  13. package/lib/models/ResourceRequest.js +24 -1
  14. package/lib/models/ResourceRequestJob.js +35 -3
  15. package/lib/models/WorkersConfig.js +5 -1
  16. package/lib/registry/JobRegistry.js +18 -0
  17. package/lib/registry/JobRegistryInstance.js +55 -2
  18. package/lib/serializers/JobIndexSerializer.js +26 -0
  19. package/lib/serializers/JobSerializer.js +26 -0
  20. package/lib/serializers/JobShowSerializer.js +47 -0
  21. package/lib/serializers/Serializer.js +36 -0
  22. package/lib/server/AssetsRequestHandler.js +50 -0
  23. package/lib/server/IndexRequestHandler.js +31 -0
  24. package/lib/server/JobRequestHandler.js +33 -0
  25. package/lib/server/JobsRequestHandler.js +30 -0
  26. package/lib/server/PathValidator.js +41 -0
  27. package/lib/server/RouteRegister.js +27 -1
  28. package/lib/server/Router.js +27 -3
  29. package/lib/services/Application.js +19 -2
  30. package/lib/services/Client.js +47 -6
  31. package/lib/services/ConfigParser.js +13 -2
  32. package/lib/utils/HtmlElementParser.js +39 -0
  33. package/lib/utils/HtmlParser.js +49 -0
  34. package/lib/utils/collections/Collection.js +9 -0
  35. package/lib/utils/collections/IdentifyableCollection.js +9 -0
  36. package/lib/utils/collections/Queue.js +8 -0
  37. package/lib/utils/logging/BaseLogger.js +14 -9
  38. package/lib/utils/logging/BufferedLogger.js +3 -2
  39. package/lib/utils/logging/ConsoleLogger.js +3 -2
  40. package/lib/utils/logging/Log.js +14 -2
  41. package/lib/utils/logging/LogBuffer.js +3 -2
  42. package/lib/utils/logging/LogFactory.js +3 -2
  43. package/lib/utils/logging/Logger.js +12 -8
  44. package/lib/utils/logging/LoggerGroup.js +12 -8
  45. package/package.json +10 -4
  46. package/static/assets/index-BF8_ow13.js +11 -0
  47. package/static/assets/index-DBkz-poX.css +1 -0
  48. package/static/index.html +13 -0
@@ -2,10 +2,14 @@ import { Engine } from './Engine.js';
2
2
  import { ConfigurationFileNotProvided } from '../exceptions/ConfigurationFileNotProvided.js';
3
3
  import { JobFactory } from '../factories/JobFactory.js';
4
4
  import { ActionProcessingJob } from '../models/ActionProcessingJob.js';
5
+ import { AssetDownloadJob } from '../models/AssetDownloadJob.js';
5
6
  import { Config } from '../models/Config.js';
7
+ import { HtmlParseJob } from '../models/HtmlParseJob.js';
6
8
  import { JobRegistry } from '../registry/JobRegistry.js';
7
9
  import { WorkersRegistry } from '../registry/WorkersRegistry.js';
8
10
  import { WebServer } from '../server/WebServer.js';
11
+ import { BufferedLogger } from '../utils/logging/BufferedLogger.js';
12
+ import { Logger } from '../utils/logging/Logger.js';
9
13
  import { PromiseAggregator } from '../utils/PromiseAggregator.js';
10
14
  import { ResourceRequestCollector } from '../utils/ResourceRequestCollector.js';
11
15
 
@@ -16,6 +20,7 @@ import { ResourceRequestCollector } from '../utils/ResourceRequestCollector.js';
16
20
  */
17
21
  class Application {
18
22
  #workers;
23
+ #bufferedLogger;
19
24
 
20
25
  /**
21
26
  * Creates a new Application instance.
@@ -40,6 +45,8 @@ class Application {
40
45
 
41
46
  // Load the configuration from the specified path.
42
47
  this.config = Config.fromFile(configPath);
48
+ this.#bufferedLogger = new BufferedLogger(undefined, this.config.logConfig.size);
49
+ Logger.addLogger(this.#bufferedLogger);
43
50
  this.#initRegistries();
44
51
  }
45
52
 
@@ -65,7 +72,7 @@ class Application {
65
72
  * @returns {Engine} The created Engine instance.
66
73
  */
67
74
  buildEngine() {
68
- return new Engine();
75
+ return new Engine({ sleepMs: this.config.workersConfig.sleep });
69
76
  }
70
77
 
71
78
  /**
@@ -78,6 +85,14 @@ class Application {
78
85
  });
79
86
  }
80
87
 
88
+ /**
89
+ * Gets the buffered logger instance created during config loading.
90
+ * @returns {BufferedLogger} The buffered logger instance.
91
+ */
92
+ get bufferedLogger() {
93
+ return this.#bufferedLogger;
94
+ }
95
+
81
96
  /**
82
97
  * Enqueues all parameter-free ResourceRequests into the job registry.
83
98
  * These are requests whose URLs contain no {:placeholder} tokens and can be
@@ -97,8 +112,10 @@ class Application {
97
112
  #initRegistries() {
98
113
  JobFactory.build('ResourceRequestJob', { attributes: { clients: this.config.clientRegistry } });
99
114
  JobFactory.build('Action', { klass: ActionProcessingJob });
115
+ JobFactory.build('HtmlParse', { klass: HtmlParseJob, attributes: { jobRegistry: JobRegistry, clientRegistry: this.config.clientRegistry } });
116
+ JobFactory.build('AssetDownload', { klass: AssetDownloadJob, attributes: { clientRegistry: this.config.clientRegistry } });
100
117
 
101
- JobRegistry.build({ cooldown: this.config.workersConfig.retryCooldown });
118
+ JobRegistry.build({ cooldown: this.config.workersConfig.retryCooldown, maxRetries: this.config.workersConfig.maxRetries });
102
119
 
103
120
  WorkersRegistry.build({
104
121
  workers: this.#workers,
@@ -65,11 +65,24 @@ class Client {
65
65
  try {
66
66
  return await this.#request(resourceRequest, requestUrl);
67
67
  } catch (error) {
68
- Logger.error(`Request failed: ${error}`);
69
- if (error.response) {
70
- throw new RequestFailed(error.response.status, requestUrl);
71
- }
72
- throw error;
68
+ this.#handleError(error, requestUrl);
69
+ }
70
+ }
71
+
72
+ /**
73
+ * Performs an HTTP request to the given fully-resolved URL and validates the expected status.
74
+ * Unlike `perform`, this method accepts an absolute URL directly and does not prepend `baseUrl`.
75
+ * @param {string} absoluteUrl The fully-resolved URL to request.
76
+ * @param {number} expectedStatus The expected HTTP response status code.
77
+ * @returns {Promise<object>} The Axios response object.
78
+ * @throws {RequestFailed} If the response status does not match `expectedStatus`.
79
+ */
80
+ async performUrl(absoluteUrl, expectedStatus) {
81
+ Logger.info(`[Client:${this.name}] Requesting ${absoluteUrl}`);
82
+ try {
83
+ return await this.#requestUrl(absoluteUrl, expectedStatus);
84
+ } catch (error) {
85
+ this.#handleError(error, absoluteUrl);
73
86
  }
74
87
  }
75
88
 
@@ -82,19 +95,47 @@ class Client {
82
95
  * @throws {RequestFailed} Throws an error if the response status does not match.
83
96
  */
84
97
  async #request(resourceRequest, requestUrl) {
98
+ return this.#requestUrl(requestUrl, resourceRequest.status);
99
+ }
100
+
101
+ /**
102
+ * Performs the HTTP GET request to the given URL and validates the response status.
103
+ * @param {string} requestUrl The full URL to request.
104
+ * @param {number} expectedStatus The expected HTTP response status code.
105
+ * @returns {Promise<object>} The Axios response object.
106
+ * @throws {RequestFailed} Throws an error if the response status does not match.
107
+ */
108
+ async #requestUrl(requestUrl, expectedStatus) {
85
109
  const response = await axios.get(requestUrl, {
86
110
  timeout: this.timeout,
87
111
  responseType: 'text',
88
112
  headers: this.headers,
113
+ maxRedirects: 0,
114
+ validateStatus: () => true,
89
115
  });
90
116
 
91
- if (response.status !== resourceRequest.status) {
117
+ if (response.status !== expectedStatus) {
92
118
  throw new RequestFailed(response.status, requestUrl);
93
119
  }
94
120
 
95
121
  return response;
96
122
  }
97
123
 
124
+ /**
125
+ * Handles a caught request error, logging it and re-throwing as RequestFailed when applicable.
126
+ * @param {Error} error The caught error.
127
+ * @param {string} requestUrl The URL that was requested.
128
+ * @throws {RequestFailed} If the error has a response object.
129
+ * @throws {Error} Re-throws the original error otherwise.
130
+ */
131
+ #handleError(error, requestUrl) {
132
+ Logger.error(`Request failed: ${error}`);
133
+ if (error.response) {
134
+ throw new RequestFailed(error.response.status, requestUrl);
135
+ }
136
+ throw error;
137
+ }
138
+
98
139
  /**
99
140
  * Builds the complete URL by combining base URL and resource URL path.
100
141
  * @param {string} resourceUrl URL path from the resource request.
@@ -1,6 +1,7 @@
1
1
  import { Client } from './Client.js';
2
2
  import { MissingClientsConfig } from '../exceptions/MissingClientsConfig.js';
3
3
  import { MissingResourceConfig } from '../exceptions/MissingResourceConfig.js';
4
+ import { LogConfig } from '../models/LogConfig.js';
4
5
  import { Resource } from '../models/Resource.js';
5
6
  import { WebConfig } from '../models/WebConfig.js';
6
7
  import { WorkersConfig } from '../models/WorkersConfig.js';
@@ -39,8 +40,9 @@ class ConfigParser {
39
40
  * resources: Record<string, Resource>,
40
41
  * clients: Record<string, Client>,
41
42
  * workersConfig: WorkersConfig,
42
- * webConfig: WebConfig|null
43
- * }} Parsed configuration with resources, clients, workersConfig, and webConfig.
43
+ * webConfig: WebConfig|null,
44
+ * logConfig: LogConfig
45
+ * }} Parsed configuration with resources, clients, workersConfig, webConfig, and logConfig.
44
46
  */
45
47
  parse() {
46
48
  const mappedResources = Object.fromEntries(
@@ -56,6 +58,7 @@ class ConfigParser {
56
58
  clients: mappedClients,
57
59
  workersConfig: this.#workersConfig(),
58
60
  webConfig: this.#webConfig(),
61
+ logConfig: this.#logConfig(),
59
62
  };
60
63
  }
61
64
 
@@ -76,6 +79,14 @@ class ConfigParser {
76
79
  return new WebConfig(this.config.web);
77
80
  }
78
81
 
82
+ /**
83
+ * Creates a LogConfig from the parsed YAML log section.
84
+ * @returns {LogConfig} The log configuration instance.
85
+ */
86
+ #logConfig() {
87
+ return LogConfig.fromObject(this.config.log);
88
+ }
89
+
79
90
  /**
80
91
  * Maps the resources to entries suitable for Object.fromEntries.
81
92
  * @returns {Array<Array>} Entries of resource name and Resource instance.
@@ -0,0 +1,39 @@
1
+ import { Logger } from './logging/Logger.js';
2
+
3
+ /**
4
+ * HtmlElementParser wraps a single parsed HTML element and extracts attribute values,
5
+ * logging a warning when the requested attribute is absent.
6
+ * @author darthjee
7
+ */
8
+ class HtmlElementParser {
9
+ #element;
10
+ #selector;
11
+
12
+ /**
13
+ * @param {object} element A parsed HTML element with a `getAttribute` method.
14
+ * @param {string} selector The CSS selector that matched this element (used in warning messages).
15
+ */
16
+ constructor(element, selector) {
17
+ this.#element = element;
18
+ this.#selector = selector;
19
+ }
20
+
21
+ /**
22
+ * Returns the value of the named attribute, or `null` if the attribute is absent.
23
+ * Logs a warning when the attribute is absent.
24
+ * @param {string} attribute Attribute name to extract.
25
+ * @returns {string|null} The attribute value, or `null` when absent.
26
+ */
27
+ getAttribute(attribute) {
28
+ const value = this.#element.getAttribute(attribute);
29
+
30
+ if (value === undefined || value === null) {
31
+ Logger.warn(`HtmlParser: element matched by "${this.#selector}" is missing attribute "${attribute}"`);
32
+ return null;
33
+ }
34
+
35
+ return value;
36
+ }
37
+ }
38
+
39
+ export { HtmlElementParser };
@@ -0,0 +1,49 @@
1
+ import { parse } from 'node-html-parser';
2
+ import { HtmlElementParser } from './HtmlElementParser.js';
3
+ import { InvalidHtmlResponseBody } from '../exceptions/InvalidHtmlResponseBody.js';
4
+ import { Logger } from './logging/Logger.js';
5
+
6
+ /**
7
+ * HtmlParser parses a raw HTML string and extracts attribute values using CSS selectors.
8
+ * @author darthjee
9
+ */
10
+ class HtmlParser {
11
+ /**
12
+ * Parses the given HTML string, finds all elements matching the selector,
13
+ * and returns an array of the specified attribute value from each matched element.
14
+ *
15
+ * Logs a warning when the selector matches zero elements.
16
+ * Logs a warning and skips elements missing the target attribute.
17
+ * @param {string} rawHtml The raw HTML string to parse.
18
+ * @param {string} selector CSS selector to match elements.
19
+ * @param {string} attribute Attribute name whose value is extracted from each matched element.
20
+ * @returns {Array<string>} Array of attribute values from matched elements.
21
+ * @throws {InvalidHtmlResponseBody} If the HTML cannot be parsed.
22
+ */
23
+ static parse(rawHtml, selector, attribute) {
24
+ let root;
25
+
26
+ try {
27
+ root = parse(rawHtml);
28
+ } catch (cause) {
29
+ throw new InvalidHtmlResponseBody(rawHtml, cause);
30
+ }
31
+
32
+ const elements = root.querySelectorAll(selector);
33
+
34
+ if (elements.length === 0) {
35
+ Logger.warn(`HtmlParser: selector "${selector}" matched zero elements`);
36
+ return [];
37
+ }
38
+
39
+ const values = [];
40
+ for (const element of elements) {
41
+ const value = new HtmlElementParser(element, selector).getAttribute(attribute);
42
+ if (value !== null) values.push(value);
43
+ }
44
+
45
+ return values;
46
+ }
47
+ }
48
+
49
+ export { HtmlParser };
@@ -12,6 +12,15 @@ class Collection {
12
12
  hasAny() {
13
13
  return this.size() > 0;
14
14
  }
15
+
16
+ /**
17
+ * Searches for an item with the given id.
18
+ * @param {string} id - The id to search for.
19
+ * @returns {object|null} The matching item, or null if not found.
20
+ */
21
+ findById(id) {
22
+ return this.list().find(item => item.id === id) ?? null;
23
+ }
15
24
  }
16
25
 
17
26
  export { Collection };
@@ -54,6 +54,15 @@ class IdentifyableCollection extends Collection {
54
54
  return this.#items[id] !== undefined;
55
55
  }
56
56
 
57
+ /**
58
+ * Searches for an item with the given id.
59
+ * @param {string} id - The id to search for.
60
+ * @returns {object|null} The matching item, or null if not found.
61
+ */
62
+ findById(id) {
63
+ return this.get(id) ?? null;
64
+ }
65
+
57
66
  /**
58
67
  * Retrieves an item from the collection by index.
59
68
  * @param {number} index - The index of the item to retrieve.
@@ -40,6 +40,14 @@ class Queue extends Collection {
40
40
  size() {
41
41
  return this.items.length;
42
42
  }
43
+
44
+ /**
45
+ * Returns a shallow copy of all items in the queue, preserving FIFO order.
46
+ * @returns {Array} A copy of all items.
47
+ */
48
+ list() {
49
+ return [...this.items];
50
+ }
43
51
  }
44
52
 
45
53
  export { Queue };
@@ -20,44 +20,49 @@ class BaseLogger {
20
20
  * Outputs a message at the given level. Override in subclasses.
21
21
  * @param {string} _level - The log level.
22
22
  * @param {string} _message - The message to output.
23
+ * @param {object} _attributes - The structured metadata for the log entry.
23
24
  * @returns {void}
24
25
  */
25
- _output(_level, _message) {}
26
+ _output(_level, _message, _attributes) {}
26
27
 
27
28
  /**
28
29
  * Logs a debug message if the configured level allows it.
29
30
  * @param {string} message - The message to log.
31
+ * @param {object} [attributes={}] - Optional structured metadata.
30
32
  * @returns {void}
31
33
  */
32
- debug(message) {
33
- if (this.#shouldLog('debug')) this._output('debug', message);
34
+ debug(message, attributes = {}) {
35
+ if (this.#shouldLog('debug')) this._output('debug', message, attributes);
34
36
  }
35
37
 
36
38
  /**
37
39
  * Logs an info message if the configured level allows it.
38
40
  * @param {string} message - The message to log.
41
+ * @param {object} [attributes={}] - Optional structured metadata.
39
42
  * @returns {void}
40
43
  */
41
- info(message) {
42
- if (this.#shouldLog('info')) this._output('info', message);
44
+ info(message, attributes = {}) {
45
+ if (this.#shouldLog('info')) this._output('info', message, attributes);
43
46
  }
44
47
 
45
48
  /**
46
49
  * Logs a warn message if the configured level allows it.
47
50
  * @param {string} message - The message to log.
51
+ * @param {object} [attributes={}] - Optional structured metadata.
48
52
  * @returns {void}
49
53
  */
50
- warn(message) {
51
- if (this.#shouldLog('warn')) this._output('warn', message);
54
+ warn(message, attributes = {}) {
55
+ if (this.#shouldLog('warn')) this._output('warn', message, attributes);
52
56
  }
53
57
 
54
58
  /**
55
59
  * Logs an error message if the configured level allows it.
56
60
  * @param {string} message - The message to log.
61
+ * @param {object} [attributes={}] - Optional structured metadata.
57
62
  * @returns {void}
58
63
  */
59
- error(message) {
60
- if (this.#shouldLog('error')) this._output('error', message);
64
+ error(message, attributes = {}) {
65
+ if (this.#shouldLog('error')) this._output('error', message, attributes);
61
66
  }
62
67
 
63
68
  /**
@@ -23,10 +23,11 @@ class BufferedLogger extends BaseLogger {
23
23
  * Stores the message in the buffer.
24
24
  * @param {string} level - The log level ('debug', 'info', 'warn', 'error').
25
25
  * @param {string} message - The message to output.
26
+ * @param {object} [attributes={}] - Optional structured metadata for the log entry.
26
27
  * @returns {void}
27
28
  */
28
- _output(level, message) {
29
- this.#buffer.add(level, message);
29
+ _output(level, message, attributes = {}) {
30
+ this.#buffer.add(level, message, attributes);
30
31
  }
31
32
 
32
33
  /**
@@ -9,10 +9,11 @@ class ConsoleLogger extends BaseLogger {
9
9
  * Writes a message to the console at the given level.
10
10
  * @param {string} level - One of 'debug', 'info', 'warn', 'error'.
11
11
  * @param {string} message - The message to output.
12
+ * @param {object} [attributes={}] - Optional structured metadata to output alongside the message.
12
13
  * @returns {void}
13
14
  */
14
- _output(level, message) {
15
- console[level](message); // eslint-disable-line no-console
15
+ _output(level, message, attributes = {}) {
16
+ console[level](message, attributes); // eslint-disable-line no-console
16
17
  }
17
18
  }
18
19
 
@@ -1,11 +1,12 @@
1
1
  /**
2
- * Represents a single log entry with id, level, message and timestamp.
2
+ * Represents a single log entry with id, level, message, attributes and timestamp.
3
3
  * @author darthjee
4
4
  */
5
5
  class Log {
6
6
  #id;
7
7
  #level;
8
8
  #message;
9
+ #attributes;
9
10
  #timestamp;
10
11
 
11
12
  /**
@@ -13,11 +14,13 @@ class Log {
13
14
  * @param {number} id - Unique incremental identifier for this log.
14
15
  * @param {string} level - The log level (debug, info, warn, error).
15
16
  * @param {string} message - The log message.
17
+ * @param {object} [attributes={}] - Optional structured metadata for the log entry.
16
18
  */
17
- constructor(id, level, message) {
19
+ constructor(id, level, message, attributes = {}) {
18
20
  this.#id = id;
19
21
  this.#level = level;
20
22
  this.#message = message;
23
+ this.#attributes = attributes;
21
24
  this.#timestamp = new Date();
22
25
  }
23
26
 
@@ -45,6 +48,14 @@ class Log {
45
48
  return this.#message;
46
49
  }
47
50
 
51
+ /**
52
+ * Gets the log attributes.
53
+ * @returns {object} The structured metadata attached to this log entry.
54
+ */
55
+ get attributes() {
56
+ return this.#attributes;
57
+ }
58
+
48
59
  /**
49
60
  * Gets the log timestamp.
50
61
  * @returns {Date} The timestamp when the log was created.
@@ -62,6 +73,7 @@ class Log {
62
73
  id: this.#id,
63
74
  level: this.#level,
64
75
  message: this.#message,
76
+ attributes: this.#attributes,
65
77
  timestamp: this.#timestamp.toISOString()
66
78
  };
67
79
  }
@@ -25,10 +25,11 @@ class LogBuffer {
25
25
  * If retention limit is reached, removes the oldest log.
26
26
  * @param {string} level - The log level.
27
27
  * @param {string} message - The log message.
28
+ * @param {object} [attributes={}] - Optional structured metadata for the log entry.
28
29
  * @returns {import('./Log.js').Log} The created log entry.
29
30
  */
30
- add(level, message) {
31
- const log = this.#factory.build(level, message);
31
+ add(level, message, attributes = {}) {
32
+ const log = this.#factory.build(level, message, attributes);
32
33
 
33
34
  this.#logs.push(log);
34
35
 
@@ -21,11 +21,12 @@ class LogFactory {
21
21
  * Builds a new Log entry with an auto-assigned id.
22
22
  * @param {string} level - The log level.
23
23
  * @param {string} message - The log message.
24
+ * @param {object} [attributes={}] - Optional structured metadata for the log entry.
24
25
  * @returns {Log} The created log entry.
25
26
  */
26
- build(level, message) {
27
+ build(level, message, attributes = {}) {
27
28
  const id = this.#idGenerator.generate();
28
- return new Log(id, level, message);
29
+ return new Log(id, level, message, attributes);
29
30
  }
30
31
  }
31
32
 
@@ -42,37 +42,41 @@ class Logger {
42
42
  /**
43
43
  * Logs a debug message using the default logger instance.
44
44
  * @param {string} message - The message to log.
45
+ * @param {object} [attributes={}] - Optional structured metadata.
45
46
  * @returns {void}
46
47
  */
47
- static debug(message) {
48
- this.default().debug(message);
48
+ static debug(message, attributes = {}) {
49
+ this.default().debug(message, attributes);
49
50
  }
50
51
 
51
52
  /**
52
53
  * Logs an info message using the default logger instance.
53
54
  * @param {string} message - The message to log.
55
+ * @param {object} [attributes={}] - Optional structured metadata.
54
56
  * @returns {void}
55
57
  */
56
- static info(message) {
57
- this.default().info(message);
58
+ static info(message, attributes = {}) {
59
+ this.default().info(message, attributes);
58
60
  }
59
61
 
60
62
  /**
61
63
  * Logs a warn message using the default logger instance.
62
64
  * @param {string} message - The message to log.
65
+ * @param {object} [attributes={}] - Optional structured metadata.
63
66
  * @returns {void}
64
67
  */
65
- static warn(message) {
66
- this.default().warn(message);
68
+ static warn(message, attributes = {}) {
69
+ this.default().warn(message, attributes);
67
70
  }
68
71
 
69
72
  /**
70
73
  * Logs an error message using the default logger instance.
71
74
  * @param {string} message - The message to log.
75
+ * @param {object} [attributes={}] - Optional structured metadata.
72
76
  * @returns {void}
73
77
  */
74
- static error(message) {
75
- this.default().error(message);
78
+ static error(message, attributes = {}) {
79
+ this.default().error(message, attributes);
76
80
  }
77
81
 
78
82
  /**
@@ -45,37 +45,41 @@ class LoggerGroup {
45
45
  /**
46
46
  * Broadcasts a debug message to all loggers in the group.
47
47
  * @param {string} message - The message to log.
48
+ * @param {object} [attributes={}] - Optional structured metadata.
48
49
  * @returns {void}
49
50
  */
50
- debug(message) {
51
- this.#loggers.forEach(logger => logger.debug(message));
51
+ debug(message, attributes = {}) {
52
+ this.#loggers.forEach(logger => logger.debug(message, attributes));
52
53
  }
53
54
 
54
55
  /**
55
56
  * Broadcasts an info message to all loggers in the group.
56
57
  * @param {string} message - The message to log.
58
+ * @param {object} [attributes={}] - Optional structured metadata.
57
59
  * @returns {void}
58
60
  */
59
- info(message) {
60
- this.#loggers.forEach(logger => logger.info(message));
61
+ info(message, attributes = {}) {
62
+ this.#loggers.forEach(logger => logger.info(message, attributes));
61
63
  }
62
64
 
63
65
  /**
64
66
  * Broadcasts a warn message to all loggers in the group.
65
67
  * @param {string} message - The message to log.
68
+ * @param {object} [attributes={}] - Optional structured metadata.
66
69
  * @returns {void}
67
70
  */
68
- warn(message) {
69
- this.#loggers.forEach(logger => logger.warn(message));
71
+ warn(message, attributes = {}) {
72
+ this.#loggers.forEach(logger => logger.warn(message, attributes));
70
73
  }
71
74
 
72
75
  /**
73
76
  * Broadcasts an error message to all loggers in the group.
74
77
  * @param {string} message - The message to log.
78
+ * @param {object} [attributes={}] - Optional structured metadata.
75
79
  * @returns {void}
76
80
  */
77
- error(message) {
78
- this.#loggers.forEach(logger => logger.error(message));
81
+ error(message, attributes = {}) {
82
+ this.#loggers.forEach(logger => logger.error(message, attributes));
79
83
  }
80
84
 
81
85
  /**
package/package.json CHANGED
@@ -1,19 +1,24 @@
1
1
  {
2
2
  "name": "navi-hey",
3
3
  "type": "module",
4
- "version": "0.4.0",
4
+ "version": "0.5.1",
5
5
  "description": "Navi cache warmer CLI",
6
+ "readme": "README.md",
6
7
  "main": "index.js",
7
8
  "bin": {
8
9
  "navi-hey": "bin/navi.js"
9
10
  },
10
- "files": ["bin", "lib"],
11
+ "files": [
12
+ "bin",
13
+ "lib",
14
+ "static"
15
+ ],
11
16
  "scripts": {
12
17
  "spec": "npx jasmine spec/**/*.js",
13
18
  "test": "npx c8 jasmine spec/**/*.js",
14
19
  "coverage": "npx c8 --reporter=lcov jasmine spec/**/*.js",
15
- "lint": "eslint .",
16
- "lint_fix": "eslint . --fix",
20
+ "lint": "eslint lib spec",
21
+ "lint_fix": "eslint lib spec --fix",
17
22
  "lint_report": "eslint . --format html --output-file report/eslint-report.html",
18
23
  "report": "jscpd lib spec --reporters console,html --output ./report/jscpd",
19
24
  "docs": "jsdoc -c jsdoc.json",
@@ -24,6 +29,7 @@
24
29
  "dependencies": {
25
30
  "axios": "^1.13.0",
26
31
  "express": "5.2.1",
32
+ "node-html-parser": "7.1.0",
27
33
  "yaml": "^2.8.2"
28
34
  },
29
35
  "devDependencies": {