@onlineapps/cookbook-template-helpers 1.0.15 → 2.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 +9 -0
- package/package.json +2 -2
- package/src/helpers/fileHelpers.js +25 -2
package/README.md
CHANGED
|
@@ -49,6 +49,15 @@ Převede file/inline descriptor na string (přes ContentResolver). File stáhne
|
|
|
49
49
|
async function file2string(descriptor, context)
|
|
50
50
|
```
|
|
51
51
|
|
|
52
|
+
### Helper context — logger
|
|
53
|
+
|
|
54
|
+
Oba descriptor helpery si staví `ContentResolver`, pokud jim v kontextu nepředáš
|
|
55
|
+
hotový `context.contentResolver`. V tom případě je `context.logger` **povinný** a
|
|
56
|
+
musí mít všechny čtyři metody: `info()`, `warn()`, `error()`, `debug()` — přesně
|
|
57
|
+
to, co vyžaduje `@onlineapps/content-resolver` a za ním `@onlineapps/conn-base-storage`.
|
|
58
|
+
Chybějící logger i logger neúplný padají hned v `getContentResolver()` a hláška
|
|
59
|
+
jmenuje chybějící metodu; žádný `console` fallback neexistuje.
|
|
60
|
+
|
|
52
61
|
## Usage in Cookbook
|
|
53
62
|
|
|
54
63
|
Helpers jsou k dispozici při resolvování template proměnných:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onlineapps/cookbook-template-helpers",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Template helper functions for cookbook variable resolution - string2file, file2string, and more",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"author": "OnlineApps",
|
|
20
20
|
"license": "PROPRIETARY",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@onlineapps/content-resolver": "
|
|
22
|
+
"@onlineapps/content-resolver": "3.0.0"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"jest": "29.7.0"
|
|
@@ -7,6 +7,10 @@
|
|
|
7
7
|
|
|
8
8
|
const ContentResolver = require('@onlineapps/content-resolver');
|
|
9
9
|
|
|
10
|
+
// The logger methods `ContentResolver` requires of the object this module hands
|
|
11
|
+
// it — the order is the order the error message lists them in.
|
|
12
|
+
const LOGGER_METHODS = ['info', 'warn', 'error', 'debug'];
|
|
13
|
+
|
|
10
14
|
/**
|
|
11
15
|
* Normalize string: remove control/unsafe chars, keep letters (incl. diacritics), numbers,
|
|
12
16
|
* whitespace and basic punctuation .,!?;:-_
|
|
@@ -66,8 +70,27 @@ function getContentResolver(helperContext) {
|
|
|
66
70
|
helperContext.data?.step_id ||
|
|
67
71
|
null;
|
|
68
72
|
|
|
69
|
-
|
|
70
|
-
|
|
73
|
+
// The logger goes straight into `ContentResolver`, which demands all four
|
|
74
|
+
// methods (content-resolver src/index.js; conn-base-storage 3.0.0 behind it).
|
|
75
|
+
// Until 2026-09-03 only `warn()` was checked here, so a three-method logger
|
|
76
|
+
// passed this gate and failed one frame down — delayed validation, forbidden
|
|
77
|
+
// by architecture-principles.md §4. Owner confirmation:
|
|
78
|
+
// api/docs/governance/confirmations/connector-logger-contract.md 001.
|
|
79
|
+
if (!helperContext.logger) {
|
|
80
|
+
throw new Error(
|
|
81
|
+
'[cookbook-template-helpers] logger is required - Expected: a logger with info/warn/error/debug, '
|
|
82
|
+
+ 'so the resolver this helper builds writes where the service writes. '
|
|
83
|
+
+ 'Fix: pass context.logger (e.g. the logger your service already built).'
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const missing = LOGGER_METHODS.filter((method) => typeof helperContext.logger[method] !== 'function');
|
|
88
|
+
if (missing.length > 0) {
|
|
89
|
+
throw new Error(
|
|
90
|
+
'[cookbook-template-helpers] logger is incomplete - Expected: info, warn, error, debug as functions; '
|
|
91
|
+
+ `missing: ${missing.join(', ')}. `
|
|
92
|
+
+ 'Fix: pass a logger implementing all four.'
|
|
93
|
+
);
|
|
71
94
|
}
|
|
72
95
|
|
|
73
96
|
return new ContentResolver({
|