@shardworks/spider-apparatus 0.1.304 → 0.1.306
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.
|
@@ -15,8 +15,17 @@
|
|
|
15
15
|
* - `givens` (optional, object) — caller-supplied key/value pairs. Each
|
|
16
16
|
* `${vars.<key>}` reference in the resolved template's engine givens is
|
|
17
17
|
* substituted with the matching value. References that do not match any
|
|
18
|
-
* caller-given key, and all `${writ}` / `${yields.*}` references
|
|
19
|
-
* left intact for Spider's normal
|
|
18
|
+
* caller-given key, and all `${writ}` / `${yields.*}` references in the
|
|
19
|
+
* template's engine givens, are left intact for Spider's normal
|
|
20
|
+
* spawn-time and run-time resolution.
|
|
21
|
+
*
|
|
22
|
+
* `${yields.<engineId>.<path>}` references *inside the caller-supplied
|
|
23
|
+
* overlay's own string values* are resolved against this engine's
|
|
24
|
+
* `context.upstream` before substitution. This lets a caller pass
|
|
25
|
+
* dynamic values produced by upstream fixtures into the template (e.g.
|
|
26
|
+
* `cwd: '${yields.fixture-codex-checkout-setup.workdir}'`) — Spider's
|
|
27
|
+
* own `resolveYieldRefs` only walks top-level givens and would otherwise
|
|
28
|
+
* leave such refs unresolved through the nested `givens.givens` map.
|
|
20
29
|
*
|
|
21
30
|
* graftTail rule:
|
|
22
31
|
* If the resolved template declares a `resolutionEngine`, that engine id is
|
|
@@ -24,7 +33,9 @@
|
|
|
24
33
|
* `engines` array (declaration order) is used.
|
|
25
34
|
*
|
|
26
35
|
* Yields:
|
|
27
|
-
* `{ template: <name>, givens: <caller givens
|
|
36
|
+
* `{ template: <name>, givens: <caller givens with overlay yields resolved> }`
|
|
37
|
+
* The echoed `givens` is the post-resolution overlay, so trial-archive
|
|
38
|
+
* inspection shows what values were actually substituted.
|
|
28
39
|
*
|
|
29
40
|
* Failure modes:
|
|
30
41
|
* - `givens.template` not a non-empty string — throws immediately.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graft-rig-template.d.ts","sourceRoot":"","sources":["../../src/engines/graft-rig-template.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"graft-rig-template.d.ts","sourceRoot":"","sources":["../../src/engines/graft-rig-template.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAqC,MAAM,kCAAkC,CAAC;AAgDxG,QAAA,MAAM,sBAAsB,EAAE,YAsG7B,CAAC;AAEF,eAAe,sBAAsB,CAAC"}
|
|
@@ -15,8 +15,17 @@
|
|
|
15
15
|
* - `givens` (optional, object) — caller-supplied key/value pairs. Each
|
|
16
16
|
* `${vars.<key>}` reference in the resolved template's engine givens is
|
|
17
17
|
* substituted with the matching value. References that do not match any
|
|
18
|
-
* caller-given key, and all `${writ}` / `${yields.*}` references
|
|
19
|
-
* left intact for Spider's normal
|
|
18
|
+
* caller-given key, and all `${writ}` / `${yields.*}` references in the
|
|
19
|
+
* template's engine givens, are left intact for Spider's normal
|
|
20
|
+
* spawn-time and run-time resolution.
|
|
21
|
+
*
|
|
22
|
+
* `${yields.<engineId>.<path>}` references *inside the caller-supplied
|
|
23
|
+
* overlay's own string values* are resolved against this engine's
|
|
24
|
+
* `context.upstream` before substitution. This lets a caller pass
|
|
25
|
+
* dynamic values produced by upstream fixtures into the template (e.g.
|
|
26
|
+
* `cwd: '${yields.fixture-codex-checkout-setup.workdir}'`) — Spider's
|
|
27
|
+
* own `resolveYieldRefs` only walks top-level givens and would otherwise
|
|
28
|
+
* leave such refs unresolved through the nested `givens.givens` map.
|
|
20
29
|
*
|
|
21
30
|
* graftTail rule:
|
|
22
31
|
* If the resolved template declares a `resolutionEngine`, that engine id is
|
|
@@ -24,7 +33,9 @@
|
|
|
24
33
|
* `engines` array (declaration order) is used.
|
|
25
34
|
*
|
|
26
35
|
* Yields:
|
|
27
|
-
* `{ template: <name>, givens: <caller givens
|
|
36
|
+
* `{ template: <name>, givens: <caller givens with overlay yields resolved> }`
|
|
37
|
+
* The echoed `givens` is the post-resolution overlay, so trial-archive
|
|
38
|
+
* inspection shows what values were actually substituted.
|
|
28
39
|
*
|
|
29
40
|
* Failure modes:
|
|
30
41
|
* - `givens.template` not a non-empty string — throws immediately.
|
|
@@ -32,10 +43,51 @@
|
|
|
32
43
|
* - Named template not found in registry — throws with the template name.
|
|
33
44
|
*/
|
|
34
45
|
import { guild } from '@shardworks/nexus-core';
|
|
35
|
-
import { interpolateTemplate, SKIP } from "../template.js";
|
|
46
|
+
import { interpolateTemplate, resolveDotPath, SKIP } from "../template.js";
|
|
47
|
+
/**
|
|
48
|
+
* Resolve `${yields.<engineId>.<path>}` references in the caller's overlay
|
|
49
|
+
* against this engine's upstream. Other expressions (`${writ}`, `${vars.*}`,
|
|
50
|
+
* etc.) are left untouched — they're not part of the overlay's contract.
|
|
51
|
+
*
|
|
52
|
+
* Mirrors Spider's run-time `resolveYieldRefs` semantics: walks top-level
|
|
53
|
+
* string values only, drops keys whose whole-value resolution yields
|
|
54
|
+
* undefined, leaves non-string values literal.
|
|
55
|
+
*
|
|
56
|
+
* Without this pre-pass, callers can't pass `${yields.X.Y}` substitutions
|
|
57
|
+
* through the overlay because Spider's spawn-time and run-time resolution
|
|
58
|
+
* don't recurse into nested objects (and `givens.givens` is itself a
|
|
59
|
+
* nested object on the engine's outer givens map).
|
|
60
|
+
*/
|
|
61
|
+
function resolveOverlayYields(overlay, upstream) {
|
|
62
|
+
const result = {};
|
|
63
|
+
for (const [key, value] of Object.entries(overlay)) {
|
|
64
|
+
if (typeof value !== 'string' || !value.includes('${')) {
|
|
65
|
+
result[key] = value;
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
const resolved = interpolateTemplate(value, (expr) => {
|
|
69
|
+
if (!expr.startsWith('yields.')) {
|
|
70
|
+
return SKIP; // not a yield ref — leave it alone
|
|
71
|
+
}
|
|
72
|
+
const withoutPrefix = expr.slice('yields.'.length);
|
|
73
|
+
const dotIndex = withoutPrefix.indexOf('.');
|
|
74
|
+
if (dotIndex < 0)
|
|
75
|
+
return undefined; // malformed — drop the key
|
|
76
|
+
const engineId = withoutPrefix.slice(0, dotIndex);
|
|
77
|
+
const propPath = withoutPrefix.slice(dotIndex + 1);
|
|
78
|
+
const engineYields = upstream[engineId];
|
|
79
|
+
return resolveDotPath(engineYields, propPath);
|
|
80
|
+
});
|
|
81
|
+
if (resolved !== undefined) {
|
|
82
|
+
result[key] = resolved;
|
|
83
|
+
}
|
|
84
|
+
// undefined whole-value → omit key (matches resolveYieldRefs)
|
|
85
|
+
}
|
|
86
|
+
return result;
|
|
87
|
+
}
|
|
36
88
|
const graftRigTemplateEngine = {
|
|
37
89
|
id: 'spider.graft-rig-template',
|
|
38
|
-
async run(givens,
|
|
90
|
+
async run(givens, context) {
|
|
39
91
|
// ── Input validation ──────────────────────────────────────────────
|
|
40
92
|
const templateName = givens.template;
|
|
41
93
|
if (typeof templateName !== 'string' || templateName.trim() === '') {
|
|
@@ -47,7 +99,13 @@ const graftRigTemplateEngine = {
|
|
|
47
99
|
throw new Error(`spider.graft-rig-template: givens.givens must be a plain object or omitted` +
|
|
48
100
|
` (got ${Array.isArray(callerGivens) ? 'array' : JSON.stringify(callerGivens)})`);
|
|
49
101
|
}
|
|
50
|
-
const
|
|
102
|
+
const rawOverlay = (callerGivens ?? {});
|
|
103
|
+
// ── Resolve ${yields.X} refs inside the overlay ───────────────────
|
|
104
|
+
// Spider's resolveYieldRefs at run time only walks top-level givens
|
|
105
|
+
// and stops at non-string values. The overlay is a nested object, so
|
|
106
|
+
// any ${yields.X} refs inside it survive unresolved unless we do this
|
|
107
|
+
// pre-pass against context.upstream here.
|
|
108
|
+
const overlay = resolveOverlayYields(rawOverlay, context.upstream);
|
|
51
109
|
// ── Template lookup ───────────────────────────────────────────────
|
|
52
110
|
const spider = guild().apparatus('spider');
|
|
53
111
|
const template = spider.getTemplate(templateName);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graft-rig-template.js","sourceRoot":"","sources":["../../src/engines/graft-rig-template.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"graft-rig-template.js","sourceRoot":"","sources":["../../src/engines/graft-rig-template.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAG/C,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAE3E;;;;;;;;;;;;;GAaG;AACH,SAAS,oBAAoB,CAC3B,OAAgC,EAChC,QAAiC;IAEjC,MAAM,MAAM,GAA4B,EAAE,CAAC;IAC3C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACnD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YACvD,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;YACpB,SAAS;QACX,CAAC;QACD,MAAM,QAAQ,GAAG,mBAAmB,CAAC,KAAK,EAAE,CAAC,IAAY,EAAE,EAAE;YAC3D,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;gBAChC,OAAO,IAAI,CAAC,CAAC,mCAAmC;YAClD,CAAC;YACD,MAAM,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;YACnD,MAAM,QAAQ,GAAG,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YAC5C,IAAI,QAAQ,GAAG,CAAC;gBAAE,OAAO,SAAS,CAAC,CAAC,2BAA2B;YAC/D,MAAM,QAAQ,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ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AAO,CAAC,MAAM,CAAC,CAAC;wBACzB,CAAC;oBACH,CAAC;oBACD,sEAAsE;oBACtE,OAAO,IAAI,CAAC;gBACd,CAAC,CAAC,CAAC;gBACH,oEAAoE;gBACpE,2EAA2E;gBAC3E,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;oBAC3B,MAAM,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC;gBACzB,CAAC;YACH,CAAC;YACD,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,MAAM,KAAK,GAAwB,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;YACnE,GAAG,MAAM;YACT,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,MAAM,CAAC;SACrC,CAAC,CAAC,CAAC;QAEJ,qEAAqE;QAErE,MAAM,SAAS,GACb,QAAQ,CAAC,gBAAgB,IAAI,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAE,CAAC,EAAE,CAAC;QAEjF,qEAAqE;QAErE,MAAM,MAAM,GAA0B;YACpC,MAAM,EAAE,WAAW;YACnB,MAAM,EAAE,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE;YACnD,KAAK;YACL,SAAS;SACV,CAAC;QAEF,OAAO,MAAyB,CAAC;IACnC,CAAC;CACF,CAAC;AAEF,eAAe,sBAAsB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shardworks/spider-apparatus",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.306",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -22,17 +22,17 @@
|
|
|
22
22
|
"hono": "^4.7.11",
|
|
23
23
|
"yaml": "^2.0.0",
|
|
24
24
|
"zod": "4.3.6",
|
|
25
|
-
"@shardworks/fabricator-apparatus": "0.1.
|
|
26
|
-
"@shardworks/stacks-apparatus": "0.1.
|
|
27
|
-
"@shardworks/
|
|
28
|
-
"@shardworks/
|
|
29
|
-
"@shardworks/
|
|
30
|
-
"@shardworks/
|
|
31
|
-
"@shardworks/
|
|
25
|
+
"@shardworks/fabricator-apparatus": "0.1.306",
|
|
26
|
+
"@shardworks/stacks-apparatus": "0.1.306",
|
|
27
|
+
"@shardworks/animator-apparatus": "0.1.306",
|
|
28
|
+
"@shardworks/codexes-apparatus": "0.1.306",
|
|
29
|
+
"@shardworks/loom-apparatus": "0.1.306",
|
|
30
|
+
"@shardworks/clerk-apparatus": "0.1.306",
|
|
31
|
+
"@shardworks/tools-apparatus": "0.1.306"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@types/node": "25.5.0",
|
|
35
|
-
"@shardworks/nexus-core": "0.1.
|
|
35
|
+
"@shardworks/nexus-core": "0.1.306"
|
|
36
36
|
},
|
|
37
37
|
"files": [
|
|
38
38
|
"dist",
|