@fuzdev/fuz_app 0.135.0 → 0.137.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.
Files changed (104) hide show
  1. package/dist/actions/CLAUDE.md +2 -2
  2. package/dist/actions/action_spec.d.ts +0 -48
  3. package/dist/actions/action_spec.d.ts.map +1 -1
  4. package/dist/actions/transports_ws_backend.d.ts +1 -1
  5. package/dist/actions/transports_ws_backend.js +1 -1
  6. package/dist/auth/CLAUDE.md +8 -2
  7. package/dist/auth/account_action_specs.d.ts +7 -0
  8. package/dist/auth/account_action_specs.d.ts.map +1 -1
  9. package/dist/auth/account_action_specs.js +12 -3
  10. package/dist/auth/account_schema.d.ts +1 -6
  11. package/dist/auth/account_schema.d.ts.map +1 -1
  12. package/dist/auth/account_schema.js +1 -0
  13. package/dist/auth/actor_search_action_specs.d.ts +1 -1
  14. package/dist/auth/actor_search_action_specs.d.ts.map +1 -1
  15. package/dist/auth/actor_search_action_specs.js +3 -6
  16. package/dist/auth/audit_emitter.d.ts +4 -0
  17. package/dist/auth/audit_emitter.d.ts.map +1 -1
  18. package/dist/auth/audit_emitter.js +18 -2
  19. package/dist/auth/cell_action_specs.d.ts +11 -1
  20. package/dist/auth/cell_action_specs.d.ts.map +1 -1
  21. package/dist/auth/cell_action_specs.js +18 -5
  22. package/dist/auth/cell_item_action_specs.d.ts.map +1 -1
  23. package/dist/auth/cell_item_action_specs.js +2 -4
  24. package/dist/auth/password.d.ts +2 -2
  25. package/dist/auth/password.d.ts.map +1 -1
  26. package/dist/auth/password.js +10 -12
  27. package/dist/auth/role_grant_offer_action_specs.d.ts.map +1 -1
  28. package/dist/auth/role_grant_offer_action_specs.js +9 -9
  29. package/dist/auth/role_grant_offer_notifications.d.ts.map +1 -1
  30. package/dist/auth/role_grant_offer_notifications.js +2 -1
  31. package/dist/auth/role_grant_offer_schema.d.ts +1 -1
  32. package/dist/auth/role_grant_offer_schema.d.ts.map +1 -1
  33. package/dist/auth/role_grant_offer_schema.js +4 -7
  34. package/dist/auth/role_schema.d.ts.map +1 -1
  35. package/dist/auth/role_schema.js +5 -4
  36. package/dist/auth/scope_kind_schema.d.ts +10 -0
  37. package/dist/auth/scope_kind_schema.d.ts.map +1 -1
  38. package/dist/auth/scope_kind_schema.js +15 -3
  39. package/dist/cli/args.d.ts +21 -15
  40. package/dist/cli/args.d.ts.map +1 -1
  41. package/dist/cli/args.js +40 -16
  42. package/dist/cli/daemon.d.ts +0 -5
  43. package/dist/cli/daemon.d.ts.map +1 -1
  44. package/dist/cli/help.d.ts +45 -6
  45. package/dist/cli/help.d.ts.map +1 -1
  46. package/dist/cli/help.js +81 -4
  47. package/dist/env/load.d.ts +1 -1
  48. package/dist/env/load.js +1 -1
  49. package/dist/http/CLAUDE.md +1 -1
  50. package/dist/http/auth_shape.d.ts +0 -27
  51. package/dist/http/auth_shape.d.ts.map +1 -1
  52. package/dist/http/body_limit.d.ts +27 -14
  53. package/dist/http/body_limit.d.ts.map +1 -1
  54. package/dist/http/body_limit.js +29 -16
  55. package/dist/http/db_routes.d.ts.map +1 -1
  56. package/dist/http/db_routes.js +5 -3
  57. package/dist/primitive_schemas.d.ts +38 -4
  58. package/dist/primitive_schemas.d.ts.map +1 -1
  59. package/dist/primitive_schemas.js +77 -13
  60. package/dist/server/x_accel.d.ts +0 -1
  61. package/dist/server/x_accel.d.ts.map +1 -1
  62. package/dist/testing/CLAUDE.md +36 -19
  63. package/dist/testing/audit_drift_guard.d.ts +18 -5
  64. package/dist/testing/audit_drift_guard.d.ts.map +1 -1
  65. package/dist/testing/audit_drift_guard.js +24 -8
  66. package/dist/testing/cross_backend/action_manifest.d.ts +0 -14
  67. package/dist/testing/cross_backend/action_manifest.d.ts.map +1 -1
  68. package/dist/testing/cross_backend/body_size.d.ts +18 -5
  69. package/dist/testing/cross_backend/body_size.d.ts.map +1 -1
  70. package/dist/testing/cross_backend/body_size.js +233 -34
  71. package/dist/testing/cross_backend/body_size_smuggling.d.ts +0 -12
  72. package/dist/testing/cross_backend/body_size_smuggling.d.ts.map +1 -1
  73. package/dist/testing/cross_backend/body_size_smuggling.js +92 -147
  74. package/dist/testing/cross_backend/capabilities.d.ts +3 -24
  75. package/dist/testing/cross_backend/capabilities.d.ts.map +1 -1
  76. package/dist/testing/cross_backend/capabilities.js +1 -4
  77. package/dist/testing/cross_backend/cell_crud.d.ts.map +1 -1
  78. package/dist/testing/cross_backend/cell_crud.js +31 -2
  79. package/dist/testing/cross_backend/conformance_case.d.ts +3 -3
  80. package/dist/testing/cross_backend/credential_header_robustness.d.ts.map +1 -1
  81. package/dist/testing/cross_backend/credential_header_robustness.js +18 -54
  82. package/dist/testing/cross_backend/default_backend_configs.d.ts.map +1 -1
  83. package/dist/testing/cross_backend/default_backend_configs.js +2 -8
  84. package/dist/testing/cross_backend/testing_backdoor.d.ts.map +1 -1
  85. package/dist/testing/cross_backend/testing_backdoor.js +2 -0
  86. package/dist/testing/cross_backend/testing_reset_actions.d.ts +5 -9
  87. package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
  88. package/dist/testing/cross_backend/testing_reset_actions.js +5 -0
  89. package/dist/testing/cross_backend/token_lifetime.d.ts.map +1 -1
  90. package/dist/testing/cross_backend/token_lifetime.js +34 -1
  91. package/dist/testing/cross_backend/ts_spine_backend_config.d.ts.map +1 -1
  92. package/dist/testing/cross_backend/ts_spine_backend_config.js +7 -14
  93. package/dist/testing/cross_backend/ws_outbound_overflow.d.ts.map +1 -1
  94. package/dist/testing/cross_backend/ws_outbound_overflow.js +65 -0
  95. package/dist/testing/schema_introspect.d.ts +24 -4
  96. package/dist/testing/schema_introspect.d.ts.map +1 -1
  97. package/dist/testing/schema_introspect.js +27 -4
  98. package/dist/testing/transports/raw_http.d.ts +78 -0
  99. package/dist/testing/transports/raw_http.d.ts.map +1 -0
  100. package/dist/testing/transports/raw_http.js +141 -0
  101. package/package.json +7 -5
  102. package/dist/env/resolve.d.ts +0 -163
  103. package/dist/env/resolve.d.ts.map +0 -1
  104. package/dist/env/resolve.js +0 -267
@@ -1,267 +0,0 @@
1
- /**
2
- * Environment variable `$$VAR$$` resolution suite.
3
- *
4
- * Resolves `$$VAR$$` references in strings and object trees,
5
- * scans configs for references, and validates/formats missing vars.
6
- *
7
- * The double-dollar bookending syntax is:
8
- * - Visually distinct from shell `$VAR` syntax
9
- * - Unambiguous about variable boundaries
10
- * - Easy to grep: `grep '\$\$'`
11
- * - Fails loud if accidentally shell-processed (`$$`=PID in shell)
12
- *
13
- * # Syntax
14
- *
15
- * - `$$VAR$$` — required reference. Missing or empty fails validation
16
- * (see `validate_env_vars`).
17
- * - `$$?VAR$$` — optional reference. Missing or empty resolves to the
18
- * empty string and passes validation. Use for vars that exist in the
19
- * contract but may be intentionally blank (e.g. `SMTP_PASSWORD=` on
20
- * a deployment that hasn't configured SMTP yet).
21
- * - `\$$VAR$$` — escape. The leading backslash is dropped at resolution
22
- * time and the rest is emitted literally. Use this when documenting
23
- * the syntax inside a string literal (comments in env-file templates,
24
- * for example) where a regex scan would otherwise treat the mention
25
- * as a real reference. Combines with `?` as `\$$?VAR$$`.
26
- *
27
- * @module
28
- */
29
- /**
30
- * Pattern matching `$$VAR$$`, `$$?VAR$$`, and their escaped forms
31
- * `\$$VAR$$` / `\$$?VAR$$`. Capture groups:
32
- *
33
- * - 1: the `$$...$$` body (without any leading escape char) — what to
34
- * emit when the match is escaped.
35
- * - 2: `?` if the reference is optional, empty otherwise.
36
- * - 3: the variable name (without `$$` delimiters).
37
- *
38
- * The leading `\\?` (optional backslash) is the escape signal — its
39
- * presence in `match[0]` (vs. `match[1]`) drives the literal-emission
40
- * branch in the resolver.
41
- */
42
- const ENV_VAR_PATTERN = /\\?(\$\$(\??)([A-Za-z_][A-Za-z0-9_]*)\$\$)/g;
43
- /**
44
- * Resolve environment variable references in a string.
45
- *
46
- * - `$$VAR$$` resolves from the runtime env; missing values are left as-is
47
- * for the validation phase to report.
48
- * - `$$?VAR$$` is the optional form — missing or empty resolves to the empty
49
- * string. Required validation skips refs marked optional.
50
- * - `\$$VAR$$` / `\$$?VAR$$` are escapes — the leading backslash is dropped
51
- * and the body is emitted literally (no resolution attempted).
52
- *
53
- * @param runtime - runtime with `env_get` capability
54
- * @param value - string that may contain `$$VAR$$` references
55
- * @returns string with env vars resolved
56
- */
57
- export const resolve_env_vars = (runtime, value) => {
58
- return value.replace(ENV_VAR_PATTERN, (match, body, modifier, name) => {
59
- if (match.startsWith('\\')) {
60
- // Escaped: drop the leading backslash, emit the body literally.
61
- return body;
62
- }
63
- const resolved = runtime.env_get(name);
64
- if (resolved !== undefined && resolved !== '')
65
- return resolved;
66
- // Optional: empty-on-miss. Required: leave unresolved for validation.
67
- if (modifier === '?')
68
- return '';
69
- return match;
70
- });
71
- };
72
- /**
73
- * Check if a string contains unresolved env var references.
74
- *
75
- * Escaped references (`\$$VAR$$`) do not count — they're literal text once
76
- * resolved.
77
- *
78
- * @param value - string to check
79
- * @returns `true` if string contains unescaped `$$VAR$$` patterns
80
- */
81
- export const has_env_vars = (value) => {
82
- // Iterate the shared pattern (fresh regex; lastIndex is fine on construct).
83
- const pattern = new RegExp(ENV_VAR_PATTERN.source, 'g');
84
- let match;
85
- while ((match = pattern.exec(value)) !== null) {
86
- if (!match[0].startsWith('\\'))
87
- return true;
88
- }
89
- return false;
90
- };
91
- /**
92
- * Get list of env var names referenced in a string.
93
- *
94
- * Escaped references are skipped; optional and required references are both
95
- * included (callers that care about the distinction should use `scan_env_vars`
96
- * which preserves the `optional` flag per ref).
97
- *
98
- * @param value - string to scan
99
- * @returns array of variable names (without `$$` delimiters)
100
- */
101
- export const get_env_var_names = (value) => {
102
- const names = [];
103
- const pattern = new RegExp(ENV_VAR_PATTERN.source, 'g');
104
- let match;
105
- while ((match = pattern.exec(value)) !== null) {
106
- if (match[0].startsWith('\\'))
107
- continue;
108
- names.push(match[3]);
109
- }
110
- return names;
111
- };
112
- /**
113
- * Resolve env vars in an object's string values (shallow).
114
- *
115
- * @param runtime - runtime with `env_get` capability
116
- * @param obj - object with string values
117
- * @returns new object with env vars resolved
118
- */
119
- export const resolve_env_vars_in_object = (runtime, obj) => {
120
- const result = { ...obj };
121
- for (const [key, value] of Object.entries(result)) {
122
- if (typeof value === 'string') {
123
- result[key] = resolve_env_vars(runtime, value);
124
- }
125
- }
126
- return result;
127
- };
128
- /**
129
- * Resolve env vars and throw if any are missing/empty.
130
- *
131
- * Use this for values that must be present. `$$?VAR$$` (optional) refs
132
- * resolve to the empty string on miss without contributing to the error.
133
- * Escaped references (`\$$VAR$$`) emit literally and never check the env.
134
- *
135
- * @param runtime - runtime with `env_get` capability
136
- * @param value - string with `$$VAR$$` references
137
- * @param context - description for error message (e.g., `"target.host"`)
138
- * @returns resolved string
139
- * @throws Error if any referenced env var is missing or empty
140
- */
141
- export const resolve_env_vars_required = (runtime, value, context) => {
142
- const missing = [];
143
- const result = value.replace(ENV_VAR_PATTERN, (match, body, modifier, name) => {
144
- if (match.startsWith('\\')) {
145
- // Escaped — emit body, no env lookup.
146
- return body;
147
- }
148
- const resolved = runtime.env_get(name);
149
- if (resolved !== undefined && resolved !== '')
150
- return resolved;
151
- if (modifier === '?')
152
- return '';
153
- missing.push(name);
154
- return match; // keep original for error message
155
- });
156
- if (missing.length > 0) {
157
- throw new Error(`Missing required environment variable(s) for ${context}: ${missing.join(', ')}`);
158
- }
159
- return result;
160
- };
161
- /**
162
- * Recursively scan an object for `$$VAR$$` env var references.
163
- *
164
- * Walks all string values in the object tree and extracts env var names
165
- * with their path context for error reporting. Escaped references
166
- * (`\$$VAR$$`) are skipped — they're literal text, not references.
167
- * The `optional` flag on each ref distinguishes `$$VAR$$` (required) from
168
- * `$$?VAR$$` (optional) for downstream validation.
169
- *
170
- * @param obj - object to scan (typically a config)
171
- * @returns array of env var references with paths and optional flags
172
- */
173
- export const scan_env_vars = (obj) => {
174
- const refs = [];
175
- scan_recursive(obj, '', refs);
176
- return refs;
177
- };
178
- /**
179
- * Recursive helper for `scan_env_vars`. Uses the full pattern (not
180
- * `get_env_var_names`) to preserve the `optional` modifier on each ref.
181
- */
182
- const scan_recursive = (value, path, refs) => {
183
- if (typeof value === 'string') {
184
- const pattern = new RegExp(ENV_VAR_PATTERN.source, 'g');
185
- let match;
186
- while ((match = pattern.exec(value)) !== null) {
187
- if (match[0].startsWith('\\'))
188
- continue; // escaped — literal text
189
- refs.push({ name: match[3], path, optional: match[2] === '?' });
190
- }
191
- }
192
- else if (Array.isArray(value)) {
193
- for (let i = 0; i < value.length; i++) {
194
- scan_recursive(value[i], `${path}[${i}]`, refs);
195
- }
196
- }
197
- else if (value !== null && typeof value === 'object') {
198
- for (const [key, v] of Object.entries(value)) {
199
- const new_path = path ? `${path}.${key}` : key;
200
- scan_recursive(v, new_path, refs);
201
- }
202
- }
203
- // primitives (number, boolean, null, undefined) have no env vars
204
- };
205
- /**
206
- * Validate that all referenced env vars exist in the environment.
207
- *
208
- * Returns all missing refs (including duplicates by name). Grouping
209
- * and deduplication is handled by `format_missing_env_vars` at display time.
210
- * Refs marked `optional: true` (from `$$?VAR$$` syntax) are skipped — a
211
- * deliberately-blank var is contract, not a missing dependency.
212
- *
213
- * @param runtime - runtime with `env_get` capability
214
- * @param refs - env var references from `scan_env_vars`
215
- * @returns validation result with any missing vars
216
- */
217
- export const validate_env_vars = (runtime, refs) => {
218
- let missing = null;
219
- for (const ref of refs) {
220
- if (ref.optional)
221
- continue;
222
- const value = runtime.env_get(ref.name);
223
- if (value === undefined || value === '') {
224
- (missing ??= []).push(ref);
225
- }
226
- }
227
- return missing === null ? { ok: true, missing: null } : { ok: false, missing };
228
- };
229
- /**
230
- * Format missing env vars error message.
231
- *
232
- * Groups refs by variable name so each missing var is shown once
233
- * with all paths where it's referenced.
234
- *
235
- * @param missing - missing env var references (may contain duplicate names)
236
- * @param options - formatting options
237
- * @returns formatted error message for display
238
- */
239
- export const format_missing_env_vars = (missing, options) => {
240
- const lines = ['Missing required environment variables:', ''];
241
- // group by variable name, preserving insertion order
242
- const grouped = new Map();
243
- for (const ref of missing) {
244
- let paths = grouped.get(ref.name);
245
- if (!paths) {
246
- paths = [];
247
- grouped.set(ref.name, paths);
248
- }
249
- paths.push(ref.path);
250
- }
251
- for (const [name, paths] of grouped) {
252
- lines.push(` ${name} - used in ${paths.join(', ')}`);
253
- }
254
- lines.push('');
255
- const env_file = options?.env_file;
256
- if (env_file) {
257
- lines.push(`Loaded from: ${env_file}`);
258
- lines.push(`Add these to your ${env_file} file.`);
259
- if (options.setup_hint) {
260
- lines.push(options.setup_hint);
261
- }
262
- }
263
- else {
264
- lines.push('Use --env_file to load environment variables from a file.');
265
- }
266
- return lines.join('\n');
267
- };