@walkeros/cli 4.8.1-next-1792019907609 → 4.8.2

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.
@@ -26,7 +26,7 @@ type ValidateOptions = z.infer<typeof ValidateOptionsSchema>;
26
26
  * Every code an error, warning or skip of `validate` can carry. Agents and
27
27
  * tests branch on these, never on message text.
28
28
  */
29
- declare const VALIDATE_CODES: readonly ["INPUT_ERROR", "SERIALIZATION_ERROR", "OPTION_NOT_APPLICABLE", "FLOW_NOT_FOUND", "ENTRY_NOT_FOUND", "AMBIGUOUS_ENTRY", "UNSUPPORTED_SECTION", "INVALID_PATH", "SCHEMA_VALIDATION", "CONFIG_WARNING", "EMPTY_FLOWS", "UNKNOWN_KEY", "CONFLICT", "MISSING_PACKAGE", "OBSOLETE_CODE_STRING", "INVALID_IMPORT", "INVALID_CODE_SHAPE", "PACKAGE_VERSION_MISSING", "DEPRECATED_PACKAGE", "UNKNOWN_ROUTE_TARGET", "ROUTE_DEAD_CODE", "ROUTE_EMPTY_MANY", "ROUTE_SINGLE_MANY", "ROUTE_FIRST_MATCH", "INCOMPATIBLE_EXAMPLES", "EXAMPLES_INCOMPLETE", "CONTRACT_VIOLATION", "MAPPING_DOT_KEY", "FLOW_REF_WARNING", "FLOW_CYCLE", "VAR_CYCLE", "INVALID_COMPONENT_NAME", "INVALID_REFERENCE", "STORE_REFERENCE_NOT_FOUND", "STATE_STORE_UNKNOWN", "STATE_STORE_FILE", "TRANSFORMER_MAPPING_NO_OP", "UNRESOLVED_REFERENCE", "MISSING_ENV", "WEB_SECRET_REF", "UNRESOLVED_CONTRACT", "ENTRY_SCHEMA", "NO_CONTRACT_SECTION", "INVALID_CONTRACT", "FLAT_CONTRACT_SHAPE", "INVALID_CONTRACT_ENTRY", "UNKNOWN_CONTRACT_KEY", "INVALID_TAGGING", "INVALID_SCHEMA", "INVALID_EXTENDS", "INVALID_SECTION", "INVALID_EVENTS", "CIRCULAR_EXTENDS", "INVALID_ENTITY_KEY", "INVALID_ENTITY", "INVALID_ACTION_KEY", "INVALID_SCHEMA_ENTRY", "NOT_AN_OBJECT", "MISSING_EVENT_NAME", "EMPTY_EVENT_NAME", "INVALID_EVENT_NAME", "INVALID_MAPPING_TYPE", "INVALID_EVENT_PATTERN", "INVALID_RULE_TYPE", "CATCH_ALL_NOT_LAST", "GATED_BY_ERRORS", "CONTRACT_NOT_STATIC", "NO_PACKAGE", "NO_SETTINGS_SCHEMA", "SCHEMA_UNAVAILABLE"];
29
+ declare const VALIDATE_CODES: readonly ["INPUT_ERROR", "SERIALIZATION_ERROR", "OPTION_NOT_APPLICABLE", "FLOW_NOT_FOUND", "ENTRY_NOT_FOUND", "AMBIGUOUS_ENTRY", "UNSUPPORTED_SECTION", "INVALID_PATH", "SCHEMA_VALIDATION", "CONFIG_WARNING", "EMPTY_FLOWS", "UNKNOWN_KEY", "CONFLICT", "MISSING_PACKAGE", "OBSOLETE_CODE_STRING", "INVALID_IMPORT", "INVALID_CODE_SHAPE", "PACKAGE_VERSION_MISSING", "DEPRECATED_PACKAGE", "UNKNOWN_ROUTE_TARGET", "ROUTE_DEAD_CODE", "ROUTE_EMPTY_MANY", "ROUTE_SINGLE_MANY", "ROUTE_FIRST_MATCH", "INCOMPATIBLE_EXAMPLES", "EXAMPLES_INCOMPLETE", "CONTRACT_VIOLATION", "MAPPING_DOT_KEY", "FLOW_REF_WARNING", "WEB_LOGGER_FORMAT", "FLOW_CYCLE", "VAR_CYCLE", "INVALID_COMPONENT_NAME", "INVALID_REFERENCE", "STORE_REFERENCE_NOT_FOUND", "STATE_STORE_UNKNOWN", "STATE_STORE_FILE", "MAPPING_NO_OP", "MAPPING_VALUE_NO_OPERATOR", "MAPPING_VALUE_PRODUCERS", "BATCH_WITHOUT_PUSH_BATCH", "MALFORMED_REFERENCE", "UNRESOLVED_REFERENCE", "MISSING_ENV", "WEB_SECRET_REF", "UNRESOLVED_CONTRACT", "ENTRY_SCHEMA", "NO_CONTRACT_SECTION", "INVALID_CONTRACT", "FLAT_CONTRACT_SHAPE", "INVALID_CONTRACT_ENTRY", "UNKNOWN_CONTRACT_KEY", "INVALID_TAGGING", "INVALID_SCHEMA", "INVALID_EXTENDS", "INVALID_EVENTS", "CIRCULAR_EXTENDS", "INVALID_ENTITY_KEY", "INVALID_ENTITY", "INVALID_ACTION_KEY", "INVALID_SCHEMA_ENTRY", "NOT_AN_OBJECT", "MISSING_EVENT_NAME", "EMPTY_EVENT_NAME", "INVALID_EVENT_NAME", "INVALID_MAPPING_TYPE", "INVALID_EVENT_PATTERN", "INVALID_RULE_TYPE", "CATCH_ALL_NOT_LAST", "GATED_BY_ERRORS", "CONTRACT_NOT_STATIC", "NO_PACKAGE", "NO_SETTINGS_SCHEMA", "SCHEMA_UNAVAILABLE"];
30
30
  type ValidateCode = (typeof VALIDATE_CODES)[number];
31
31
  /**
32
32
  * Named checks a run includes (`details.scope.checks`). `file:` checks run
package/dist/validate.js CHANGED
@@ -133,34 +133,6 @@ import fs4 from "fs-extra";
133
133
  // src/core/stdin.ts
134
134
  import fs5 from "fs-extra";
135
135
 
136
- // src/core/oauth-client.ts
137
- import { z as z2 } from "zod";
138
-
139
- // src/core/app-fetch.ts
140
- import { z } from "zod";
141
- var AppErrorSchema = z.object({
142
- error: z.object({ message: z.string().min(1) })
143
- });
144
-
145
- // src/core/oauth-client.ts
146
- var DeviceAuthorizationSchema = z2.object({
147
- device_code: z2.string().min(1),
148
- user_code: z2.string().min(1),
149
- verification_uri: z2.string().min(1),
150
- verification_uri_complete: z2.string().min(1).optional(),
151
- expires_in: z2.number().int().nonnegative(),
152
- interval: z2.number().int().nonnegative()
153
- });
154
- var TokenSchema = z2.object({
155
- access_token: z2.string().min(1),
156
- expires_in: z2.number().int().nonnegative(),
157
- refresh_token: z2.string().min(1).optional()
158
- });
159
- var ErrorSchema = z2.object({
160
- error: z2.string().min(1),
161
- error_description: z2.string().optional()
162
- });
163
-
164
136
  // src/core/event-validation.ts
165
137
  import { schemas } from "@walkeros/core/dev";
166
138
  var { PartialEventSchema } = schemas;
@@ -256,6 +228,7 @@ var { safeParseConfig } = schemas2;
256
228
  // src/config/loader.ts
257
229
  import fs7 from "fs-extra";
258
230
  import { getFlowSettings, getPlatform } from "@walkeros/core";
231
+ import { validateFlowStructure } from "@walkeros/core/dev";
259
232
 
260
233
  // src/core/content-digest.ts
261
234
  import { createHash } from "crypto";
@@ -265,16 +238,9 @@ import fs6 from "fs-extra";
265
238
  import { checkWindowCollector } from "@walkeros/core";
266
239
 
267
240
  // src/commands/validate/validators/contract.ts
268
- import { isObject as isObject2 } from "@walkeros/core";
241
+ import { CONTRACT_RULE_KEYS, isObject as isObject2 } from "@walkeros/core";
242
+ var KNOWN_KEYS = new Set(CONTRACT_RULE_KEYS);
269
243
  var SECTION_KEYS = ["globals", "context", "custom", "user", "consent"];
270
- var KNOWN_KEYS = /* @__PURE__ */ new Set([
271
- "extend",
272
- "tagging",
273
- "description",
274
- "events",
275
- "schema",
276
- ...SECTION_KEYS
277
- ]);
278
244
  function validateContract(input) {
279
245
  const errors = [];
280
246
  const warnings = [];
@@ -315,7 +281,9 @@ function validateContract(input) {
315
281
  const keys = Object.keys(obj);
316
282
  const unknownKeys = keys.filter((k) => !KNOWN_KEYS.has(k));
317
283
  const hasKnownKey = keys.some((k) => KNOWN_KEYS.has(k));
318
- const objectValuedUnknown = unknownKeys.filter((k) => isObject2(obj[k]));
284
+ const objectValuedUnknown = unknownKeys.filter(
285
+ (k) => isObject2(obj[k]) && !SECTION_KEYS.includes(k)
286
+ );
319
287
  if (!hasKnownKey && objectValuedUnknown.length > 0) {
320
288
  errors.push({
321
289
  path: name,
@@ -325,9 +293,9 @@ function validateContract(input) {
325
293
  continue;
326
294
  }
327
295
  for (const key of unknownKeys) {
328
- warnings.push({
296
+ errors.push({
329
297
  path: `${name}.${key}`,
330
- message: `Unknown contract key "${key}" is ignored`,
298
+ message: SECTION_KEYS.includes(key) ? `Contract section "${key}" is not enforced: the validate transformer reads only "events" and "schema". Put the rule into "schema" (a JSON Schema for the whole event), for example "schema": { "properties": { "${key}": { ... } } }.` : `Unknown contract key "${key}" is not supported. Known keys: ${[...KNOWN_KEYS].join(", ")}.`,
331
299
  code: "UNKNOWN_CONTRACT_KEY"
332
300
  });
333
301
  }
@@ -361,18 +329,6 @@ function validateContract(input) {
361
329
  });
362
330
  }
363
331
  }
364
- for (const key of SECTION_KEYS) {
365
- if (key in obj) {
366
- if (typeof obj[key] !== "object" || obj[key] === null) {
367
- errors.push({
368
- path: `${name}.${key}`,
369
- message: `Section "${key}" must be a JSON Schema object`,
370
- value: obj[key],
371
- code: "INVALID_SECTION"
372
- });
373
- }
374
- }
375
- }
376
332
  if (obj.events !== void 0) {
377
333
  if (typeof obj.events !== "object" || obj.events === null) {
378
334
  errors.push({
@@ -484,9 +440,14 @@ import {
484
440
  isObject as isObject5,
485
441
  REF_CONTRACT,
486
442
  resolveContracts,
443
+ SECRET_MARKER_PREFIX as SECRET_MARKER_PREFIX2,
487
444
  validateStepEntry
488
445
  } from "@walkeros/core";
489
- import { schemas as schemas3, validateFlowStructure } from "@walkeros/core/dev";
446
+ import {
447
+ checkStepKeys,
448
+ schemas as schemas3,
449
+ validateFlowStructure as validateFlowStructure2
450
+ } from "@walkeros/core/dev";
490
451
  import {
491
452
  validateEventAgainstContract
492
453
  } from "@walkeros/transformer-validate";
@@ -736,7 +697,7 @@ function parsePackageSpec(spec) {
736
697
  }
737
698
 
738
699
  // src/commands/validate/validators/settings.ts
739
- var CLIENT_HEADER = "walkeros-cli/4.8.1-next-1792019907609";
700
+ var CLIENT_HEADER = "walkeros-cli/4.8.2";
740
701
  function createSettingsContext(configDir) {
741
702
  return { configDir, cache: /* @__PURE__ */ new Map(), compiled: /* @__PURE__ */ new Map() };
742
703
  }
@@ -1051,7 +1012,9 @@ var { validateFlowConfig: validateFlowConfig2 } = schemas3;
1051
1012
  var DEPRECATED_PACKAGES = {
1052
1013
  "@walkeros/store-memory": "has been removed. Use the built-in cache by omitting cache.store, or remove the store declaration if it was only used as a cache target."
1053
1014
  };
1054
- var OPEN_STEP_KINDS = [
1015
+ var STEP_KINDS = [
1016
+ ["sources", "Source"],
1017
+ ["transformers", "Transformer"],
1055
1018
  ["destinations", "Destination"],
1056
1019
  ["stores", "Store"]
1057
1020
  ];
@@ -1100,7 +1063,11 @@ async function validateFlowWithPackages(input, options = {}) {
1100
1063
  }
1101
1064
  }
1102
1065
  for (const outcome of await Promise.all(pending)) {
1103
- result.warnings.push(...outcome.findings);
1066
+ for (const finding of outcome.findings) {
1067
+ if (finding.keyword === "additionalProperties")
1068
+ result.errors.push(finding);
1069
+ else result.warnings.push(finding);
1070
+ }
1104
1071
  run.skipped.push(...outcome.skipped);
1105
1072
  deferred.push(...outcome.deferred);
1106
1073
  if (outcome.checked) packages.push(outcome.checked);
@@ -1108,6 +1075,7 @@ async function validateFlowWithPackages(input, options = {}) {
1108
1075
  result.details.scope = describeScope(scope, run.checks);
1109
1076
  result.details.deferred = [...result.details.deferred ?? [], ...deferred];
1110
1077
  if (packages.length > 0) result.details.packages = packages;
1078
+ result.valid = result.errors.length === 0;
1111
1079
  return result;
1112
1080
  }
1113
1081
  function runFlowChecks(input, options) {
@@ -1166,8 +1134,13 @@ function runFlowChecks(input, options) {
1166
1134
  for (const issue of coreResult.errors) {
1167
1135
  const path4 = issue.path || "root";
1168
1136
  if (!inScope(path4)) continue;
1169
- if (path4 === "contract" && contractErrors > 0) continue;
1170
- errors.push({ path: path4, message: issue.message, code: "SCHEMA_VALIDATION" });
1137
+ if ((path4 === "contract" || path4.startsWith("contract.")) && contractErrors > 0)
1138
+ continue;
1139
+ errors.push({
1140
+ path: path4,
1141
+ message: issue.message,
1142
+ code: issue.code ?? "SCHEMA_VALIDATION"
1143
+ });
1171
1144
  }
1172
1145
  for (const issue of coreResult.warnings) {
1173
1146
  const path4 = issue.path || "root";
@@ -1201,20 +1174,13 @@ function runFlowChecks(input, options) {
1201
1174
  }
1202
1175
  }
1203
1176
  }
1204
- for (const [section, kind] of OPEN_STEP_KINDS) {
1177
+ for (const [section, kind] of STEP_KINDS) {
1205
1178
  const steps = flowValue[section];
1206
1179
  if (!isObject5(steps)) continue;
1207
1180
  for (const [name, step] of Object.entries(steps)) {
1208
1181
  if (!isObject5(step)) continue;
1209
1182
  const at = `flows.${flowName}.${section}.${name}`;
1210
- for (const key of unknownStepKeys(step, kind)) {
1211
- warnings.push({
1212
- path: `${at}.${key}`,
1213
- message: `Unknown key "${key}" on ${kind} is ignored by the runtime`,
1214
- suggestion: "Remove the key, or move it to where it belongs.",
1215
- code: "UNKNOWN_KEY"
1216
- });
1217
- }
1183
+ errors.push(...checkStepKeys(step, kind, at));
1218
1184
  const pkg = step.package;
1219
1185
  if (typeof pkg === "string" && pkg in DEPRECATED_PACKAGES) {
1220
1186
  warnings.push({
@@ -1225,6 +1191,7 @@ function runFlowChecks(input, options) {
1225
1191
  }
1226
1192
  }
1227
1193
  }
1194
+ checkWebLoggerFormat(flowName, flowValue, errors);
1228
1195
  }
1229
1196
  if (flows) {
1230
1197
  details.flowNames = allFlows;
@@ -1288,7 +1255,7 @@ function runFlowChecks(input, options) {
1288
1255
  }
1289
1256
  };
1290
1257
  perFlow(["flow:structure"], (name, flow, file) => {
1291
- const structure = validateFlowStructure({
1258
+ const structure = validateFlowStructure2({
1292
1259
  ...file,
1293
1260
  flows: { [name]: flow }
1294
1261
  });
@@ -1396,16 +1363,31 @@ function checkResolvedWindowCollector(name, raw, flow, errors, deferred) {
1396
1363
  code: "SCHEMA_VALIDATION"
1397
1364
  });
1398
1365
  }
1399
- function unknownStepKeys(step, kind) {
1400
- const unknown = [];
1401
- const rest = { ...step };
1402
- for (; ; ) {
1403
- const verdict = validateStepEntry(rest, kind);
1404
- if (verdict.code !== "UNKNOWN_KEY" || verdict.key === void 0) break;
1405
- unknown.push(verdict.key);
1406
- Reflect.deleteProperty(rest, verdict.key);
1366
+ function checkWebLoggerFormat(flowName, flow, errors) {
1367
+ if (!isObject5(flow.config) || flow.config.platform !== "web") return;
1368
+ const at = `flows.${flowName}`;
1369
+ const loggers = [];
1370
+ if (isObject5(flow.collector))
1371
+ loggers.push([`${at}.collector.logger`, flow.collector.logger]);
1372
+ for (const [section] of STEP_KINDS) {
1373
+ const steps = flow[section];
1374
+ if (!isObject5(steps)) continue;
1375
+ for (const [name, step] of Object.entries(steps)) {
1376
+ if (isObject5(step) && isObject5(step.config))
1377
+ loggers.push([
1378
+ `${at}.${section}.${name}.config.logger`,
1379
+ step.config.logger
1380
+ ]);
1381
+ }
1382
+ }
1383
+ for (const [path4, logger] of loggers) {
1384
+ if (!isObject5(logger) || logger.format === void 0) continue;
1385
+ errors.push({
1386
+ path: `${path4}.format`,
1387
+ message: "logger.format applies to server flows only: a web flow logs to the browser console, which has no output format. Remove it.",
1388
+ code: "WEB_LOGGER_FORMAT"
1389
+ });
1407
1390
  }
1408
- return unknown;
1409
1391
  }
1410
1392
  function routeTargets(spec) {
1411
1393
  if (spec === void 0) return [];
@@ -1633,6 +1615,12 @@ function lintRoute(spec, position, known, errors, warnings) {
1633
1615
  }
1634
1616
  }
1635
1617
  }
1618
+ function hasRuntimeValue(value) {
1619
+ if (typeof value === "string")
1620
+ return value.includes(ENV_MARKER_PREFIX2) || value.startsWith(SECRET_MARKER_PREFIX2) || /\$(?:env|secret)\./.test(value);
1621
+ if (Array.isArray(value)) return value.some(hasRuntimeValue);
1622
+ return isObject5(value) && Object.values(value).some(hasRuntimeValue);
1623
+ }
1636
1624
  var VALIDATE_PACKAGE = "@walkeros/transformer-validate";
1637
1625
  function isValidateStep(step) {
1638
1626
  return step.package === VALIDATE_PACKAGE;
@@ -1703,6 +1691,15 @@ function checkValidateStepExamples(stepPath, step, contract, errors, warnings, s
1703
1691
  }
1704
1692
  if (!step.examples) return;
1705
1693
  const contracts = resolution.sources;
1694
+ if (contracts.some(hasRuntimeValue)) {
1695
+ skipped?.push({
1696
+ path: stepPath,
1697
+ check: "flow:contract-examples",
1698
+ reason: "the contract uses a $env or $secret value, known only when the bundle builds or runs, so the examples cannot be judged statically",
1699
+ code: "CONTRACT_NOT_STATIC"
1700
+ });
1701
+ return;
1702
+ }
1706
1703
  const mode = settings.mode === "strict" ? "strict" : "pass";
1707
1704
  const format = settings.format === true;
1708
1705
  const output = isObject5(settings.output) ? settings.output : {};
@@ -1909,6 +1906,7 @@ var VALIDATE_CODES = [
1909
1906
  "CONTRACT_VIOLATION",
1910
1907
  "MAPPING_DOT_KEY",
1911
1908
  "FLOW_REF_WARNING",
1909
+ "WEB_LOGGER_FORMAT",
1912
1910
  "FLOW_CYCLE",
1913
1911
  "VAR_CYCLE",
1914
1912
  // Structure (the bundler's own preflight, validateFlowStructure)
@@ -1917,7 +1915,11 @@ var VALIDATE_CODES = [
1917
1915
  "STORE_REFERENCE_NOT_FOUND",
1918
1916
  "STATE_STORE_UNKNOWN",
1919
1917
  "STATE_STORE_FILE",
1920
- "TRANSFORMER_MAPPING_NO_OP",
1918
+ "MAPPING_NO_OP",
1919
+ "MAPPING_VALUE_NO_OPERATOR",
1920
+ "MAPPING_VALUE_PRODUCERS",
1921
+ "BATCH_WITHOUT_PUSH_BATCH",
1922
+ "MALFORMED_REFERENCE",
1921
1923
  // Resolution (getFlowSettings, as the bundler resolves the flow)
1922
1924
  "UNRESOLVED_REFERENCE",
1923
1925
  "MISSING_ENV",
@@ -1934,7 +1936,6 @@ var VALIDATE_CODES = [
1934
1936
  "INVALID_TAGGING",
1935
1937
  "INVALID_SCHEMA",
1936
1938
  "INVALID_EXTENDS",
1937
- "INVALID_SECTION",
1938
1939
  "INVALID_EVENTS",
1939
1940
  "CIRCULAR_EXTENDS",
1940
1941
  "INVALID_ENTITY_KEY",