@kaelen-ai/cli 0.1.18 → 0.1.19
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/dist/index.js +64 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -861,6 +861,16 @@ var SECRET_HEADER_NAMES = /* @__PURE__ */ new Set([
|
|
|
861
861
|
]);
|
|
862
862
|
var HTTP_LIKE_KINDS = /* @__PURE__ */ new Set(["http", "graphql", "httpApi", "graphqlApi"]);
|
|
863
863
|
var OP_RESOURCE_KINDS = /* @__PURE__ */ new Set(["httpApi", "graphqlApi"]);
|
|
864
|
+
var PRINCIPAL_RESOLUTION_MATCHES = /* @__PURE__ */ new Set(["principal_id", "external_id"]);
|
|
865
|
+
var WEBHOOK_PRINCIPAL_SOURCES = /* @__PURE__ */ new Set(["body", "headers", "query"]);
|
|
866
|
+
var QUEUE_PRINCIPAL_SOURCES = /* @__PURE__ */ new Set(["message", "attributes"]);
|
|
867
|
+
var PRINCIPAL_BOUND_QUEUE_KINDS = /* @__PURE__ */ new Set([
|
|
868
|
+
"kafka",
|
|
869
|
+
"rabbitmq",
|
|
870
|
+
"redis",
|
|
871
|
+
"pubsub",
|
|
872
|
+
"sqs"
|
|
873
|
+
]);
|
|
864
874
|
function countPlaceholders(format) {
|
|
865
875
|
let count = 0;
|
|
866
876
|
let idx = 0;
|
|
@@ -1058,6 +1068,51 @@ function validateHttpLikeConfig(appName, resourceName, resourceKind, config, sec
|
|
|
1058
1068
|
}
|
|
1059
1069
|
}
|
|
1060
1070
|
}
|
|
1071
|
+
function validatePrincipalResolution(appName, resourceName, resourceKind, signals2, config, errors) {
|
|
1072
|
+
const requiresPrincipalResolution = resourceKind === "webhook" || PRINCIPAL_BOUND_QUEUE_KINDS.has(resourceKind) && signals2.length > 0;
|
|
1073
|
+
if (!requiresPrincipalResolution) return;
|
|
1074
|
+
const owner = `resource "${appName}/${resourceName}"`;
|
|
1075
|
+
if (!isRecord2(config)) {
|
|
1076
|
+
errors.push(`${owner} config must be an object with principal_resolution`);
|
|
1077
|
+
return;
|
|
1078
|
+
}
|
|
1079
|
+
const rule = config.principal_resolution;
|
|
1080
|
+
if (!isRecord2(rule)) {
|
|
1081
|
+
errors.push(`${owner} config.principal_resolution is required`);
|
|
1082
|
+
return;
|
|
1083
|
+
}
|
|
1084
|
+
const from = stringField2(rule, "from");
|
|
1085
|
+
const match = stringField2(rule, "match");
|
|
1086
|
+
const allowedSources = resourceKind === "webhook" ? WEBHOOK_PRINCIPAL_SOURCES : QUEUE_PRINCIPAL_SOURCES;
|
|
1087
|
+
if (!from || !allowedSources.has(from)) {
|
|
1088
|
+
errors.push(
|
|
1089
|
+
`${owner} principal_resolution.from must be one of ${Array.from(
|
|
1090
|
+
allowedSources
|
|
1091
|
+
).join(", ")}`
|
|
1092
|
+
);
|
|
1093
|
+
}
|
|
1094
|
+
if (!match || !PRINCIPAL_RESOLUTION_MATCHES.has(match)) {
|
|
1095
|
+
errors.push(
|
|
1096
|
+
`${owner} principal_resolution.match must be principal_id or external_id`
|
|
1097
|
+
);
|
|
1098
|
+
}
|
|
1099
|
+
if (from === "body" || from === "query" || from === "message") {
|
|
1100
|
+
if (!stringField2(rule, "path")) {
|
|
1101
|
+
errors.push(`${owner} principal_resolution.path is required for ${from}`);
|
|
1102
|
+
}
|
|
1103
|
+
if (rule.name !== void 0) {
|
|
1104
|
+
errors.push(`${owner} principal_resolution.name is not valid for ${from}`);
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
if (from === "headers" || from === "attributes") {
|
|
1108
|
+
if (!stringField2(rule, "name")) {
|
|
1109
|
+
errors.push(`${owner} principal_resolution.name is required for ${from}`);
|
|
1110
|
+
}
|
|
1111
|
+
if (rule.path !== void 0) {
|
|
1112
|
+
errors.push(`${owner} principal_resolution.path is not valid for ${from}`);
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1061
1116
|
function isRecord2(value) {
|
|
1062
1117
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
1063
1118
|
}
|
|
@@ -1426,6 +1481,14 @@ function validateManifest(manifest) {
|
|
|
1426
1481
|
validateResourceCapability(appName, resourceName, capability, errors);
|
|
1427
1482
|
}
|
|
1428
1483
|
const resourceKindForConfig = stringField2(resource, "kind") ?? "";
|
|
1484
|
+
validatePrincipalResolution(
|
|
1485
|
+
appName,
|
|
1486
|
+
resourceName,
|
|
1487
|
+
resourceKindForConfig,
|
|
1488
|
+
signals2,
|
|
1489
|
+
resource.config,
|
|
1490
|
+
errors
|
|
1491
|
+
);
|
|
1429
1492
|
validateHttpLikeConfig(
|
|
1430
1493
|
appName,
|
|
1431
1494
|
resourceName,
|
|
@@ -6717,7 +6780,7 @@ async function catalogShowCommand(options) {
|
|
|
6717
6780
|
|
|
6718
6781
|
// src/index.ts
|
|
6719
6782
|
var program = new Command();
|
|
6720
|
-
program.name("io").description("IO CLI \u2014 build and deploy behaviors").version("0.1.
|
|
6783
|
+
program.name("io").description("IO CLI \u2014 build and deploy behaviors").version("0.1.19");
|
|
6721
6784
|
program.command("init").description("Initialize io.config.json for the current project").option("--yes", "Overwrite existing config without prompting").action(initCommand);
|
|
6722
6785
|
program.command("build").description("Build behaviors from the io/ directory").option("--dir <path>", "Source directory", "io").option("--minify", "Minify bundles", false).action(buildCommand);
|
|
6723
6786
|
program.command("deploy").description("Build and package for deployment").option("--dir <path>", "Source directory", "io").option("--no-minify", "Skip minification").option("--yes", "Skip confirmation prompt").option("--watch", "Tail deployment status until it reaches a terminal state").action(deployCommand);
|