@goodandready/dsh-dsml-artifact-guard 0.2.6 → 0.2.7
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/CHANGELOG.md +5 -0
- package/lib/index.js +27 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
---
|
|
9
9
|
|
|
10
|
+
## [0.2.7] - 2026-09-25
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
- **Volatile Config Unwrapping**: introduced `unwrapConfig` helper to gracefully handle pre-resolved volatile schema references passed by Cordis to `apply` and `ctx.on('config')`, avoiding TypeError on functions inside volatile schemas (#47).
|
|
14
|
+
|
|
10
15
|
## [0.2.6] - 2026-09-25
|
|
11
16
|
|
|
12
17
|
### Fixed
|
package/lib/index.js
CHANGED
|
@@ -107,16 +107,40 @@ export async function* sanitizeDsmlArtifacts(s, { mode = 'sanitize', onArtifact
|
|
|
107
107
|
yield* flush(true);
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
+
export function unwrapConfig(conf) {
|
|
111
|
+
if (!conf) return {};
|
|
112
|
+
if (typeof conf.get === 'function') {
|
|
113
|
+
try {
|
|
114
|
+
const val = conf.get();
|
|
115
|
+
return (val && typeof val === 'object') ? val : {};
|
|
116
|
+
} catch (err) {
|
|
117
|
+
/* Volatile getter failed */
|
|
118
|
+
return {};
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
try {
|
|
122
|
+
const res = Config(conf);
|
|
123
|
+
if (res && typeof res.get === 'function') {
|
|
124
|
+
const val = res.get();
|
|
125
|
+
return (val && typeof val === 'object') ? val : {};
|
|
126
|
+
}
|
|
127
|
+
return (res && typeof res === 'object') ? res : {};
|
|
128
|
+
} catch (err) {
|
|
129
|
+
/* Config validation fallback to object */
|
|
130
|
+
return (conf && typeof conf === 'object') ? conf : {};
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
110
134
|
export function apply(ctx, initialConfig = {}) {
|
|
111
135
|
const NS = '@goodandready/dsh-dsml-artifact-guard';
|
|
112
|
-
let activeConfig =
|
|
136
|
+
let activeConfig = unwrapConfig(initialConfig);
|
|
113
137
|
|
|
114
|
-
let getConfig = () => activeConfig;
|
|
138
|
+
let getConfig = () => (typeof initialConfig?.get === 'function' ? unwrapConfig(initialConfig) : activeConfig);
|
|
115
139
|
|
|
116
140
|
// Live config subscription from the plugin fiber
|
|
117
141
|
if (typeof ctx.on === 'function') {
|
|
118
142
|
ctx.effect(() => ctx.on('config', (nextConfig) => {
|
|
119
|
-
activeConfig =
|
|
143
|
+
activeConfig = unwrapConfig(nextConfig);
|
|
120
144
|
}), 'dsh-dsml-artifact-guard: live config');
|
|
121
145
|
}
|
|
122
146
|
|