@combycode/dpe-framework-ts 2.0.3 → 2.1.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 CHANGED
@@ -97,6 +97,8 @@ tool is wired into a pipeline — see `docs/testing.md`.
97
97
 
98
98
  ## Repo & licence
99
99
 
100
- - Source: <https://github.com/combycode/dpe-framework-ts>
101
- - Monorepo (canonical): <https://github.com/combycode/dpe>
100
+ - Source: <https://github.com/combycode/dpe/tree/main/frameworks/ts>
101
+ - Monorepo: <https://github.com/combycode/dpe>
102
+ - Issues: <https://github.com/combycode/dpe/issues>
103
+ - Changelog: <https://github.com/combycode/dpe/blob/main/CHANGELOG.md>
102
104
  - Licence: AGPL-3.0-or-later
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@combycode/dpe-framework-ts",
3
- "version": "2.0.3",
3
+ "version": "2.1.0",
4
4
  "description": "DPE framework for building streaming pipeline tools in TypeScript/Bun",
5
5
  "license": "AGPL-3.0-or-later",
6
6
  "repository": {
@@ -23,9 +23,9 @@
23
23
  "test": "bun test"
24
24
  },
25
25
  "devDependencies": {
26
- "@types/bun": "^1.3.13",
27
- "ajv": "^8.17.1",
28
- "typescript": "^5.9.0"
26
+ "@types/bun": "^1.4.4",
27
+ "ajv": "^8.20.0",
28
+ "typescript": "^7.0.2"
29
29
  },
30
30
  "files": [
31
31
  "src/",
package/src/paths.ts CHANGED
@@ -6,6 +6,8 @@
6
6
  * Output side (context.output / context.meta): absolute path -> $token/subpath
7
7
  *
8
8
  * Both sides are a no-op when the DPE_* env vars are not set.
9
+ * `DPE_PATH_TOKENS=off` (also `0` / `false` / `no`) turns the output side off; the
10
+ * runner sets it from the variant's / stage's `path_tokens`. Input resolution stays on.
9
11
  */
10
12
 
11
13
  import type { JSONValue } from './envelope';
@@ -24,9 +26,17 @@ interface Entry {
24
26
  abs: string;
25
27
  }
26
28
 
29
+ /** True unless `DPE_PATH_TOKENS` is `off`, `0`, `false` or `no` (any case). */
30
+ export function tokensEnabledFromEnv(): boolean {
31
+ const v = process.env.DPE_PATH_TOKENS;
32
+ if (v == null) return true;
33
+ return !['off', '0', 'false', 'no'].includes(v.trim().toLowerCase());
34
+ }
35
+
27
36
  /** Resolved env prefix map. Build once at tool startup; cheap to clone. */
28
37
  export class EnvPaths {
29
38
  private entries: Entry[];
39
+ private noTokenize: boolean;
30
40
 
31
41
  /**
32
42
  * If `pairs` is provided, use those (token, abs_path) pairs directly.
@@ -48,6 +58,18 @@ export class EnvPaths {
48
58
 
49
59
  // Sort longest-abs-first for greedy tokenization.
50
60
  this.entries = raw.sort((a, b) => b.abs.length - a.abs.length);
61
+ this.noTokenize = pairs == null ? !tokensEnabledFromEnv() : false;
62
+ }
63
+
64
+ /** Turn the output side (absolute path -> `$token`) on or off. */
65
+ withTokenize(on: boolean): EnvPaths {
66
+ this.noTokenize = !on;
67
+ return this;
68
+ }
69
+
70
+ /** Whether `tokenizeValue` rewrites anything. */
71
+ tokenizeEnabled(): boolean {
72
+ return !this.noTokenize;
51
73
  }
52
74
 
53
75
  /** Read the standard DPE_* env vars; missing/empty vars are skipped. */
@@ -72,7 +94,7 @@ export class EnvPaths {
72
94
 
73
95
  /** Walk v, tokenizing absolute paths back to $token[/subpath] form. */
74
96
  tokenizeValue(v: JSONValue): JSONValue {
75
- if (this.isEmpty()) return v;
97
+ if (this.isEmpty() || this.noTokenize) return v;
76
98
  return this.walk(v, (s) => this.tokenizeStr(s));
77
99
  }
78
100