@walkeros/cli 4.8.2 → 4.8.3-next-1793115089237
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 +59 -3
- package/README.md +2 -2
- package/dist/cli.js +1320 -1318
- package/dist/dev.d.ts +51 -3
- package/dist/dev.js +186 -0
- package/dist/dev.js.map +1 -1
- package/dist/examples/README.md +12 -1
- package/dist/examples/contracts/app.json +261 -0
- package/dist/examples/contracts/base.json +708 -0
- package/dist/examples/contracts/ecommerce.json +963 -0
- package/dist/examples/contracts/leadgen.json +240 -0
- package/dist/examples/contracts/publisher.json +372 -0
- package/dist/examples/contracts/saas.json +229 -0
- package/dist/examples/contracts/travel.json +234 -0
- package/dist/examples/customers/README.md +4 -1
- package/dist/examples/flow-complete.json +40 -25
- package/dist/examples/flow-complete.md +5 -3
- package/dist/examples/index.js +42 -27
- package/dist/examples/index.js.map +1 -1
- package/dist/examples/shared/README.md +4 -0
- package/dist/index.d.ts +41 -41
- package/dist/index.js +161 -134
- package/dist/index.js.map +1 -1
- package/dist/validate.js +264 -132
- package/dist/validate.js.map +1 -1
- package/examples/README.md +12 -1
- package/examples/contracts/app.json +261 -0
- package/examples/contracts/base.json +708 -0
- package/examples/contracts/ecommerce.json +963 -0
- package/examples/contracts/leadgen.json +240 -0
- package/examples/contracts/publisher.json +372 -0
- package/examples/contracts/saas.json +229 -0
- package/examples/contracts/travel.json +234 -0
- package/examples/customers/README.md +4 -1
- package/examples/flow-complete.json +40 -25
- package/examples/flow-complete.md +5 -3
- package/examples/shared/README.md +4 -0
- package/package.json +30 -30
- package/dist/examples/test.html +0 -43
- package/dist/examples/web-serve.js +0 -25503
- package/examples/test.html +0 -43
- package/examples/web-serve.js +0 -25503
package/dist/index.js
CHANGED
|
@@ -862,6 +862,9 @@ function getFlowSection(flow, section) {
|
|
|
862
862
|
return flow.stores;
|
|
863
863
|
}
|
|
864
864
|
}
|
|
865
|
+
function isLocalPath(spec) {
|
|
866
|
+
return spec.startsWith(".") || spec.startsWith("/");
|
|
867
|
+
}
|
|
865
868
|
function parsePackageSpec(spec) {
|
|
866
869
|
const at = spec.lastIndexOf("@");
|
|
867
870
|
if (at <= 0) return { name: spec };
|
|
@@ -917,8 +920,7 @@ function applyStepPackages(flowSettings, packages, logger) {
|
|
|
917
920
|
}
|
|
918
921
|
};
|
|
919
922
|
for (const pkg of stepPackages) {
|
|
920
|
-
|
|
921
|
-
if (isLocalPath) {
|
|
923
|
+
if (isLocalPath(pkg)) {
|
|
922
924
|
const varName = packageNameToVariable(pkg);
|
|
923
925
|
if (!packages[varName]) {
|
|
924
926
|
packages[varName] = {
|
|
@@ -963,6 +965,40 @@ function applyStepPackages(flowSettings, packages, logger) {
|
|
|
963
965
|
}
|
|
964
966
|
}
|
|
965
967
|
}
|
|
968
|
+
var KIND_TO_SECTION = {
|
|
969
|
+
source: "sources",
|
|
970
|
+
transformer: "transformers",
|
|
971
|
+
destination: "destinations",
|
|
972
|
+
store: "stores"
|
|
973
|
+
};
|
|
974
|
+
function resolveStepPackage(flow, kind, id, logger) {
|
|
975
|
+
const normalizedFlow = structuredClone(flow);
|
|
976
|
+
const packages = structuredClone(
|
|
977
|
+
normalizedFlow.config?.bundle?.packages ?? {}
|
|
978
|
+
);
|
|
979
|
+
applyStepPackages(normalizedFlow, packages, logger);
|
|
980
|
+
const bucket = getFlowSection(normalizedFlow, KIND_TO_SECTION[kind]);
|
|
981
|
+
const step = bucket?.[id];
|
|
982
|
+
if (!step) {
|
|
983
|
+
const available = Object.keys(bucket ?? {}).join(", ") || "(none)";
|
|
984
|
+
throw new Error(
|
|
985
|
+
`${kind} "${id}" not found in flow. Available: ${available}`
|
|
986
|
+
);
|
|
987
|
+
}
|
|
988
|
+
if (typeof step.package !== "string") {
|
|
989
|
+
throw new Error(
|
|
990
|
+
`${kind}.${id} has no "package" (inline code cannot be set up).`
|
|
991
|
+
);
|
|
992
|
+
}
|
|
993
|
+
const declared = getFlowSection(flow, KIND_TO_SECTION[kind])?.[id]?.package;
|
|
994
|
+
return {
|
|
995
|
+
packageName: step.package,
|
|
996
|
+
label: declared !== void 0 && isLocalPath(declared) ? declared : step.package,
|
|
997
|
+
spec: packages[step.package] ?? {},
|
|
998
|
+
overrides: normalizedFlow.config?.bundle?.overrides ?? {},
|
|
999
|
+
normalizedFlow
|
|
1000
|
+
};
|
|
1001
|
+
}
|
|
966
1002
|
|
|
967
1003
|
// src/core/package-manager.ts
|
|
968
1004
|
import pacote from "pacote";
|
|
@@ -6034,7 +6070,7 @@ async function simulateDestination(configOrPath, event, options) {
|
|
|
6034
6070
|
import * as fs20 from "fs";
|
|
6035
6071
|
import * as path20 from "path";
|
|
6036
6072
|
import chalk2 from "chalk";
|
|
6037
|
-
import { isObject as
|
|
6073
|
+
import { isObject as isObject11 } from "@walkeros/core";
|
|
6038
6074
|
|
|
6039
6075
|
// src/commands/validate/validators/contract.ts
|
|
6040
6076
|
import { CONTRACT_RULE_KEYS, isObject as isObject5 } from "@walkeros/core";
|
|
@@ -6236,7 +6272,7 @@ import {
|
|
|
6236
6272
|
ENV_MARKER_PREFIX as ENV_MARKER_PREFIX3,
|
|
6237
6273
|
getByPath,
|
|
6238
6274
|
getRouteGraph,
|
|
6239
|
-
isObject as
|
|
6275
|
+
isObject as isObject9,
|
|
6240
6276
|
REF_CONTRACT,
|
|
6241
6277
|
resolveContracts,
|
|
6242
6278
|
SECRET_MARKER_PREFIX as SECRET_MARKER_PREFIX4,
|
|
@@ -6435,19 +6471,52 @@ function resolutionCode(error) {
|
|
|
6435
6471
|
}
|
|
6436
6472
|
|
|
6437
6473
|
// src/commands/validate/validators/settings.ts
|
|
6438
|
-
import * as fs19 from "fs";
|
|
6439
|
-
import * as path19 from "path";
|
|
6440
6474
|
import Ajv from "ajv";
|
|
6441
6475
|
import {
|
|
6476
|
+
createLogger,
|
|
6442
6477
|
ENV_MARKER_PREFIX as ENV_MARKER_PREFIX2,
|
|
6443
|
-
fetchPackage,
|
|
6444
6478
|
getErrorMessage as getErrorMessage3,
|
|
6445
|
-
isObject as
|
|
6479
|
+
isObject as isObject8,
|
|
6446
6480
|
REF_CODE_PREFIX,
|
|
6447
6481
|
REF_STORE,
|
|
6448
6482
|
SECRET_MARKER_PREFIX as SECRET_MARKER_PREFIX3
|
|
6449
6483
|
} from "@walkeros/core";
|
|
6450
|
-
|
|
6484
|
+
|
|
6485
|
+
// src/core/package-info.ts
|
|
6486
|
+
import * as fs19 from "fs";
|
|
6487
|
+
import * as path19 from "path";
|
|
6488
|
+
import { fetchPackage, isObject as isObject7, parseWalkerOSJson } from "@walkeros/core";
|
|
6489
|
+
function readJson(file) {
|
|
6490
|
+
return JSON.parse(fs19.readFileSync(file, "utf-8"));
|
|
6491
|
+
}
|
|
6492
|
+
async function readStepPackageInfo(resolved, options) {
|
|
6493
|
+
const { packageName, spec } = resolved;
|
|
6494
|
+
if (spec.path === void 0)
|
|
6495
|
+
return fetchPackage(packageName, {
|
|
6496
|
+
...spec.version ? { version: spec.version } : {},
|
|
6497
|
+
client: options.client
|
|
6498
|
+
});
|
|
6499
|
+
if (options.configDir === void 0)
|
|
6500
|
+
throw new Error(
|
|
6501
|
+
"it is a local path package and the input is not a file, so there is no directory to read it from"
|
|
6502
|
+
);
|
|
6503
|
+
const root = path19.isAbsolute(spec.path) ? spec.path : path19.resolve(options.configDir, spec.path);
|
|
6504
|
+
const file = [
|
|
6505
|
+
path19.join(root, "dist", "walkerOS.json"),
|
|
6506
|
+
path19.join(root, "walkerOS.json")
|
|
6507
|
+
].find((candidate) => fs19.existsSync(candidate));
|
|
6508
|
+
if (!file) throw new Error(`no walkerOS.json under ${root}`);
|
|
6509
|
+
const meta = readJson(file);
|
|
6510
|
+
if (!isObject7(meta)) throw new Error(`${file} is not a JSON object`);
|
|
6511
|
+
const pkgFile = path19.join(root, "package.json");
|
|
6512
|
+
const pkg = fs19.existsSync(pkgFile) ? readJson(pkgFile) : void 0;
|
|
6513
|
+
const version = isObject7(pkg) && typeof pkg.version === "string" ? pkg.version : void 0;
|
|
6514
|
+
return { ...parseWalkerOSJson(meta), ...version ? { version } : {} };
|
|
6515
|
+
}
|
|
6516
|
+
|
|
6517
|
+
// src/commands/validate/validators/settings.ts
|
|
6518
|
+
var CLIENT_HEADER = "walkeros-cli/4.8.3-next-1793115089237";
|
|
6519
|
+
var LOGGER = createLogger();
|
|
6451
6520
|
function createSettingsContext(configDir) {
|
|
6452
6521
|
return { configDir, cache: /* @__PURE__ */ new Map(), compiled: /* @__PURE__ */ new Map() };
|
|
6453
6522
|
}
|
|
@@ -6458,7 +6527,7 @@ function selectSettingsSchema(pkg, packageLabel, exportName) {
|
|
|
6458
6527
|
pkg.exportSchemas,
|
|
6459
6528
|
exportName
|
|
6460
6529
|
) ? pkg.exportSchemas[exportName] : void 0;
|
|
6461
|
-
if (!
|
|
6530
|
+
if (!isObject8(entry))
|
|
6462
6531
|
return {
|
|
6463
6532
|
ok: false,
|
|
6464
6533
|
reason: `${packageLabel} has no export "${exportName}"`
|
|
@@ -6486,7 +6555,7 @@ function valueAt(root, segments) {
|
|
|
6486
6555
|
let current = root;
|
|
6487
6556
|
for (const segment of segments) {
|
|
6488
6557
|
if (Array.isArray(current)) current = current[Number(segment)];
|
|
6489
|
-
else if (
|
|
6558
|
+
else if (isObject8(current)) current = current[segment];
|
|
6490
6559
|
else return void 0;
|
|
6491
6560
|
}
|
|
6492
6561
|
return current;
|
|
@@ -6501,7 +6570,7 @@ function prepareSettings(settings) {
|
|
|
6501
6570
|
const walk = (value, segments) => {
|
|
6502
6571
|
if (Array.isArray(value))
|
|
6503
6572
|
return value.map((item, index) => walk(item, [...segments, `${index}`]));
|
|
6504
|
-
if (
|
|
6573
|
+
if (isObject8(value))
|
|
6505
6574
|
return Object.fromEntries(
|
|
6506
6575
|
Object.entries(value).map(([key, item]) => [
|
|
6507
6576
|
key,
|
|
@@ -6545,62 +6614,9 @@ function prepareSettings(settings) {
|
|
|
6545
6614
|
function isUnder(segments, prefix) {
|
|
6546
6615
|
return prefix.every((segment, index) => segments[index] === segment);
|
|
6547
6616
|
}
|
|
6548
|
-
function
|
|
6549
|
-
const
|
|
6550
|
-
|
|
6551
|
-
const packages = isObject7(bundle2) ? bundle2.packages : void 0;
|
|
6552
|
-
const pin = isObject7(packages) ? packages[name] : void 0;
|
|
6553
|
-
if (!isObject7(pin)) return {};
|
|
6554
|
-
return {
|
|
6555
|
-
...typeof pin.version === "string" ? { version: pin.version } : {},
|
|
6556
|
-
...typeof pin.path === "string" ? { path: pin.path } : {}
|
|
6557
|
-
};
|
|
6558
|
-
}
|
|
6559
|
-
function packageSource(spec, rawFlow) {
|
|
6560
|
-
if (spec.startsWith(".") || spec.startsWith("/"))
|
|
6561
|
-
return { name: spec, localPath: spec };
|
|
6562
|
-
const { name, version } = parsePackageSpec(spec);
|
|
6563
|
-
const pin = bundlePin(rawFlow, name);
|
|
6564
|
-
if (pin.path) return { name, localPath: pin.path };
|
|
6565
|
-
const pinned = pin.version ?? version;
|
|
6566
|
-
return pinned ? { name, version: pinned } : { name };
|
|
6567
|
-
}
|
|
6568
|
-
function readJson(file) {
|
|
6569
|
-
return JSON.parse(fs19.readFileSync(file, "utf-8"));
|
|
6570
|
-
}
|
|
6571
|
-
function readLocalSchema(source, configDir) {
|
|
6572
|
-
const localPath = source.localPath ?? "";
|
|
6573
|
-
const root = path19.isAbsolute(localPath) ? localPath : path19.resolve(configDir, localPath);
|
|
6574
|
-
const file = [
|
|
6575
|
-
path19.join(root, "dist", "walkerOS.json"),
|
|
6576
|
-
path19.join(root, "walkerOS.json")
|
|
6577
|
-
].find((candidate) => fs19.existsSync(candidate));
|
|
6578
|
-
if (!file) throw new Error(`no walkerOS.json under ${root}`);
|
|
6579
|
-
const meta = readJson(file);
|
|
6580
|
-
const pkgFile = path19.join(root, "package.json");
|
|
6581
|
-
const pkg = fs19.existsSync(pkgFile) ? readJson(pkgFile) : void 0;
|
|
6582
|
-
const schemas6 = isObject7(meta) ? meta.schemas : void 0;
|
|
6583
|
-
const exportSchemas = isObject7(meta) ? meta.exportSchemas : void 0;
|
|
6584
|
-
const declared = isObject7(meta) && isObject7(meta.$meta) ? meta.$meta.exports : void 0;
|
|
6585
|
-
const version = isObject7(pkg) && typeof pkg.version === "string" ? pkg.version : void 0;
|
|
6586
|
-
return {
|
|
6587
|
-
...version ? { version } : {},
|
|
6588
|
-
settings: isObject7(schemas6) ? schemas6.settings : void 0,
|
|
6589
|
-
...isObject7(exportSchemas) ? { exportSchemas } : {},
|
|
6590
|
-
...isObject7(declared) ? { exports: Object.keys(declared) } : {}
|
|
6591
|
-
};
|
|
6592
|
-
}
|
|
6593
|
-
async function loadSchema(source, context2) {
|
|
6594
|
-
if (source.localPath !== void 0) {
|
|
6595
|
-
const configDir = context2.configDir;
|
|
6596
|
-
if (configDir === void 0)
|
|
6597
|
-
throw new Error(
|
|
6598
|
-
"it is a local path package and the input is not a file, so there is no directory to read it from"
|
|
6599
|
-
);
|
|
6600
|
-
return readLocalSchema(source, configDir);
|
|
6601
|
-
}
|
|
6602
|
-
const info = await fetchPackage(source.name, {
|
|
6603
|
-
...source.version ? { version: source.version } : {},
|
|
6617
|
+
async function loadSchema(resolved, context2) {
|
|
6618
|
+
const info = await readStepPackageInfo(resolved, {
|
|
6619
|
+
configDir: context2.configDir,
|
|
6604
6620
|
client: CLIENT_HEADER
|
|
6605
6621
|
});
|
|
6606
6622
|
return {
|
|
@@ -6611,7 +6627,7 @@ async function loadSchema(source, context2) {
|
|
|
6611
6627
|
};
|
|
6612
6628
|
}
|
|
6613
6629
|
function compileSettings(settings) {
|
|
6614
|
-
if (!
|
|
6630
|
+
if (!isObject8(settings)) return void 0;
|
|
6615
6631
|
const ajv = new Ajv({ allErrors: true, validateFormats: false });
|
|
6616
6632
|
try {
|
|
6617
6633
|
return { ok: true, validate: ajv.compile(settings) };
|
|
@@ -6619,26 +6635,26 @@ function compileSettings(settings) {
|
|
|
6619
6635
|
return { ok: false, message: getErrorMessage3(error) };
|
|
6620
6636
|
}
|
|
6621
6637
|
}
|
|
6622
|
-
function sourceKey(
|
|
6623
|
-
return
|
|
6638
|
+
function sourceKey({ packageName, spec }) {
|
|
6639
|
+
return spec.path !== void 0 ? `path:${spec.path}` : `${packageName}@${spec.version ?? "latest"}`;
|
|
6624
6640
|
}
|
|
6625
|
-
function cachedSchema(
|
|
6626
|
-
const key = sourceKey(
|
|
6641
|
+
function cachedSchema(resolved, context2) {
|
|
6642
|
+
const key = sourceKey(resolved);
|
|
6627
6643
|
let pending = context2.cache.get(key);
|
|
6628
6644
|
if (!pending) {
|
|
6629
|
-
pending = loadSchema(
|
|
6645
|
+
pending = loadSchema(resolved, context2);
|
|
6630
6646
|
context2.cache.set(key, pending);
|
|
6631
6647
|
}
|
|
6632
6648
|
return pending;
|
|
6633
6649
|
}
|
|
6634
|
-
function cachedCompile(
|
|
6635
|
-
const key = `${sourceKey(
|
|
6650
|
+
function cachedCompile(resolved, exportName, settings, context2) {
|
|
6651
|
+
const key = `${sourceKey(resolved)}#${exportName ?? ""}`;
|
|
6636
6652
|
if (context2.compiled.has(key)) return context2.compiled.get(key);
|
|
6637
6653
|
const compiled = compileSettings(settings);
|
|
6638
6654
|
context2.compiled.set(key, compiled);
|
|
6639
6655
|
return compiled;
|
|
6640
6656
|
}
|
|
6641
|
-
async function checkStepSettings(target, resolvedFlow,
|
|
6657
|
+
async function checkStepSettings(target, resolvedFlow, check, context2) {
|
|
6642
6658
|
const at = `flows.${target.flow}.${target.section}.${target.key}`;
|
|
6643
6659
|
const outcome = { findings: [], skipped: [], deferred: [] };
|
|
6644
6660
|
const spec = typeof target.entry.package === "string" ? target.entry.package : "";
|
|
@@ -6651,33 +6667,51 @@ async function checkStepSettings(target, resolvedFlow, rawFlow, check, context2)
|
|
|
6651
6667
|
});
|
|
6652
6668
|
return outcome;
|
|
6653
6669
|
}
|
|
6654
|
-
|
|
6670
|
+
let resolved;
|
|
6671
|
+
try {
|
|
6672
|
+
resolved = resolveStepPackage(
|
|
6673
|
+
resolvedFlow,
|
|
6674
|
+
SECTION_KIND[target.section],
|
|
6675
|
+
target.key,
|
|
6676
|
+
LOGGER
|
|
6677
|
+
);
|
|
6678
|
+
} catch (error) {
|
|
6679
|
+
outcome.skipped.push({
|
|
6680
|
+
path: at,
|
|
6681
|
+
check,
|
|
6682
|
+
reason: `Schema for ${spec} could not be loaded: ${getErrorMessage3(error)}`,
|
|
6683
|
+
code: "SCHEMA_UNAVAILABLE"
|
|
6684
|
+
});
|
|
6685
|
+
return outcome;
|
|
6686
|
+
}
|
|
6687
|
+
const { label } = resolved;
|
|
6688
|
+
const pinned = resolved.spec.path === void 0 ? resolved.spec.version : void 0;
|
|
6655
6689
|
let schema;
|
|
6656
6690
|
try {
|
|
6657
|
-
schema = await cachedSchema(
|
|
6691
|
+
schema = await cachedSchema(resolved, context2);
|
|
6658
6692
|
} catch (error) {
|
|
6659
6693
|
outcome.skipped.push({
|
|
6660
6694
|
path: at,
|
|
6661
6695
|
check,
|
|
6662
|
-
reason: `Schema for ${
|
|
6696
|
+
reason: `Schema for ${label}${pinned ? `@${pinned}` : ""} could not be loaded: ${getErrorMessage3(error)}`,
|
|
6663
6697
|
code: "SCHEMA_UNAVAILABLE"
|
|
6664
6698
|
});
|
|
6665
6699
|
return outcome;
|
|
6666
6700
|
}
|
|
6667
6701
|
outcome.checked = {
|
|
6668
6702
|
path: at,
|
|
6669
|
-
package:
|
|
6703
|
+
package: label,
|
|
6670
6704
|
...schema.version ? { version: schema.version } : {}
|
|
6671
6705
|
};
|
|
6672
6706
|
const { exportName } = resolveExportName(
|
|
6673
|
-
|
|
6707
|
+
resolved.normalizedFlow,
|
|
6674
6708
|
SECTION_KIND[target.section],
|
|
6675
6709
|
target.key
|
|
6676
6710
|
);
|
|
6677
|
-
const version = schema.version ??
|
|
6711
|
+
const version = schema.version ?? pinned;
|
|
6678
6712
|
const selection = selectSettingsSchema(
|
|
6679
6713
|
schema,
|
|
6680
|
-
version ? `${
|
|
6714
|
+
version ? `${label}@${version}` : label,
|
|
6681
6715
|
exportName
|
|
6682
6716
|
);
|
|
6683
6717
|
if (!selection.ok) {
|
|
@@ -6690,7 +6724,7 @@ async function checkStepSettings(target, resolvedFlow, rawFlow, check, context2)
|
|
|
6690
6724
|
return outcome;
|
|
6691
6725
|
}
|
|
6692
6726
|
const compiled = cachedCompile(
|
|
6693
|
-
|
|
6727
|
+
resolved,
|
|
6694
6728
|
exportName,
|
|
6695
6729
|
selection.settings,
|
|
6696
6730
|
context2
|
|
@@ -6699,7 +6733,7 @@ async function checkStepSettings(target, resolvedFlow, rawFlow, check, context2)
|
|
|
6699
6733
|
outcome.skipped.push({
|
|
6700
6734
|
path: at,
|
|
6701
6735
|
check,
|
|
6702
|
-
reason: `Package ${
|
|
6736
|
+
reason: `Package ${label} has no settings schema`,
|
|
6703
6737
|
code: "NO_SETTINGS_SCHEMA"
|
|
6704
6738
|
});
|
|
6705
6739
|
return outcome;
|
|
@@ -6708,14 +6742,14 @@ async function checkStepSettings(target, resolvedFlow, rawFlow, check, context2)
|
|
|
6708
6742
|
outcome.skipped.push({
|
|
6709
6743
|
path: at,
|
|
6710
6744
|
check,
|
|
6711
|
-
reason: `The settings schema of ${
|
|
6745
|
+
reason: `The settings schema of ${label} cannot be compiled: ${compiled.message}`,
|
|
6712
6746
|
code: "SCHEMA_UNAVAILABLE"
|
|
6713
6747
|
});
|
|
6714
6748
|
return outcome;
|
|
6715
6749
|
}
|
|
6716
6750
|
const validate2 = compiled.validate;
|
|
6717
6751
|
const step = stepOf(resolvedFlow, target.section, target.key);
|
|
6718
|
-
const config =
|
|
6752
|
+
const config = isObject8(step?.config) ? step.config : {};
|
|
6719
6753
|
const prepared = prepareSettings(config.settings ?? {});
|
|
6720
6754
|
const base = `${at}.config.settings`;
|
|
6721
6755
|
for (const { segments, reference } of prepared.deferred) {
|
|
@@ -6796,18 +6830,12 @@ async function validateFlowWithPackages(input, options = {}) {
|
|
|
6796
6830
|
continue;
|
|
6797
6831
|
}
|
|
6798
6832
|
for (const section of ENTRY_SECTIONS) {
|
|
6799
|
-
const steps =
|
|
6833
|
+
const steps = isObject9(rawFlow[section]) ? rawFlow[section] : {};
|
|
6800
6834
|
for (const [key, entry] of Object.entries(steps)) {
|
|
6801
|
-
if (!
|
|
6835
|
+
if (!isObject9(entry) || entry.package === void 0) continue;
|
|
6802
6836
|
const target = { flow: name, section, key, entry };
|
|
6803
6837
|
pending.push(
|
|
6804
|
-
checkStepSettings(
|
|
6805
|
-
target,
|
|
6806
|
-
flow,
|
|
6807
|
-
rawFlow,
|
|
6808
|
-
"flow:package-settings",
|
|
6809
|
-
context2
|
|
6810
|
-
)
|
|
6838
|
+
checkStepSettings(target, flow, "flow:package-settings", context2)
|
|
6811
6839
|
);
|
|
6812
6840
|
}
|
|
6813
6841
|
}
|
|
@@ -6862,9 +6890,9 @@ function runFlowChecks(input, options) {
|
|
|
6862
6890
|
};
|
|
6863
6891
|
}
|
|
6864
6892
|
errors.push(...scope.errors);
|
|
6865
|
-
const config =
|
|
6893
|
+
const config = isObject9(input) ? input : {};
|
|
6866
6894
|
const flowsValue = config.flows;
|
|
6867
|
-
const flows =
|
|
6895
|
+
const flows = isObject9(flowsValue) ? flowsValue : void 0;
|
|
6868
6896
|
const allFlows = scope.allFlows;
|
|
6869
6897
|
const inScope = (path23) => {
|
|
6870
6898
|
const flow = flowOfPath(path23, allFlows);
|
|
@@ -6907,13 +6935,13 @@ function runFlowChecks(input, options) {
|
|
|
6907
6935
|
checks.push("flow:steps");
|
|
6908
6936
|
for (const flowName of scope.flows) {
|
|
6909
6937
|
const flowValue = flows?.[flowName];
|
|
6910
|
-
if (!
|
|
6938
|
+
if (!isObject9(flowValue)) continue;
|
|
6911
6939
|
const transformersValue = flowValue.transformers;
|
|
6912
|
-
if (
|
|
6940
|
+
if (isObject9(transformersValue)) {
|
|
6913
6941
|
for (const [name, transformerValue] of Object.entries(
|
|
6914
6942
|
transformersValue
|
|
6915
6943
|
)) {
|
|
6916
|
-
if (!
|
|
6944
|
+
if (!isObject9(transformerValue)) continue;
|
|
6917
6945
|
const result2 = validateStepEntry(transformerValue, "Transformer");
|
|
6918
6946
|
if (!result2.ok) {
|
|
6919
6947
|
errors.push({
|
|
@@ -6926,9 +6954,9 @@ function runFlowChecks(input, options) {
|
|
|
6926
6954
|
}
|
|
6927
6955
|
for (const [section, kind] of STEP_KINDS2) {
|
|
6928
6956
|
const steps = flowValue[section];
|
|
6929
|
-
if (!
|
|
6957
|
+
if (!isObject9(steps)) continue;
|
|
6930
6958
|
for (const [name, step] of Object.entries(steps)) {
|
|
6931
|
-
if (!
|
|
6959
|
+
if (!isObject9(step)) continue;
|
|
6932
6960
|
const at = `flows.${flowName}.${section}.${name}`;
|
|
6933
6961
|
errors.push(...checkStepKeys(step, kind, at));
|
|
6934
6962
|
const pkg = step.package;
|
|
@@ -6951,15 +6979,15 @@ function runFlowChecks(input, options) {
|
|
|
6951
6979
|
let totalPackageCount = 0;
|
|
6952
6980
|
for (const flowName of scope.flows) {
|
|
6953
6981
|
const flowValue = flows?.[flowName];
|
|
6954
|
-
if (!
|
|
6982
|
+
if (!isObject9(flowValue)) continue;
|
|
6955
6983
|
const flowConfig = flowValue.config;
|
|
6956
|
-
if (!
|
|
6984
|
+
if (!isObject9(flowConfig)) continue;
|
|
6957
6985
|
const bundle2 = flowConfig.bundle;
|
|
6958
|
-
if (!
|
|
6986
|
+
if (!isObject9(bundle2)) continue;
|
|
6959
6987
|
const packages = bundle2.packages;
|
|
6960
|
-
if (!
|
|
6988
|
+
if (!isObject9(packages)) continue;
|
|
6961
6989
|
for (const [pkgName, pkgConfigValue] of Object.entries(packages)) {
|
|
6962
|
-
if (!
|
|
6990
|
+
if (!isObject9(pkgConfigValue)) continue;
|
|
6963
6991
|
if (!pkgConfigValue.version && !pkgConfigValue.path) {
|
|
6964
6992
|
warnings.push({
|
|
6965
6993
|
path: `flows.${flowName}.config.bundle.packages.${pkgName}`,
|
|
@@ -7047,13 +7075,13 @@ function runFlowChecks(input, options) {
|
|
|
7047
7075
|
warnings,
|
|
7048
7076
|
options.strict === true,
|
|
7049
7077
|
skipped,
|
|
7050
|
-
|
|
7078
|
+
isObject9(resolvedConfig) && isObject9(resolvedConfig.settings) ? resolvedConfig.settings : void 0
|
|
7051
7079
|
);
|
|
7052
7080
|
}
|
|
7053
7081
|
for (const [destName, dest] of Object.entries(flow.destinations || {})) {
|
|
7054
|
-
if (!
|
|
7082
|
+
if (!isObject9(dest.config)) continue;
|
|
7055
7083
|
const mapping = dest.config.mapping;
|
|
7056
|
-
if (!
|
|
7084
|
+
if (!isObject9(mapping)) continue;
|
|
7057
7085
|
for (const key of Object.keys(mapping)) {
|
|
7058
7086
|
if (key.includes(".") && !key.includes(" ")) {
|
|
7059
7087
|
const parts = key.split(".");
|
|
@@ -7114,16 +7142,16 @@ function checkResolvedWindowCollector(name, raw, flow, errors, deferred) {
|
|
|
7114
7142
|
});
|
|
7115
7143
|
}
|
|
7116
7144
|
function checkWebLoggerFormat(flowName, flow, errors) {
|
|
7117
|
-
if (!
|
|
7145
|
+
if (!isObject9(flow.config) || flow.config.platform !== "web") return;
|
|
7118
7146
|
const at = `flows.${flowName}`;
|
|
7119
7147
|
const loggers = [];
|
|
7120
|
-
if (
|
|
7148
|
+
if (isObject9(flow.collector))
|
|
7121
7149
|
loggers.push([`${at}.collector.logger`, flow.collector.logger]);
|
|
7122
7150
|
for (const [section] of STEP_KINDS2) {
|
|
7123
7151
|
const steps = flow[section];
|
|
7124
|
-
if (!
|
|
7152
|
+
if (!isObject9(steps)) continue;
|
|
7125
7153
|
for (const [name, step] of Object.entries(steps)) {
|
|
7126
|
-
if (
|
|
7154
|
+
if (isObject9(step) && isObject9(step.config))
|
|
7127
7155
|
loggers.push([
|
|
7128
7156
|
`${at}.${section}.${name}.config.logger`,
|
|
7129
7157
|
step.config.logger
|
|
@@ -7131,7 +7159,7 @@ function checkWebLoggerFormat(flowName, flow, errors) {
|
|
|
7131
7159
|
}
|
|
7132
7160
|
}
|
|
7133
7161
|
for (const [path23, logger] of loggers) {
|
|
7134
|
-
if (!
|
|
7162
|
+
if (!isObject9(logger) || logger.format === void 0) continue;
|
|
7135
7163
|
errors.push({
|
|
7136
7164
|
path: `${path23}.format`,
|
|
7137
7165
|
message: "logger.format applies to server flows only: a web flow logs to the browser console, which has no output format. Remove it.",
|
|
@@ -7236,21 +7264,21 @@ function isStepOut(value) {
|
|
|
7236
7264
|
return Array.isArray(value) && value.every((entry) => Array.isArray(entry) && typeof entry[0] === "string");
|
|
7237
7265
|
}
|
|
7238
7266
|
function returnedEvents(value) {
|
|
7239
|
-
if (
|
|
7267
|
+
if (isObject9(value)) return [isObject9(value.event) ? value.event : value];
|
|
7240
7268
|
if (Array.isArray(value)) return value.flatMap(returnedEvents);
|
|
7241
7269
|
return [];
|
|
7242
7270
|
}
|
|
7243
7271
|
function outEvents(out) {
|
|
7244
7272
|
if (isStepOut(out)) {
|
|
7245
7273
|
return out.flatMap(([head, first]) => {
|
|
7246
|
-
if (head === "elb") return
|
|
7274
|
+
if (head === "elb") return isObject9(first) ? [first] : [];
|
|
7247
7275
|
if (head === "return") return returnedEvents(first);
|
|
7248
7276
|
return [];
|
|
7249
7277
|
});
|
|
7250
7278
|
}
|
|
7251
7279
|
if (Array.isArray(out) || typeof out === "string")
|
|
7252
7280
|
return out.length > 0 ? [out] : [];
|
|
7253
|
-
return
|
|
7281
|
+
return isObject9(out) && Object.keys(out).length > 0 ? [out] : [];
|
|
7254
7282
|
}
|
|
7255
7283
|
function hasComparableOut(out) {
|
|
7256
7284
|
return outEvents(out).length > 0;
|
|
@@ -7292,7 +7320,7 @@ function routeAt(spec, path23) {
|
|
|
7292
7320
|
for (const key of path23) {
|
|
7293
7321
|
if (typeof key === "number")
|
|
7294
7322
|
current = Array.isArray(current) ? current[key] : void 0;
|
|
7295
|
-
else current =
|
|
7323
|
+
else current = isObject9(current) ? current[key] : void 0;
|
|
7296
7324
|
}
|
|
7297
7325
|
return current;
|
|
7298
7326
|
}
|
|
@@ -7317,7 +7345,7 @@ function lintRoute(spec, position, known, errors, warnings) {
|
|
|
7317
7345
|
if (node.stop && !node.match && node.kind !== "many") {
|
|
7318
7346
|
const self = routeAt(spec, node.path);
|
|
7319
7347
|
const list = routeAt(spec, node.path.slice(0, -1));
|
|
7320
|
-
if (
|
|
7348
|
+
if (isObject9(self) && self.stop === true && typeof last === "number" && Array.isArray(list) && last < list.length - 1 && once2(`stop:${where(node.path)}`)) {
|
|
7321
7349
|
const at = where(node.path);
|
|
7322
7350
|
warnings.push({
|
|
7323
7351
|
path: at,
|
|
@@ -7369,7 +7397,7 @@ function hasRuntimeValue(value) {
|
|
|
7369
7397
|
if (typeof value === "string")
|
|
7370
7398
|
return value.includes(ENV_MARKER_PREFIX3) || value.startsWith(SECRET_MARKER_PREFIX4) || /\$(?:env|secret)\./.test(value);
|
|
7371
7399
|
if (Array.isArray(value)) return value.some(hasRuntimeValue);
|
|
7372
|
-
return
|
|
7400
|
+
return isObject9(value) && Object.values(value).some(hasRuntimeValue);
|
|
7373
7401
|
}
|
|
7374
7402
|
var VALIDATE_PACKAGE = "@walkeros/transformer-validate";
|
|
7375
7403
|
function isValidateStep(step) {
|
|
@@ -7389,7 +7417,7 @@ function resolveStepContracts(entries, contract) {
|
|
|
7389
7417
|
}
|
|
7390
7418
|
const sources = [];
|
|
7391
7419
|
for (const [index, entry] of entries.entries()) {
|
|
7392
|
-
if (
|
|
7420
|
+
if (isObject9(entry)) {
|
|
7393
7421
|
sources.push(entry);
|
|
7394
7422
|
continue;
|
|
7395
7423
|
}
|
|
@@ -7407,7 +7435,7 @@ function resolveStepContracts(entries, contract) {
|
|
|
7407
7435
|
message: `contract "${match[1]}" is not defined in the root contract (defined: ${Object.keys(resolved).join(", ") || "none"})`
|
|
7408
7436
|
};
|
|
7409
7437
|
const rule = match[2] ? getByPath(resolved[match[1]], match[2]) : resolved[match[1]];
|
|
7410
|
-
if (!
|
|
7438
|
+
if (!isObject9(rule))
|
|
7411
7439
|
return {
|
|
7412
7440
|
ok: false,
|
|
7413
7441
|
index,
|
|
@@ -7418,7 +7446,7 @@ function resolveStepContracts(entries, contract) {
|
|
|
7418
7446
|
return { ok: true, sources };
|
|
7419
7447
|
}
|
|
7420
7448
|
function checkValidateStepExamples(stepPath, step, contract, errors, warnings, strict, skipped, resolvedSettings) {
|
|
7421
|
-
const settings = resolvedSettings ?? (
|
|
7449
|
+
const settings = resolvedSettings ?? (isObject9(step.config) && isObject9(step.config.settings) ? step.config.settings : {});
|
|
7422
7450
|
const contractPath = `${stepPath}.config.settings.contract`;
|
|
7423
7451
|
if (settings.contract !== void 0 && !Array.isArray(settings.contract)) {
|
|
7424
7452
|
if (step.examples)
|
|
@@ -7452,10 +7480,10 @@ function checkValidateStepExamples(stepPath, step, contract, errors, warnings, s
|
|
|
7452
7480
|
}
|
|
7453
7481
|
const mode = settings.mode === "strict" ? "strict" : "pass";
|
|
7454
7482
|
const format = settings.format === true;
|
|
7455
|
-
const output =
|
|
7483
|
+
const output = isObject9(settings.output) ? settings.output : {};
|
|
7456
7484
|
const isValidPath = typeof output.isValid === "string" ? output.isValid : "source.valid";
|
|
7457
7485
|
for (const [exName, example] of Object.entries(step.examples)) {
|
|
7458
|
-
if (example.command || !
|
|
7486
|
+
if (example.command || !isObject9(example.in)) continue;
|
|
7459
7487
|
if (example.out === void 0) continue;
|
|
7460
7488
|
const event = example.in;
|
|
7461
7489
|
const verdict = validateEventAgainstContract(event, void 0, {
|
|
@@ -7493,14 +7521,14 @@ function checkValidateStepExamples(stepPath, step, contract, errors, warnings, s
|
|
|
7493
7521
|
}
|
|
7494
7522
|
|
|
7495
7523
|
// src/commands/validate/validators/mapping.ts
|
|
7496
|
-
import { isObject as
|
|
7524
|
+
import { isObject as isObject10 } from "@walkeros/core";
|
|
7497
7525
|
import { schemas as schemas5 } from "@walkeros/core/dev";
|
|
7498
7526
|
var { RuleSchema } = schemas5.MappingSchemas;
|
|
7499
7527
|
function isRule(value) {
|
|
7500
|
-
return
|
|
7528
|
+
return isObject10(value) && RuleSchema.safeParse(value).success;
|
|
7501
7529
|
}
|
|
7502
7530
|
function isNestedActions(key, value) {
|
|
7503
|
-
if (key.includes(" ") || !
|
|
7531
|
+
if (key.includes(" ") || !isObject10(value)) return false;
|
|
7504
7532
|
const rules = Object.values(value);
|
|
7505
7533
|
return rules.length > 0 && rules.every(
|
|
7506
7534
|
(rule) => Array.isArray(rule) ? rule.length > 0 && rule.every(isRule) : isRule(rule)
|
|
@@ -7510,7 +7538,7 @@ function validateMapping(input) {
|
|
|
7510
7538
|
const errors = [];
|
|
7511
7539
|
const warnings = [];
|
|
7512
7540
|
const details = {};
|
|
7513
|
-
if (!
|
|
7541
|
+
if (!isObject10(input)) {
|
|
7514
7542
|
errors.push({
|
|
7515
7543
|
path: "root",
|
|
7516
7544
|
message: "Mapping must be an object with event patterns as keys",
|
|
@@ -7599,7 +7627,6 @@ async function validateEntry(path23, flowConfig, options = {}) {
|
|
|
7599
7627
|
const outcome = await checkStepSettings(
|
|
7600
7628
|
target,
|
|
7601
7629
|
resolution.flow,
|
|
7602
|
-
file?.flows[target.flow],
|
|
7603
7630
|
"entry:settings",
|
|
7604
7631
|
context2
|
|
7605
7632
|
);
|
|
@@ -7740,7 +7767,7 @@ function inapplicableOptions(type, options) {
|
|
|
7740
7767
|
}
|
|
7741
7768
|
function validateContractInput(input) {
|
|
7742
7769
|
if (!isFlowJson2(input)) return validateContract(input);
|
|
7743
|
-
const contract =
|
|
7770
|
+
const contract = isObject11(input) ? input.contract : void 0;
|
|
7744
7771
|
if (contract === void 0) {
|
|
7745
7772
|
return {
|
|
7746
7773
|
valid: false,
|