@onlineapps/content-resolver 2.0.1 → 3.0.0
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 +2 -2
- package/package.json +1 -1
- package/src/index.js +28 -3
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
|
|
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()
|
|
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
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}
|
|
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
|
-
|
|
187
|
-
|
|
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)
|