@onlineapps/content-resolver 2.0.0 → 3.0.0-rc.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 CHANGED
@@ -32,7 +32,7 @@ const resolver = new ContentResolver({
32
32
  accessKey: 'minioadmin',
33
33
  secretKey: 'minioadmin'
34
34
  },
35
- logger // required - the constructor throws without a logger exposing warn()
35
+ logger // required - the constructor throws unless it exposes info/warn/error/debug
36
36
  });
37
37
 
38
38
  // Resolve reference to content
@@ -81,7 +81,7 @@ exports.processDocument = async (input, context = {}) => {
81
81
  |--------|------|---------|-------------|
82
82
  | `threshold` | number | 16384 | Size threshold in bytes |
83
83
  | `storage` | Object | env-based | Storage connector config |
84
- | `logger` | Object | **required** | Logger instance — must expose `warn()`. The constructor throws without it (`src/index.js`); there is no `console` default. |
84
+ | `logger` | Object | **required** | Logger instance — must expose `info()`, `warn()`, `error()` and `debug()`, all four as functions. The constructor throws without it, and names the missing method (`src/index.js`); there is no `console` default. The four are what `@onlineapps/conn-base-storage` demands of the connector this class builds, so validating fewer here only moved the failure later (owner confirmation `connector-logger-contract` 001). |
85
85
 
86
86
  ### Input contract
87
87
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onlineapps/content-resolver",
3
- "version": "2.0.0",
3
+ "version": "3.0.0-rc.1",
4
4
  "description": "Automatic conversion between text content and storage references with Content Descriptor pattern",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -18,7 +18,7 @@
18
18
  "author": "OnlineApps",
19
19
  "license": "ISC",
20
20
  "dependencies": {
21
- "@onlineapps/conn-base-storage": "2.0.0",
21
+ "@onlineapps/conn-base-storage": "3.0.0",
22
22
  "@onlineapps/runtime-config": "1.0.3"
23
23
  },
24
24
  "devDependencies": {
package/src/index.js CHANGED
@@ -17,6 +17,10 @@ const runtimeCfg = require('./config');
17
17
  // Backward-compatible constant export (module-owned default, not ENV override)
18
18
  const DEFAULT_THRESHOLD = DEFAULTS.thresholdBytes;
19
19
 
20
+ // The logger methods this module and the storage connector it builds both
21
+ // require — the order is the order the error message lists them in.
22
+ const LOGGER_METHODS = ['info', 'warn', 'error', 'debug'];
23
+
20
24
  // Reference patterns
21
25
  const MINIO_REF_PATTERN = /^minio:\/\/([^/]+)\/(.+)$/;
22
26
  const INTERNAL_REF_PATTERN = /^internal:\/\/storage\/(.+)$/;
@@ -178,14 +182,35 @@ class ContentResolver {
178
182
  * @param {Object} options - Configuration options
179
183
  * @param {number} [options.threshold=16384] - Size threshold in bytes (default 16KB)
180
184
  * @param {Object} [options.storage] - Storage connector config or instance
181
- * @param {Object} [options.logger] - Logger instance
185
+ * @param {Object} options.logger - REQUIRED. Logger with info/warn/error/debug.
182
186
  */
183
187
  constructor(options = {}) {
184
188
  const resolved = runtimeCfg.resolve(options);
185
189
  this.threshold = resolved.threshold;
186
- if (!options.logger || typeof options.logger.warn !== 'function') {
187
- throw new Error('[ContentResolver] Logger is required Expected object with warn() method');
190
+ // The logger is INJECTED and validated in full, HERE. Until 2026-09-03 only
191
+ // `warn()` was checked, while the same object was handed to
192
+ // `StorageConnector`, which demands all four (conn-base-storage 3.0.0
193
+ // src/index.js:89-95). A three-method logger therefore constructed fine and
194
+ // failed later, on the first storage access — delayed validation, which
195
+ // architecture-principles.md §4 forbids. Owner confirmation:
196
+ // docs/governance/confirmations/connector-logger-contract.md 001.
197
+ if (!options.logger) {
198
+ throw new Error(
199
+ '[ContentResolver] logger is required - Expected: a logger with info/warn/error/debug, '
200
+ + 'so the resolver and the connector it builds write where the service writes. '
201
+ + 'Fix: pass options.logger (e.g. the logger your service already built).'
202
+ );
203
+ }
204
+
205
+ const missing = LOGGER_METHODS.filter((method) => typeof options.logger[method] !== 'function');
206
+ if (missing.length > 0) {
207
+ throw new Error(
208
+ '[ContentResolver] logger is incomplete - Expected: info, warn, error, debug as functions; '
209
+ + `missing: ${missing.join(', ')}. `
210
+ + 'Fix: pass a logger implementing all four.'
211
+ );
188
212
  }
213
+
189
214
  this.logger = options.logger;
190
215
 
191
216
  // Storage can be passed as instance or config (no fallbacks - fail-fast)
@@ -220,7 +245,10 @@ class ContentResolver {
220
245
  if (config.endPoint) {
221
246
  config.endPoint = config.endPoint.replace(/^https?:\/\//, '');
222
247
  }
223
- this.storage = new StorageConnector(config);
248
+ // The connector requires an injected logger (conn-base-storage 3.0.0,
249
+ // architecture-principles.md §1). ContentResolver already fail-fasts on
250
+ // its own logger, so it has one to give.
251
+ this.storage = new StorageConnector({ ...config, logger: this.logger });
224
252
  await this.storage.initialize();
225
253
  }
226
254
  return this.storage;